Ejemplo n.º 1
0
 private function _setPageContent($url, __SiteMapPage &$page)
 {
     $ch = curl_init();
     // initialize curl handle
     curl_setopt($ch, CURLOPT_URL, $url);
     // set url to post to
     curl_setopt($ch, CURLOPT_FAILONERROR, 1);
     // Fail on errors
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
     // allow redirects
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     // return into a variable
     curl_setopt($ch, CURLOPT_PORT, $_SERVER['SERVER_PORT']);
     //Set the port number
     curl_setopt($ch, CURLOPT_TIMEOUT, 15);
     // times out after 15s
     curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)');
     $return_value = curl_exec($ch);
     if ($return_value === false) {
         $info = curl_getinfo($ch);
         $page->setHttpCode($info['http_code']);
         $page->setContent(null);
     } else {
         $info = curl_getinfo($ch);
         $page->setHttpCode($info['http_code']);
         $page->setContent($return_value);
     }
     curl_close($ch);
     return $return_value;
 }
Ejemplo n.º 2
0
 public function addPage(__SiteMapPage &$page)
 {
     $uri = $page->getUri();
     $this->_pages[$uri] =& $page;
     $route = $page->getRoute();
     if (!key_exists($route, $this->_routes)) {
         $this->_routes[$route] = array();
     }
     $this->_routes[$route][$uri] =& $page;
     $links = $page->getLinks();
     foreach ($links as $link) {
         $href = $link->getHref();
         $url_parts = parse_url($href);
         if ($url_parts['host'] != $_SERVER['HTTP_HOST']) {
             $this->_external_links[$href] =& $link;
         }
         if ($href != $uri) {
             if (!key_exists($href, $this->_connection_matrix)) {
                 $this->_connection_matrix[$href] = array();
             }
             $this->_connection_matrix[$href][$uri] =& $link;
         }
     }
 }