示例#1
0
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";
}
示例#2
0
function getSelectedEntries($list)
{
    // --------------
    // Input = array where dirfilename is set if the entry was selected, not set if not selected:
    //   [1] => Array ( [dirfilename] => dir1 [dirorfile] => d [size] => 0 [selectable] => ok      [permissions] => ---rw-rw- )   <-- selected
    //   [2] => Array ( [dirfilename] => dir2 [dirorfile] => d [size] => 0 [selectable] => ok      [permissions] => ---rw-rw- )   <-- selected
    //   [3] => Array ( [dirfilename] => dir3 [dirorfile] => d [size] => 0 [selectable] => too_big [permissions] => ---rw-rw- )   <-- selected
    //   [4] => Array (                       [dirorfile] => d [size] => 0 [selectable] => ok      [permissions] => ---rw-rw- )   <-- not selected
    //
    // Output = array with only the selected entries, which are not TOO BIG or which do not contain a forbidden keyword
    //   [1] => Array ( [dirfilename] => dir1 [dirorfile] => d [size] => 0 [permissions] => ---rw-rw- )
    //   [2] => Array ( [dirfilename] => dir2 [dirorfile] => d [size] => 0 [permissions] => ---rw-rw- )
    // --------------
    // Global variables
    global $net2ftp_globals;
    $newlist = array();
    $newlist["directories"] = array();
    $newlist["files"] = array();
    $newlist["symlinks"] = array();
    $newlist["unrecognized"] = array();
    $directory_index = 1;
    $file_index = 1;
    $symlink_index = 1;
    $unrecognized_index = 1;
    $all_index = 1;
    for ($i = 1; $i <= sizeof($list); $i = $i + 1) {
        if (isset($list[$i]["dirorfile"]) == true && isset($list[$i]["dirfilename"]) == true) {
            if (isset($list[$i]["selectable"]) == false || $list[$i]["selectable"] != "ok" && ($net2ftp_globals["state"] == "downloadfile" || $net2ftp_globals["state"] == "downloadzip" || $net2ftp_globals["state"] == "edit" || $net2ftp_globals["state"] == "findstring" || $net2ftp_globals["state"] == "unzip" || $net2ftp_globals["state"] == "view" || $net2ftp_globals["state"] == "zip" || $net2ftp_globals["state2"] == "copy" || $net2ftp_globals["state2"] == "move")) {
                continue;
            }
            $list[$i]["dirfilename"] = validateGenericInput($list[$i]["dirfilename"]);
            $list[$i]["dirfilename_html"] = htmlEncode2($list[$i]["dirfilename"]);
            $list[$i]["dirfilename_js"] = javascriptEncode2($list[$i]["dirfilename"]);
            if ($list[$i]["dirorfile"] == "d") {
                $newlist["directories"][$directory_index] = $list[$i];
                $directory_index++;
                $newlist["all"][$all_index] = $list[$i];
                $all_index++;
            } elseif ($list[$i]["dirorfile"] == "-") {
                $newlist["files"][$file_index] = $list[$i];
                $file_index++;
                $newlist["all"][$all_index] = $list[$i];
                $all_index++;
            } elseif ($list[$i]["dirorfile"] == "l") {
                $newlist["symlinks"][$symlink_index] = $list[$i];
                $symlink_index++;
                $newlist["all"][$all_index] = $list[$i];
                $all_index++;
            } elseif ($list[$i]["dirorfile"] == "u") {
                $newlist["unrecognized"][$unrecognized_index] = $list[$i];
                $unrecognized_index++;
                $newlist["all"][$all_index] = $list[$i];
                $all_index++;
            }
        }
    }
    // end for
    // Store the statistics
    $newlist["stats"]["directories"]["total_number"] = $directory_index - 1;
    $newlist["stats"]["files"]["total_number"] = $file_index - 1;
    $newlist["stats"]["symlinks"]["total_number"] = $symlink_index - 1;
    $newlist["stats"]["unrecognized"]["total_number"] = $unrecognized_index - 1;
    return $newlist;
}
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["url"]) == true) {
        // Do not urlEncode2() this variable, it's already encoded in printPHP_SELF()
        $url = $_POST["url"];
    } else {
        $url = "";
    }
    if (isset($_POST["text"]) == true) {
        $text = validateGenericInput($_POST["text"]);
    } else {
        $text = "";
    }
    // -------------------------------------------------------------------------
    // Variables
    // -------------------------------------------------------------------------
    if ($net2ftp_globals["screen"] == 1) {
        // Title
        $title = __("Bookmark");
        // Form name, back and forward buttons
        $formname = "BookmarkForm";
        $back_onclick = "document.forms['" . $formname . "'].state.value='browse';document.forms['" . $formname . "'].state2.value='main';document.forms['" . $formname . "'].submit();";
    }
    // end if
    // -------------------------------------------------------------------------
    // 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 browse screen ($state2=="main") or the directory popup screen ($state2=="popup")
    // For the browse screen ($state2=="main"), 2 template files are called
    // --------------
    // -------------------------------------------------------------------------
    // Global variables
    // -------------------------------------------------------------------------
    global $net2ftp_settings, $net2ftp_globals, $net2ftp_messages, $net2ftp_result;
    // -------------------------------------------------------------------------
    // Check if the directory name contains \' and if it does, print an error message
    // Note: these directories cannot be browsed, but can be deleted
    // -------------------------------------------------------------------------
    //	if (strstr($directory, "\'") != false) {
    //		$errormessage = __("Directories with names containing \' cannot be displayed correctly. They can only be deleted. Please go back and select another subdirectory.");
    //		setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__);
    //		return false;
    //	}
    // -------------------------------------------------------------------------
    // Variables
    // With status update if $state2=="main"
    // -------------------------------------------------------------------------
    // ------------------------------------
    // Open connection
    // ------------------------------------
    if ($net2ftp_globals["state2"] == "main") {
        setStatus(2, 10, __("Connecting to the FTP server"));
    }
    $conn_id = ftp_openconnection();
    if ($net2ftp_result["success"] == false) {
        return false;
    }
    // ------------------------------------
    // Get raw list of directories and files; parse the raw list and return a nice list
    // This function may change the current $directory; a warning message is returned in that case
    // ------------------------------------
    if ($net2ftp_globals["state2"] == "main") {
        setStatus(4, 10, __("Getting the list of directories and files"));
    }
    $list = ftp_getlist($conn_id, $net2ftp_globals["directory"]);
    if ($net2ftp_result["success"] == false) {
        return false;
    }
    // ------------------------------------
    // Close connection
    // ------------------------------------
    ftp_closeconnection($conn_id);
    // ------------------------------------
    // Sort the list
    // ------------------------------------
    $list_directories = sort_list($list["directories"]);
    $list_files = sort_list($list["files"]);
    $list_symlinks = sort_list($list["symlinks"]);
    $list_unrecognized = sort_list($list["unrecognized"]);
    $warning_directory = $list["stats"]["warnings"];
    $directory = $list["stats"]["newdirectory"];
    $directory_html = htmlEncode2($directory);
    $directory_url = urlEncode2($directory);
    $directory_js = javascriptEncode2($directory);
    $updirectory = upDir($directory);
    $updirectory_html = htmlEncode2($updirectory);
    $updirectory_url = urlEncode2($updirectory);
    $updirectory_js = javascriptEncode2($updirectory);
    // ------------------------------------
    // Calculate the list of HTTP URLs
    // ------------------------------------
    if ($net2ftp_globals["state2"] == "main") {
        $list_links_js = ftp2http($net2ftp_globals["directory"], $list_files, "no");
        $list_links_url = ftp2http($net2ftp_globals["directory"], $list_files, "yes");
    }
    // ------------------------------------
    // Consumption message
    // ------------------------------------
    $warning_consumption = "";
    if (checkConsumption() == false) {
        $warning_consumption .= "<b>" . __("Daily limit reached: you will not be able to transfer data") . "</b><br /><br />\n";
        $warning_consumption .= __("In order to guarantee the fair use of the web server for everyone, the data transfer volume and script execution time are limited per user, and per day. Once this limit is reached, you can still browse the FTP server but not transfer data to/from it.") . "<br /><br />\n";
        $warning_consumption .= __("If you need unlimited usage, please install net2ftp on your own web server.") . "<br />\n";
    }
    // ------------------------------------
    // Browse message
    // ------------------------------------
    if ($net2ftp_settings["message_browse"] != "" && $net2ftp_settings["message_browse"] != "Setting message_browse does not exist") {
        $warning_message = $net2ftp_settings["message_browse"];
    }
    // ------------------------------------
    // Directory tree
    // ------------------------------------
    $directory_exploded = explode("/", stripDirectory($directory));
    if ($directory != "/" && checkAuthorizedDirectory("/") == true) {
        $directory_tree = "<a href=\"javascript:submitBrowseForm('/','','browse','main');\">root</a> ";
    } else {
        $directory_tree = "root ";
    }
    $directory_goto = "";
    for ($i = 0; $i < sizeof($directory_exploded) - 1; $i++) {
        $directory_goto = glueDirectories($directory_goto, $directory_exploded[$i]);
        $directory_goto_url = urlEncode2($directory_goto);
        if (checkAuthorizedDirectory($directory_goto) == true) {
            $directory_tree .= "/<a href=\"javascript:submitBrowseForm('" . $directory_goto_url . "','','browse','main');\">" . htmlEncode2($directory_exploded[$i]) . "</a> ";
        } else {
            $directory_tree .= "/" . $directory_exploded[$i] . " ";
        }
    }
    $directory_tree .= "/" . $directory_exploded[sizeof($directory_exploded) - 1];
    // ------------------------------------
    // Language
    // ------------------------------------
    $language_onchange = "document.BrowseForm.language.value=document.forms['BrowseForm'].language2.options[document.forms['BrowseForm'].language2.selectedIndex].value; submitBrowseForm('{$directory_js}', '', 'browse', 'main');";
    // ------------------------------------
    // Skin
    // ------------------------------------
    $skin_onchange = "document.BrowseForm.skin.value=document.forms['BrowseForm'].skin2.options[document.forms['BrowseForm'].skin2.selectedIndex].value; submitBrowseForm('{$directory_js}', '', 'browse', 'main');";
    // ------------------------------------
    // $rowcounter counts the total nr of rows
    // ------------------------------------
    $rowcounter = 0;
    // ------------------------------------
    // Column spans
    // ------------------------------------
    $action_colspan = 1;
    if ($net2ftp_settings["functionuse_view"] == "yes") {
        $action_colspan++;
    }
    if ($net2ftp_settings["functionuse_edit"] == "yes") {
        $action_colspan++;
    }
    if ($net2ftp_settings["functionuse_update"] == "yes") {
        $action_colspan++;
    }
    // Total nr of columns
    $total_colspan = $action_colspan + 9;
    // ------------------------------------
    // Name, Type, Size, ...
    // Determine the sort criteria and direction (ascending/descending)
    // ------------------------------------
    $sortArray["dirfilename"]["text"] = __("Name");
    $sortArray["type"]["text"] = __("Type");
    $sortArray["size"]["text"] = __("Size");
    $sortArray["owner"]["text"] = __("Owner");
    $sortArray["group"]["text"] = __("Group");
    $sortArray["permissions"]["text"] = __("Perms");
    $sortArray["mtime"]["text"] = __("Mod Time");
    $icon_directory = $net2ftp_globals["application_rootdir_url"] . "/skins/" . $net2ftp_globals["skin"] . "/images/mime";
    // Loop over all the sort possibilities
    while (list($key, $value) = each($sortArray)) {
        // The list is sorted by the current $key
        // Print the icon representing the current sortorder
        // Print the link to sort using the other sortorder
        if ($net2ftp_globals["sort"] == $key) {
            // Ascending
            if ($net2ftp_globals["sortorder"] == "ascending") {
                $sortArray[$key]["title"] = __("Click to sort by %1\$s in descending order", $value["text"]);
                $sortArray[$key]["onclick"] = "do_sort('" . $key . "','descending');";
                $icon = "ascend.png";
                $alt = __("Ascending order");
            } else {
                $sortArray[$key]["title"] = __("Click to sort by %1\$s in ascending order", $value["text"]);
                $sortArray[$key]["onclick"] = "do_sort('" . $key . "','ascending');";
                $icon = "descend.png";
                $alt = __("Descending order");
            }
        } else {
            $sortArray[$key]["title"] = __("Click to sort by %1\$s in ascending order", $value["text"]);
            $sortArray[$key]["onclick"] = "do_sort('" . $key . "','ascending');";
            $icon = "";
            $alt = "";
        }
        // The icon to be printed is determined above
        // Now, print the full HTML depending on the browser agent, version and platform
        if ($icon != "") {
            if ($net2ftp_globals["browser_agent"] == "IE" && ($net2ftp_globals["browser_version"] == "5.5" || $net2ftp_globals["browser_version"] == "6") && $net2ftp_globals["browser_platform"] == "Win") {
                $sortArray[$key]["icon"] = "<img src=\"{$icon_directory}/spacer.gif\"   alt=\"{$alt}\" style=\"border: 0px; width: 16px; height: 16px; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='{$icon_directory}/{$icon}', sizingMethod='scale');\" />\n";
            } else {
                $sortArray[$key]["icon"] = "<img src=\"{$icon_directory}/{$icon}\"        alt=\"{$alt}\" style=\"border: 0px; width: 16px; height: 16px;\" />\n";
            }
        } else {
            $sortArray[$key]["icon"] = "";
        }
    }
    // ------------------------------------
    // popup - FormAndFieldname
    // ------------------------------------
    if (isset($_POST["FormAndFieldName"]) == true) {
        $FormAndFieldName = validateGenericInput($_POST["FormAndFieldName"]);
    } else {
        $FormAndFieldName = "";
    }
    // ------------------------------------
    // Action URL
    // Used for Up, Subdirectories, Files (download + actions)
    // ------------------------------------
    $action_url = printPHP_SELF("actions");
    // ------------------------------------
    // Data transfer statistics
    // Print this only if the consumption statistics are available (logging must be on, using a MySQL database)
    // ------------------------------------
    if (isset($net2ftp_globals["consumption_ipaddress_datatransfer"]) == true || isset($net2ftp_globals["consumption_ftpserver_datatransfer"]) == true) {
        $print_consumption = true;
        $consumption_ipaddress_datatransfer = formatFilesize($net2ftp_globals["consumption_ipaddress_datatransfer"]);
        $consumption_ftpserver_datatransfer = formatFilesize($net2ftp_globals["consumption_ftpserver_datatransfer"]);
    } else {
        $print_consumption = false;
    }
    // ------------------------------------
    // HTTP URL
    // ------------------------------------
    $list_files_tmp[1]["dirfilename_url"] = "";
    $httplink = ftp2http($directory, $list_files_tmp, "no");
    // -------------------------------------------------------------------------
    // Print the output - part 2
    // -------------------------------------------------------------------------
    if ($net2ftp_globals["state2"] == "main") {
        setStatus(6, 10, __("Printing the list of directories and files"));
        require_once $net2ftp_globals["application_skinsdir"] . "/" . $net2ftp_globals["skin"] . "/browse_main.template.php";
    } elseif ($net2ftp_globals["state2"] == "popup") {
        require_once $net2ftp_globals["application_skinsdir"] . "/" . $net2ftp_globals["skin"] . "/browse_popup.template.php";
    }
}
$net2ftp_globals["screen_html"] = htmlEncode2($net2ftp_globals["screen"]);
$net2ftp_globals["screen_url"] = urlEncode2($net2ftp_globals["screen"]);
$net2ftp_globals["screen_js"] = javascriptEncode2($net2ftp_globals["screen"]);
// ----------------------------------------------
// MAMBO variables
// ----------------------------------------------
if (defined("_VALID_MOS") == true) {
    $option = validateGenericInput($_GET["option"]);
    $Itemid = validateGenericInput($_GET["Itemid"]);
    $net2ftp_globals["action_url"] .= "?option={$option}&amp;Itemid={$Itemid}";
}
// ----------------------------------------------
// DRUPAL variables
// ----------------------------------------------
if (defined("CACHE_PERMANENT") == true) {
    $q = validateGenericInput($_GET["q"]);
    $net2ftp_globals["action_url"] .= "?q={$q}";
}
// -------------------------------------------------------------------------
// 5.1 Delete the session data when logging out
// -------------------------------------------------------------------------
if ($net2ftp_globals["state"] == "logout") {
    $_SESSION["net2ftp_password_encrypted_" . $net2ftp_globals["ftpserver"] . $net2ftp_globals["username"]] = "";
}
// -------------------------------------------------------------------------
// 5.2 Redirect to login_small
//         if session has expired        (not for OpenLaszlo skin as it does not make a connection on the Login screen)
//         if the IP address has changed (disabled as this may cause problems for some people)
//         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"]) {
示例#6
0
function net2ftp_module_printBody()
{
    // --------------
    // This function prints the login screen
    // --------------
    // -------------------------------------------------------------------------
    // Global variables
    // -------------------------------------------------------------------------
    global $net2ftp_settings, $net2ftp_globals, $net2ftp_messages, $net2ftp_result;
    if (isset($_POST["input_admin_username"]) == true) {
        $input_admin_username = htmlEncode2(validateGenericInput($_POST["input_admin_username"]));
    } else {
        $input_admin_username = "";
    }
    if (isset($_POST["input_admin_password"]) == true) {
        $input_admin_password = htmlEncode2(validateGenericInput($_POST["input_admin_password"]));
    } else {
        $input_admin_password = "";
    }
    // -------------------------------------------------------------------------
    // Variables
    // -------------------------------------------------------------------------
    // Title
    $title = __("Admin functions");
    // Form name, back and forward buttons
    $formname = "AdminForm";
    $back_onclick = "document.forms['" . $formname . "'].state.value='login';document.forms['" . $formname . "'].submit();";
    // Current build number
    $application_build_nr = $net2ftp_settings["application_build_nr"];
    // Date from and to
    $today = date("Y-m-d");
    $oneweekago = date("Y-m-d", time() - 3600 * 24 * 7);
    $datefrom = $oneweekago;
    $dateto = $today;
    // -------------------------------------------------------------------------
    // Print the output
    // -------------------------------------------------------------------------
    require_once $net2ftp_globals["application_skinsdir"] . "/" . $net2ftp_globals["skin"] . "/manage.template.php";
}
示例#7
0
function getBrowser($what)
{
    // --------------
    // This function returns the browser name, version and platform using the http_user_agent string
    // --------------
    // Original code comes from http://www.phpbuilder.com/columns/tim20000821.php3?print_mode=1
    // Written by Tim Perdue, and released under the GPL license
    //
    // SourceForge: Breaking Down the Barriers to Open Source Development
    // Copyright 1999-2000 (c) The SourceForge Crew
    // http://sourceforge.net
    //
    // $Id: tim20000821.php3,v 1.2 2001/05/22 19:22:47 tim Exp $
    // -------------------------------------------------------------------------
    // If no information is available, return ""
    // -------------------------------------------------------------------------
    if (isset($_SERVER["HTTP_USER_AGENT"]) == false) {
        return "";
    }
    // -------------------------------------------------------------------------
    // Remove XSS code
    // -------------------------------------------------------------------------
    $http_user_agent = validateGenericInput($_SERVER["HTTP_USER_AGENT"]);
    // -------------------------------------------------------------------------
    // Determine browser and version
    // -------------------------------------------------------------------------
    if ($what == "version" || $what == "agent") {
        // !!! If a new browser is added, add is also in the plugin properties
        // Else, functionality will be broken when loading the plugin in printTextareaSelect().
        if (ereg('MSIE ([0-9].[0-9]{1,2})', $http_user_agent, $regs)) {
            $BROWSER_VERSION = $regs[1];
            $BROWSER_AGENT = 'IE';
        } elseif (ereg('Safari/([0-9].[0-9]{1,2})', $http_user_agent, $regs)) {
            $BROWSER_VERSION = $regs[1];
            $BROWSER_AGENT = 'Safari';
        } elseif (ereg('Chrome/([0-9].[0-9]{1,2})', $http_user_agent, $regs)) {
            $BROWSER_VERSION = $regs[1];
            $BROWSER_AGENT = 'Chrome';
        } elseif (ereg('Opera ([0-9].[0-9]{1,2})', $http_user_agent, $regs)) {
            $BROWSER_VERSION = $regs[1];
            $BROWSER_AGENT = 'Opera';
        } elseif (ereg('Mozilla/([0-9].[0-9]{1,2})', $http_user_agent, $regs)) {
            $BROWSER_VERSION = $regs[1];
            $BROWSER_AGENT = 'Mozilla';
        } else {
            $BROWSER_VERSION = 0;
            $BROWSER_AGENT = 'Other';
        }
        if ($what == "version") {
            return $BROWSER_VERSION;
        } elseif ($what == "agent") {
            return $BROWSER_AGENT;
        }
    } elseif ($what == "platform") {
        if (strstr($http_user_agent, 'BlackBerry') || strstr($http_user_agent, 'DoCoMo') || strstr($http_user_agent, 'Nokia') || strstr($http_user_agent, 'Palm') || strstr($http_user_agent, 'SonyEricsson') || strstr($http_user_agent, 'SymbianOS') || strstr($http_user_agent, 'Windows CE')) {
            $BROWSER_PLATFORM = 'Mobile';
        } elseif (strstr($http_user_agent, 'iPhone') || strstr($http_user_agent, 'iPod')) {
            $BROWSER_PLATFORM = 'iPhone';
        } elseif (strstr($http_user_agent, 'Win')) {
            $BROWSER_PLATFORM = 'Win';
        } else {
            if (strstr($http_user_agent, 'Mac')) {
                $BROWSER_PLATFORM = 'Mac';
            } else {
                if (strstr($http_user_agent, 'Linux')) {
                    $BROWSER_PLATFORM = 'Linux';
                } else {
                    if (strstr($http_user_agent, 'Unix')) {
                        $BROWSER_PLATFORM = 'Unix';
                    } else {
                        $BROWSER_PLATFORM = 'Other';
                    }
                }
            }
        }
        return $BROWSER_PLATFORM;
    }
    // end if elseif
}
function net2ftp_module_printBody()
{
    // --------------
    // This function prints the login screen
    // --------------
    // -------------------------------------------------------------------------
    // Global variables
    // -------------------------------------------------------------------------
    global $net2ftp_settings, $net2ftp_globals, $net2ftp_messages, $net2ftp_result;
    if (isset($_POST["input_admin_username"]) == true) {
        $input_admin_username = htmlEncode2(validateGenericInput($_POST["input_admin_username"]));
    } else {
        $input_admin_username = "";
    }
    if (isset($_POST["input_admin_password"]) == true) {
        $input_admin_password = htmlEncode2(validateGenericInput($_POST["input_admin_password"]));
    } else {
        $input_admin_password = "";
    }
    if (isset($_POST["dbusername2"]) == true) {
        $dbusername2 = validateUsername($_POST["dbusername2"]);
    } else {
        $dbusername2 = "";
    }
    if (isset($_POST["dbpassword2"]) == true) {
        $dbpassword2 = validatePassword($_POST["dbpassword2"]);
    } else {
        $dbpassword2 = "";
    }
    if (isset($_POST["dbname2"]) == true) {
        $dbname2 = validateGenericInput($_POST["dbname2"]);
    } else {
        $dbname2 = "";
    }
    if (isset($_POST["dbserver2"]) == true) {
        $dbserver2 = validateGenericInput($_POST["dbserver2"]);
    } else {
        $dbserver2 = "";
    }
    $dbusername2_html = htmlEncode2($dbusername2);
    $dbpassword2_html = htmlEncode2($dbpassword2);
    $dbname2_html = htmlEncode2($dbname2);
    $dbserver2_html = htmlEncode2($dbserver2);
    if ($dbserver2 == "") {
        $dbserver2 = "localhost";
    }
    // -------------------------------------------------------------------------
    // Variables for all screens
    // -------------------------------------------------------------------------
    // Output variable
    $net2ftp_output["admin_createtables"][] = "";
    // Title
    $title = __("Admin functions");
    // Form name
    $formname = "AdminForm";
    // Read the SQL file
    $filename = glueDirectories($net2ftp_globals["application_rootdir"], "create_tables.sql");
    $handle = fopen($filename, "rb");
    // Open the file for reading only
    if ($handle == false) {
        $net2ftp_output["admin_createtables"][] = __("The handle of file %1\$s could not be opened.", $filename);
    }
    clearstatcache();
    // for filesize
    $sqlquerystring = fread($handle, filesize($filename));
    if ($sqlquerystring == false) {
        $net2ftp_output["admin_createtables"][] = __("The file %1\$s could not be opened.", $filename);
    }
    $result1 = fclose($handle);
    if ($result1 == false) {
        $net2ftp_output["admin_createtables"][] = __("The handle of file %1\$s could not be closed.", $filename);
    }
    // Split the SQL file in individual queries
    $sqlquerypieces = explode("\n", $sqlquerystring);
    // -------------------------------------------------------------------------
    // Variables for screen 1
    // -------------------------------------------------------------------------
    if ($net2ftp_globals["screen"] == 1) {
        // Next screen
        $nextscreen = 2;
        // Back and forward buttons
        $back_onclick = "document.forms['" . $formname . "'].state.value='admin';document.forms['" . $formname . "'].screen.value='1';document.forms['" . $formname . "'].submit();";
        $forward_onclick = "document.forms['" . $formname . "'].submit();";
    } elseif ($net2ftp_globals["screen"] == 2) {
        // Next screen
        $nextscreen = 1;
        // Back and forward buttons
        $back_onclick = "document.forms['" . $formname . "'].state.value='admin';document.forms['" . $formname . "'].screen.value='1';document.forms['" . $formname . "'].submit();";
        $dbpassword2_length = strlen($dbpassword2);
        // ------------------------------------
        // Connect
        // ------------------------------------
        $mydb = mysql_connect($dbserver2, $dbusername2, $dbpassword2);
        if ($mydb == false) {
            $net2ftp_output["admin_createtables"][] = __("The connection to the server <b>%1\$s</b> could not be set up. Please check the database settings you've entered.", $dbserver2_html) . "\n";
        }
        // ------------------------------------
        // Select
        // ------------------------------------
        if ($mydb != false) {
            $mysql_select_db_result = mysql_select_db($dbname2);
            if ($mysql_select_db_result == false) {
                $net2ftp_output["admin_createtables"][] = __("Unable to select the database <b>%1\$s</b>.", $dbserver2_html) . "\n";
            }
        }
        // ------------------------------------
        // Query
        // ------------------------------------
        if ($mydb != false && $mysql_select_db_result != false) {
            for ($i = 0; $i < sizeof($sqlquerypieces); $i++) {
                $mysql_query_results[$i] = mysql_query($sqlquerypieces[$i]);
                if ($mysql_query_results[$i] == false) {
                    $net2ftp_output["admin_createtables"][] = __("The SQL query nr <b>%1\$s</b> could not be executed.", $i + 1) . "\n";
                } else {
                    $net2ftp_output["admin_createtables"][] = __("The SQL query nr <b>%1\$s</b> was executed successfully.", $i + 1) . "\n";
                }
            }
        }
    }
    // end elseif
    // -------------------------------------------------------------------------
    // Print the output
    // -------------------------------------------------------------------------
    require_once $net2ftp_globals["application_skinsdir"] . "/" . $net2ftp_globals["skin"] . "/manage.template.php";
}
    $ftpserverport = validateGenericInput($_POST["ftpserverport"]);
}
if (isset($_POST["username"]) == true) {
    $username = validateGenericInput($_POST["username"]);
}
if (isset($_POST["password"]) == true) {
    $password = validateGenericInput($_POST["password"]);
}
if (isset($_POST["passivemode"]) == true) {
    $passivemode = validateGenericInput($_POST["passivemode"]);
}
if (isset($_POST["targetdirectory"]) == true) {
    $targetdirectory = validateDirectory($_POST["targetdirectory"]);
}
if (isset($_POST["screen"]) == true) {
    $screen = validateGenericInput($_POST["screen"]);
}
if (isset($_SERVER["SCRIPT_NAME"]) == true) {
    $php_self = $_SERVER["SCRIPT_NAME"];
} elseif (isset($_SERVER["PHP_SELF"]) == true) {
    $php_self = $_SERVER["PHP_SELF"];
}
$tempdir = dirname(__FILE__) . "/net2ftp_temp_06er8";
// --------------------------------------------------------------------------------
// HTML start
// --------------------------------------------------------------------------------
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en" dir="LTR">
<head>
<meta http-equiv="Content-type" content="text/html; charset=iso-8859-1">
function net2ftp_module_printBody()
{
    // --------------
    // This function prints the login screen
    // --------------
    // -------------------------------------------------------------------------
    // Global variables
    // -------------------------------------------------------------------------
    global $net2ftp_settings, $net2ftp_globals, $net2ftp_messages, $net2ftp_result;
    if (isset($_POST["input_admin_username"]) == true) {
        $input_admin_username = htmlEncode2(validateGenericInput($_POST["input_admin_username"]));
    } else {
        $input_admin_username = "";
    }
    if (isset($_POST["input_admin_password"]) == true) {
        $input_admin_password = htmlEncode2(validateGenericInput($_POST["input_admin_password"]));
    } else {
        $input_admin_password = "";
    }
    if (isset($_POST["datefrom"]) == true) {
        $datefrom = addslashes(validateGenericInput($_POST["datefrom"]));
    } else {
        $datefrom = "";
    }
    if (isset($_POST["dateto"]) == true) {
        $dateto = addslashes(validateGenericInput($_POST["dateto"]));
    } else {
        $dateto = "";
    }
    // -------------------------------------------------------------------------
    // Variables for all screens
    // -------------------------------------------------------------------------
    // Output variable
    $net2ftp_output["admin_viewlogs"][] = "";
    // Title
    $title = __("Admin functions");
    // Form name, back and forward buttons
    $formname = "AdminForm";
    $back_onclick = "document.forms['" . $formname . "'].state.value='admin';document.forms['" . $formname . "'].submit();";
    $forward_onclick = "document.forms['" . $formname . "'].submit();";
    // -------------------------------------------------------------------------
    // Variables for screen 1
    // -------------------------------------------------------------------------
    // ------------------------------------
    // Connect to the database
    // ------------------------------------
    $mydb = connect2db();
    if ($net2ftp_result["success"] == false) {
        return false;
    }
    // ------------------------------------
    // Execute the SQL query and print the data
    // ------------------------------------
    // Query 1
    $sqlquery1 = "SELECT * FROM net2ftp_log_access WHERE date BETWEEN '{$datefrom}' AND '{$dateto}' ORDER BY date DESC, time DESC;";
    $table1 = printTable($sqlquery1);
    if ($net2ftp_result["success"] == false) {
        return false;
    }
    // Query 2
    $sqlquery2 = "SELECT * FROM net2ftp_log_error WHERE date BETWEEN '{$datefrom}' AND '{$dateto}' ORDER BY date DESC, time DESC;";
    $table2 = printTable($sqlquery2);
    if ($net2ftp_result["success"] == false) {
        return false;
    }
    // Query 3
    $sqlquery3 = "SELECT * FROM net2ftp_log_consumption_ftpserver WHERE date BETWEEN '{$datefrom}' AND '{$dateto}' ORDER BY datatransfer DESC, date DESC;";
    $table3 = printTable($sqlquery3);
    if ($net2ftp_result["success"] == false) {
        return false;
    }
    // Query 4
    $sqlquery4 = "SELECT * FROM net2ftp_log_consumption_ipaddress WHERE date BETWEEN '{$datefrom}' AND '{$dateto}' ORDER BY datatransfer DESC, date DESC;";
    $table4 = printTable($sqlquery4);
    if ($net2ftp_result["success"] == false) {
        return false;
    }
    // -------------------------------------------------------------------------
    // Print the output
    // -------------------------------------------------------------------------
    require_once $net2ftp_globals["application_skinsdir"] . "/" . $net2ftp_globals["skin"] . "/manage.template.php";
}
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["input_admin_username"]) == true) {
        $input_admin_username = htmlEncode2(validateGenericInput($_POST["input_admin_username"]));
    } else {
        $input_admin_username = "";
    }
    if (isset($_POST["input_admin_password"]) == true) {
        $input_admin_password = htmlEncode2(validateGenericInput($_POST["input_admin_password"]));
    } else {
        $input_admin_password = "";
    }
    if (isset($_POST["datefrom"]) == true) {
        $datefrom = addslashes(validateGenericInput($_POST["datefrom"]));
    } else {
        $datefrom = "";
    }
    if (isset($_POST["dateto"]) == true) {
        $dateto = addslashes(validateGenericInput($_POST["dateto"]));
    } else {
        $dateto = "";
    }
    // -------------------------------------------------------------------------
    // Variables for all screens
    // -------------------------------------------------------------------------
    // Output variable
    $net2ftp_output["admin_emptylogs"][] = "";
    // Title
    $title = __("Admin functions");
    // Form name, back and forward buttons
    $formname = "AdminForm";
    $back_onclick = "document.forms['" . $formname . "'].state.value='admin';document.forms['" . $formname . "'].submit();";
    $forward_onclick = "document.forms['" . $formname . "'].submit();";
    // -------------------------------------------------------------------------
    // Variables for screen 1
    // -------------------------------------------------------------------------
    // ------------------------------------
    // Input checks
    // ------------------------------------
    // Add slashes to variables which are used in a SQL query, and which are
    // potentially unsafe (supplied by the user).
    $datefrom = addslashes($datefrom);
    $dateto = addslashes($dateto);
    if ($datefrom == "" || $datefrom == 0) {
        return false;
    }
    if ($dateto == "" || $dateto == 0) {
        return false;
    }
    // ------------------------------------
    // Delete empty logs
    // ------------------------------------
    emptyLogs($datefrom, $dateto);
    if (isset($net2ftp_output["emptyLogs"]) == true) {
        $net2ftp_output["admin_emptylogs"] = $net2ftp_output["admin_emptylogs"] + $net2ftp_output["emptyLogs"];
    }
    // -------------------------------------------------------------------------
    // Print the output
    // -------------------------------------------------------------------------
    require_once $net2ftp_globals["application_skinsdir"] . "/" . $net2ftp_globals["skin"] . "/manage.template.php";
}