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


PHP get_filename_extension函数代码示例

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


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

示例1: getFileType

function getFileType($filename)
{
    // --------------
    // Checks the extension of a file to determine what should be done with it in the View and Edit functions
    // Default: TEXT
    // Exceptions (see list below): IMAGE, EXECUTABLE, OFFICE, ARCHIVE
    // --------------
    $last = get_filename_extension($filename);
    if ($last == "asp" || $last == "bas" || $last == "bat" || $last == "c" || $last == "cfg" || $last == "cfm" || $last == "cgi" || $last == "conf" || $last == "cpp" || $last == "css" || $last == "dhtml" || $last == "diz" || $last == "default" || $last == "file" || $last == "h" || $last == "hpp" || $last == "htaccess" || $last == "htpasswd" || $last == "htm" || $last == "html" || $last == "inc" || $last == "ini" || $last == "js" || $last == "jsp" || $last == "mak" || $last == "msg" || $last == "nfo" || $last == "old" || $last == "pas" || $last == "patch" || $last == "perl" || $last == "php" || $last == "php3" || $last == "phps" || $last == "phtml" || $last == "pinerc" || $last == "pl" || $last == "pm" || $last == "qmail" || $last == "readme" || $last == "setup" || $last == "sh" || $last == "shtml" || $last == "sql" || $last == "style" || $last == "tcl" || $last == "tex" || $last == "threads" || $last == "tmpl" || $last == "tpl" || $last == "txt" || $last == "ubb" || $last == "vbs" || $last == "xml" || $last == "conf" || strstr($last, "htm")) {
        return "TEXT";
    } elseif ($last == "png" || $last == "jpg" || $last == "jpeg" || $last == "gif" || $last == "bmp" || $last == "tif" || $last == "tiff") {
        return "IMAGE";
    } elseif ($last == "exe" || $last == "com") {
        return "EXECUTABLE";
    } elseif ($last == "doc" || $last == "rtf" || $last == "xls" || $last == "ppt" || $last == "mdb" || $last == "vsd" || $last == "mpp") {
        return "OFFICE";
    } elseif ($last == "zip" || $last == "tar" || $last == "gz" || $last == "tgz" || $last == "rar" || $last == "arj" || $last == "arc") {
        return "ARCHIVE";
    } else {
        return "OTHER";
    }
}
开发者ID:GTAWWEKID,项目名称:tsiserver.us,代码行数:22,代码来源:filesystem.inc.php

示例2: net2ftp_module_printBody

