Example #1
0
 function __construct()
 {
     if (self::$obMemcache == null) {
         self::$obMemcache = new \Memcache();
         $cacheConfig = Config\Configuration::getValue("cache");
         $v = isset($cacheConfig["memcache"]) ? $cacheConfig["memcache"] : null;
         if ($v != null && isset($v["host"]) && $v["host"] != "") {
             if ($v != null && isset($v["port"])) {
                 $port = intval($v["port"]);
             } else {
                 $port = 11211;
             }
             if (self::$obMemcache->connect($v["host"], $port)) {
                 self::$isConnected = true;
                 register_shutdown_function(array("\\Freetrix\\Main\\Data\\CacheEngineMemcache", "close"));
             }
         }
     }
     $v = Config\Configuration::getValue("cache");
     if ($v != null && isset($v["sid"]) && $v["sid"] != "") {
         $this->sid = $v["sid"];
     } else {
         $this->sid = "BX";
     }
 }
 public function __construct()
 {
     $v = \Freetrix\Main\Config\Configuration::getValue("cache");
     if ($v != null && isset($v["sid"]) && $v["sid"] != "") {
         $this->sid = $v["sid"];
     } else {
         $this->sid = "BX";
     }
 }
Example #3
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";
 }
Example #4
0
 /**
  * Search connection parameters (type, host, db, login and password) by connection name
  *
  * @param string $name Connection name
  * @return array('type' => string, 'host' => string, 'db_name' => string, 'login' => string, 'password' => string, "init_command" => string, "options" => string)|null
  * @throws \Freetrix\Main\ArgumentTypeException
  * @throws \Freetrix\Main\ArgumentNullException
  */
 private function searchConnectionParametersByName($name)
 {
     if (!is_string($name)) {
         throw new \Freetrix\Main\ArgumentTypeException("name", "string");
     }
     if ($name === "") {
         throw new \Freetrix\Main\ArgumentNullException("name");
     }
     if ($name === self::DEFAULT_CONNECTION) {
         $v = \Freetrix\Main\Config\Configuration::getValue(self::DEFAULT_CONNECTION_CONFIGURATION);
         if ($v != null) {
             return $v;
         }
         $DBType = "";
         $DBHost = "";
         $DBName = "";
         $DBLogin = "";
         $DBPassword = "";
         include \Freetrix\Main\IO\Path::convertRelativeToAbsolute("/freetrix/php_interface/dbconn.php");
         return array("type" => $DBType, "host" => $DBHost, "db_name" => $DBName, "login" => $DBLogin, "password" => $DBPassword);
     }
     /* TODO: реализовать */
     return null;
 }
Example #5
0
 public function getDefaultConnectionType()
 {
     $params = Config\Configuration::getValue('connections');
     if (isset($params[static::DEFAULT_CONNECTION_NAME]) && !empty($params[static::DEFAULT_CONNECTION_NAME])) {
         $cn = $params[static::DEFAULT_CONNECTION_NAME]['className'];
         if ($cn === "\\Freetrix\\Main\\DB\\MysqlConnection" || $cn === "\\Freetrix\\Main\\DB\\MysqliConnection") {
             return 'MYSQL';
         } elseif ($cn === "\\Freetrix\\Main\\DB\\OracleConnection") {
             return 'ORACLE';
         } else {
             return 'MSSQL';
         }
     }
     return strtoupper($GLOBALS["DBType"]);
 }
Example #6
0
 /**
  * Resets accelerator if any.
  */
 public static function resetAccelerator()
 {
     if (defined("FX_NO_ACCELERATOR_RESET")) {
         return;
     }
     $fl = Config\Configuration::getValue("no_accelerator_reset");
     if ($fl) {
         return;
     }
     if (function_exists("accelerator_reset")) {
         accelerator_reset();
     } elseif (function_exists("wincache_refresh_if_changed")) {
         wincache_refresh_if_changed();
     }
 }
