示例#1
0
 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;
 }
示例#2
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;
 }
示例#3
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.";
         }
     }
 }
示例#4
0
 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\"");
     }
 }
示例#5
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";
 }
 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.";
             }
         }
     }
 }
示例#7
0
 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;
     }
 }
示例#8
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];
 }
示例#9
0
 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]);
     }
 }
示例#10
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;
 }
示例#11
0
 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;
 }
示例#12
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"]]);
             }
         }
     }
 }
示例#13
0
<?php

require_once $_SERVER["DOCUMENT_ROOT"] . "/freetrix/modules/main" . "/SetCorePath.php";
require_once $_SERVER["DOCUMENT_ROOT"] . "/freetrix/modules/main/Start.php";
require_once $_SERVER["DOCUMENT_ROOT"] . "/freetrix/modules/main/classes/general/virtual_io.php";
require_once $_SERVER["DOCUMENT_ROOT"] . "/freetrix/modules/main/classes/general/virtual_file.php";
$Application = \Freetrix\Main\Application::getInstance();
$Application->initializeExtendedKernel(array("get" => $_GET, "post" => $_POST, "files" => $_FILES, "cookie" => $_COOKIE, "server" => $_SERVER, "env" => $_ENV));
$GLOBALS["APPLICATION"] = new CMain();
if (defined("SITE_ID")) {
    define("LANG", SITE_ID);
}
if (defined("LANG")) {
    if (defined("ADMIN_SECTION") && ADMIN_SECTION === true) {
        $currentLangGetter = CLangAdmin::GetByID(LANG);
    } else {
        $currentLangGetter = CLang::GetByID(LANG);
    }
    $definedLang = $currentLangGetter->Fetch();
} else {
    $definedLang = $GLOBALS["APPLICATION"]->GetLang();
    define("LANG", $definedLang["LID"]);
}
$_762722495 = $definedLang["LID"];
define("SITE_ID", $definedLang["LID"]);
define("SITE_DIR", $definedLang["DIR"]);
define("SITE_SERVER_NAME", $definedLang["SERVER_NAME"]);
define("SITE_CHARSET", $definedLang["CHARSET"]);
define("FORMAT_DATE", $definedLang["FORMAT_DATE"]);
define("FORMAT_DATETIME", $definedLang["FORMAT_DATETIME"]);
define("LANG_DIR", $definedLang["DIR"]);
示例#14
0
文件: cookie.php 项目: ASDAFF/open_bx
 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;
 }
示例#15
0
 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();
         }
     }
 }
示例#16
0
文件: cache.php 项目: ASDAFF/open_bx
 public static function getSalt()
 {
     $context = Main\Application::getInstance()->getContext();
     $server = $context->getServer();
     $scriptName = $server->get("SCRIPT_NAME");
     if ($scriptName == "/freetrix/urlrewrite.php" && ($v = $server->get("REAL_FILE_PATH")) != null) {
         $scriptName = $v;
     } elseif ($scriptName == "/404.php" && ($v = $server->get("REAL_FILE_PATH")) != null) {
         $scriptName = $v;
     }
     return "/" . substr(md5($scriptName), 0, 3);
 }
示例#17
0
文件: cache.php 项目: ASDAFF/open_bx
 public function __construct()
 {
     $app = \Freetrix\Main\Application::getInstance();
     $this->taggedCache = $app->getTaggedCache();
 }
