Ejemplo n.º 1
0
    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 
        }
    }
Ejemplo n.º 2
0
 public static function modifyDbconn($DBHost, $DBName, $DBLogin, $DBPassword)
 {
     if (strlen($DBHost) <= 0) {
         throw new \Bitrix\Main\ArgumentNullException("DBHost");
     }
     if (strlen($DBName) <= 0) {
         throw new \Bitrix\Main\ArgumentNullException("DBName");
     }
     if (strlen($DBLogin) <= 0) {
         throw new \Bitrix\Main\ArgumentNullException("DBLogin");
     }
     $filename = \Bitrix\Main\Application::getDocumentRoot() . "/bitrix/php_interface/dbconn.php";
     $file = new \Bitrix\Main\IO\File($filename);
     if (!$file->isExists()) {
         return false;
     }
     $content = file_get_contents($filename);
     if (strlen($content) <= 0) {
         return false;
     }
     file_put_contents(\Bitrix\Main\Application::getDocumentRoot() . "/bitrix/php_interface/dbconn.php.bak", $content);
     $content = preg_replace('/(\\$DBHost\\s*=\\s*(\\"|\')+)(.*)((\\"|\')+;)/', '${1}' . $DBHost . '${4}', $content);
     $content = preg_replace('/(\\$DBName\\s*=\\s*(\\"|\')+)(.*)((\\"|\')+;)/', '${1}' . $DBName . '${4}', $content);
     $content = preg_replace('/(\\$DBLogin\\s*=\\s*(\\"|\')+)(.*)((\\"|\')+;)/', '${1}' . $DBLogin . '${4}', $content);
     $content = preg_replace('/(\\$DBPassword\\s*=\\s*(\\"|\')+)(.*)((\\"|\')+;)/', '${1}' . $DBPassword . '${4}', $content);
     return file_put_contents($filename, $content);
 }
Ejemplo n.º 3
0
 private static function getMap()
 {
     if (empty(self::$map)) {
         self::$map = (include Application::getDocumentRoot() . "/bitrix/modules/mobileapp/maps/resources.php");
     }
     return self::$map;
 }
Ejemplo n.º 4
0
 /**
  * @param string $dbName
  * @return array List of all sites & their params
  */
 public static function getList($dbName = false)
 {
     if (!$dbName) {
         $connection = \Bitrix\Main\Application::getConnection();
         $dbName = $connection->getDbName();
     }
     $result = array();
     $shellAdapter = new ShellAdapter();
     $execRes = $shellAdapter->syncExec("sudo -u root /opt/webdir/bin/bx-sites -o json -a list -d " . $dbName);
     $sitesData = $shellAdapter->getLastOutput();
     if ($execRes) {
         $arData = json_decode($sitesData, true);
         if (isset($arData["params"])) {
             $result = $arData["params"];
         }
         $rsSite = \Bitrix\Main\SiteTable::getList();
         while ($site = $rsSite->fetch()) {
             foreach ($result as $siteId => $siteInfo) {
                 $docRoot = strlen($site["DOC_ROOT"]) > 0 ? $site["DOC_ROOT"] : \Bitrix\Main\Application::getDocumentRoot();
                 if ($siteInfo["DocumentRoot"] == $docRoot) {
                     $result[$siteId]["NAME"] = $site["NAME"] . " (" . $site["LID"] . ") ";
                 } else {
                     $result[$siteId]["NAME"] = $siteId;
                 }
             }
         }
     }
     return $result;
 }
Ejemplo n.º 5
0
 function UnInstallFiles()
 {
     $rootDir = Application::getDocumentRoot() . '/' . Application::getPersonalRoot();
     $adminGatewayFile = '/admin/ws_tools.php';
     unlink($rootDir . $adminGatewayFile);
     return true;
 }
Ejemplo n.º 6
0
 public function UnInstallFiles()
 {
     $files = array('js' => '/js/' . $this->MODULE_ID, 'img' => '/images/' . $this->MODULE_ID, 'request' => '/tools/' . $this->MODULE_ID);
     $rootDir = Application::getDocumentRoot() . '/' . ltrim(Application::getPersonalRoot(), '/');
     foreach ($files as $file) {
         Directory::deleteDirectory($rootDir . $file);
     }
 }