Example #7
0
include_once $_SERVER["DOCUMENT_ROOT"] . "/freetrix/modules/main/lib/loader.php";
require_once $_SERVER["DOCUMENT_ROOT"] . FX_ROOT . "/modules/main/Helpers.php";
\Freetrix\Main\Loader::registerAutoLoadClasses("main", array("freetrix\\main\\application" => "lib/application.php", "freetrix\\main\\httpapplication" => "lib/httpapplication.php", "freetrix\\main\\argumentexception" => "lib/exception.php", "freetrix\\main\\argumentnullexception" => "lib/exception.php", "freetrix\\main\\argumentoutofrangeexception" => "lib/exception.php", "freetrix\\main\\argumenttypeexception" => "lib/exception.php", "freetrix\\main\notimplementedexception" => "lib/exception.php", "freetrix\\main\notsupportedexception" => "lib/exception.php", "freetrix\\main\\objectpropertyexception" => "lib/exception.php", "freetrix\\main\\systemexception" => "lib/exception.php", "freetrix\\main\\context" => "lib/context.php", "freetrix\\main\\httpcontext" => "lib/httpcontext.php", "freetrix\\mainvent" => "lib/event.php", "freetrix\\mainventmanager" => "lib/eventmanager.php", "freetrix\\mainventresult" => "lib/eventresult.php", "freetrix\\main\request" => "lib/request.php", "freetrix\\main\\httprequest" => "lib/httprequest.php", "freetrix\\main\response" => "lib/response.php", "freetrix\\main\\httpresponse" => "lib/httpresponse.php", "freetrix\\main\\modulemanager" => "lib/modulemanager.php", "freetrix\\main\\server" => "lib/server.php", "freetrix\\main\\config\\configuration" => "lib/config/configuration.php", "freetrix\\main\\config\\option" => "lib/config/option.php", "freetrix\\main\\context\\culture" => "lib/context/culture.php", "freetrix\\main\\context\\site" => "lib/context/site.php", "freetrix\\main\\data\\connection" => "lib/data/connection.php", "freetrix\\main\\data\\connectionpool" => "lib/data/connectionpool.php", "freetrix\\main\\data\\hsphpreadconnection" => "lib/data/hsphpreadconnection.php", "freetrix\\main\\data\nosqlconnection" => "lib/data/nosqlconnection.php", "freetrix\\main\\db\\arrayresult" => "lib/db/arrayresult.php", "freetrix\\main\\db\result" => "lib/db/result.php", "freetrix\\main\\db\\connection" => "lib/db/connection.php", "freetrix\\main\\db\\sqlexception" => "lib/db/sqlexception.php", "freetrix\\main\\db\\sqlqueryexception" => "lib/db/sqlexception.php", "freetrix\\main\\db\\sqlexpression" => "lib/db/sqlexpression.php", "freetrix\\main\\db\\sqlhelper" => "lib/db/sqlhelper.php", "freetrix\\main\\db\\mysqlconnection" => "lib/db/mysqlconnection.php", "freetrix\\main\\db\\mysqlresult" => "lib/db/mysqlresult.php", "freetrix\\main\\db\\mysqlsqlhelper" => "lib/db/mysqlsqlhelper.php", "freetrix\\main\\db\\mysqliconnection" => "lib/db/mysqliconnection.php", "freetrix\\main\\db\\mysqliresult" => "lib/db/mysqliresult.php", "freetrix\\main\\db\\mysqlisqlhelper" => "lib/db/mysqlisqlhelper.php", "freetrix\\main\\diag\\httpexceptionhandleroutput" => "lib/diag/httpexceptionhandleroutput.php", "freetrix\\main\\diag\fileexceptionhandlerlog" => "lib/diag/fileexceptionhandlerlog.php", "freetrix\\main\\diagxceptionhandler" => "lib/diag/exceptionhandler.php", "freetrix\\main\\diag\\iexceptionhandleroutput" => "lib/diag/iexceptionhandleroutput.php", "freetrix\\main\\diagxceptionhandlerlog" => "lib/diag/exceptionhandlerlog.php", "freetrix\\main\\io\file" => "lib/io/file.php", "freetrix\\main\\io\fileentry" => "lib/io/fileentry.php", "freetrix\\main\\io\\path" => "lib/io/path.php", "freetrix\\main\\io\filesystementry" => "lib/io/filesystementry.php", "freetrix\\main\\io\\ifilestream" => "lib/io/ifilestream.php", "freetrix\\main\\localization\\loc" => "lib/localization/loc.php", "freetrix\\main\text\\converter" => "lib/text/converter.php", "freetrix\\main\textmptyconverter" => "lib/text/emptyconverter.php", "freetrix\\main\textncoding" => "lib/text/encoding.php", "freetrix\\main\text\\htmlconverter" => "lib/text/htmlconverter.php", "freetrix\\main\text\\string" => "lib/text/string.php", "freetrix\\main\text\\xmlconverter" => "lib/text/xmlconverter.php", "freetrix\\main\type\\collection" => "lib/type/collection.php", "freetrix\\main\type\\datetime" => "lib/type/datetime.php", "freetrix\\main\type\\dictionary" => "lib/type/dictionary.php", "freetrix\\main\type\filterabledictionary" => "lib/type/filterabledictionary.php", "freetrix\\main\type\\parameterdictionary" => "lib/type/parameterdictionary.php", "freetrix\\main\\web\\cookie" => "lib/web/cookie.php", "freetrix\\main\\web\\uri" => "lib/web/uri.php", 'CTimeZone' => 'classes/general/time.php'));
$application = \Freetrix\Main\HttpApplication::getInstance();
$application->initializeBasicKernel();
define("B_PROLOG_INCLUDED", true);
/* Влияет на добавление типов инфоблока и просмотра инфоблоков */
FormDecode();
define("FX_UTF", true);
define("FX_FILE_PERMISSIONS", 0644);
define("FX_DIR_PERMISSIONS", 0755);
@umask(~FX_DIR_PERMISSIONS);
define("FX_DISABLE_INDEX_PAGE", true);
define("FX_UTF_PCRE_MODIFIER", "u");
define("POST_FORM_ACTION_URI", htmlspecialcharsbx("/" . ltrim($_SERVER["REQUEST_URI"], "/")));
$connectionSettings = \Freetrix\Main\Config\Configuration::getValue('connections');
$DBType = $connectionSettings['default']['dbType'];
$DBHost = $connectionSettings['default']['host'];
$DBLogin = $connectionSettings['default']['login'];
$DBPassword = $connectionSettings['default']['password'];
$DBName = $connectionSettings['default']['database'];
$DBDebug = $connectionSettings['default']['debug'];
$DBDebugToFile = $connectionSettings['default']['debugToFile'];
$DBCharset = $connectionSettings['default']['charset'];
require_once $_SERVER["DOCUMENT_ROOT"] . FX_ROOT . "/modules/main/classes/" . $DBType . "/database.php";
$GLOBALS["DB"] = new CDatabase();
$GLOBALS["DB"]->debug = $DBDebug;
$GLOBALS["DB"]->DebugToFile = $DBDebugToFile;
if (!$GLOBALS["DB"]->Connect($DBHost, $DBName, $DBLogin, $DBPassword, $DBCharset)) {
    /* @todo: make universal method/function */
    throw new \Exception("Cannont connect to database " . $DBName . '. Please check settings');
Example #8
0
 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;
 }
