function net2ftp_module_printBody() { // -------------- // This function prints the login screen // -------------- // ------------------------------------------------------------------------- // Global variables // ------------------------------------------------------------------------- global $net2ftp_settings, $net2ftp_globals, $net2ftp_messages, $net2ftp_result, $net2ftp_output; // The 2 go_to_state variables come from the bookmark, or from registerglobals.inc.php if (isset($_GET["go_to_state"]) == true) { $go_to_state = validateGenericInput($_GET["go_to_state"]); } else { $go_to_state = $net2ftp_globals["go_to_state"]; } if (isset($_GET["go_to_state2"]) == true) { $go_to_state2 = validateGenericInput($_GET["go_to_state2"]); } else { $go_to_state2 = $net2ftp_globals["go_to_state2"]; } if (isset($_GET["errormessage"]) == true) { $errormessage = validateGenericInput($_GET["errormessage"]); } // Most actions if (isset($_POST["list"]) == true) { $list = getSelectedEntries($_POST["list"]); } else { $list = ""; } // Bookmark if (isset($_POST["url"]) == true) { $url = validateGenericInput($_POST["url"]); } else { $url = ""; } if (isset($_POST["text"]) == true) { $text = validateGenericInput($_POST["text"]); } else { $text = ""; } // Copy, move, delete if (isset($_POST["ftpserver2"]) == true) { $net2ftp_globals["ftpserver2"] = validateFtpserver($_POST["ftpserver2"]); } else { $net2ftp_globals["ftpserver2"] = ""; } if (isset($_POST["ftpserverport2"]) == true) { $net2ftp_globals["ftpserverport2"] = validateFtpserverport($_POST["ftpserverport2"]); } else { $net2ftp_globals["ftpserverport2"] = ""; } if (isset($_POST["username2"]) == true) { $net2ftp_globals["username2"] = validateUsername($_POST["username2"]); } else { $net2ftp_globals["username2"] = ""; } if (isset($_POST["password2"]) == true) { $net2ftp_globals["password2"] = validatePassword($_POST["password2"]); } else { $net2ftp_globals["password2"] = ""; } // Edit 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 = ""; } // Find string if (isset($_POST["searchoptions"]) == true) { $searchoptions = $_POST["searchoptions"]; } // New directory // Rename if (isset($_POST["newNames"]) == true) { $newNames = validateEntry($_POST["newNames"]); } else { $newNames = ""; } // Raw FTP command if (isset($_POST["command"]) == true) { $command = $_POST["command"]; } else { $command = "CWD {$directory_html}\nPWD\n"; } // Zip if (isset($_POST["zipactions"]) == true) { $zipactions = $_POST["zipactions"]; } else { $zipactions = ""; } // ------------------------------------------------------------------------- // Variables for all screens // ------------------------------------------------------------------------- $formname = "LoginForm"; $enctype = ""; if ($net2ftp_globals["state2"] == "admin") { $message = __("Please enter your Administrator username and password."); $button_text = __("Login"); $username_fieldname = "input_admin_username"; $password_fieldname = "input_admin_password"; $username_value = ""; $password_value = ""; $focus = $username_fieldname; } elseif ($net2ftp_globals["state2"] == "bookmark") { $message = __("Please enter your username and password for FTP server <b>%1\$s</b>.", htmlEncode2($net2ftp_globals["ftpserver"])); $button_text = __("Login"); $username_fieldname = "username"; $password_fieldname = "password"; if (isset($net2ftp_globals["username"]) == true) { $username_value = htmlEncode2($net2ftp_globals["username"]); $focus = $password_fieldname; } else { $username_value = ""; $focus = $username_fieldname; } $password_value = ""; } elseif ($net2ftp_globals["state2"] == "session_expired") { $message = __("Your session has expired; please enter your password for FTP server <b>%1\$s</b> to continue.", htmlEncode2($net2ftp_globals["ftpserver"])); $button_text = __("Continue"); $username_fieldname = "username"; $password_fieldname = "password"; if (isset($net2ftp_globals["username"]) == true) { $username_value = htmlEncode2($net2ftp_globals["username"]); $focus = $password_fieldname; } else { $username_value = ""; $focus = $username_fieldname; } $password_value = ""; } elseif ($net2ftp_globals["state2"] == "session_ipchange") { $message = __("Your IP address has changed; please enter your password for FTP server <b>%1\$s</b> to continue.", htmlEncode2($net2ftp_globals["ftpserver"])); $button_text = __("Continue"); $username_fieldname = "username"; $password_fieldname = "password"; if (isset($net2ftp_globals["username"]) == true) { $username_value = htmlEncode2($net2ftp_globals["username"]); $focus = $password_fieldname; } else { $username_value = ""; $focus = $username_fieldname; } $password_value = ""; } // ------------------------------------------------------------------------- // Print the output // ------------------------------------------------------------------------- require_once $net2ftp_globals["application_skinsdir"] . "/" . $net2ftp_globals["skin"] . "/login_small.template.php"; }
function net2ftp_module_printBody() { // -------------- // This function prints the copy/move/delete screen // -------------- // ------------------------------------------------------------------------- // Global variables // ------------------------------------------------------------------------- global $net2ftp_settings, $net2ftp_globals, $net2ftp_messages, $net2ftp_result, $net2ftp_output; if (isset($_POST["list"]) == true) { $list = getSelectedEntries($_POST["list"]); } else { $list = ""; } if (isset($_POST["ftpserver2"]) == true) { $net2ftp_globals["ftpserver2"] = validateFtpserver($_POST["ftpserver2"]); } else { $net2ftp_globals["ftpserver2"] = ""; } if (isset($_POST["ftpserverport2"]) == true) { $net2ftp_globals["ftpserverport2"] = validateFtpserverport($_POST["ftpserverport2"]); } else { $net2ftp_globals["ftpserverport2"] = ""; } if (isset($_POST["username2"]) == true) { $net2ftp_globals["username2"] = validateUsername($_POST["username2"]); } else { $net2ftp_globals["username2"] = ""; } if (isset($_POST["password2"]) == true) { $net2ftp_globals["password2"] = validatePassword($_POST["password2"]); } else { $net2ftp_globals["password2"] = ""; } // ------------------------------------------------------------------------- // Variables for all screens // ------------------------------------------------------------------------- // Title if ($net2ftp_globals["state2"] == "copy") { $title = __("Copy directories and files"); } elseif ($net2ftp_globals["state2"] == "move") { $title = __("Move directories and files"); } elseif ($net2ftp_globals["state2"] == "delete") { $title = __("Delete directories and files"); } // Form name, back and forward buttons $formname = "CopyMoveDeleteForm"; $back_onclick = "document.forms['" . $formname . "'].state.value='browse';document.forms['" . $formname . "'].state2.value='main';document.forms['" . $formname . "'].submit();"; $forward_onclick = "document.forms['" . $formname . "'].submit();"; // ------------------------------------------------------------------------- // Variables for screen 1 // ------------------------------------------------------------------------- if ($net2ftp_globals["screen"] == 1) { // Next screen $nextscreen = 2; } elseif ($net2ftp_globals["screen"] == 2) { // --------------------------------------- // Open connection to the source server // --------------------------------------- setStatus(2, 10, __("Connecting to the FTP server")); $conn_id_source = ftp_openconnection(); if ($net2ftp_result["success"] == false) { return false; } // --------------------------------------- // Open connection to the target server, if it is different from the source server, or if the username // is different (different users may have different authorizations on the same FTP server) // --------------------------------------- if (($net2ftp_globals["ftpserver2"] != "" || $net2ftp_globals["username2"] != "") && ($net2ftp_globals["ftpserver2"] != $net2ftp_globals["ftpserver"] || $net2ftp_globals["username2"] != $net2ftp_globals["username"])) { $conn_id_target = ftp_openconnection2(); // Note: ftp_openconnection2 cleans the input values if ($net2ftp_result["success"] == false) { return false; } } else { $conn_id_target = $conn_id_source; } // --------------------------------------- // Copy, move or delete the files and directories // --------------------------------------- ftp_copymovedelete($conn_id_source, $conn_id_target, $list, $net2ftp_globals["state2"], 0); // --------------------------------------- // Close the connection to the source server // --------------------------------------- ftp_closeconnection($conn_id_source); // --------------------------------------- // Close the connection to the target server, if it is different from the source server // --------------------------------------- if ($conn_id_source != $conn_id_target) { ftp_closeconnection($conn_id_target); } } // end elseif // ------------------------------------------------------------------------- // Print the output // ------------------------------------------------------------------------- require_once $net2ftp_globals["application_skinsdir"] . "/" . $net2ftp_globals["skin"] . "/manage.template.php"; }
// if the password is blank // ------------------------------------------------------------------------- if ($net2ftp_globals["state"] != "login" && $net2ftp_globals["state"] != "login_small" && $_SESSION["net2ftp_session_id_old"] != $_SESSION["net2ftp_session_id_new"]) { $net2ftp_globals["go_to_state"] = $net2ftp_globals["state"]; $net2ftp_globals["go_to_state2"] = $net2ftp_globals["state2"]; $net2ftp_globals["state"] = "login_small"; $net2ftp_globals["state2"] = "session_expired"; } elseif (substr($net2ftp_globals["state"], 0, 5) != "admin" && $net2ftp_globals["state"] != "clearcookies" && $net2ftp_globals["state"] != "login" && $net2ftp_globals["state"] != "login_small" && $net2ftp_globals["state"] != "logout" && $_SESSION["net2ftp_password_encrypted_" . $net2ftp_globals["ftpserver"] . $net2ftp_globals["username"]] == "") { $net2ftp_globals["state"] = "login"; $net2ftp_globals["state2"] = ""; } // ------------------------------------------------------------------------- // 6 COOKIE variabes // ------------------------------------------------------------------------- if (isset($_COOKIE["net2ftpcookie_ftpserver"]) == true) { $net2ftp_globals["cookie_ftpserver"] = validateFtpserver($_COOKIE["net2ftpcookie_ftpserver"]); } else { $net2ftp_globals["cookie_ftpserver"] = ""; } if (isset($_COOKIE["net2ftpcookie_ftpserverport"]) == true) { $net2ftp_globals["cookie_ftpserverport"] = validateFtpserverport($_COOKIE["net2ftpcookie_ftpserverport"]); } else { $net2ftp_globals["cookie_ftpserverport"] = ""; } if (isset($_COOKIE["net2ftpcookie_username"]) == true) { $net2ftp_globals["cookie_username"] = validateUsername($_COOKIE["net2ftpcookie_username"]); } else { $net2ftp_globals["cookie_username"] = ""; } if (isset($_COOKIE["net2ftpcookie_language"]) == true) { $net2ftp_globals["cookie_language"] = validateLanguage($_COOKIE["net2ftpcookie_language"]);
function net2ftp_module_printBody() { // -------------- // This function prints the login screen // -------------- // ------------------------------------------------------------------------- // Global variables // ------------------------------------------------------------------------- global $net2ftp_settings, $net2ftp_globals, $net2ftp_messages, $net2ftp_result, $net2ftp_output; if (isset($_POST["troubleshoot_ftpserver"]) == true) { $troubleshoot_ftpserver = validateFtpserver($_POST["troubleshoot_ftpserver"]); } else { $troubleshoot_ftpserver = ""; } if (isset($_POST["troubleshoot_ftpserverport"]) == true) { $troubleshoot_ftpserverport = validateFtpserverport($_POST["troubleshoot_ftpserverport"]); } else { $troubleshoot_ftpserverport = ""; } if (isset($_POST["troubleshoot_username"]) == true) { $troubleshoot_username = validateUsername($_POST["troubleshoot_username"]); } else { $troubleshoot_username = ""; } if (isset($_POST["troubleshoot_password"]) == true) { $troubleshoot_password = validatePassword($_POST["troubleshoot_password"]); } else { $troubleshoot_password = ""; } if (isset($_POST["troubleshoot_directory"]) == true) { $troubleshoot_directory = validateDirectory($_POST["troubleshoot_directory"]); } else { $troubleshoot_directory = ""; } if (isset($_POST["troubleshoot_passivemode"]) == true) { $troubleshoot_passivemode = validatePassivemode($_POST["troubleshoot_passivemode"]); } else { $troubleshoot_passivemode = ""; } $troubleshoot_ftpserver_html = htmlEncode2($troubleshoot_ftpserver); $troubleshoot_ftpserverport_html = htmlEncode2($troubleshoot_ftpserverport); $troubleshoot_username_html = htmlEncode2($troubleshoot_username); $troubleshoot_directory_html = htmlEncode2($troubleshoot_directory); $troubleshoot_passivemode_html = htmlEncode2($troubleshoot_passivemode); // ------------------------------------------------------------------------- // Variables for all screens // ------------------------------------------------------------------------- // Title $title = __("Troubleshoot an FTP server"); // Form name $formname = "AdvancedForm"; // ------------------------------------------------------------------------- // Variables for screen 1 // ------------------------------------------------------------------------- if ($net2ftp_globals["screen"] == 1) { // Next screen $nextscreen = 2; // Back and forward buttons $back_onclick = "document.forms['" . $formname . "'].state.value='advanced';document.forms['" . $formname . "'].screen.value='1';document.forms['" . $formname . "'].submit();"; $forward_onclick = "document.forms['" . $formname . "'].submit();"; } elseif ($net2ftp_globals["screen"] == 2) { // Back and forward buttons $back_onclick = "document.forms['" . $formname . "'].state.value='advanced_ftpserver'; document.forms['" . $formname . "'].submit();"; // Initial checks if ($troubleshoot_passivemode != "yes") { $troubleshoot_passivemode = "no"; } // Connect setStatus(1, 10, __("Connecting to the FTP server")); $conn_id = ftp_connect("{$troubleshoot_ftpserver}", $troubleshoot_ftpserverport); // Login with username and password setStatus(2, 10, __("Logging into the FTP server")); $ftp_login_result = ftp_login($conn_id, $troubleshoot_username, $troubleshoot_password); // Passive mode if ($troubleshoot_passivemode == "yes") { setStatus(3, 10, __("Setting the passive mode")); $ftp_pasv_result = ftp_pasv($conn_id, TRUE); } else { $ftp_pasv_result = true; } // Get the FTP system type setStatus(4, 10, __("Getting the FTP system type")); $ftp_systype_result = ftp_systype($conn_id); // Change the directory setStatus(5, 10, __("Changing the directory")); $ftp_chdir_result = ftp_chdir($conn_id, $troubleshoot_directory); // Get the current directory from the FTP server setStatus(6, 10, __("Getting the current directory")); $ftp_pwd_result = ftp_pwd($conn_id); // Try to get a raw list setStatus(7, 10, __("Getting the list of directories and files")); $ftp_rawlist_result = ftp_rawlist($conn_id, "-a"); if (sizeof($ftp_rawlist_result) <= 1) { $ftp_rawlist_result = ftp_rawlist($conn_id, ""); } // Parse the list setStatus(8, 10, __("Parsing the list of directories and files")); for ($i = 0; $i < sizeof($ftp_rawlist_result); $i++) { $parsedlist[$i] = ftp_scanline($troubleshoot_directory, $ftp_rawlist_result[$i]); } // end for // Quiting; ftp_quit doesn't return a value setStatus(9, 10, __("Logging out of the FTP server")); ftp_quit($conn_id); } // end if // ------------------------------------------------------------------------- // Print the output // ------------------------------------------------------------------------- setStatus(10, 10, __("Printing the result")); require_once $net2ftp_globals["application_skinsdir"] . "/" . $net2ftp_globals["skin"] . "/manage.template.php"; }