private function isRequestedUriExists()
 {
     /** @var $request HttpRequest */
     $request = $this->getContext()->getRequest();
     $absUrl = IO\Path::convertRelativeToAbsolute($request->getRequestedPage());
     return IO\File::isFileExists($absUrl);
 }
Example #2
0
 public function __construct($type)
 {
     parent::__construct();
     $type = trim(strtolower($type), '.');
     if (!$this->issetType($type)) {
         throw new SystemException("Could not find type '{$type}' in BlankFile");
     }
     $typeData = $this->getType($type);
     $this->name = $typeData['newFileName'] . $typeData['ext'];
     $this->mimeType = TypeFile::getMimeTypeByFilename($this->name);
     $this->src = $typeData['src'];
     $this->size = IO\File::isFileExists($typeData['src']) ? filesize($typeData['src']) : 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.";
             }
         }
     }
 }
Example #4
0
 private static function loadRules($siteId)
 {
     $site = SiteTable::getRow(array("filter" => array("LID" => $siteId)));
     $docRoot = $site["DOC_ROOT"];
     if (!empty($docRoot)) {
         $docRoot = IO\Path::normalize($docRoot);
     } else {
         $docRoot = Application::getDocumentRoot();
     }
     $arUrlRewrite = array();
     if (IO\File::isFileExists($docRoot . "/urlrewrite.php")) {
         include $docRoot . "/urlrewrite.php";
     }
     foreach ($arUrlRewrite as &$rule) {
         if (!isset($rule["SORT"])) {
             $rule["SORT"] = self::DEFAULT_SORT;
         }
     }
     return $arUrlRewrite;
 }
Example #5
0
 private function sendToEventHandler(array $handler, Event $event)
 {
     try {
         $result = true;
         $event->addDebugInfo($handler);
         if (isset($handler["TO_MODULE_ID"]) && !empty($handler["TO_MODULE_ID"]) && $handler["TO_MODULE_ID"] != 'main') {
             $result = Loader::includeModule($handler["TO_MODULE_ID"]);
         } elseif (isset($handler["TO_PATH"]) && !empty($handler["TO_PATH"])) {
             $path = ltrim($handler["TO_PATH"], "/");
             if (($path = Loader::getLocal($path)) !== false) {
                 $result = (include_once $path);
             }
         } elseif (isset($handler["FULL_PATH"]) && !empty($handler["FULL_PATH"]) && IO\File::isFileExists($handler["FULL_PATH"])) {
             $result = (include_once $handler["FULL_PATH"]);
         }
         $event->addDebugInfo($result);
         if (isset($handler["TO_METHOD_ARG"]) && is_array($handler["TO_METHOD_ARG"]) && !empty($handler["TO_METHOD_ARG"])) {
             $args = $handler["TO_METHOD_ARG"];
         } else {
             $args = array();
         }
         if ($handler["VERSION"] > 1) {
             $args[] = $event;
         } else {
             $args = array_merge($args, array_values($event->getParameters()));
         }
         $callback = null;
         if (isset($handler["CALLBACK"])) {
             $callback = $handler["CALLBACK"];
         } elseif (!empty($handler["TO_CLASS"]) && !empty($handler["TO_METHOD"]) && class_exists($handler["TO_CLASS"])) {
             $callback = array($handler["TO_CLASS"], $handler["TO_METHOD"]);
         }
         if ($callback != null) {
             $result = call_user_func_array($callback, $args);
         }
         if ($result != null && !$result instanceof EventResult) {
             $result = new EventResult(EventResult::UNDEFINED, $result, $handler["TO_MODULE_ID"]);
         }
         $event->addDebugInfo($result);
         if ($result != null) {
             $event->addResult($result);
         }
     } catch (\Exception $ex) {
         if ($event->isDebugOn()) {
             $event->addException($ex);
         } else {
             throw $ex;
         }
     }
 }
Example #6
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;
 }
			</select>
			<input type="hidden" value="<?php 
echo $paySystem['ACTION_FILE'];
?>
" name="PRIOR_ACTION_FILE">
		</td>
	</tr>
	<tbody id="pay_system_ps_mode">
	<?php 