Example #9
0
 protected static function getDirectoryIndexArray()
 {
     static $directoryIndexDefault = array("index.php" => 1, "index.html" => 1, "index.htm" => 1, "index.phtml" => 1, "default.html" => 1, "index.php3" => 1);
     $directoryIndex = Main\Config\Configuration::getValue("directory_index");
     if ($directoryIndex !== null) {
         return $directoryIndex;
     }
     return $directoryIndexDefault;
 }
Example #10
0
 private static function getCacheTtl()
 {
     $cacheFlags = Configuration::getValue("cache_flags");
     if (!isset($cacheFlags["config_options"])) {
         return 0;
     }
     return $cacheFlags["config_options"];
 }
Example #11
0
 protected function updateDigest($userId, $password)
 {
     if (empty($userId)) {
         throw new Main\ArgumentNullException("userId");
     }
     if (!Main\Type\Int::isInteger($userId)) {
         throw new Main\ArgumentTypeException("userId");
     }
     $userId = intval($userId);
     $connection = Main\Application::getDbConnection();
     $sqlHelper = $connection->getSqlHelper();
     $recordset = $connection->query("SELECT U.LOGIN, UD.DIGEST_HA1 " . "FROM b_user U " . "   LEFT JOIN b_user_digest UD on U.ID = UD.USER_ID " . "WHERE U.ID = " . $userId);
     if ($record = $recordset->fetch()) {
         $realm = Main\Config\Configuration::getValue("http_auth_realm");
         if (is_null($realm)) {
             $realm = "Freetrix Site Manager";
         }
         $digest = md5($record["LOGIN"] . ':' . $realm . ':' . $password);
         if ($record["DIGEST_HA1"] == '') {
             //new digest
             $connection->queryExecute("INSERT INTO b_user_digest (USER_ID, DIGEST_HA1) " . "VALUES('" . $userId . "', '" . $sqlHelper->forSql($digest) . "')");
         } else {
             //update digest (login, password or realm were changed)
             if ($record["DIGEST_HA1"] !== $digest) {
                 $connection->queryExecute("UPDATE b_user_digest SET " . "   DIGEST_HA1 = '" . $sqlHelper->forSql($digest) . "' " . "WHERE USER_ID = " . $userId);
             }
         }
     }
 }