示例#18
0
 public static function setAuthentication(CurrentUser $user, $isPersistent = false)
 {
     /** @var $context \Freetrix\Main\HttpContext */
     $context = \Freetrix\Main\Application::getInstance()->getContext();
     $context->setUser($user);
     static::copyToSession($user);
     /** @var $response \Freetrix\Main\HttpResponse */
     $response = $context->getResponse();
     if (!$user->isAuthenticated()) {
         $cookie = new \Freetrix\Main\Web\Cookie("UIDH", "", time() - 3600);
         $response->addCookie($cookie);
         return;
     }
     $connection = \Freetrix\Main\Application::getDbConnection();
     $sqlHelper = $connection->getSqlHelper();
     $connection->queryExecute("UPDATE b_user SET " . "   STORED_HASH = NULL, " . "   LAST_LOGIN = "******", " . "   TIMESTAMP_X = TIMESTAMP_X,  " . "   LOGIN_ATTEMPTS = 0, " . "   TIME_ZONE_OFFSET = " . \CTimeZone::getOffset() . " " . "WHERE ID = " . $user->getUserId() . " ");
     $cookie = new \Freetrix\Main\Web\Cookie("LOGIN", $user->getLogin(), time() + 60 * 60 * 24 * 30 * 60);
     $cookie->setSpread(\Freetrix\Main\Config\Option::get("main", "auth_multisite", "N") == "Y" ? \Freetrix\Main\Web\Cookie::SPREAD_SITES : \Freetrix\Main\Web\Cookie::SPREAD_DOMAIN);
     $response->addCookie($cookie);
     if ($isPersistent || \Freetrix\Main\Config\Option::get("main", "auth_multisite", "N") == "Y") {
         $hash = $user->getSessionHash();
         /** @var $request \Freetrix\Main\HttpRequest */
         $request = $context->getRequest();
         if ($isPersistent) {
             $cookie = new \Freetrix\Main\Web\Cookie("UIDH", $hash, time() + 60 * 60 * 24 * 30 * 60);
         } else {
             $cookie = new \Freetrix\Main\Web\Cookie("UIDH", $hash, 0);
         }
         $cookie->setSecure(\Freetrix\Main\Config\Option::get("main", "use_secure_password_cookies", "N") == "Y" && $request->isHttps());
         $response->addCookie($cookie);
         $storedId = static::getStoredHashId($user, $hash);
         if ($storedId) {
             $connection->queryExecute("UPDATE b_user_stored_auth SET " . "\tLAST_AUTH = " . $sqlHelper->getCurrentDateTimeFunction() . ", " . "\t" . ($user->getAuthType() === static::AUTHENTICATED_BY_HASH ? "" : "TEMP_HASH='" . ($isPersistent ? "N" : "Y") . "', ") . " " . "\tIP_ADDR = '" . sprintf("%u", ip2long($request->getRemoteAddress())) . "' " . "WHERE ID = " . intval($storedId));
         } else {
             $sqlTmp1 = "";
             $sqlTmp2 = "";
             if ($connection->getType() === "oracle") {
                 $storedId = $connection->getIdentity("sq_b_user_stored_auth");
                 $sqlTmp1 = "ID, ";
                 $sqlTmp2 = intval($storedId) . ", ";
             }
             $sql = "INSERT INTO b_user_stored_auth (" . $sqlTmp1 . "USER_ID, DATE_REG, LAST_AUTH, TEMP_HASH, " . "   IP_ADDR, STORED_HASH) " . "VALUES (" . $sqlTmp2 . intval($user->getUserId()) . ", " . $sqlHelper->getCurrentDateTimeFunction() . ", " . "   " . $sqlHelper->getCurrentDateTimeFunction() . ", '" . ($isPersistent ? "N" : "Y") . "', " . "   '" . $sqlHelper->forSql(sprintf("%u", ip2long($request->getRemoteAddress()))) . "', " . "   '" . $sqlHelper->forSql($hash) . "')";
             $connection->queryExecute($sql);
             if ($connection->getType() !== "oracle") {
                 $storedId = $connection->getIdentity();
             }
         }
         $user->setStoredAuthId($storedId);
     }
     $event = new Main\Event("main", "OnUserLogin", array("USER" => $user));
     $event->send();
     if (\Freetrix\Main\Config\Option::get("main", "event_log_login_success", "N") === "Y") {
         \CEventLog::log("SECURITY", "USER_AUTHORIZE", "main", $user->getUserId());
     }
 }
示例#19
0
文件: base.php 项目: ASDAFF/open_bx
 public function getConnection()
 {
     return \Freetrix\Main\Application::getInstance()->getConnectionPool()->getConnection($this->connectionName);
 }
示例#20
0
文件: query.php 项目: ASDAFF/open_bx
 protected function query($query)
 {
     // check nosql configuration
     $configuration = $this->init_entity->getConnection()->getConfiguration();
     if (isset($configuration['handlersocket']['read'])) {
         $nosqlConnectionName = $configuration['handlersocket']['read'];
         $nosqlConnection = \Freetrix\Main\Application::getInstance()->getConnectionPool()->getConnection($nosqlConnectionName);
         $isNosqlCapable = NosqlPrimarySelector::checkQuery($nosqlConnection, $this);
         if ($isNosqlCapable) {
             $nosqlResult = NosqlPrimarySelector::relayQuery($nosqlConnection, $this);
             return new \Freetrix\Main\DB\ArrayResult($nosqlResult);
         }
     }
     /*
     Vadim: this is for paging but currently is not used
     		if ($this->count_total || !is_null($this->offset))
     		{
     			$cnt_body_elements = $build_parts;
     
     			// remove order
     			unset($cnt_body_elements['ORDER BY']);
     
     			$cnt_query = join("\n", $cnt_body_elements);
     
     			// remove long aliases
     			list($cnt_query, ) = $this->replaceSelectAliases($cnt_query);
     
     			// select count
     			$cnt_query = 'SELECT COUNT(1) AS TMP_ROWS_CNT FROM ('.$cnt_query.') xxx';
     			$cnt = $connection->queryScalar($cnt_query);
     		}
     */
     $connection = \Freetrix\Main\Application::getConnection();
     $result = $connection->query($query);
     $result->setReplacedAliases($this->replaced_aliases);
     $this->last_query = $query;
     return $result;
 }
示例#21
0
 /**
  * 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
 function Disconnect()
 {
     if (!DBPersistent && $this->bConnected) {
         $this->bConnected = false;
         if (!$this->bNodeConnection) {
             $fl = true;
             $app = \Freetrix\Main\Application::getInstance();
             if ($app != null) {
                 $con = $app->getConnection();
                 if ($con->isConnected()) {
                     $con->disconnect();
                     $fl = false;
                 }
             }
             if ($fl) {
                 mysql_close($this->db_Conn);
             }
         }
     }
     foreach (self::$arNodes as $i => $arNode) {
         if (is_array($arNode) && array_key_exists("DB", $arNode)) {
             mysql_close($arNode["DB"]->db_Conn);
             unset(self::$arNodes[$i]["DB"]);
         }
     }
 }