示例#1
0
 /**
  * @param $pingUrl string The Sitemap URL to ping
  * @param bool $updateStatus If the global ping status should be updated
  *
  * @return \GoogleSitemapGeneratorStatus
  */
 protected function ExecutePing($pingUrl, $updateStatus = true)
 {
     $status = new GoogleSitemapGeneratorStatus($updateStatus);
     if ($pingUrl) {
         $pings = array();
         if ($this->GetOption("b_ping")) {
             $pings["google"] = array("name" => "Google", "url" => "http://www.google.com/webmasters/sitemaps/ping?sitemap=%s", "check" => "successfully");
         }
         if ($this->GetOption("b_pingmsn")) {
             $pings["bing"] = array("name" => "Bing", "url" => "http://www.bing.com/webmaster/ping.aspx?siteMap=%s", "check" => " ");
         }
         foreach ($pings as $serviceId => $service) {
             $url = str_replace("%s", urlencode($pingUrl), $service["url"]);
             $status->StartPing($serviceId, $url, $service["name"]);
             $pingres = $this->RemoteOpen($url);
             if ($pingres === null || $pingres === false || strpos($pingres, $service["check"]) === false) {
                 $status->EndPing($serviceId, false);
                 trigger_error("Failed to ping {$serviceId}: " . htmlspecialchars(strip_tags($pingres)), E_USER_NOTICE);
             } else {
                 $status->EndPing($serviceId, true);
             }
         }
         $this->SetOption('i_lastping', time());
         $this->SaveOptions();
     }
     $status->End();
     return $status;
 }
示例#2
0
 /**
  * Sends the pings to the search engines
  */
 public function SendPing()
 {
     $this->LoadOptions();
     $status = new GoogleSitemapGeneratorStatus();
     $pingUrl = $this->GetXmlUrl();
     if ($pingUrl) {
         $pings = array();
         if ($this->GetOption("b_ping")) {
             $pings["google"] = array("name" => "Google", "url" => "http://www.google.com/webmasters/sitemaps/ping?sitemap=%s", "check" => "successfully");
         }
         if ($this->GetOption("b_pingask")) {
             $pings["ask"] = array("name" => "Ask.com", "url" => "http://submissions.ask.com/ping?sitemap=%s", "check" => "successfully received and added");
         }
         if ($this->GetOption("b_pingmsn")) {
             $pings["bing"] = array("name" => "Bing", "url" => "http://www.bing.com/webmaster/ping.aspx?siteMap=%s", "check" => "感谢您提交站点地图。");
         }
         if ($this->GetOption("b_pingyahoo") === true && $this->GetOption("b_yahookey")) {
             $pings["yahoo"] = array("name" => "Yahoo", "url" => "http://search.yahooapis.com/SiteExplorerService/V1/updateNotification?appid=" . $this->GetOption("b_yahookey") . "&url=%s", "check" => "success");
         }
         foreach ($pings as $serviceId => $service) {
             $url = str_replace("%s", urlencode($pingUrl), $service["url"]);
             $status->StartPing($serviceId, $url, $service["name"]);
             $pingres = $this->RemoteOpen($url);
             if ($pingres === NULL || $pingres === false || strpos($pingres, $service["check"]) === false) {
                 $status->EndPing($serviceId, false);
                 trigger_error("Failed to ping {$serviceId}: " . htmlspecialchars(strip_tags($pingres)), E_USER_NOTICE);
             } else {
                 $status->EndPing($serviceId, true);
             }
         }
     }
     $status->End();
 }