Example #12
0
 public static function createCacheEngine()
 {
     $cacheEngine = null;
     // Events can't be used here because events use cache
     $cacheType = "files";
     $v = Config\Configuration::getValue("cache");
     if ($v != null && isset($v["type"]) && !empty($v["type"])) {
         $cacheType = $v["type"];
     }
     if (is_array($cacheType)) {
         if (isset($cacheType["class_name"])) {
             if (!isset($cacheType["extension"]) || extension_loaded($cacheType["extension"])) {
                 if (isset($cacheType["required_file"]) && ($requiredFile = Main\Loader::getLocal($cacheType["required_file"])) !== false) {
                     require_once $requiredFile;
                 }
                 if (isset($cacheType["required_remote_file"])) {
                     require_once $cacheType["required_remote_file"];
                 }
                 $className = $cacheType["class_name"];
                 if (class_exists($className)) {
                     $cacheEngine = new $className();
                 }
             }
         }
     } else {
         switch ($cacheType) {
             case "memcache":
                 if (extension_loaded('memcache')) {
                     $cacheEngine = new CacheEngineMemcache();
                 }
                 break;
             case "eaccelerator":
                 if (extension_loaded('eaccelerator')) {
                     $cacheEngine = new CacheEngineEAccelerator();
                 }
                 break;
             case "apc":
                 if (extension_loaded('apc')) {
                     $cacheEngine = new CacheEngineApc();
                 }
                 break;
             case "xcache":
                 if (extension_loaded('xcache')) {
                     $cacheEngine = new CacheEngineXCache();
                 }
                 break;
             case "files":
                 $cacheEngine = new CacheEngineFiles();
                 break;
             case "none":
                 $cacheEngine = new CacheEngineNone();
                 break;
             default:
                 break;
         }
     }
     if ($cacheEngine == null) {
         $cacheEngine = new CacheEngineNone();
         trigger_error("Cache engine is not found", E_USER_WARNING);
     }
     if (!$cacheEngine->isAvailable()) {
         $cacheEngine = new CacheEngineNone();
         trigger_error("Cache engine is not available", E_USER_WARNING);
     }
     return $cacheEngine;
 }
