Пример #1
0
function ftp_zip($conn_id, $directory, $list, $zipactions, $zipdir, $divelevel)
{
    // --------------
    // This function allows to download/save/email a zipfile which contains the selected directories and files
    // --------------
    // -------------------------------------------------------------------------
    // Global variables
    // -------------------------------------------------------------------------
    global $net2ftp_globals, $net2ftp_settings, $net2ftp_result, $net2ftp_output;
    // -------------------------------------------------------------------------
    // Initialization
    // -------------------------------------------------------------------------
    if ($divelevel == 0) {
        // Create the zipfile
        $net2ftp_globals["zipfile"] = new zipfile();
        $timenow = time();
        $zipdir = "";
        // Open the connection
        $conn_id = ftp_openconnection();
        if ($net2ftp_result["success"] == false) {
            return false;
        }
    }
    // -------------------------------------------------------------------------
    // For all directories...
    // -------------------------------------------------------------------------
    for ($i = 1; $i <= $list["stats"]["directories"]["total_number"]; $i = $i + 1) {
        $newdir = glueDirectories($directory, $list["directories"][$i]["dirfilename"]);
        $newzipdir = glueDirectories($zipdir, $list["directories"][$i]["dirfilename"]);
        $newdivelevel = $divelevel + 1;
        // Check if the directory contains a banned keyword
        if ($list["directories"][$i]["selectable"] == "banned_keyword") {
            continue;
        }
        // Get a new list
        $newlist = ftp_getlist($conn_id, $newdir);
        if ($net2ftp_result["success"] == false) {
            return false;
        }
        ftp_zip($conn_id, $newdir, $newlist, $zipactions, $newzipdir, $newdivelevel);
        if ($net2ftp_result["success"] == false) {
            setErrorVars(true, "", "", "", "");
            continue;
        }
        if ($divelevel == 0 && ($zipactions["save"] == "yes" || $zipactions["email"] == "yes")) {
            $total = $list["stats"]["directories"]["total_number"] + $list["stats"]["files"]["total_number"];
            setStatus($i, $total, __("Processing the entries"));
        }
    }
    // end for directories
    // -------------------------------------------------------------------------
    // For all files...
    // -------------------------------------------------------------------------
    for ($i = 1; $i <= $list["stats"]["files"]["total_number"]; $i = $i + 1) {
        if ($list["files"][$i]["selectable"] != "ok") {
            continue;
        }
        $text = ftp_readfile($conn_id, $directory, $list["files"][$i]["dirfilename"]);
        if ($net2ftp_result["success"] == false) {
            setErrorVars(true, "", "", "", "");
            continue;
        }
        $filename = stripDirectory(glueDirectories($zipdir, $list["files"][$i]["dirfilename"]));
        $net2ftp_globals["zipfile"]->addFile($text, $filename);
        if ($divelevel == 0 && ($zipactions["save"] == "yes" || $zipactions["email"] == "yes")) {
            $total = $list["stats"]["directories"]["total_number"] + $list["stats"]["files"]["total_number"];
            setStatus($list["stats"]["directories"]["total_number"] + $i - 1, $total, __("Processing the entries"));
        }
    }
    // end for files
    // -------------------------------------------------------------------------
    // End
    // -------------------------------------------------------------------------
    if ($divelevel == 0) {
        // ------------------------
        // Send the zipfile to the browser
        // ------------------------
        if ($zipactions["download"] == "yes") {
            $timenow = time();
            $filenameToSend = "net2ftp-" . $timenow . ".zip";
            $filesizeToSend = strlen($net2ftp_globals["zipfile"]->file());
            sendDownloadHeaders($filenameToSend, $filesizeToSend);
            echo $net2ftp_globals["zipfile"]->file();
            flush();
        }
        // ------------------------
        // Save the zipfile string to a file
        // ------------------------
        if ($zipactions["save"] == "yes" || $zipactions["email"] == "yes") {
            $string = $net2ftp_globals["zipfile"]->file();
            $tempfilename = tempnam($net2ftp_globals["application_tempdir"], "zip__");
            if ($tempfilename == false) {
                @unlink($tempfilename);
                $errormessage = __("Unable to create the temporary file. Check the permissions of the %1\$s directory.", $net2ftp_globals["application_tempdir"]);
                setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__);
                return false;
            }
            registerTempfile("register", $tempfilename);
            local_writefile($tempfilename, $string);
            if ($net2ftp_result["success"] == false) {
                return false;
            }
        }
        // ------------------------
        // Save the zip file to the FTP server
        // ------------------------
        if ($zipactions["save"] == "yes") {
            ftp_putfile($conn_id, "", $tempfilename, $directory, $zipactions["save_filename"], FTP_BINARY, "copy");
            if ($net2ftp_result["success"] == false) {
                @unlink($tempfilename);
                //				$errormessage = __("Unable to put the file <b>%1\$s</b> on the FTP server.<br />You may not have write permissions on the directory.", $zipactions["save_filename"]);
                //				setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__);
                return false;
            } else {
                $net2ftp_output["ftp_zip"][] = __("The zip file has been saved on the FTP server as <b>%1\$s</b>", $zipactions["save_filename"]) . "<br /><br />\n";
            }
        }
        // ------------------------
        // Close the connection
        // ------------------------
        ftp_closeconnection($conn_id);
        // ------------------------
        // Email
        // ------------------------
        if ($zipactions["email"] == "yes") {
            $FromName = "net2ftp";
            $From = $net2ftp_settings["email_feedback"];
            $ToName = "";
            $To = $zipactions["email_to"];
            $Subject = __("Requested files");
            // Email message
            $Text = __("Dear,") . "\n\n";
            $Text .= __("Someone has requested the files in attachment to be sent to this email account (%1\$s).", $To) . "\n";
            $Text .= __("If you know nothing about this or if you don't trust that person, please delete this email without opening the Zip file in attachment.") . "\n";
            $Text .= __("Note that if you don't open the Zip file, the files inside cannot harm your computer.") . "\n";
            $Text .= "\n\n---------------------------------------\n";
            $Text .= __("Information about the sender: ") . "\n";
            $Text .= __("IP address: ") . $REMOTE_ADDR . "\n";
            $Text .= __("Time of sending: ") . mytime() . "\n";
            $Text .= __("Sent via the net2ftp application installed on this website: ") . $HTTP_REFERER . "\n";
            $Text .= __("Webmaster's email: ") . $From . "\n";
            $Text .= "\n\n---------------------------------------\n";
            $Text .= __("Message of the sender: ") . "\n";
            $Text .= $zipactions["message"] . "\n";
            $Text .= "\n\n---------------------------------------\n";
            $Text .= __("net2ftp is free software, released under the GNU/GPL license. For more information, go to http://www.net2ftp.com.") . "\n\n\n";
            $AttmFiles = array($tempfilename);
            SendMail($From, $FromName, $To, $ToName, $Subject, $Text, $Html, $AttmFiles);
            if ($net2ftp_result["success"] == false) {
                @unlink($tempfilename);
                return false;
            }
            $net2ftp_output["ftp_zip"][] = __("The zip file has been sent to <b>%1\$s</b>.", $To) . "<br /><br />";
        }
        // ------------------------
        // Delete the temporary zipfile
        // ------------------------
        if ($zipactions["save"] == "yes" || $zipactions["email"] == "yes") {
            $success4 = @unlink($tempfilename);
            if ($success4 == false) {
                $errormessage = __("Unable to delete the temporary file");
                setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__);
                return false;
            }
            registerTempfile("unregister", $tempfilename);
        }
        // Set the variable to NULL to save memory
        $net2ftp_globals["zipfile"] = NULL;
    }
    // end if $divelevel == 0
}
Пример #2
0
function net2ftp_module_printBody()
{
    // --------------
    // This function prints the edit screen
    // For screen == 1, the file is read from the FTP server
    // For screen == 2, the textarea is changed, the file is not read from the FTP server but comes from the HTML form
    // For screen == 3, the file is saved to the FTP server
    // --------------
    // -------------------------------------------------------------------------
    // Global variables
    // -------------------------------------------------------------------------
    global $net2ftp_settings, $net2ftp_globals, $net2ftp_messages, $net2ftp_result;
    if (isset($_POST["textareaType"]) == true) {
        $textareaType = validateTextareaType($_POST["textareaType"]);
    } else {
        $textareaType = "";
    }
    if (isset($_POST["text"]) == true) {
        $text = $_POST["text"];
    } else {
        $text = "";
    }
    if (isset($_POST["text_splitted"]) == true) {
        $text_splitted = $_POST["text_splitted"];
    } else {
        $text_splitted = "";
    }
    if (isset($_POST["encodingSelect"]) == true) {
        $encodingSelect = $_POST["encodingSelect"];
    } else {
        $encodingSelect = "";
    }
    if (isset($_POST["breakSelect"]) == true) {
        $breakSelect = $_POST["breakSelect"];
    } else {
        $breakSelect = "";
    }
    $text_encoding_selected = "";
    $line_break_selected = "";
    // -------------------------------------------------------------------------
    // Variables for all screens
    // -------------------------------------------------------------------------
    // Form name, back and forward buttons
    $formname = "EditForm";
    $back_onclick = "document.forms['" . $formname . "'].state.value='browse';document.forms['" . $formname . "'].state2.value='main';document.forms['" . $formname . "'].submit();";
    // Directory + file name
    $dirfilename = htmlEncode2(glueDirectories($net2ftp_globals["directory"], $net2ftp_globals["entry"]));
    // TextareaSelect onchange
    $onchange = "document.forms['EditForm'].screen.value=2;document.forms['EditForm'].textareaType.value=document.forms['EditForm'].textareaSelect.options[document.forms['EditForm'].textareaSelect.selectedIndex].value;document.forms['EditForm'].submit();";
    // Character encoding (requires multibyte string module to be installed)
    // With this, you can save a text with specified encoding and line break sequence
    // http://www.net2ftp.org/forums/viewtopic.php?id=2449
    if (($net2ftp_globals["language"] == "ja" || $net2ftp_globals["language"] == "tc" || $net2ftp_messages["iso-8859-1"] == "UTF-8") && function_exists("mb_detect_encoding") == true) {
        // $textarea_encodings is an array which contains the possible character encodings
        $textarea_encodings = getTextareaEncodingsArray();
        // $textarea_breaks is an array which contains the possible line breaks
        $textarea_breaks[] = "CRLF";
        $textarea_breaks[] = "CR";
        $textarea_breaks[] = "LF";
        // $text_encoding_old is the original encoding which is detected when the file is first read
        // $text_encoding_new is the requested encoding from the drop-down box
        // Default = encoding used for the page, which is defined by the language file in /languages/xx.inc.php
        // HTML uses BIG5, PHP uses BIG-5 (Traditional Chinese)
        // If the HTML encoding is not foreseen in the PHP function, set it to the default ISO-8859-1
        // $text_encoding is changed further on too
        if ($encodingSelect != "" && in_array($encodingSelect, $textarea_encodings)) {
            $text_encoding_new = $encodingSelect;
        } else {
            $text_encoding_new = "";
        }
        // $line_break_old is the original line break which is detected when the file is first read
        // $line_break is the requested line break from the drop-down box
        if ($breakSelect != "" && in_array($breakSelect, $textarea_breaks) == true) {
            $line_break_new = $breakSelect;
        } else {
            $line_break_new = "LF";
        }
    }
    // Programming language (for CodePress syntax highlighting)
    if ($textareaType == "codepress") {
        $filename_extension = get_filename_extension($net2ftp_globals["entry"]);
        if ($filename_extension == "asp") {
            $codepress_programming_language = "asp";
        } elseif ($filename_extension == "css") {
            $codepress_programming_language = "css";
        } elseif ($filename_extension == "cgi") {
            $codepress_programming_language = "perl";
        } elseif ($filename_extension == "htm") {
            $codepress_programming_language = "html";
        } elseif ($filename_extension == "html") {
            $codepress_programming_language = "html";
        } elseif ($filename_extension == "java") {
            $codepress_programming_language = "java";
        } elseif ($filename_extension == "js") {
            $codepress_programming_language = "javascript";
        } elseif ($filename_extension == "javascript") {
            $codepress_programming_language = "javascript";
        } elseif ($filename_extension == "pl") {
            $codepress_programming_language = "perl";
        } elseif ($filename_extension == "perl") {
            $codepress_programming_language = "perl";
        } elseif ($filename_extension == "php") {
            $codepress_programming_language = "php";
        } elseif ($filename_extension == "phps") {
            $codepress_programming_language = "php";
        } elseif ($filename_extension == "phtml") {
            $codepress_programming_language = "php";
        } elseif ($filename_extension == "ruby") {
            $codepress_programming_language = "ruby";
        } elseif ($filename_extension == "sql") {
            $codepress_programming_language = "sql";
        } elseif ($filename_extension == "txt") {
            $codepress_programming_language = "text";
        } else {
            $codepress_programming_language = "generic";
        }
        $codepress_onclick = "text.toggleEditor();";
    } else {
        $codepress_programming_language = "";
        $codepress_onclick = "";
    }
    // -------------------------------------------------------------------------
    // Variables for screen 1
    // Read the remote file (edit), or read the local template (new file)
    // -------------------------------------------------------------------------
    if ($net2ftp_globals["screen"] == 1) {
        // Template file
        $templatefile = $net2ftp_globals["application_rootdir"] . "/modules/edit/template.txt";
        // Edit: read the file from the FTP server
        if ($net2ftp_globals["state2"] == "") {
            $text = ftp_readfile("", $net2ftp_globals["directory"], $net2ftp_globals["entry"]);
            if ($net2ftp_result["success"] == false) {
                return false;
            }
            // Character encoding (requires multibyte string module to be installed)
            // Detect the original encoding of the text, and change the encoding of the text to the encoding of the page
            if (($net2ftp_globals["language"] == "ja" || $net2ftp_globals["language"] == "tc" || $net2ftp_messages["iso-8859-1"] == "UTF-8") && function_exists("mb_detect_encoding") == true) {
                // Detect original encoding
                $text_encoding_old = mb_detect_encoding($text, $textarea_encodings);
                $text_encoding_selected = $text_encoding_old;
                // If original encoding is detected and different from the page encoding, convert the text to the page encoding
                if ($text_encoding_old != "" && strcasecmp($text_encoding_old, $net2ftp_messages["iso-8859-1"]) != 0) {
                    $text = mb_convert_encoding($text, $net2ftp_messages["iso-8859-1"], $text_encoding_old);
                }
                // Detect original line break
                if (strpos($text, "\r\n") !== false) {
                    $line_break_old = "CRLF";
                } elseif (strpos($text, "\n") !== false) {
                    $line_break_old = "LF";
                } elseif (strpos($text, "\r") !== false) {
                    $line_break_old = "CR";
                } else {
                    $line_break_old = "LF";
                }
                $line_break_selected = $line_break_old;
            }
        } elseif ($net2ftp_globals["state2"] == "newfile") {
            $handle = fopen($templatefile, "r");
            // Open the local template file for reading only
            if ($handle == false) {
                $errormessage = __("Unable to open the template file");
                setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__);
                return false;
            }
            clearstatcache();
            // for filesize
            $text = trim(fread($handle, filesize($templatefile)));
            if ($text == false) {
                $errormessage = __("Unable to read the template file");
                setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__);
                return false;
            }
            @fclose($handle);
        }
        // Save status
        $savestatus = __("Status: This file has not yet been saved");
        $savestatus_short = __("Not yet saved");
    } elseif ($net2ftp_globals["screen"] == 2) {
        // For HTML WYSIWYG editors, split the HTML
        if (($textareaType == "tinymce" || $textareaType == "ckeditor") && $text_splitted == "") {
            $text_splitted = splitHtml($text, $textareaType);
        } elseif (($textareaType == "plain" || $textareaType == "codepress") && $text == "" && isset($text_splitted["top"]) == true) {
            $text = $text_splitted["top"];
            $text .= $text_splitted["middle"];
            $text .= $text_splitted["bottom"];
        }
        // Save status
        $savestatus = __("Status: This file has not yet been saved");
        $savestatus_short = __("Not yet saved");
    } elseif ($net2ftp_globals["screen"] == 3) {
        // Check if a filename is specified
        if (strlen($net2ftp_globals["entry"]) < 1) {
            $errormessage = __("Please specify a filename");
            setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__);
            return false;
        }
        // For HTML WYSIWYG editors, join the HTML
        if ($textareaType == "tinymce" || $textareaType == "ckeditor") {
            $text = $text_splitted["top"];
            $text .= $text_splitted["middle"];
            $text .= $text_splitted["bottom"];
        }
        // $text_file contains the text which is written to the FTP server
        // It is equal to the text shown on screen, except if a different character encoding is chosen
        $text_file = $text;
        // Character encoding (requires multibyte string module to be installed)
        // Change the encoding of the text from the original or page encoding to the selected encoding
        if (($net2ftp_globals["language"] == "ja" || $net2ftp_globals["language"] == "tc" || $net2ftp_messages["iso-8859-1"] == "UTF-8") && function_exists("mb_detect_encoding") == true) {
            $break_map = array("CRLF" => "\r\n", "CR" => "\r", "LF" => "\n");
            if (isset($break_map[$line_break_new]) == true) {
                $text_file = preg_replace('/(\\r\\n)|\\r|\\n/', $break_map[$line_break_new], $text_file);
            }
            if ($text_encoding_new != "" && strcasecmp($text_encoding_new, $net2ftp_messages["iso-8859-1"]) != 0) {
                $text_file = mb_convert_encoding($text_file, $text_encoding_new, $net2ftp_messages["iso-8859-1"]);
            }
            $text_encoding_selected = $text_encoding_new;
            $line_break_selected = $line_break_new;
        }
        // Write the string to the FTP server
        // Note: this function also replaces CarriageReturn+LineFeed by LineFeed
        ftp_writefile("", $net2ftp_globals["directory"], $net2ftp_globals["entry"], $text_file);
        if ($net2ftp_result["success"] == false) {
            setErrorVars(true, "", "", "", "");
            // Continue anyway and print warning message
            $savestatus = __("Status: <b>This file could not be saved</b>");
            $savestatus_short = __("Could not be saved");
        } else {
            $mytime = mytime();
            $mytime_short = mytime_short();
            $ftpmode = ftpAsciiBinary($net2ftp_globals["entry"]);
            if ($ftpmode == FTP_ASCII) {
                $printftpmode = "FTP_ASCII";
            } elseif ($ftpmode == FTP_BINARY) {
                $printftpmode = "FTP_BINARY";
            }
            $savestatus = __("Status: Saved on <b>%1\$s</b> using mode %2\$s", $mytime, $printftpmode);
            $savestatus_short = __("Saved at %1\$s", $mytime_short);
        }
    }
    // -------------------------------------------------------------------------
    // Convert special characters to HTML entities
    // -------------------------------------------------------------------------
    // Plain textarea
    if ($textareaType == "" || $textareaType == "plain") {
        $text = htmlspecialchars($text, ENT_QUOTES);
    } elseif ($textareaType == "ckeditor") {
        $text_splitted["top"] = htmlspecialchars($text_splitted["top"], ENT_QUOTES);
        $text_splitted["bottom"] = htmlspecialchars($text_splitted["bottom"], ENT_QUOTES);
        // Do not encode the middle part, this is done by CKEditor itself
        //		$text_splitted["middle"] = htmlspecialchars($text_splitted["middle"], ENT_QUOTES);
    } elseif ($textareaType == "tinymce") {
        $text_splitted["top"] = htmlspecialchars($text_splitted["top"], ENT_QUOTES);
        $text_splitted["middle"] = htmlspecialchars($text_splitted["middle"], ENT_QUOTES);
        $text_splitted["bottom"] = htmlspecialchars($text_splitted["bottom"], ENT_QUOTES);
    } elseif ($textareaType == "codepress") {
        $text = htmlspecialchars($text, ENT_QUOTES);
    }
    // -------------------------------------------------------------------------
    // Print the output
    // -------------------------------------------------------------------------
    require_once $net2ftp_globals["application_skinsdir"] . "/" . $net2ftp_globals["skin"] . "/edit.template.php";
}
Пример #3
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";
}
Пример #4
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";
}