$psMode = $request->get('PS_MODE') ? $request->get('PS_MODE') : $paySystem['PS_MODE'];
/** @var PaySystem\BaseServiceHandler $className */
$className = PaySystem\Manager::getClassNameFromPath($handlerName);
if (!class_exists($className)) {
    $path = PaySystem\Manager::getPathToHandlerFolder($handler);
    $fullPath = $documentRoot . $path . '/handler.php';
    if ($path && \Bitrix\Main\IO\File::isFileExists($fullPath)) {
        require_once $fullPath;
    }
}
$handlerModeList = array();
if (class_exists($className)) {
    $handlerModeList = $className::getHandlerModeList();
}
if ($handlerModeList) {
    ?>
			<tr>
				<td width="40%" valign="top"><?php 
    echo Loc::getMessage("F_PS_MODE");
    ?>
:</td>
				<td width="60%" valign="top">
Example #8
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 #9
0
 /**
  * Sets viewport-metadata
  */
 public static function initScripts()
 {
     global $APPLICATION;
     \CJSCore::Init();
     $APPLICATION->AddHeadString("<script type=\"text/javascript\">var mobileSiteDir=\"" . SITE_DIR . "\"; var appVersion = " . self::$apiVersion . ";var platform = \"" . self::$platform . "\";</script>", false, true);
     if (self::$platform == "android") {
         /**
          * This is workaround for android
          * We use console.log() to tell the application about successful loading of this page
          */
         $APPLICATION->AddHeadString("<script type=\"text/javascript\">console.log(\"bxdata://success\")</script>", false, true);
     }
     if (self::getInstance()->getBXScriptSupported()) {
         /**
          * If the application tells us bxscript-feature is available
          * it means that device can load cordova-scripts (including plugins) itself.
          */
         $pgJsFile = "/bitrix/js/mobileapp/__deviceload__/cordova.js";
         $APPLICATION->AddHeadString("<script type=\"text/javascript\" src=\"" . $pgJsFile . "\"></script>", false, true);
     } else {
         $pgJsFile = "/bitrix/js/mobileapp/" . self::$platform . "-cordova-" . self::$pgVersion . ".js";
         if (!File::isFileExists(Application::getDocumentRoot() . $pgJsFile)) {
             $pgJsFile = self::$remoteScriptPath . self::$platform . "-cordova-" . self::$pgVersion . ".js";
         }
         $APPLICATION->AddHeadString("<script type=\"text/javascript\" src=\"" . \CUtil::GetAdditionalFileURL($pgJsFile) . "\"></script>", false, true);
     }
     $APPLICATION->AddHeadString("<script type=\"text/javascript\" src=\"" . \CUtil::GetAdditionalFileURL("/bitrix/js/mobileapp/bitrix_mobile.js") . "\"></script>", false, true);
     $APPLICATION->AddHeadString("<script type=\"text/javascript\" src=\"" . \CUtil::GetAdditionalFileURL("/bitrix/js/mobileapp/mobile_lib.js") . "\"></script>", false, true);
     if (self::$platform == "android") {
         $APPLICATION->AddHeadString("<script type=\"text/javascript\">app.bindloadPageBlank();</script>", false, false);
     }
     $APPLICATION->AddHeadString(Mobile::getInstance()->getViewPort());
 }
 protected function setTheme($site_template_id)
 {
     if (strlen($site_template_id) > 0) {
         $result = \CSiteTemplate::GetByID($site_template_id);
         if ($templateFields = $result->Fetch()) {
             $template_path_header = \Bitrix\Main\Application::getDocumentRoot() . $templateFields['PATH'] . '/header.php';
             $template_path_footer = \Bitrix\Main\Application::getDocumentRoot() . $templateFields['PATH'] . '/footer.php';
             if ($templateFields['PATH'] != '' && IO\File::isFileExists($template_path_footer) && IO\File::isFileExists($template_path_header)) {
                 $this->themeStylesString .= $templateFields['TEMPLATE_STYLES'] . "\r\n";
                 $this->themeStylesString .= $templateFields['STYLES'] . "\r\n";
                 $this->setThemeProlog(IO\File::getFileContents($template_path_header));
                 $this->setThemeEpilog(IO\File::getFileContents($template_path_footer));
             }
         }
     }
 }
Example #11
0
 public function write($arAllVars, $baseDir, $initDir, $filename, $TTL)
 {
     $documentRoot = \Bitrix\Main\Application::getDocumentRoot();
     $fn = IO\Path::combine($documentRoot, $baseDir, $initDir, $filename);
     $file = new IO\File($fn);
     $fnTmp = IO\Path::combine($documentRoot, $baseDir, $initDir, md5(mt_rand()) . ".tmp");
     $fileTmp = new IO\File($fnTmp);
     $dir = $file->getDirectory();
     if (!$dir->isExists()) {
         $dir->create();
     }
     if (is_array($arAllVars)) {
         $contents = "<?";
         $contents .= "\nif(\$INCLUDE_FROM_CACHE!='Y')return false;";
         $contents .= "\n\$datecreate = '" . str_pad(mktime(), 12, "0", STR_PAD_LEFT) . "';";
         $contents .= "\n\$dateexpire = '" . str_pad(mktime() + IntVal($TTL), 12, "0", STR_PAD_LEFT) . "';";
         $v = serialize($arAllVars);
         if (static::checkZeroDanger()) {
             $v = str_replace("*", "", $v);
             $contents .= "\n\$zeroDanger = true;";
         }
         $contents .= "\n\$ser_content = '" . str_replace("'", "\\'", str_replace("\\", "\\\\", $v)) . "';";
         $contents .= "\nreturn true;";
         $contents .= "\n?>";
     } else {
         $contents = "BX" . str_pad(mktime(), 12, "0", STR_PAD_LEFT) . str_pad(mktime() + IntVal($this->TTL), 12, "0", STR_PAD_LEFT);
         $contents .= $arAllVars;
     }
     $this->written = $fileTmp->putContents($contents);
     $len = \Bitrix\Main\Text\String::strlenBytes($contents);
     //This checks for Zend Server CE in order to supress warnings
     if (function_exists('accelerator_reset')) {
         try {
             $file->delete();
         } catch (\Exception $ex) {
         }
     } elseif ($file->isExists()) {
         $file->delete();
     }
     if ($this->written === $len) {
         $fileTmp->rename($fn);
     }
     //This checks for Zend Server CE in order to supress warnings
     if (function_exists('accelerator_reset')) {
         try {
             IO\File::deleteFile($fnTmp);
         } catch (\Exception $ex) {
         }
     } elseif (IO\File::isFileExists($fnTmp)) {
         IO\File::deleteFile($fnTmp);
     }
 }
Example #12
0
 public function valid()
 {
     return isset($this->dataFiles[$this->currentFileIdx]) && $this->dataFiles[$this->currentFileIdx] && \Bitrix\Main\IO\File::isFileExists($this->dataFiles[$this->currentFileIdx]);
 }
Example #13
0
 /**
  * @param $matches
  * @return string
  * @throws \Bitrix\Main\IO\FileNotFoundException
  */
 protected function getReplacedImageCid($matches)
 {
     $src = $matches[3];
     if ($src == "") {
         return $matches[0];
     }
     if (array_key_exists($src, $this->filesReplacedFromBody)) {
         $uid = $this->filesReplacedFromBody[$src]["ID"];
         return $matches[1] . $matches[2] . "cid:" . $uid . $matches[4] . $matches[5];
     }
     $io = \CBXVirtualIo::GetInstance();
     $filePath = $io->GetPhysicalName(\Bitrix\Main\Application::getDocumentRoot() . $src);
     if (!File::isFileExists($filePath)) {
         return $matches[0];
     }
     foreach ($this->attachment as $attach) {
         if ($filePath == $attach['PATH']) {
             return $matches[1] . $matches[2] . "cid:" . $attach['ID'] . $matches[4] . $matches[5];
         }
     }
     if ($this->settingMaxFileSize > 0) {
         $fileIoObject = new File($filePath);
         if ($fileIoObject->getSize() > $this->settingMaxFileSize) {
             return $matches[0];
         }
     }
     $aImage = \CFile::GetImageSize($filePath, true);
     if (!is_array($aImage)) {
         return $matches[0];
     }
     if (function_exists("image_type_to_mime_type")) {
         $contentType = image_type_to_mime_type($aImage[2]);
     } else {
         $contentType = $this->imageTypeToMimeType($aImage[2]);
     }
     $uid = uniqid(md5($src));
     $this->filesReplacedFromBody[$src] = array("SRC" => $src, "PATH" => $filePath, "CONTENT_TYPE" => $contentType, "NAME" => bx_basename($src), "ID" => $uid);
     return $matches[1] . $matches[2] . "cid:" . $uid . $matches[4] . $matches[5];
 }
Example #14
0
 public function getRemoteTypeGroups()
 {
     if (!$this->useCache || !isset($this->data['settings']['remote']['typeGroups'])) {
         $localPath = \CTempFile::GetDirectoryName(100);
         static::downloadFile(self::REMOTE_TYPE_GROUP_FILE, self::LOCAL_TYPE_GROUP_FILE, false, $localPath);
         $csv = new CSVReader();
         $res = $csv->ReadBlock($localPath . self::LOCAL_TYPE_GROUP_FILE);
         $result = array();
         foreach ($res as $line) {
             $result[$line['CODE']] = explode(':', $line['TYPES']);
         }
         $this->data['settings']['remote']['typeGroups'] = $result;
         if (\Bitrix\Main\IO\File::isFileExists($localPath . self::LOCAL_TYPE_GROUP_FILE)) {
             try {
                 \Bitrix\Main\IO\File::deleteFile($localPath . self::LOCAL_TYPE_GROUP_FILE);
                 \Bitrix\Main\IO\Directory::deleteDirectory($localPath);
             } catch (\Exception $e) {
             }
         }
     }
     return $this->data['settings']['remote']['typeGroups'];
 }
Example #15
0
 /**
  * @param string $template
  * @return string
  */
 protected static function replaceTemplateByDefaultData($template)
 {
     $phone = '8 495 212-85-06';
     $phonePath = Application::getDocumentRoot() . '/include/telephone.php';
     $logoHeader = '/include/logo.png';
     $logoFooter = '/include/logo_mobile.png';
     if (!File::isFileExists(Application::getDocumentRoot() . $logoHeader)) {
         $logoHeader = '/bitrix/images/sender/preset/blocked1/logo.png';
     }
     if (!File::isFileExists(Application::getDocumentRoot() . $logoFooter)) {
         $logoFooter = '/bitrix/images/sender/preset/blocked1/logo_m.png';
     }
     if (File::isFileExists($phonePath)) {
         $phone = File::getFileContents($phonePath);
     }
     $themeContent = File::getFileContents(\Bitrix\Main\Loader::getLocal(static::LOCAL_DIR_TMPL . 'theme.php'));
     return str_replace(array('%TEMPLATE_CONTENT%', '%LOGO_PATH_HEADER%', '%LOGO_PATH_FOOTER%', '%PHONE%', '%UNSUB_LINK%', '%MENU_CONTACTS%', '%MENU_HOWTO%', '%MENU_DELIVERY%', '%MENU_ABOUT%', '%MENU_GUARANTEE%', '%SCHEDULE_NAME%', '%SCHEDULE_DETAIL%', '%BUTTON%', '%HEADER%', '%TEXT1%', '%TEXT2%', '%TEXT3%', '%TEXT4%', '%TEXT5%', '%TEXT6%'), array($template, $logoHeader, $logoFooter, $phone, Loc::getMessage('PRESET_TEMPLATE_LIST_BLANK_UNSUB_LINK'), Loc::getMessage('PRESET_TEMPLATE_LIST_BLANK_MENU_CONTACTS'), Loc::getMessage('PRESET_TEMPLATE_LIST_BLANK_MENU_HOWTO'), Loc::getMessage('PRESET_TEMPLATE_LIST_BLANK_MENU_DELIVERY'), Loc::getMessage('PRESET_TEMPLATE_LIST_BLANK_MENU_ABOUT'), Loc::getMessage('PRESET_TEMPLATE_LIST_BLANK_MENU_GUARANTEE'), Loc::getMessage('PRESET_TEMPLATE_LIST_BLANK_SCHEDULE_NAME'), Loc::getMessage('PRESET_TEMPLATE_LIST_BLANK_SCHEDULE_DETAIL'), Loc::getMessage('PRESET_TEMPLATE_LIST_BLANK_BUTTON'), Loc::getMessage('PRESET_TEMPLATE_LIST_BLANK_HEADER'), Loc::getMessage('PRESET_TEMPLATE_LIST_BLANK_TEXT1'), Loc::getMessage('PRESET_TEMPLATE_LIST_BLANK_TEXT2'), Loc::getMessage('PRESET_TEMPLATE_LIST_BLANK_TEXT3'), Loc::getMessage('PRESET_TEMPLATE_LIST_BLANK_TEXT4'), Loc::getMessage('PRESET_TEMPLATE_LIST_BLANK_TEXT5'), Loc::getMessage('PRESET_TEMPLATE_LIST_BLANK_TEXT6')), $themeContent);
 }