diff --git a/includes/PHPMailer/class.phpmailer.php b/includes/PHPMailer/class.phpmailer.php index 4dd9a044..327d7f90 100644 --- a/includes/PHPMailer/class.phpmailer.php +++ b/includes/PHPMailer/class.phpmailer.php @@ -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()); diff --git a/includes/functions.php b/includes/functions.php index cb96b11f..bd374ceb 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -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); } } diff --git a/modules/TS3Admin/smarty/Smarty_Compiler.class.php b/modules/TS3Admin/smarty/Smarty_Compiler.class.php index e1e5cea8..c0a2d5ce 100644 --- a/modules/TS3Admin/smarty/Smarty_Compiler.class.php +++ b/modules/TS3Admin/smarty/Smarty_Compiler.class.php @@ -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 */ diff --git a/modules/dsi/geoip.inc.php b/modules/dsi/geoip.inc.php index f7f1c2c5..fa717f1a 100644 --- a/modules/dsi/geoip.inc.php +++ b/modules/dsi/geoip.inc.php @@ -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; } diff --git a/modules/ftp/includes/authorizations.inc.php b/modules/ftp/includes/authorizations.inc.php index 2342bd8f..f62efc13 100644 --- a/modules/ftp/includes/authorizations.inc.php +++ b/modules/ftp/includes/authorizations.inc.php @@ -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)
$sqlquery1"); - $nrofrows1 = mysql_num_rows($result1); + $result1 = mysqli_query($mydb, "$sqlquery1") or die("Unable to execute SQL SELECT query (isAuthorizedDirectory > sqlquery1)
$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 { diff --git a/modules/ftp/includes/consumption.inc.php b/modules/ftp/includes/consumption.inc.php index 3d506eaa..219bb322 100644 --- a/modules/ftp/includes/consumption.inc.php +++ b/modules/ftp/includes/consumption.inc.php @@ -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)
$sqlquery1"); - $nrofrows1 = mysql_num_rows($result1); + $result1 = mysqli_query($mydb, "$sqlquery1") or die("Unable to execute SQL SELECT query (getConsumption > sqlquery1)
$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)
$sqlquery2"); - $nrofrows2 = mysql_num_rows($result2); + $result2 = mysqli_query($mydb, "$sqlquery2") or die("Unable to execute SQL SELECT query (getConsumption > sqlquery2)
$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; diff --git a/modules/ftp/includes/database.inc.php b/modules/ftp/includes/database.inc.php index a4177132..f1adb319 100644 --- a/modules/ftp/includes/database.inc.php +++ b/modules/ftp/includes/database.inc.php @@ -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 diff --git a/modules/ftp/includes/filesystem.inc.php b/modules/ftp/includes/filesystem.inc.php index edf793d8..7625050f 100644 --- a/modules/ftp/includes/filesystem.inc.php +++ b/modules/ftp/includes/filesystem.inc.php @@ -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.
Please enter an address in the format username@domain.com", $To); setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__); return false; diff --git a/modules/ftp/includes/logging.inc.php b/modules/ftp/includes/logging.inc.php index 6db7da46..da90df43 100644 --- a/modules/ftp/includes/logging.inc.php +++ b/modules/ftp/includes/logging.inc.php @@ -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)
$sqlquery1"); - $nrofrows1 = mysql_num_rows($result1); + $result1 = mysqli_query($mydb, "$sqlquery1") or die("Unable to execute SQL SELECT query (getLogStatus > sqlquery1)
$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 %1\$s 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."); diff --git a/modules/ftp/includes/pclzip.lib.php b/modules/ftp/includes/pclzip.lib.php index d26819a1..73fcc89a 100644 --- a/modules/ftp/includes/pclzip.lib.php +++ b/modules/ftp/includes/pclzip.lib.php @@ -5335,24 +5335,9 @@ echo "p entry filename 2 is " . $p_entry['filename'] . "
\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'] . "
\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; diff --git a/modules/ftp/includes/registerglobals.inc.php b/modules/ftp/includes/registerglobals.inc.php index d883d700..443ea45a 100644 --- a/modules/ftp/includes/registerglobals.inc.php +++ b/modules/ftp/includes/registerglobals.inc.php @@ -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 diff --git a/modules/ftp/languages/languages.inc.php b/modules/ftp/languages/languages.inc.php index 3998ec13..d857eff6 100644 --- a/modules/ftp/languages/languages.inc.php +++ b/modules/ftp/languages/languages.inc.php @@ -119,13 +119,13 @@ function printLanguageSelect($fieldname, $onchange, $style, $class) { echo "\n"; diff --git a/modules/ftp/modules/admin_createtables/admin_createtables.inc.php b/modules/ftp/modules/admin_createtables/admin_createtables.inc.php index 7cd9ff2f..dfe46765 100644 --- a/modules/ftp/modules/admin_createtables/admin_createtables.inc.php +++ b/modules/ftp/modules/admin_createtables/admin_createtables.inc.php @@ -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 %1\$s 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 %1\$s.", $dbserver2_html) . "\n"; } } @@ -241,7 +241,7 @@ function net2ftp_module_printBody() { // ------------------------------------ if ($mydb != false && $mysql_select_db_result != false) { for ($i=0; $i%1\$s could not be executed.", $i+1) . "\n"; } else { $net2ftp_output["admin_createtables"][] = __("The SQL query nr %1\$s was executed successfully.", $i+1) . "\n"; } } diff --git a/modules/ftp/modules/admin_viewlogs/admin_viewlogs.inc.php b/modules/ftp/modules/admin_viewlogs/admin_viewlogs.inc.php index c50dc1f3..91badb6f 100644 --- a/modules/ftp/modules/admin_viewlogs/admin_viewlogs.inc.php +++ b/modules/ftp/modules/admin_viewlogs/admin_viewlogs.inc.php @@ -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 %1\$s.", $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 .= "\n"; $output .= "Index\n"; - while(list($fieldname, $fieldvalue) = each($row) ) { $output .= "$fieldname\n"; } + foreach ($row as $fieldname => $fieldvalue) { $output .= "$fieldname\n"; } $output .= "\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 .= "\n"; $output .= "$rowcounter\n"; - while(list($fieldname, $fieldvalue) = each($row) ) { $output .= "" . htmlEncode2($fieldvalue) . "\n"; } + foreach ($row as $fieldname => $fieldvalue) { $output .= "" . htmlEncode2($fieldvalue) . "\n"; } $output .= "\n"; $rowcounter++; } @@ -289,7 +289,7 @@ function printTable($sqlquery) { // ------------------------------------------------------------------------- // Free the $result // ------------------------------------------------------------------------- - mysql_free_result($result); + mysqli_free_result($result); return $output; diff --git a/modules/ftp/modules/advanced_parsing/advanced_parsing.inc.php b/modules/ftp/modules/advanced_parsing/advanced_parsing.inc.php index 65365424..52e30932 100644 --- a/modules/ftp/modules/advanced_parsing/advanced_parsing.inc.php +++ b/modules/ftp/modules/advanced_parsing/advanced_parsing.inc.php @@ -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"][] = "" . $sampleName . "
\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) . "
\n"; - } // end while + } // end foreach $net2ftp_output["advanced_parsing"][] = "
\n"; } $net2ftp_output["advanced_parsing"][] = "

