Fix all PHP 8 deprecated/removed function usage across the repository

Agent-Logs-Url: https://github.com/GameServerPanel/GSP/sessions/209fe796-9a38-47c1-a6b7-992ce11d038b

Co-authored-by: iaretechnician <2749183+iaretechnician@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-04-30 13:47:38 +00:00 committed by GitHub
parent 73319ffeed
commit c0bd0a0bb5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
30 changed files with 198 additions and 471 deletions

View file

@ -2692,26 +2692,10 @@ class PHPMailer
if (!is_readable($path)) { if (!is_readable($path)) {
throw new phpmailerException($this->lang('file_open') . $path, self::STOP_CONTINUE); throw new phpmailerException($this->lang('file_open') . $path, self::STOP_CONTINUE);
} }
$magic_quotes = get_magic_quotes_runtime(); // get_magic_quotes_runtime() was removed in PHP 8.0 and always
if ($magic_quotes) { // returned false in PHP 5.4+, so no magic-quotes handling is needed.
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
set_magic_quotes_runtime(false);
} else {
//Doesn't exist in PHP 5.4, but we don't need to check because
//get_magic_quotes_runtime always returns false in 5.4+
//so it will never get here
ini_set('magic_quotes_runtime', false);
}
}
$file_buffer = file_get_contents($path); $file_buffer = file_get_contents($path);
$file_buffer = $this->encodeString($file_buffer, $encoding); $file_buffer = $this->encodeString($file_buffer, $encoding);
if ($magic_quotes) {
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
set_magic_quotes_runtime($magic_quotes);
} else {
ini_set('magic_quotes_runtime', $magic_quotes);
}
}
return $file_buffer; return $file_buffer;
} catch (Exception $exc) { } catch (Exception $exc) {
$this->setError($exc->getMessage()); $this->setError($exc->getMessage());

View file

@ -1055,10 +1055,8 @@ function removeInvalidFileNameCharacters($string){
function deleteMysqlAddonDatabasesForGameServerHome($home_id){ function deleteMysqlAddonDatabasesForGameServerHome($home_id){
global $db, $db_host, $db_user, $db_pass, $db_name, $table_prefix, $db_port; global $db, $db_host, $db_user, $db_pass, $db_name, $table_prefix, $db_port;
if ( function_exists('mysqli_connect') ) // mysqli is always available in PHP 7+; the old mysql extension was removed in PHP 7.
require_once("modules/mysql/mysqli_database.php"); require_once("modules/mysql/mysqli_database.php");
else
require_once("modules/mysql/mysql_database.php");
require_once('includes/lib_remote.php'); require_once('includes/lib_remote.php');
@ -1089,48 +1087,29 @@ function deleteMysqlAddonDatabasesForGameServerHome($home_id){
} }
else else
{ {
if( function_exists('mysqli_connect') ) // mysqli_connect is always available in PHP 7+; the old mysql_*
{ // fallback has been removed as those functions were removed in PHP 7.
mysqli_report(MYSQLI_REPORT_OFF); mysqli_report(MYSQLI_REPORT_OFF);
try { try {
$link = mysqli_connect($mysql_db['mysql_ip'], $mysql_admin_user, $mysql_db['mysql_root_passwd'], "", $mysql_db['mysql_port']); $link = mysqli_connect($mysql_db['mysql_ip'], $mysql_admin_user, $mysql_db['mysql_root_passwd'], "", $mysql_db['mysql_port']);
} catch (Exception $e) { } catch (Exception $e) {
$link = false; $link = false;
} catch (Throwable $e) { } catch (Throwable $e) {
$link = false; $link = false;
}
if ( $link !== FALSE )
{
$queries = array("DROP DATABASE ".$mysql_db['db_name'].";",
"DROP USER '".$mysql_db['db_user']."'@'%';");
foreach ((array)$queries as $query)
{
@$return = mysqli_query($link, $query);
if(!$return)
break;
}
mysqli_close($link);
$db->connect($db_host,$db_user,$db_pass,$db_name,$table_prefix,isset($db_port)?$db_port:NULL);
}
} }
else
if ( $link !== FALSE )
{ {
@$link = mysql_connect($mysql_db['mysql_ip'].':'.$mysql_db['mysql_port'], $mysql_admin_user, $mysql_db['mysql_root_passwd']); $queries = array("DROP DATABASE ".$mysql_db['db_name'].";",
"DROP USER '".$mysql_db['db_user']."'@'%';");
if ( $link !== FALSE ) foreach ((array)$queries as $query)
{ {
$queries = array("DROP DATABASE ".$mysql_db['db_name'].";", @$return = mysqli_query($link, $query);
"DROP USER '".$mysql_db['db_user']."'@'%';"); if(!$return)
foreach ((array)$queries as $query) break;
{
@$return = mysql_query($query);
if(!$return)
break;
}
mysql_close($link);
$db->connect($db_host,$db_user,$db_pass,$db_name,$table_prefix,isset($db_port)?$db_port:NULL);
} }
mysqli_close($link);
$db->connect($db_host,$db_user,$db_pass,$db_name,$table_prefix,isset($db_port)?$db_port:NULL);
} }
} }

View file

@ -262,11 +262,13 @@ class Smarty_Compiler extends Smarty {
reset($this->_folded_blocks); reset($this->_folded_blocks);
/* replace special blocks by "{php}" */ /* replace special blocks by "{php}" */
$source_content = preg_replace_callback($search, create_function ('$matches', "return '" $left_quoted = $this->_quote_replace($this->left_delimiter);
. $this->_quote_replace($this->left_delimiter) . 'php' $right_quoted = $this->_quote_replace($this->right_delimiter);
. "' . str_repeat(\"\n\", substr_count('\$matches[1]', \"\n\")) .'" $source_content = preg_replace_callback($search, function($matches) use ($left_quoted, $right_quoted) {
. $this->_quote_replace($this->right_delimiter) return $left_quoted . 'php'
. "';") . str_repeat("\n", substr_count($matches[1], "\n"))
. $right_quoted;
}
, $source_content); , $source_content);
/* Gather all template tags. */ /* Gather all template tags. */
@ -556,7 +558,8 @@ class Smarty_Compiler extends Smarty {
case 'php': case 'php':
/* handle folded tags replaced by {php} */ /* handle folded tags replaced by {php} */
list(, $block) = each($this->_folded_blocks); list(, $block) = current($this->_folded_blocks);
next($this->_folded_blocks);
$this->_current_line_no += substr_count($block[0], "\n"); $this->_current_line_no += substr_count($block[0], "\n");
/* the number of matched elements in the regexp in _compile_file() /* the number of matched elements in the regexp in _compile_file()
determins the type of folded tag that was found */ determins the type of folded tag that was found */

View file

@ -503,7 +503,7 @@ function getdnsattributes ($l,$ip){
$r->nameservers = array("ws1.maxmind.com"); $r->nameservers = array("ws1.maxmind.com");
$p = $r->search($l."." . $ip .".s.maxmind.com","TXT","IN"); $p = $r->search($l."." . $ip .".s.maxmind.com","TXT","IN");
$str = is_object($p->answer[0])?$p->answer[0]->string():''; $str = is_object($p->answer[0])?$p->answer[0]->string():'';
ereg("\"(.*)\"",$str,$regs); preg_match('/\"(.*)\"/', $str, $regs);
$str = $regs[1]; $str = $regs[1];
return $str; return $str;
} }

View file

@ -611,14 +611,14 @@ function getRootdirectory() {
// Get user's home directory // Get user's home directory
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
$sqlquery1 = "SELECT homedirectory FROM net2ftp_users WHERE ftpserver = '$net2ftp_ftpserver_safe' AND username = '$net2ftp_username_safe';"; $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"); $result1 = mysqli_query($mydb, "$sqlquery1") or die("Unable to execute SQL SELECT query (isAuthorizedDirectory > sqlquery1) <br /> $sqlquery1");
$nrofrows1 = mysql_num_rows($result1); $nrofrows1 = mysqli_num_rows($result1);
if ($nrofrows1 == 0) { if ($nrofrows1 == 0) {
$net2ftp_globals["homedirectory"] = "/"; $net2ftp_globals["homedirectory"] = "/";
} }
elseif ($nrofrows1 == 1) { elseif ($nrofrows1 == 1) {
$resultRow1 = mysql_fetch_row($result1); $resultRow1 = mysqli_fetch_row($result1);
$net2ftp_globals["homedirectory"] = $resultRow1[0]; $net2ftp_globals["homedirectory"] = $resultRow1[0];
} }
else { else {

View file

@ -120,15 +120,15 @@ function getConsumption() {
// Get consumed data volume and execution time by the current IP address // Get consumed data volume and execution time by the current IP address
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
$sqlquery1 = "SELECT datatransfer, executiontime FROM net2ftp_log_consumption_ipaddress WHERE date = '$date' AND ipaddress = '$REMOTE_ADDR_safe';"; $sqlquery1 = "SELECT datatransfer, executiontime FROM net2ftp_log_consumption_ipaddress WHERE date = '$date' AND ipaddress = '$REMOTE_ADDR_safe';";
$result1 = mysql_query("$sqlquery1") or die("Unable to execute SQL SELECT query (getConsumption > sqlquery1) <br /> $sqlquery1"); $result1 = mysqli_query($mydb, "$sqlquery1") or die("Unable to execute SQL SELECT query (getConsumption > sqlquery1) <br /> $sqlquery1");
$nrofrows1 = mysql_num_rows($result1); $nrofrows1 = mysqli_num_rows($result1);
if ($nrofrows1 == 0) { if ($nrofrows1 == 0) {
$net2ftp_globals["consumption_ipaddress_datatransfer"] = 0; $net2ftp_globals["consumption_ipaddress_datatransfer"] = 0;
$net2ftp_globals["consumption_ipaddress_executiontime"] = 0; $net2ftp_globals["consumption_ipaddress_executiontime"] = 0;
} }
elseif ($nrofrows1 == 1) { elseif ($nrofrows1 == 1) {
$resultRow1 = mysql_fetch_row($result1); $resultRow1 = mysqli_fetch_row($result1);
$net2ftp_globals["consumption_ipaddress_datatransfer"] = $resultRow1[0]; $net2ftp_globals["consumption_ipaddress_datatransfer"] = $resultRow1[0];
$net2ftp_globals["consumption_ipaddress_executiontime"] = $resultRow1[1]; $net2ftp_globals["consumption_ipaddress_executiontime"] = $resultRow1[1];
} }
@ -141,15 +141,15 @@ function getConsumption() {
// Get consumed data volume and execution time to the current FTP server // Get consumed data volume and execution time to the current FTP server
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
$sqlquery2 = "SELECT datatransfer, executiontime FROM net2ftp_log_consumption_ftpserver WHERE date = '$date' AND ftpserver = '$net2ftp_ftpserver_safe';"; $sqlquery2 = "SELECT datatransfer, executiontime FROM net2ftp_log_consumption_ftpserver WHERE date = '$date' AND ftpserver = '$net2ftp_ftpserver_safe';";
$result2 = mysql_query("$sqlquery2") or die("Unable to execute SQL SELECT query (getConsumption > sqlquery2) <br /> $sqlquery2"); $result2 = mysqli_query($mydb, "$sqlquery2") or die("Unable to execute SQL SELECT query (getConsumption > sqlquery2) <br /> $sqlquery2");
$nrofrows2 = mysql_num_rows($result2); $nrofrows2 = mysqli_num_rows($result2);
if ($nrofrows2 == 0) { if ($nrofrows2 == 0) {
$net2ftp_globals["consumption_ftpserver_datatransfer"] = 0; $net2ftp_globals["consumption_ftpserver_datatransfer"] = 0;
$net2ftp_globals["consumption_ftpserver_executiontime"] = 0; $net2ftp_globals["consumption_ftpserver_executiontime"] = 0;
} }
elseif ($nrofrows2 == 1) { elseif ($nrofrows2 == 1) {
$resultRow2 = mysql_fetch_row($result2); $resultRow2 = mysqli_fetch_row($result2);
$net2ftp_globals["consumption_ftpserver_datatransfer"] = $resultRow2[0]; $net2ftp_globals["consumption_ftpserver_datatransfer"] = $resultRow2[0];
$net2ftp_globals["consumption_ftpserver_executiontime"] = $resultRow2[1]; $net2ftp_globals["consumption_ftpserver_executiontime"] = $resultRow2[1];
} }
@ -251,13 +251,13 @@ function putConsumption() {
// Put consumed data volume and execution time by the current IP address // 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';"; $sqlquery1 = "SELECT * FROM net2ftp_log_consumption_ipaddress WHERE date = '$date' AND ipaddress = '$REMOTE_ADDR_safe';";
$result1 = mysql_query("$sqlquery1"); $result1 = mysqli_query($mydb, "$sqlquery1");
$nrofrows1 = mysql_num_rows($result1); $nrofrows1 = mysqli_num_rows($result1);
if ($nrofrows1 == 1) { 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';"; $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"); $result2 = mysqli_query($mydb, "$sqlquery2");
$nrofrows2 = mysql_affected_rows($mydb); $nrofrows2 = mysqli_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, // 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 // 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.) // and the executiontime is the same as in the table.)
@ -268,8 +268,8 @@ function putConsumption() {
} }
elseif ($nrofrows1 == 0) { 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"]) . "');"; $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"); $result3 = mysqli_query($mydb, "$sqlquery3");
$nrofrows3 = mysql_affected_rows($mydb); $nrofrows3 = mysqli_affected_rows($mydb);
if ($nrofrows3 != 1) { if ($nrofrows3 != 1) {
setErrorVars(false, __("Table net2ftp_log_consumption_ipaddress could not be updated."), debug_backtrace(), __FILE__, __LINE__); setErrorVars(false, __("Table net2ftp_log_consumption_ipaddress could not be updated."), debug_backtrace(), __FILE__, __LINE__);
return false; return false;
@ -288,13 +288,13 @@ function putConsumption() {
// Put consumed data volume and execution time to the current FTP server // 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';"; $sqlquery4 = "SELECT * FROM net2ftp_log_consumption_ftpserver WHERE date = '$date' AND ftpserver = '$net2ftp_ftpserver_safe';";
$result4 = mysql_query("$sqlquery4"); $result4 = mysqli_query($mydb, "$sqlquery4");
$nrofrows4 = mysql_num_rows($result4); $nrofrows4 = mysqli_num_rows($result4);
if ($nrofrows4 == 1) { 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';"; $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"); $result5 = mysqli_query($mydb, "$sqlquery5");
$nrofrows5 = mysql_affected_rows($mydb); $nrofrows5 = mysqli_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, // 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 // 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.) // and the executiontime is the same as in the table.)
@ -305,8 +305,8 @@ function putConsumption() {
} }
elseif ($nrofrows4 == 0) { elseif ($nrofrows4 == 0) {
$sqlquery6 = "INSERT INTO net2ftp_log_consumption_ftpserver VALUES('$date', '$net2ftp_ftpserver_safe', '" . $net2ftp_globals["consumption_ftpserver_datatransfer"] . "', '" . round($net2ftp_globals["consumption_ftpserver_executiontime"]) . "');"; $sqlquery6 = "INSERT INTO net2ftp_log_consumption_ftpserver VALUES('$date', '$net2ftp_ftpserver_safe', '" . $net2ftp_globals["consumption_ftpserver_datatransfer"] . "', '" . round($net2ftp_globals["consumption_ftpserver_executiontime"]) . "');";
$result6 = mysql_query("$sqlquery6"); $result6 = mysqli_query($mydb, "$sqlquery6");
$nrofrows6 = mysql_affected_rows($mydb); $nrofrows6 = mysqli_affected_rows($mydb);
if ($nrofrows6 != 1) { if ($nrofrows6 != 1) {
setErrorVars(false, __("Table net2ftp_log_consumption_ftpserver could not be updated."), debug_backtrace(), __FILE__, __LINE__); setErrorVars(false, __("Table net2ftp_log_consumption_ftpserver could not be updated."), debug_backtrace(), __FILE__, __LINE__);
return false; return false;
@ -321,13 +321,13 @@ function putConsumption() {
// Update the net2ftp_log_access record with the consumed data volume and execution time // Update the net2ftp_log_access record with the consumed data volume and execution time
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
$sqlquery7 = "SELECT * FROM net2ftp_log_access WHERE id = '" . $net2ftp_globals["log_access_id"] . "';"; $sqlquery7 = "SELECT * FROM net2ftp_log_access WHERE id = '" . $net2ftp_globals["log_access_id"] . "';";
$result7 = mysql_query("$sqlquery7"); $result7 = mysqli_query($mydb, "$sqlquery7");
$nrofrows7 = mysql_num_rows($result7); $nrofrows7 = mysqli_num_rows($result7);
if ($nrofrows7 == 1) { if ($nrofrows7 == 1) {
$sqlquery8 = "UPDATE net2ftp_log_access SET datatransfer = '" . $net2ftp_globals["consumption_datatransfer"] . "', executiontime = '" . round($net2ftp_globals["consumption_executiontime"]) . "' WHERE id = '" . $net2ftp_globals["log_access_id"] . "'"; $sqlquery8 = "UPDATE net2ftp_log_access SET datatransfer = '" . $net2ftp_globals["consumption_datatransfer"] . "', executiontime = '" . round($net2ftp_globals["consumption_executiontime"]) . "' WHERE id = '" . $net2ftp_globals["log_access_id"] . "'";
$result8 = mysql_query("$sqlquery8"); $result8 = mysqli_query($mydb, "$sqlquery8");
$nrofrows8 = mysql_affected_rows($mydb); $nrofrows8 = mysqli_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, // 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 // 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.) // and the executiontime is the same as in the table.)
@ -338,8 +338,8 @@ function putConsumption() {
} }
elseif ($nrofrows7 == 0) { elseif ($nrofrows7 == 0) {
$sqlquery9 = "INSERT INTO net2ftp_log_access VALUES('$date', '$REMOTE_ADDR_safe', '" . $net2ftp_globals["consumption_ipaddress_datatransfer"] . "', '" . round($net2ftp_globals["consumption_ipaddress_executiontime"]) . "');"; $sqlquery9 = "INSERT INTO net2ftp_log_access VALUES('$date', '$REMOTE_ADDR_safe', '" . $net2ftp_globals["consumption_ipaddress_datatransfer"] . "', '" . round($net2ftp_globals["consumption_ipaddress_executiontime"]) . "');";
$result9 = mysql_query("$sqlquery9"); $result9 = mysqli_query($mydb, "$sqlquery9");
$nrofrows9 = mysql_affected_rows($mydb); $nrofrows9 = mysqli_affected_rows($mydb);
if ($nrofrows9 != 1) { if ($nrofrows9 != 1) {
setErrorVars(false, __("Table net2ftp_log_access could not be updated."), debug_backtrace(), __FILE__, __LINE__); setErrorVars(false, __("Table net2ftp_log_access could not be updated."), debug_backtrace(), __FILE__, __LINE__);
return false; return false;

View file

@ -28,18 +28,12 @@ function connect2db() {
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
global $net2ftp_settings; global $net2ftp_settings;
$mydb = mysql_connect($net2ftp_settings["dbserver"], $net2ftp_settings["dbusername"], $net2ftp_settings["dbpassword"]); $mydb = mysqli_connect($net2ftp_settings["dbserver"], $net2ftp_settings["dbusername"], $net2ftp_settings["dbpassword"], $net2ftp_settings["dbname"]);
if ($mydb == false) { 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__); 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; 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; return $mydb;
} // End connect2db } // End connect2db

View file

@ -2953,12 +2953,12 @@ function checkEmailAddress($email) {
// Returns true for valid email addresses, false for non-valid email addresses // Returns true for valid email addresses, false for non-valid email addresses
// -------------- // --------------
if (eregi( "^" . if (preg_match( "/^" .
"[a-z0-9]+([_\.-][a-z0-9]+)*" . //user "[a-z0-9]+([_\.-][a-z0-9]+)*" . //user
"@" . "@" .
"([a-z0-9]+([\.-][a-z0-9]+)*)+" . //domain "([a-z0-9]+([\.-][a-z0-9]+)*)+" . //domain
"\\.[a-z]{2,}" . //sld, tld "\\.[a-z]{2,}" . //sld, tld
"$", $email, $regs)) { return true; } "$/i", $email, $regs)) { return true; }
else { return false; } else { return false; }
} // end checkEmailAddress } // end checkEmailAddress
@ -3326,12 +3326,12 @@ $AttmFiles ... array containing the filenames to attach like array("file1","file
} }
// Check if the To email address is valid // Check if the To email address is valid
if (!eregi( "^" . if (!preg_match( "/^" .
"[a-zA-Z0-9]+([_\.-][a-zA-Z0-9]+)*" . //user "[a-zA-Z0-9]+([_\.-][a-zA-Z0-9]+)*" . //user
"@" . "@" .
"([a-zA-Z0-9]+([\.-][a-zA-Z0-9]+)*)+" . //domain "([a-zA-Z0-9]+([\.-][a-zA-Z0-9]+)*)+" . //domain
"\\.[a-zA-Z]{2,}" . //sld, tld "\\.[a-zA-Z]{2,}" . //sld, tld
"$", $To, $regs)) { "$/i", $To, $regs)) {
$errormessage = __("The email address you have entered (%1\$s) does not seem to be valid.<br />Please enter an address in the format <b>username@domain.com</b>", $To); $errormessage = __("The email address you have entered (%1\$s) does not seem to be valid.<br />Please enter an address in the format <b>username@domain.com</b>", $To);
setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__); setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__);
return false; return false;

View file

@ -93,16 +93,16 @@ function logAccess() {
// Add record to the database table // Add record to the database table
// ---------------------------------------------- // ----------------------------------------------
$sqlquery1 = "INSERT INTO net2ftp_log_access VALUES(null, '$date', '$time', '$REMOTE_ADDR_safe', '$REMOTE_PORT_safe', '$HTTP_USER_AGENT_safe', '$PHP_SELF_safe', '$consumption_datatransfer_safe', '$consumption_executiontime_safe', '$net2ftp_ftpserver_safe', '$net2ftp_username_safe', '$state_safe', '$state2_safe', '$screen_safe', '$directory_safe', '$entry_safe', '$HTTP_REFERER_safe')"; $sqlquery1 = "INSERT INTO net2ftp_log_access VALUES(null, '$date', '$time', '$REMOTE_ADDR_safe', '$REMOTE_PORT_safe', '$HTTP_USER_AGENT_safe', '$PHP_SELF_safe', '$consumption_datatransfer_safe', '$consumption_executiontime_safe', '$net2ftp_ftpserver_safe', '$net2ftp_username_safe', '$state_safe', '$state2_safe', '$screen_safe', '$directory_safe', '$entry_safe', '$HTTP_REFERER_safe')";
$result1 = mysql_query($sqlquery1); $result1 = mysqli_query($mydb, $sqlquery1);
if ($result1 == false) { if ($result1 == false) {
$errormessage = __("Unable to execute the SQL query."); $errormessage = __("Unable to execute the SQL query.");
setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__); setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__);
return false; return false;
} }
$nrofrows1 = mysql_affected_rows($mydb); $nrofrows1 = mysqli_affected_rows($mydb);
$net2ftp_globals["log_access_id"] = mysql_insert_id(); $net2ftp_globals["log_access_id"] = mysqli_insert_id($mydb);
} // end if use_database } // end if use_database
@ -256,7 +256,7 @@ function logError() {
// Add record to the database table // 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')"; $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); $result_mysql_query = mysqli_query($mydb, $sqlquerystring);
if ($result_mysql_query == false) { 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"]); setErrorVars($net2ftp_result_original["success"], $net2ftp_result_original["errormessage"], $net2ftp_result_original["debug_backtrace"], $net2ftp_result_original["file"], $net2ftp_result_original["line"]);
return false; return false;
@ -365,14 +365,14 @@ function getLogStatus() {
// Get log rotation status // Get log rotation status
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
$sqlquery1 = "SELECT status FROM net2ftp_log_status WHERE month = '$currentmonth';"; $sqlquery1 = "SELECT status FROM net2ftp_log_status WHERE month = '$currentmonth';";
$result1 = mysql_query("$sqlquery1") or die("Unable to execute SQL SELECT query (getLogStatus > sqlquery1) <br /> $sqlquery1"); $result1 = mysqli_query($mydb, "$sqlquery1") or die("Unable to execute SQL SELECT query (getLogStatus > sqlquery1) <br /> $sqlquery1");
$nrofrows1 = mysql_num_rows($result1); $nrofrows1 = mysqli_num_rows($result1);
if ($nrofrows1 == 0) { if ($nrofrows1 == 0) {
$logStatus = 1; $logStatus = 1;
} }
elseif ($nrofrows1 == 1) { elseif ($nrofrows1 == 1) {
$resultRow1 = mysql_fetch_row($result1); $resultRow1 = mysqli_fetch_row($result1);
$logStatus = $resultRow1[0]; $logStatus = $resultRow1[0];
} }
else { else {
@ -434,25 +434,25 @@ function putLogStatus($logStatus) {
// Put log rotation status // Put log rotation status
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
$sqlquery1 = "SELECT status, changelog FROM net2ftp_log_status WHERE month = '$currentmonth';"; $sqlquery1 = "SELECT status, changelog FROM net2ftp_log_status WHERE month = '$currentmonth';";
$result1 = mysql_query("$sqlquery1"); $result1 = mysqli_query($mydb, "$sqlquery1");
$nrofrows1 = mysql_num_rows($result1); $nrofrows1 = mysqli_num_rows($result1);
if ($nrofrows1 == 1) { if ($nrofrows1 == 1) {
$resultRow1 = mysql_fetch_row($result1); $resultRow1 = mysqli_fetch_row($result1);
$logStatus_old = $resultRow1[0]; $logStatus_old = $resultRow1[0];
$changelog_old = $resultRow1[1]; $changelog_old = $resultRow1[1];
$changelog_new = $changelog_old . "From $logStatus_old to $logStatus on $datetime. "; $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';"; $sqlquery2 = "UPDATE net2ftp_log_status SET status = '" . $logStatus . "', changelog = '" . $changelog_new . "' WHERE month = '$currentmonth';";
$result2 = mysql_query("$sqlquery2"); $result2 = mysqli_query($mydb, "$sqlquery2");
$nrofrows2 = mysql_affected_rows($mydb); $nrofrows2 = mysqli_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, // 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. // the $nrofrows2 is set to 0.
elseif ($nrofrows1 == 0) { elseif ($nrofrows1 == 0) {
$changelog_new = "Set to $logStatus on $datetime. "; $changelog_new = "Set to $logStatus on $datetime. ";
$sqlquery3 = "INSERT INTO net2ftp_log_status VALUES('$currentmonth', '" . $logStatus . "', '" . $changelog_new . "');"; $sqlquery3 = "INSERT INTO net2ftp_log_status VALUES('$currentmonth', '" . $logStatus . "', '" . $changelog_new . "');";
$result3 = mysql_query("$sqlquery3"); $result3 = mysqli_query($mydb, "$sqlquery3");
$nrofrows3 = mysql_affected_rows($mydb); $nrofrows3 = mysqli_affected_rows($mydb);
if ($nrofrows3 != 1) { if ($nrofrows3 != 1) {
setErrorVars(false, __("Table net2ftp_log_status could not be updated."), debug_backtrace(), __FILE__, __LINE__); setErrorVars(false, __("Table net2ftp_log_status could not be updated."), debug_backtrace(), __FILE__, __LINE__);
return false; return false;
@ -516,10 +516,10 @@ function emptyLogs($datefrom, $dateto) {
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
for ($i=1; $i<=sizeof($tables); $i++) { for ($i=1; $i<=sizeof($tables); $i++) {
$sqlquery_empty = "DELETE FROM $tables[$i] WHERE date BETWEEN '$datefrom' AND '$dateto';"; $sqlquery_empty = "DELETE FROM $tables[$i] WHERE date BETWEEN '$datefrom' AND '$dateto';";
$result_empty[$i] = mysql_query("$sqlquery_empty"); $result_empty[$i] = mysqli_query($mydb, "$sqlquery_empty");
$sqlquery_optimize = "OPTIMIZE TABLE `" . $tables[$i] . "`;"; $sqlquery_optimize = "OPTIMIZE TABLE `" . $tables[$i] . "`;";
$result_optimize[$i] = mysql_query("$sqlquery_optimize"); $result_optimize[$i] = mysqli_query($mydb, "$sqlquery_optimize");
if ($result_empty[$i] == true) { if ($result_empty[$i] == true) {
$net2ftp_output["emptyLogs"][] = __("The table <b>%1\$s</b> was emptied successfully.", $tables[$i]); $net2ftp_output["emptyLogs"][] = __("The table <b>%1\$s</b> was emptied successfully.", $tables[$i]);
@ -641,7 +641,7 @@ function rotateLogs() {
$table_archive_drop = $table . "_" . $dropmonth; // Example: net2ftp_log_access_201106 $table_archive_drop = $table . "_" . $dropmonth; // Example: net2ftp_log_access_201106
$sqlquery_rename = "RENAME TABLE $table TO $table_archive"; $sqlquery_rename = "RENAME TABLE $table TO $table_archive";
$result_rename[$i] = mysql_query("$sqlquery_rename"); $result_rename[$i] = mysqli_query($mydb, "$sqlquery_rename");
if ($result_rename[$i] == true) { if ($result_rename[$i] == true) {
$net2ftp_output["rotateLogs"][] = __("The log tables were renamed successfully."); $net2ftp_output["rotateLogs"][] = __("The log tables were renamed successfully.");
@ -673,7 +673,7 @@ function rotateLogs() {
$table_archive_drop = $table . "_" . $dropmonth; // Example: net2ftp_log_access_201106 $table_archive_drop = $table . "_" . $dropmonth; // Example: net2ftp_log_access_201106
$sqlquery_copy = "CREATE TABLE $table LIKE $table_archive"; $sqlquery_copy = "CREATE TABLE $table LIKE $table_archive";
$result_copy[$i] = mysql_query("$sqlquery_copy"); $result_copy[$i] = mysqli_query($mydb, "$sqlquery_copy");
if ($result_copy[$i] == true) { if ($result_copy[$i] == true) {
$net2ftp_output["rotateLogs"][] = __("The log tables were copied successfully."); $net2ftp_output["rotateLogs"][] = __("The log tables were copied successfully.");
@ -705,7 +705,7 @@ function rotateLogs() {
$table_archive_drop = $table . "_" . $dropmonth; // Example: net2ftp_log_access_201106 $table_archive_drop = $table . "_" . $dropmonth; // Example: net2ftp_log_access_201106
$sqlquery_drop = "DROP TABLE IF EXISTS $table_archive_drop;"; $sqlquery_drop = "DROP TABLE IF EXISTS $table_archive_drop;";
$result_drop[$i] = mysql_query("$sqlquery_drop"); $result_drop[$i] = mysqli_query($mydb, "$sqlquery_drop");
if ($result_drop[$i] == true) { if ($result_drop[$i] == true) {
$net2ftp_output["rotateLogs"][] = __("The oldest log table was dropped successfully."); $net2ftp_output["rotateLogs"][] = __("The oldest log table was dropped successfully.");

View file

@ -5335,24 +5335,9 @@ echo "p entry filename 2 is " . $p_entry['filename'] . " <br />\n";
{ {
$v_result=1; $v_result=1;
// ----- Look if function exists // get_magic_quotes_runtime() and set_magic_quotes_runtime() were removed
if ( (!function_exists("get_magic_quotes_runtime")) // in PHP 8.0. Magic quotes were always disabled from PHP 5.4 onward,
|| (!function_exists("set_magic_quotes_runtime"))) { // so there is nothing to do here.
return $v_result;
}
// ----- Look if already done
if ($this->magic_quotes_status != -1) {
return $v_result;
}
// ----- Get and memorize the magic_quote value
$this->magic_quotes_status = @get_magic_quotes_runtime();
// ----- Disable magic_quotes
if ($this->magic_quotes_status == 1) {
@set_magic_quotes_runtime(0);
}
// ----- Return // ----- Return
return $v_result; return $v_result;
@ -5369,21 +5354,9 @@ echo "p entry filename 2 is " . $p_entry['filename'] . " <br />\n";
{ {
$v_result=1; $v_result=1;
// ----- Look if function exists // get_magic_quotes_runtime() and set_magic_quotes_runtime() were removed
if ( (!function_exists("get_magic_quotes_runtime")) // in PHP 8.0. Magic quotes were always disabled from PHP 5.4 onward,
|| (!function_exists("set_magic_quotes_runtime"))) { // so there is nothing to restore here.
return $v_result;
}
// ----- Look if something to do
if ($this->magic_quotes_status != -1) {
return $v_result;
}
// ----- Swap back magic_quotes
if ($this->magic_quotes_status == 1) {
@set_magic_quotes_runtime($this->magic_quotes_status);
}
// ----- Return // ----- Return
return $v_result; return $v_result;

View file

@ -31,11 +31,8 @@ defined("NET2FTP") or die("Direct access to this location is not allowed.");
// 1 When a variable is submitted, quotes ' are replaced by backslash-quotes \' // 1 When a variable is submitted, quotes ' are replaced by backslash-quotes \'
// This function removes the extra backslash that is added // This function removes the extra backslash that is added
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
if (get_magic_quotes_gpc() == 1) { // Note: get_magic_quotes_gpc() was removed in PHP 8.0; magic quotes are
remove_magic_quotes($_POST); // always disabled on PHP 5.4+ so no stripping is needed.
remove_magic_quotes($_GET);
remove_magic_quotes($_COOKIE);
}
// Do not add remove_magic_quotes for $GLOBALS because this would call the same // Do not add remove_magic_quotes for $GLOBALS because this would call the same
// function a second time, replacing \' by ' and \" by " // function a second time, replacing \' by ' and \" by "
@ -432,28 +429,9 @@ $net2ftp_globals["browser_platform"] = getBrowser("platform");
function remove_magic_quotes(&$x, $keyname="") { function remove_magic_quotes(&$x, $keyname="") {
// http://www.php.net/manual/en/configuration.php#ini.magic-quotes-gpc (by the way: gpc = get post cookie) // get_magic_quotes_gpc() was removed in PHP 8.0; magic quotes are always
// if (magic_quotes_gpc == 1), then PHP converts automatically " --> \", ' --> \' // disabled on PHP 5.4+, so this function is now a no-op kept for
// Has only to be done when getting info from get post cookie // compatibility with any callers that may still reference it.
if (get_magic_quotes_gpc() == 1) {
if (is_array($x)) {
while (list($key,$value) = each($x)) {
if ($value) { remove_magic_quotes($x[$key],$key); }
}
}
else {
$quote = "'";
$doublequote = "\"";
$backslash = "\\";
$x = str_replace("$backslash$quote", $quote, $x);
$x = str_replace("$backslash$doublequote", $doublequote, $x);
$x = str_replace("$backslash$backslash", $backslash, $x);
}
} // end if get_magic_quotes_gpc
return $x; return $x;
} // end function remove_magic_quotes } // end function remove_magic_quotes

View file

@ -119,13 +119,13 @@ function printLanguageSelect($fieldname, $onchange, $style, $class) {
echo "<select name=\"$fieldname\" id=\"$fieldname\" $onchange_full $style_full $class_full>\n"; echo "<select name=\"$fieldname\" id=\"$fieldname\" $onchange_full $style_full $class_full>\n";
while (list($key,$value) = each($languageArray)) { foreach ($languageArray as $key => $value) {
// $key loops over "en", "fr", "nl", ... // $key loops over "en", "fr", "nl", ...
// $value will be an array like $value["name"] = "English" and $value["file"] = "en.inc.php" // $value will be an array like $value["name"] = "English" and $value["file"] = "en.inc.php"
if ($key == $currentlanguage) { $selected = "selected=\"selected\""; } if ($key == $currentlanguage) { $selected = "selected=\"selected\""; }
else { $selected = ""; } else { $selected = ""; }
echo "<option value=\"" . $key . "\" $selected>" . $value["name"] . "</option>\n"; echo "<option value=\"" . $key . "\" $selected>" . $value["name"] . "</option>\n";
} // end while } // end foreach
echo "</select>\n"; echo "</select>\n";

View file

@ -225,14 +225,14 @@ function net2ftp_module_printBody() {
// ------------------------------------ // ------------------------------------
// Connect // Connect
// ------------------------------------ // ------------------------------------
$mydb = mysql_connect($dbserver2, $dbusername2, $dbpassword2); $mydb = mysqli_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"; } 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 // Select
// ------------------------------------ // ------------------------------------
if ($mydb != false) { if ($mydb != false) {
$mysql_select_db_result = mysql_select_db($dbname2); $mysql_select_db_result = mysqli_select_db($mydb, $dbname2);
if ($mysql_select_db_result == false) { $net2ftp_output["admin_createtables"][] = __("Unable to select the database <b>%1\$s</b>.", $dbserver2_html) . "\n"; } if ($mysql_select_db_result == false) { $net2ftp_output["admin_createtables"][] = __("Unable to select the database <b>%1\$s</b>.", $dbserver2_html) . "\n"; }
} }
@ -241,7 +241,7 @@ function net2ftp_module_printBody() {
// ------------------------------------ // ------------------------------------
if ($mydb != false && $mysql_select_db_result != false) { if ($mydb != false && $mysql_select_db_result != false) {
for ($i=0; $i<sizeof($sqlquerypieces); $i++) { for ($i=0; $i<sizeof($sqlquerypieces); $i++) {
$mysql_query_results[$i] = mysql_query($sqlquerypieces[$i]); $mysql_query_results[$i] = mysqli_query($mydb, $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"; } 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"; } else { $net2ftp_output["admin_createtables"][] = __("The SQL query nr <b>%1\$s</b> was executed successfully.", $i+1) . "\n"; }
} }

View file

@ -237,14 +237,14 @@ function printTable($sqlquery) {
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// Execute the SQL query // Execute the SQL query
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
$result = mysql_query("$sqlquery"); $result = mysqli_query($mydb, "$sqlquery");
if ($result == false) { if ($result == false) {
$errormessage = __("Unable to execute the SQL query <b>%1\$s</b>.", $sqlquery); $errormessage = __("Unable to execute the SQL query <b>%1\$s</b>.", $sqlquery);
setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__); setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__);
return false; return false;
} }
$nrofrows = mysql_num_rows($result); $nrofrows = mysqli_num_rows($result);
$nrofcolumns_withindex = mysql_num_fields($result) + 1; $nrofcolumns_withindex = mysqli_num_fields($result) + 1;
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
@ -260,19 +260,19 @@ function printTable($sqlquery) {
if ($nrofrows != 0) { if ($nrofrows != 0) {
// Second row: header // Second row: header
$row = mysql_fetch_array($result, MYSQL_ASSOC); $row = mysqli_fetch_array($result, MYSQLI_ASSOC);
$output .= "<tr>\n"; $output .= "<tr>\n";
$output .= "<td>Index</td>\n"; $output .= "<td>Index</td>\n";
while(list($fieldname, $fieldvalue) = each($row) ) { $output .= "<td>$fieldname</td>\n"; } foreach ($row as $fieldname => $fieldvalue) { $output .= "<td>$fieldname</td>\n"; }
$output .= "</tr>\n"; $output .= "</tr>\n";
mysql_data_seek($result, 0); // reset row pointer to the first row mysqli_data_seek($result, 0); // reset row pointer to the first row
// 3rd and next rows: data // 3rd and next rows: data
$rowcounter = 1; $rowcounter = 1;
while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
$output .= "<tr>\n"; $output .= "<tr>\n";
$output .= "<td>$rowcounter</td>\n"; $output .= "<td>$rowcounter</td>\n";
while(list($fieldname, $fieldvalue) = each($row) ) { $output .= "<td>" . htmlEncode2($fieldvalue) . "</td>\n"; } foreach ($row as $fieldname => $fieldvalue) { $output .= "<td>" . htmlEncode2($fieldvalue) . "</td>\n"; }
$output .= "</tr>\n"; $output .= "</tr>\n";
$rowcounter++; $rowcounter++;
} }
@ -289,7 +289,7 @@ function printTable($sqlquery) {
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// Free the $result // Free the $result
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
mysql_free_result($result); mysqli_free_result($result);
return $output; return $output;

View file

@ -160,7 +160,7 @@ function net2ftp_module_printBody() {
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// For each sample // For each sample
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
while(list($sampleName, $sampleLines) = each($list_samples)) { foreach ($list_samples as $sampleName => $sampleLines) {
$net2ftp_output["advanced_parsing"][] = "<span style=\"font-size: 120%; font-weight: bold;\">" . $sampleName . "</span><br />\n"; $net2ftp_output["advanced_parsing"][] = "<span style=\"font-size: 120%; font-weight: bold;\">" . $sampleName . "</span><br />\n";
// ------------------------------------ // ------------------------------------
// Input // Input
@ -179,9 +179,9 @@ function net2ftp_module_printBody() {
// Scan the sample // Scan the sample
$outputArray = ftp_scanline("", $sampleLines[$i]); $outputArray = ftp_scanline("", $sampleLines[$i]);
while(list($fieldName, $fieldValue) = each($outputArray)) { foreach ($outputArray as $fieldName => $fieldValue) {
$net2ftp_output["advanced_parsing"][] = "Line $i: " . $fieldName . ": " . htmlEncode2($fieldValue) . "<br />\n"; $net2ftp_output["advanced_parsing"][] = "Line $i: " . $fieldName . ": " . htmlEncode2($fieldValue) . "<br />\n";
} // end while } // end foreach
$net2ftp_output["advanced_parsing"][] = "<br />\n"; $net2ftp_output["advanced_parsing"][] = "<br />\n";
} }
$net2ftp_output["advanced_parsing"][] = "<br /><br />\n"; $net2ftp_output["advanced_parsing"][] = "<br /><br />\n";

View file

@ -347,7 +347,7 @@ function net2ftp_module_printBody() {
$icon_directory = $net2ftp_globals["application_rootdir_url"] . "/skins/" . $net2ftp_globals["skin"] . "/images/mime"; $icon_directory = $net2ftp_globals["application_rootdir_url"] . "/skins/" . $net2ftp_globals["skin"] . "/images/mime";
// Loop over all the sort possibilities // Loop over all the sort possibilities
while(list($key, $value) = each($sortArray)) { foreach ($sortArray as $key => $value) {
// The list is sorted by the current $key // The list is sorted by the current $key
// Print the icon representing the current sortorder // Print the icon representing the current sortorder
@ -549,7 +549,7 @@ function sort_list($list) {
// Fill the $return array // Fill the $return array
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
$i=1; $i=1;
while(list($tname, $tvalue) = each($temp)) { foreach ($temp as $tname => $tvalue) {
$return[$i] = $list[$tname]; $return[$i] = $list[$tname];
$i++; $i++;
} }

View file

@ -480,7 +480,7 @@ function printTextareaSelect($onchange) {
if ($textareaType == "" || $textareaType == "plain") { $plainselected = "selected=\"selected\""; } if ($textareaType == "" || $textareaType == "plain") { $plainselected = "selected=\"selected\""; }
echo "<option value=\"plain\" $plainselected>Normal textarea</option>\n"; echo "<option value=\"plain\" $plainselected>Normal textarea</option>\n";
while(list($pluginName, $value) = each($pluginProperties)) { foreach ($pluginProperties as $pluginName => $value) {
// Print only the plugins which have 'use' set to yes // Print only the plugins which have 'use' set to yes
// which are textareas // which are textareas
// which are suitable for this browser // which are suitable for this browser
@ -490,7 +490,7 @@ function printTextareaSelect($onchange) {
else { $selected = ""; } else { $selected = ""; }
echo "<option value=\"$pluginName\" $selected>" . $pluginProperties[$pluginName]["label"] . "</option>\n"; echo "<option value=\"$pluginName\" $selected>" . $pluginProperties[$pluginName]["label"] . "</option>\n";
} // end if } // end if
} // end while } // end foreach
echo "</select>\n"; echo "</select>\n";

View file

@ -240,7 +240,7 @@ function net2ftp_module_printBody() {
'xml' => array('xml') 'xml' => array('xml')
); );
while(list($language, $extensions) = each($list_language_extensions)) { foreach ($list_language_extensions as $language => $extensions) {
if (in_array($filename_extension, $extensions)) { if (in_array($filename_extension, $extensions)) {
$luminous_language = $language; $luminous_language = $language;
break; break;

View file

@ -20,28 +20,28 @@
<input type="hidden" name="url" value="<?php echo htmlEncode2($url); ?>" /> <input type="hidden" name="url" value="<?php echo htmlEncode2($url); ?>" />
<?php if (is_array($searchoptions) == true) { ?> <?php if (is_array($searchoptions) == true) { ?>
<?php while (list($key, $value) = each($searchoptions)) { ?> <?php foreach ($searchoptions as $key => $value) { ?>
<input type="hidden" name="searchoptions[<?php echo htmlEncode2($key); ?>]" value="<?php echo htmlEncode2($value); ?>" /> <input type="hidden" name="searchoptions[<?php echo htmlEncode2($key); ?>]" value="<?php echo htmlEncode2($value); ?>" />
<?php } // end while ?> <?php } // end foreach ?>
<?php } // end if ?> <?php } // end if ?>
<?php if (is_array($text_splitted) == true) { ?> <?php if (is_array($text_splitted) == true) { ?>
<?php while (list($key, $value) = each($text_splitted)) { ?> <?php foreach ($text_splitted as $key => $value) { ?>
<input type="hidden" name="text_splitted[<?php echo htmlEncode2($key); ?>]" value="<?php echo htmlEncode2($value); ?>" /> <input type="hidden" name="text_splitted[<?php echo htmlEncode2($key); ?>]" value="<?php echo htmlEncode2($value); ?>" />
<?php } // end while ?> <?php } // end foreach ?>
<?php } // end if ?> <?php } // end if ?>
<?php if (is_array($zipactions) == true) { ?> <?php if (is_array($zipactions) == true) { ?>
<?php while (list($key, $value) = each($zipactions)) { ?> <?php foreach ($zipactions as $key => $value) { ?>
<input type="hidden" name="zipactions[<?php echo htmlEncode2($key); ?>]" value="<?php echo htmlEncode2($value); ?>" /> <input type="hidden" name="zipactions[<?php echo htmlEncode2($key); ?>]" value="<?php echo htmlEncode2($value); ?>" />
<?php } // end while ?> <?php } // end foreach ?>
<?php } // end if ?> <?php } // end if ?>
<?php if (is_array($zipactions) == true) { ?> <?php if (is_array($zipactions) == true) { ?>
<?php for ($i=1; $i<=sizeof($list["all"]); $i++) { ?> <?php for ($i=1; $i<=sizeof($list["all"]); $i++) { ?>
<?php while (list($key, $value) = each($list["all"][$i])) { ?> <?php foreach ($list["all"][$i] as $key => $value) { ?>
<input type="hidden" name="list[<?php echo $i; ?>][<?php echo htmlEncode2($key); ?>]" value="<?php echo htmlEncode2($value); ?>" /> <input type="hidden" name="list[<?php echo $i; ?>][<?php echo htmlEncode2($key); ?>]" value="<?php echo htmlEncode2($value); ?>" />
<?php } // end while ?> <?php } // end foreach ?>
<?php } // end for ?> <?php } // end for ?>
<?php } // end if ?> <?php } // end if ?>

View file

@ -189,13 +189,13 @@ function printSkinSelect($fieldname, $onchange, $style, $class) {
echo "<select name=\"$fieldname\" id=\"$fieldname\" $onchange_full $style_full $class_full>\n"; echo "<select name=\"$fieldname\" id=\"$fieldname\" $onchange_full $style_full $class_full>\n";
while (list($key,$value) = each($skinArray)) { foreach ($skinArray as $key => $value) {
// $key loops over "blue", "pastel", ... // $key loops over "blue", "pastel", ...
// $value will be an array like $value["name"] = "Blue" // $value will be an array like $value["name"] = "Blue"
if ($key == $currentskin) { $selected = "selected=\"selected\""; } if ($key == $currentskin) { $selected = "selected=\"selected\""; }
else { $selected = ""; } else { $selected = ""; }
echo "<option value=\"" . $key . "\" $selected>" . $value["name"] . "</option>\n"; echo "<option value=\"" . $key . "\" $selected>" . $value["name"] . "</option>\n";
} // end while } // end foreach
echo "</select>\n"; echo "</select>\n";

View file

@ -491,7 +491,7 @@ function getdnsattributes ($l,$ip){
$r->nameservers = array("ws1.maxmind.com"); $r->nameservers = array("ws1.maxmind.com");
$p = $r->search($l."." . $ip .".s.maxmind.com","TXT","IN"); $p = $r->search($l."." . $ip .".s.maxmind.com","TXT","IN");
$str = is_object($p->answer[0])?$p->answer[0]->string():''; $str = is_object($p->answer[0])?$p->answer[0]->string():'';
ereg("\"(.*)\"",$str,$regs); preg_match('/\"(.*)\"/', $str, $regs);
$str = $regs[1]; $str = $regs[1];
return $str; return $str;
} }

View file

@ -39,8 +39,6 @@
//------------------------------------------------------------------------------------------------------------+ //------------------------------------------------------------------------------------------------------------+
if ($_POST && get_magic_quotes_gpc()) { $_POST = lgsl_stripslashes_deep($_POST); }
//------------------------------------------------------------------------------------------------------------+ //------------------------------------------------------------------------------------------------------------+
if (!empty($_POST['lgsl_save_1']) || !empty($_POST['lgsl_save_2'])) if (!empty($_POST['lgsl_save_1']) || !empty($_POST['lgsl_save_2']))

View file

@ -45,20 +45,14 @@ $(document).ready(function(){
require_once('includes/form_table_class.php'); require_once('includes/form_table_class.php');
require_once('includes/lib_remote.php'); require_once('includes/lib_remote.php');
if ( function_exists('mysqli_connect') ) // mysqli is always available in PHP 7+
require_once("modules/mysql/mysqli_database.php"); require_once("modules/mysql/mysqli_database.php");
else
require_once("modules/mysql/mysql_database.php");
function get_mysql_admin_user(array $mysql_server) { function get_mysql_admin_user(array $mysql_server) {
return !empty($mysql_server['mysql_admin_user']) ? $mysql_server['mysql_admin_user'] : 'root'; return !empty($mysql_server['mysql_admin_user']) ? $mysql_server['mysql_admin_user'] : 'root';
} }
function mysqli_connect_safe($host, $user, $pass, $db = "", $port = null) { function mysqli_connect_safe($host, $user, $pass, $db = "", $port = null) {
if (!function_exists('mysqli_connect')) {
return false;
}
mysqli_report(MYSQLI_REPORT_OFF); mysqli_report(MYSQLI_REPORT_OFF);
try { try {
return mysqli_connect($host, $user, $pass, $db, $port); return mysqli_connect($host, $user, $pass, $db, $port);
@ -182,32 +176,6 @@ function exec_ogp_module() {
} }
} }
} }
else
{
@$link = mysql_connect($mysql_db['mysql_ip'].':'.$mysql_db['mysql_port'], $mysql_db['db_user'], $mysql_db['db_passwd']);
if ( $link === FALSE )
{
@$link = mysql_connect($mysql_db['mysql_ip'].':'.$mysql_db['mysql_port'], get_mysql_admin_user($mysql_db), $mysql_db['mysql_root_passwd']);
if ( $link !== FALSE )
{
$queries = array("CREATE DATABASE IF NOT EXISTS `".$mysql_db['db_name']."`;",
"GRANT ".$mysql_db['privilegies_str']." ON `".$mysql_db['db_name']."`.* TO '".$mysql_db['db_user']."'@'%' IDENTIFIED BY '".$mysql_db['db_passwd']."';",
"FLUSH PRIVILEGES;");
foreach ((array)$queries as $query)
{
@$return = mysql_query($query);
if(!$return)
{
break;
}
}
mysql_close($link);
}
}
}
} }
print_success(get_lang_f('db_added_for_home_id',$_POST['home_id'])); print_success(get_lang_f('db_added_for_home_id',$_POST['home_id']));
} }
@ -250,24 +218,6 @@ function exec_ogp_module() {
$modDb->connect($db_host,$db_user,$db_pass,$db_name,$table_prefix,isset($db_port)?$db_port:NULL); $modDb->connect($db_host,$db_user,$db_pass,$db_name,$table_prefix,isset($db_port)?$db_port:NULL);
} }
} }
else
{
@$link = mysql_connect($mysql_db['mysql_ip'].':'.$mysql_db['mysql_port'], get_mysql_admin_user($mysql_db), $mysql_db['mysql_root_passwd']);
if ( $link !== FALSE )
{
$queries = array("DROP DATABASE ".$mysql_db['db_name'].";",
"DROP USER '".$mysql_db['db_user']."'@'%';");
foreach ((array)$queries as $query)
{
@$return = mysql_query($query);
if(!$return)
break;
}
mysql_close($link);
$modDb->connect($db_host,$db_user,$db_pass,$db_name,$table_prefix,isset($db_port)?$db_port:NULL);
}
}
} }
if ( $modDb->removeMysqlServerDB($db_id) === FALSE ) if ( $modDb->removeMysqlServerDB($db_id) === FALSE )
@ -338,25 +288,6 @@ function exec_ogp_module() {
$modDb->connect($db_host,$db_user,$db_pass,$db_name,$table_prefix,isset($db_port)?$db_port:NULL); $modDb->connect($db_host,$db_user,$db_pass,$db_name,$table_prefix,isset($db_port)?$db_port:NULL);
} }
} }
else
{
@$link = mysql_connect($mysql_db['mysql_ip'].':'.$mysql_db['mysql_port'], get_mysql_admin_user($mysql_db), $mysql_db['mysql_root_passwd']);
if ( $link !== FALSE )
{
$queries = array("DROP USER '".$mysql_db['db_user']."'@'%';",
"GRANT ".$mysql_db['privilegies_str']." ON `".$mysql_db['db_name']."`.* TO '".$mysql_db['db_user']."'@'%' IDENTIFIED BY '".$post_db_passwd."';",
"FLUSH PRIVILEGES;");
foreach ((array)$queries as $query)
{
@$return = mysql_query($query);
if(!$return)
break;
}
mysql_close($link);
$modDb->connect($db_host,$db_user,$db_pass,$db_name,$table_prefix,isset($db_port)?$db_port:NULL);
}
}
} }
} }
@ -405,29 +336,6 @@ function exec_ogp_module() {
$modDb->connect($db_host,$db_user,$db_pass,$db_name,$table_prefix,isset($db_port)?$db_port:NULL); $modDb->connect($db_host,$db_user,$db_pass,$db_name,$table_prefix,isset($db_port)?$db_port:NULL);
} }
} }
else
{
@$link = mysql_connect($mysql_db['mysql_ip'].':'.$mysql_db['mysql_port'], get_mysql_admin_user($mysql_db), $mysql_db['mysql_root_passwd']);
if ( $link !== FALSE )
{
if($enabled == "0")
$queries = array("DROP USER '".$mysql_db['db_user']."'@'%';",
"FLUSH PRIVILEGES;");
else
$queries = array("GRANT ".$mysql_db['privilegies_str']." ON `".$mysql_db['db_name']."`.* TO '".$mysql_db['db_user']."'@'%' IDENTIFIED BY '".$post_db_passwd."';",
"FLUSH PRIVILEGES;");
foreach ((array)$queries as $query)
{
@$return = mysql_query($query);
if(!$return)
break;
}
mysql_close($link);
$modDb->connect($db_host,$db_user,$db_pass,$db_name,$table_prefix,isset($db_port)?$db_port:NULL);
}
}
} }
} }
@ -490,23 +398,6 @@ function exec_ogp_module() {
mysqli_close($link); mysqli_close($link);
} }
} }
else
{
@$link = mysql_connect($mysql_server['mysql_ip'].':'.$mysql_server['mysql_port'], get_mysql_admin_user($mysql_server), $mysql_server['mysql_root_passwd']);
if ( $link !== FALSE )
{
$queries = array("DROP DATABASE ".$mysql_db['db_name'].";",
"DROP USER '".$mysql_db['db_user']."'@'%';");
foreach ((array)$queries as $query)
{
@$return = mysql_query($query);
if(!$return)
break;
}
mysql_close($link);
}
}
} }
} }
} }

View file

@ -36,22 +36,18 @@ class MySQLModuleDatabase extends OGPDatabaseMySQL
} }
public function connect($db_host, $db_user, $db_pass, $db_name, $table_prefix = NULL) { public function connect($db_host, $db_user, $db_pass, $db_name, $table_prefix = NULL) {
if ( !extension_loaded("mysql") ) // The mysql extension was removed in PHP 7. This class now uses mysqli.
return -99;
$this->table_prefix = $table_prefix; $this->table_prefix = $table_prefix;
/// \todo We might want to do other checks here as well? /// \todo We might want to do other checks here as well?
if ( $db_host === NULL ) if ( $db_host === NULL )
return -1; return -1;
$this->link = mysql_connect($db_host, $db_user, $db_pass); $this->link = mysqli_connect($db_host, $db_user, $db_pass, $db_name);
if ( $this->link === FALSE ) if ( $this->link === FALSE )
return -11; return -11;
if ( mysql_select_db($db_name,$this->link) === FALSE )
return -12;
return TRUE; return TRUE;
} }
@ -60,20 +56,20 @@ class MySQLModuleDatabase extends OGPDatabaseMySQL
if ( !$this->link ) return FALSE; if ( !$this->link ) return FALSE;
++$this->queries_; ++$this->queries_;
$result = mysql_query($query, $this->link); $result = mysqli_query($this->link, $query);
if ( mysql_errno($this->link) > 0 ) if ( mysqli_errno($this->link) > 0 )
print mysql_error($this->link); print mysqli_error($this->link);
if ( $result === FALSE ) if ( $result === FALSE )
return FALSE; return FALSE;
if ( mysql_num_rows($result) == 0 ) if ( mysqli_num_rows($result) == 0 )
return FALSE; return FALSE;
$results = array(); $results = array();
while ( $row = mysql_fetch_assoc( $result ) ) while ( $row = mysqli_fetch_assoc( $result ) )
array_push($results,$row); array_push($results,$row);
return $results; return $results;
@ -93,22 +89,22 @@ class MySQLModuleDatabase extends OGPDatabaseMySQL
$query = sprintf("INSERT INTO `%smysql_servers` (`remote_server_id`,`mysql_name`,`mysql_ip`,`mysql_port`,`mysql_admin_user`,`mysql_root_passwd`,`privilegies_str`) $query = sprintf("INSERT INTO `%smysql_servers` (`remote_server_id`,`mysql_name`,`mysql_ip`,`mysql_port`,`mysql_admin_user`,`mysql_root_passwd`,`privilegies_str`)
VALUES('%s','%s','%s','%s','%s','%s','%s');", VALUES('%s','%s','%s','%s','%s','%s','%s');",
$this->table_prefix, $this->table_prefix,
mysql_real_escape_string($remote_server_id,$this->link), mysqli_real_escape_string($this->link, $remote_server_id),
mysql_real_escape_string($mysql_name,$this->link), mysqli_real_escape_string($this->link, $mysql_name),
mysql_real_escape_string($mysql_ip,$this->link), mysqli_real_escape_string($this->link, $mysql_ip),
mysql_real_escape_string($mysql_port,$this->link), mysqli_real_escape_string($this->link, $mysql_port),
mysql_real_escape_string($mysql_admin_user,$this->link), mysqli_real_escape_string($this->link, $mysql_admin_user),
mysql_real_escape_string($mysql_root_passwd,$this->link), mysqli_real_escape_string($this->link, $mysql_root_passwd),
mysql_real_escape_string($privilegies_str,$this->link)); mysqli_real_escape_string($this->link, $privilegies_str));
++$this->queries_; ++$this->queries_;
mysql_query($query,$this->link); mysqli_query($this->link, $query);
if( mysql_errno($this->link) != 0 ) if( mysqli_errno($this->link) != 0 )
{ {
return false; return false;
} }
return mysql_insert_id($this->link); return mysqli_insert_id($this->link);
} }
public function editMysqlServer($mysql_server_id,$remote_server_id,$mysql_name,$mysql_ip,$mysql_port,$mysql_admin_user,$mysql_root_passwd,$privilegies_str) public function editMysqlServer($mysql_server_id,$remote_server_id,$mysql_name,$mysql_ip,$mysql_port,$mysql_admin_user,$mysql_root_passwd,$privilegies_str)
@ -118,17 +114,17 @@ class MySQLModuleDatabase extends OGPDatabaseMySQL
`mysql_admin_user` = '%s', `mysql_root_passwd` = '%s', `privilegies_str` = '%s' `mysql_admin_user` = '%s', `mysql_root_passwd` = '%s', `privilegies_str` = '%s'
WHERE `mysql_server_id` = %s;", WHERE `mysql_server_id` = %s;",
$this->table_prefix, $this->table_prefix,
mysql_real_escape_string($remote_server_id,$this->link), mysqli_real_escape_string($this->link, $remote_server_id),
mysql_real_escape_string($mysql_name,$this->link), mysqli_real_escape_string($this->link, $mysql_name),
mysql_real_escape_string($mysql_ip,$this->link), mysqli_real_escape_string($this->link, $mysql_ip),
mysql_real_escape_string($mysql_port,$this->link), mysqli_real_escape_string($this->link, $mysql_port),
mysql_real_escape_string($mysql_admin_user,$this->link), mysqli_real_escape_string($this->link, $mysql_admin_user),
mysql_real_escape_string($mysql_root_passwd,$this->link), mysqli_real_escape_string($this->link, $mysql_root_passwd),
mysql_real_escape_string($privilegies_str,$this->link), mysqli_real_escape_string($this->link, $privilegies_str),
mysql_real_escape_string($mysql_server_id,$this->link)); mysqli_real_escape_string($this->link, $mysql_server_id));
++$this->queries_; ++$this->queries_;
if ( mysql_query($query) === FALSE ) if ( mysqli_query($this->link, $query) === FALSE )
return FALSE; return FALSE;
return TRUE; return TRUE;
@ -145,20 +141,20 @@ class MySQLModuleDatabase extends OGPDatabaseMySQL
$query = sprintf("SELECT * FROM `%smysql_servers` WHERE `mysql_server_id` = %d", $query = sprintf("SELECT * FROM `%smysql_servers` WHERE `mysql_server_id` = %d",
$this->table_prefix, $this->table_prefix,
mysql_real_escape_string($id,$this->link)); mysqli_real_escape_string($this->link, $id));
++$this->queries_; ++$this->queries_;
$result = mysql_query($query, $this->link); $result = mysqli_query($this->link, $query);
// If there are no servers then we can stop here. // If there are no servers then we can stop here.
if ( mysql_num_rows($result) != 1 ) if ( mysqli_num_rows($result) != 1 )
return FALSE; return FALSE;
return mysql_fetch_assoc( $result ); return mysqli_fetch_assoc( $result );
} }
public function removeMysqlServer($mysql_server_id){ public function removeMysqlServer($mysql_server_id){
$mysql_server_id = mysql_real_escape_string($mysql_server_id, $this->link); $mysql_server_id = mysqli_real_escape_string($this->link, $mysql_server_id);
$return = TRUE; $return = TRUE;
@ -169,7 +165,7 @@ class MySQLModuleDatabase extends OGPDatabaseMySQL
{ {
$query = sprintf($query,$this->table_prefix,$mysql_server_id); $query = sprintf($query,$this->table_prefix,$mysql_server_id);
++$this->queries_; ++$this->queries_;
$result = mysql_query($query,$this->link); $result = mysqli_query($this->link, $query);
$return = ($result === FALSE) ? FALSE : $return; $return = ($result === FALSE) ? FALSE : $return;
} }
return $return; return $return;
@ -178,7 +174,7 @@ class MySQLModuleDatabase extends OGPDatabaseMySQL
public function getMysqlServerDBs($mysql_server_id){ public function getMysqlServerDBs($mysql_server_id){
$query = sprintf("SELECT * FROM `%smysql_databases` WHERE mysql_server_id = %d;", $query = sprintf("SELECT * FROM `%smysql_databases` WHERE mysql_server_id = %d;",
$this->table_prefix, $this->table_prefix,
mysql_real_escape_string($mysql_server_id,$this->link)); mysqli_real_escape_string($this->link, $mysql_server_id));
return $this->listQuery($query); return $this->listQuery($query);
} }
@ -186,27 +182,27 @@ class MySQLModuleDatabase extends OGPDatabaseMySQL
$query = sprintf("INSERT INTO `%smysql_databases` (`mysql_server_id`, `home_id`, `db_user`, `db_passwd`, `db_name`, `enabled`) $query = sprintf("INSERT INTO `%smysql_databases` (`mysql_server_id`, `home_id`, `db_user`, `db_passwd`, `db_name`, `enabled`)
VALUES('%d','%d','%s','%s','%s','%d');", VALUES('%d','%d','%s','%s','%s','%d');",
$this->table_prefix, $this->table_prefix,
mysql_real_escape_string($mysql_server_id,$this->link), mysqli_real_escape_string($this->link, $mysql_server_id),
mysql_real_escape_string($home_id,$this->link), mysqli_real_escape_string($this->link, $home_id),
mysql_real_escape_string($db_user,$this->link), mysqli_real_escape_string($this->link, $db_user),
mysql_real_escape_string($db_passwd,$this->link), mysqli_real_escape_string($this->link, $db_passwd),
mysql_real_escape_string($db_name,$this->link), mysqli_real_escape_string($this->link, $db_name),
mysql_real_escape_string($enabled,$this->link)); mysqli_real_escape_string($this->link, $enabled));
++$this->queries_; ++$this->queries_;
mysql_query($query,$this->link); mysqli_query($this->link, $query);
if( mysql_errno($this->link) != 0 ) if( mysqli_errno($this->link) != 0 )
{ {
return false; return false;
} }
return mysql_insert_id($this->link); return mysqli_insert_id($this->link);
} }
public function getMysqlDBbyId($db_id){ public function getMysqlDBbyId($db_id){
$query = sprintf('SELECT * FROM `%1$smysql_databases` NATURAL JOIN `%1$smysql_servers` WHERE db_id = %2$d;', $query = sprintf('SELECT * FROM `%1$smysql_databases` NATURAL JOIN `%1$smysql_servers` WHERE db_id = %2$d;',
$this->table_prefix, $this->table_prefix,
mysql_real_escape_string($db_id,$this->link)); mysqli_real_escape_string($this->link, $db_id));
$db_info = $this->listQuery($query); $db_info = $this->listQuery($query);
return $db_info[0]; return $db_info[0];
} }
@ -214,15 +210,15 @@ class MySQLModuleDatabase extends OGPDatabaseMySQL
public function getMysqlDBsbyHomeId($home_id){ public function getMysqlDBsbyHomeId($home_id){
$query = sprintf('SELECT * FROM `%1$smysql_databases` WHERE enabled = 1 AND home_id = %2$d;', $query = sprintf('SELECT * FROM `%1$smysql_databases` WHERE enabled = 1 AND home_id = %2$d;',
$this->table_prefix, $this->table_prefix,
mysql_real_escape_string($home_id,$this->link)); mysqli_real_escape_string($this->link, $home_id));
return $this->listQuery($query); return $this->listQuery($query);
} }
public function getMysqlHomeDBbyId($home_id,$db_id){ public function getMysqlHomeDBbyId($home_id,$db_id){
$query = sprintf('SELECT * FROM `%1$smysql_databases` NATURAL JOIN `%1$smysql_servers` WHERE home_id = %2$d AND db_id = %3$d;', $query = sprintf('SELECT * FROM `%1$smysql_databases` NATURAL JOIN `%1$smysql_servers` WHERE home_id = %2$d AND db_id = %3$d;',
$this->table_prefix, $this->table_prefix,
mysql_real_escape_string($home_id,$this->link), mysqli_real_escape_string($this->link, $home_id),
mysql_real_escape_string($db_id,$this->link)); mysqli_real_escape_string($this->link, $db_id));
$db_info = $this->listQuery($query); $db_info = $this->listQuery($query);
return $db_info[0]; return $db_info[0];
} }
@ -233,17 +229,17 @@ class MySQLModuleDatabase extends OGPDatabaseMySQL
SET `home_id`='%d', `db_user`='%s', `db_passwd`='%s', `db_name`='%s',`enabled`='%d' SET `home_id`='%d', `db_user`='%s', `db_passwd`='%s', `db_name`='%s',`enabled`='%d'
WHERE `db_id` = '%d';", WHERE `db_id` = '%d';",
$this->table_prefix, $this->table_prefix,
mysql_real_escape_string($home_id, $this->link), mysqli_real_escape_string($this->link, $home_id),
mysql_real_escape_string($db_user, $this->link), mysqli_real_escape_string($this->link, $db_user),
mysql_real_escape_string($db_passwd, $this->link), mysqli_real_escape_string($this->link, $db_passwd),
mysql_real_escape_string($db_name, $this->link), mysqli_real_escape_string($this->link, $db_name),
mysql_real_escape_string($enabled, $this->link), mysqli_real_escape_string($this->link, $enabled),
mysql_real_escape_string($db_id, $this->link) ); mysqli_real_escape_string($this->link, $db_id) );
++$this->queries_; ++$this->queries_;
mysql_query($query,$this->link); mysqli_query($this->link, $query);
if( mysql_errno($this->link) != 0 ) if( mysqli_errno($this->link) != 0 )
return FALSE; return FALSE;
return true; return true;
@ -254,10 +250,10 @@ class MySQLModuleDatabase extends OGPDatabaseMySQL
$query = sprintf("DELETE FROM `%smysql_databases` $query = sprintf("DELETE FROM `%smysql_databases`
WHERE `db_id` = '%d'", WHERE `db_id` = '%d'",
$this->table_prefix, $this->table_prefix,
mysql_real_escape_string($db_id, $this->link)); mysqli_real_escape_string($this->link, $db_id));
++$this->queries_; ++$this->queries_;
if ( mysql_query($query) === FALSE ) if ( mysqli_query($this->link, $query) === FALSE )
return FALSE; return FALSE;
return TRUE; return TRUE;
@ -267,7 +263,7 @@ class MySQLModuleDatabase extends OGPDatabaseMySQL
$query = sprintf('SELECT %1$sserver_homes.*,%1$sremote_servers.*, %1$sconfig_homes.game_name $query = sprintf('SELECT %1$sserver_homes.*,%1$sremote_servers.*, %1$sconfig_homes.game_name
FROM `%1$sserver_homes` NATURAL JOIN `%1$sconfig_homes` NATURAL JOIN `%1$sremote_servers` WHERE remote_server_id=%2$s;', FROM `%1$sserver_homes` NATURAL JOIN `%1$sconfig_homes` NATURAL JOIN `%1$sremote_servers` WHERE remote_server_id=%2$s;',
$this->table_prefix, $this->table_prefix,
mysql_real_escape_string($remote_server_id,$this->link)); mysqli_real_escape_string($this->link, $remote_server_id));
return $this->listQuery($query); return $this->listQuery($query);
} }
} }

View file

@ -234,33 +234,17 @@ function exec_ogp_module() {
else else
{ {
$mysql_admin_user = get_mysql_admin_user($mysql_server); $mysql_admin_user = get_mysql_admin_user($mysql_server);
if( function_exists('mysqli_connect') ) // mysqli is always available in PHP 7+; the old mysql_* fallback has been removed.
{ $link = mysqli_connect_safe($mysql_server['mysql_ip'], $mysql_admin_user, $mysql_server['mysql_root_passwd'], "", $mysql_server['mysql_port']);
$link = mysqli_connect_safe($mysql_server['mysql_ip'], $mysql_admin_user, $mysql_server['mysql_root_passwd'], "", $mysql_server['mysql_port']);
if ( $link === FALSE ) if ( $link === FALSE )
{ {
$server_status = "<span class='failure'>".get_lang('mysql_offline')."</span>"; $server_status = "<span class='failure'>".get_lang('mysql_offline')."</span>";
}
else
{
$server_status = "<span class='success'>".get_lang('mysql_online')."</span>";
mysqli_close($link);
}
} }
else else
{ {
@$link = mysql_connect($mysql_server['mysql_ip'].':'.$mysql_server['mysql_port'], $mysql_admin_user, $mysql_server['mysql_root_passwd']); $server_status = "<span class='success'>".get_lang('mysql_online')."</span>";
mysqli_close($link);
if ( $link === FALSE )
{
$server_status = "<span class='failure'>".get_lang('mysql_offline')."</span>";
}
else
{
$server_status = "<span class='success'>".get_lang('mysql_online')."</span>";
mysql_close($link);
}
} }
} }

View file

@ -32,20 +32,14 @@ $(document).ready(function(){
require_once("modules/mysql/functions.php"); require_once("modules/mysql/functions.php");
require_once('includes/form_table_class.php'); require_once('includes/form_table_class.php');
require_once('includes/lib_remote.php'); require_once('includes/lib_remote.php');
if ( function_exists('mysqli_connect') ) // mysqli is always available in PHP 7+
require_once("modules/mysql/mysqli_database.php"); require_once("modules/mysql/mysqli_database.php");
else
require_once("modules/mysql/mysql_database.php");
function get_mysql_admin_user(array $mysql_server) { function get_mysql_admin_user(array $mysql_server) {
return !empty($mysql_server['mysql_admin_user']) ? $mysql_server['mysql_admin_user'] : 'root'; return !empty($mysql_server['mysql_admin_user']) ? $mysql_server['mysql_admin_user'] : 'root';
} }
function mysqli_connect_safe($host, $user, $pass, $db = "", $port = null) { function mysqli_connect_safe($host, $user, $pass, $db = "", $port = null) {
if (!function_exists('mysqli_connect')) {
return false;
}
mysqli_report(MYSQLI_REPORT_OFF); mysqli_report(MYSQLI_REPORT_OFF);
try { try {
return mysqli_connect($host, $user, $pass, $db, $port); return mysqli_connect($host, $user, $pass, $db, $port);
@ -145,26 +139,6 @@ function exec_ogp_module() {
mysqli_close($link); mysqli_close($link);
} }
} }
else
{
@$link = mysql_connect($mysql_db['mysql_ip'].':'.$mysql_db['mysql_port'], $mysql_db['db_user'], $mysql_db['db_passwd']);
if ( $link !== FALSE )
{
$server_online = TRUE;
if ( mysql_select_db($mysql_db['db_name'],$link) !== FALSE )
{
$databases = mysql_query("SHOW TABLES;");
$user_db = "Database: ".$mysql_db['db_name']."\nTables:\n";
while ( $table = mysql_fetch_array($databases) ) {
$user_db .= $table[0] . "\n";
}
$database_exists = TRUE;
}
mysql_close($link);
}
}
} }
if(isset($_POST['restore'])) if(isset($_POST['restore']))
@ -292,25 +266,6 @@ function exec_ogp_module() {
$modDb->connect($db_host,$db_user,$db_pass,$db_name,$table_prefix,isset($db_port)?$db_port:NULL); $modDb->connect($db_host,$db_user,$db_pass,$db_name,$table_prefix,isset($db_port)?$db_port:NULL);
} }
} }
else
{
@$link = mysql_connect($mysql_db['mysql_ip'].':'.$mysql_db['mysql_port'], get_mysql_admin_user($mysql_db), $mysql_db['mysql_root_passwd']);
if ( $link !== FALSE )
{
$queries = array("DROP USER '".$mysql_db['db_user']."'@'%';",
"GRANT ".$mysql_db['privilegies_str']." ON `".$mysql_db['db_name']."`.* TO '".$mysql_db['db_user']."'@'%' IDENTIFIED BY '".$post_db_passwd."';",
"FLUSH PRIVILEGES;");
foreach ((array)$queries as $query)
{
@$return = mysql_query($query);
if(!$return)
break;
}
mysql_close($link);
$modDb->connect($db_host,$db_user,$db_pass,$db_name,$table_prefix,isset($db_port)?$db_port:NULL);
}
}
} }
if ( $modDb->editMysqlServerDB($db_id, $home_id, $post_db_user, $post_db_passwd, $post_db_name, $enabled) === FALSE ) if ( $modDb->editMysqlServerDB($db_id, $home_id, $post_db_user, $post_db_passwd, $post_db_name, $enabled) === FALSE )

View file

@ -64,9 +64,6 @@ function exec_ogp_module()
//Function to sanitize values received from the form. Prevents SQL injection //Function to sanitize values received from the form. Prevents SQL injection
function clean($str) { function clean($str) {
$str = @trim($str); $str = @trim($str);
if(get_magic_quotes_gpc()) {
$str = stripslashes($str);
}
return $str; return $str;
} }

View file

@ -41,9 +41,6 @@ function exec_ogp_module()
//Function to sanitize values received from the form. Prevents SQL injection //Function to sanitize values received from the form. Prevents SQL injection
function clean($str) { function clean($str) {
$str = @trim($str); $str = @trim($str);
if(get_magic_quotes_gpc()) {
$str = stripslashes($str);
}
return $str; return $str;
} }

View file

@ -724,8 +724,7 @@ class Smarty extends Smarty_Internal_Data {
{ {
static $camel_func; static $camel_func;
if (!isset($camel_func)) if (!isset($camel_func))
$camel_func = create_function('$c', 'return "_" . strtolower($c[1]);'); $camel_func = function($c) { return "_" . strtolower($c[1]); };
// PHP4 call to constructor?
if (strtolower($name) == 'smarty') { if (strtolower($name) == 'smarty') {
throw new SmartyException('Please use parent::__construct() to call parent constuctor'); throw new SmartyException('Please use parent::__construct() to call parent constuctor');
return false; return false;

View file

@ -896,8 +896,7 @@ class Smarty_Internal_Template extends Smarty_Internal_Data {
{ {
static $camel_func; static $camel_func;
if (!isset($camel_func)) if (!isset($camel_func))
$camel_func = create_function('$c', 'return "_" . strtolower($c[1]);'); $camel_func = function($c) { return "_" . strtolower($c[1]); };
// see if this is a set/get for a property
$first3 = strtolower(substr($name, 0, 3)); $first3 = strtolower(substr($name, 0, 3));
if (in_array($first3, array('set', 'get')) && substr($name, 3, 1) !== '_') { if (in_array($first3, array('set', 'get')) && substr($name, 3, 1) !== '_') {
// try to keep case correct for future PHP 6.0 case-sensitive class methods // try to keep case correct for future PHP 6.0 case-sensitive class methods