Exemple #1
0
 function InstallFiles()
 {
     CopyDirFiles($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/mobile/public/mobile/", $_SERVER["DOCUMENT_ROOT"] . "/mobile/", True, True);
     CopyDirFiles($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/mobile/install/templates/", $_SERVER["DOCUMENT_ROOT"] . "/bitrix/templates/", True, True);
     CopyDirFiles($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/mobile/install/components/", $_SERVER["DOCUMENT_ROOT"] . "/bitrix/components", true, true);
     $default_site_id = CSite::GetDefSite();
     if ($default_site_id) {
         $arAppTempalate = array("SORT" => 1, "CONDITION" => "CSite::InDir('/mobile/')", "TEMPLATE" => "mobile_app");
         $arFields = array("TEMPLATE" => array());
         $dbTemplates = CSite::GetTemplateList($default_site_id);
         $mobileAppFound = false;
         while ($template = $dbTemplates->Fetch()) {
             if ($template["TEMPLATE"] == "mobile_app") {
                 $mobileAppFound = true;
                 $template = $arAppTempalate;
             }
             $arFields["TEMPLATE"][] = array("TEMPLATE" => $template['TEMPLATE'], "SORT" => $template['SORT'], "CONDITION" => $template['CONDITION']);
         }
         if (!$mobileAppFound) {
             $arFields["TEMPLATE"][] = $arAppTempalate;
         }
         $obSite = new CSite();
         $arFields["LID"] = $default_site_id;
         $obSite->Update($default_site_id, $arFields);
     }
     CUrlRewriter::ReindexFile("/mobile/webdav/index.php");
     CUrlRewriter::ReindexFile("/mobile/disk/index.php");
     CUrlRewriter::Add(array("CONDITION" => "#^/mobile/disk/(?<hash>[0-9]+)/download#", "RULE" => "download=1&objectId=\$1", "ID" => "bitrix:mobile.disk.file.detail", "PATH" => "/mobile/disk/index.php"));
     return true;
 }
Exemple #2
0
 function RecurseIndex($path = array(), $max_execution_time = 0, &$NS)
 {
     CMain::InitPathVars($site, $path);
     $DOC_ROOT = CSite::GetSiteDocRoot($site);
     $abs_path = $DOC_ROOT . $path;
     if (strlen($site) <= 0) {
         return 0;
     }
     if (!file_exists($abs_path) || !is_dir($abs_path)) {
         return 0;
     }
     $handle = @opendir($abs_path);
     while (false !== ($file = @readdir($handle))) {
         if ($file == "." || $file == "..") {
             continue;
         }
         $full_path = $path . "/" . $file;
         if (is_dir($abs_path . "/" . $file)) {
             if ($full_path == "/bitrix" || $full_path == "/" . COption::GetOptionString("main", "upload_dir", "upload")) {
                 continue;
             }
             //this is not first step and we had stopped here, so go on to reindex
             if ($max_execution_time <= 0 || strlen($NS["FLG"]) <= 0 || strlen($NS["FLG"]) > 0 && substr($NS["ID"] . "/", 0, strlen($site . "|" . $full_path . "/")) == $site . "|" . $full_path . "/") {
                 $new_site = CSite::GetSiteByFullPath($DOC_ROOT . $full_path);
                 if (CUrlRewriter::RecurseIndex(array($new_site, $full_path), $max_execution_time, $NS) === false) {
                     return false;
                 }
             } else {
                 //all done
                 continue;
             }
         } else {
             //not the first step and we found last file from previos one
             if ($max_execution_time > 0 && strlen($NS["FLG"]) > 0 && $NS["ID"] == $site . "|" . $full_path) {
                 $NS["FLG"] = "";
             } elseif (strlen($NS["FLG"]) <= 0) {
                 $ID = CUrlRewriter::ReindexFile(array($site, $full_path), $NS["SESS_ID"], $NS["max_file_size"]);
                 if ($ID) {
                     $NS["CNT"] = intval($NS["CNT"]) + 1;
                 }
             }
             if ($max_execution_time > 0 && getmicrotime() - START_EXEC_TIME > $max_execution_time) {
                 $NS["FLG"] = "Y";
                 $NS["ID"] = $site . "|" . $full_path;
                 return false;
             }
         }
     }
     return true;
 }