Example #1
0
 /**
  * Parse Gmail responses.
  *
  * @access private
  * @static
  * @return bool 
  * @param string $raw_html
  * @since 7 Jun 2005
  */
 function parse_gmail_response($raw_html, $non_standard = false)
 {
     $raw_html = str_replace("\n", "", $raw_html);
     $raw_html = str_replace("D([", "\nD([", $raw_html);
     $raw_html = str_replace("]);", "]);\n", $raw_html);
     // Fix Gmail's conversion of = and /; by Neerav; 18 Dec 2005
     // Added < and >; by Neerav; 4 Mar 2007
     $raw_html = str_replace(array('u003d', 'u002f', 'u003c', 'u003e'), array('=', '/', '<', '>'), $raw_html);
     $regexp = !$non_standard ? "|D\\(\\[(.*)\\]\\);|U" : "/\\[(.*)\\]/";
     $matches = "";
     preg_match_all($regexp, $raw_html, $matches, PREG_SET_ORDER);
     $packets = array();
     for ($i = 0; $i < count($matches); $i++) {
         $off = 0;
         $tmp = GMailer::parse_data_packet("[" . $matches[$i][1] . "]", $off);
         if (array_key_exists($tmp[0], $packets) || ($tmp[0] == "mi" || $tmp[0] == "mb" || $tmp[0] == "di")) {
             // Added cl as alternate contact datapack; by Neerav; 15 June 2005
             if ($tmp[0] == "t" || $tmp[0] == "ts" || $tmp[0] == "a" || $tmp[0] == "cl") {
                 $packets[$tmp[0]] = array_merge($packets[$tmp[0]], array_slice($tmp, 1));
             }
             if ($tmp[0] == "mi" || $tmp[0] == "mb" || $tmp[0] == "di") {
                 if (array_key_exists("mg", $packets)) {
                     array_push($packets["mg"], $tmp);
                 } else {
                     $packets["mg"] = array($tmp);
                 }
             }
         } else {
             $packets[$tmp[0]] = $tmp;
         }
     }
     $this->raw = $packets;
     return 1;
 }
 /**
  * Parse status replies.
  *
  * @access private
  * @static
  * @return bool 
  * @param string $raw_html
  * @author Neerav
  * @since 7 Jun 2005
  */
 function status_message($raw_html)
 {
     Debugger::say("Begin parsing status...");
     $raw_html = str_replace("\n", "", $raw_html);
     $raw_html = str_replace("D([", "\nD([", $raw_html);
     $raw_html = str_replace("]);", "]);\n", $raw_html);
     $regexp = "|D\\(\\[(.*)\\]\\);|U";
     $matches = "";
     preg_match_all($regexp, $raw_html, $matches, PREG_SET_ORDER);
     $packets = array();
     for ($i = 0; $i < count($matches); $i++) {
         $off = 0;
         $tmp = GMailer::parse_data_packet("[" . $matches[$i][1] . "]", $off);
         if (array_key_exists($tmp[0], $packets) || ($tmp[0] == "mi" || $tmp[0] == "mb" || $tmp[0] == "di")) {
             if ($tmp[0] == "t" || $tmp[0] == "ts" || $tmp[0] == "a" || $tmp[0] == "cl") {
                 $packets[$tmp[0]] = array_merge($packets[$tmp[0]], array_slice($tmp, 1));
             }
             if ($tmp[0] == "mi" || $tmp[0] == "mb" || $tmp[0] == "di") {
                 if (array_key_exists("mg", $packets)) {
                     array_push($packets["mg"], $tmp);
                 } else {
                     $packets["mg"] = array($tmp);
                 }
             }
         } else {
             $packets[$tmp[0]] = $tmp;
         }
     }
     $this->raw = $packets;
     Debugger::say("Status parsing completed.");
     return 1;
 }