Ejemplo n.º 7
0
 /**
  * @param array $options
  */
 public function setOptions(array $options)
 {
     parent::setOptions($options);
     $this->file = new File(Application::getDocumentRoot() . $this->options['path']);
     if (!$this->file->isFile()) {
         throw new \Shantilab\BxEcho\Exceptions\InvalidFilePathException(Application::getDocumentRoot() . $this->options['path']);
     }
 }
Ejemplo n.º 8
0
 public function getPath($notDocumentRoot = false)
 {
     $drName = dirname(__DIR__);
     if ($notDocumentRoot) {
         return str_replace(Application::getDocumentRoot(), '', $drName);
     }
     return $drName;
 }
Ejemplo n.º 9
0
 /**
  * @param bool $notDocumentRoot
  * @return mixed|string
  */
 public function GetPath($notDocumentRoot = false)
 {
     if ($notDocumentRoot) {
         return str_ireplace(Application::getDocumentRoot(), '', dirname(__DIR__));
     } else {
         return dirname(__DIR__);
     }
     // текущая папка с полным путем можем узнать с помощью константы __DIR__ а путь то родительского каталога узнаем ф-ей dirname()
 }
Ejemplo n.º 10
0
 public function saveConfiguration()
 {
     $path = \Bitrix\Main\Application::getDocumentRoot() . self::CONFIGURATION_FILE_PATH;
     $path = preg_replace("'[\\\\/]+'", "/", $path);
     $data = var_export($this->data, true);
     if (!is_writable($path)) {
         @chmod($path, 0600);
     }
     file_put_contents($path, "<" . "?php\n\$data=" . $data . ";\n");
 }
Ejemplo n.º 11
0
 public function __construct($path)
 {
     if (empty($path)) {
         throw new InvalidPathException($path);
     }
     $this->originalPath = $path;
     $this->path = Path::normalize($path);
     $this->documentRoot = \Bitrix\Main\Application::getDocumentRoot();
     if (empty($this->path)) {
         throw new InvalidPathException($path);
     }
 }
Ejemplo n.º 12
0
 public function initialize(array $options)
 {
     $this->logFile = static::DEFAULT_LOG_FILE;
     if (isset($options["file"]) && !empty($options["file"])) {
         $this->logFile = $options["file"];
     }
     $this->logFile = preg_replace("'[\\\\/]+'", "/", $this->logFile);
     if (substr($this->logFile, 0, 1) !== "/" && !preg_match("#^[a-z]:/#", $this->logFile)) {
         $this->logFile = Main\Application::getDocumentRoot() . "/" . $this->logFile;
     }
     $this->logFileHistory = $this->logFile . ".old";
     $this->maxLogSize = static::MAX_LOG_SIZE;
     if (isset($options["log_size"]) && $options["log_size"] > 0) {
         $this->maxLogSize = intval($options["log_size"]);
     }
 }
Ejemplo n.º 13
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);
     }
 }
Ejemplo n.º 14
0
 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";
 }
Ejemplo n.º 15
0
 private function __construct()
 {
     // Initialize Twig template engine
     $documentRoot = Application::getDocumentRoot();
     $cacheStoragePathOption = \COption::GetOptionString("wlbl.twigrix", "cache_storage_path");
     if ($cacheStoragePathOption == "") {
         $cacheStoragePath = $documentRoot . BX_PERSONAL_ROOT . "/cache/twig";
     } else {
         $cacheStoragePath = $documentRoot . $cacheStoragePathOption;
     }
     $debugModeOptionValue = \COption::GetOptionString("wlbl.twigrix", "debug_mode");
     $debugMode = $debugModeOptionValue == "Y" ? true : false;
     $loader = new \Twig_Loader_Filesystem($documentRoot);
     $this->environment = new \Twig_Environment($loader, ['autoescape' => false, 'cache' => $cacheStoragePath, 'debug' => $debugMode]);
     $this->addExtensions();
     self::$instance = $this;
 }
Ejemplo n.º 16
0
 /**
  * @return array All roles defenitions
  * @throws \Bitrix\Main\IO\FileNotFoundException
  */
 public static function getList()
 {
     static $def = null;
     if ($def == null) {
         $filename = \Bitrix\Main\Application::getDocumentRoot() . "/bitrix/modules/scale/include/rolesdefinitions.php";
         $file = new \Bitrix\Main\IO\File($filename);
         if ($file->isExists()) {
             require_once $filename;
         } else {
             throw new \Bitrix\Main\IO\FileNotFoundException($filename);
         }
         if (isset($rolesDefinitions)) {
             $def = $rolesDefinitions;
         } else {
             $def = array();
         }
     }
     return $def;
 }