function net2ftp_module_printBody()
{
    // --------------
    // This function prints the login screen
    // --------------
    // -------------------------------------------------------------------------
    // Global variables
    // -------------------------------------------------------------------------
    global $net2ftp_settings, $net2ftp_globals, $net2ftp_messages, $net2ftp_result;
    // -------------------------------------------------------------------------
    // Variables
    // -------------------------------------------------------------------------
    $filename_extension = get_filename_extension($net2ftp_globals["entry"]);
    // ------------------------
    // Set the state2 variable depending on the file extension !!!!!
    // ------------------------
    if (getFileType($net2ftp_globals["entry"]) == "IMAGE") {
        $filetype = "image";
    } elseif ($filename_extension == "swf") {
        $filetype = "flash";
    } else {
        $filetype = "text";
    }
    // Form name, back and forward buttons
    $formname = "ViewForm";
    $back_onclick = "document.forms['" . $formname . "'].state.value='browse';document.forms['" . $formname . "'].state2.value='main';document.forms['" . $formname . "'].submit();";
    // Next screen
    $nextscreen = 2;
    // -------------------------------------------------------------------------
    // Text
    // -------------------------------------------------------------------------
    if ($filetype == "text") {
        // Title
        $title = __("View file %1\$s", $net2ftp_globals["entry"]);
        // ------------------------
        // geshi_text
        // ------------------------
        setStatus(2, 10, __("Reading the file"));
        $geshi_text = ftp_readfile("", $net2ftp_globals["directory"], $net2ftp_globals["entry"]);
        if ($net2ftp_result["success"] == false) {
            return false;
        }
        // ------------------------
        // geshi_language
        // ------------------------
        $geshi_language = "";
        $list_language_extensions = array('html4strict' => array('html', 'htm'), 'javascript' => array('js'), 'css' => array('css'), 'php' => array('php', 'php5', 'phtml', 'phps'), 'perl' => array('pl', 'pm', 'cgi'), 'sql' => array('sql'), 'java' => array('java'), 'actionscript' => array('as'), 'ada' => array('a', 'ada', 'adb', 'ads'), 'apache' => array('conf'), 'asm' => array('ash', 'asm'), 'asp' => array('asp'), 'bash' => array('sh'), 'c' => array('c', 'h'), 'c_mac' => array('c'), 'caddcl' => array(), 'cadlisp' => array(), 'cpp' => array('cpp'), 'csharp' => array(), 'd' => array(''), 'delphi' => array('dpk'), 'diff' => array(''), 'email' => array('eml', 'mbox'), 'lisp' => array('lisp'), 'lua' => array('lua'), 'matlab' => array(), 'mpasm' => array(), 'nsis' => array(), 'objc' => array(), 'oobas' => array(), 'oracle8' => array(), 'pascal' => array('pas'), 'python' => array('py'), 'qbasic' => array('bi'), 'smarty' => array('tpl'), 'vb' => array('bas'), 'vbnet' => array(), 'vhdl' => array(), 'visualfoxpro' => array(), 'xml' => array('xml'));
        while (list($language, $extensions) = each($list_language_extensions)) {
            if (in_array($filename_extension, $extensions)) {
                $geshi_language = $language;
                break;
            }
        }
        // ------------------------
        // geshi_path
        // ------------------------
        $geshi_path = NET2FTP_APPLICATION_ROOTDIR . "/plugins/geshi/geshi/";
        // ------------------------
        // Call geshi
        // ------------------------
        setStatus(4, 10, __("Parsing the file"));
        $geshi = new GeSHi($geshi_text, $geshi_language, $geshi_path);
        $geshi->set_encoding(__("iso-8859-1"));
        $geshi->set_header_type(GESHI_HEADER_PRE);
        $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 10);
        //		$geshi->enable_classes();
        $geshi->set_overall_style('border: 2px solid #d0d0d0; background-color: #f6f6f6; color: #000066; padding: 10px;', true);
        $geshi->set_link_styles(GESHI_LINK, 'color: #000060;');
        $geshi->set_link_styles(GESHI_HOVER, 'background-color: #f0f000;');
        $geshi->set_tab_width(4);
        $geshi_text = $geshi->parse_code();
    } elseif ($filetype == "image") {
        $title = __("View image %1\$s", htmlEncode2($net2ftp_globals["entry"]));
        $image_url = printPHP_SELF("view");
        $image_alt = __("Image") . $net2ftp_globals["entry"];
    } elseif ($filetype == "flash") {
        $title = __("View Macromedia ShockWave Flash movie %1\$s", htmlEncode2($net2ftp_globals["entry"]));
        $flash_url = printPHP_SELF("view");
    }
    // -------------------------------------------------------------------------
    // Print the output
    // -------------------------------------------------------------------------
    require_once $net2ftp_globals["application_skinsdir"] . "/" . $net2ftp_globals["skin"] . "/manage.template.php";
}
开发者ID:rohdoor,项目名称:Zpanel-net2ftp,代码行数:84,代码来源:view.inc.php

示例3: net2ftp_module_sendHttpHeaders