Example #3
0
 /**
  * Parse Gmail responses.
  *
  * @access private
  * @static
  * @return bool 
  * @param string $raw_html
  * @since 7 Jun 2005
  */
 function parse_gmail_response($raw_html)
 {
     $raw_html = str_replace("\n", "", $raw_html);
     $raw_html = str_replace("D([", "\nD([", $raw_html);
     $raw_html = str_replace("]);", "]);\n", $raw_html);
     // Fix Gmail's conversion of = and /; by Neerav; 18 Dec 2005
     $raw_html = str_replace(array('u003d', 'u002f'), array('=', '/'), $raw_html);
     /* 		$raw_html = preg_replace(array('/(<[^>]*?u003d[^>]*?'.'>)/e'),array('str_replace("u003d","=",\1)'),$raw_html); */
     /* 		$raw_html = str_replace(array('\\\\u003d\\\\','\\\\u002f\\\\'),array('=','/'),$raw_html); */
     /* 		$raw_html = preg_replace(array('/(<[^>]*?u003d[^>]*?'.'>)/e'),array('str_replace("u003d","=",\1)'),$raw_html); */
     /* 		$raw_html = preg_replace('/(\w)u003d\"/','\\1=\\2',&$raw_html); */
     /* 		$raw_html = str_replace(array('u003d\"','u002f'),array('=\"','/'),$raw_html); */
     /* 		$raw_html = preg_replace(array('/(<[^>]*?)u003d/'),array('\\1='),$raw_html); */
     $regexp = "|D\\(\\[(.*)\\]\\);|U";
     $matches = "";
     preg_match_all($regexp, $raw_html, $matches, PREG_SET_ORDER);
     $packets = array();
     for ($i = 0; $i < count($matches); $i++) {
         $off = 0;
         $tmp = GMailer::parse_data_packet("[" . $matches[$i][1] . "]", $off);
         if (array_key_exists($tmp[0], $packets) || ($tmp[0] == "mi" || $tmp[0] == "mb" || $tmp[0] == "di")) {
             // Added cl as alternate contact datapack; by Neerav; 15 June 2005
             if ($tmp[0] == "t" || $tmp[0] == "ts" || $tmp[0] == "a" || $tmp[0] == "cl") {
                 $packets[$tmp[0]] = array_merge($packets[$tmp[0]], array_slice($tmp, 1));
             }
             if ($tmp[0] == "mi" || $tmp[0] == "mb" || $tmp[0] == "di") {
                 if (array_key_exists("mg", $packets)) {
                     array_push($packets["mg"], $tmp);
                 } else {
                     $packets["mg"] = array($tmp);
                 }
             }
         } else {
             $packets[$tmp[0]] = $tmp;
         }
     }
     $this->raw = $packets;
     return 1;
 }
Example #4
0
 /**
  * Parse Gmail responses.
  *
  * @access private
  * @static
  * @return bool 
  * @param string $raw_html
  * @since 7 Jun 2005
  */
 function parse_gmail_response($raw_html, $non_standard = false)
 {
     //Debugger::say(basename(__FILE__).": ".__LINE__.": "."parse_gmail_response(): start:\n".print_r($raw_html,true));
     $raw_html = str_replace("\n", "", $raw_html);
     /* 		$raw_html = str_replace("D([", "\nD([", $raw_html); */
     /* 		$raw_html = str_replace("]);", "]);\n", $raw_html); */
     // combined multiple str_replace into one; Neerav; 12 Sept 2007
     $raw_html = str_replace(array("D([", "]);"), array("\nD([", "]);\n"), $raw_html);
     // Fix Gmail's conversion of = and /; by Neerav; 18 Dec 2005
     // Added < and >; by Neerav; 4 Mar 2007
     // Added \> (Gmail is doing something wierd); Neerav; 12 Sept 2007
     // Added &; Neerav; 10 Dec 2007
     $raw_html = str_replace(array('\\u003d', '\\u002f', '\\u003c', '\\u003e', '\\>', '\\u0026'), array('=', '/', '<', '>', '>', '&'), $raw_html);
     //Debugger::say(basename(__FILE__).": ".__LINE__.": "."parse_gmail_response(): cleaned:\n".print_r($raw_html,true));
     /* 		// combined multiple str_replace into one; Neerav; 12 Sept 2007 */
     /* 		$raw_html = str_replace(array("D([","]);",'u003d','u002f','u003c','u003e'), array("\nD([","]);\n",'=','/','<','>'), $raw_html); */
     $regexp = !$non_standard ? "|D\\(\\[(.*)\\]\\);|U" : "/\\[(.*)\\]/";
     $matches = "";
     preg_match_all($regexp, $raw_html, $matches, PREG_SET_ORDER);
     $packets = array();
     $matches_count = count($matches);
     for ($i = 0; $i < $matches_count; $i++) {
         $off = 0;
         //Debugger::say(basename(__FILE__).": ".__LINE__.": "."parse_gmail_response(): match(pre parse_data_packet):\n".print_r($matches[$i][1],true));
         $tmp = GMailer::parse_data_packet("[" . $matches[$i][1] . "]", $off);
         //Debugger::say(basename(__FILE__).": ".__LINE__.": "."parse_gmail_response(): parsed(post parse_data_packet):\n".print_r($tmp,true));
         if (array_key_exists($tmp[0], $packets) || ($tmp[0] == "mi" || $tmp[0] == "mb" || $tmp[0] == "di")) {
             // Added cl as alternate contact datapack; by Neerav; 15 June 2005
             if ($tmp[0] == "t" || $tmp[0] == "ts" || $tmp[0] == "a" || $tmp[0] == "cl") {
                 $packets[$tmp[0]] = array_merge($packets[$tmp[0]], array_slice($tmp, 1));
             }
             if ($tmp[0] == "mi" || $tmp[0] == "mb" || $tmp[0] == "di") {
                 if (array_key_exists("mg", $packets)) {
                     array_push($packets["mg"], $tmp);
                 } else {
                     $packets["mg"] = array($tmp);
                 }
             }
         } else {
             $packets[$tmp[0]] = $tmp;
         }
     }
     $this->raw = $packets;
     //Debugger::say(basename(__FILE__).": ".__LINE__.": "."parse_gmail_response(): raw packets:\n".print_r($this->raw,true));
     return 1;
 }