Example #13
0
 public static function wnc()
 {
     $configuration = Configuration::getInstance();
     $configuration->loadConfiguration();
     $ar = array("utf_mode" => array("value" => defined('FX_UTF'), "readonly" => true), "default_charset" => array("value" => defined('FX_DEFAULT_CHARSET'), "readonly" => false), "no_accelerator_reset" => array("value" => defined('FX_NO_ACCELERATOR_RESET'), "readonly" => false), "http_status" => array("value" => defined('FX_HTTP_STATUS') && FX_HTTP_STATUS ? true : false, "readonly" => false));
     $cache = array();
     if (defined('FX_CACHE_SID')) {
         $cache["sid"] = FX_CACHE_SID;
     }
     if (file_exists($_SERVER["DOCUMENT_ROOT"] . "/freetrix/modules/cluster/memcache.php")) {
         $arList = null;
         include $_SERVER["DOCUMENT_ROOT"] . "/freetrix/modules/cluster/memcache.php";
         if (defined("FX_MEMCACHE_CLUSTER") && is_array($arList)) {
             foreach ($arList as $listKey => $listVal) {
                 $bOtherGroup = defined("FX_CLUSTER_GROUP") && $listVal["GROUP_ID"] !== FX_CLUSTER_GROUP;
                 if ($listVal["STATUS"] !== "ONLINE" || $bOtherGroup) {
                     unset($arList[$listKey]);
                 }
             }
             if (count($arList) > 0) {
                 $cache["type"] = array("extension" => "memcache", "required_file" => "modules/cluster/classes/general/memcache_cache.php", "class_name" => "CPHPCacheMemcacheCluster");
             }
         }
     }
     if (!isset($cache["type"])) {
         if (defined('FX_CACHE_TYPE')) {
             $cache["type"] = FX_CACHE_TYPE;
             switch ($cache["type"]) {
                 case "memcache":
                 case "CPHPCacheMemcache":
                     $cache["type"] = "memcache";
                     break;
                 case "eaccelerator":
                 case "CPHPCacheEAccelerator":
                     $cache["type"] = "eaccelerator";
                     break;
                 case "apc":
                 case "CPHPCacheAPC":
                     $cache["type"] = "apc";
                     break;
                 case "xcache":
                 case "CPHPCacheXCache":
                     $cache["type"] = array("extension" => "xcache", "required_file" => "modules/main/classes/general/cache_xcache.php", "class_name" => "CPHPCacheXCache");
                     break;
                 default:
                     if (defined("FX_CACHE_CLASS_FILE") && file_exists(FX_CACHE_CLASS_FILE)) {
                         $cache["type"] = array("required_remote_file" => FX_CACHE_CLASS_FILE, "class_name" => FX_CACHE_TYPE);
                     } else {
                         $cache["type"] = "files";
                     }
                     break;
             }
         } else {
             $cache["type"] = "files";
         }
     }
     if (defined("FX_MEMCACHE_PORT")) {
         $cache["memcache"]["port"] = intval(FX_MEMCACHE_PORT);
     }
     if (defined("FX_MEMCACHE_HOST")) {
         $cache["memcache"]["host"] = FX_MEMCACHE_HOST;
     }
     $ar["cache"] = array("value" => $cache, "readonly" => false);
     $cacheFlags = array();
     $arCacheConsts = array("CACHED_b_option" => "config_options", "CACHED_b_lang_domain" => "site_domain");
     foreach ($arCacheConsts as $const => $name) {
         $cacheFlags[$name] = defined($const) ? constant($const) : 0;
     }
     $ar["cache_flags"] = array("value" => $cacheFlags, "readonly" => false);
     $ar["cookies"] = array("value" => array("secure" => false, "http_only" => true), "readonly" => false);
     $ar["exception_handling"] = array("value" => array("debug" => true, "handled_errors_types" => E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE, "exception_errors_types" => E_ALL & ~E_NOTICE & ~E_WARNING & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_WARNING & ~E_COMPILE_WARNING, "ignore_silence" => false, "assertion_throws_exception" => true, "assertion_error_type" => E_USER_ERROR, "log" => array("settings" => array("file" => "freetrix/modules/error.log", "log_size" => 1000000))), "readonly" => false);
     global $DBType, $DBHost, $DBName, $DBLogin, $DBPassword;
     $DBType = strtolower($DBType);
     if ($DBType == 'mysql') {
         $dbClassName = "\\Freetrix\\Main\\DB\\MysqlConnection";
     } elseif ($DBType == 'mssql') {
         $dbClassName = "\\Freetrix\\Main\\DB\\MssqlConnection";
     } else {
         $dbClassName = "\\Freetrix\\Main\\DB\\OracleConnection";
     }
     $ar['connections']['value']['default'] = array('className' => $dbClassName, 'host' => $DBHost, 'database' => $DBName, 'login' => $DBLogin, 'password' => $DBPassword, 'options' => (!defined("DBPersistent") || DBPersistent ? 1 : 0) | (defined("DELAY_DB_CONNECT") && DELAY_DB_CONNECT === true ? 2 : 0));
     $ar['connections']['readonly'] = true;
     foreach ($ar as $k => $v) {
         if ($configuration->get($k) === null) {
             if ($v["readonly"]) {
                 $configuration->addReadonly($k, $v["value"]);
             } else {
                 $configuration->add($k, $v["value"]);
             }
         }
     }
     $configuration->saveConfiguration();
     $filename1 = $_SERVER["DOCUMENT_ROOT"] . "/freetrix/php_interface/after_connect.php";
     $filename2 = $_SERVER["DOCUMENT_ROOT"] . "/freetrix/php_interface/after_connect_d7.php";
     if (file_exists($filename1) && !file_exists($filename2)) {
         $source = file_get_contents($filename1);
         $source = trim($source);
         $pos = 2;
         if (strtolower(substr($source, 0, 5)) == '<?php') {
             $pos = 5;
         }
         $source = substr($source, 0, $pos) . "\n" . '$connection = \\Freetrix\\Main\\Application::getConnection();' . substr($source, $pos);
         $source = preg_replace("#\\\$DB->Query\\(#i", "\$connection->queryExecute(", $source);
         file_put_contents($filename2, $source);
     }
 }
