コード例 #1
0
ファイル: iblockvalues.php プロジェクト: ASDAFF/open_bx
 function clearValues()
 {
     $connection = \Freetrix\Main\Application::getConnection();
     $connection->query("\n\t\t\tDELETE FROM b_iblock_element_iprop\n\t\t\tWHERE IBLOCK_ID = " . $this->iblock_id . "\n\t\t");
     $connection->query("\n\t\t\tDELETE FROM b_iblock_section_iprop\n\t\t\tWHERE IBLOCK_ID = " . $this->iblock_id . "\n\t\t");
     $connection->query("\n\t\t\tDELETE FROM b_iblock_iblock_iprop\n\t\t\tWHERE IBLOCK_ID = " . $this->iblock_id . "\n\t\t");
 }
コード例 #2
0
ファイル: oraclesqlhelper.php プロジェクト: ASDAFF/open_bx
    function forSql($value, $maxLength = 0)
    {
        if ($maxLength <= 0 || $maxLength > 2000) {
            $maxLength = 2000;
        }
        $value = substr($value, 0, $maxLength);
        if (\Freetrix\Main\Application::isUtfMode()) {
            // From http://w3.org/International/questions/qa-forms-utf-8.html
            // This one can crash php with segmentation fault on large input data (over 20K)
            // https://bugs.php.net/bug.php?id=60423
            if (preg_match_all('%(
				[\\x00-\\x7E]                        # ASCII
				|[\\xC2-\\xDF][\\x80-\\xBF]            # non-overlong 2-byte
				|\\xE0[\\xA0-\\xBF][\\x80-\\xBF]        # excluding overlongs
				|[\\xE1-\\xEC\\xEE\\xEF][\\x80-\\xBF]{2} # straight 3-byte
				|\\xED[\\x80-\\x9F][\\x80-\\xBF]        # excluding surrogates
				|\\xF0[\\x90-\\xBF][\\x80-\\xBF]{2}     # planes 1-3
				|[\\xF1-\\xF3][\\x80-\\xBF]{3}         # planes 4-15
				|\\xF4[\\x80-\\x8F][\\x80-\\xBF]{2}     # plane 16
			)+%x', $value, $match)) {
                $value = implode(' ', $match[0]);
            } else {
                return '';
            }
            //There is no valid utf at all
        }
        return str_replace("'", "''", $value);
    }
コード例 #3
0
ファイル: culture.php プロジェクト: ASDAFF/open_bx
 public static function update($primary, array $data)
 {
     $result = parent::update($primary, $data);
     if (CACHED_b_lang !== false && $result->isSuccess()) {
         $cache = \Freetrix\Main\Application::getInstance()->getManagedCache();
         $cache->cleanDir("b_lang");
     }
     return $result;
 }
コード例 #4
0
ファイル: sectionvalues.php プロジェクト: ASDAFF/open_bx
 function clearValues()
 {
     $connection = \Freetrix\Main\Application::getConnection();
     $sectionList = \Freetrix\Iblock\SectionTable::getList(array("select" => array("LEFT_MARGIN", "RIGHT_MARGIN"), "filter" => array("=ID" => $this->section_id)));
     $section = $sectionList->fetch();
     if ($section) {
         $connection->query("\n\t\t\t\tDELETE FROM b_iblock_element_iprop\n\t\t\t\tWHERE IBLOCK_ID = " . $this->iblock_id . "\n\t\t\t\tAND ELEMENT_ID in (\n\t\t\t\t\tSELECT BSE.IBLOCK_ELEMENT_ID\n\t\t\t\t\tFROM b_iblock_section_element BSE\n\t\t\t\t\tINNER JOIN b_iblock_section BS ON BSE.IBLOCK_SECTION_ID = BS.ID AND BSE.ADDITIONAL_PROPERTY_ID IS NULL\n\t\t\t\t\tWHERE BS.IBLOCK_ID = " . $this->iblock_id . "\n\t\t\t\t\tAND BS.LEFT_MARGIN <= " . $section["RIGHT_MARGIN"] . "\n\t\t\t\t\tAND BS.RIGHT_MARGIN >= " . $section["LEFT_MARGIN"] . "\n\t\t\t\t)\n\t\t\t");
         $connection->query("\n\t\t\t\tDELETE FROM b_iblock_section_iprop\n\t\t\t\tWHERE IBLOCK_ID = " . $this->iblock_id . "\n\t\t\t\tAND SECTION_ID in (\n\t\t\t\t\tSELECT BS.ID\n\t\t\t\t\tFROM b_iblock_section BS\n\t\t\t\t\tWHERE BS.IBLOCK_ID = " . $this->iblock_id . "\n\t\t\t\t\tAND BS.LEFT_MARGIN <= " . $section["RIGHT_MARGIN"] . "\n\t\t\t\t\tAND BS.RIGHT_MARGIN >= " . $section["LEFT_MARGIN"] . "\n\t\t\t\t)\n\t\t\t");
     }
 }