function net2ftp_module_sendHttpHeaders()
{
    // --------------
    // This function sends HTTP headers
    // --------------
    global $net2ftp_settings, $net2ftp_globals, $net2ftp_messages, $net2ftp_result, $net2ftp_output;
    // ------------------------------------
    // 1. Register the global variables
    // ------------------------------------
    if ($net2ftp_globals["screen"] == 2) {
        // Code for old file jupload applet (jupload version 0.86)
        //		$file_counter = 0;
        //		foreach($_FILES as $tagname=>$object) {
        //			if ($object['name'] != "") {
        //				$file_counter = $file_counter + 1;
        //				$uploadedFilesArray["$file_counter"]["name"]               = $object['name'];
        //				$uploadedFilesArray["$file_counter"]["tmp_name"]           = $object['tmp_name'];
        //				$uploadedFilesArray["$file_counter"]["size"]               = $object['size'];
        //				$uploadedFilesArray["$file_counter"]["error"]              = $object['error'];
        //				// Look for special encoded jupload files
        //				$contentType = $object['type'];
        //				if (substr($contentType,0,7) == "jupload") {
        //					$base64_encoded_path = substr($contentType,8);
        //					$base64_decoded_path = base64_decode($base64_encoded_path);
        //					$uploadedFilesArray["$file_counter"]["absolute_directory"] = $base64_decoded_path;
        //				} // end if
        //			} // end if
        //		} // end foreach
        // Code for new file jupload applet (jupload version 5.0.8)
        $file_counter = 0;
        foreach ($_FILES as $tagname => $object) {
            if ($object['name'] != "") {
                $file_counter = $file_counter + 1;
                $uploadedFilesArray["{$file_counter}"]["name"] = $object['name'];
                $uploadedFilesArray["{$file_counter}"]["type"] = $object['type'];
                $uploadedFilesArray["{$file_counter}"]["tmp_name"] = $object['tmp_name'];
                $uploadedFilesArray["{$file_counter}"]["error"] = $object['error'];
                $uploadedFilesArray["{$file_counter}"]["size"] = $object['size'];
                $uploadedFilesArray["{$file_counter}"]["mime"] = validateEntry($_POST["mimetype" . $file_counter]);
                $uploadedFilesArray["{$file_counter}"]["relative_directory"] = validateDirectory($_POST["relpathinfo" . $file_counter]);
                $uploadedFilesArray["{$file_counter}"]["mtime"] = validateEntry($_POST["filemodificationdate" . $file_counter]);
            }
            // end if
        }
        // end foreach
        echo "Please wait, the files are being transferred to the FTP server...<br />\n";
        flush();
        // ------------------------------------
        // 2. POST METHOD: Move files from the *webserver's* temporary directory to *net2ftp's*
        // temporary directory (move_uploaded_files).
        // ------------------------------------
        if ($_SERVER["REQUEST_METHOD"] == "POST" && sizeof($uploadedFilesArray) > 0) {
            $moved_counter = 0;
            for ($j = 1; $j <= sizeof($uploadedFilesArray); $j++) {
                $file_name = $uploadedFilesArray["{$j}"]["name"];
                $file_tmp_name = $uploadedFilesArray["{$j}"]["tmp_name"];
                $file_size = $uploadedFilesArray["{$j}"]["size"];
                $file_error = $uploadedFilesArray["{$j}"]["error"];
                $file_relative_directory = $uploadedFilesArray["{$j}"]["relative_directory"];
                if ($file_name != "" && $file_tmp_name == "" || $file_size > $net2ftp_settings["max_filesize"]) {
                    // The case ($file_name != "" && $file_tmp_name == "") occurs when the file is bigger than the directives set in php.ini
                    // In that case, only $uploadedFilesArray["$j"]["name"] is filled in.
                    echo "WARNING: File <b>{$file_name}</b> skipped: this file is too big.<br />\n";
                    @unlink($file_tmp_name);
                    continue;
                } elseif (checkAuthorizedName($file_name) == false || checkAuthorizedName($file_relative_directory) == false) {
                    echo "WARNING: File <b>{$file_relative_directory}</b> skipped: it contains a banned keyword.<br />\n";
                    $skipped = $skipped + 1;
                    @unlink($file_tmp_name);
                    continue;
                }
                // Create the temporary filename as follows: (from left to right)
                // - Use prefix "upload__", to be able to identify from where this temporary file comes from
                // - Create a random filename
                // - Add the original filename extension, to be able to identify the filetype
                // - Add suffix ".txt" to avoid that the file would be executed on the webserver
                $extension = get_filename_extension($file_name);
                if (substr($file_name, -6) == "tar.gz") {
                    $extension = "tar.gz";
                }
                $tempfilename = tempnam2($net2ftp_globals["application_tempdir"], "upload__", "." . $extension . ".txt");
                if ($tempfilename == false) {
                    // If you get this warning message, you've probably forgotten to chmod 777 the /temp directory
                    echo "WARNING: File <b>{$file_name}</b> skipped: unable to create a temporary file on the webserver.<br />\n";
                    @unlink($file_tmp_name);
                    continue;
                }
                // Move the uploaded file
                $move_uploaded_file_result = move_uploaded_file($uploadedFilesArray["{$j}"]["tmp_name"], $tempfilename);
                if ($move_uploaded_file_result == false) {
                    echo "WARNING: File <b>{$file_name}</b> skipped: unable to move the uploaded file to the webserver's temporary directory.<br />\n";
                    @unlink($file_tmp_name);
                    @unlink($tempfilename);
                    continue;
                } else {
                    $moved_counter = $moved_counter + 1;
                    $acceptedFilesArray["{$moved_counter}"] = $uploadedFilesArray["{$j}"];
                    // Copy all parameters for this file from the $uploadedFilesArray to the $acceptedFilesArray
                    $acceptedFilesArray["{$moved_counter}"]["tmp_name"] = $tempfilename;
                    // Overwrite the old temporary name by the new one
//.........这里部分代码省略.........
开发者ID:GTAWWEKID,项目名称:tsiserver.us,代码行数:101,代码来源:jupload.inc.php

示例4: printTextareaSelect

function printTextareaSelect($onchange)
{
    // --------------
    // This function prints a select with the available textareas
    // --------------
    // -------------------------------------------------------------------------
    // Global variables
    // -------------------------------------------------------------------------
    global $net2ftp_globals;
    $pluginProperties = getPluginProperties();
    if (isset($_POST["textareaType"]) == true) {
        $textareaType = validateTextareaType($_POST["textareaType"]);
    } else {
        $textareaType = "";
    }
    $filename_extension = get_filename_extension($net2ftp_globals["entry"]);
    // Convert *htm* to html
    if (strpos($filename_extension, "htm") !== false) {
        $filename_extension = "html";
    }
    echo "<select name=\"textareaSelect\" id=\"textareaSelect\" onchange=\"{$onchange}\">\n";
    if ($textareaType == "" || $textareaType == "plain") {
        $plainselected = "selected=\"selected\"";
    }
    echo "<option value=\"plain\" {$plainselected}>Normal textarea</option>\n";
    while (list($pluginName, $value) = each($pluginProperties)) {
        // Print only the plugins which have 'use' set to yes
        //                        which are textareas
        //                        which are suitable for this browser
        //                        which are suitable for this type of file
        if ($pluginProperties[$pluginName]["use"] == "yes" && $pluginProperties[$pluginName]["type"] == "textarea" && in_array($net2ftp_globals["browser_agent"], $pluginProperties[$pluginName]["browsers"]) == true && in_array($filename_extension, $pluginProperties[$pluginName]["filename_extensions"]) == true) {
            if ($pluginName == $textareaType) {
                $selected = "selected=\"selected\"";
            } else {
                $selected = "";
            }
            echo "<option value=\"{$pluginName}\" {$selected}>" . $pluginProperties[$pluginName]["label"] . "</option>\n";
        }
        // end if
    }
    // end while
    echo "</select>\n";
}
开发者ID:rohdoor,项目名称:Zpanel-net2ftp,代码行数:43,代码来源:edit.inc.php

示例5: ftpAsciiBinary

function ftpAsciiBinary($filename)
{
    // --------------
    // Checks the first character of a file and its extension to see if it should be
    // transferred in ASCII or Binary mode
    // --------------
    $firstcharacter = substr($filename, 0, 1);
    if ($firstcharacter == ".") {
        $ftpmode = FTP_ASCII;
        return $ftpmode;
    }
    $last = get_filename_extension($filename);
    if ($last == "1st" || $last == "asp" || $last == "bas" || $last == "bat" || $last == "c" || $last == "cfg" || $last == "cfm" || $last == "cgi" || $last == "conf" || $last == "cpp" || $last == "css" || $last == "csv" || $last == "dhtml" || $last == "diz" || $last == "default" || $last == "file" || $last == "h" || $last == "hpp" || $last == "htaccess" || $last == "htpasswd" || $last == "htm" || $last == "html" || $last == "inc" || $last == "ini" || $last == "js" || $last == "jsp" || $last == "log" || $last == "m3u" || $last == "mak" || $last == "msg" || $last == "nfo" || $last == "old" || $last == "pas" || $last == "patch" || $last == "perl" || $last == "php" || $last == "php3" || $last == "phps" || $last == "phtml" || $last == "pinerc" || $last == "pl" || $last == "pm" || $last == "qmail" || $last == "readme" || $last == "setup" || $last == "seq" || $last == "sh" || $last == "sql" || $last == "style" || $last == "tcl" || $last == "tex" || $last == "threads" || $last == "tmpl" || $last == "tpl" || $last == "txt" || $last == "ubb" || $last == "vbs" || $last == "xml" || strstr($last, "htm")) {
        $ftpmode = FTP_ASCII;
    } else {
        $ftpmode = FTP_BINARY;
    }
    return $ftpmode;
}
开发者ID:fedeB-IT-dept,项目名称:fedeB_website,代码行数:19,代码来源:net2ftp_installer.php

示例6: net2ftp_module_printBody

function net2ftp_module_printBody()
{
    // --------------
    // This function prints the login screen
    // --------------
    // -------------------------------------------------------------------------
    // Global variables
    // -------------------------------------------------------------------------
    global $net2ftp_settings, $net2ftp_globals, $net2ftp_messages, $net2ftp_result;
    // -------------------------------------------------------------------------
    // Variables
    // -------------------------------------------------------------------------
    $filename_extension = get_filename_extension($net2ftp_globals["entry"]);
    // ------------------------
    // Set the state2 variable depending on the file extension !!!!!
    // ------------------------
    if (getFileType($net2ftp_globals["entry"]) == "IMAGE") {
        $filetype = "image";
    } elseif ($filename_extension == "swf") {
        $filetype = "flash";
    } else {
        $filetype = "text";
    }
    // Form name, back and forward buttons
    $formname = "ViewForm";
    $back_onclick = "document.forms['" . $formname . "'].state.value='browse';document.forms['" . $formname . "'].state2.value='main';document.forms['" . $formname . "'].submit();";
    // Next screen
    $nextscreen = 2;
    // -------------------------------------------------------------------------
    // Text
    // -------------------------------------------------------------------------
    if ($filetype == "text") {
        // Title
        $title = __("View file %1\$s", $net2ftp_globals["entry"]);
        // ------------------------
        // luminous_text
        // ------------------------
        setStatus(2, 10, __("Reading the file"));
        $luminous_text = ftp_readfile("", $net2ftp_globals["directory"], $net2ftp_globals["entry"]);
        if ($net2ftp_result["success"] == false) {
            return false;
        }
        // ------------------------
        // luminous_language
        // ------------------------
        $luminous_language = "";
        $list_language_extensions = array('html' => array('html', 'htm'), 'javascript' => array('js'), 'css' => array('css'), 'php' => array('php', 'php5', 'phtml', 'phps'), 'perl' => array('pl', 'pm', 'cgi'), 'sql' => array('sql'), 'java' => array('java'), 'ada' => array('a', 'ada', 'adb', 'ads'), 'as' => array('as'), 'asp' => array('asp'), 'cpp' => array('cpp'), 'csharp' => array('csharp'), 'diff' => array('diff'), 'go' => array('go'), 'latex' => array('latex'), 'matlab' => array('matlab'), 'python' => array('py'), 'rails' => array('rails'), 'ruby' => array('ruby'), 'sql' => array('sql'), 'vb' => array('bas'), 'vim' => array('vim'), 'xml' => array('xml'));
        while (list($language, $extensions) = each($list_language_extensions)) {
            if (in_array($filename_extension, $extensions)) {
                $luminous_language = $language;
                break;
            }
        }
        // ------------------------
        // Call luminous
        // ------------------------
        setStatus(4, 10, __("Parsing the file"));
        $luminous_text = luminous::highlight($luminous_language, $luminous_text, FALSE);
    } elseif ($filetype == "image") {
        $title = __("View image %1\$s", htmlEncode2($net2ftp_globals["entry"]));
        $image_url = printPHP_SELF("view");
        $image_alt = __("Image") . $net2ftp_globals["entry"];
    } elseif ($filetype == "flash") {
        $title = __("View Macromedia ShockWave Flash movie %1\$s", htmlEncode2($net2ftp_globals["entry"]));
        $flash_url = printPHP_SELF("view");
    }
    // -------------------------------------------------------------------------
    // Print the output
    // -------------------------------------------------------------------------
    require_once $net2ftp_globals["application_skinsdir"] . "/" . $net2ftp_globals["skin"] . "/manage.template.php";
}
开发者ID:GTAWWEKID,项目名称:tsiserver.us,代码行数:71,代码来源:view.inc.php

示例7: getMime

function getMime($listline)
{
    // --------------
    // Checks the extension of a file to determine which is the type of the file and the icon
    // --------------
    // -------------------------------------------------------------------------
    // Global variables and settings
    // -------------------------------------------------------------------------
    global $net2ftp_globals, $net2ftp_settings;
    $skinArray = getSkinArray();
    if ($listline["dirorfile"] == "d") {
        $last = "directory";
    } elseif ($listline["dirorfile"] == "l") {
        $last = "symlink";
    } else {
        $last = get_filename_extension($listline["dirfilename"]);
    }
    // -------------------------------------------------------------------------
    // Icon names
    // -------------------------------------------------------------------------
    if ($last == "directory") {
        $icon = "folder";
        $type = __("Directory");
    } elseif ($last == "symlink") {
        $icon = "folder_grey";
        $type = __("Symlink");
    } elseif ($last == "asp") {
        $icon = "";
        $type = __("ASP script");
    } elseif ($last == "css") {
        $icon = "stylesheet";
        $type = __("Cascading Style Sheet");
    } elseif ($last == "htm" || $last == "html") {
        $icon = "html";
        $type = __("HTML file");
    } elseif ($last == "java") {
        $icon = "source_java";
        $type = __("Java source file");
    } elseif ($last == "js") {
        $icon = "";
        $type = __("JavaScript file");
    } elseif ($last == "phps") {
        $icon = "php";
        $type = __("PHP Source");
    } elseif (substr($last, 0, 3) == "php") {
        $icon = "php";
        $type = __("PHP script");
    } elseif ($last == "txt") {
        $icon = "document";
        $type = __("Text file");
    } elseif ($last == "bmp") {
        $icon = "colors";
        $type = __("Bitmap file");
    } elseif ($last == "gif") {
        $icon = "colors";
        $type = __("GIF file");
    } elseif ($last == "jpg" || $last == "jpeg") {
        $icon = "colors";
        $type = __("JPEG file");
    } elseif ($last == "png") {
        $icon = "colors";
        $type = __("PNG file");
    } elseif ($last == "tif" || $last == "tiff") {
        $icon = "colors";
        $type = __("TIF file");
    } elseif ($last == "xcf") {
        $icon = "gimp";
        $type = __("GIMP file");
    } elseif ($last == "exe" || $last == "com") {
        $icon = "exec";
        $type = __("Executable");
    } elseif ($last == "sh") {
        $icon = "terminal";
        $type = __("Shell script");
    } elseif ($last == "doc") {
        $icon = "";
        $type = __("MS Office - Word document");
    } elseif ($last == "xls") {
        $icon = "";
        $type = __("MS Office - Excel spreadsheet");
    } elseif ($last == "ppt") {
        $icon = "";
        $type = __("MS Office - PowerPoint presentation");
    } elseif ($last == "mdb") {
        $icon = "";
        $type = __("MS Office - Access database");
    } elseif ($last == "vsd") {
        $icon = "";
        $type = __("MS Office - Visio drawing");
    } elseif ($last == "mpp") {
        $icon = "";
        $type = __("MS Office - Project file");
    } elseif ($last == "sxw") {
        $icon = "openoffice";
        $type = __("OpenOffice - Writer 6.0 document");
    } elseif ($last == "stw") {
        $icon = "openoffice";
        $type = __("OpenOffice - Writer 6.0 template");
    } elseif ($last == "sxc") {
        $icon = "openoffice";
//.........这里部分代码省略.........
开发者ID:Jmainguy,项目名称:multicraft_install,代码行数:101,代码来源:skins.inc.php

示例8: extract_file

 function extract_file($filename, $extractto)
 {
     $ext = get_filename_extension($filename);
     $mydir = getcwd();
     chdir($extractto);
     $ret = True;
     if ($ext == 'gz') {
         if (strpos($filename, '.tar.gz') === False) {
             passthru2("gunzip {$filename}");
         } else {
             passthru2("tar -zvxf {$filename}");
         }
     } elseif ($ext == 'tgz') {
         passthru2("tar -zxvf {$filename}");
     } elseif ($ext == 'bz2') {
         if (strpos($filename, '.tar.bz2') === False) {
             passthru2("bunzip2 {$filename}");
         } else {
             passthru2("tar -jvxf {$filename}");
         }
     } elseif ($ext == 'zip') {
         passthru2("unzip {$filename}");
     } elseif ($ext == 'rar') {
         passthru2("unrar x {$filename}");
     } else {
         print "Unsupported extension/Desteklenmeyen dosya uzantisi, extract yapılmadı... : {$ext} ";
         $ret = False;
     }
     chdir($mydir);
     return $ret;
 }
开发者ID:jprice,项目名称:EHCP,代码行数:31,代码来源:classapp.php


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