ソースを参照

Small fixes to make the panel work on PHP8

dani 3 年 前
コミット
14a7e8588a

+ 23 - 8
includes/database_mysqli.php

@@ -68,7 +68,7 @@ class OGPDatabaseMySQL extends OGPDatabase
 	}
 	
 	public function realEscapeSingle($string){
-		return mysqli_real_escape_string($this->link, $string);
+		return mysqli_real_escape_string($this->link, @(string)$string);
 	}
 
 	private function listQuery($query) {
@@ -1160,15 +1160,22 @@ class OGPDatabaseMySQL extends OGPDatabase
 		if ( !$this->link ) return FALSE;
 
 		$query = str_replace( "OGP_DB_PREFIX", $this->table_prefix, $query );
+		
+		try {
+			$query = mysqli_query($this->link,$query);
+			if ($query === FALSE) {
+				throw new Exception(mysqli_error($this->link));
+			}
 
-		++$this->queries_;
-		mysqli_query($this->link,$query);
+		} catch(Exception $e) {
+			return FALSE;
+		}
 
 		if( mysqli_errno($this->link) != 0 )
 		{
 			return FALSE;
 		}
-
+		
 		return TRUE;
 	}
 
@@ -2185,7 +2192,7 @@ class OGPDatabaseMySQL extends OGPDatabase
 		return $this->listQuery($query);
 	}
 	
