Ejemplo n.º 1
0
 public function appendIBlockEntry($url, $modifiedDate, $priority = 0)
 {
     if ($this->isExists()) {
         $this->appendEntry(array('XML_LOC' => $this->settings['PROTOCOL'] . '://' . \CBXPunycode::toASCII($this->settings['DOMAIN'], $e = null) . $url, 'XML_LASTMOD' => date('c', $modifiedDate - \CTimeZone::getOffset()), 'XML_PRIORITY' => $priority ? $priority : self::DEFAULT_PRIORITY));
     } else {
         $this->addHeader();
         $this->addIBlockEntry($url, $modifiedDate, $priority);
         $this->addFooter();
     }
 }
Ejemplo n.º 2
0
 public function appendIndexEntry($file)
 {
     if ($this->isExists()) {
         $fileUrlEnc = Converter::getXmlConverter()->encode($this->settings['PROTOCOL'] . '://' . \CBXPunycode::toASCII($this->settings['DOMAIN'], $e = null) . $this->getFileUrl($file));
         $contents = $this->getContents();
         $reg = "/" . sprintf(preg_quote(self::ENTRY_TPL, "/"), preg_quote($fileUrlEnc, "/"), "[^<]*") . "/";
         $newEntry = sprintf(self::ENTRY_TPL, $fileUrlEnc, date(c, $file->getModificationTime($file)));
         $count = 0;
         $contents = preg_replace($reg, $newEntry, $contents, 1, $count);
         if ($count <= 0) {
             $contents = substr($contents, 0, -strlen(self::FILE_FOOTER)) . $newEntry . self::FILE_FOOTER;
         }
         $this->putContents($contents);
     } else {
         $this->createIndex(array($file));
     }
 }
Ejemplo n.º 3
0
	/**
	 * Returns sitemap file URL
	 *
	 * @return string
	 */
	public function getUrl()
	{
		return $this->settings['PROTOCOL'].'://'.\CBXPunycode::toASCII($this->settings['DOMAIN'], $e = null).$this->getFileUrl($this);
	}
Ejemplo n.º 4
0
 protected function processSiteResult($res)
 {
     $obXml = new \CDataXML();
     if ($obXml->loadString($res)) {
         $hostName = $obXml->getTree()->elementsByName('name');
         $hostName = \CBXPunycode::toASCII(ToLower($hostName[0]->textContent()), $e = null);
         if (preg_match("/^https:\\/\\//", $hostName)) {
             $hostName = substr($hostName, 8);
         }
         $this->engineSettings['SITES'][$hostName]['SERVICES'] = array();
         $arLinks = $obXml->getTree()->elementsByName('link');
         foreach ($arLinks as $link) {
             $this->engineSettings['SITES'][$hostName]['SERVICES'][$link->getAttribute('rel')] = $link->getAttribute('href');
         }
         $this->saveSettings();
         return true;
     }
     return false;
 }
Ejemplo n.º 5
0
 public function getFeeds()
 {
     $queryResult = $this->queryJson(self::QUERY_BASE . self::SCOPE_FEED_SITES);
     if ($queryResult->getStatus() == self::HTTP_STATUS_OK && strlen($queryResult->getResult()) > 0) {
         $result = Json::decode($queryResult->getResult());
         $response = array();
         if (is_array($result)) {
             foreach ($result['siteEntry'] as $key => $siteInfo) {
                 $siteUrlInfo = parse_url($siteInfo['siteUrl']);
                 if ($siteUrlInfo) {
                     $errors = array();
                     $hostKey = \CBXPunycode::toASCII($siteUrlInfo["host"], $errors);
                     if (count($errors) > 0) {
                         $hostKey = $siteUrlInfo["host"];
                     }
                     $response[$hostKey] = array('binded' => $siteInfo["permissionLevel"] !== "siteRestrictedUser", 'verified' => $siteInfo["permissionLevel"] !== "siteRestrictedUser" && $siteInfo["permissionLevel"] !== "siteUnverifiedUser");
                 }
             }
         }
         return $response;
     } else {
         throw new \Exception('Query error! ' . $queryResult->getStatus() . ': ' . $queryResult->getResult());
     }
 }