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)) {
throw new phpmailerException($this->lang('file_open') . $path, self::STOP_CONTINUE);
}
$magic_quotes = get_magic_quotes_runtime();
if ($magic_quotes) {
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);
}
}
// get_magic_quotes_runtime() was removed in PHP 8.0 and always
// returned false in PHP 5.4+, so no magic-quotes handling is needed.
$file_buffer = file_get_contents($path);
$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;
} catch (Exception $exc) {
$this->setError($exc->getMessage());

View file

@ -1055,10 +1055,8 @@ function removeInvalidFileNameCharacters($string){
function deleteMysqlAddonDatabasesForGameServerHome($home_id){
global $db, $db_host, $db_user, $db_pass, $db_name, $table_prefix, $db_port;
if ( function_exists('mysqli_connect') )
require_once("modules/mysql/mysqli_database.php");
else
require_once("modules/mysql/mysql_database.php");
// 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('includes/lib_remote.php');
@ -1089,48 +1087,29 @@ function deleteMysqlAddonDatabasesForGameServerHome($home_id){
}
else
{
if( function_exists('mysqli_connect') )
{
mysqli_report(MYSQLI_REPORT_OFF);
try {
$link = mysqli_connect($mysql_db['mysql_ip'], $mysql_admin_user, $mysql_db['mysql_root_passwd'], "", $mysql_db['mysql_port']);
} catch (Exception $e) {
$link = false;
} catch (Throwable $e) {
$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);
}
// 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);
try {
$link = mysqli_connect($mysql_db['mysql_ip'], $mysql_admin_user, $mysql_db['mysql_root_passwd'], "", $mysql_db['mysql_port']);
} catch (Exception $e) {
$link = false;
} catch (Throwable $e) {
$link = false;
}
else
if ( $link !== FALSE )
{
@$link = mysql_connect($mysql_db['mysql_ip'].':'.$mysql_db['mysql_port'], $mysql_admin_user, $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)
{
$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);
$db->connect($db_host,$db_user,$db_pass,$db_name,$table_prefix,isset($db_port)?$db_port:NULL);
@$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);
}
}

View file

@ -262,11 +262,13 @@ class Smarty_Compiler extends Smarty {
reset($this->_folded_blocks);
/* replace special blocks by "{php}" */
$source_content = preg_replace_callback($search, create_function ('$matches', "return '"
. $this->_quote_replace($this->left_delimiter) . 'php'
. "' . str_repeat(\"\n\", substr_count('\$matches[1]', \"\n\")) .'"
. $this->_quote_replace($this->right_delimiter)
. "';")
$left_quoted = $this->_quote_replace($this->left_delimiter);
$right_quoted = $this->_quote_replace($this->right_delimiter);
$source_content = preg_replace_callback($search, function($matches) use ($left_quoted, $right_quoted) {
return $left_quoted . 'php'
. str_repeat("\n", substr_count($matches[1], "\n"))
. $right_quoted;
}
, $source_content);
/* Gather all template tags. */
@ -556,7 +558,8 @@ class Smarty_Compiler extends Smarty {
case '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");
/* the number of matched elements in the regexp in _compile_file()
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");
$p = $r->search($l."." . $ip .".s.maxmind.com","TXT","IN");
$str = is_object($p->answer[0])?$p->answer[0]->string():'';
ereg("\"(.*)\"",$str,$regs);
preg_match('/\"(.*)\"/', $str, $regs);
$str = $regs[1];
return $str;
}

View file

@ -611,14 +611,14 @@ function getRootdirectory() {
// 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);
$result1 = mysqli_query($mydb, "$sqlquery1") or die("Unable to execute SQL SELECT query (isAuthorizedDirectory > sqlquery1) <br /> $sqlquery1");
$nrofrows1 = mysqli_num_rows($result1);
if ($nrofrows1 == 0) {
$net2ftp_globals["homedirectory"] = "/";
}
elseif ($nrofrows1 == 1) {
$resultRow1 = mysql_fetch_row($result1);
$resultRow1 = mysqli_fetch_row($result1);
$net2ftp_globals["homedirectory"] = $resultRow1[0];
}
else {

View file

@ -120,15 +120,15 @@ function getConsumption() {
// 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';";
$result1 = mysql_query("$sqlquery1") or die("Unable to execute SQL SELECT query (getConsumption > sqlquery1) <br /> $sqlquery1");
$nrofrows1 = mysql_num_rows($result1);
$result1 = mysqli_query($mydb, "$sqlquery1") or die("Unable to execute SQL SELECT query (getConsumption > sqlquery1) <br /> $sqlquery1");
$nrofrows1 = mysqli_num_rows($result1);
if ($nrofrows1 == 0) {
$net2ftp_globals["consumption_ipaddress_datatransfer"] = 0;
$net2ftp_globals["consumption_ipaddress_executiontime"] = 0;
}
elseif ($nrofrows1 == 1) {
$resultRow1 = mysql_fetch_row($result1);
$resultRow1 = mysqli_fetch_row($result1);
$net2ftp_globals["consumption_ipaddress_datatransfer"] = $resultRow1[0];
$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
// -------------------------------------------------------------------------
$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");
$nrofrows2 = mysql_num_rows($result2);
$result2 = mysqli_query($mydb, "$sqlquery2") or die("Unable to execute SQL SELECT query (getConsumption > sqlquery2) <br /> $sqlquery2");
$nrofrows2 = mysqli_num_rows($result2);
if ($nrofrows2 == 0) {
$net2ftp_globals["consumption_ftpserver_datatransfer"] = 0;
$net2ftp_globals["consumption_ftpserver_executiontime"] = 0;
}
elseif ($nrofrows2 == 1) {
$resultRow2 = mysql_fetch_row($result2);
$resultRow2 = mysqli_fetch_row($result2);
$net2ftp_globals["consumption_ftpserver_datatransfer"] = $resultRow2[0];
$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
// -------------------------------------------------------------------------
$sqlquery1 = "SELECT * FROM net2ftp_log_consumption_ipaddress WHERE date = '$date' AND ipaddress = '$REMOTE_ADDR_safe';";
$result1 = mysql_query("$sqlquery1");
$nrofrows1 = mysql_num_rows($result1);
$result1 = mysqli_query($mydb, "$sqlquery1");
$nrofrows1 = mysqli_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);
$result2 = mysqli_query($mydb, "$sqlquery2");
$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,
// 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.)
@ -268,8 +268,8 @@ function putConsumption() {
}
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);
$result3 = mysqli_query($mydb, "$sqlquery3");
$nrofrows3 = mysqli_affected_rows($mydb);
if ($nrofrows3 != 1) {
setErrorVars(false, __("Table net2ftp_log_consumption_ipaddress could not be updated."), debug_backtrace(), __FILE__, __LINE__);
return false;
@ -288,13 +288,13 @@ function putConsumption() {
// 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);
$result4 = mysqli_query($mydb, "$sqlquery4");
$nrofrows4 = mysqli_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);
$result5 = mysqli_query($mydb, "$sqlquery5");
$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,
// 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.)
@ -305,8 +305,8 @@ function putConsumption() {
}
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"]) . "');";
$result6 = mysql_query("$sqlquery6");
$nrofrows6 = mysql_affected_rows($mydb);
$result6 = mysqli_query($mydb, "$sqlquery6");
$nrofrows6 = mysqli_affected_rows($mydb);
if ($nrofrows6 != 1) {
setErrorVars(false, __("Table net2ftp_log_consumption_ftpserver could not be updated."), debug_backtrace(), __FILE__, __LINE__);
return false;
@ -321,13 +321,13 @@ function putConsumption() {
// 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"] . "';";
$result7 = mysql_query("$sqlquery7");
$nrofrows7 = mysql_num_rows($result7);
$result7 = mysqli_query($mydb, "$sqlquery7");
$nrofrows7 = mysqli_num_rows($result7);
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"] . "'";
$result8 = mysql_query("$sqlquery8");
$nrofrows8 = mysql_affected_rows($mydb);
$result8 = mysqli_query($mydb, "$sqlquery8");
$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,
// 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.)
@ -338,8 +338,8 @@ function putConsumption() {
}
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"]) . "');";
$result9 = mysql_query("$sqlquery9");
$nrofrows9 = mysql_affected_rows($mydb);
$result9 = mysqli_query($mydb, "$sqlquery9");
$nrofrows9 = mysqli_affected_rows($mydb);
if ($nrofrows9 != 1) {
setErrorVars(false, __("Table net2ftp_log_access could not be updated."), debug_backtrace(), __FILE__, __LINE__);
return false;

View file

@ -28,18 +28,12 @@ function connect2db() {
// -------------------------------------------------------------------------
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) {
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;
} // End connect2db

View file

@ -2953,12 +2953,12 @@ function checkEmailAddress($email) {
// 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]+)*)+" . //domain
"\\.[a-z]{2,}" . //sld, tld
"$", $email, $regs)) { return true; }
"$/i", $email, $regs)) { return true; }
else { return false; }
} // 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
if (!eregi( "^" .
if (!preg_match( "/^" .
"[a-zA-Z0-9]+([_\.-][a-zA-Z0-9]+)*" . //user
"@" .
"([a-zA-Z0-9]+([\.-][a-zA-Z0-9]+)*)+" . //domain
"\\.[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);
setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__);
return false;

View file

@ -93,16 +93,16 @@ function logAccess() {
// 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')";
$result1 = mysql_query($sqlquery1);
$result1 = mysqli_query($mydb, $sqlquery1);
if ($result1 == false) {
$errormessage = __("Unable to execute the SQL query.");
setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__);
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
@ -256,7 +256,7 @@ function logError() {
// 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);
$result_mysql_query = mysqli_query($mydb, $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;
@ -365,14 +365,14 @@ function getLogStatus() {
// Get log rotation status
// -------------------------------------------------------------------------
$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");
$nrofrows1 = mysql_num_rows($result1);
$result1 = mysqli_query($mydb, "$sqlquery1") or die("Unable to execute SQL SELECT query (getLogStatus > sqlquery1) <br /> $sqlquery1");
$nrofrows1 = mysqli_num_rows($result1);
if ($nrofrows1 == 0) {
$logStatus = 1;
}
elseif ($nrofrows1 == 1) {
$resultRow1 = mysql_fetch_row($result1);
$resultRow1 = mysqli_fetch_row($result1);
$logStatus = $resultRow1[0];
}
else {
@ -434,25 +434,25 @@ function putLogStatus($logStatus) {
// Put log rotation status
// -------------------------------------------------------------------------
$sqlquery1 = "SELECT status, changelog FROM net2ftp_log_status WHERE month = '$currentmonth';";
$result1 = mysql_query("$sqlquery1");
$nrofrows1 = mysql_num_rows($result1);
$result1 = mysqli_query($mydb, "$sqlquery1");
$nrofrows1 = mysqli_num_rows($result1);
if ($nrofrows1 == 1) {
$resultRow1 = mysql_fetch_row($result1);
$resultRow1 = mysqli_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);
$result2 = mysqli_query($mydb, "$sqlquery2");
$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,
// the $nrofrows2 is set to 0.
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);
$result3 = mysqli_query($mydb, "$sqlquery3");
$nrofrows3 = mysqli_affected_rows($mydb);
if ($nrofrows3 != 1) {
setErrorVars(false, __("Table net2ftp_log_status could not be updated."), debug_backtrace(), __FILE__, __LINE__);
return false;
@ -516,10 +516,10 @@ function emptyLogs($datefrom, $dateto) {
// -------------------------------------------------------------------------
for ($i=1; $i<=sizeof($tables); $i++) {
$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] . "`;";
$result_optimize[$i] = mysql_query("$sqlquery_optimize");
$result_optimize[$i] = mysqli_query($mydb, "$sqlquery_optimize");
if ($result_empty[$i] == true) {
$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
$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) {
$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
$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) {
$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
$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) {
$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;
// ----- Look if function exists
if ( (!function_exists("get_magic_quotes_runtime"))
|| (!function_exists("set_magic_quotes_runtime"))) {
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);
}
// get_magic_quotes_runtime() and set_magic_quotes_runtime() were removed
// in PHP 8.0. Magic quotes were always disabled from PHP 5.4 onward,
// so there is nothing to do here.
// ----- Return
return $v_result;
@ -5369,21 +5354,9 @@ echo "p entry filename 2 is " . $p_entry['filename'] . " <br />\n";
{
$v_result=1;
// ----- Look if function exists
if ( (!function_exists("get_magic_quotes_runtime"))
|| (!function_exists("set_magic_quotes_runtime"))) {
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);
}
// get_magic_quotes_runtime() and set_magic_quotes_runtime() were removed
// in PHP 8.0. Magic quotes were always disabled from PHP 5.4 onward,
// so there is nothing to restore here.
// ----- Return
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 \'
// This function removes the extra backslash that is added
// -------------------------------------------------------------------------
if (get_magic_quotes_gpc() == 1) {
remove_magic_quotes($_POST);
remove_magic_quotes($_GET);
remove_magic_quotes($_COOKIE);
}
// Note: get_magic_quotes_gpc() was removed in PHP 8.0; magic quotes are
// always disabled on PHP 5.4+ so no stripping is needed.
// Do not add remove_magic_quotes for $GLOBALS because this would call the same
// function a second time, replacing \' by ' and \" by "
@ -432,28 +429,9 @@ $net2ftp_globals["browser_platform"] = getBrowser("platform");
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)
// if (magic_quotes_gpc == 1), then PHP converts automatically " --> \", ' --> \'
// Has only to be done when getting info from get post cookie
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
// get_magic_quotes_gpc() was removed in PHP 8.0; magic quotes are always
// disabled on PHP 5.4+, so this function is now a no-op kept for
// compatibility with any callers that may still reference it.
return $x;
} // 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";
while (list($key,$value) = each($languageArray)) {
foreach ($languageArray as $key => $value) {
// $key loops over "en", "fr", "nl", ...
// $value will be an array like $value["name"] = "English" and $value["file"] = "en.inc.php"
if ($key == $currentlanguage) { $selected = "selected=\"selected\""; }
else { $selected = ""; }
echo "<option value=\"" . $key . "\" $selected>" . $value["name"] . "</option>\n";
} // end while
} // end foreach
echo "</select>\n";

View file

@ -225,14 +225,14 @@ function net2ftp_module_printBody() {
// ------------------------------------
// 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"; }
// ------------------------------------
// Select
// ------------------------------------
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"; }
}
@ -241,7 +241,7 @@ function net2ftp_module_printBody() {
// ------------------------------------
if ($mydb != false && $mysql_select_db_result != false) {
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"; }
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
// -------------------------------------------------------------------------
$result = mysql_query("$sqlquery");
$result = mysqli_query($mydb, "$sqlquery");
if ($result == false) {
$errormessage = __("Unable to execute the SQL query <b>%1\$s</b>.", $sqlquery);
setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__);
return false;
}
$nrofrows = mysql_num_rows($result);
$nrofcolumns_withindex = mysql_num_fields($result) + 1;
$nrofrows = mysqli_num_rows($result);
$nrofcolumns_withindex = mysqli_num_fields($result) + 1;
// -------------------------------------------------------------------------
@ -260,19 +260,19 @@ function printTable($sqlquery) {
if ($nrofrows != 0) {
// Second row: header
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$row = mysqli_fetch_array($result, MYSQLI_ASSOC);
$output .= "<tr>\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";
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
$rowcounter = 1;
while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
$output .= "<tr>\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";
$rowcounter++;
}
@ -289,7 +289,7 @@ function printTable($sqlquery) {
// -------------------------------------------------------------------------
// Free the $result
// -------------------------------------------------------------------------
mysql_free_result($result);
mysqli_free_result($result);
return $output;

View file

@ -160,7 +160,7 @@ function net2ftp_module_printBody() {
// -------------------------------------------------------------------------
// 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";
// ------------------------------------
// Input
@ -179,9 +179,9 @@ function net2ftp_module_printBody() {
// Scan the sample
$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";
} // end while
} // end foreach
$net2ftp_output["advanced_parsing"][] = "<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";
// 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
// Print the icon representing the current sortorder
@ -549,7 +549,7 @@ function sort_list($list) {
// Fill the $return array
// -------------------------------------------------------------------------
$i=1;
while(list($tname, $tvalue) = each($temp)) {
foreach ($temp as $tname => $tvalue) {
$return[$i] = $list[$tname];
$i++;
}

View file

@ -480,7 +480,7 @@ function printTextareaSelect($onchange) {
if ($textareaType == "" || $textareaType == "plain") { $plainselected = "selected=\"selected\""; }
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
// which are textareas
// which are suitable for this browser
@ -490,7 +490,7 @@ function printTextareaSelect($onchange) {
else { $selected = ""; }
echo "<option value=\"$pluginName\" $selected>" . $pluginProperties[$pluginName]["label"] . "</option>\n";
} // end if
} // end while
} // end foreach
echo "</select>\n";

View file

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

View file

@ -20,28 +20,28 @@
<input type="hidden" name="url" value="<?php echo htmlEncode2($url); ?>" />
<?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); ?>" />
<?php } // end while ?>
<?php } // end foreach ?>
<?php } // end if ?>
<?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); ?>" />
<?php } // end while ?>
<?php } // end foreach ?>
<?php } // end if ?>
<?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); ?>" />
<?php } // end while ?>
<?php } // end foreach ?>
<?php } // end if ?>
<?php if (is_array($zipactions) == true) { ?>
<?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); ?>" />
<?php } // end while ?>
<?php } // end foreach ?>
<?php } // end for ?>
<?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";
while (list($key,$value) = each($skinArray)) {
foreach ($skinArray as $key => $value) {
// $key loops over "blue", "pastel", ...
// $value will be an array like $value["name"] = "Blue"
if ($key == $currentskin) { $selected = "selected=\"selected\""; }
else { $selected = ""; }
echo "<option value=\"" . $key . "\" $selected>" . $value["name"] . "</option>\n";
} // end while
} // end foreach
echo "</select>\n";

View file

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

View file

@ -45,20 +45,14 @@ $(document).ready(function(){
require_once('includes/form_table_class.php');
require_once('includes/lib_remote.php');
if ( function_exists('mysqli_connect') )
require_once("modules/mysql/mysqli_database.php");
else
require_once("modules/mysql/mysql_database.php");
// mysqli is always available in PHP 7+
require_once("modules/mysql/mysqli_database.php");
function get_mysql_admin_user(array $mysql_server) {
return !empty($mysql_server['mysql_admin_user']) ? $mysql_server['mysql_admin_user'] : 'root';
}
function mysqli_connect_safe($host, $user, $pass, $db = "", $port = null) {
if (!function_exists('mysqli_connect')) {
return false;
}
mysqli_report(MYSQLI_REPORT_OFF);
try {
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']));
}
@ -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);
}
}
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 )
@ -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);
}
}
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);
}
}
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);
}
}
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) {
if ( !extension_loaded("mysql") )
return -99;
// The mysql extension was removed in PHP 7. This class now uses mysqli.
$this->table_prefix = $table_prefix;
/// \todo We might want to do other checks here as well?
if ( $db_host === NULL )
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 )
return -11;
if ( mysql_select_db($db_name,$this->link) === FALSE )
return -12;
return TRUE;
}
@ -60,20 +56,20 @@ class MySQLModuleDatabase extends OGPDatabaseMySQL
if ( !$this->link ) return FALSE;
++$this->queries_;
$result = mysql_query($query, $this->link);
$result = mysqli_query($this->link, $query);
if ( mysql_errno($this->link) > 0 )
print mysql_error($this->link);
if ( mysqli_errno($this->link) > 0 )
print mysqli_error($this->link);
if ( $result === FALSE )
return FALSE;
if ( mysql_num_rows($result) == 0 )
if ( mysqli_num_rows($result) == 0 )
return FALSE;
$results = array();
while ( $row = mysql_fetch_assoc( $result ) )
while ( $row = mysqli_fetch_assoc( $result ) )
array_push($results,$row);
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`)
VALUES('%s','%s','%s','%s','%s','%s','%s');",
$this->table_prefix,
mysql_real_escape_string($remote_server_id,$this->link),
mysql_real_escape_string($mysql_name,$this->link),
mysql_real_escape_string($mysql_ip,$this->link),
mysql_real_escape_string($mysql_port,$this->link),
mysql_real_escape_string($mysql_admin_user,$this->link),
mysql_real_escape_string($mysql_root_passwd,$this->link),
mysql_real_escape_string($privilegies_str,$this->link));
mysqli_real_escape_string($this->link, $remote_server_id),
mysqli_real_escape_string($this->link, $mysql_name),
mysqli_real_escape_string($this->link, $mysql_ip),
mysqli_real_escape_string($this->link, $mysql_port),
mysqli_real_escape_string($this->link, $mysql_admin_user),
mysqli_real_escape_string($this->link, $mysql_root_passwd),
mysqli_real_escape_string($this->link, $privilegies_str));
++$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 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)
@ -118,17 +114,17 @@ class MySQLModuleDatabase extends OGPDatabaseMySQL
`mysql_admin_user` = '%s', `mysql_root_passwd` = '%s', `privilegies_str` = '%s'
WHERE `mysql_server_id` = %s;",
$this->table_prefix,
mysql_real_escape_string($remote_server_id,$this->link),
mysql_real_escape_string($mysql_name,$this->link),
mysql_real_escape_string($mysql_ip,$this->link),
mysql_real_escape_string($mysql_port,$this->link),
mysql_real_escape_string($mysql_admin_user,$this->link),
mysql_real_escape_string($mysql_root_passwd,$this->link),
mysql_real_escape_string($privilegies_str,$this->link),
mysql_real_escape_string($mysql_server_id,$this->link));
mysqli_real_escape_string($this->link, $remote_server_id),
mysqli_real_escape_string($this->link, $mysql_name),
mysqli_real_escape_string($this->link, $mysql_ip),
mysqli_real_escape_string($this->link, $mysql_port),
mysqli_real_escape_string($this->link, $mysql_admin_user),
mysqli_real_escape_string($this->link, $mysql_root_passwd),
mysqli_real_escape_string($this->link, $privilegies_str),
mysqli_real_escape_string($this->link, $mysql_server_id));
++$this->queries_;
if ( mysql_query($query) === FALSE )
if ( mysqli_query($this->link, $query) === FALSE )
return FALSE;
return TRUE;
@ -145,20 +141,20 @@ class MySQLModuleDatabase extends OGPDatabaseMySQL
$query = sprintf("SELECT * FROM `%smysql_servers` WHERE `mysql_server_id` = %d",
$this->table_prefix,
mysql_real_escape_string($id,$this->link));
mysqli_real_escape_string($this->link, $id));
++$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 ( mysql_num_rows($result) != 1 )
if ( mysqli_num_rows($result) != 1 )
return FALSE;
return mysql_fetch_assoc( $result );
return mysqli_fetch_assoc( $result );
}
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;
@ -169,7 +165,7 @@ class MySQLModuleDatabase extends OGPDatabaseMySQL
{
$query = sprintf($query,$this->table_prefix,$mysql_server_id);
++$this->queries_;
$result = mysql_query($query,$this->link);
$result = mysqli_query($this->link, $query);
$return = ($result === FALSE) ? FALSE : $return;
}
return $return;
@ -178,7 +174,7 @@ class MySQLModuleDatabase extends OGPDatabaseMySQL
public function getMysqlServerDBs($mysql_server_id){
$query = sprintf("SELECT * FROM `%smysql_databases` WHERE mysql_server_id = %d;",
$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);
}
@ -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`)
VALUES('%d','%d','%s','%s','%s','%d');",
$this->table_prefix,
mysql_real_escape_string($mysql_server_id,$this->link),
mysql_real_escape_string($home_id,$this->link),
mysql_real_escape_string($db_user,$this->link),
mysql_real_escape_string($db_passwd,$this->link),
mysql_real_escape_string($db_name,$this->link),
mysql_real_escape_string($enabled,$this->link));
mysqli_real_escape_string($this->link, $mysql_server_id),
mysqli_real_escape_string($this->link, $home_id),
mysqli_real_escape_string($this->link, $db_user),
mysqli_real_escape_string($this->link, $db_passwd),
mysqli_real_escape_string($this->link, $db_name),
mysqli_real_escape_string($this->link, $enabled));
++$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 mysql_insert_id($this->link);
return mysqli_insert_id($this->link);
}
public function getMysqlDBbyId($db_id){
$query = sprintf('SELECT * FROM `%1$smysql_databases` NATURAL JOIN `%1$smysql_servers` WHERE db_id = %2$d;',
$this->table_prefix,
mysql_real_escape_string($db_id,$this->link));
mysqli_real_escape_string($this->link, $db_id));
$db_info = $this->listQuery($query);
return $db_info[0];
}
@ -214,15 +210,15 @@ class MySQLModuleDatabase extends OGPDatabaseMySQL
public function getMysqlDBsbyHomeId($home_id){
$query = sprintf('SELECT * FROM `%1$smysql_databases` WHERE enabled = 1 AND home_id = %2$d;',
$this->table_prefix,
mysql_real_escape_string($home_id,$this->link));
mysqli_real_escape_string($this->link, $home_id));
return $this->listQuery($query);
}
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;',
$this->table_prefix,
mysql_real_escape_string($home_id,$this->link),
mysql_real_escape_string($db_id,$this->link));
mysqli_real_escape_string($this->link, $home_id),
mysqli_real_escape_string($this->link, $db_id));
$db_info = $this->listQuery($query);
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'
WHERE `db_id` = '%d';",
$this->table_prefix,
mysql_real_escape_string($home_id, $this->link),
mysql_real_escape_string($db_user, $this->link),
mysql_real_escape_string($db_passwd, $this->link),
mysql_real_escape_string($db_name, $this->link),
mysql_real_escape_string($enabled, $this->link),
mysql_real_escape_string($db_id, $this->link) );
mysqli_real_escape_string($this->link, $home_id),
mysqli_real_escape_string($this->link, $db_user),
mysqli_real_escape_string($this->link, $db_passwd),
mysqli_real_escape_string($this->link, $db_name),
mysqli_real_escape_string($this->link, $enabled),
mysqli_real_escape_string($this->link, $db_id) );
++$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 true;
@ -254,10 +250,10 @@ class MySQLModuleDatabase extends OGPDatabaseMySQL
$query = sprintf("DELETE FROM `%smysql_databases`
WHERE `db_id` = '%d'",
$this->table_prefix,
mysql_real_escape_string($db_id, $this->link));
mysqli_real_escape_string($this->link, $db_id));
++$this->queries_;
if ( mysql_query($query) === FALSE )
if ( mysqli_query($this->link, $query) === FALSE )
return FALSE;
return TRUE;
@ -267,7 +263,7 @@ class MySQLModuleDatabase extends OGPDatabaseMySQL
$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;',
$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);
}
}

View file

@ -234,33 +234,17 @@ function exec_ogp_module() {
else
{
$mysql_admin_user = get_mysql_admin_user($mysql_server);
if( function_exists('mysqli_connect') )
{
$link = mysqli_connect_safe($mysql_server['mysql_ip'], $mysql_admin_user, $mysql_server['mysql_root_passwd'], "", $mysql_server['mysql_port']);
// 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']);
if ( $link === FALSE )
{
$server_status = "<span class='failure'>".get_lang('mysql_offline')."</span>";
}
else
{
$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
{
@$link = mysql_connect($mysql_server['mysql_ip'].':'.$mysql_server['mysql_port'], $mysql_admin_user, $mysql_server['mysql_root_passwd']);
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);
}
$server_status = "<span class='success'>".get_lang('mysql_online')."</span>";
mysqli_close($link);
}
}

View file

@ -32,20 +32,14 @@ $(document).ready(function(){
require_once("modules/mysql/functions.php");
require_once('includes/form_table_class.php');
require_once('includes/lib_remote.php');
if ( function_exists('mysqli_connect') )
require_once("modules/mysql/mysqli_database.php");
else
require_once("modules/mysql/mysql_database.php");
// mysqli is always available in PHP 7+
require_once("modules/mysql/mysqli_database.php");
function get_mysql_admin_user(array $mysql_server) {
return !empty($mysql_server['mysql_admin_user']) ? $mysql_server['mysql_admin_user'] : 'root';
}
function mysqli_connect_safe($host, $user, $pass, $db = "", $port = null) {
if (!function_exists('mysqli_connect')) {
return false;
}
mysqli_report(MYSQLI_REPORT_OFF);
try {
return mysqli_connect($host, $user, $pass, $db, $port);
@ -145,26 +139,6 @@ function exec_ogp_module() {
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']))
@ -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);
}
}
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 )

View file

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

View file

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

View file

@ -896,8 +896,7 @@ class Smarty_Internal_Template extends Smarty_Internal_Data {
{
static $camel_func;
if (!isset($camel_func))
$camel_func = create_function('$c', 'return "_" . strtolower($c[1]);');
// see if this is a set/get for a property
$camel_func = function($c) { return "_" . strtolower($c[1]); };
$first3 = strtolower(substr($name, 0, 3));
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