コード例 #5
0
ファイル: user.php プロジェクト: ASDAFF/open_bx
 public static function getActiveUsersCount()
 {
     if (ModuleManager::isModuleInstalled("intranet")) {
         $sql = "SELECT COUNT(U.ID) " . "FROM b_user U " . "WHERE U.ACTIVE = 'Y' " . "   AND U.LAST_LOGIN IS NOT NULL " . "   AND EXISTS(" . "       SELECT 'x' " . "       FROM b_utm_user UF, b_user_field F " . "       WHERE F.ENTITY_ID = 'USER' " . "           AND F.FIELD_NAME = 'UF_DEPARTMENT' " . "           AND UF.FIELD_ID = F.ID " . "           AND UF.VALUE_ID = U.ID " . "           AND UF.VALUE_INT IS NOT NULL " . "           AND UF.VALUE_INT <> 0" . "   )";
     } else {
         $sql = "SELECT COUNT(ID) " . "FROM b_user " . "WHERE ACTIVE = 'Y' " . "   AND LAST_LOGIN IS NOT NULL";
     }
     $connection = Application::getConnection();
     return $connection->queryScalar($sql);
 }
コード例 #6
0
 function renderExceptionMessage(\Exception $exception, $debug = false)
 {
     if ($debug) {
         echo ExceptionHandlerFormatter::format($exception, false);
     } else {
         $context = Main\Application::getInstance();
         if ($context) {
             echo Main\Localization\Loc::getMessage("eho_render_exception_message");
         } else {
             echo "A error occurred during execution of this script. You can turn on extended error reporting in .settings.php file.";
         }
     }
 }
コード例 #7
0
ファイル: json.php プロジェクト: ASDAFF/open_bx
 public function decode($data)
 {
     $res = json_decode($data, true);
     self::checkException();
     // PHP<5.3.3 returns no error for JSON_ERROR_UTF8 and some other ones
     if ($res === null && ToLower($data) != 'null') {
         self::throwException(self::JSON_ERROR_UNKNOWN);
     }
     if (!Application::getInstance()->isUtfMode()) {
         $res = self::unConvertData($res);
     }
     return $res;
 }
コード例 #8
0
ファイル: httpresponse.php プロジェクト: ASDAFF/open_bx
 private function createStandardHeaders()
 {
     $server = $this->context->getServer();
     if ($server->get("REDIRECT_STATUS") != null && $server->get("REDIRECT_STATUS") == 404) {
         if (Config\Option::get("main", "header_200", "N") == "Y") {
             $this->setStatus("200 OK");
         }
     }
     $dispatcher = Application::getInstance()->getDispatcher();
     $key = $dispatcher->getLicenseKey();
     $this->addHeader("X-Powered-CMS", "Freetrix Site Manager (" . ($key == "DEMO" ? "DEMO" : md5("FREETRIX" . $key . "LICENCE")) . ")");
     if (Config\Option::get("main", "set_p3p_header", "Y") == "Y") {
         $this->addHeader("P3P", "policyref=\"/freetrix/p3p.xml\", CP=\"NON DSP COR CUR ADM DEV PSA PSD OUR UNR BUS UNI COM NAV INT DEM STA\"");
     }
 }
コード例 #9
0
ファイル: parameters.php プロジェクト: ASDAFF/open_bx
 public static function deleteBySiteId($siteId)
 {
     if (empty($siteId)) {
         throw new \Freetrix\Main\ArgumentNullException("siteId");
     }
     $result = new \Freetrix\Main\Entity\DeleteResult();
     // event PRE
     // delete
     $connection = \Freetrix\Main\Application::getConnection();
     $helper = $connection->getSqlHelper();
     $tableName = static::getEntity()->getDBTableName();
     $sql = "DELETE FROM " . $tableName . " WHERE SITE_ID = '" . $helper->forSql($siteId) . "'";
     $connection->queryExecute($sql);
     // event POST
     return $result;
 }
