Пример #1
0
function GetTDirList($path, $subDirs = false)
{
    global $arDirs, $arFiles;
    $fullpath = realpath($_SERVER["DOCUMENT_ROOT"] . "/" . $path . "/");
    if (preg_match('|^' . preg_quote(realpath($_SERVER['DOCUMENT_ROOT'] . '/upload'), '|') . '|i' . BX_UTF_PCRE_MODIFIER, $fullpath)) {
        return;
    }
    $fullpath = prepare_path($fullpath);
    //flag if dir is lang
    $is_lang = strpos($fullpath, "/lang/") !== false;
    $handle = @opendir($fullpath);
    if ($handle) {
        $parent = prepare_path("/" . $path . "/");
        $abs_parent = prepare_path($_SERVER["DOCUMENT_ROOT"] . $parent);
        $arList = array();
        while (false !== ($file = readdir($handle))) {
            if ($file != "." && $file != ".." && $file != ".access.php" && $file != ".htaccess") {
                $IS_DIR = is_dir($abs_parent . $file) ? "Y" : "N";
                $path_prepared = $parent . $file;
                if ($IS_DIR == "Y" && ($path_prepared == "/bitrix/updates" || $path_prepared == "/bitrix/updates_enc" || $path_prepared == "/bitrix/updates_enc5" || $path_prepared == "/bitrix/help" || $path_prepared == "/bitrix/cache" || $path_prepared == "/bitrix/cache_image" || $path_prepared == "/bitrix/managed_cache" || $path_prepared == "/bitrix/stack_cache")) {
                    continue;
                }
                $arList[$path_prepared] = array("IS_DIR" => $IS_DIR, "PARENT" => $parent, "PATH" => $IS_DIR == "Y" ? $path_prepared . "/" : $path_prepared, "FILE" => $file, "IS_LANG" => $is_lang);
                if ($arList[$path_prepared]['IS_DIR'] == 'N') {
                    $arList[$path_prepared]["LANG"] = $is_lang ? get_lang_id($path_prepared) : '';
                }
            }
        }
        ksort($arList);
        foreach ($arList as $path_prepared => $arr) {
            if ($arr["IS_DIR"] == "Y") {
                if ($subDirs) {
                    $arr["IS_LANG"] |= GetTDirList($path_prepared . "/", $subDirs);
                }
                $arDirs[] = $arr;
                //dir is lang if any of it's children is lang
                $is_lang = $is_lang || $arr["IS_LANG"];
            } elseif (is_lang_dir($path_prepared)) {
                if (substr($arr["FILE"], -4) == '.php') {
                    $arFiles[] = $arr;
                }
            }
        }
        closedir($handle);
    }
    //flag for parent
    return $is_lang;
}
Пример #2
0
$path = $_REQUEST["path"];
if (preg_match("#\\.\\.[\\/]#" . BX_UTF_PCRE_MODIFIER, $path)) {
    $path = "";
}
$path = Rel2Abs("/", "/" . $path . "/");
$IS_LANG_DIR = is_lang_dir($path);
if ($IS_LANG_DIR) {
    foreach ($arTLangs as $hlang) {
        $ph = add_lang_id($path, $hlang, $arTLangs);
        if (strlen($ph) > 0) {
            GetTDirList($ph, true);
        }
        $ph = "";
    }
} else {
    GetTDirList($path, true);
}
$strFile = '';
$arFileFilter = array();
if (isset($_REQUEST['file'])) {
    $strFile = strval($_REQUEST['file']);
}
if (preg_match("#\\.\\.[\\/]#" . BX_UTF_PCRE_MODIFIER, $strFile)) {
    $strFile = "";
}
if ('' != $strFile) {
    $strFile = Rel2Abs("/", "/" . $strFile);
    foreach ($arTLangs as $hlang) {
        $ph = add_lang_id($strFile, $hlang, $arTLangs);
        if ('' != $ph) {
            $arFileFilter[] = $ph;
Пример #3
0
$arLangDirs = array();
$IS_LANG_DIR = false;
if (!$SHOW_LANG_DIFF || $SHOW_LANG_DIFF && check_bitrix_sessid()) {
    $go_path = remove_lang_id($path, $arTLangs);
    $IS_LANG_DIR = is_lang_dir($path);
    //no lang
    if ($IS_LANG_DIR) {
        foreach ($arTLangs as $hlang) {
            $ph = add_lang_id($path, $hlang, $arTLangs);
            if (strlen($ph) > 0) {
                GetTDirList($ph, $GET_SUBFOLRERS);
            }
            $ph = "";
        }
    } else {
        GetTDirList($path, $GET_SUBFOLRERS);
    }
    $arrChain = array();
    $arr = explode("/", $go_path);
    if (is_array($arr)) {
        $arrP = array();
        TrimArr($arr);
        foreach ($arr as $d) {
            $arrP[] = $d;
            $p = prepare_path("/" . implode("/", $arrP) . "/");
            if (remove_lang_id($path, $arTLangs) == $p) {
                $p = "";
            }
            $arrChain[] = array("NAME" => $d, "PATH" => $p);
        }
    }