Beispiel #1
0
 public function __construct($path, $siteId = null)
 {
     if (empty($path)) {
         throw new InvalidPathException($path);
     }
     $this->originalPath = $path;
     $this->path = Path::normalize($path);
     if ($siteId === null) {
         $this->documentRoot = Main\Application::getDocumentRoot();
     } else {
         $this->documentRoot = Main\SiteTable::getDocumentRoot($siteId);
     }
     if (empty($this->path)) {
         throw new InvalidPathException($path);
     }
 }
Beispiel #2
0
 public function __construct($fileName, $arSettings)
 {
     $this->settings = array('SITE_ID' => $arSettings['SITE_ID'], 'PROTOCOL' => $arSettings['PROTOCOL'] == 'https' ? 'https' : 'http', 'DOMAIN' => $arSettings['DOMAIN']);
     $arSite = SiteTable::getRow(array("filter" => array("LID" => $this->settings['SITE_ID'])));
     $this->siteRoot = Path::combine(SiteTable::getDocumentRoot($this->settings['SITE_ID']), $arSite['DIR']);
     if (substr($fileName, -strlen(self::FILE_EXT)) != self::FILE_EXT) {
         $fileName .= self::FILE_EXT;
     }
     if ($this->partFile == '') {
         $this->partFile = $fileName;
     }
     $this->pathPhysical = null;
     // hack for object reconstuct during file splitting
     parent::__construct($this->siteRoot . '/' . $fileName, $this->settings['SITE_ID']);
     $this->partChanged = $this->isExists();
 }
Beispiel #3
0
 public static function convertSiteRelativeToAbsolute($relativePath, $site = null)
 {
     if (!is_string($relativePath) || $relativePath == "") {
         $site = SITE_ID;
     }
     $basePath = Main\SiteTable::getDocumentRoot($site);
     return self::combine($basePath, $relativePath);
 }
Beispiel #4
0
function seoSitemapGetFilesData($PID, $arSitemap, $arCurrentDir, $sitemapFile)
{
	global $NS;

	$arDirList = array();

	if($arCurrentDir['ACTIVE'] == SitemapRuntimeTable::ACTIVE)
	{
		$list = \CSeoUtils::getDirStructure(
			$arSitemap['SETTINGS']['logical'] == 'Y',
			$arSitemap['SITE_ID'],
			$arCurrentDir['ITEM_PATH']
		);

		foreach($list as $dir)
		{
			$dirKey = "/".ltrim($dir['DATA']['ABS_PATH'], "/");

			if($dir['TYPE'] == 'F')
			{
				if(!isset($arSitemap['SETTINGS']['FILE'][$dirKey])
					|| $arSitemap['SETTINGS']['FILE'][$dirKey] == 'Y')
				{
					if(preg_match($arSitemap['SETTINGS']['FILE_MASK_REGEXP'], $dir['FILE']))
					{
						$f = new IO\File($dir['DATA']['PATH'], $arSitemap['SITE_ID']);
						$sitemapFile->addFileEntry($f);
						$NS['files_count']++;
					}
				}
			}
			else
			{
				if(!isset($arSitemap['SETTINGS']['DIR'][$dirKey])
					|| $arSitemap['SETTINGS']['DIR'][$dirKey] == 'Y')
				{
					$arDirList[] = $dirKey;
				}
			}
		}
	}
	else
	{
		$len = strlen($arCurrentDir['ITEM_PATH']);
		if(!empty($arSitemap['SETTINGS']['DIR']))
		{
			foreach($arSitemap['SETTINGS']['DIR'] as $dirKey => $checked)
			{
				if($checked == 'Y')
				{
					if(strncmp($arCurrentDir['ITEM_PATH'], $dirKey, $len) === 0)
					{
						$arDirList[] = $dirKey;
					}
				}
			}
		}

		if(!empty($arSitemap['SETTINGS']['FILE']))
		{
			foreach($arSitemap['SETTINGS']['FILE'] as $dirKey => $checked)
			{
				if($checked == 'Y')
				{
					if(strncmp($arCurrentDir['ITEM_PATH'], $dirKey, $len) === 0)
					{
						$fileName = IO\Path::combine(
							SiteTable::getDocumentRoot($arSitemap['SITE_ID']),
							$dirKey
						);

						if(!is_dir($fileName))
						{
							$f = new IO\File($fileName, $arSitemap['SITE_ID']);
							if($f->isExists()
								&& !$f->isSystem()
								&& preg_match($arSitemap['SETTINGS']['FILE_MASK_REGEXP'], $f->getName())
							)
							{
								$sitemapFile->addFileEntry($f);
								$NS['files_count']++;
							}
						}
					}
				}
			}
		}
	}

	if(count($arDirList) > 0)
	{
		foreach($arDirList as $dirKey)
		{
			$arRuntimeData = array(
				'PID' => $PID,
				'ITEM_PATH' => $dirKey,
				'PROCESSED' => SitemapRuntimeTable::UNPROCESSED,
				'ACTIVE' => SitemapRuntimeTable::ACTIVE,
				'ITEM_TYPE' => SitemapRuntimeTable::ITEM_TYPE_DIR,
			);
			SitemapRuntimeTable::add($arRuntimeData);
		}
	}

	SitemapRuntimeTable::update($arCurrentDir['ID'], array(
		'PROCESSED' => SitemapRuntimeTable::PROCESSED
	));
}
Beispiel #5
0
 public function __construct($siteId)
 {
     $this->siteId = $siteId;
     $this->documentRoot = SiteTable::getDocumentRoot($this->siteId);
     parent::__construct(IO\Path::combine($this->documentRoot, self::ROBOTS_FILE_NAME));
 }
Beispiel #6
0
$arSites = array();

$dbSites = Freetrix\Main\SiteTable::getList(
	array(
		'order' => array('DEF' => 'DESC', 'NAME' => 'ASC'),
		'select' => array('LID', 'NAME', 'DEF', 'DIR', 'DOC_ROOT', 'SERVER_NAME')
	)
);


while($arRes = $dbSites->fetch(Converter::getHtmlConverter()))
{
	if($arRes['DOC_ROOT'] == '')
	{
		$arRes['DOC_ROOT'] = Converter::getHtmlConverter()->encode(
			Main\SiteTable::getDocumentRoot($arRes['LID'])
		);
	}

	if($arRes['DEF'] == 'Y')
	{
		$arDefaultSite = $arRes;
	}

	$arSites[$arRes['LID']] = $arRes;
}

$arCurrentSite = isset($arSites[$siteId]) ? $arSites[$siteId] : $arDefaultSite;
$siteId = $arCurrentSite['LID'];

$arRobotsConfig = array(