コード例 #10
0
ファイル: filesystementry.php プロジェクト: ASDAFF/open_bx
 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);
     }
 }
コード例 #11
0
ファイル: sitetemplate.php プロジェクト: ASDAFF/open_bx
 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";
 }
コード例 #12
0
 function renderExceptionMessage(\Exception $exception, $debug = false)
 {
     if ($debug) {
         echo ExceptionHandlerFormatter::format($exception, true);
     } else {
         $p = Main\IO\Path::convertRelativeToAbsolute("/error.php");
         if (Main\IO\File::isFileExists($p)) {
             include $p;
         } else {
             $context = Main\Application::getInstance();
             if ($context) {
                 echo Main\Localization\Loc::getMessage("eho_render_exception_message");
             } else {
                 echo "A error occurred during execution of this script. You can turn on extended error reporting in .settings.php file.";
             }
         }
     }
 }
コード例 #13
0
ファイル: mysqliconnection.php プロジェクト: ASDAFF/open_bx
 protected function connectInternal()
 {
     if ($this->isConnected) {
         return;
     }
     $dbHost = $this->dbHost;
     $dbPort = 0;
     if (($pos = strpos($dbHost, ":")) !== false) {
         $dbPort = intval(substr($dbHost, $pos + 1));
         $dbHost = substr($dbHost, 0, $pos);
     }
     if (($this->dbOptions & self::PERSISTENT) != 0) {
         $dbHost = "p:" . $dbHost;
     }
     /** @var $connection \mysqli */
     $connection = \mysqli_init();
     if (!$connection) {
         throw new ConnectionException('Mysql init failed');
     }
     if (!empty($this->dbInitCommand)) {
         if (!$connection->options(MYSQLI_INIT_COMMAND, $this->dbInitCommand)) {
             throw new ConnectionException('Setting mysql init command failed');
         }
     }
     if ($dbPort > 0) {
         $r = $connection->real_connect($dbHost, $this->dbLogin, $this->dbPassword, $this->dbName, $dbPort);
     } else {
         $r = $connection->real_connect($dbHost, $this->dbLogin, $this->dbPassword, $this->dbName);
     }
     if (!$r) {
         throw new ConnectionException('Mysql connect error', sprintf('(%s) %s', $connection->connect_errno, $connection->connect_error));
     }
     $this->resource = $connection;
     $this->isConnected = true;
     // nosql memcached driver
     if (isset($this->configuration['memcache'])) {
         $memcached = \Freetrix\Main\Application::getInstance()->getConnectionPool()->getConnection($this->configuration['memcache']);
         mysqlnd_memcache_set($this->resource, $memcached->getResource());
     }
     //global $DB, $USER, $APPLICATION;
     if ($fn = \Freetrix\Main\Loader::getPersonal("php_interface/after_connect_d7.php")) {
         include $fn;
     }
 }
コード例 #14
0
ファイル: site.php プロジェクト: ASDAFF/open_bx
 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];
 }
コード例 #15
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"]);
     }
     if (isset($options["level"]) && $options["level"] > 0) {
         $this->level = intval($options["level"]);
     }
 }
コード例 #16
0
ファイル: sqlexpression.php プロジェクト: ASDAFF/open_bx
 protected function execPlaceholders($matches)
 {
     $sqlHelper = Application::getConnection()->getSqlHelper();
     $this->i++;
     $pre = $matches[1];
     $ph = $matches[2];
     if (isset($this->args[$this->i])) {
         $value = $this->args[$this->i];
         if ($ph == '?' || $ph == '?s') {
             $value = "'" . $sqlHelper->forSql($value) . "'";
         } elseif ($ph == '?#') {
             $value = $sqlHelper->quote($value);
         } elseif ($ph == '?i') {
             $value = (int) $value;
         } elseif ($ph == '?f') {
             $value = (double) $value;
         }
         return $pre . $value;
     }
     return $matches[0];
 }
コード例 #17
0
ファイル: sitemapentity.php プロジェクト: ASDAFF/open_bx
 public static function clearBySitemap($sitemapId)
 {
     $connection = \Freetrix\Main\Application::getConnection();
     $connection->query("\nDELETE\nFROM " . self::getTableName() . "\nWHERE SITEMAP_ID=" . intval($sitemapId) . " AND ENTITY_TYPE='" . static::ENTITY_TYPE . "'\n");
 }
コード例 #18
0
ファイル: urlrewriter.php プロジェクト: ASDAFF/open_bx
 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"];
 }