\n"; diff --git a/modules/ftp/modules/browse/browse.inc.php b/modules/ftp/modules/browse/browse.inc.php index a4b873ca..146a139b 100644 --- a/modules/ftp/modules/browse/browse.inc.php +++ b/modules/ftp/modules/browse/browse.inc.php @@ -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++; } diff --git a/modules/ftp/modules/edit/edit.inc.php b/modules/ftp/modules/edit/edit.inc.php index 1ba59135..7d74c24f 100644 --- a/modules/ftp/modules/edit/edit.inc.php +++ b/modules/ftp/modules/edit/edit.inc.php @@ -480,7 +480,7 @@ function printTextareaSelect($onchange) { if ($textareaType == "" || $textareaType == "plain") { $plainselected = "selected=\"selected\""; } echo "\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 "\n"; } // end if - } // end while + } // end foreach echo "\n"; diff --git a/modules/ftp/modules/view/view.inc.php b/modules/ftp/modules/view/view.inc.php index 5aeeb2ce..e13eb120 100644 --- a/modules/ftp/modules/view/view.inc.php +++ b/modules/ftp/modules/view/view.inc.php @@ -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; diff --git a/modules/ftp/skins/blue/login_small.template.php b/modules/ftp/skins/blue/login_small.template.php index 65f9bf45..0f823281 100644 --- a/modules/ftp/skins/blue/login_small.template.php +++ b/modules/ftp/skins/blue/login_small.template.php @@ -20,28 +20,28 @@ - + $value) { ?> - + - + $value) { ?> - + - + $value) { ?> - + - + $value) { ?> - + diff --git a/modules/ftp/skins/skins.inc.php b/modules/ftp/skins/skins.inc.php index 7cbf7486..28bc6b22 100644 --- a/modules/ftp/skins/skins.inc.php +++ b/modules/ftp/skins/skins.inc.php @@ -189,13 +189,13 @@ function printSkinSelect($fieldname, $onchange, $style, $class) { echo "\n"; diff --git a/modules/lgsl_with_img_mod/lgsl_files/geoip.inc.php b/modules/lgsl_with_img_mod/lgsl_files/geoip.inc.php index 46ac448b..4d0ffa01 100644 --- a/modules/lgsl_with_img_mod/lgsl_files/geoip.inc.php +++ b/modules/lgsl_with_img_mod/lgsl_files/geoip.inc.php @@ -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; } diff --git a/modules/lgsl_with_img_mod/lgsl_files/lgsl_admin.php b/modules/lgsl_with_img_mod/lgsl_files/lgsl_admin.php index 9d39b351..a3070099 100644 --- a/modules/lgsl_with_img_mod/lgsl_files/lgsl_admin.php +++ b/modules/lgsl_with_img_mod/lgsl_files/lgsl_admin.php @@ -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'])) diff --git a/modules/mysql/edit_server.php b/modules/mysql/edit_server.php index 93a48ba3..4d7d0a94 100644 --- a/modules/mysql/edit_server.php +++ b/modules/mysql/edit_server.php @@ -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); - } - } } } } diff --git a/modules/mysql/mysql_database.php b/modules/mysql/mysql_database.php index d7179833..c31ae35f 100644 --- a/modules/mysql/mysql_database.php +++ b/modules/mysql/mysql_database.php @@ -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); } } diff --git a/modules/mysql/servers.php b/modules/mysql/servers.php index 1429c344..3251f975 100644 --- a/modules/mysql/servers.php +++ b/modules/mysql/servers.php @@ -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 = "".get_lang('mysql_offline').""; - } - else - { - $server_status = "".get_lang('mysql_online').""; - mysqli_close($link); - } + if ( $link === FALSE ) + { + $server_status = "".get_lang('mysql_offline').""; } 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 = "".get_lang('mysql_offline').""; - } - else - { - $server_status = "".get_lang('mysql_online').""; - mysql_close($link); - } + $server_status = "".get_lang('mysql_online').""; + mysqli_close($link); } } diff --git a/modules/mysql/user_db.php b/modules/mysql/user_db.php index 491059aa..59fc36ac 100644 --- a/modules/mysql/user_db.php +++ b/modules/mysql/user_db.php @@ -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 ) diff --git a/modules/register/register-exec.php b/modules/register/register-exec.php index 83dd1bcf..6f098320 100644 --- a/modules/register/register-exec.php +++ b/modules/register/register-exec.php @@ -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; } diff --git a/modules/subusers/add_subuser-exec.php b/modules/subusers/add_subuser-exec.php index b71e0f59..829946c2 100644 --- a/modules/subusers/add_subuser-exec.php +++ b/modules/subusers/add_subuser-exec.php @@ -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; } diff --git a/modules/teamspeak3/libs/Smarty/libs/Smarty.class.php b/modules/teamspeak3/libs/Smarty/libs/Smarty.class.php index ade63ec7..483f99d8 100644 --- a/modules/teamspeak3/libs/Smarty/libs/Smarty.class.php +++ b/modules/teamspeak3/libs/Smarty/libs/Smarty.class.php @@ -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; diff --git a/modules/teamspeak3/libs/Smarty/libs/sysplugins/smarty_internal_template.php b/modules/teamspeak3/libs/Smarty/libs/sysplugins/smarty_internal_template.php index 592c2580..9c11c170 100644 --- a/modules/teamspeak3/libs/Smarty/libs/sysplugins/smarty_internal_template.php +++ b/modules/teamspeak3/libs/Smarty/libs/sysplugins/smarty_internal_template.php @@ -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