示例#1
0
 /**
  * Change Gmail Language
  *
  * @return bool Success or not.
  * @param string $old_lang Current language
  * @param string $new_lang New language
  * @author Neerav
  * @since 27 Nov 2005
  */
 function changeLanguage($new_lang, $old_lang = "")
 {
     if ($this->isConnected()) {
         $query = "";
         $refer = "";
         //$query .= "&ik=".IKVALUE;
         $query .= "&view=lpc&gfl=" . ($old_lang != "" ? $old_lang : "en") . "&gtl=" . $new_lang;
         //$refer .= "&ik=".IKVALUE;
         $refer .= "&view=pr&pnl=g";
         $refer .= $this->proxy_defeat();
         // to fool proxy
         $this->gmail_data = GMailer::execute_curl(GM_LNK_GMAIL . "?" . $query, GM_LNK_GMAIL . "?" . $refer, 'get');
         //S=gmail=j8lv94EXSjI:gmail_yj=Fs3UajIqvjY:gmproxy=ZwcQ86EuvyY;
         ereg("S=gmail=([^\\:]*):gmail_yj=([^\\:]*):gmproxy=([^\\;]*);", $this->gmail_data, $matches);
         /* 			//Debugger::say("cookie matches: ".print_r($matches,true));			 */
         $this->cookie_str = ereg_replace("S=gmail=([^\\:]*):gmail_yj=([^\\:]*):gmproxy=([^\\;]*);", "S=gmail=" . $matches[1] . ":gmail_yj=" . $matches[2] . ":gmproxy=" . $matches[3] . ";", $this->cookie_str);
         /* 			//Debugger::say("new cookie: ".print_r($this->cookie_str,true));			 */
         // save updated cookie
         GMailer::saveSessionToBrowser();
         // GMAIL DOES NOT RESPOND WITH A STATUS MESSAGE
         $a = array("action" => "change language", "status" => "success", "message" => "(no message)");
         array_unshift($this->return_status, $a);
         return true;
     } else {
         $a = array("action" => "change language", "status" => "failed", "message" => "libgmailer: not connected");
         array_unshift($this->return_status, $a);
         return false;
     }
 }
示例#2
0
 /**
  * Update Gmail cookie
  *
  * @return bool true
  * @param string raw HTML header
  * @access private
  * @static
  * @author Neerav
  * @since 19 Apr 2006
  */
 function update_cookies($data = "")
 {
     // completely rewritten (expanded, fixed); Neerav; 25 Jan 2007
     $new_cookies = GMailer::get_cookies($data);
     $parse_headers = $data == "" ? $this->gmail_data : $data;
     $replace_cookies = array("S", "GX", "GXAS_SEC", "GMAIL_AT", "GMAIL_HELP");
     //Debugger::say("new cookies: ".print_r($new_cookies,true));
     //Debugger::say("old cookie: ".print_r($this->cookie_str,true));
     //Debugger::say("set new cookies: ".print_r($parse_headers,true));
     foreach ($replace_cookies as $indexval => $cookie) {
         $matches = array();
         if (preg_match("/" . $cookie . "=([^;]*);/U", $parse_headers, $matches)) {
             //Debugger::say("cookie matches: ".print_r($matches,true));
             if (preg_match("/" . $cookie . "=([^;]*);/U", $this->cookie_str)) {
                 $this->cookie_str = preg_replace("/" . $cookie . "=([^;]*);/U", $cookie . "=" . $matches[1] . ";", $this->cookie_str);
             } else {
                 $this->cookie_str = $cookie . "=" . $matches[1] . "; " . $this->cookie_str;
             }
         }
     }
     // save updated cookie
     GMailer::saveSessionToBrowser();
     //Debugger::say("new cookie: ".print_r($this->cookie_str,true));
     return true;
 }
示例#3
0
 /**
  * Update Gmail cookie
  *
  * @return bool true
  * @param string raw HTML header
  * @access private
  * @static
  * @author Neerav
  * @since 19 Apr 2006
  */
 function update_cookies($data = "")
 {
     // completely rewritten (expanded, fixed); Neerav; 25 Jan 2007
     /* 		$this->cookie_str = GMailer::get_cookies($data, $this->cookie_str); */
     //$new_cookies = GMailer::get_cookies($data);
     $new_cookies_array = GMailer::get_cookies($data, 'array');
     $existing_cookies = explode(";", $this->cookie_str);
     //Debugger::say(basename(__FILE__).": ".__LINE__.": "."existing cookies: ".print_r($existing_cookies,true));
     //Debugger::say(basename(__FILE__).": ".__LINE__.": "."cookies returned: ".print_r($new_cookies_array,true));
     if (is_string($new_cookies_array) or count($new_cookies_array) == 0) {
         // no cookies to update
         $a = array("action" => "update cookies", "status" => "success", "message" => "no cookies to be updated");
         array_unshift($this->return_status, $a);
         ///Debugger::say(basename(__FILE__).": ".__LINE__.": update_cookies():\n".print_r($a,true));
         return true;
     } else {
         //Debugger::say(basename(__FILE__).": ".__LINE__.": "."new cookies: ".print_r($new_cookies_array,true));
     }
     $all_cookies = array();
     $cookie_count = count($existing_cookies);
     for ($i = 0; $i < $cookie_count; $i++) {
         $cookie = trim($existing_cookies[$i]);
         if ($cookie == "") {
             continue;
         }
         list($name, $value) = explode("=", $cookie, 2);
         $all_cookies["{$name}"] = "{$value}";
         //Debugger::say(basename(__FILE__).": ".__LINE__.": "."this cookie: \n".$cookie."\nexploded:\n".$name."\n".$value);
     }
     //Debugger::say(basename(__FILE__).": ".__LINE__.": "."all existing cookies: \n".print_r($all_cookies,true));
     foreach ($new_cookies_array as $name => $cookie) {
         //$replace_cookies = array("S","GX","GXAS_SEC","GMAIL_AT","GMAIL_HELP");
         if (isset($all_cookies["{$name}"])) {
             $all_cookies["{$name}"] = $cookie['value'];
         }
     }
     $cookie_string = "";
     foreach ($all_cookies as $name => $value) {
         $cookie_string .= $cookie_string == "" ? $name . "=" . $value : "; " . $name . "=" . $value;
     }
     $a = array("action" => "update cookies", "status" => "success", "message" => "Updated cookies");
     array_unshift($this->return_status, $a);
     //Debugger::say(basename(__FILE__).": ".__LINE__.": update_cookies():\n".print_r($a,true));
     // save updated cookie
     GMailer::saveSessionToBrowser();
     ///Debugger::say(basename(__FILE__).": ".__LINE__.": update_cookies(): new cookie: ".print_r($this->cookie_str,true));
     return true;
 }