-	public function getIpPorts_limit($ip_id = 0,$page_dashboardlist,$limit_dashboardlist) {
+	public function getIpPorts_limit($ip_id = 0,$page_dashboardlist = 0,$limit_dashboardlist = 1) {
 		$ip_id = $this->realEscapeSingle($ip_id);
 		$user_request_page = ($page_dashboardlist - 1) * $limit_dashboardlist;
 		
@@ -3566,15 +3573,22 @@ class OGPDatabaseMySQL extends OGPDatabase
 		
 	public function getNextAvailablePort($ip_id,$home_cfg_id){
 		$ranges = $this->getPortsRange($ip_id,$home_cfg_id);
-		$range = $ranges[0];
+		if($ranges === false)
+			$range = array();
+		else
+			$range = $ranges[0];
+		
 		if(empty($range))
 		{
 			$ranges = $this->getPortsRange($ip_id,"0");
-			$range = $ranges[0];
+			if($ranges === false)
+				$range = array();
+			else
+				$range = $ranges[0];
 		}
 		if(empty($range))
 			$range = array('start_port' => '27015','end_port' => '39915', 'port_increment' => '100');
-			
+		
 		$home_used_ports = $this->getIpPorts($ip_id);	
 		$used_ports = array();
 		if(!empty($home_used_ports))
@@ -3882,6 +3896,7 @@ class OGPDatabaseMySQL extends OGPDatabase
 	
 	public function checkApiTable()
 	{
+		//echo "<h1>PUTO " . ($this->query('SELECT 1 FROM '.$this->table_prefix.'api_tokens LIMIT 1') ? 'true' : 'false') . "</h1>";
 		if(!$this->query('SELECT 1 FROM '.$this->table_prefix.'api_tokens LIMIT 1'))
 		{
 			$this->query(	"CREATE TABLE IF NOT EXISTS `".$this->table_prefix.'api_tokens'."` (".

+ 1 - 1
includes/functions.php

@@ -622,7 +622,7 @@ function getClientIPAddress(){
 		$ip = $_SERVER['HTTP_X_REAL_IP'];
 	}
 	
-	if(filter_var($ip, FILTER_VALIDATE_IP)){
+	if(filter_var(@(string)$ip, FILTER_VALIDATE_IP)){
 		return $ip;
 	}
 		

+ 8 - 8
includes/view.php

@@ -272,25 +272,25 @@ class OGPView {
 		}
 		else
 		{
-			$page = str_replace("%meta%",$this->meta,$page);
-			$top = str_replace("%logo%",$this->logo,$top);
-			$topbody = str_replace("%bg_wrapper%",$this->bg_wrapper,$topbody);
+			$page = str_replace("%meta%",(string)$this->meta,$page);
+			$top = str_replace("%logo%",(string)$this->logo,$top);
+			$topbody = str_replace("%bg_wrapper%",(string)$this->bg_wrapper,$topbody);
 			if ( !empty($_SESSION['users_theme']) ) 
 				$theme = $_SESSION['users_theme'];
 			else 
 				$theme = @$panel_settings['theme'];
 					
-			$page = str_replace("%bg_wrapper%",$this->bg_wrapper,$page);
-        	$page = str_replace("%title%",$this->title,$page);
-        	$page = str_replace("%header_code%",$this->header_code,$page);
-			$page = str_replace("%charset%",$this->charset,$page);
+			$page = str_replace("%bg_wrapper%",(string)$this->bg_wrapper,$page);
+        	$page = str_replace("%title%",(string)$this->title,$page);
+        	$page = str_replace("%header_code%",(string)$this->header_code,$page);
+			$page = str_replace("%charset%",(string)$this->charset,$page);
         	$page = str_replace("%body%",$buffer,$page);
 			$page = str_replace("%top%",$top,$page);
 			$page = str_replace("%topbody%",$topbody,$page);
 			$page = str_replace("%botbody%",$botbody,$page);
 			$page = str_replace("%bottom%",$bottom,$page);
 			$page = str_replace("%footer%",$footer,$page);
-			$page = str_replace("%notifications%",@$notifications,$page);
+			$page = str_replace("%notifications%",@(string)$notifications,$page);
 		}
 		
 		// Set the content-type header as this is needed by older browsers

+ 5 - 2
modules/addonsmanager/addons_manager.php

@@ -343,8 +343,11 @@ function exec_ogp_module() {
 	<table class="center">
 	<?php
 	$group_names = array();
-	foreach($groups as $group)
-		$group_names[$group['group_id']] = $group['group_name'];
+	if(is_array($groups))
+	{
+		foreach($groups as $group)
+			$group_names[$group['group_id']] = $group['group_name'];
+	}
 	
 	if (isset($result) && $result && count($result) > 0)
 	{

+ 3 - 3
modules/extras/extras.php

@@ -59,7 +59,7 @@ function installUpdate($info, $base_dir, $current_blacklist = array())
 	}
 		
 	// Set default values for file checkings before installing
-	$not_writable = can_not_update_non_writable_files ." :\n";
+	$not_writable = get_lang('can_not_update_non_writable_files') ." :\n";
 	$filename = "";
 	$overwritten = 0;
 	$not_overwritten = 0;
@@ -146,7 +146,7 @@ function installUpdate($info, $base_dir, $current_blacklist = array())
 					$newResult["extracted_files"][$i]["filename"] = $filename;
 					$webDir = dirname($web_file);
 					@mkdir($webDir, 0775, true);
-					copy($temp_file, $web_file);
+					@copy($temp_file, $web_file);
 					$i++;
 					$new_files .= $filename . "\n";
 					$new++;
@@ -423,7 +423,7 @@ function exec_ogp_module()
 		$LOCAL_REPO_FILE = DATA_PATH . $repository['name'] . '.atom';
 		if(!file_exists($LOCAL_REPO_FILE) 
 			OR (isset($_GET['searchForUpdates']) and $_GET['searchForUpdates'] == $repository['name']) 
-			OR ( isset($_POST['update']) && ( (in_array($m, $_POST["module"]) && $isModule) || (in_array($t, $_POST["theme"]) && $isTheme) ) ) )
+			OR ( isset($_POST['update']) && ( (in_array($m, @(array)$_POST["module"]) && $isModule) || (in_array($t, @(array)$_POST["theme"]) && $isTheme) ) ) )
 		{
 			$used_file = $REMOTE_REPO_FILE;
 			$contents = file_get_contents($used_file);

+ 1 - 1
modules/ftp/includes/StonePhpSafeCrypt_config.php

@@ -33,7 +33,7 @@
   //  For obvious reasons, be careful to escape backslashes and quote marks
   //  according to PHP rules.  Or, avoid them entirely.  Doesn't matter.
 
-  define('DEFAULT_MD5_SALT', $net2ftp_settings["md5_salt"]); // empty string is illegal
+  define('DEFAULT_MD5_SALT', ''); // empty string is illegal
 
   // examples:
   //

+ 5 - 5
modules/ftp/includes/authorizations.inc.php

@@ -47,11 +47,11 @@ function encryptPassword($password) {
 //	else {
 		$password_encrypted = "";
 		$encryption_string = sha1($net2ftp_settings["encryption_string"]);
-		if ($encryption_string % 2 == 1) { // we need even number of characters
-			$encryption_string .= $encryption_string{0};
+		if (strlen($encryption_string) % 2 == 1) { // we need even number of characters
+			$encryption_string .= $encryption_string[0];
 		}
 		for ($i=0; $i < strlen($password); $i++) { // encrypts one character - two bytes at once
-			$password_encrypted .= sprintf("%02X", hexdec(substr($encryption_string, 2*$i % strlen($encryption_string), 2)) ^ ord($password{$i}));
+			$password_encrypted .= sprintf("%02X", hexdec(substr($encryption_string, 2*$i % strlen($encryption_string), 2)) ^ ord($password[$i]));
 		}
 		return $password_encrypted;
 //	}
@@ -101,8 +101,8 @@ function decryptPassword($password_encrypted) {
 //	else {
 		$password = "";
 		$encryption_string = sha1($net2ftp_settings["encryption_string"]);
-		if ($encryption_string % 2 == 1) { // we need even number of characters
-			$encryption_string .= $encryption_string{0};
+		if (strlen($encryption_string) % 2 == 1) { // we need even number of characters
+			$encryption_string .= $encryption_string[0];
 		}
 		for ($i=0; $i < strlen($password_encrypted); $i += 2) { // decrypts two bytes - one character at once
 			$password .= chr(hexdec(substr($encryption_string, $i % strlen($encryption_string), 2)) ^ hexdec(substr($password_encrypted, $i, 2)));

+ 1 - 1
modules/ftp/includes/browse.inc.php

@@ -858,7 +858,7 @@ function ftp2http($directory, $list_files, $htmltags) {
 
 // Calculate all the URLs on the Browse screen
 		for ($i=1; $i<=sizeof($list_files); $i++) {
-			$URL = "http://" . $net2ftp_globals["ftpserver"]. $directory . "/" . $list_files[$i][$encoding];
+			$URL = "http://" . $net2ftp_globals["ftpserver"]. $directory . "/" . @(string)$list_files[$i][$encoding];
 			if ($htmltags == "no") { $list_links[$i] = $URL; }
 			else                   { $list_links[$i] = "<a href=\"" . $URL . "\" target=\"_blank\" title=\"" . __("Execute %1\$s in a new window", $list_files[$i][$encoding]) . "\">" . $list_files[$i][$encoding] . "</a>"; }
 		} // end for

+ 1 - 1
modules/ftp/includes/filesystem.inc.php

@@ -48,7 +48,7 @@ function ftp_openconnection() {
 
 // Set up basic connection
 	$ftp_connect = "ftp_connect";
-	if ($net2ftp_globals["sslconnect"] == "yes" && function_exists("ftp_ssl_connect")) { $ftp_connect = "ftp_ssl_connect"; }
+	if (array_key_exists("sslconnect", $net2ftp_globals) && $net2ftp_globals["sslconnect"] == "yes" && function_exists("ftp_ssl_connect")) { $ftp_connect = "ftp_ssl_connect"; }
 
 	$conn_id = $ftp_connect($net2ftp_globals["ftpserver"], $net2ftp_globals["ftpserverport"]);
 	if ($conn_id == false) {

+ 1 - 1
modules/ftp/index.php

@@ -18,7 +18,7 @@
     
     David 
 */
-error_reporting(E_ERROR);
+error_reporting(E_ALL);
 
 if(file_exists("includes/helpers.php")){
 	require_once("includes/helpers.php");

+ 7 - 4
modules/ftp/settings.inc.php

@@ -46,6 +46,9 @@ function lang_str($ogp_lang){
 			return "en";
 	}
 }
+
+$settings = $_SESSION['settings'];
+
 $panel_email_address = $settings['panel_email_address'];
 $panel_language = $settings['panel_language'];
 
@@ -70,8 +73,8 @@ if(function_exists("startSession")){
 	session_start();
 }
 
-$net2ftp_settings["default_language"] = ($_SESSION['users_lang'] != "" and $_SESSION['users_lang'] != "-") ? lang_str($_SESSION['users_lang']) : 
-										($panel_language != "-") ? lang_str($panel_language): "en";
+$net2ftp_settings["default_language"] = (($_SESSION['users_lang'] != "" and $_SESSION['users_lang'] != "-") ? lang_str($_SESSION['users_lang']) : 
+										($panel_language != "-")) ? lang_str($panel_language): "en";
 $net2ftp_settings["default_skin"]     = "blue";
 // Enter the address of your help pages, support forum or ticket system
 // This will add a link in the footer; leave empty if you don't have this
@@ -79,8 +82,8 @@ $net2ftp_settings["help_text"] = "";
 $net2ftp_settings["help_link"] = "";
 
 // PHP error reporting
-//$net2ftp_settings["error_reporting"] = "NONE";
-$net2ftp_settings["error_reporting"] = "standard";
+$net2ftp_settings["error_reporting"] = "NONE";
+//$net2ftp_settings["error_reporting"] = "standard";
 //$net2ftp_settings["error_reporting"] = "ALL";
 
 // Fix transparent PNG images in IE

+ 1 - 1
modules/ftp/skins/blue/google_browse.template.php

@@ -1,6 +1,6 @@
 <?php defined("NET2FTP") or die("Direct access to this location is not allowed."); ?>
 <!-- Template /skins/india/google_browse.template.php begin -->
-<?php if ($net2ftp_settings["show_google_ads"] == "yes") { ?>
+<?php if (@(string)$net2ftp_settings["show_google_ads"] == "yes") { ?>
 <script type="text/javascript"><!--
 google_ad_client = "pub-8420366685399799";
 google_ad_width = 728;

+ 1 - 1
modules/ftp/skins/blue/login.template.php

@@ -64,7 +64,7 @@ foreach($user_homes as $ftp_info)
 			<tr>
 			  <td colspan="3">
 				<form id="LoginForm" action="<?php echo $net2ftp_globals["action_url"]; ?>" method="post" onsubmit="return CheckInput(this);">
-				<input type="hidden" name="language" value="<?php echo $_POST['language']; ?>">
+				<input type="hidden" name="language" value="<?php echo @(string)$_POST['language']; ?>">
 				<input type="hidden" name="ftpserverport" value="<?php echo $ftp_info['ftp_port']; ?>">
 				<input type="hidden" name="ftpserver" value="<?php echo $ftp_ip; ?>">
 				<input type="hidden" name="username" value="<?php echo $ftp_login; ?>" autocorrect="off" autocapitalize="off" style="width: 80%;" />

+ 2 - 2
modules/ftp/skins/skins.inc.php

@@ -119,7 +119,7 @@ function net2ftp_skin_printCSS() {
 	elseif ($net2ftp_globals["cookie_skin"] != "") { $currentskin = $net2ftp_globals["cookie_skin"]; }
 	else                                           { $currentskin = "shinra"; }
 
-	echo $skinArray[$currentskin]["css"];
+	echo @(string)$skinArray[$currentskin]["css"];
 
 } // End function net2ftp_skin_printCSS
 
@@ -146,7 +146,7 @@ function net2ftp_skin_printJavascript() {
 	elseif ($net2ftp_globals["cookie_skin"] != "") { $currentskin = $net2ftp_globals["cookie_skin"]; }
 	else                                           { $currentskin = "shinra"; }
 
-	echo $skinArray[$currentskin]["javascript"];
+	echo @(string)$skinArray[$currentskin]["javascript"];
 
 } // End function net2ftp_skin_printJavascript
 

+ 3 - 2
modules/gamemanager/cfg_text_replace.php

@@ -33,7 +33,8 @@ $server_home["true"] = "";
 $last_param = json_decode($db->getLastParam($server_home["home_id"]), True);		
 $server_home["max_players"] = isset($cli_param_data['PLAYERS']) ? $cli_param_data['PLAYERS'] : $last_param['players'];
 $server_home["webhost_ip"] = $_SERVER['SERVER_ADDR'];
-$server_home["incremental"] = $db->incrementalNumByHomeId( $server_home["home_id"], $server_home["mod_cfg_id"], $server_home["remote_server_id"] );
+if (array_key_exists("mod_cfg_id", $server_home))
+	$server_home["incremental"] = $db->incrementalNumByHomeId( $server_home["home_id"], $server_home["mod_cfg_id"], $server_home["remote_server_id"] );
 $server_home["map"] = clean_server_param_value(isset($cli_param_data['MAP']) ? $cli_param_data['MAP'] : $last_param['map'], $server_xml->cli_allow_chars);
 
 $isWin = preg_match('/CYGWIN/', $remote->what_os());
@@ -91,7 +92,7 @@ if($fields)
 		{			
 			if ($key == "default_value")
 			{
-				if (array_key_exists((string)$array['key'], $custom_fields))
+				if (array_key_exists((string)$array['key'], (array)$custom_fields))
 					$replacements[$replace_id]['info_param'] = strip_real_escape_string((string)$custom_fields[(string)$array['key']]);
 				else
 					$replacements[$replace_id]['info_param'] = (string)$value;

+ 1 - 1
modules/gamemanager/start_server.php

@@ -114,7 +114,7 @@ function exec_ogp_module()
 	}
 	
 	function getLastLines($string, $n = 1) {
-		$lines = explode("\n", $string);
+		$lines = explode("\n", (string)$string);
 		$lines = array_slice($lines, -$n);
 		return implode("\n", $lines);
 	}

+ 1 - 1
modules/litefm/fm_dir.php

@@ -575,7 +575,7 @@ function exec_ogp_module()
 		// Dialog translation && info
 		$user = $db->getUserById($_SESSION['user_id']);
 		echo "<div id='dialog' ".
-			 "data-folder=\"" . clean_path("/".str_replace('"', "&quot;", @$_SESSION['fm_cwd_'.$home_id])) . "\" " .
+			 "data-folder=\"" . clean_path("/".str_replace('"', "&quot;", @(string)$_SESSION['fm_cwd_'.$home_id])) . "\" " .
 			 "data-select_at_least_one_item='" . get_lang("select_at_least_one_item") . "' " .
 			 "data-ask_delete='" . get_lang("delete_item") . "' " .
 			 "data-ask_rename='" . get_lang("rename_item") . "' " .

+ 1 - 1
protocol/GameQ/GameQMonitor.php

@@ -51,7 +51,7 @@ if($num_of_servers < $numberservers_to_skip_query)
 		$players = $results['server']['gq_numplayers'];
 		$playersmax = $results['server']['gq_maxplayers'];
 		$name = $results['server']['gq_hostname'];
-		$map  = preg_replace("/[^a-z0-9_]/", "_", strtolower($results['server']['gq_mapname']));
+		$map  = preg_replace("/[^a-z0-9_]/", "_", strtolower(@(string)$results['server']['gq_mapname']));
 		
 		//----------+ patches for voice servers (ts2, ts3, ventrilo)
 		if(!$map)$map = $results['server']['gq_type'];

+ 2 - 0
protocol/lgsl/MurmurQuery.php

@@ -339,6 +339,8 @@
 
 	private function _parse_channels($channels)
 	{
+		if(array_key_exists('x_gtmurmur_error', $channels))
+			return;
 		// We'll have to deal with the root channel separately
 		if(array_key_exists('root', $channels))
 		{