public static function showTab($div, $iblockElementInfo) { $engineList = array(); if (Option::get('main', 'vendor', '') == '1c_bitrix') { $engineList[] = array("DIV" => "yandex_direct", "TAB" => Loc::getMessage("SEO_ADV_YANDEX_DIRECT"), "TITLE" => Loc::getMessage("SEO_ADV_YANDEX_DIRECT_TITLE"), "HANDLER" => IO\Path::combine(Application::getDocumentRoot(), BX_ROOT, "/modules/seo/admin/tab/seo_search_yandex_direct.php")); } if (count($engineList) > 0) { $engineTabControl = new \CAdminViewTabControl("engineTabControl", $engineList); ?> <tr> <td colspan="2"> <?php $engineTabControl->begin(); foreach ($engineList as $engineTab) { $engineTabControl->beginNextTab(); $file = new IO\File($engineTab["HANDLER"]); if ($file->isExists()) { require $file->getPath(); } } $engineTabControl->end(); ?> </td> </tr> <?php } }
public function __construct($fileName, $settings) { $this->settings = array( 'SITE_ID' => $settings['SITE_ID'], 'PROTOCOL' => $settings['PROTOCOL'] == 'https' ? 'https' : 'http', 'DOMAIN' => $settings['DOMAIN'], ); $site = SiteTable::getRow(array("filter" => array("LID" => $this->settings['SITE_ID']))); $this->siteRoot = Path::combine( SiteTable::getDocumentRoot($this->settings['SITE_ID']), $site['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() && !$this->isSplitNeeded(); }
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)); }
public function finish() { foreach ($this->partList as $key => $partName) { $f = new File(Path::combine($this->getDirectoryName(), $partName)); $f->rename(str_replace($this->getPrefix(), '', $f->getPath())); $this->partList[$key] = $f->getName(); } if ($this->isCurrentPartNotEmpty()) { $this->addFooter(); $this->rename(str_replace($this->getPrefix(), '', $this->getPath())); } }
public static function getCurrentTemplateId($siteId) { $cacheFlags = Config\Configuration::getValue("cache_flags"); $ttl = isset($cacheFlags["site_template"]) ? $cacheFlags["site_template"] : 0; $connection = Application::getConnection(); $sqlHelper = $connection->getSqlHelper(); $field = $connection->getType() === "mysql" ? "`CONDITION`" : "CONDITION"; $path2templates = IO\Path::combine(Application::getDocumentRoot(), Application::getPersonalRoot(), "templates"); if ($ttl === false) { $sql = "\n\t\t\t\tSELECT " . $field . ", TEMPLATE\n\t\t\t\tFROM b_site_template\n\t\t\t\tWHERE SITE_ID = '" . $sqlHelper->forSql($siteId) . "'\n\t\t\t\tORDER BY IF(LENGTH(" . $field . ") > 0, 1, 2), SORT\n\t\t\t\t"; $recordset = $connection->query($sql); while ($record = $recordset->fetch()) { $condition = trim($record["CONDITION"]); if ($condition != '' && !@eval("return " . $condition . ";")) { continue; } if (IO\Directory::isDirectoryExists($path2templates . "/" . $record["TEMPLATE"])) { return $record["TEMPLATE"]; } } } else { $managedCache = Application::getInstance()->getManagedCache(); if ($managedCache->read($ttl, "b_site_template")) { $arSiteTemplateBySite = $managedCache->get("b_site_template"); } else { $arSiteTemplateBySite = array(); $sql = "\n\t\t\t\t\tSELECT " . $field . ", TEMPLATE, SITE_ID\n\t\t\t\t\tFROM b_site_template\n\t\t\t\t\tWHERE SITE_ID = '" . $sqlHelper->forSql($siteId) . "'\n\t\t\t\t\tORDER BY SITE_ID, IF(LENGTH(" . $field . ") > 0, 1, 2), SORT\n\t\t\t\t\t"; $recordset = $connection->query($sql); while ($record = $recordset->fetch()) { $arSiteTemplateBySite[$record['SITE_ID']][] = $record; } $managedCache->set("b_site_template", $arSiteTemplateBySite); } if (is_array($arSiteTemplateBySite[$siteId])) { foreach ($arSiteTemplateBySite[$siteId] as $record) { $condition = trim($record["CONDITION"]); if ($condition != '' && !@eval("return " . $condition . ";")) { continue; } if (IO\Directory::isDirectoryExists($path2templates . "/" . $record["TEMPLATE"])) { return $record["TEMPLATE"]; } } } } return ".default"; }
public static function getDocumentRoot($siteId = null) { if ($siteId === null) { $context = Application::getInstance()->getContext(); $siteId = $context->getSite(); } if (!isset(self::$documentRootCache[$siteId])) { $ar = SiteTable::getRow(array("filter" => array("LID" => $siteId))); if ($ar && ($docRoot = $ar["DOC_ROOT"]) && strlen($docRoot) > 0) { if (!IO\Path::isAbsolute($docRoot)) { $docRoot = IO\Path::combine(Application::getDocumentRoot(), $docRoot); } self::$documentRootCache[$siteId] = $docRoot; } else { self::$documentRootCache[$siteId] = Application::getDocumentRoot(); } } return self::$documentRootCache[$siteId]; }
public function __construct($siteId) { $this->siteId = $siteId; $this->documentRoot = SiteTable::getDocumentRoot($this->siteId); parent::__construct(IO\Path::combine($this->documentRoot, self::ROBOTS_FILE_NAME)); }
$res = $engine->addSite($arDomain['DOMAIN'], $arDomain['SITE_DIR']); $res['_domain'] = $arDomain['DOMAIN']; break; case 'top-queries': $res = $engine->getQueriesFeed($arDomain['DOMAIN'], $arDomain['SITE_DIR']); break; case 'site_verify': $res = array('error' => array('message' => 'Unknown domain')); if (is_array($arDomain)) { $arFeeds = $engine->getFeeds(); if (isset($arFeeds[$arDomain['DOMAIN']]) && is_array($arFeeds[$arDomain['DOMAIN']])) { if ($arFeeds[$arDomain['DOMAIN']]['verification'] != 'VERIFIED') { $uin = $engine->verifySite($arDomain['DOMAIN'], false); if ($uin) { $filename = "yandex_" . $uin . ".html"; $path = Path::combine(strlen($arDomain['SITE_DOC_ROOT']) > 0 ? $arDomain['SITE_DOC_ROOT'] : $_SERVER['DOCUMENT_ROOT'], $arDomain['SITE_DIR'], $filename); $obFile = new \Bitrix\Main\IO\File($path); $obFile->putContents('<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head><body>Verification: ' . $uin . '</body></html>'); $res = $engine->verifySite($arDomain['DOMAIN'], true); //$obFile->delete(); } } } $res['_domain'] = $arDomain['DOMAIN']; } else { $res = array('error' => 'No domain'); } break; case 'original_text': $textContent = $_POST['original_text']; $res = $engine->addOriginalText($textContent, $arDomain['DOMAIN'], $arDomain['SITE_DIR']);
private function reindexFile($siteId, $rootPath, $path, $maxFileSize = 0) { $pathAbs = IO\Path::combine($rootPath, $path); if (!UrlRewriter::checkPath($pathAbs)) { return 0; } $file = new IO\File($pathAbs); if ($maxFileSize > 0 && $file->getFileSize() > $maxFileSize * 1024) { return 0; } $fileSrc = $file->getContents(); if (!$fileSrc || $fileSrc == "") { return 0; } $arComponents = \PHPParser::parseScript($fileSrc); for ($i = 0, $cnt = count($arComponents); $i < $cnt; $i++) { $sef = is_array($arComponents[$i]["DATA"]["PARAMS"]) && $arComponents[$i]["DATA"]["PARAMS"]["SEF_MODE"] == "Y"; Component\ParametersTable::add(array('SITE_ID' => $siteId, 'COMPONENT_NAME' => $arComponents[$i]["DATA"]["COMPONENT_NAME"], 'TEMPLATE_NAME' => $arComponents[$i]["DATA"]["TEMPLATE_NAME"], 'REAL_PATH' => $path, 'SEF_MODE' => $sef ? Component\ParametersTable::SEF_MODE : Component\ParametersTable::NOT_SEF_MODE, 'SEF_FOLDER' => $sef ? $arComponents[$i]["DATA"]["PARAMS"]["SEF_FOLDER"] : null, 'START_CHAR' => $arComponents[$i]["START"], 'END_CHAR' => $arComponents[$i]["END"], 'PARAMETERS' => serialize($arComponents[$i]["DATA"]["PARAMS"]))); if ($sef) { if (array_key_exists("SEF_RULE", $arComponents[$i]["DATA"]["PARAMS"])) { $ruleMaker = new UrlRewriterRuleMaker(); $ruleMaker->process($arComponents[$i]["DATA"]["PARAMS"]["SEF_RULE"]); $arFields = array("CONDITION" => $ruleMaker->getCondition(), "RULE" => $ruleMaker->getRule(), "ID" => $arComponents[$i]["DATA"]["COMPONENT_NAME"], "PATH" => $path, "SORT" => self::DEFAULT_SORT); } else { $arFields = array("CONDITION" => "#^" . $arComponents[$i]["DATA"]["PARAMS"]["SEF_FOLDER"] . "#", "RULE" => "", "ID" => $arComponents[$i]["DATA"]["COMPONENT_NAME"], "PATH" => $path, "SORT" => self::DEFAULT_SORT); } UrlRewriter::add($siteId, $arFields); } } return true; }
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } use Bitrix\Main\Localization\Loc; use Bitrix\Main\IO\Path; use Bitrix\Sale\Order; require_once Path::combine(__DIR__, "functions.php"); Loc::loadLanguageFile(Path::combine(__DIR__, "statuses.php")); $success = isset($_POST['bill_id']) && isset($_POST['amount']) && isset($_POST['ccy']) && isset($_POST['status']) && isset($_POST['error']) && isset($_POST['user']) && isset($_POST['comment']) && isset($_POST['prv_name']) && isset($_POST['command']); if (!$success) { qiwiWalletXmlResponse(QIWI_WALLET_ERROR_CODE_NONE); } if (!isset($GLOBALS["SALE_INPUT_PARAMS"])) { $GLOBALS["SALE_INPUT_PARAMS"] = array(); } $authType = CSalePaySystemAction::GetParamValue("AUTHORIZATION"); if ($authType == "OPEN") { $login = CSalePaySystemAction::GetParamValue("SHOP_ID"); $password = CSalePaySystemAction::GetParamValue("NOTICE_PASSWORD"); if (!qiwiWalletCheckAuth($login, $password)) { qiwiWalletXmlResponse(QIWI_WALLET_ERROR_CODE_AUTH); } } else { $key = CSalePaySystemAction::GetParamValue("API_PASSWORD"); if (isset($_SERVER['HTTP_X_API_SIGNATURE']) && strlen($key) > 0) { $key = CSalePaySystemAction::GetParamValue("API_PASSWORD"); $params = $_POST; ksort($params); $check = base64_encode(sha1($key, implode("|", array_values($params))));
function seo_getDir($bLogical, $site_id, $dir, $depth, $checked, $arChecked = array()) { if (!is_array($arChecked)) { $arChecked = array(); } $arDirs = \CSeoUtils::getDirStructure($bLogical, $site_id, $dir); if (count($arDirs) > 0) { foreach ($arDirs as $arDir) { $d = Main\IO\Path::combine($dir, $arDir['FILE']); $bChecked = $arChecked[$d] === 'Y' || $checked && $arChecked[$d] !== 'N'; $d = Converter::getHtmlConverter()->encode($d); $r = RandString(8); $varName = $arDir['TYPE'] == 'D' ? 'DIR' : 'FILE'; ?> <div class="sitemap-dir-item"> <?php if ($arDir['TYPE'] == 'D') { ?> <span onclick="loadDir(<?php echo $bLogical ? 'true' : 'false'; ?> , this, '<?php echo CUtil::JSEscape($d); ?> ', '<?php echo $r; ?> ', '<?php echo $depth + 1; ?> ', BX('DIR_<?php echo $d; ?> ').checked)" class="sitemap-tree-icon"></span><?php } ?> <span class="sitemap-dir-item-text"> <input type="hidden" name="<?php echo $varName; ?> [<?php echo $d; ?> ]" value="N" /> <input type="checkbox" name="<?php echo $varName; ?> [<?php echo $d; ?> ]" id="DIR_<?php echo $d; ?> "<?php echo $bChecked ? ' checked="checked"' : ''; ?> value="Y" onclick="checkAll('<?php echo $r; ?> ', this.checked);" /> <label for="DIR_<?php echo $d; ?> "><?php echo Converter::getHtmlConverter()->encode($arDir['NAME'] . ($bLogical ? ' (' . $arDir['FILE'] . ')' : '')); ?> </label> </span> <div id="subdirs_<?php echo $r; ?> " class="sitemap-dir-item-children"></div> </div> <?php } } else { echo $space . Loc::getMessage('SEO_SITEMAP_NO_DIRS_FOUND'); } }
public function write($arAllVars, $baseDir, $initDir, $filename, $TTL) { $documentRoot = \Bitrix\Main\Application::getDocumentRoot(); $fn = IO\Path::combine($documentRoot, $baseDir, $initDir, $filename); $file = new IO\File($fn); $fnTmp = IO\Path::combine($documentRoot, $baseDir, $initDir, md5(mt_rand()) . ".tmp"); $fileTmp = new IO\File($fnTmp); $dir = $file->getDirectory(); if (!$dir->isExists()) { $dir->create(); } if (is_array($arAllVars)) { $contents = "<?"; $contents .= "\nif(\$INCLUDE_FROM_CACHE!='Y')return false;"; $contents .= "\n\$datecreate = '" . str_pad(mktime(), 12, "0", STR_PAD_LEFT) . "';"; $contents .= "\n\$dateexpire = '" . str_pad(mktime() + IntVal($TTL), 12, "0", STR_PAD_LEFT) . "';"; $v = serialize($arAllVars); if (static::checkZeroDanger()) { $v = str_replace("*", "", $v); $contents .= "\n\$zeroDanger = true;"; } $contents .= "\n\$ser_content = '" . str_replace("'", "\\'", str_replace("\\", "\\\\", $v)) . "';"; $contents .= "\nreturn true;"; $contents .= "\n?>"; } else { $contents = "BX" . str_pad(mktime(), 12, "0", STR_PAD_LEFT) . str_pad(mktime() + IntVal($this->TTL), 12, "0", STR_PAD_LEFT); $contents .= $arAllVars; } $this->written = $fileTmp->putContents($contents); $len = \Bitrix\Main\Text\String::strlenBytes($contents); //This checks for Zend Server CE in order to supress warnings if (function_exists('accelerator_reset')) { try { $file->delete(); } catch (\Exception $ex) { } } elseif ($file->isExists()) { $file->delete(); } if ($this->written === $len) { $fileTmp->rename($fn); } //This checks for Zend Server CE in order to supress warnings if (function_exists('accelerator_reset')) { try { IO\File::deleteFile($fnTmp); } catch (\Exception $ex) { } } elseif (IO\File::isFileExists($fnTmp)) { IO\File::deleteFile($fnTmp); } }
public function initCache($TTL, $uniqueString, $initDir = false, $baseDir = "cache") { if ($initDir === false) { $request = \Bitrix\Main\Context::getCurrent()->getRequest(); $initDir = $request->getRequestedPageDirectory(); } $personalRoot = \Bitrix\Main\Application::getPersonalRoot(); $this->baseDir = \Bitrix\Main\IO\Path::combine($personalRoot, $baseDir); $this->initDir = $initDir; $this->filename = $this->getPath($uniqueString); $this->TTL = $TTL; $this->uniqueString = $uniqueString; $this->vars = false; if ($TTL <= 0) { return false; } if ($this->getClearCache()) { return false; } $arAllVars = array("CONTENT" => "", "VARS" => ""); if (!$this->cacheEngine->read($arAllVars, $this->baseDir, $this->initDir, $this->filename, $this->TTL)) { return false; } $this->content = $arAllVars["CONTENT"]; $this->vars = $arAllVars["VARS"]; return true; }