Ejemplo n.º 17
0
 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];
 }
Ejemplo n.º 18
0
 private function createMap()
 {
     $mapFilePath = Application::getDocumentRoot() . "/bitrix/modules/mobileapp/maps/config.php";
     $file = new File($mapFilePath);
     if (!$file->isExists()) {
         throw new SystemException("The map file  '" . $mapFilePath . "' doesn't exists!", 100);
     }
     $map = (include $mapFilePath);
     if (!is_array($map)) {
         throw new SystemException("The map file does exist but has some broken structure.", 101);
     }
     self::$configMap = $map;
     self::$configMap["groups"] = array();
     $groupTypes = array(ParameterType::GROUP, ParameterType::GROUP_BACKGROUND, ParameterType::GROUP_BACKGROUND_LIGHT);
     foreach ($map["types"] as $paramName => $intType) {
         if (in_array($intType, $groupTypes)) {
             self::$configMap["groups"][] = $paramName;
         }
     }
 }
Ejemplo n.º 19
0
 /**
  * Performs actions enabled by its parameters.
  *
  * @param string $message Message to show with bitrix:system.show_message component.
  * @param bool $defineConstant If true then ERROR_404 constant defined.
  * @param bool $setStatus If true sets http response status.
  * @param bool $showPage If true then work area will be cleaned and /404.php will be included.
  * @param string $pageFile Alternative file to /404.php.
  *
  * @return void
  */
 public static function process404($message = "", $defineConstant = true, $setStatus = true, $showPage = false, $pageFile = "")
 {
     /** @global \CMain $APPLICATION */
     global $APPLICATION;
     if ($message != "") {
         $APPLICATION->includeComponent("bitrix:system.show_message", ".default", array("MESSAGE" => $message, "STYLE" => "errortext"), null, array("HIDE_ICONS" => "Y"));
     }
     if ($defineConstant && !defined("ERROR_404")) {
         define("ERROR_404", "Y");
     }
     if ($setStatus) {
         \CHTTP::setStatus("404 Not Found");
     }
     if ($showPage) {
         if ($APPLICATION->RestartWorkarea()) {
             if ($pageFile) {
                 require \Bitrix\Main\Application::getDocumentRoot() . rel2abs("/", "/" . $pageFile);
             } else {
                 require \Bitrix\Main\Application::getDocumentRoot() . "/404.php";
             }
             die;
         }
     }
 }
Ejemplo n.º 20
0
 /**
  * Read messages from user defined lang file
  */
 private static function loadCustomMessages($lang)
 {
     $customMess = array();
     $documentRoot = \Bitrix\Main\Application::getDocumentRoot();
     if (($fname = Main\Loader::getLocal("php_interface/user_lang/" . $lang . "/lang.php", $documentRoot)) !== false) {
         $mess = self::includeFile($fname);
         // typical call is Loc::loadMessages(__FILE__)
         // __FILE__ can differ from path used in the user file
         foreach ($mess as $key => $val) {
             $customMess[str_replace("\\", "/", realpath($documentRoot . $key))] = $val;
         }
     }
     return $customMess;
 }
Ejemplo n.º 21
0
 /**
  * Returns actions list
  * @param bool $checkConditions - if we need to check conditions
  * @return array of all actions defenitions
  * @throws \Bitrix\Main\IO\FileNotFoundException
  */
 public static function getList($checkConditions = false)
 {
     static $def = null;
     if ($def == null) {
         $filename = \Bitrix\Main\Application::getDocumentRoot() . "/bitrix/modules/scale/include/actionsdefinitions.php";
         $file = new \Bitrix\Main\IO\File($filename);
         if ($file->isExists()) {
             require_once $filename;
         } else {
             throw new \Bitrix\Main\IO\FileNotFoundException($filename);
         }
         if (isset($actionsDefinitions)) {
             $def = $actionsDefinitions;
             if (is_array($def) && $checkConditions) {
                 foreach ($def as $actionId => $action) {
                     if (isset($action["CONDITION"]) && !self::isConditionSatisfied($action["CONDITION"])) {
                         unset($def[$actionId]);
                     }
                 }
             }
         } else {
             $def = array();
         }
     }
     return $def;
 }
