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";
    }
}
Example #2
0
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";
}
Example #3
0
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
                }
            }
            // end for j
            flush();
        }
        // end if elseif
        // ------------------------------------
        // 3. Move the files from net2ftp's temporary directory to the FTP server.
        // ------------------------------------
        if (sizeof($acceptedFilesArray) == 0 && sizeof($uploadedFilesArray) != 0) {
            echo "WARNING: No files were accepted (see messages above), so nothing will be transferred to the FTP server.<br />\n";
        } elseif (sizeof($acceptedFilesArray) > 0) {
            // ------------------------------
            // 3.1 Open connection
            // ------------------------------
            // Open connection
            echo __("Connecting to the FTP server") . "<br />\n";
            $conn_id = ftp_openconnection();
            if ($net2ftp_result["success"] == false) {
                echo "ERROR: " . $net2ftp_result["errormessage"] . "<br />\n";
                return false;
            }
            // ------------------------------
            // For loop (loop over all the files)
            // ------------------------------
            for ($k = 1; $k <= sizeof($acceptedFilesArray); $k++) {
                $file_name = $acceptedFilesArray["{$k}"]["name"];
                $file_tmp_name = $acceptedFilesArray["{$k}"]["tmp_name"];
                $file_size = $acceptedFilesArray["{$k}"]["size"];
                $file_error = $acceptedFilesArray["{$k}"]["error"];
                $file_relative_directory = $acceptedFilesArray["{$k}"]["relative_directory"];
                $ftpmode = ftpAsciiBinary($file_name);
                if ($ftpmode == FTP_ASCII) {
                    $printftpmode = "FTP_ASCII";
                } elseif ($ftpmode == FTP_BINARY) {
                    $printftpmode = "FTP_BINARY";
                }
                // ------------------------------
                // 3.2 Within the for loop: create the subdirectory if needed
                // ------------------------------
                // Replace Windows-style backslashes \ by Unix-style slashes /
                $file_relative_directory = str_replace("\\", "/", trim($file_relative_directory));
                // Get the names of the subdirectories by splitting the string using slashes /
                $file_subdirectories = explode("/", $file_relative_directory);
                // $targetdirectory contains the successive directories to be created
                $targetdirectory = $net2ftp_globals["directory"];
                // Loop over sizeof()-1 because the last part is the filename itself:
                for ($m = 0; $m < sizeof($file_subdirectories) - 1; $m++) {
                    // Create the targetdirectory string
                    $targetdirectory = glueDirectories($targetdirectory, $file_subdirectories[$m]);
                    // Check if the subdirectories exist
                    if ($targetdirectory != "") {
                        $result = @ftp_chdir($conn_id, $targetdirectory);
                        if ($result == false) {
                            $ftp_mkdir_result = ftp_mkdir($conn_id, $targetdirectory);
                            if ($ftp_mkdir_result == false) {
                                echo "WARNING: Unable to create the directory <b>{$targetdirectory}</b>. The script will try to continue...<br />\n";
                                continue;
                            }
                            echo "Directory {$targetdirectory} created.<br />\n";
                        }
                        // end if
                        flush();
                    }
                    // end if
                }
                // end for m
                // Store the $targetdirectory in the $acceptedFilesArray
                if ($targetdirectory != "" && $targetdirectory != "/") {
                    $acceptedFilesArray["{$k}"]["targetdirectory"] = $targetdirectory;
                }
                // ------------------------------
                // 3.3 Within the for loop: put local file to remote file
                // ------------------------------
                ftp_putfile($conn_id, "", $acceptedFilesArray["{$k}"]["tmp_name"], $acceptedFilesArray["{$k}"]["targetdirectory"], $acceptedFilesArray["{$k}"]["name"], $ftpmode, "move");
                if ($net2ftp_result["success"] == false) {
                    echo "ERROR: File <b>{$file_name}</b> skipped. Message: " . $net2ftp_result["errormessage"] . "<br />\n";
                    setErrorVars(true, "", "", "", "");
                    continue;
                } else {
                    echo "The file <b>{$file_name}</b> was transferred to the FTP server successfully. <br />\n";
                }
                flush();
            }
            // End for k
            // Note: the java applet is looking for the word "SUCCESS" to determine if the upload result is OK or not (see applet parameter stringUploadSuccess)
            // The applet doesn't seem to recognize the words "SUCCESS", "WARNING" or "ERROR" when they are issued by the code above
            echo "SUCCESS";
            // ------------------------------
            // 3.4 Close connection
            // ------------------------------
            ftp_quit($conn_id);
        }
        // end if
    }
    // end if $screen == 2
}
Example #4
0
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";
}
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;
}
Example #6
0
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";
}
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";
        $type = __("OpenOffice - Calc 6.0 spreadsheet");
    } elseif ($last == "stc") {
        $icon = "openoffice";
        $type = __("OpenOffice - Calc 6.0 template");
    } elseif ($last == "sxd") {
        $icon = "openoffice";
        $type = __("OpenOffice - Draw 6.0 document");
    } elseif ($last == "std") {
        $icon = "openoffice";
        $type = __("OpenOffice - Draw 6.0 template");
    } elseif ($last == "sxi") {
        $icon = "openoffice";
        $type = __("OpenOffice - Impress 6.0 presentation");
    } elseif ($last == "sti") {
        $icon = "openoffice";
        $type = __("OpenOffice - Impress 6.0 template");
    } elseif ($last == "sxg") {
        $icon = "openoffice";
        $type = __("OpenOffice - Writer 6.0 global document");
    } elseif ($last == "sxm") {
        $icon = "openoffice";
        $type = __("OpenOffice - Math 6.0 document");
    } elseif ($last == "sdw") {
        $icon = "openoffice";
        $type = __("StarOffice - StarWriter 5.x document");
    } elseif ($last == "sgl") {
        $icon = "openoffice";
        $type = __("StarOffice - StarWriter 5.x global document");
    } elseif ($last == "sdc") {
        $icon = "openoffice";
        $type = __("StarOffice - StarCalc 5.x spreadsheet");
    } elseif ($last == "sda") {
        $icon = "openoffice";
        $type = __("StarOffice - StarDraw 5.x document");
    } elseif ($last == "sdd") {
        $icon = "openoffice";
        $type = __("StarOffice - StarImpress 5.x presentation");
    } elseif ($last == "sdp") {
        $icon = "openoffice";
        $type = __("StarOffice - StarImpress Packed 5.x file");
    } elseif ($last == "smf") {
        $icon = "openoffice";
        $type = __("StarOffice - StarMath 5.x document");
    } elseif ($last == "sds") {
        $icon = "openoffice";
        $type = __("StarOffice - StarChart 5.x document");
    } elseif ($last == "sdm") {
        $icon = "openoffice";
        $type = __("StarOffice - StarMail 5.x mail file");
    } elseif ($last == "pdf") {
        $icon = "acroread";
        $type = __("Adobe Acrobat document");
    } elseif ($last == "arc") {
        $icon = "tgz";
        $type = __("ARC archive");
    } elseif ($last == "arj") {
        $icon = "tgz";
        $type = __("ARJ archive");
    } elseif ($last == "rpm") {
        $icon = "rpm";
        $type = __("RPM");
    } elseif ($last == "gz") {
        $icon = "tgz";
        $type = __("GZ archive");
    } elseif ($last == "tar") {
        $icon = "tar";
        $type = __("TAR archive");
    } elseif ($last == "zip") {
        $icon = "tgz";
        $type = __("Zip archive");
    } elseif ($last == "mov") {
        $icon = "video";
        $type = __("MOV movie file");
    } elseif ($last == "mpg" || $last == "mpeg") {
        $icon = "video";
        $type = __("MPEG movie file");
    } elseif ($last == "rm" || $last == "ram") {
        $icon = "realplayer";
        $type = __("Real movie file");
    } elseif ($last == "qt") {
        $icon = "quicktime";
        $type = __("Quicktime movie file");
    } elseif ($last == "fla") {
        $icon = "";
        $type = __("Shockwave flash file");
    } elseif ($last == "swf") {
        $icon = "";
        $type = __("Shockwave file");
    } elseif ($last == "wav") {
        $icon = "sound";
        $type = __("WAV sound file");
    } elseif ($last == "ttf") {
        $icon = "fonts";
        $type = __("Font file");
    } elseif ($last) {
        $icon = "mime";
        $type = Yii::t('mc', "{file} File", array('{file}' => strtoupper($last)));
    } else {
        $icon = "mime";
        $type = __("File");
    }
    if ($icon == "") {
        $icon = "mime";
    }
    if ($type == "") {
        $type = __("File");
    }
    // -------------------------------------------------------------------------
    // Return mime icon and mime type
    // -------------------------------------------------------------------------
    // OpenLaszlo skin doesn't need HTML tags
    if ($net2ftp_globals["skin"] == "openlaszlo") {
        $mime["mime_icon"] = $icon . "_icon";
    } elseif ($net2ftp_settings["fix_png"] == "yes" && $net2ftp_globals["browser_agent"] == "IE" && $net2ftp_globals["browser_platform"] == "Win" && ($net2ftp_globals["browser_version"] == "5.5" || $net2ftp_globals["browser_version"] == "6.0" || $net2ftp_globals["browser_version"] == "7.0")) {
        $icon .= ".png";
        $icon_directory = $net2ftp_globals["application_rootdir_url"] . "/net2ftp/img/mime";
        $mime["mime_icon"] = "<img src=\"{$icon_directory}/spacer.gif\" alt=\"icon\" style=\"width: " . $skinArray[$net2ftp_globals["skin"]]["icon_size_mime"] . "px; height: " . $skinArray[$net2ftp_globals["skin"]]["icon_size_mime"] . "px; border: 0px; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='{$icon_directory}/{$icon}', sizingMethod='scale')\" />\n";
    } else {
        $icon .= ".png";
        $icon_directory = $net2ftp_globals["application_rootdir_url"] . "/net2ftp/img/mime";
        $mime["mime_icon"] = "<img src=\"{$icon_directory}/{$icon}\"      alt=\"icon\" style=\"width: " . $skinArray[$net2ftp_globals["skin"]]["icon_size_mime"] . "px; height: " . $skinArray[$net2ftp_globals["skin"]]["icon_size_mime"] . "px; border: 0px;\" />\n";
    }
    $mime["mime_type"] = $type;
    return $mime;
}
Example #8
0
 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;
 }