当前位置: 首页>>代码示例>>PHP>>正文


PHP GetFileExt函数代码示例

本文整理汇总了PHP中GetFileExt函数的典型用法代码示例。如果您正苦于以下问题:PHP GetFileExt函数的具体用法?PHP GetFileExt怎么用?PHP GetFileExt使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GetFileExt函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: FormsCheckType

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;
}
开发者ID:agnyrussia,项目名称:linkorcms_mod_forms_file_support,代码行数:35,代码来源:forms.inc.php

示例2: IndexDownloadsGetFileType

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);
    }
}
开发者ID:agnyrussia,项目名称:linkorcms_mod_forms_file_support,代码行数:31,代码来源:index.php

示例3: basic_view

 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';
 }
开发者ID:archives-of-michigan,项目名称:Governing-Michigan-cdm,代码行数:26,代码来源:partial.php

示例4: IsFileExt

function IsFileExt($file, $ext)
{
    if (GetFileExt(strtolower($file)) == strtolower($ext)) {
        return true;
    } else {
        return false;
    }
}
开发者ID:m1has1k,项目名称:Okay,代码行数:8,代码来源:tools.php

示例5: CheckExtName

 function CheckExtName()
 {
     global $zbp;
     $e = GetFileExt($this->Name);
     if (HasNameInString($zbp->option['ZC_UPLOAD_FILETYPE'], $e)) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:jdjjdkdkdm,项目名称:zblogphp,代码行数:10,代码来源:upload.php

示例6: CheckExtName

 /**
  * @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);
 }
开发者ID:zblogcn,项目名称:zblogphp,代码行数:14,代码来源:upload.php

示例7: GetFiles

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];
}
开发者ID:dimadmb,项目名称:100shub,代码行数:55,代码来源:tools.php

示例8: Storage

/**
 * @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;
}
开发者ID:ijustyce,项目名称:zblogphp,代码行数:16,代码来源:include.php

示例9: GetThumb

/**
 * Генерирует миниатюру и кэширует её. Возвращает имя файла миниатюры.
 * @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;
}
开发者ID:agnyrussia,项目名称:linkorcms_mod_forms_file_support,代码行数:32,代码来源:images.php

示例10: build_page

 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;
开发者ID:laiello,项目名称:mystep-cms,代码行数:31,代码来源:art_content.php

示例11: SuggestionsPick

 /**
  * \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;
 }
开发者ID:pombredanne,项目名称:fossology-test,代码行数:42,代码来源:ui-picker.php

示例12: UnlinkUserAvatarFiles

/**
 * Удаляет все размеры аватара по его имени
 * @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);
        }
    }
}
开发者ID:agnyrussia,项目名称:linkorcms_mod_forms_file_support,代码行数:21,代码来源:system_build.php

示例13: GetDocumentRoot

     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"]);
开发者ID:m1has1k,项目名称:Okay,代码行数:31,代码来源:action.php

示例14: FuzzyName

/**
 * \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;
}
开发者ID:DanielDobre,项目名称:fossology,代码行数:27,代码来源:common-compare.php

示例15: showInfo

                }
            } 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'];
开发者ID:laiello,项目名称:mystep-cms,代码行数:31,代码来源:web_template.php


注:本文中的GetFileExt函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。