function FormsCheckType($var, $typearr, &$error = null, &$filename = null) { if ($typearr[1] == 'file') { $file_save_dir = 'uploads/forms'; if (!is_dir($file_save_dir)) { mkdir($file_save_dir); } $UploadErrors = array(0 => '', 1 => 'Размер файла превышен', 2 => 'Размер файла превышен', 3 => 'Файл загружен только частично', 4 => 'Файл не был загружен.', 6 => 'Не найдена папка для временных файлов на сервере', 7 => 'Ошибка во время записи на диск', 8 => 'Загрузка файла была прервана расширением PHP', 9 => 'Ошибка во время записи на диск'); if ($var['error'] == UPLOAD_ERR_OK) { $filename = Translit($var['name'], true); $ext = GetFileExt($filename); $name = GetFileName($filename, true); $file_path = $file_save_dir . '/' . $name . '_' . GenRandomString(8) . $ext; copy($var['tmp_name'], $file_path); return $file_path; } else { if ($var['error'] != 4) { $error = $UploadErrors[$var['error']]; } return ''; } } if ($typearr[2] == 'false') { $strip_tags = false; } else { $strip_tags = true; } $r = SafeEnv($var, (int) $typearr[0], (string) $typearr[1], $strip_tags); if ($r === false) { $r = '0'; } elseif ($r === true) { $r = '1'; } return $r; }
function IndexDownloadsGetFileType($filename) { $ext = strtolower(GetFileExt($filename, true)); $types = array('rar' => 'Архив RAR', 'zip' => 'Архив ZIP', '7z' => 'Архив 7zip', 'ace' => 'WinACE', 'odt' => 'Текстовый документ OpenDocument', 'odg' => 'Графический документ OpenDocument', 'odp' => 'Документ презентации OpenDocument', 'ods' => 'Электронная таблица OpenDocument', 'odc' => 'Документ диаграммы OpenDocument', 'odi' => 'Документ изображения OpenDocument', 'odf' => 'Документ формулы OpenDocument', 'odm' => 'Составной текстовый документ OpenDocument'); if (isset($types[$ext])) { return $types[$ext]; } else { if (preg_match('/pdf|pds/i', $ext)) { return 'Документ Adobe PDF'; } if (preg_match('/xls|xl|xla|xlb|xlc|xld|xlk|xll|xlm|xlt|xlv|xlw/i', $ext)) { return 'Документ MS-Excel'; } if (preg_match('/doc|dot|wiz|wzs|docx/i', $ext)) { return 'Документ MS-Word'; } if (preg_match('/pot|ppa|pps|ppt|pwz/i', $ext)) { return 'Документ MS-Powerpoint'; } if (preg_match('/flv|f4v|f4p|f4a|f4b/i', $ext)) { return 'Flash Video (FLV)'; } if (preg_match('/jpeg|jpe|jpg/i', $ext)) { return 'JPEG/JPE/JPG'; } if (preg_match('/ogv|oga|ogx|ogg/i', $ext)) { return 'Ogg Vorbis'; } return strtoupper($ext); } }
public function basic_view($alias, $display_item, $parent_item, $image_types, $encoded_seek_search_params, $search_position, $seek_search_params, $isthisCompoundObject, $previous_item, $next_item, $current_item_num, $totalitems) { $conf =& dmGetCollectionFieldInfo($alias); $itnum = $display_item['ptr']; $rc = dmGetItemInfo($alias, $itnum, $data); $parser = xml_parser_create(); xml_parse_into_struct($parser, $data, $structure, $index); xml_parser_free($parser); dmGetImageInfo($alias, $itnum, $filename, $type, $width, $height); $filename = substr($filename, strrpos($filename, "/") + 1); $file_extension = GetFileExt($filename); if (in_array($file_extension, $image_types)) { $is_image = true; $dimensions = Image::fit_width($width, $height, 640); $scaled_width = $dimensions[0]; $scaled_height = $dimensions[1]; $scaling_factor = $dimensions[2]; $file_url = "http://cdm9006.cdmhost.com/cgi-bin/getimage.exe?CISOROOT=" . $alias . "&CISOPTR=" . $itnum; $file_url .= "&DMWIDTH=" . $scaled_width . "&DMHEIGHT=" . $scaled_height . "&DMSCALE=" . $scaling_factor; } else { $is_image = false; $file_url = "http://cdm9006.cdmhost.com/cgi-bin/showfile.exe?CISOROOT=" . $alias . "&CISOPTR=" . $itnum; $encoded_file_url = urlencode("http://cdm9006.cdmhost.com/cgi-bin/showfile.exe?CISOROOT=" . $alias . "&CISOPTR=" . $itnum); } include 'basic_view.php'; }
function IsFileExt($file, $ext) { if (GetFileExt(strtolower($file)) == strtolower($ext)) { return true; } else { return false; } }
function CheckExtName() { global $zbp; $e = GetFileExt($this->Name); if (HasNameInString($zbp->option['ZC_UPLOAD_FILETYPE'], $e)) { return true; } else { return false; } }
/** * @param string $extlist * @return bool */ public function CheckExtName($extlist = '') { global $zbp; $e = GetFileExt($this->Name); $extlist = strtolower($extlist); if (trim($extlist) == '') { $extlist = $zbp->option['ZC_UPLOAD_FILETYPE']; } return HasNameInString($extlist, $e); }
function GetFiles($dir, $orderby, $hidden) { $files = array(); // Server-Pfad ermitteln $dir = GetDocumentRoot() . $dir; // In Kleinbuchstaben umwandeln for ($i = 0; $i < count($hidden); $i++) { $hidden[$i] = strtolower($hidden[$i]); } // Leerzeichen entfernen for ($i = 0; $i < count($hidden); $i++) { $hidden[$i] = ltrim($hidden[$i]); $hidden[$i] = rtrim($hidden[$i]); } // Dateien ermitteln if ($dh = @opendir($dir)) { while ($file = readdir($dh)) { if (!preg_match("/^\\.+\$/", $file)) { if (is_file($dir . $file) && !in_array(strtolower(GetFileExt($file)), $hidden)) { $files[0][] = $file; $files[1][] = filemtime($dir . $file); $files[2][] = filesize($dir . $file); } } } closedir($dh); } switch ($orderby) { case "0": @array_multisort($files[1], SORT_NUMERIC, SORT_DESC, $files[0], SORT_STRING, SORT_DESC); break; case "1": @array_multisort($files[0], SORT_STRING, SORT_ASC); break; case "2": @array_multisort($files[0], SORT_STRING, SORT_DESC); break; case "3": @array_multisort($files[2], SORT_NUMERIC, SORT_ASC, $files[0], SORT_STRING, SORT_DESC); break; case "4": @array_multisort($files[2], SORT_NUMERIC, SORT_DESC, $files[0], SORT_STRING, SORT_DESC); break; case "5": @array_multisort($files[1], SORT_NUMERIC, SORT_ASC, $files[0], SORT_STRING, SORT_DESC); break; case "6": @array_multisort($files[1], SORT_NUMERIC, SORT_DESC, $files[0], SORT_STRING, SORT_DESC); break; } // Server-Cache löschen clearstatcache(); // Datei-Array zurückgeben return $files[0]; }
/** * @param $tmp * @param $upload */ function Storage($tmp, &$upload) { global $zbp, $domainname; $filename = date("Ymd", time()) . mt_rand(1000, 9999) . '_' . mt_rand(0, 1000) . '.' . GetFileExt($upload->SourceName); $object = date("Y/m/", time()) . $filename; //构造云文件名 $upload->Name = $filename; $s = new SaeStorage(); $url = $s->upload($domainname, $object, $tmp); $upload->Metas->Storage_URL = $object; $GLOBALS['Filter_Plugin_Upload_SaveFile']['Storage'] = PLUGIN_EXITSIGNAL_RETURN; }
/** * Генерирует миниатюру и кэширует её. Возвращает имя файла миниатюры. * @param $FileName Исходный файл изображения. * @param int $MaxWidth Максимальная ширина миниатюры. * @param int $MaxHeight Максимальная высота миниатюры. * @param bool $Streech Растягивать ли картинку если заданные размеры больше исходных * @param null $SaveFormat Формат сохранения миниатюры (jpeg, png, gif, wbmp). * @return mixed */ function GetThumb($FileName, $MaxWidth = 0, $MaxHeight = 0, $Streech = false, $SaveFormat = null) { if ($FileName == '') { return 'images/no_image.png'; } elseif (substr($FileName, 0, 7) == 'http://') { return $FileName; } $FileName = RealPath2($FileName); if (isset($SaveFormat)) { $ext = '.' . $SaveFormat; } else { $ext = GetFileExt($FileName); } $tmb_path = System::config('general/tmb_path'); if (!is_dir($tmb_path)) { MkDirRecursive($tmb_path); } $tmb_file = $tmb_path . md5($FileName) . '_' . $MaxWidth . 'x' . $MaxHeight . ($Streech ? '_streech' : '') . $ext; if (!is_file($tmb_file)) { CreateThumb($FileName, $tmb_file, $MaxWidth, $MaxHeight, $Streech, $SaveFormat); } return $tmb_file; }
case "edit": case "list": build_page($method); break; case "delete": if (!$op_mode && $web_id != $_GET['web_id']) { $goto_url = $setting['info']['self']; } else { $log_info = $setting['language']['admin_art_content_delete']; $sql_list = array(); $db->delete($setting['db']['pre_sub'] . "news_show", array("news_id", "n=", $news_id)); $db->delete($setting['db']['pre_sub'] . "news_detail", array("news_id", "n=", $news_id)); $db->select($setting['db']['pre_sub'] . "attachment", "*", array(array("web_id", "n=", $web_id), array("news_id", "n=", $news_id))); while ($record = $db->GetRS()) { $the_path = ROOT_PATH . "/" . $setting['path']['upload'] . date("/Y/m/d/", substr($record['file_time'], 0, 10)); $the_ext = GetFileExt($record['file_name']); if ($the_ext == "php") { $the_ext = "txt"; } $the_file = $record['file_time'] . "." . $the_ext; MultiDel($the_path . $the_file); MultiDel($the_path . "cache/" . $the_file); MultiDel($the_path . "preview/" . $the_file); MultiDel($the_path . "preview/cache/" . $the_file); $sql_list[] = $db->delete($setting['db']['pre'] . "attachment", array("id", "n=", $record['id']), false); } $db->Free(); $db->BatchExec($sql_list); delCacheFile($news_id, $setting_sub["info"]['web_id']); } break;
/** * \brief Search the whole repository for containers with names * similar to $FileName (based on the beggining text of $FileName) * * \param $uploadtree_pk - the pk of $FileName. * * \return html (select list) for picking suggestions. */ function SuggestionsPick($FileName, $uploadtree_pk, &$rtncount) { global $PG_CONN; /* find the root of $FileName. Thats the beginning alpha part. */ $BaseFN = basename($FileName); $delims = "/-.0123456789 \t\n\rxb"; $NameRoot = ltrim($BaseFN, $delims); $NameRoot = strtok($NameRoot, $delims); /* Only make suggestions with matching file extensions */ $ext = GetFileExt($FileName); $tail = ".{$ext}"; if (empty($NameRoot)) { return ""; } /* find non artifact containers with names similar to $FileName */ $sql = "select uploadtree_pk from uploadtree\n where ((ufile_mode & (1<<29))!=0) AND ((ufile_mode & (1<<28))=0)\n and (ufile_name like '{$NameRoot}%{$tail}') \n and (uploadtree_pk != '{$uploadtree_pk}') limit 100"; $result = pg_query($PG_CONN, $sql); DBCheckResult($result, $sql, __FILE__, __LINE__); $SuggestionsArray = array(); while ($row = pg_fetch_assoc($result)) { $PathArray = Dir2Path($row['uploadtree_pk'], 'uploadtree'); $SuggestionsArray[$row['uploadtree_pk']] = Uploadtree2PathStr($PathArray); } pg_free_result($result); $rtncount = count($SuggestionsArray); if ($rtncount == 0) { return ""; } /* Order the select list by the beginning of the path */ natsort($SuggestionsArray); $Options = "id=SuggestPick onchange='AppJump(this.value)')"; $SelectList = Array2SingleSelect($SuggestionsArray, "SuggestionsPick", "", true, true, $Options); return $SelectList; }
/** * Удаляет все размеры аватара по его имени * @param $AvatarFileName * @return void */ function UnlinkUserAvatarFiles($AvatarFileName) { $pavatar_dir = System::config('general/personal_avatars_dir'); $AvatarFileName = RealPath2($pavatar_dir . $AvatarFileName); if (is_file($AvatarFileName)) { unlink($AvatarFileName); $_name = GetFileName($AvatarFileName, true); $_ext = GetFileExt($AvatarFileName); if (is_file($pavatar_dir . $_name . '_24x24' . $_ext)) { unlink($pavatar_dir . $_name . '_24x24' . $_ext); } if (is_file($pavatar_dir . $_name . '_64x64' . $_ext)) { unlink($pavatar_dir . $_name . '_64x64' . $_ext); } } }
if ($SESSION["upload_filetype"] != "" && $SESSION["upload_filesize"] != "") { if (filesize($_FILES["input1"]["tmp_name"]) / 1024 <= $SESSION["upload_filesize"] && in_array(strtolower(GetFileExt($_POST["edit1"] . $_POST["edit2"])), $array)) { $UPLOAD_RESULT = @move_uploaded_file($_FILES["input1"]["tmp_name"], GetDocumentRoot() . $SESSION["dir"] . $_POST["edit1"] . $_POST["edit2"]); } else { $UPLOAD_RESULT = false; } } else { if ($SESSION["upload_filetype"] == "" && $SESSION["upload_filesize"] != "") { if (filesize($_FILES["input1"]["tmp_name"]) / 1024 <= $SESSION["upload_filesize"]) { $UPLOAD_RESULT = @move_uploaded_file($_FILES["input1"]["tmp_name"], GetDocumentRoot() . $SESSION["dir"] . $_POST["edit1"] . $_POST["edit2"]); } else { $UPLOAD_RESULT = false; } } else { if ($SESSION["upload_filetype"] != "" && $SESSION["upload_filesize"] == "") { if (in_array(strtolower(GetFileExt($_POST["edit1"] . $_POST["edit2"])), $array)) { $UPLOAD_RESULT = @move_uploaded_file($_FILES["input1"]["tmp_name"], GetDocumentRoot() . $SESSION["dir"] . $_POST["edit1"] . $_POST["edit2"]); } else { $UPLOAD_RESULT = false; } } else { if ($SESSION["upload_filetype"] == "" && $SESSION["upload_filesize"] == "") { $UPLOAD_RESULT = @move_uploaded_file($_FILES["input1"]["tmp_name"], GetDocumentRoot() . $SESSION["dir"] . $_POST["edit1"] . $_POST["edit2"]); } } } } } // Dateirechte anpassen if ($UPLOAD_RESULT) { @chmod(GetDocumentRoot() . $SESSION["dir"] . $_POST["edit1"] . $_POST["edit2"], $CONFIG["chmod_file"]);
/** * \brief Add fuzzyname and fuzzynameext to $Children. * The fuzzy name is used to do fuzzy matches. * In this implementation the fuzzyname is just the filename * with numbers, punctuation, and the file extension removed. * fuzzynameext is the same as fuzzyname but with the file extension. * * \param $Children child list */ function FuzzyName(&$Children) { foreach ($Children as $key1 => &$Child) { /* remove file extension */ if (strstr($Child['ufile_name'], ".") !== false) { $Ext = GetFileExt($Child['ufile_name']); $ExtLen = strlen($Ext); $NoExtName = substr($Child['ufile_name'], 0, -1 * $ExtLen); } else { $NoExtName = $Child['ufile_name']; } $NoNumbName = preg_replace('/([0-9]|\\.|-|_)/', "", $NoExtName); $NoNumbNameext = preg_replace('/([0-9]|\\.|-|_)/', "", $Child['ufile_name']); $Child['fuzzyname'] = $NoNumbName; $Child['fuzzynameext'] = $NoNumbName; } return; }
} } else { showInfo($setting['language']['admin_web_template_upload_error']); } unset($upload); } $idx = ""; break; case "add_ok": case "edit_ok": if (count($_POST) > 0) { $log_info = $setting['language']['admin_web_template_edit']; if ($_POST['file_name'] == "style.css") { $the_file = ROOT_PATH . "/images/" . $idx . "/style.css"; } else { $ext = GetFileExt($_POST['file_name']); if ($ext != "tpl") { $_POST['file_name'] .= ".tpl"; } $the_file = $tpl_path . $idx . "/" . $_POST['file_name']; } $_POST['file_content'] = str_replace(" ", "\t", $_POST['file_content']); WriteFile($the_file, $_POST['file_content'], "wb"); } break; default: build_page("show"); } if (!empty($log_info)) { write_log($log_info, "idx={$idx}"); $goto_url = $setting['info']['self'];
function AdminSmiliesFind($DirName, $Xor = array(), $RevertXor = false, $New = true) { static $result = array(); static $BasePath; if ($New) { $result = array(); $BasePath = $DirName; } $files = array(); $folders = array(); $relative_path = str_replace($BasePath, '', $DirName); $dir = @opendir($DirName); while ($file = @readdir($dir)) { if (is_dir($DirName . $file) && $file != '.' && $file != '..') { $folders[] = $file; } else { $ext = GetFileExt($file); if ($ext == '.gif' || $ext == '.png') { $file = $relative_path . $file; if (!in_array($file, $Xor) || $RevertXor) { $files[] = $file; } } } } $info = AdminSmiliesLoadInfo($DirName, $relative_path, $files); foreach ($files as $file) { if (isset($info[$file])) { $result[$file] = $info[$file]; } else { $result[$file] = array('file' => $file, 'desc' => GetFileName($file, true), 'code' => '*' . GetFileName($file, true) . '*'); } } foreach ($folders as $folder) { AdminSmiliesFind($DirName . $folder . '/', $Xor, $RevertXor, false); } return $result; }
<?php include "../dmscripts/DMSystem.php"; if (isset($_SERVER["QUERY_STRING"])) { $arglist = $_SERVER["QUERY_STRING"]; $p = strpos($arglist, ",", 0); if ($p > 0) { $alias = substr($arglist, 0, $p); $ptr = substr($arglist, $p + 1); $rc = dmGetCollectionParameters($alias, $name, $path); if ($rc >= 0) { $rc2 = dmGetItemInfo($alias, $ptr, $buf); if ($rc2 > 0) { $find = GetXMLField("find", $buf); $ext = GetFileExt($find); if ($ext == "cpd") { $link = "/seeking_michigan/discover_item_viewer.php?CISOROOT=" . $alias . "&CISOPTR=" . $ptr; } else { $rc3 = GetParent($alias, $ptr, $path); if ($rc3 >= 0) { $link = "/seeking_michigan/discover_item_viewer.php?CISOROOT=" . $alias . "&CISOPTR=" . $rc3 . "&CISOSHOW=" . $ptr; } else { $link = "/seeking_michigan/discover_item_viewer.php?CISOROOT=" . $alias . "&CISOPTR=" . $ptr; } } print "<html>\n"; print "<head>\n"; print "<title>Redirect URL</title>\n"; $line = '<META HTTP-EQUIV="Refresh" CONTENT="0; URL=' . $link . '">' . "\n"; print "{$line}"; print "</head>\n";
function localPicture($img_list, &$content, $zoom = 700) { global $db, $setting, $req, $pic_list; for ($i = 0, $m = count($img_list); $i < $m; $i++) { if (array_search($img_list[$i], $pic_list) === false) { array_push($pic_list, $img_list[$i]); } else { continue; } if (strpos($img_list[$i], $setting['web']['url']) !== false) { continue; } if (strpos($img_list[$i], getSetting('web', 'url')) !== false) { continue; } $the_time = GetMicrotime(); $old_name = strtolower(basename($img_list[$i])); $ext = "." . GetFileExt($img_list[$i]); $ext = preg_replace("/\\?.*\$/", "", $ext); $old_name = preg_replace("/\\?.*\$/", "", $old_name); $old_name = preg_replace("/[;,&\\=]/", "", $old_name); //if(strpos("*.jpg.bmp.gif.png",$ext)===false) continue; if ($ext == ".") { $ext = ".jpg"; $old_name .= $ext; } if (strlen($old_name) > 120) { $old_name = substr($old_name, -120); } $new_name = $the_time . $ext; $the_path = ROOT_PATH . "/" . $setting['path']['upload'] . date("/Y/m/d/"); MakeDir($the_path); if (GetRemoteFile($img_list[$i], $the_path . $new_name)) { $img_info = GetImageSize($the_path . $new_name); $the_width = $img_info[0]; $the_height = $img_info[1]; if (!is_numeric($zoom)) { $zoom = 700; } if ($the_width > $zoom) { $the_height *= $zoom / $the_width; $the_width = $zoom; } $data = array(0, 0, 0, $old_name, "image" . str_replace(".", "/", $ext), filesize($the_path . $new_name), '', $the_time, 0, '', $req->getSession('username'), $setting['watermark']['mode'] & 2 ? 1 : 0); $db->insert($setting['db']['pre'] . "attachment", $data); $new_id = $db->GetInsertId(); if ($new_id != 0) { $attach_list .= $new_id . ","; $content = str_replace($img_list[$i], $setting['web']['url'] . "/files?" . $new_id, $content); array_push($id_list, $new_id); } $name_new = $the_time . substr(md5(filesize($the_path . $new_name)), 0, 5) . $ext; rename($the_path . $new_name, $the_path . $name_new); MakeDir("{$the_path}/preview/"); img_thumb($the_path . $name_new, $the_width, $the_height, $the_path . "/preview/" . $name_new); } } return $attach_list; }
if ($method == "import") { $log_info = $setting['language']['admin_func_backup_import']; $path_upload = ROOT_PATH . "/" . $setting['path']['upload'] . "/tmp/"; $upload = $mystep->getInstance("MyUploader", $path_upload, true); $upload->DoIt(false); if (count($upload->upload_result) > 0) { if ($upload->upload_result[0]['error'] == 0) { $db->SelectDB($setting_sub['db']['name']); if ($upload->upload_result[0]['type'] == "application/x-zip-compressed") { require ROOT_PATH . "/source/class/myzip.class.php"; $dir = $path_upload . date("/Ymd_") . rand(1000, 9999) . "/"; unzip($path_upload . $upload->upload_result[0]['new_name'], $dir); $result_exe = array(); if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { if (is_file($file) && GetFileExt($file) == "sql") { $result_exe += $db->ExeSqlFile($file); } } closedir($handle); } $result = count($result_exe) > 0 ? $setting['language']['admin_func_backup_import_done'] : $setting['language']['admin_func_backup_import_failed']; MultiDel($dir); } else { $result_exe = $db->ExeSqlFile($path_upload . $upload->upload_result[0]['new_name']); $result = count($result_exe) > 0 ? $setting['language']['admin_func_backup_import_done'] : $setting['language']['admin_func_backup_import_failed']; } unlink($path_upload . $upload->upload_result[0]['new_name']); $db->SelectDB($setting['db']['name']); } else { $result = $setting['language']['admin_func_backup_upload_failed'] . $upload->upload_result[0]['message'];
} else { if ($parent_filetype == 'pdf') { $isthisCompoundObject = false; $display_item = $parent_item; $itnum = $requested_itnum; $printable = true; $print_item = $display_item; } else { $isthisCompoundObject = false; $display_item = $parent_item; $itnum = $requested_itnum; $print_item = $display_item; } } } $filetype = GetFileExt($display_item['structure'][$display_item['index']["FIND"][0]]["value"]); $doctitle = $display_item['structure'][$display_item['index']["TITLE"][0]]["value"]; $isthisImage = in_array($filetype, $isImage); if ($isthisImage) { dmGetCollectionImageSettings($alias, $pan_enabled, $minjpegdim, $zoomlevels, $maxderivedimg, $viewer, $docviewer, $compareviewer, $slideshowviewer); include "discover/pan_scr.php"; define("FACEBOX", 'display'); define("LIGHTBOX", 'display'); define("SLIDER", 'display'); $lightbox_images = array('fullscreen_popup' => array('alias' => $alias, 'itnum' => $itnum)); // full-screen view settings if ($lightbox_images) { foreach ($lightbox_images as $id => $data) { $filename = $type = $width = $height = ''; $image_info = dmGetImageInfo($alias, $itnum, $filename, $type, $width, $height); $lightbox_images[$id]['filename'] = $filename;
function AdminUserSaveAvatar() { $alloy_mime = array('image/gif' => '.gif', 'image/jpeg' => '.jpg', 'image/pjpeg' => '.jpg', 'image/png' => '.png', 'image/x-png' => '.png'); include_once System::config('inc_dir') . 'picture.class.php'; $asize = getimagesize($_FILES['avatar']['tmp_name']); $alloy_mime = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png'); $alloy_exts = array('.gif', '.jpg', '.jpeg', '.png'); if (in_array($_FILES['avatar']['type'], $alloy_mime) && in_array(strtolower(GetFileExt($_FILES['avatar']['name'])), $alloy_exts)) { $NewName = $_FILES['avatar']['name']; if ($asize[0] > System::config('user/max_avatar_width') || $asize[1] > System::config('user/max_avatar_height')) { $thumb = new TPicture($_FILES['avatar']['tmp_name']); $thumb->SetImageSize(System::config('user/max_avatar_width'), System::config('user/max_avatar_height')); $thumb->SaveToFile(System::config('general/avatars_dir') . $NewName); } else { copy($_FILES['avatar']['tmp_name'], System::config('general/avatars_dir') . $NewName); } Audit('Пользователи: Добавление аватара в галерею аватар "' . $NewName . '"'); } else { System::admin()->AddCenterBox('Загрузка аватара'); System::admin()->HighlightError('Неправильный формат аватара. Ваш аватар должен быть формата GIF, JPEG или PNG.<br /><a href="javascript:history.go(-1)">Назад в галерею</a>'); } GO(ADMIN_FILE . '?exe=user&a=avatars'); }
/** * \brief Display the loaded menu and plugins. */ function Output() { if ($this->State != PLUGIN_STATE_READY) { return; } global $Plugins; $V = ""; $Time = time(); $Max = 50; /* Input parameters */ $nomosagent_pk = GetParm("napk", PARM_INTEGER); $uploadtree_pk = GetParm("item", PARM_INTEGER); $rf_shortname = GetParm("lic", PARM_RAW); $tag_pk = GetParm("tag", PARM_INTEGER); $Excl = GetParm("excl", PARM_RAW); $Exclic = GetParm("exclic", PARM_RAW); $rf_shortname = rawurldecode($rf_shortname); if (empty($uploadtree_pk) || empty($rf_shortname)) { $text = _("is missing required parameters."); echo $this->Name . " {$text}"; return; } $Page = GetParm("page", PARM_INTEGER); if (empty($Page)) { $Page = 0; } // Get upload_pk and $uploadtree_tablename $UploadtreeRec = GetSingleRec("uploadtree", "where uploadtree_pk={$uploadtree_pk}"); $UploadRec = GetSingleRec("upload", "where upload_pk={$UploadtreeRec['upload_fk']}"); $uploadtree_tablename = $UploadRec['uploadtree_tablename']; switch ($this->OutputType) { case "XML": break; case "HTML": // micro menus $V .= menu_to_1html(menu_find($this->Name, $MenuDepth), 0); /* Load licenses */ $Offset = $Page < 0 ? 0 : $Page * $Max; $order = ""; $PkgsOnly = false; $CheckOnly = false; // Count is uploadtree recs, not pfiles $CountArray = CountFilesWithLicense($nomosagent_pk, $rf_shortname, $uploadtree_pk, $PkgsOnly, $CheckOnly, $tag_pk, $uploadtree_tablename); $Count = $CountArray['count']; $Unique = $CountArray['unique']; $text = _("files found"); $text1 = _("unique"); $text2 = _("with license"); $V .= "{$Count} {$text} ({$Unique} {$text1}) {$text2} <b>{$rf_shortname}</b>"; if ($Count < $Max) { $Max = $Count; } $limit = $Page < 0 ? "ALL" : $Max; $order = " order by ufile_name asc"; /** should delete $filesresult yourself */ $filesresult = GetFilesWithLicense($nomosagent_pk, $rf_shortname, $uploadtree_pk, $PkgsOnly, $Offset, $limit, $order, $tag_pk, $uploadtree_tablename); $NumFiles = pg_num_rows($filesresult); $file_result_temp = pg_fetch_all($filesresult); $sorted_file_result = array(); // the final file list will display $max_num = $NumFiles; /** sorting by ufile_name from DB, then reorder the duplicates indented */ for ($i = 0; $i < $max_num; $i++) { $row = $file_result_temp[$i]; if (empty($row)) { continue; } array_push($sorted_file_result, $row); for ($j = $i + 1; $j < $max_num; $j++) { $row_next = $file_result_temp[$j]; if (!empty($row_next) && $row['pfile_fk'] == $row_next['pfile_fk']) { array_push($sorted_file_result, $row_next); $file_result_temp[$j] = null; } } } $text = _("Display"); $text1 = _("excludes"); $text2 = _("files with these extensions"); if (!empty($Excl)) { $V .= "<br>{$text} <b>{$text1}</b> {$text2}: {$Excl}"; } $text2 = _("files with these licenses"); if (!empty($Exclic)) { $V .= "<br>{$text} <b>{$text1}</b> {$text2}: {$Exclic}"; } /* Get the page menu */ if ($Max > 0 && $Count >= $Max && $Page >= 0) { $VM = "<P />\n" . MenuEndlessPage($Page, intval(($Count + $Offset) / $Max)) . "<P />\n"; $V .= $VM; } else { $VM = ""; } /* Offset is +1 to start numbering from 1 instead of zero */ $RowNum = $Offset; $LinkLast = "view-license&napk={$nomosagent_pk}"; $ShowBox = 1; $ShowMicro = NULL; // base url $ushortname = rawurlencode($rf_shortname); $baseURL = "?mod=" . $this->Name . "&napk={$nomosagent_pk}&item={$uploadtree_pk}&lic={$ushortname}&page=-1"; $V .= "<table>"; $text = _("File"); $V .= "<tr><th>{$text}</th><th> "; $LastPfilePk = -1; $ExclArray = explode(":", $Excl); $ExclicArray = explode(":", $Exclic); foreach ($sorted_file_result as $row) { $pfile_pk = $row['pfile_fk']; $licstring = GetFileLicenses_string($nomosagent_pk, $pfile_pk, $row['uploadtree_pk'], $uploadtree_tablename); $URLlicstring = urlencode($licstring); // Allow user to exclude files with this extension $FileExt = GetFileExt($row['ufile_name']); $URL = $baseURL; if (!empty($Excl)) { $URL .= "&excl={$Excl}:{$FileExt}"; } else { $URL .= "&excl={$FileExt}"; } if (!empty($Exclic)) { $URL .= "&exclic=" . urlencode($Exclic); } $text = _("Exclude this file type."); $Header = "<a href={$URL}>{$text}</a>"; /* Allow user to exclude files with this exact license list */ $URL = $baseURL; if (!empty($Exclic)) { $URL .= "&exclic=" . urlencode($Exclic) . ":" . $URLlicstring; } else { $URL .= "&exclic={$URLlicstring}"; } if (!empty($Excl)) { $URL .= "&excl={$Excl}"; } $text = _("Exclude files with license"); $Header .= "<br><a href={$URL}>{$text}: {$licstring}.</a>"; $ok = true; /* exclude by type */ if ($Excl) { if (in_array($FileExt, $ExclArray)) { $ok = false; } } /* exclude by license */ if ($Exclic) { if (in_array($licstring, $ExclicArray)) { $ok = false; } } if (empty($licstring)) { $ok = false; } if ($ok) { $V .= "<tr><td>"; /* Tack on pfile to url - information only */ $LinkLastpfile = $LinkLast . "&pfile={$pfile_pk}"; if ($LastPfilePk == $pfile_pk) { $indent = "<div style='margin-left:2em;'>"; $outdent = "</div>"; } else { $indent = ""; $outdent = ""; } $V .= $indent; $V .= Dir2Browse("browse", $row['uploadtree_pk'], $LinkLastpfile, $ShowBox, $ShowMicro, ++$RowNum, $Header, '', $uploadtree_tablename); $V .= $outdent; $V .= "</td>"; $V .= "<td> </td>"; // spaces to seperate licenses // show the entire license list as a single string with links to the files // in this container with that license. $V .= "<td>{$licstring}</td></tr>"; $V .= "<tr><td colspan=3><hr></td></tr>"; // separate files } $LastPfilePk = $pfile_pk; } pg_free_result($filesresult); $V .= "</table>"; if (!empty($VM)) { $V .= $VM . "\n"; } $V .= "<hr>\n"; $Time = time() - $Time; $text = _("Elapsed time"); $text1 = _("seconds"); $V .= "<small>{$text}: {$Time} {$text1}</small>\n"; break; case "Text": break; default: break; } if (!$this->OutputToStdout) { return $V; } print $V; return; }
/** * Возвращает URL эскиза изображения или иконки файла * * @param $dir * @param $md5 * @param $filename * @param int $width * @param int $height * @internal param $type * @return string */ public function GetThumbUrl($dir, $md5, $filename, $width = 100, $height = 100) { $path = RealPath2(DIR_FILES . '/' . $dir); $url_path = URL_FILES . '/' . RealPath2($dir); if (substr($url_path, -1) == '/') { $url_path = substr($url_path, 0, -1); } $ext = strtolower(GetFileExt($filename, true)); if (in_array($ext, $this->allowedImages)) { $thumb = '/.thumbs/' . $md5 . '_' . $width . '_' . $height . '.jpg'; if (is_file($path . $thumb)) { return $url_path . $thumb; } CreateThumb($path . '/' . $filename, $path . $thumb, $width, $height, false, 'jpeg'); return $url_path . $thumb; } else { if ($ext != '' && is_file(DIR_ICONS . '/' . $ext . '.png')) { return URL_ICONS . '/' . $ext . '.png'; } else { return URL_ICONS . '/' . 'none.png'; } } }
function get_sub_item($alias, $compound_items, $num, $itnum) { $item = $compound_items[$num]; $stitle = linkText($item["title"]); if ($thisdoc == "PDFdoc") { $pageptr = "CISOROOT=" . $alias . "&CISOPTR=" . $itnum . "&CISOPAGE=" . $i . "&CISOSHOW=" . $item["ptr"]; $ptr = $itnum; } else { $pageptr = "CISOROOT=" . $alias . "&CISOPTR=" . $itnum . "&CISOSHOW=" . $item["ptr"]; $ptr = $item["ptr"]; } $item_data = get_item($alias, $item["ptr"]); $filetype = GetFileExt($item_data["structure"][$item_data["index"]["FIND"][0]]["value"]); return array('alias' => $alias, 'ptr' => $ptr, 'structure' => $item_data["structure"], 'index' => $item_data["index"], 'title' => $stitle, 'query_string' => $pageptr, 'res' => $compound_items, 'settings' => get_item_settings($alias, $ptr, $filetype), 'filetype' => $item_data['filetype'], 'thumbnail' => "/cgi-bin/thumbnail.exe?CISOROOT=" . $alias . "&CISOPTR=" . $ptr); }
if ($avatar == '' || !is_file($avatar)) { $avatar = GetGalleryAvatar('noavatar.gif'); } // Создаём уменьшенную копию аватара, если нужно и отправляем пользователю if (isset($_GET['size'])) { switch ($_GET['size']) { case 'small': $avatar_64 = System::config('general/personal_avatars_dir') . GetFileName($avatar, true) . '_64x64' . GetFileExt($avatar); if (is_file($avatar_64)) { CreateThumb($avatar_64)->SendToHTTPClient(); } else { CreateThumb($avatar, $avatar_64, 64, 64)->SendToHTTPClient(); } break; case 'smallest': $avatar_24 = System::config('general/personal_avatars_dir') . GetFileName($avatar, true) . '_24x24' . GetFileExt($avatar); if (is_file($avatar_24)) { CreateThumb($avatar_24)->SendToHTTPClient(); } else { CreateThumb($avatar, $avatar_24, 24, 24)->SendToHTTPClient(); } break; default: CreateThumb($avatar)->SendToHTTPClient(); } } else { CreateThumb($avatar)->SendToHTTPClient(); } if (isset($user_id) && !System::config('user/secure_avatar_upload')) { System::user()->UpdateAvatarData($user_id); }
/** * @param $tmp * @param $upload */ function CloudStorage($tmp, &$upload) { global $zbp; $bucket = $zbp->Config('CloudStorage')->CS_Bucket; //云文件夹 $filename = date("Ymd", time()) . mt_rand(1000, 9999) . '_' . mt_rand(0, 1000) . '.' . GetFileExt($upload->SourceName); $object = $zbp->Config('CloudStorage')->CS_Dir . date("Y/m/", time()) . $filename; //构造云文件名 $file_path = $zbp->usersdir . 'upload/tmp.data'; //本地临时文件地址 @move_uploaded_file($tmp, $file_path); //先上传到本地 $upload->Name = $filename; switch ($zbp->Config('CloudStorage')->CS_Storage) { case '1': define('OSS_ACCESS_ID', $zbp->Config('CloudStorage')->CS_Ali_KeyID); //ACCESS_ID define('OSS_ACCESS_KEY', $zbp->Config('CloudStorage')->CS_Ali_KeySecret); //ACCESS_KEY require_once dirname(__FILE__) . '/api/oss/sdk.class.php'; $os_service = new ALIOSS(); $os_service->set_debug_mode(FALSE); //$os_service->set_enable_domain_style(TRUE);//二级域名 $response = $os_service->upload_file_by_file($bucket, $object, $file_path); //将本地文件上传到云 $upload->Metas->CS_URL = $response->header['_info']['url']; break; case '2': require_once dirname(__FILE__) . '/api/qiniu/io.php'; require_once dirname(__FILE__) . '/api/qiniu/rs.php'; $accessKey = $zbp->Config('CloudStorage')->CS_QNiu_KeyID; $secretKey = $zbp->Config('CloudStorage')->CS_QNiu_KeySecret; Qiniu_SetKeys($accessKey, $secretKey); $putPolicy = new Qiniu_RS_PutPolicy($bucket); $upToken = $putPolicy->Token(null); //$putExtra = new Qiniu_PutExtra(); //$putExtra->Crc32 = 1; list($ret, $err) = Qiniu_PutFile($upToken, $object, $file_path, null); $upload->Metas->CS_URL = 'http://' . $bucket . '.qiniudn.com/' . $ret['key']; //20140509更新V1.1:删除u break; case '3': define('BCS_AK', $zbp->Config('CloudStorage')->CS_Baidu_KeyID); //AK 公钥 define('BCS_SK', $zbp->Config('CloudStorage')->CS_Baidu_KeySecret); //SK 私钥 require_once dirname(__FILE__) . '/api/bcs/bcs.class.php'; $baidu_bcs = new BaiduBCS(); $object = "/" . $object; $response = $baidu_bcs->create_object($bucket, $object, $file_path, array('acl' => 'public-read')); //var_dump($response);die(); $upload->Metas->CS_URL = "http://bcs.duapp.com/" . $bucket . $object; //$response->header['_info']['url']; //未解决文件标识 break; default: break; } $upload->Metas->CS_Tpye = $zbp->Config('CloudStorage')->CS_Storage; unlink($file_path); //删除本地文件 $GLOBALS['Filter_Plugin_Upload_SaveFile']['CloudStorage'] = PLUGIN_EXITSIGNAL_RETURN; return true; }
/** * \brief Display the loaded menu and plugins. */ function Output() { $uploadtree_pk = GetParm("item", PARM_INTEGER); $rf_shortname = GetParm("lic", PARM_RAW); $tag_pk = GetParm("tag", PARM_INTEGER); $Excl = GetParm("excl", PARM_RAW); $Exclic = GetParm("exclic", PARM_RAW); if (empty($uploadtree_pk) || empty($rf_shortname)) { $text = _("is missing required parameters."); return $this->Name . " {$text}"; } $Max = 50; $Page = GetParm("page", PARM_INTEGER); if (empty($Page)) { $Page = 0; } // Get upload_pk and $uploadtree_tablename $UploadtreeRec = GetSingleRec("uploadtree", "where uploadtree_pk={$uploadtree_pk}"); global $container; /** @var UploadDao */ $uploadDao = $container->get('dao.upload'); $uploadtree_tablename = $uploadDao->getUploadtreeTableName($UploadtreeRec['upload_fk']); // micro menus $V = menu_to_1html(menu_find($this->Name, $MenuDepth), 0); /* Load licenses */ $Offset = $Page < 0 ? 0 : $Page * $Max; $order = ""; $PkgsOnly = false; // Count is uploadtree recs, not pfiles $agentId = GetParm('agentId', PARM_INTEGER); if (empty($agentId)) { $agentId = "any"; } $CountArray = $this->countFilesWithLicense($agentId, $rf_shortname, $uploadtree_pk, $tag_pk, $uploadtree_tablename); if (empty($CountArray)) { $V .= _("<b> No files found for license {$rf_shortname} !</b>\n"); } else { $Count = $CountArray['count']; $Unique = $CountArray['unique']; $text = _("files found"); $text2 = _("with license"); $V .= "{$Unique} {$text} {$text2} <b>{$rf_shortname}</b>"; if ($Count < $Max) { $Max = $Count; } $limit = $Page < 0 ? "ALL" : $Max; $order = " order by ufile_name asc"; /** should delete $filesresult yourself */ $filesresult = GetFilesWithLicense($agentId, $rf_shortname, $uploadtree_pk, $PkgsOnly, $Offset, $limit, $order, $tag_pk, $uploadtree_tablename); $NumFiles = pg_num_rows($filesresult); $file_result_temp = pg_fetch_all($filesresult); $sorted_file_result = array(); // the final file list will display $max_num = $NumFiles; /** sorting by ufile_name from DB, then reorder the duplicates indented */ for ($i = 0; $i < $max_num; $i++) { $row = $file_result_temp[$i]; if (empty($row)) { continue; } array_push($sorted_file_result, $row); for ($j = $i + 1; $j < $max_num; $j++) { $row_next = $file_result_temp[$j]; if (!empty($row_next) && $row['pfile_fk'] == $row_next['pfile_fk']) { array_push($sorted_file_result, $row_next); $file_result_temp[$j] = null; } } } $text = _("Display"); $text1 = _("excludes"); $text2 = _("files with these extensions"); if (!empty($Excl)) { $V .= "<br>{$text} <b>{$text1}</b> {$text2}: {$Excl}"; } $text2 = _("files with these licenses"); if (!empty($Exclic)) { $V .= "<br>{$text} <b>{$text1}</b> {$text2}: {$Exclic}"; } /* Get the page menu */ if ($Max > 0 && $Count >= $Max && $Page >= 0) { $VM = "<P />\n" . MenuEndlessPage($Page, intval(($Count + $Offset) / $Max)) . "<P />\n"; $V .= $VM; } else { $VM = ""; } /* Offset is +1 to start numbering from 1 instead of zero */ $RowNum = $Offset; $LinkLast = "view-license"; $ShowBox = 1; $ShowMicro = NULL; // base url $ushortname = rawurlencode($rf_shortname); $baseURL = "?mod=" . $this->Name . "&item={$uploadtree_pk}&lic={$ushortname}&page=-1"; $V .= "<table>"; $text = _("File"); $V .= "<tr><th>{$text}</th><th> "; $LastPfilePk = -1; $ExclArray = explode(":", $Excl); $ExclicArray = explode(":", $Exclic); foreach ($sorted_file_result as $row) { $pfile_pk = $row['pfile_fk']; $licstring = GetFileLicenses_string($row['agent_pk'], $pfile_pk, $row['uploadtree_pk'], $uploadtree_tablename); $URLlicstring = urlencode($licstring); // Allow user to exclude files with this extension $FileExt = GetFileExt($row['ufile_name']); $URL = $baseURL; if (!empty($Excl)) { $URL .= "&excl={$Excl}:{$FileExt}"; } else { $URL .= "&excl={$FileExt}"; } if (!empty($Exclic)) { $URL .= "&exclic=" . urlencode($Exclic); } $text = _("Exclude this file type."); $Header = "<a href={$URL}>{$text}</a>"; /* Allow user to exclude files with this exact license list */ $URL = $baseURL; if (!empty($Exclic)) { $URL .= "&exclic=" . urlencode($Exclic) . ":" . $URLlicstring; } else { $URL .= "&exclic={$URLlicstring}"; } if (!empty($Excl)) { $URL .= "&excl={$Excl}"; } $text = _("Exclude files with license"); $Header .= "<br><a href={$URL}>{$text}: {$licstring}.</a>"; $excludeByType = $Excl && in_array($FileExt, $ExclArray); $excludeByLicense = $Exclic && in_array($licstring, $ExclicArray); if (!empty($licstring) && !$excludeByType && !$excludeByLicense) { $V .= "<tr><td>"; /* Tack on pfile to url - information only */ $LinkLastpfile = $LinkLast . "&pfile={$pfile_pk}"; if ($LastPfilePk == $pfile_pk) { $indent = "<div style='margin-left:2em;'>"; $outdent = "</div>"; } else { $indent = ""; $outdent = ""; } $V .= $indent; $V .= Dir2Browse("browse", $row['uploadtree_pk'], $LinkLastpfile, $ShowBox, $ShowMicro, ++$RowNum, $Header, '', $uploadtree_tablename); $V .= $outdent; $V .= "</td>"; $V .= "<td> </td>"; $V .= "<td>{$row['agent_name']}: {$licstring}</td></tr>"; $V .= "<tr><td colspan=3><hr></td></tr>"; } $LastPfilePk = $pfile_pk; } pg_free_result($filesresult); $V .= "</table>"; if (!empty($VM)) { $V .= $VM . "\n"; } } return $V; }
/** * \brief Display the loaded menu and plugins. */ function Output() { if ($this->State != PLUGIN_STATE_READY) { return; } global $Plugins; global $PG_CONN; // make sure there is a db connection if (!$PG_CONN) { echo _("NO DB connection"); } $OutBuf = ""; $Time = microtime(true); $Max = 50; /* Input parameters */ $agent_pk = GetParm("agent", PARM_INTEGER); $uploadtree_pk = GetParm("item", PARM_INTEGER); $hash = GetParm("hash", PARM_RAW); $type = GetParm("type", PARM_RAW); $excl = GetParm("excl", PARM_RAW); $filter = GetParm("filter", PARM_RAW); if (empty($uploadtree_pk) || empty($hash) || empty($type) || empty($agent_pk)) { $text = _("is missing required parameters"); echo $this->Name . " {$text}."; return; } /* Check item1 and item2 upload permissions */ $Row = GetSingleRec("uploadtree", "WHERE uploadtree_pk = {$uploadtree_pk}"); $UploadPerm = GetUploadPerm($Row['upload_fk']); if ($UploadPerm < PERM_READ) { $text = _("Permission Denied"); echo "<h2>{$text}<h2>"; return; } $Page = GetParm("page", PARM_INTEGER); if (empty($Page)) { $Page = 0; } /* get all rows */ $rows = $this->GetRows($uploadtree_pk, $agent_pk, $upload_pk); /* Get uploadtree_tablename */ $uploadtree_tablename = GetUploadtreeTableName($upload_pk); /* slim down to all rows with this hash and type, and filter */ $NumInstances = 0; $rows = $this->GetRequestedRows($rows, $hash, $type, $excl, $NumInstances, $filter); //debugprint($rows, "rows"); switch ($this->OutputType) { case "XML": break; case "HTML": // micro menus $OutBuf .= menu_to_1html(menu_find($this->Name, $MenuDepth), 0); $RowCount = count($rows); if ($RowCount) { $Content = htmlentities($rows[0]['content']); $Offset = $Page < 0 ? 0 : $Page * $Max; $PkgsOnly = false; $text = _("files"); $text1 = _("unique"); $text3 = _("copyright"); $text4 = _("email"); $text5 = _("url"); switch ($type) { case "statement": $TypeStr = "{$text3}"; break; case "email": $TypeStr = "{$text4}"; break; case "url": $TypeStr = "{$text5}"; break; } $OutBuf .= "{$NumInstances} {$TypeStr} instances found in {$RowCount} {$text}"; $OutBuf .= ": <b>{$Content}</b>"; $text = _("Display excludes files with these extensions"); if (!empty($excl)) { $OutBuf .= "<br>{$text}: {$excl}"; } /* Get the page menu */ if ($RowCount >= $Max && $Page >= 0) { $PagingMenu = "<P />\n" . MenuEndlessPage($Page, intval(($RowCount + $Offset) / $Max)) . "<P />\n"; $OutBuf .= $PagingMenu; } else { $PagingMenu = ""; } /* Offset is +1 to start numbering from 1 instead of zero */ $RowNum = $Offset; $LinkLast = "copyrightview&agent={$agent_pk}"; $ShowBox = 1; $ShowMicro = NULL; // base url $ucontent = rawurlencode($Content); $baseURL = "?mod=" . $this->Name . "&agent={$agent_pk}&item={$uploadtree_pk}&hash={$hash}&type={$type}&page=-1"; // display rows foreach ($rows as $row) { // Allow user to exclude files with this extension $FileExt = GetFileExt($row['ufile_name']); if (empty($excl)) { $URL = $baseURL . "&excl={$FileExt}"; } else { $URL = $baseURL . "&excl={$excl}:{$FileExt}"; } $text = _("Exclude this file type"); $Header = "<a href={$URL}>{$text}.</a>"; $ok = true; if ($excl) { $ExclArray = explode(":", $excl); if (in_array($FileExt, $ExclArray)) { $ok = false; } } if ($ok) { $OutBuf .= Dir2Browse("browse", $row['uploadtree_pk'], $LinkLast, $ShowBox, $ShowMicro, ++$RowNum, $Header, '', $uploadtree_tablename); } } } else { $OutBuf .= _("No files found"); } if (!empty($PagingMenu)) { $OutBuf .= $PagingMenu . "\n"; } $OutBuf .= "<hr>\n"; $Time = microtime(true) - $Time; $text = _("Elapsed time"); $text1 = _("seconds"); $OutBuf .= sprintf("<small>{$text}: %.2f {$text1}</small>\n", $Time); break; case "Text": break; default: break; } if (!$this->OutputToStdout) { return $OutBuf; } print $OutBuf; return; }
/** * Рекурсивно обходит каталог и возвращает массив с относительными именами файлов просматриваемого каталога. * @param String $folder Имя папки. * @param Boolean $use_subfolders Искать в подпапках * @param Boolean $use_mask Использовать маску поиска * @param String $mask Маска поиска. Вы можете указать расширения (с точкой) через запятую. * @param Boolean $newSearch Начать ли новый поиск (статическая переменная будет перезаписана) * @param String $parentf Не обращайте внимания. Нужна для работы функции. * @return Array Список найденных файлов */ function GetFiles($folder, $use_subfolders = false, $use_mask = false, $mask = '', $newSearch = true, $parentf = '') { static $sfiles = array(); if (!is_dir($folder)) { return array(); } if ($newSearch) { $sfiles = array(); AddLastSlash($folder); } $mask = strtolower($mask); if ($parentf == '') { $parentf = $folder; } $files = scandir($folder); foreach ($files as $file) { if (is_dir($folder . $file) && $file != '.' && $file != '..') { if ($use_subfolders) { GetFiles($folder . $file . '/', $use_subfolders, $use_mask, $mask, false, $parentf); } } elseif (is_file($folder . $file)) { $ext = GetFileExt($file); if (!$use_mask || stripos($mask, strtolower($ext)) !== false) { $rf = str_replace($parentf, '', $folder . $file); $sfiles[] = $rf; } } } return $sfiles; }
/** * \brief test of ExtensionGetter */ public function test_GetFileExt() { $this->assertEquals(GetFileExt('autodestroy.exe.bak'), 'bak'); }