Ejemplo n.º 22
0
 /**
  * Binds (and creates if it's necessary) template to the application folder
  *
  * @param $templateId - symbolic code of the template
  * @param $folder - the application folder
  * @param bool $createNew - flag of the necessity of creating a new template
  */
 public static function bindTemplate($templateId, $folder, $createNew)
 {
     $arFields = array("TEMPLATE" => array());
     if ($createNew) {
         CopyDirFiles(Application::getDocumentRoot() . "/bitrix/modules/mobileapp/templates/default_app/", Application::getDocumentRoot() . "/bitrix/templates/" . $templateId, True, True);
         File::putFileContents(Application::getDocumentRoot() . "/bitrix/templates/" . $templateId . "/description.php", str_replace(array("#mobile_template_name#"), array($templateId), File::getFileContents(Application::getDocumentRoot() . "/bitrix/templates/" . $templateId . "/description.php")));
         $arFields["TEMPLATE"][] = array("SORT" => 1, "CONDITION" => "CSite::InDir('/" . $folder . "/')", "TEMPLATE" => $templateId);
     }
     $default_site_id = \CSite::GetDefSite();
     if ($default_site_id) {
         $dbTemplates = \CSite::GetTemplateList($default_site_id);
         $arFields["LID"] = $default_site_id;
         $isTemplateFound = false;
         while ($template = $dbTemplates->Fetch()) {
             $arFields["TEMPLATE"][] = array("TEMPLATE" => $template['TEMPLATE'], "SORT" => $template['SORT'], "CONDITION" => $template['CONDITION']);
             if ($template["TEMPLATE"] == $templateId && !$createNew && !$isTemplateFound) {
                 $isTemplateFound = true;
                 $arFields["TEMPLATE"][] = array("SORT" => 1, "CONDITION" => "CSite::InDir('/" . $folder . "/')", "TEMPLATE" => $templateId);
             }
         }
         $obSite = new \CSite();
         $obSite->Update($default_site_id, $arFields);
     }
 }
Ejemplo n.º 23
0
 /**
  * Sets viewport-metadata
  */
 public static function initScripts()
 {
     global $APPLICATION;
     \CJSCore::Init();
     $APPLICATION->AddHeadString("<script type=\"text/javascript\">var mobileSiteDir=\"" . SITE_DIR . "\"; var appVersion = " . self::$apiVersion . ";var platform = \"" . self::$platform . "\";</script>", false, true);
     if (self::$platform == "android") {
         /**
          * This is workaround for android
          * We use console.log() to tell the application about successful loading of this page
          */
         $APPLICATION->AddHeadString("<script type=\"text/javascript\">console.log(\"bxdata://success\")</script>", false, true);
     }
     if (self::getInstance()->getBXScriptSupported()) {
         /**
          * If the application tells us bxscript-feature is available
          * it means that device can load cordova-scripts (including plugins) itself.
          */
         $pgJsFile = "/bitrix/js/mobileapp/__deviceload__/cordova.js";
         $APPLICATION->AddHeadString("<script type=\"text/javascript\" src=\"" . $pgJsFile . "\"></script>", false, true);
     } else {
         $pgJsFile = "/bitrix/js/mobileapp/" . self::$platform . "-cordova-" . self::$pgVersion . ".js";
         if (!File::isFileExists(Application::getDocumentRoot() . $pgJsFile)) {
             $pgJsFile = self::$remoteScriptPath . self::$platform . "-cordova-" . self::$pgVersion . ".js";
         }
         $APPLICATION->AddHeadString("<script type=\"text/javascript\" src=\"" . \CUtil::GetAdditionalFileURL($pgJsFile) . "\"></script>", false, true);
     }
     $APPLICATION->AddHeadString("<script type=\"text/javascript\" src=\"" . \CUtil::GetAdditionalFileURL("/bitrix/js/mobileapp/bitrix_mobile.js") . "\"></script>", false, true);
     $APPLICATION->AddHeadString("<script type=\"text/javascript\" src=\"" . \CUtil::GetAdditionalFileURL("/bitrix/js/mobileapp/mobile_lib.js") . "\"></script>", false, true);
     if (self::$platform == "android") {
         $APPLICATION->AddHeadString("<script type=\"text/javascript\">app.bindloadPageBlank();</script>", false, false);
     }
     $APPLICATION->AddHeadString(Mobile::getInstance()->getViewPort());
 }
