if ($Config->DisplayHiddenFiles == "false" && substr($Item, 0, 1) == "_") { $RecordItem = false; } if ($Config->UseThumbnails && substr($Item, 0, 7) == "_thumb.") { // Don't record the current item in the regular file collections, dump it into a thumbnail collection $RecordItem = false; $ThumbnailCollection[] = $Item; } if ($RecordItem) { // If dealing with a folder, add it to the folder collection if (is_dir($Config->CurrentBrowsingDirectory . "/" . $Item)) { $FolderCollection[] = $Item; // If not dealing with a folder, add it to the proper file collection } else { // Match the current file extension with an item in the extension library $CurrentExtension = GetExtension($Item); $KeyMatch = @$ExtensionLibrary[$CurrentExtension]; // If the match came back positive, add the file to the collection if ($KeyMatch) { $FileCollections[$ExtensionLibrary[$CurrentExtension][0]]->AddFile($Item, filesize($Config->CurrentBrowsingDirectory . "/" . $Item), filemtime($Config->CurrentBrowsingDirectory . "/" . $Item), $ExtensionLibrary[$CurrentExtension][1]); // If the match came back false, attempt to add this file to the wildcard group } elseif (array_key_exists("*", $ExtensionLibrary)) { $FileCollections[$ExtensionLibrary["*"][0]]->AddFile($Item, filesize($Config->CurrentBrowsingDirectory . "/" . $Item), filemtime($Config->CurrentBrowsingDirectory . "/" . $Item), $ExtensionLibrary["*"][1], $ExtensionLibrary["*"]); } // Ignore all other files } } } // -------------------------- // 4. BUILD THE PAGE ELEMENTS // --------------------------
function ValidImage($str_FileName) { extract($GLOBALS); $valid = false; $ext = "." . GetExtension($str_FileName); $filter_Array; $filter_Array = explode(",", strtolower($MediaFilters)); foreach ($filter_Array as $v) { if (strcasecmp($ext, $v) == 0) { $valid = true; break; } } return $valid; }
function FileName2Pic($FileName) { $Ext = strtoupper(GetExtension($FileName)); switch ($Ext) { case "TXT": $PicName = "txt.gif"; break; case "CHM": $PicName = "hlp.gif"; break; case "HLP": $PicName = "hlp.gif"; break; case "DOC": $PicName = "doc.gif"; break; case "PDF": $PicName = "pdf.gif"; break; case "MDB": $PicName = "mdb.gif"; break; case "GIF": $PicName = "gif.gif"; break; case "JPG": $PicName = "jpg.gif"; break; case "BMP": $PicName = "bmp.gif"; break; case "PNG": $PicName = "pic.gif"; break; case "ASP": $PicName = "code.gif"; break; case "JSP": $PicName = "code.gif"; break; case "JS": $PicName = "js.gif"; break; case "PHP": $PicName = "php.gif"; break; case "PHP3": $PicName = "php.gif"; break; case "ASPX": $PicName = "code.gif"; break; case "HTM": $PicName = "htm.gif"; break; case "HTML": $PicName = "htm.gif"; break; case "SHTML": $PicName = "htm.gif"; break; case "ZIP": $PicName = "zip.gif"; break; case "RAR": $PicName = "rar.gif"; break; case "EXE": $PicName = "exe.gif"; break; case "AVI": $PicName = "wmv.gif"; break; case "MPG": $PicName = "wmv.gif"; break; case "MPEG": $PicName = "wmv.gif"; break; case "ASF": $PicName = "mp.gif"; break; case "RA": $PicName = "rm.gif"; break; case "RM": $PicName = "rm.gif"; break; case "MP3": $PicName = "mp3.gif"; break; case "MID": $PicName = "wmv.gif"; break; case "MIDI": $PicName = "mid.gif"; break; case "WAV": $PicName = "audio.gif"; break; case "XLS": $PicName = "xls.gif"; break; case "PPT": $PicName = "ppt.gif"; break; case "PPS": $PicName = "ppt.gif"; break; case "PHPFILE": $PicName = "php.gif"; break; case "FILE": $PicName = "common.gif"; break; case "SWF": $PicName = "swf.gif"; break; default: $PicName = "unknow.gif"; break; } return "<img border='0' src='admin/images/file/{$PicName}' align='absmiddle' id='icon'>"; }
} if (!file_exists($file)) { $output["success"] = 0; $output["msg"] = lang('the_file_does_not_exist'); header("Content-type: text/plain;"); echo json_encode($output); exit; } if (!is_file($file)) { $output["success"] = 0; $output["msg"] = lang('that_is_not_a_file'); header("Content-type: text/plain;"); echo json_encode($output); exit; } if (!unlink($file)) { $output["success"] = 0; $output["msg"] = lang('the_file_could_not_be_deleted'); header("Content-type: text/plain;"); echo json_encode($output); exit; } $__ext = GetExtension($file); $__thumbfilename = str_replace('.' . $__ext, '', $file) . THUMBNAIL_POSTFIX . '.' . $__ext; if (is_file($__thumbfilename)) { @unlink($__thumbfilename); } include 'contents.php'; header("Content-type: text/plain;"); echo json_encode($output); exit;
} else { echo ""; ?> BGCOLOR="#d8dde7" bordercolor="#d8dde7"<?php } ?> ALIGN="left" ><font color="#000099"><font face=" Verdana,Arial, Helvetica, sans-serif" size="2"></TD> </TR> <?php } // --------------------------------------- Affichage des fichiers ----------------------------------------- // $IndiceImage++; for ($i = 0; $i < $fileind; $i++) { $nomfic = $filetab[$i]["nom"]; $ext = GetExtension($nomfic); $ext = strtolower($ext); $icone = GetIcone($ext); $IndiceImage = $i; $pair = $i % 2; ?> <TR> <?php if ($pair == 1) { $BGCOLOR = "#F2F4F7"; $BORDERCOLOR = "#F2F3F7"; } else { $BGCOLOR = "#EBEEF3"; $BORDERCOLOR = "#EBEEF3"; } ?>
} } else { if ($c['is_file'] == false) { $html .= '<div class="item"> <a class="lib-folder" href="" rel="' . urlencode($c['path']) . '" title="' . $c['name'] . '"> <img src="bootstrap/img/130x90.png" class="img-polaroid" width="130" height="90"> </a> <div> <a href="" class="pull-left transparent change-folder" title="' . _lang('change_name') . '" rel="' . $c['name'] . '"><i class="icon-pencil"></i></a> <a href="" class="pull-right transparent delete-folder" rel="' . urlencode($c['path']) . '" title="' . _lang('delete') . '"><i class="icon-trash"></i></a> <div class="clearfix"></div> <p class="caption">' . TrimText($c['name'], 17) . '</p> </div> </div>'; } else { $extension = GetExtension($c['name']); if (!is_image_extenstion($extension)) { $html .= '<div class="item"> <a href="" class="pdf-thumbs" data-icon="' . get_file_icon_path($extension) . '" rel="' . $c['path'] . '" title="' . $c['name'] . '"> <img src="' . get_file_icon_path($extension) . '" class="img-polaroid" width="130" height="90"> </a> <div> <a href="" class="pull-left transparent change-file" title="' . _lang('change_name') . '" rel="' . $c['name'] . '"><i class="icon-pencil"></i></a> <a href="" class="pull-right transparent delete-file" data-path="' . urlencode($c['x']) . '" rel="' . urlencode($c['p']) . '" title="' . _lang('delete') . '"><i class="icon-trash"></i></a> <div class="clearfix"></div> <p class="caption">' . TrimText($c['name'], 17) . '</p> </div> </div>'; } else { $html .= '<div class="item"> <a href="" class="img-thumbs" rel="' . $c['path'] . '" title="' . $c['name'] . '">
print "The area you are attempting to access is forbidden"; exit; } $uploader = new PhpUploader(); $guidlist = explode("/", $fileguidlist); foreach ($guidlist as $fileguid) { //$contentType=$_FILES["file"]["type"]; $mvcfile = $uploader->GetUploadedFile($fileguid); if (!$mvcfile) { continue; } $filesize = $mvcfile->FileSize; $filemimetype = FindType(GetExtension($mvcfile->FilePath)); $filemimetype2 = FindType2(GetExtension($mvcfile->FilePath)); $Is_valid = false; if (!in_array(strtolower(GetExtension($mvcfile->FileName)), $Filter_Array)) { echo "<span style='font-family: MS Sans Serif; font-size: 9pt; color:red'><b>File format not allowed! Please contact site administrator. </b></span><br><br>"; echo "<span><a style=\"font-family: MS Sans Serif; font-size: 9pt; vertical-align: top;\" href=\"upload.php?" . $setting . "&FP=" . $_GET["FP"] . "&Type=" . $_GET["Type"] . "\">Upload a new file</a></span>"; return; } $C_MaxSize = GetMaxSize($C_MaxSize); if ($filesize > $C_MaxSize * 1024) { echo "<span style='font-family: MS Sans Serif; font-size: 9pt; color:red'><b>File size (" . FormatSize($filesize) . ") exceeds the maximum size allowed. </b></span><br><br>"; echo "<span><a style=\"font-family: MS Sans Serif; font-size: 9pt; vertical-align: top;\" href=\"upload.php?" . $setting . "&FP=" . $_GET["FP"] . "&Type=" . $_GET["Type"] . "\">Upload a new file</a></span>"; return; } } foreach ($guidlist as $fileguid) { //$contentType=$_FILES["file"]["type"]; $mvcfile = $uploader->GetUploadedFile($fileguid); if (!$mvcfile) {
function ValidImage($str_FileName) { $valid = false; $ext = "." . GetExtension($str_FileName); if (strcasecmp($ext, ".swf") == 0 || strcasecmp($ext, ".flv") == 0) { $valid = true; } return $valid; }
function DoUpload($field = 'userfile') { $output = array(); $output["success"] = true; $output["is_pdf"] = 0; if (isset($_SESSION["tinymce_upload_directory"]) and $_SESSION["tinymce_upload_directory"] != "") { $current_folder = $_SESSION["tinymce_upload_directory"]; } else { $current_folder = LIBRARY_FOLDER_PATH; } if (!CanAcessUploadForm()) { $output["reason"] = lang('no_permission_to_upload'); $output["success"] = false; return $output; } if (!isset($_FILES[$field])) { $output["reason"] = lang('file_not_selected'); $output["success"] = false; return $output; } if (!is_uploaded_file($_FILES[$field]['tmp_name'])) { $error = !isset($_FILES[$field]['error']) ? 4 : $_FILES[$field]['error']; $output["success"] = false; switch ($error) { case 1: // UPLOAD_ERR_INI_SIZE $output["reason"] = lang('file_exceeds_limit_size'); break; case 2: // UPLOAD_ERR_FORM_SIZE $output["reason"] = lang('file_exceeds_limit_size'); break; case 3: // UPLOAD_ERR_PARTIAL $output["reason"] = lang('file_uploaded_partially'); break; case 4: // UPLOAD_ERR_NO_FILE $output["reason"] = lang('file_not_selected'); break; case 6: // UPLOAD_ERR_NO_TMP_DIR $output["reason"] = lang('no_temp_directory'); break; case 7: // UPLOAD_ERR_CANT_WRITE $output["reason"] = lang('unable_to_write_the_file'); break; case 8: // UPLOAD_ERR_EXTENSION $output["reason"] = lang('invalid_extension'); break; default: $output["reason"] = lang('file_not_selected'); break; } return $output; } if (!ValidFileExtension($_FILES[$field]['name'])) { $output["reason"] = lang('invalid_extension'); $output["success"] = false; return $output; } if (RENAME_UPLOADED_FILES == true) { $file_name = random_file_name($_FILES[$field]['name']); $file_name = set_filename($current_folder, $file_name); } else { $file_name = set_filename($current_folder, $_FILES[$field]['name']); } if (!@copy($_FILES[$field]['tmp_name'], $current_folder . $file_name)) { if (!@move_uploaded_file($_FILES[$field]['tmp_name'], $current_folder . $file_name)) { $output["reason"] = lang('could_not_move_file'); $output["success"] = false; return $output; } } if (!isset($_SESSION['SimpleImageManager'])) { $_SESSION['SimpleImageManager'] = array(); } $_SESSION['SimpleImageManager'][] = PathToUrl($current_folder) . $file_name; $output["file"] = PathToUrl($current_folder) . $file_name; if (is_image_extenstion(GetExtension($file_name))) { Resizing($current_folder, $file_name); } else { $output["is_pdf"] = 1; $output["icon"] = get_file_icon_path(GetExtension($file_name)); } return $output; }
require_once 'functions.php'; $output = array(); $output["success"] = 1; if (isset($_SESSION['SimpleImageManager']) and count($_SESSION['SimpleImageManager']) > 0) { $html = ''; foreach ($_SESSION['SimpleImageManager'] as $s) { $me = false; $exists = is_url_exist($s); $url_host = parse_url($s, PHP_URL_HOST); if ($url_host == $_SERVER['HTTP_HOST']) { $me = true; } if ($exists == false) { continue; } $extension = GetExtension($s); if ($me) { if (!is_image_extenstion($extension)) { $html .= '<div class="item"><a data-icon="' . get_file_icon_path($extension) . '" href="" class="pdf-thumbs" title="' . $s . '" rel="' . $s . '"><img src="' . get_file_icon_path($extension) . '" class="img-polaroid" width="130" height="90"></a></div>'; } else { $html .= '<div class="item"><a href="" class="img-thumbs" title="' . $s . '" rel="' . $s . '"><img src="asc-thumb.php?src=' . $s . '&w=130&h=90" class="img-polaroid" width="130" height="90"></a></div>'; } } elseif ($exists) { $html .= '<div class="item"><a href="" class="img-thumbs" title="' . $s . '" rel="' . $s . '"><img src="' . $s . '" class="img-polaroid" width="130" height="90"></a></div>'; } } if ($html != '') { $output["html"] = $html; } else { $output["success"] = 0; }
$Filter_Array = explode(",", strtolower($MediaFilters)); break; case "template": $C_MaxSize = $MaxTemplateSize; $Filter_Array = explode(",", strtolower($TemplateFilters)); break; case "document": $C_MaxSize = $MaxDocumentSize; $Filter_Array = explode(",", strtolower($DocumentFilters)); break; default: break; } $Is_valid = false; $contentType = str_replace("image/pjpeg", "image/jpeg", $contentType); if (in_array(strtolower(GetExtension($filename)), $Filter_Array)) { if (strnatcasecmp(trim($contentType), trim($filemimetype)) == 0) { $Is_valid = true; } else { if (strnatcasecmp(trim($contentType), trim($filemimetype2)) == 0) { $Is_valid = true; } } } if (strpos($contentType, 'video/') !== false) { $Is_valid = true; } if (!$Is_valid) { echo trim($contentType) . trim($filemimetype) . " <span style='font-family: MS Sans Serif; font-size: 9pt; color:red'><b>File format not allowed! Please contact site administrator. </b></span><br><br>"; echo "<span><a style=\"font-family: MS Sans Serif; font-size: 9pt; vertical-align: top;\" href=\"upload.php?" . $setting . "&FP=" . $_GET["FP"] . "&Type=" . $_GET["Type"] . "\">Upload a new file</a></span>"; return;
function GetFileType($Path, $FileName) { $FileExtension = GetExtension($FileName); $Return = "Invalid"; if (in_array($FileExtension, array("jpg", "gif", "bmp", "png", "jpe", "jpeg"))) { $File = $this->FilePath($Path, $FileName); $ImageInfo = getimagesize($File); /* http://ca.php.net/manual/en/function.getimagesize.php 1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP, 7 = TIFF(intel byte order), 8 = TIFF(motorola byte order), 9 = JPC, 10 = JP2, 11 = JPX, 12 = JB2, 13 = SWC, 14 = IFF, 15 = WBMP, 16 = XBM */ switch ($ImageInfo[2]) { case 1: $Return = "gif"; break; case 2: $Return = "jpeg"; break; case 3: $Return = "png"; break; case 15: $Return = "wbmp"; break; } } return $Return; }
<? $target_path = "minidumps/"; $target_path = $target_path . basename( $_FILES['crashfile']['name']); if(GetExtension($target_path) != "zip") { echo "Invalid file."; return; } if($_FILES['crashfile']['size'] > 1024*1024) { echo "The file is too large."; return; } if(move_uploaded_file($_FILES['crashfile']['tmp_name'], $target_path)) { chmod($target_path, 0666); echo "The file " . basename($_FILES['crashfile']['name']) . " has been uploaded"; $logline = basename($_FILES['crashfile']['name']) . " | " . gethostbyaddr($_SERVER['REMOTE_ADDR']) . "\r\n"; error_log($logline, 3, 'minidumps/minidumps.log.php'); } else { echo "There was an error uploading the file, please try again!"; }
function set_filename($path, $filename) { $filename = clean_file_name($filename); $file_ext = GetExtension($filename); if (!file_exists($path . $filename)) { return $filename; } $new_filename = str_replace('.' . $file_ext, '', $filename); for ($i = 1; $i < 300; $i++) { if (!file_exists($path . $new_filename . '_' . $i . '.' . $file_ext)) { $new_filename .= '_' . $i . '.' . $file_ext; break; } } return $new_filename; }
function newpage() { global $FileName, $ErrorPage, $version; //編集モード $host = $_SERVER["HTTP_HOST"]; $uri = rtrim(dirname($_SERVER["PHP_SELF"]), "/\\"); //ファイル存在? if (ExistsPage($FileName)) { http_response_code(404); echo Error("404 NotFound", $ErrorPage, "The appointed file exist.", $version); exit; } //追加チェック if (isset($_POST["name"])) { $NewName = $_POST["name"]; } else { http_response_code(404); echo Error("404 NotFound", $ErrorPage, "It's an unjust URL.", $version); exit; } if (isset($_POST["text"])) { $NewText = $_POST["text"]; } else { http_response_code(404); echo Error("404 NotFound", $ErrorPage, "It's an unjust URL.", $version); exit; } if (isset($_POST["file"])) { $NewFile = $_POST["file"]; } else { http_response_code(404); echo Error("404 NotFound", $ErrorPage, "It's an unjust URL.", $version); exit; } if (isset($_POST["filename"])) { if ($_POST["filename"] === "auto") { $NewFileName = time(); } else { $NewFileName = $NewFile; } } else { http_response_code(404); echo Error("404 NotFound", $ErrorPage, "It's an unjust URL.", $version); exit; } if (isset($_POST["type"])) { $Type = $_POST["type"]; } else { http_response_code(404); echo Error("404 NotFound", $ErrorPage, "It's an unjust URL.", $version); exit; } if (isset($_POST["priority"])) { $Priority = $_POST["priority"]; } else { http_response_code(404); echo Error("404 NotFound", $ErrorPage, "It's an unjust URL.", $version); exit; } if (isset($_POST["tags"])) { $Tag = $_POST["tags"]; } else { $Tag = ""; } $Table = file_get_contents("config/exttable.txt"); if (GetExtension($Type, $Table)) { $Extension = GetExtension($Type, $Table); } else { http_response_code(404); echo Error("404 NotFound", $ErrorPage, "It's an unjust URL.", $version); exit; } //各種ファイル生成 mkdir("page/{$NewFileName}"); touch("page/{$NewFileName}/config.ini"); touch("page/{$NewFileName}/{$NewFileName}.{$Extension}"); //設定変更 $config["general"]["filename"] = "{$NewFileName}.{$Extension}"; $config["general"]["title"] = $NewName; $config["general"]["type"] = "markdown"; $config["general"]["author"] = "atnanasi"; $config["general"]["date"] = date("Y/m/d"); $config["general"]["time"] = date("H:i:s"); $config["general"]["type"] = $Type; $config["general"]["tag"] = $Tag; $config["general"]["priority"] = $Priority; write_ini_file($config, "page/{$NewFileName}/config.ini"); //ファイルへ書き込み file_put_contents("page/{$NewFileName}/{$config["general"]["filename"]}", $NewText); header("Location: http://{$host}{$uri}/index.php?q={$NewFileName}"); }