コード例 #19
0
ファイル: base.php プロジェクト: ASDAFF/open_bx
 public function getConnection()
 {
     return \Freetrix\Main\Application::getInstance()->getConnectionPool()->getConnection($this->connectionName);
 }
コード例 #20
0
ファイル: statichtmlcache.php プロジェクト: ASDAFF/open_bx
 /**
  * Reads the configuration.
  *
  * @return array
  */
 public function includeConfiguration()
 {
     if (!isset($this->options)) {
         $arHTMLPagesOptions = array();
         $configurationPath = Main\IO\Path::convertRelativeToAbsolute(Main\Application::getPersonalRoot() . "/html_pages/.config.php");
         if (file_exists($configurationPath)) {
             include $configurationPath;
         }
         $this->options = $arHTMLPagesOptions;
     }
     return $this->options;
 }
コード例 #21
0
ファイル: application.php プロジェクト: ASDAFF/open_bx
 /**
  * Returns personal root directory (relative to document root)
  *
  * @return null|string
  */
 public static function getPersonalRoot()
 {
     static $personalRoot = null;
     if ($personalRoot != null) {
         return $personalRoot;
     }
     $context = Application::getInstance()->getContext();
     if ($context != null) {
         $server = $context->getServer();
         if ($server != null) {
             return $personalRoot = $server->getPersonalRoot();
         }
     }
     return isset($_SERVER["FX_PERSONAL_ROOT"]) ? $_SERVER["FX_PERSONAL_ROOT"] : "/freetrix";
 }
コード例 #22
0
ファイル: cache.php プロジェクト: ASDAFF/open_bx
 public function __construct()
 {
     $app = \Freetrix\Main\Application::getInstance();
     $this->taggedCache = $app->getTaggedCache();
 }
コード例 #23
0
ファイル: managedcache.php プロジェクト: ASDAFF/open_bx
 public static function finalize()
 {
     $cacheManager = Main\Application::getInstance()->getManagedCache();
     $cache = Cache::createInstance();
     foreach ($cacheManager->cache as $uniqueId => $val) {
         if (array_key_exists($uniqueId, $cacheManager->vars)) {
             $cache->startDataCache($cacheManager->ttl[$uniqueId], $uniqueId, $cacheManager->cachePath[$uniqueId], $cacheManager->vars[$uniqueId], "managed_cache");
             $cache->endDataCache();
         }
     }
 }
コード例 #24
0
ファイル: taggedcache.php プロジェクト: ASDAFF/open_bx
 public function clearByTag($tag)
 {
     $con = Main\Application::getConnection();
     $sqlHelper = $con->getSqlHelper();
     if ($tag === true) {
         $sqlWhere = " WHERE TAG <> '*'";
     } else {
         $sqlWhere = "  WHERE TAG = '" . $sqlHelper->forSql($tag) . "'";
     }
     $arDirs = array();
     $rs = $con->query("SELECT * FROM b_cache_tag" . $sqlWhere);
     while ($ar = $rs->fetch()) {
         $arDirs[$ar["RELATIVE_PATH"]] = $ar;
     }
     $con->queryExecute("DELETE FROM b_cache_tag" . $sqlWhere);
     $cache = Cache::createInstance();
     $managedCache = Main\Application::getInstance()->getManagedCache();
     foreach ($arDirs as $path => $ar) {
         $con->queryExecute("\n\t\t\t\tDELETE FROM b_cache_tag\n\t\t\t\tWHERE SITE_ID = '" . $sqlHelper->forSql($ar["SITE_ID"]) . "'\n\t\t\t\tAND CACHE_SALT = '" . $sqlHelper->forSql($ar["CACHE_SALT"]) . "'\n\t\t\t\tAND RELATIVE_PATH = '" . $sqlHelper->forSql($ar["RELATIVE_PATH"]) . "'\n\t\t\t");
         if (preg_match("/^managed:(.+)\$/", $path, $match)) {
             $managedCache->cleanDir($match[1]);
         } else {
             $cache->cleanDir($path);
         }
         unset($this->dbCacheTags[$path]);
     }
 }
