private function isRequestedUriExists()
 {
     /** @var $request HttpRequest */
     $request = $this->getContext()->getRequest();
     $absUrl = IO\Path::convertRelativeToAbsolute($request->getRequestedPage());
     return IO\File::isFileExists($absUrl);
 }
 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.";
             }
         }
     }
 }
Example #3
0
 private function transferUri($url)
 {
     $url = IO\Path::normalize($url);
     $urlTmp = trim($url, " \t\n\r\v\\/");
     if (empty($urlTmp)) {
         throw new ArgumentNullException("url");
     }
     $ext = IO\Path::getExtension($url);
     if (strtolower($ext) != "php") {
         throw new SystemException("Only php files are allowable for url rewriting");
     }
     $arUrl = explode("/", $url);
     $rootDirName = "";
     while (!empty($arUrl) && ($rootDirName = array_shift($arUrl)) === "") {
     }
     $rootDirName = strtolower(str_replace(".", "", $rootDirName));
     if (in_array($rootDirName, array("bitrix", "local", "upload"))) {
         throw new SystemException(sprintf("Can not use path '%s' for url rewriting", $url));
     }
     if (!IO\Path::validate($url)) {
         throw new SystemException(sprintf("Path '%s' is not valid", $url));
     }
     $absUrl = IO\Path::convertRelativeToAbsolute($url);
     if (!IO\File::isFileExists($absUrl)) {
         throw new SystemException(sprintf("Path '%s' is not found", $url));
     }
     $absUrlPhysical = IO\Path::convertLogicalToPhysical($absUrl);
     global $APPLICATION, $USER, $DB;
     include_once $absUrlPhysical;
     die;
 }
Example #4
0
 private static function loadTriggers($moduleId)
 {
     static $triggersCache = array();
     if (isset($triggersCache[$moduleId])) {
         return;
     }
     if (!IO\Path::validateFilename($moduleId)) {
         throw new Main\ArgumentOutOfRangeException("moduleId");
     }
     $triggersCache[$moduleId] = true;
     $path = IO\Path::convertRelativeToAbsolute("/bitrix/modules/" . $moduleId . "/option_triggers.php");
     if (!IO\File::isFileExists($path)) {
         return;
     }
     include IO\Path::convertLogicalToPhysical($path);
 }
Example #5
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 \Bitrix\Main\ArgumentTypeException
  * @throws \Bitrix\Main\ArgumentNullException
  */
 private function searchConnectionParametersByName($name)
 {
     if (!is_string($name)) {
         throw new \Bitrix\Main\ArgumentTypeException("name", "string");
     }
     if ($name === "") {
         throw new \Bitrix\Main\ArgumentNullException("name");
     }
     if ($name === self::DEFAULT_CONNECTION) {
         $v = \Bitrix\Main\Config\Configuration::getValue(self::DEFAULT_CONNECTION_CONFIGURATION);
         if ($v != null) {
             return $v;
         }
         $DBType = "";
         $DBHost = "";
         $DBName = "";
         $DBLogin = "";
         $DBPassword = "";
         include \Bitrix\Main\IO\Path::convertRelativeToAbsolute("/bitrix/php_interface/dbconn.php");
         return array("type" => $DBType, "host" => $DBHost, "db_name" => $DBName, "login" => $DBLogin, "password" => $DBPassword);
     }
     /* TODO: реализовать */
     return null;
 }
Example #6
0
 protected function deleteOneDir($etime = 0)
 {
     $bDeleteFromQueue = false;
     $con = \Bitrix\Main\Application::getDbConnection();
     $rs = $con->query("SELECT * from b_cache_tag WHERE TAG='*'", 0, 1);
     if ($ar = $rs->fetch()) {
         $dir_name = \Bitrix\Main\IO\Path::convertRelativeToAbsolute($ar["RELATIVE_PATH"]);
         $dir = new \Bitrix\Main\IO\Directory($dir_name);
         if ($dir->isExists()) {
             $arChildren = $dir->getChildren();
             $Counter = 0;
             foreach ($arChildren as $child) {
                 $child->delete();
                 $Counter++;
                 if (time() > $etime) {
                     break;
                 }
             }
             if ($Counter == 0) {
                 $dir->delete();
                 $bDeleteFromQueue = true;
             }
         } else {
             $bDeleteFromQueue = true;
         }
         if ($bDeleteFromQueue) {
             $con->queryExecute("DELETE FROM b_cache_tag\n\t\t\t\t\tWHERE SITE_ID = '" . $con->getSqlHelper()->forSql($ar["SITE_ID"]) . "'\n\t\t\t\t\tAND CACHE_SALT = '" . $con->getSqlHelper()->forSql($ar["CACHE_SALT"]) . "'\n\t\t\t\t\tAND RELATIVE_PATH = '" . $con->getSqlHelper()->forSql($ar["RELATIVE_PATH"]) . "'");
         }
     }
 }
Example #7
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;
 }
 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));
 }