本文整理汇总了PHP中setErrorVars函数的典型用法代码示例。如果您正苦于以下问题:PHP setErrorVars函数的具体用法?PHP setErrorVars怎么用?PHP setErrorVars使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setErrorVars函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: net2ftp_module_sendHttpHeaders
function net2ftp_module_sendHttpHeaders()
{
// --------------
// This function sends HTTP headers
// --------------
global $net2ftp_globals, $net2ftp_settings;
if ($net2ftp_settings["functionuse_downloadfile"] == "yes") {
ftp_downloadfile($net2ftp_globals["directory"], $net2ftp_globals["entry"]);
} else {
$errormessage = __("This function has been disabled by the Administrator of this website.");
setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__);
return false;
}
}
开发者ID:NN-Dev-Team,项目名称:Nordic-Network,代码行数:14,代码来源:downloadfile.inc.php
示例2: connect2db
function connect2db()
{
// --------------
// This function logs user accesses to the site
// --------------
// -------------------------------------------------------------------------
// Global variables
// -------------------------------------------------------------------------
global $net2ftp_settings;
$mydb = mysql_connect($net2ftp_settings["dbserver"], $net2ftp_settings["dbusername"], $net2ftp_settings["dbpassword"]);
if ($mydb == false) {
setErrorVars(false, __("Unable to connect to the MySQL database. Please check your MySQL database settings in net2ftp's configuration file settings.inc.php."), debug_backtrace(), __FILE__, __LINE__);
return false;
}
$result2 = mysql_select_db($net2ftp_settings["dbname"]);
if ($result2 == false) {
setErrorVars(false, __("Unable to select the MySQL database. Please check your MySQL database settings in net2ftp's configuration file settings.inc.php."), debug_backtrace(), __FILE__, __LINE__);
return false;
}
return $mydb;
}
开发者ID:rohdoor,项目名称:Zpanel-net2ftp,代码行数:21,代码来源:database.inc.php
示例3: net2ftp_module_sendHttpHeaders
function net2ftp_module_sendHttpHeaders()
{
// --------------
// This function sends HTTP headers
// --------------
global $net2ftp_globals, $net2ftp_settings;
if (isset($_POST["list"]) == true) {
$list = getSelectedEntries($_POST["list"]);
} elseif (isset($_GET["list"]) == true) {
$list = getSelectedEntries($_GET["list"]);
} else {
$list = "";
}
if ($net2ftp_settings["functionuse_downloadzip"] == "yes") {
$zipactions["download"] = "yes";
$zipactions["email"] = "no";
$zipactions["save"] = "no";
ftp_zip("", $net2ftp_globals["directory"], $list, $zipactions, "", 0);
} else {
$errormessage = __("This function has been disabled by the Administrator of this website.");
setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__);
return false;
}
}
开发者ID:jprice,项目名称:EHCP,代码行数:24,代码来源:downloadzip.inc.php
示例4: putConsumption
function putConsumption()
{
// --------------
// This function writes the consumption to the database.
// It is run at the end of the script.
// --------------
// -------------------------------------------------------------------------
// Global variables
// -------------------------------------------------------------------------
global $net2ftp_globals, $net2ftp_settings, $net2ftp_result;
// -------------------------------------------------------------------------
// Initial checks
// -------------------------------------------------------------------------
// Verify if a database is used, and if consumption checking is turned on. If not: don't continue.
if ($net2ftp_settings["use_database"] != "yes" || $net2ftp_settings["check_consumption"] != "yes") {
return true;
}
// When user is not logged in, the FTP server is not set
if ($net2ftp_globals["ftpserver"] == "") {
return true;
}
// If the REMOTE_ADDR is not filled in, then there is a problem (IP spoofing), so return an error
if ($net2ftp_globals["REMOTE_ADDR"] == "") {
setErrorVars(false, __("Unable to determine your IP address."), debug_backtrace(), __FILE__, __LINE__);
return false;
}
// If the database has already been updated, don't do it a second time.
// This is to avoid updating the database twice. The putConsumption() function
// is called from index.php and from shutdown() in filesystem.inc.php. On Windows
// the shutdown() function is called after *every* script execution.
if ($net2ftp_globals["consumption_database_updated"] == 1) {
return true;
}
// Add slashes to variables which are used in a SQL query, and which are
// potentially unsafe (supplied by the user).
// $date is calculated in this function
// $time is calculated in this function
$REMOTE_ADDR_safe = addslashes($net2ftp_globals["REMOTE_ADDR"]);
$net2ftp_ftpserver_safe = addslashes($net2ftp_globals["ftpserver"]);
// -------------------------------------------------------------------------
// Check the input
// -------------------------------------------------------------------------
// if (preg_match("/^[0-9]+$/", $net2ftp_globals["consumption_ipaddress_datatransfer) == FALSE) {
// setErrorVars(false, __("The variable <b>consumption_ipaddress_datatransfer</b> is not numeric."), debug_backtrace(), __FILE__, __LINE__);
// return false;
// }
// -------------------------------------------------------------------------
// Connect
// -------------------------------------------------------------------------
$mydb = connect2db();
if ($net2ftp_result["success"] == false) {
return false;
}
// -------------------------------------------------------------------------
// Get date
// -------------------------------------------------------------------------
$date = date("Y-m-d");
// -------------------------------------------------------------------------
// Put consumed data volume and execution time by the current IP address
// -------------------------------------------------------------------------
$sqlquery1 = "SELECT * FROM net2ftp_log_consumption_ipaddress WHERE date = '{$date}' AND ipaddress = '{$REMOTE_ADDR_safe}';";
$result1 = mysql_query("{$sqlquery1}");
$nrofrows1 = mysql_num_rows($result1);
if ($nrofrows1 == 1) {
$sqlquery2 = "UPDATE net2ftp_log_consumption_ipaddress SET datatransfer = '" . $net2ftp_globals["consumption_ipaddress_datatransfer"] . "', executiontime = '" . round($net2ftp_globals["consumption_ipaddress_executiontime"]) . "' WHERE date = '{$date}' AND ipaddress = '{$REMOTE_ADDR_safe}';";
$result2 = mysql_query("{$sqlquery2}");
$nrofrows2 = mysql_affected_rows($mydb);
// Don't check on the UPDATE nr of rows, because when the values in the variables and in the table are the same,
// the $nrofrows2 is set to 0. (This happens on the Browse screen, when the loading is fast: the datatransfer is 0
// and the executiontime is the same as in the table.)
// if ($nrofrows2 != 1) {
// setErrorVars(false, __("Table net2ftp_log_consumption_ipaddress could not be updated."), debug_backtrace(), __FILE__, __LINE__);
// return false;
// }
} elseif ($nrofrows1 == 0) {
$sqlquery3 = "INSERT INTO net2ftp_log_consumption_ipaddress VALUES('{$date}', '{$REMOTE_ADDR_safe}', '" . $net2ftp_globals["consumption_ipaddress_datatransfer"] . "', '" . round($net2ftp_globals["consumption_ipaddress_executiontime"]) . "');";
$result3 = mysql_query("{$sqlquery3}");
$nrofrows3 = mysql_affected_rows($mydb);
if ($nrofrows3 != 1) {
setErrorVars(false, __("Table net2ftp_log_consumption_ipaddress could not be updated."), debug_backtrace(), __FILE__, __LINE__);
return false;
}
} else {
setErrorVars(false, __("Table net2ftp_log_consumption_ipaddress contains duplicate entries."), debug_backtrace(), __FILE__, __LINE__);
return false;
}
// MySQL > 4.1.0
// $sqlquery1 = "INSERT INTO net2ftp_log_consumption_ipaddress VALUES('$date', '$REMOTE_ADDR_safe', '" . $net2ftp_globals["consumption_ipaddress_datatransfer"] . "', '" . round($net2ftp_globals["consumption_ipaddress_executiontime"]) . "') ON DUPLICATE KEY UPDATE datatransfer = '" . $net2ftp_globals["consumption_ipaddress_datatransfer"] . "', executiontime = '" . round($net2ftp_globals["consumption_ipaddress_executiontime"]) . "';";
// -------------------------------------------------------------------------
// Put consumed data volume and execution time to the current FTP server
// -------------------------------------------------------------------------
$sqlquery4 = "SELECT * FROM net2ftp_log_consumption_ftpserver WHERE date = '{$date}' AND ftpserver = '{$net2ftp_ftpserver_safe}';";
$result4 = mysql_query("{$sqlquery4}");
$nrofrows4 = mysql_num_rows($result4);
if ($nrofrows4 == 1) {
$sqlquery5 = "UPDATE net2ftp_log_consumption_ftpserver SET datatransfer = '" . $net2ftp_globals["consumption_ftpserver_datatransfer"] . "', executiontime = '" . round($net2ftp_globals["consumption_ftpserver_executiontime"]) . "' WHERE date = '{$date}' AND ftpserver = '{$net2ftp_ftpserver_safe}';";
$result5 = mysql_query("{$sqlquery5}");
$nrofrows5 = mysql_affected_rows($mydb);
// Don't check on the UPDATE nr of rows, because when the values in the variables and in the table are the same,
// the $nrofrows2 is set to 0. (This happens on the Browse screen, when the loading is fast: the datatransfer is 0
//.........这里部分代码省略.........
开发者ID:klr2003,项目名称:sourceread,代码行数:101,代码来源:consumption.inc.php
示例5: net2ftp
//.........这里部分代码省略.........
if ($net2ftp_result["success"] == false) {
logError();
return false;
}
}
// -------------------------------------------------------------------------
// Check authorizations
// --> Do this only once, when $action == "sendHttpHeaders"
// -------------------------------------------------------------------------
if ($action == "sendHttpHeaders" && $net2ftp_settings["check_authorization"] == "yes" && $net2ftp_globals["ftpserver"] != "") {
checkAuthorization($net2ftp_globals["ftpserver"], $net2ftp_globals["ftpserverport"], $net2ftp_globals["directory"], $net2ftp_globals["username"]);
if ($net2ftp_result["success"] == false) {
logError();
return false;
}
}
// -------------------------------------------------------------------------
// Get the consumption counter values from the database
// This retrieves the consumption of network and server resources for the
// current IP address and FTP server from the database, and stores these
// values in global variables. See /includes/consumption.inc.php for the details.
// --> Do this only once, when $action == "sendHttpHeaders"
// -------------------------------------------------------------------------
if ($action == "sendHttpHeaders") {
getConsumption();
if ($net2ftp_result["success"] == false) {
logError();
return false;
}
}
// -------------------------------------------------------------------------
// Execute the action!
// -------------------------------------------------------------------------
// ------------------------------------
// For most modules, everything must be done: send headers, print body, etc
// ------------------------------------
if ($net2ftp_globals["state"] == "admin" || $net2ftp_globals["state"] == "admin_createtables" || $net2ftp_globals["state"] == "admin_emptylogs" || $net2ftp_globals["state"] == "admin_viewlogs" || $net2ftp_globals["state"] == "advanced" || $net2ftp_globals["state"] == "advanced_ftpserver" || $net2ftp_globals["state"] == "advanced_parsing" || $net2ftp_globals["state"] == "advanced_webserver" || $net2ftp_globals["state"] == "bookmark" || $net2ftp_globals["state"] == "browse" || $net2ftp_globals["state"] == "calculatesize" || $net2ftp_globals["state"] == "chmod" || $net2ftp_globals["state"] == "copymovedelete" || $net2ftp_globals["state"] == "edit" || $net2ftp_globals["state"] == "findstring" || $net2ftp_globals["state"] == "install" || $net2ftp_globals["state"] == "jupload" && $net2ftp_globals["screen"] == 1 || $net2ftp_globals["state"] == "login" || $net2ftp_globals["state"] == "login_small" || $net2ftp_globals["state"] == "logout" || $net2ftp_globals["state"] == "newdir" || $net2ftp_globals["state"] == "raw" || $net2ftp_globals["state"] == "rename" || $net2ftp_globals["state"] == "unzip" || $net2ftp_globals["state"] == "upload" || $net2ftp_globals["state"] == "view" && $net2ftp_globals["state2"] == "" || $net2ftp_globals["state"] == "zip") {
require_once $net2ftp_globals["application_modulesdir"] . "/" . $net2ftp_globals["state"] . "/" . $net2ftp_globals["state"] . ".inc.php";
if ($action == "sendHttpHeaders") {
net2ftp_module_sendHttpHeaders();
// If needed, exit to avoid sending non-header output (by net2ftp or other application)
// Example: if a module sends a HTTP redirect header (See /includes/authorizations.inc.php function checkAdminUsernamePassword()!)
if ($net2ftp_result["exit"] == true) {
exit;
}
} elseif ($action == "printJavascript") {
net2ftp_module_printJavascript();
net2ftp_plugin_printJavascript();
} elseif ($action == "printCss") {
net2ftp_module_printCss();
net2ftp_plugin_printCss();
} elseif ($action == "printBodyOnload") {
net2ftp_module_printBodyOnload();
net2ftp_plugin_printBodyOnload();
} elseif ($action == "printBody") {
// Print the status bar to be able to show the progress
if (isStatusbarActive() == true) {
require_once $net2ftp_globals["application_skinsdir"] . "/" . $net2ftp_globals["skin"] . "/statusbar.template.php";
}
require_once $net2ftp_globals["application_skinsdir"] . "/" . $net2ftp_globals["skin"] . "/status/status.inc.php";
// Do the work and meanwhile update the progress bar
net2ftp_module_printBody();
// Update the consumption statistics
$net2ftp_globals["endtime"] = microtime();
$net2ftp_globals["time_taken"] = timer();
addConsumption(0, $net2ftp_globals["time_taken"]);
putConsumption();
// Set the progress bar to "finished"
if (isStatusbarActive() == true) {
$statusmessage = __("Script finished in %1\$s seconds", $net2ftp_globals["time_taken"]);
setStatus(1, 1, $statusmessage);
}
}
} elseif ($net2ftp_globals["state"] == "clearcookies" || $net2ftp_globals["state"] == "downloadfile" || $net2ftp_globals["state"] == "downloadzip" || $net2ftp_globals["state"] == "followsymlink" || $net2ftp_globals["state"] == "jupload" && $net2ftp_globals["screen"] == 2 || $net2ftp_globals["state"] == "view" && $net2ftp_globals["state2"] != "") {
require_once $net2ftp_globals["application_modulesdir"] . "/" . $net2ftp_globals["state"] . "/" . $net2ftp_globals["state"] . ".inc.php";
if ($action == "sendHttpHeaders") {
// Do the work - do not update the progress bar
net2ftp_module_sendHttpHeaders();
// Update the consumption statistics
$net2ftp_globals["endtime"] = microtime();
$net2ftp_globals["time_taken"] = timer();
addConsumption(0, $net2ftp_globals["time_taken"]);
putConsumption();
// Exit to avoid sending non-header output (by net2ftp or other application)
exit;
} elseif ($action == "printJavascript") {
} elseif ($action == "printCss") {
} elseif ($action == "printBodyOnload") {
} elseif ($action == "printBody") {
}
} elseif ($net2ftp_globals["state"] == "error") {
logError();
return false;
} else {
$errormessage = __("Unexpected state string: %1\$s. Exiting.", $net2ftp_globals["state"]);
setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__);
logError();
return false;
}
}
开发者ID:klr2003,项目名称:sourceread,代码行数:101,代码来源:main.inc.php
示例6: net2ftp_module_printBody
//.........这里部分代码省略.........
// 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__);
开发者ID:rohdoor,项目名称:Zpanel-net2ftp,代码行数:67,代码来源:edit.inc.php
示例7: net2ftp_module_printBody
function net2ftp_module_printBody()
{
// --------------
// This function prints the rename 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["newNames"]) == true) {
$newNames = validateEntry($_POST["newNames"]);
} else {
$newNames = "";
}
// -------------------------------------------------------------------------
// Variables for all screens
// -------------------------------------------------------------------------
// Title
$title = __("Rename directories and files");
// Form name, back and forward buttons
$formname = "RenameForm";
$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
setStatus(2, 10, __("Connecting to the FTP server"));
$conn_id = ftp_openconnection();
if ($net2ftp_result["success"] == false) {
return false;
}
// Rename files
setStatus(4, 10, __("Processing the entries"));
for ($i = 1; $i <= sizeof($list["all"]); $i++) {
if (strstr($list["all"][$i]["dirfilename"], "..") != false) {
$net2ftp_output["rename"][] = __("The new name may not contain any dots. This entry was not renamed to <b>%1\$s</b>", htmlEncode2($newNames[$i])) . "<br />";
continue;
}
if (checkAuthorizedName($newNames[$i]) == false) {
$net2ftp_output["rename"][] = __("The new name may not contain any banned keywords. This entry was not renamed to <b>%1\$s</b>", htmlEncode2($newNames[$i])) . "<br />";
continue;
}
ftp_rename2($conn_id, $net2ftp_globals["directory"], $list["all"][$i]["dirfilename"], $newNames[$i]);
if ($net2ftp_result["success"] == false) {
setErrorVars(true, "", "", "", "");
$net2ftp_output["rename"][] = __("<b>%1\$s</b> could not be renamed to <b>%2\$s</b>", htmlEncode2($list["all"][$i]["dirfilename"]), htmlEncode2($newNames[$i]));
continue;
} else {
$net2ftp_output["rename"][] = __("<b>%1\$s</b> was successfully renamed to <b>%2\$s</b>", htmlEncode2($list["all"][$i]["dirfilename"]), htmlEncode2($newNames[$i]));
}
}
// End for
// Close connection
ftp_closeconnection($conn_id);
}
// end elseif
// -------------------------------------------------------------------------
// Print the output
// -------------------------------------------------------------------------
require_once $net2ftp_globals["application_skinsdir"] . "/" . $net2ftp_globals["skin"] . "/manage.template.php";
}
开发者ID:Jmainguy,项目名称:multicraft_install,代码行数:71,代码来源:rename.inc.php
示例8: getRootdirectory
function getRootdirectory()
{
// --------------
// This function gets the user's root directory from the database and
// stores it in $net2ftp_globals["homedirectory"].
//
// If $net2ftp_globals["homedirectory"] is already filled in (cache), no connection
// is made to the DB and this value is returned.
// --------------
// -------------------------------------------------------------------------
// Global variables
// -------------------------------------------------------------------------
global $net2ftp_globals, $net2ftp_settings, $net2ftp_result;
// -------------------------------------------------------------------------
// Initial checks
// -------------------------------------------------------------------------
if ($net2ftp_settings["use_database"] != "yes" || $net2ftp_settings["check_homedirectory"] != "yes") {
$net2ftp_globals["homedirectory"] = "/";
}
// -------------------------------------------------------------------------
// Get the homedirectory from the database, then store it in a global
// variable, and from then on, don't access the database any more
// -------------------------------------------------------------------------
if (isset($net2ftp_globals["homedirectory"]) == false) {
// -------------------------------------------------------------------------
// Add slashes to variables which are used in a SQL query, and which are
// potentially unsafe (supplied by the user)
// -------------------------------------------------------------------------
$net2ftp_ftpserver_safe = addslashes($net2ftp_globals["ftpserver"]);
$net2ftp_username_safe = addslashes($net2ftp_globals["username"]);
// -------------------------------------------------------------------------
// Connect
// -------------------------------------------------------------------------
$mydb = connect2db();
if ($net2ftp_result["success"] == false) {
return false;
}
// -------------------------------------------------------------------------
// Get user's home directory
// -------------------------------------------------------------------------
$sqlquery1 = "SELECT homedirectory FROM net2ftp_users WHERE ftpserver = '{$net2ftp_ftpserver_safe}' AND username = '{$net2ftp_username_safe}';";
$result1 = mysql_query("{$sqlquery1}") or die("Unable to execute SQL SELECT query (isAuthorizedDirectory > sqlquery1) <br /> {$sqlquery1}");
$nrofrows1 = mysql_num_rows($result1);
if ($nrofrows1 == 0) {
$net2ftp_globals["homedirectory"] = "/";
} elseif ($nrofrows1 == 1) {
$resultRow1 = mysql_fetch_row($result1);
$net2ftp_globals["homedirectory"] = $resultRow1[0];
} else {
setErrorVars(false, __("Table net2ftp_users contains duplicate rows."), debug_backtrace(), __FILE__, __LINE__);
return false;
}
}
return $net2ftp_globals["homedirectory"];
}
开发者ID:rohdoor,项目名称:Zpanel-net2ftp,代码行数:55,代码来源:authorizations.inc.php
示例9: putLogStatus
function putLogStatus($logStatus)
{
// --------------
// This function writes the log rotation status to the database.
// --------------
// -------------------------------------------------------------------------
// Global variables
// -------------------------------------------------------------------------
global $net2ftp_globals, $net2ftp_settings, $net2ftp_result;
// -------------------------------------------------------------------------
// Initial checks
// -------------------------------------------------------------------------
// Verify if a database is used. If not: don't continue.
if ($net2ftp_settings["use_database"] != "yes") {
return true;
}
// -------------------------------------------------------------------------
// Determine current month and last month
// -------------------------------------------------------------------------
$currentmonth = date("Ym");
// e.g. 201207
$lastmonth = date("Ym", mktime(0, 0, 0, date("m") - 1, date("d"), date("Y")));
$datetime = mytime();
// -------------------------------------------------------------------------
// Connect to the database
// -------------------------------------------------------------------------
$mydb = connect2db();
if ($net2ftp_result["success"] == false) {
return false;
}
// -------------------------------------------------------------------------
// Put log rotation status
// -------------------------------------------------------------------------
$sqlquery1 = "SELECT status, changelog FROM net2ftp_log_status WHERE month = '{$currentmonth}';";
$result1 = mysql_query("{$sqlquery1}");
$nrofrows1 = mysql_num_rows($result1);
if ($nrofrows1 == 1) {
$resultRow1 = mysql_fetch_row($result1);
$logStatus_old = $resultRow1[0];
$changelog_old = $resultRow1[1];
$changelog_new = $changelog_old . "From {$logStatus_old} to {$logStatus} on {$datetime}. ";
$sqlquery2 = "UPDATE net2ftp_log_status SET status = '" . $logStatus . "', changelog = '" . $changelog_new . "' WHERE month = '{$currentmonth}';";
$result2 = mysql_query("{$sqlquery2}");
$nrofrows2 = mysql_affected_rows($mydb);
} elseif ($nrofrows1 == 0) {
$changelog_new = "Set to {$logStatus} on {$datetime}. ";
$sqlquery3 = "INSERT INTO net2ftp_log_status VALUES('{$currentmonth}', '" . $logStatus . "', '" . $changelog_new . "');";
$result3 = mysql_query("{$sqlquery3}");
$nrofrows3 = mysql_affected_rows($mydb);
if ($nrofrows3 != 1) {
setErrorVars(false, __("Table net2ftp_log_status could not be updated."), debug_backtrace(), __FILE__, __LINE__);
return false;
}
} else {
setErrorVars(false, __("Table net2ftp_log_status contains duplicate entries."), debug_backtrace(), __FILE__, __LINE__);
return false;
}
// -------------------------------------------------------------------------
// Return true
// -------------------------------------------------------------------------
return true;
}
开发者ID:GTAWWEKID,项目名称:tsiserver.us,代码行数:62,代码来源:logging.inc.php
示例10: net2ftp_module_sendHttpHeaders
//.........这里部分代码省略.........
// Copy all parameters for this file from the $uploadedFilesArray to the $acceptedFilesArray
$acceptedFilesArray["{$moved_counter}"]["tmp_name"] = $tempfilename;
// Overwrite the old temporary name by the new one
}
}
// end for j
flush();
}
// end if elseif
// ------------------------------------
// 3. Move the files from net2ftp's temporary directory to the FTP server.
// ------------------------------------
if (sizeof($acceptedFilesArray) == 0 && sizeof($uploadedFilesArray) != 0) {
echo "WARNING: No files were accepted (see messages above), so nothing will be transferred to the FTP server.<br />\n";
} elseif (sizeof($acceptedFilesArray) > 0) {
// ------------------------------
// 3.1 Open connection
// ------------------------------
// Open connection
echo __("Connecting to the FTP server") . "<br />\n";
$conn_id = ftp_openconnection();
if ($net2ftp_result["success"] == false) {
echo "ERROR: " . $net2ftp_result["errormessage"] . "<br />\n";
return false;
}
// ------------------------------
// For loop (loop over all the files)
// ------------------------------
for ($k = 1; $k <= sizeof($acceptedFilesArray); $k++) {
$file_name = $acceptedFilesArray["{$k}"]["name"];
$file_tmp_name = $acceptedFilesArray["{$k}"]["tmp_name"];
$file_size = $acceptedFilesArray["{$k}"]["size"];
$file_error = $acceptedFilesArray["{$k}"]["error"];
$file_relative_directory = $acceptedFilesArray["{$k}"]["relative_directory"];
$ftpmode = ftpAsciiBinary($file_name);
if ($ftpmode == FTP_ASCII) {
$printftpmode = "FTP_ASCII";
} elseif ($ftpmode == FTP_BINARY) {
$printftpmode = "FTP_BINARY";
}
// ------------------------------
// 3.2 Within the for loop: create the subdirectory if needed
// ------------------------------
// Replace Windows-style backslashes \ by Unix-style slashes /
$file_relative_directory = str_replace("\\", "/", trim($file_relative_directory));
// Get the names of the subdirectories by splitting the string using slashes /
$file_subdirectories = explode("/", $file_relative_directory);
// $targetdirectory contains the successive directories to be created
$targetdirectory = $net2ftp_globals["directory"];
// Loop over sizeof()-1 because the last part is the filename itself:
for ($m = 0; $m < sizeof($file_subdirectories) - 1; $m++) {
// Create the targetdirectory string
$targetdirectory = glueDirectories($targetdirectory, $file_subdirectories[$m]);
// Check if the subdirectories exist
if ($targetdirectory != "") {
$result = @ftp_chdir($conn_id, $targetdirectory);
if ($result == false) {
$ftp_mkdir_result = ftp_mkdir($conn_id, $targetdirectory);
if ($ftp_mkdir_result == false) {
echo "WARNING: Unable to create the directory <b>{$targetdirectory}</b>. The script will try to continue...<br />\n";
continue;
}
echo "Directory {$targetdirectory} created.<br />\n";
}
// end if
flush();
}
// end if
}
// end for m
// Store the $targetdirectory in the $acceptedFilesArray
if ($targetdirectory != "" && $targetdirectory != "/") {
$acceptedFilesArray["{$k}"]["targetdirectory"] = $targetdirectory;
}
// ------------------------------
// 3.3 Within the for loop: put local file to remote file
// ------------------------------
ftp_putfile($conn_id, "", $acceptedFilesArray["{$k}"]["tmp_name"], $acceptedFilesArray["{$k}"]["targetdirectory"], $acceptedFilesArray["{$k}"]["name"], $ftpmode, "move");
if ($net2ftp_result["success"] == false) {
echo "ERROR: File <b>{$file_name}</b> skipped. Message: " . $net2ftp_result["errormessage"] . "<br />\n";
setErrorVars(true, "", "", "", "");
continue;
} else {
echo "The file <b>{$file_name}</b> was transferred to the FTP server successfully. <br />\n";
}
flush();
}
// End for k
// Note: the java applet is looking for the word "SUCCESS" to determine if the upload result is OK or not (see applet parameter stringUploadSuccess)
// The applet doesn't seem to recognize the words "SUCCESS", "WARNING" or "ERROR" when they are issued by the code above
echo "SUCCESS";
// ------------------------------
// 3.4 Close connection
// ------------------------------
ftp_quit($conn_id);
}
// end if
}
// end if $screen == 2
}
开发者ID:GTAWWEKID,项目名称:tsiserver.us,代码行数:101,代码来源:jupload.inc.php
示例11: logError
function logError()
{
// --------------
// This function logs user accesses to the site
//
// IMPORTANT: this function uses, but does not change the global $net2ftp_result[""] variables.
// It returns true on success, false on failure.
// --------------
// -------------------------------------------------------------------------
// Global variables
// -------------------------------------------------------------------------
global $net2ftp_globals, $net2ftp_settings, $net2ftp_result;
if ($net2ftp_settings["log_error"] == "yes") {
// -------------------------------------------------------------------------
// Take a copy of the $net2ftp_result
// If an error occurs within logError, logError will return false and reset the
// $net2ftp_result variable to it's original value
// Also if no error occurs logError will return the variable to it's original value
// -------------------------------------------------------------------------
$net2ftp_result_original = $net2ftp_result;
setErrorVars(true, "", "", "", "");
// -------------------------------------------------------------------------
// Errormessage and debug backtrace
// -------------------------------------------------------------------------
$errormessage = addslashes($net2ftp_result_original["errormessage"]);
$debug_backtrace = "";
$i = sizeof($net2ftp_result_original["debug_backtrace"]) - 1;
if ($i > 0) {
$debug_backtrace .= addslashes("function " . $net2ftp_result_original["debug_backtrace"][$i]["function"] . " (" . $net2ftp_result_original["debug_backtrace"][$i]["file"] . " on line " . $net2ftp_result_original["debug_backtrace"][$i]["line"] . ")\n");
for ($j = 0; $j < sizeof($net2ftp_result_original["debug_backtrace"][$i]["args"]); $j++) {
$debug_backtrace .= addslashes("argument {$j}: " . $net2ftp_result_original["debug_backtrace"][$i]["args"][$j] . "\n");
}
}
// -------------------------------------------------------------------------
// Date and time
// -------------------------------------------------------------------------
$date = date("Y-m-d");
$time = date("H:i:s");
// -------------------------------------------------------------------------
// Logging to the database
// -------------------------------------------------------------------------
if ($net2ftp_settings["use_database"] == "yes") {
// ----------------------------------------------
// Input checks
// ----------------------------------------------
// Add slashes to variables which are used in a SQL query, and which are
// potentially unsafe (supplied by the user).
// $date is calculated in this function
// $time is calculated in this function
$net2ftp_ftpserver_safe = addslashes($net2ftp_globals["ftpserver"]);
$net2ftp_username_safe = addslashes($net2ftp_globals["username"]);
$state_safe = addslashes($net2ftp_globals["state"]);
$state2_safe = addslashes($net2ftp_globals["state2"]);
$directory_safe = addslashes($net2ftp_globals["directory"]);
$REMOTE_ADDR_safe = addslashes($net2ftp_globals["REMOTE_ADDR"]);
$REMOTE_PORT_safe = addslashes($net2ftp_globals["REMOTE_PORT"]);
$HTTP_USER_AGENT_safe = addslashes($net2ftp_globals["HTTP_USER_AGENT"]);
// ----------------------------------------------
// Connect to the DB
// ----------------------------------------------
$mydb = connect2db();
if ($net2ftp_result["success"] == false) {
setErrorVars($net2ftp_result_original["success"], $net2ftp_result_original["errormessage"], $net2ftp_result_original["debug_backtrace"], $net2ftp_result_original["file"], $net2ftp_result_original["line"]);
return false;
}
// ----------------------------------------------
// Add record to the database table
// ----------------------------------------------
$sqlquerystring = "INSERT INTO net2ftp_log_error VALUES('{$date}', '{$time}', '{$net2ftp_ftpserver_safe}', '{$net2ftp_username_safe}', '{$errormessage}', '{$debug_backtrace}', '{$state_safe}', '{$state2_safe}', '{$directory_safe}', '{$REMOTE_ADDR_safe}', '{$REMOTE_PORT_safe}', '{$HTTP_USER_AGENT_safe}')";
$result_mysql_query = @mysql_query($sqlquerystring);
if ($result_mysql_query == false) {
setErrorVars($net2ftp_result_original["success"], $net2ftp_result_original["errormessage"], $net2ftp_result_original["debug_backtrace"], $net2ftp_result_original["file"], $net2ftp_result_original["line"]);
return false;
}
}
// end if use_database
// -------------------------------------------------------------------------
// Logging to the system log
// -------------------------------------------------------------------------
if ($net2ftp_settings["use_syslog"] == "yes") {
// ----------------------------------------------
// Get consumption values
// ----------------------------------------------
if (isset($net2ftp_globals["consumption_datatransfer"]) == true) {
$consumption_datatransfer = $net2ftp_globals["consumption_datatransfer"];
} else {
$consumption_datatransfer = "0";
}
if (isset($net2ftp_globals["consumption_executiontime"]) == true) {
$consumption_executiontime = $net2ftp_globals["consumption_executiontime"];
} else {
$consumption_executiontime = "0";
}
// ----------------------------------------------
// Create message
// ----------------------------------------------
$message2log = "{$date} {$time} " . $net2ftp_globals["ftpserver"] . " " . $net2ftp_globals["username"] . " " . $net2ftp_result["errormessage"] . " {$debug_backtrace} " . $net2ftp_globals["state"] . " " . $net2ftp_globals["state2"] . " " . $net2ftp_globals["directory"] . " " . $net2ftp_globals["REMOTE_ADDR"] . " " . $net2ftp_globals["HTTP_USER_AGENT"];
$result2 = openlog($net2ftp_settings["syslog_ident"], 0, $net2ftp_settings["syslog_facility"]);
if ($result2 == false) {
$errormessage = __("Unable to open the system log.");
//.........这里部分代码省略.........
开发者ID:Jmainguy,项目名称:multicraft_install,代码行数:101,代码来源:authorizations.inc.php
示例12: net2ftp_module_printBody
function net2ftp_module_printBody()
{
// --------------
// This function prints the new directory scre
|
请发表评论