예제 #1
0
 /**
 * Set general settings of Gmail account.
 *
 * @return bool Success or not.
   Extended return: array(bool status, string message)
 * @param bool $use_outgoing_name Use outgoing name (instead of the default)?
 * @param string $outgoing_name Outgoing name
 * @param bool $use_reply_email Use replying email address (instead of the default)?
 * @param string $reply_to Replying email address
 * @param string $language Language
 * @param int $page_length Page length. Must be either 25, 50 or 100
 * @param bool $shortcut Enable keyboard shortcut?
 * @param bool $indicator Enable personal level indicator?
 * @param bool $snippet Enable snippet?
 * @param bool $custom_signature Enable custom signature?
 * @param string $signature Custom signature
 * @param string $forward_to Address to auto-forward to. $forward_to = "" to disable auto-forward
 * @param string $forward_action Action on Gmail's copy of auto-forwarded emails. $forward_action = "" to keep them, "archive" to archive them, or "trash" to trash them
 * @param int $pop_setting POP settings. $pop_setting = 0 to disable POP access, 1 to remain unchanged, 2 to enable POP for new mails, or 3 to enable POP for all mails
 * @param int $pop_action Action on Gmail's copy of POP-accessed emails. $pop_action = 0 to keep them, 1 to archive them, or 2 to trash them
 * @param bool $expand_label_box Expand label box?
 * @param bool $expand_invite_box Expand invite box?
 * @author Neerav
 * @since 29 Jun 2005
 */
 function setGeneralSetting($use_outgoing_name, $outgoing_name, $use_reply_email, $reply_to, $language, $page_length, $shortcut, $indicator, $snippet, $custom_signature, $signature, $forward_to, $forward_action, $pop_setting, $pop_action, $expand_label_box = 1, $expand_invite_box = 1)
 {
     /* 			
     "bx_hs"		// (boolean) keyboard shortcuts {0 = off, 1 = on}
     "bx_show0"	// (boolean) labels box {0 = collapsed, 1 = expanded}
     "ix_nt"		// (integer) msgs per page (maximum page size)
     "sx_dl"		// (string) display language (en = English, en-GB = British-english, etc)
     "bx_sc"		// (boolean) personal level indicators {0 = no indicators, 1 = show indicators}
     "bx_show1"	// (boolean) invite box {0 = collapsed, 1 = expanded}
     "sx_sg"		// (string) signature
     "sx_dn" 	// (string) display name 
     "sx_rt" 	// (string) reply to email address
     "bx_ns" 	// (boolean) no snippets {0 = show snippets, 1 = no snippets}
     "bx_cm" 	// (boolean) rich text composition {0 = plain text, 1 = rich text}
     "sx_em"  // (string) email address forwarding to {"" to disable forwarding}
     "sx_at"  // (string) action on Gmail's copy {"trash", "archive" or ""}
     "bx_pe"  // (int) POP settings {3 = switch on POP for all mail, 2 = POP for new mail, 0 = disable}
     "ix_pd"  // (int) action on Gmail's copy {0 = keep, 1 = archive, 2 = trash}		
     */
     if ($this->isConnected()) {
         Debugger::say("Starting to set general settings...");
         $query = "";
         //$query .= "&ik=".IKVALUE;
         $query .= "&search=inbox";
         $query .= "&view=tl";
         $query .= "&start=0";
         $query .= "&act=prefs";
         $cc = split(";", $this->cookie_str);
         foreach ($cc as $cc_part) {
             $cc_parts = split("=", $cc_part);
             if (trim($cc_parts[0]) == "GMAIL_AT") {
                 $query .= "&at=" . $cc_parts[1];
                 break;
             }
         }
         $query .= "&p_bx_hs=";
         $query .= $shortcut ? "1" : "0";
         $query .= "&p_bx_show0=";
         $query .= $expand_label_box ? "1" : "0";
         $query .= "&p_ix_nt=" . $page_length;
         $query .= "&p_sx_dl=" . $language;
         $query .= "&p_bx_sc=";
         $query .= $indicator ? "1" : "0";
         $query .= "&p_bx_show1=";
         $query .= $expand_invite_box ? "1" : "0";
         $query .= "&p_sx_sg=";
         $query .= $custom_signature ? urlencode("{$signature}") : "%0A%0D";
         $query .= "&p_sx_dn=";
         $query .= $use_outgoing_name ? urlencode("{$outgoing_name}") : "%0A%0D";
         $query .= "&p_sx_rt=";
         $query .= $use_reply_email ? urlencode("{$reply_to}") : "%0A%0D";
         $query .= "&p_bx_ns=";
         $query .= $snippet ? "0" : "1";
         // REVERSED because we originally reversed it for convenience
         $query .= "&p_sx_em=" . $forward_to;
         $query .= "&p_sx_at=" . $forward_action;
         $query .= "&p_bx_pe=" . $pop_setting;
         $query .= "&p_ix_pd=" . $pop_action;
         $query .= $this->proxy_defeat();
         // to fool proxy
         set_time_limit(150);
         $c = curl_init();
         curl_setopt($c, CURLOPT_URL, GM_LNK_GMAIL . "?" . $query);
         curl_setopt($c, CURLOPT_REFERER, GM_LNK_GMAIL . "?&view=pr&pnl=g" . $this->proxy_defeat());
         //&ik=921eb6d481&view=pr&pnl=g&zx=zeurrt-akcb6h
         $this->CURL_PROXY($c);
         curl_setopt($c, CURLOPT_HEADER, 1);
         curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1);
         curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 2);
         curl_setopt($c, CURLOPT_SSL_VERIFYPEER, FALSE);
         curl_setopt($c, CURLOPT_USERAGENT, GM_USER_AGENT);
         curl_setopt($c, CURLOPT_COOKIE, $this->cookie_str);
         $this->gmail_data = curl_exec($c);
         GMailer::status_message($this->gmail_data);
         curl_close($c);
         //$updated_snapshot = new GMailSnapshot(GM_PREFERENCE, $this->raw, $this->use_session);
         //Debugger::say(print_r($updated_snapshot,true));
         Debugger::say("Finished set general settings.");
         $status = isset($this->raw["ar"][1]) ? $this->raw["ar"][1] : 0;
         $message = isset($this->raw["ar"][2]) ? $this->raw["ar"][2] : "";
         $a = array("action" => "set general settings", "status" => $status ? "success" : "failed", "message" => $message);
         array_unshift($this->return_status, $a);
         return $status;
     } else {
         $a = array("action" => "set general settings", "status" => "failed", "message" => "libgmailer: not connected");
         array_unshift($this->return_status, $a);
         Debugger::say("FAILED to set general settings.");
         return false;
     }
 }