Example #1
0
 /**
  * Retrieve a web clipping
  *
  * @author Neerav
  * @since 22 April 2006
  */
 function webClip($action = "get", $thread_id = 0, $mailbox = "")
 {
     if ($this->isConnected()) {
         $query = "";
         $update_cookie = false;
         if ($action == "get") {
             $query .= "&view=fb";
         } elseif ($action == "thread") {
             //$query 	.= "&ik=".$ik.value.here;
             $query .= "&view=ad";
             $query .= $thread_id ? "&th=" . $thread_id : "";
             $query .= "&mg=" . urlencode("3,2");
             //what is this junk? &mg=3,2,2,2,2,2,2,2,3,4,3,4
             if ($mailbox === 0 or $mailbox == "") {
                 $mailbox = "inbox";
             }
             if (in_array(strtolower($mailbox), $this->gmail_reserved_names)) {
                 $query .= "&search=" . urlencode($mailbox);
             } else {
                 $query .= "&search=cat&cat=" . urlencode($mailbox);
             }
             $query .= "&qt=";
             $query .= "&act=rd";
             $query .= $thread_id ? "&t=" . $thread_id : "";
             $query .= "&at=" . $this->at_value();
         } elseif ($action == "off" or $action == "on") {
             // turn webclips on/off; Added by Neerav; 13 May 2006
             //$query 	.= "&ik=".$ik.value.here;
             $query .= "&view=up";
             $query .= "&act=co_" . ($action == "off" ? 0 : 1);
             $query .= "&at=" . $this->at_value();
             $query .= "&rq=xm";
             $query .= $this->proxy_defeat("nodash");
             $update_cookie = true;
         } else {
             $a = array("action" => "web clip: " . $action, "status" => "failed", "message" => "invalid action");
             array_unshift($this->return_status, $a);
             return array();
         }
         $query .= $this->proxy_defeat();
         $this->gmail_data = GMailer::execute_curl($this->GM_LNK_GMAIL . "?" . $query, "", 'get', $query, "", "", $update_cookie);
         GMailer::parse_gmail_response($this->gmail_data, true);
         //Debugger::say("web clip response: ".print_r($this->gmail_data,true));
         //Debugger::say("web clip response raw: ".print_r($this->raw,true));
         if ($action == "get" or $action == "thread") {
             GMailSnapshot::web_clip_snapshot($this->raw["1"][1][3]);
             //Debugger::say("web clip response raw: ".print_r($this->raw,true));
             return $this->web_clips;
         } else {
             //Debugger::say("web clip response: ".print_r($this->gmail_data,true));
             /* 				$a = array( */
             /* 					"action" 		=> "retrieve web clip", */
             /* 					"status" 		=> "failed", */
             /* 					"message" 		=> "libgmailer: not connected" */
             /* 				); */
             /* 				array_unshift($this->return_status, $a); */
             return true;
         }
     } else {
         $a = array("action" => "retrieve web clip", "status" => "failed", "message" => "libgmailer: not connected");
         array_unshift($this->return_status, $a);
         return false;
     }
 }