コード例 #25
0
ファイル: encoding.php プロジェクト: ASDAFF/open_bx
 public static function convertEncodingToCurrent($string)
 {
     $isUtf8String = self::detectUtf8($string);
     $isUtf8Config = Application::isUtfMode();
     $currentCharset = null;
     $context = Application::getInstance()->getContext();
     if ($context != null) {
         $culture = $context->getCulture();
         if ($culture != null && method_exists($culture, "getCharset")) {
             $currentCharset = $culture->getCharset();
         }
     }
     if ($currentCharset == null) {
         $currentCharset = Configuration::getValue("default_charset");
     }
     if ($currentCharset == null) {
         $currentCharset = "Windows-1251";
     }
     $fromCp = "";
     $toCp = "";
     if ($isUtf8Config && !$isUtf8String) {
         $fromCp = $currentCharset;
         $toCp = "UTF-8";
     } elseif (!$isUtf8Config && $isUtf8String) {
         $fromCp = "UTF-8";
         $toCp = $currentCharset;
     }
     if ($fromCp !== $toCp) {
         $string = self::convertEncoding($string, $fromCp, $toCp);
     }
     return $string;
 }
コード例 #26
0
ファイル: eventmanager.php プロジェクト: ASDAFF/open_bx
 protected function clearLoadedHandlers()
 {
     $managedCache = Application::getInstance()->getManagedCache();
     $managedCache->clean(self::$cacheKey);
     foreach ($this->handlers as $module => $types) {
         foreach ($types as $type => $events) {
             foreach ($events as $i => $event) {
                 if ($event["FROM_DB"] == true) {
                     unset($this->handlers[$module][$type][$i]);
                 }
             }
         }
     }
     $this->isHandlersLoaded = false;
 }
コード例 #27
0
ファイル: appcachemanifest.php プロジェクト: ASDAFF/open_bx
 /**
  * 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 \Freetrix\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 \Freetrix\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;
 }
コード例 #28
0
ファイル: loc.php プロジェクト: ASDAFF/open_bx
 /**
  * Read messages from user defined lang file
  */
 private static function loadCustomMessages($lang)
 {
     $customMess = array();
     $documentRoot = 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;
 }
コード例 #29
0
ファイル: connectionpool.php プロジェクト: ASDAFF/open_bx
 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 = "\\Freetrix\\Main\\DB\\MysqlConnection";
     } elseif ($DBType == 'mssql') {
         $className = "\\Freetrix\\Main\\DB\\MssqlConnection";
     } else {
         $className = "\\Freetrix\\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));
 }
コード例 #30
0
ファイル: option.php プロジェクト: ASDAFF/open_bx
 public static function delete($moduleId, $filter = array())
 {
     if (static::$cacheTtl === null) {
         static::$cacheTtl = self::getCacheTtl();
     }
     if (static::$cacheTtl !== false) {
         $cache = Main\Application::getInstance()->getManagedCache();
         $cache->clean("b_option");
     }
     $con = Main\Application::getConnection();
     $sqlHelper = $con->getSqlHelper();
     $strSqlWhere = "";
     if (isset($filter["name"])) {
         if (empty($filter["name"])) {
             throw new Main\ArgumentNullException("filter[name]");
         }
         $strSqlWhere .= " AND NAME = '" . $sqlHelper->forSql($filter["name"]) . "' ";
     }
     if (isset($filter["site_id"])) {
         $strSqlWhere .= " AND SITE_ID " . ($filter["site_id"] == "" ? "IS NULL" : "= '" . $sqlHelper->forSql($filter["site_id"], 2) . "'");
     }
     if ($moduleId == "main") {
         $con->queryExecute("DELETE FROM b_option " . "WHERE MODULE_ID = 'main' " . "   AND NAME NOT LIKE '~%' " . "\tAND NAME NOT IN ('crc_code', 'admin_passwordh', 'server_uniq_id','PARAM_MAX_SITES', 'PARAM_MAX_USERS') " . $strSqlWhere);
     } else {
         $con->queryExecute("DELETE FROM b_option " . "WHERE MODULE_ID = '" . $sqlHelper->forSql($moduleId) . "' " . "   AND NAME <> '~bsm_stop_date' " . $strSqlWhere);
     }
     if (isset($filter["site_id"])) {
         $siteKey = $filter["site_id"] == "" ? "-" : $filter["site_id"];
         if (!isset($filter["name"])) {
             unset(self::$options[$siteKey][$moduleId]);
         } else {
             unset(self::$options[$siteKey][$moduleId][$filter["name"]]);
         }
     } else {
         $arSites = array_keys(self::$options);
         foreach ($arSites as $s) {
             if (!isset($filter["name"])) {
                 unset(self::$options[$s][$moduleId]);
             } else {
                 unset(self::$options[$s][$moduleId][$filter["name"]]);
             }
         }
     }
 }