Ejemplo n.º 24
0
		box-shadow: 0 1px 0 0 rgba(255, 255, 255, 0.3), 0 2px 2px -1px rgba(180, 188, 191, 0.7) inset;
		color: #000000;
		display: inline-block;
		outline: medium none;
		vertical-align: middle;
		!important;
	}
</style>';
Asset::getInstance()->addString($lheStyle);
Asset::getInstance()->addJs("/bitrix/js/sale/pay_system.js");
\Bitrix\Sale\Delivery\Restrictions\Manager::getClassesList();
$instance = Application::getInstance();
$context = $instance->getContext();
$request = $context->getRequest();
$server = $context->getServer();
$documentRoot = Application::getDocumentRoot();
$id = (int) $request->get('ID');
if (CModule::IncludeModule("fileman")) {
    $bFilemanModuleInst = true;
}
$aTabs = array(array("DIV" => "edit1", "TAB" => GetMessage("SPSN_TAB_PAYSYS"), "ICON" => "sale", "TITLE" => GetMessage("SPSN_TAB_PAYSYS_DESCR")));
if ($id > 0 && $request->getRequestMethod() !== 'POST') {
    $aTabs[] = array("DIV" => "edit3", "TAB" => GetMessage("SPS_PAY_SYSTEM_RESTRICTION"), "ICON" => "sale", "TITLE" => GetMessage("SPS_PAY_SYSTEM_RESTRICTION_DESC"));
}
$tabControl = new CAdminTabControl("tabControl", $aTabs);
$errorMessage = '';
$businessValueControl = new BusinessValueControl('PAYSYSTEM');
if ($server->getRequestMethod() == "POST" && ($request->get('save') !== null || $request->get('apply') !== null) && $saleModulePermissions == "W" && check_bitrix_sessid()) {
    $name = trim($request->get('NAME'));
    if ($name == '') {
        $errorMessage .= Loc::getMessage("ERROR_NO_NAME") . "<br>";
Ejemplo n.º 25
0
<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
include \Bitrix\Main\Application::getDocumentRoot() . '/bitrix/modules/sale/handlers/paysystem/yandex/.description.php';
Ejemplo n.º 26
0
 /**
  * Parses the passed content to find css, js and images. Returns the array of files.
  *
  * @param $content
  *
  * @return array
  */
 public function getFilesFromContent($content)
 {
     $files = array();
     $arFilesByType = array();
     $arExtensions = array("js", "css");
     $extension_regex = "(?:" . implode("|", $arExtensions) . ")";
     $regex = "/\n\t\t\t\t((?i:\n\t\t\t\t\thref=\n\t\t\t\t\t|src=\n\t\t\t\t\t|BX\\.loadCSS\\(\n\t\t\t\t\t|BX\\.loadScript\\(\n\t\t\t\t\t|jsUtils\\.loadJSFile\\(\n\t\t\t\t\t|background\\s*:\\s*url\\(\n\t\t\t\t))                                                   #attribute\n\t\t\t\t(\"|')                                               #open_quote\n\t\t\t\t([^?'\"]+\\.)                                        #href body\n\t\t\t\t(" . $extension_regex . ")                           #extentions\n\t\t\t\t(|\\?\\d+|\\?v=\\d+)                                 #params\n\t\t\t\t(\\2)                                                #close_quote\n\t\t\t/x";
     $match = array();
     preg_match_all($regex, $content, $match);
     $link = $match[3];
     $extension = $match[4];
     $params = $match[5];
     $linkCount = count($link);
     $fileData = array("FULL_FILE_LIST" => array(), "FILE_TIMESTAMPS" => array(), "CSS_FILE_IMAGES" => array());
     for ($i = 0; $i < $linkCount; $i++) {
         $fileData["FULL_FILE_LIST"][] = $files[] = $link[$i] . $extension[$i] . $params[$i];
         $fileData["FILE_TIMESTAMPS"][$link[$i] . $extension[$i]] = $params[$i];
         $arFilesByType[$extension[$i]][] = $link[$i] . $extension[$i];
     }
     $manifestCache = $this->readManifestCache($this->getCurrentManifestID());
     if (array_key_exists("css", $arFilesByType)) {
         $cssCount = count($arFilesByType["css"]);
         for ($j = 0; $j < $cssCount; $j++) {
             $cssFilePath = $arFilesByType["css"][$j];
             if ($manifestCache["FILE_DATA"]["FILE_TIMESTAMPS"][$cssFilePath] != $fileData["FILE_TIMESTAMPS"][$cssFilePath]) {
                 $fileContent = false;
                 $fileUrl = parse_url($cssFilePath);
                 $file = new \Bitrix\Main\IO\File(Application::getDocumentRoot() . $fileUrl['path']);
                 if ($file->isExists() && $file->isReadable()) {
                     $fileContent = $file->getContents();
                 } elseif ($fileUrl["scheme"]) {
                     $req = new \CHTTP();
                     $req->http_timeout = 20;
                     $fileContent = $req->Get($cssFilePath);
                 }
                 if ($fileContent != false) {
                     $regex = '#([;\\s:]*(?:url|@import)\\s*\\(\\s*)(\'|"|)(.+?)(\\2)\\s*\\)#si';
                     $cssFileRelative = new \Bitrix\Main\IO\File($cssFilePath);
                     $cssPath = $cssFileRelative->getDirectoryName();
                     preg_match_all($regex, $fileContent, $match);
                     $matchCount = count($match[3]);
                     for ($k = 0; $k < $matchCount; $k++) {
                         $file = self::replaceUrlCSS($match[3][$k], addslashes($cssPath));
                         if (!in_array($file, $files) && !strpos($file, ";base64")) {
                             $fileData["FULL_FILE_LIST"][] = $files[] = $file;
                             $fileData["CSS_FILE_IMAGES"][$cssFilePath][] = $file;
                         }
                     }
                 }
             } else {
                 $fileData["CSS_FILE_IMAGES"][$cssFilePath] = $manifestCache["FILE_DATA"]["CSS_FILE_IMAGES"][$cssFilePath];
                 if (is_array($manifestCache["FILE_DATA"]["CSS_FILE_IMAGES"][$cssFilePath])) {
                     $fileData["FULL_FILE_LIST"] = array_merge($fileData["FULL_FILE_LIST"], $manifestCache["FILE_DATA"]["CSS_FILE_IMAGES"][$cssFilePath]);
                 }
             }
         }
     }
     return $fileData;
 }
Ejemplo n.º 27
0
 /**
  * Function gets pay system info from database, no cache is used here
  * @return void
  */
 protected function obtainDataPaySystem()
 {
     if (empty($this->dbResult["ID"])) {
         return;
     }
     foreach ($this->dbResult['PAYMENT'] as &$payment) {
         if (intval($payment["PAY_SYSTEM_ID"])) {
             $payment["PAY_SYSTEM"] = \Bitrix\Sale\PaySystem\Manager::getById($payment["PAY_SYSTEM_ID"]);
             $payment["PAY_SYSTEM"]['NAME'] = htmlspecialcharsbx($payment["PAY_SYSTEM"]['NAME']);
         }
         if ($payment["PAID"] != "Y" && $this->dbResult["CANCELED"] != "Y") {
             $payment['BUFFERED_OUTPUT'] = '';
             $payment['ERROR'] = '';
             $service = new \Bitrix\Sale\PaySystem\Service($payment["PAY_SYSTEM"]);
             if ($service) {
                 $payment["CAN_REPAY"] = "Y";
                 if ($service->getField("NEW_WINDOW") == "Y") {
                     $payment["PAY_SYSTEM"]["PSA_ACTION_FILE"] = htmlspecialcharsbx($this->arParams["PATH_TO_PAYMENT"]) . '?ORDER_ID=' . urlencode(urlencode($this->dbResult["ACCOUNT_NUMBER"])) . '&PAYMENT_ID=' . $payment['ID'];
                 } else {
                     CSalePaySystemAction::InitParamArrays($this->dbResult, $this->requestData["ID"], '', array(), $payment);
                     // for compatibility
                     $actionFile = $service->getField('ACTION_FILE');
                     $map = CSalePaySystemAction::getOldToNewHandlersMap();
                     $oldHandler = array_search($actionFile, $map);
                     if ($oldHandler !== false && !$service->isCustom()) {
                         $actionFile = $oldHandler;
                     }
                     $pathToAction = Main\Application::getDocumentRoot() . $actionFile;
                     $pathToAction = str_replace("\\", "/", $pathToAction);
                     while (substr($pathToAction, strlen($pathToAction) - 1, 1) == "/") {
                         $pathToAction = substr($pathToAction, 0, strlen($pathToAction) - 1);
                     }
                     if (file_exists($pathToAction)) {
                         if (is_dir($pathToAction) && file_exists($pathToAction . "/payment.php")) {
                             $pathToAction .= "/payment.php";
                         }
                         $payment["PAY_SYSTEM"]["PSA_ACTION_FILE"] = $pathToAction;
                     }
                     $encoding = $service->getField("ENCODING");
                     if (strlen($encoding) > 0) {
                         define("BX_SALE_ENCODING", $encoding);
                         AddEventHandler("main", "OnEndBufferContent", array($this, "changeBodyEncoding"));
                     }
                     /** @var \Bitrix\Sale\Order $order */
                     $order = \Bitrix\Sale\Order::load($this->dbResult["ID"]);
                     if ($order) {
                         /** @var \Bitrix\Sale\PaymentCollection $paymentCollection */
                         $paymentCollection = $order->getPaymentCollection();
                         if ($paymentCollection) {
                             /** @var \Bitrix\Sale\Payment $paymentItem */
                             $paymentItem = $paymentCollection->getItemById($payment['ID']);
                             if ($paymentItem) {
                                 $initResult = $service->initiatePay($paymentItem, null, \Bitrix\Sale\PaySystem\BaseServiceHandler::STRING);
                                 if ($initResult->isSuccess()) {
                                     $payment['BUFFERED_OUTPUT'] = $initResult->getTemplate();
                                 } else {
                                     $payment['ERROR'] = implode('\\n', $initResult->getErrorMessages());
                                 }
                             }
                         }
                     }
                 }
                 $payment["PAY_SYSTEM"]["PSA_NEW_WINDOW"] = $payment["PAY_SYSTEM"]["NEW_WINDOW"];
             }
         }
     }
     unset($payment);
     // for compatibility
     $this->dbResult['PAY_SYSTEM'] = $this->dbResult['PAYMENT'][0]['PAY_SYSTEM'];
     $this->dbResult['CAN_REPAY'] = $this->dbResult['PAYMENT'][0]['CAN_REPAY'];
 }
Ejemplo n.º 28
0
<?php

require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/header.php";
$documentRoot = \Bitrix\Main\Application::getDocumentRoot();
$request = \Bitrix\Main\Application::getInstance()->getContext()->getRequest();
$document = false;
if (file_exists($documentRoot . $request->get('path'))) {
    $document = $documentRoot . $request->get('path');
} elseif (file_exists($documentRoot . "/upload/acrit.exportpro/" . $request->get('path'))) {
    $document = $documentRoot . "/upload/acrit.exportpro/" . $request->get('path');
} elseif (file_exists($documentRoot . "/upload/" . $request->get('path'))) {
    $document = $documentRoot . "/upload/" . $request->get('path');
}
if ($document) {
    $APPLICATION->RestartBuffer();
    if (stripos($request->get('path'), "xml") !== false) {
        header("Expires: Thu, 19 Feb 1998 13:24:18 GMT");
        header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
        header("Cache-Control: no-cache, must-revalidate");
        header("Cache-Control: post-check=0,pre-check=0");
        header("Pragma: no-cache");
        header("Content-Type: text/xml");
        //header("Cache-Control: max-age=0");
        //echo file_get_contents($documentRoot.'/upload/acrit.exportpro/'.$request->get('path'));
        echo file_get_contents($document);
    } elseif (stripos($request->get('path'), "zip") !== false) {
        header("Pragma: public");
        header("Expires: 0");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Cache-Control: public");
        header("Content-Type: application/zip");
Ejemplo n.º 29
0
 public static function reindexAll($maxExecutionTime = 0, $ns = array())
 {
     @set_time_limit(0);
     if (!is_array($ns)) {
         $ns = array();
     }
     if ($maxExecutionTime <= 0) {
         $nsOld = $ns;
         $ns = array("CLEAR" => "N", "ID" => "", "FLG" => "", "SESS_ID" => md5(uniqid("")), "max_execution_time" => $nsOld["max_execution_time"], "stepped" => $nsOld["stepped"], "max_file_size" => $nsOld["max_file_size"]);
         if ($nsOld["SITE_ID"] != "") {
             $ns["SITE_ID"] = $nsOld["SITE_ID"];
         }
     }
     $ns["CNT"] = intval($ns["CNT"]);
     $arSites = array();
     $filterRootPath = "";
     $db = SiteTable::getList(array("select" => array("LID", "DOC_ROOT", "DIR"), "filter" => array("ACTIVE" => "Y")));
     while ($ar = $db->fetch()) {
         if (empty($ar["DOC_ROOT"])) {
             $ar["DOC_ROOT"] = Application::getDocumentRoot();
         }
         $arSites[] = array("site_id" => $ar["LID"], "root" => $ar["DOC_ROOT"], "path" => IO\Path::combine($ar["DOC_ROOT"], $ar["DIR"]));
         if ($ns["SITE_ID"] != "" && $ns["SITE_ID"] == $ar["LID"]) {
             $filterRootPath = $ar["DOC_ROOT"];
         }
     }
     if ($ns["SITE_ID"] != "" && !empty($filterRootPath)) {
         $arSitesTmp = array();
         $arKeys = array_keys($arSites);
         foreach ($arKeys as $key) {
             if ($arSites[$key]["root"] == $filterRootPath) {
                 $arSitesTmp[] = $arSites[$key];
             }
         }
         $arSites = $arSitesTmp;
     }
     uasort($arSites, function ($a, $b) {
         $la = strlen($a["path"]);
         $lb = strlen($b["path"]);
         if ($la == $lb) {
             if ($a["site_id"] == $b["site_id"]) {
                 return 0;
             } else {
                 return $a["site_id"] > $b["site_id"] ? -1 : 1;
             }
         }
         return $la > $lb ? -1 : 1;
     });
     if ($ns["CLEAR"] != "Y") {
         $arAlreadyDeleted = array();
         foreach ($arSites as $site) {
             Component\ParametersTable::deleteBySiteId($site["site_id"]);
             if (!in_array($site["root"], $arAlreadyDeleted)) {
                 UrlRewriter::delete($site["site_id"], array("!ID" => ""));
                 $arAlreadyDeleted[] = $site["root"];
             }
         }
     }
     $ns["CLEAR"] = "Y";
     clearstatcache();
     $arAlreadyParsed = array();
     foreach ($arSites as $site) {
         if (in_array($site["root"], $arAlreadyParsed)) {
             continue;
         }
         $arAlreadyParsed[] = $site["root"];
         if ($maxExecutionTime > 0 && !empty($ns["FLG"]) && substr($ns["ID"] . "/", 0, strlen($site["root"] . "/")) != $site["root"] . "/") {
             continue;
         }
         UrlRewriter::recursiveReindex($site["root"], "/", $arSites, $maxExecutionTime, $ns);
         if ($maxExecutionTime > 0 && !empty($ns["FLG"])) {
             return $ns;
         }
     }
     return $ns["CNT"];
 }
Ejemplo n.º 30
0
 private function getDbConnConnectionParameters()
 {
     /* Old kernel code for compatibility */
     global $DBType, $DBDebug, $DBDebugToFile, $DBHost, $DBName, $DBLogin, $DBPassword, $DBSQLServerType;
     require_once Main\Application::getDocumentRoot() . Main\Application::getPersonalRoot() . "/php_interface/dbconn.php";
     $DBType = strtolower($DBType);
     if ($DBType == 'mysql') {
         $className = "\\Bitrix\\Main\\DB\\MysqlConnection";
     } elseif ($DBType == 'mssql') {
         $className = "\\Bitrix\\Main\\DB\\MssqlConnection";
     } else {
         $className = "\\Bitrix\\Main\\DB\\OracleConnection";
     }
     return array('className' => $className, 'host' => $DBHost, 'database' => $DBName, 'login' => $DBLogin, 'password' => $DBPassword, 'options' => (!defined("DBPersistent") || DBPersistent ? Main\DB\Connection::PERSISTENT : 0) | (defined("DELAY_DB_CONNECT") && DELAY_DB_CONNECT === true ? Main\DB\Connection::DEFERRED : 0));
 }