示例#1
0
function GetFolderTree($s_Dir, $s_Flag, $n_Indent)
{
    if ($handle = opendir($s_Dir)) {
        while (false !== ($file = readdir($handle))) {
            $sFileType = filetype($s_Dir . $file);
            if ($sFileType == "dir") {
                if ($file != "." && $file != "..") {
                    $oDirs[] = $file;
                }
            }
        }
    }
    $s_List = "";
    if (isset($oDirs)) {
        $i = 0;
        $n_Count = count($oDirs);
        foreach ($oDirs as $oDir) {
            $i = $i + 1;
            if ($i < $n_Count) {
                $s_LastFlag = "0";
            } else {
                $s_LastFlag = "1";
            }
            $s_List = $s_List . "arr" . $s_Flag . "[" . $GLOBALS["nTreeIndex"] . "]=new Array(\"" . Syscode2Pagecode($oDir, true) . "\"," . $n_Indent . ", " . $s_LastFlag . ");\n";
            $GLOBALS["nTreeIndex"] = $GLOBALS["nTreeIndex"] + 1;
            $s_List = $s_List . GetFolderTree($s_Dir . $oDir . "/", $s_Flag, $n_Indent + 1);
        }
    }
    return $s_List;
}
示例#2
0
function DoUpload()
{
    if (!isset($_FILES['uploadfile'])) {
        OutScript("parent.UploadError('file')");
        exit;
    }
    if ($_FILES['uploadfile']['error'] > 0) {
        switch ((int) $_FILES['uploadfile']['error']) {
            case UPLOAD_ERR_NO_FILE:
                OutScript("parent.UploadError('file')");
                break;
            case UPLOAD_ERR_FORM_SIZE:
                OutScript("parent.UploadError('size')");
                break;
            case UPLOAD_ERR_INI_SIZE:
                OutScript("parent.UploadError('The uploaded file exceeds the upload_max_filesize directive (" . ini_get("upload_max_filesize") . ") in php.ini!')");
                break;
        }
        exit;
    }
    preg_match("/\\.([a-zA-Z0-9]{2,4})\$/", $_FILES['uploadfile']['name'], $exts);
    if (!IsValidExt($exts[1])) {
        OutScript("parent.UploadError('ext')");
        exit;
    }
    $GLOBALS["sOriginalFileName"] = $_FILES['uploadfile']['name'];
    $GLOBALS["sSaveFileName"] = GetRndFileName(strtolower($exts[1]));
    //$sFileName = str_replace('\\','\\\\',realpath($GLOBALS["sUploadDir"]))."/";
    $s_MapFile = $GLOBALS["sUploadDir"] . Syscode2Pagecode($GLOBALS["sSaveFileName"], false);
    $s_TrueFile = MFU_GetSavePath($s_MapFile);
    if (!move_uploaded_file($_FILES['uploadfile']['tmp_name'], $s_TrueFile)) {
        OutScript("parent.UploadError('move_uploaded_file')");
        exit;
    }
    MFU_DoUploadAfter($s_MapFile);
}