Example #1
0
 function UnInstallFiles()
 {
     $rootDir = Application::getDocumentRoot() . '/' . Application::getPersonalRoot();
     $adminGatewayFile = '/admin/ws_tools.php';
     unlink($rootDir . $adminGatewayFile);
     return true;
 }
Example #2
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);
     }
 }
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
 public function initCache($TTL, $uniqueString, $initDir = false, $baseDir = "cache")
 {
     if ($initDir === false) {
         $request = Main\Context::getCurrent()->getRequest();
         $initDir = $request->getRequestedPageDirectory();
     }
     $personalRoot = Main\Application::getPersonalRoot();
     $this->baseDir = $personalRoot . "/" . $baseDir . "/";
     $this->initDir = $initDir;
     $this->filename = "/" . $this->getPath($uniqueString);
     $this->TTL = $TTL;
     $this->uniqueString = $uniqueString;
     $this->vars = false;
     if ($TTL <= 0) {
         return false;
     }
     if (static::shouldClearCache()) {
         return false;
     }
     $arAllVars = array("CONTENT" => "", "VARS" => "");
     if (!$this->cacheEngine->read($arAllVars, $this->baseDir, $this->initDir, $this->filename, $this->TTL)) {
         return false;
     }
     if (static::$showCacheStat) {
         $read = 0;
         $path = '';
         if ($this->cacheEngine instanceof ICacheEngineStat) {
             $read = $this->cacheEngine->getReadBytes();
             $path = $this->cacheEngine->getCachePath();
         } elseif ($this->cacheEngine instanceof \ICacheBackend) {
             /** @noinspection PhpUndefinedFieldInspection */
             $read = $this->cacheEngine->read;
             /** @noinspection PhpUndefinedFieldInspection */
             $path = $this->cacheEngine->path;
         }
         Diag\CacheTracker::addCacheStatBytes($read);
         Diag\CacheTracker::add($read, $path, $this->baseDir, $this->initDir, $this->filename, "R");
     }
     $this->content = $arAllVars["CONTENT"];
     $this->vars = $arAllVars["VARS"];
     return true;
 }
Example #5
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));
 }
Example #6
0
 /**
  * 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;
 }
Example #7
0
 public function initCache($TTL, $uniqueString, $initDir = false, $baseDir = "cache")
 {
     if ($initDir === false) {
         $request = \Bitrix\Main\Context::getCurrent()->getRequest();
         $initDir = $request->getRequestedPageDirectory();
     }
     $personalRoot = \Bitrix\Main\Application::getPersonalRoot();
     $this->baseDir = \Bitrix\Main\IO\Path::combine($personalRoot, $baseDir);
     $this->initDir = $initDir;
     $this->filename = $this->getPath($uniqueString);
     $this->TTL = $TTL;
     $this->uniqueString = $uniqueString;
     $this->vars = false;
     if ($TTL <= 0) {
         return false;
     }
     if ($this->getClearCache()) {
         return false;
     }
     $arAllVars = array("CONTENT" => "", "VARS" => "");
     if (!$this->cacheEngine->read($arAllVars, $this->baseDir, $this->initDir, $this->filename, $this->TTL)) {
         return false;
     }
     $this->content = $arAllVars["CONTENT"];
     $this->vars = $arAllVars["VARS"];
     return true;
 }
 public function __construct($cacheKey, array $configuration, array $htmlCacheOptions)
 {
     parent::__construct($cacheKey, $configuration, $htmlCacheOptions);
     $this->cacheFile = new Main\IO\File(Main\IO\Path::convertRelativeToAbsolute(Main\Application::getPersonalRoot() . "/html_pages" . $this->cacheKey));
 }
Example #9
0
 /**
  * @return string
  */
 private function baseDir()
 {
     $personalRoot = Application::getPersonalRoot();
     return $personalRoot . "/" . $this->bxBaseDir . "/";
 }