Example #14
0
 public function setStatus($status)
 {
     $httpStatus = Config\Configuration::getValue("http_status");
     $cgiMode = stristr(php_sapi_name(), "cgi") !== false;
     if ($cgiMode && ($httpStatus == null || $httpStatus == false)) {
         $this->addHeader("Status", $status);
     } else {
         $server = $this->context->getServer();
         $this->addHeader($server->get("SERVER_PROTOCOL") . " " . $status);
     }
 }
Example #15
0
 protected function getCookieDomain()
 {
     static $bCache = false;
     static $cache = false;
     if ($bCache) {
         return $cache;
     }
     $context = \Freetrix\Main\Application::getInstance()->getContext();
     $server = $context->getServer();
     $cacheFlags = \Freetrix\Main\Config\Configuration::getValue("cache_flags");
     $cacheTtl = isset($cacheFlags["site_domain"]) ? $cacheFlags["site_domain"] : 0;
     if ($cacheTtl === false) {
         $connection = \Freetrix\Main\Application::getConnection();
         $sqlHelper = $connection->getSqlHelper();
         $sql = "SELECT DOMAIN " . "FROM b_lang_domain " . "WHERE '" . $sqlHelper->forSql('.' . $server->getHttpHost()) . "' like " . $sqlHelper->getConcatFunction("'%.'", "DOMAIN") . " " . "ORDER BY " . $sqlHelper->getLengthFunction("DOMAIN") . " ";
         $recordset = $connection->query($sql);
         if ($record = $recordset->fetch()) {
             $cache = $record['DOMAIN'];
         }
     } else {
         $managedCache = \Freetrix\Main\Application::getInstance()->getManagedCache();
         if ($managedCache->read($cacheTtl, "b_lang_domain", "b_lang_domain")) {
             $arLangDomain = $managedCache->get("b_lang_domain");
         } else {
             $arLangDomain = array("DOMAIN" => array(), "LID" => array());
             $connection = \Freetrix\Main\Application::getConnection();
             $sqlHelper = $connection->getSqlHelper();
             $recordset = $connection->query("SELECT * " . "FROM b_lang_domain " . "ORDER BY " . $sqlHelper->getLengthFunction("DOMAIN"));
             while ($record = $recordset->fetch()) {
                 $arLangDomain["DOMAIN"][] = $record;
                 $arLangDomain["LID"][$record["LID"]][] = $record;
             }
             $managedCache->set("b_lang_domain", $arLangDomain);
         }
         foreach ($arLangDomain["DOMAIN"] as $domain) {
             if (strcasecmp(substr('.' . $server->getHttpHost(), -(strlen($domain['DOMAIN']) + 1)), "." . $domain['DOMAIN']) == 0) {
                 $cache = $domain['DOMAIN'];
                 break;
             }
         }
     }
     $bCache = true;
     return $cache;
 }