Example #2
0
 /**
  * Retrieve a web clipping
  *
  * @author Neerav
  * @since 22 April 2006
  */
 function webClip($action = "get", $thread_id = 0, $mailbox = "")
 {
     if ($this->isConnected()) {
         $data = "";
         $refer = "";
         $method = 'get';
         $update_cookie = false;
         if ($action == "get") {
             $data .= "&view=fb";
             $data .= $this->proxy_defeat();
             $query = $data;
         } elseif ($action == "thread") {
             //$query 	.= "&ik=".$ik.value.here;
             $data .= "&view=ad";
             $data .= $thread_id ? "&th=" . $thread_id : "";
             $data .= "&mg=" . urlencode("3,2");
             //what is this junk? &mg=3,2,2,2,2,2,2,2,3,4,3,4
             if ($mailbox === 0 or $mailbox == "") {
                 $mailbox = "inbox";
             }
             if (in_array(strtolower($mailbox), $this->gmail_reserved_names)) {
                 $data .= "&search=" . urlencode($mailbox);
             } else {
                 $data .= "&search=cat&cat=" . urlencode($mailbox);
             }
             $data .= "&qt=";
             $data .= "&act=rd";
             $data .= $thread_id ? "&t=" . $thread_id : "";
             $data .= "&at=" . $this->at_value();
             $data .= $this->proxy_defeat();
             $query = $data;
         } elseif ($action == "off" or $action == "on") {
             // turn webclips on/off; Added by Neerav; 13 May 2006
             //$data 	.= "&ik=".$ik.value.here;
             $data .= "&view=up";
             $data .= "&act=co_" . ($action == "off" ? 0 : 1);
             $data .= "&at=" . $this->at_value();
             $data .= "&rq=xm";
             $data .= $this->proxy_defeat("nodash");
             $query = $data;
             $update_cookie = true;
         } elseif ($action == "preview") {
             // retrieve feed preview; Added by Neerav; 19 Jul 2007
             //$query 	.= "&ik=".$ik.value.here;
             $url = urldecode(urldecode($thread_id));
             // twice, to be safe!
             if (substr($url, 0, 4) != "http") {
                 $url = "http://" . $url;
             }
             $url = urlencode(rawurlencode($url));
             // needs to be double encoded
             $data .= "&view=cps";
             $data .= "&cps=r";
             $data .= "&q=" . $url;
             $data .= "&rq=xm";
             $data .= "&at=" . $this->at_value();
             $data .= $this->proxy_defeat();
             $query = $data;
         } elseif ($action == "add" or $action == "remove") {
             // add or remove a feed; Added by Neerav; 19 Jul 2007
             $query = '&view=up';
             $data = array();
             $method = 'post';
             $refer = $this->GM_LNK_GMAIL . "?ui=1&view=pr&pnl=g&lm=m_prefs" . $this->proxy_defeat();
             if ($action == "remove") {
                 $url = $thread_id;
             } else {
                 $url = urldecode(urldecode($thread_id));
                 // twice, to be safe!
                 if (substr($url, 0, 4) != "http") {
                     $url = "http://" . $url;
                 }
             }
             $data['act'] = ($action == "remove" ? "de_" : "ae_") . $url;
             // the URL should NOT be encoded, since POSTing it will single encode it, which is only what is required
             $data['at'] = $this->at_value();
             /* 				Debugger::say(basename(__FILE__).": ".__LINE__.": "."data: ".print_r($data,true)); */
             /* 				Debugger::say(basename(__FILE__).": ".__LINE__.": "."refer: ".$refer); */
             $update_cookie = true;
             //&search=inbox&sx_dl=en&ix_nt=50&bx_hs=1&ix_pp=0&bx_pd=0&sx_sg=1&sx_sg=Neerav&bx_sc=1&bx_ns=0&bx_ve=0&sx_vs=&sx_vm=&bx_en=0
         } else {
             $a = array("action" => "web clip: " . $action, "status" => "failed", "message" => "invalid action");
             array_unshift($this->return_status, $a);
             return array();
         }
         $this->gmail_data = GMailer::execute_curl($this->GM_LNK_GMAIL . "?ui=1" . $query, $refer, $method, $data, "", "", $update_cookie);
         if ($action == "add" or $action == "remove") {
             /* 				Debugger::say(basename(__FILE__).": ".__LINE__.": ".$action." rss feed: ".print_r($this->gmail_data,true)); */
             GMailer::parse_gmail_response($this->gmail_data);
             $status = isset($this->raw["ar"][1]) ? $this->raw["ar"][1] : 0;
             $message = isset($this->raw["ar"][2]) ? $this->raw["ar"][2] : "";
             $a = array("action" => "web clip: " . $action, "status" => $status ? "success" : "failed", "message" => $message);
             array_unshift($this->return_status, $a);
             /* 				Debugger::say(basename(__FILE__).": ".__LINE__.": "."status: ".print_r($a,true)); */
             return $status;
         } elseif ($action == "preview") {
             $temp = str_replace("\n", "", $this->gmail_data);
             preg_match("/\\[\\[\\[(.*)\\]([^\\]]*)?\\]([^\\]]*)?\\]/", $temp, $matches);
             GMailer::parse_gmail_response($matches[1], true);
             GMailSnapshot::web_clip_snapshot($this->raw, 'preview');
             return $this->feed;
         } elseif ($action == "get" or $action == "thread") {
             GMailer::parse_gmail_response($this->gmail_data, true);
             GMailSnapshot::web_clip_snapshot($this->raw["1"][1][3]);
             //Debugger::say(basename(__FILE__).": ".__LINE__.": "."web clip response raw: ".print_r($this->raw,true));
             return $this->web_clips;
         } else {
             GMailer::parse_gmail_response($this->gmail_data, true);
             return true;
         }
     } else {
         $a = array("action" => "web clip: " . $action, "status" => "failed", "message" => "libgmailer: not connected");
         array_unshift($this->return_status, $a);
         return false;
     }
 }