Участник
Пользователь
- Сообщения
- 281
- Реакции
- 196
- Помог
- 1 раз(а)
При заходе на сайт показывает ошибку, начальная страничка отображает все баны
Ошибка 500
count(): Parameter must be an array or an object that implements Countable
Версия php 7.4.15
панель Plesk
debian 10
на старой версии пхп работает, куда копать не пойму, в логах пусто
прошу помочь)
Я так понимаю собака зарыта где-то тут
Ошибка 500
count(): Parameter must be an array or an object that implements Countable
Версия php 7.4.15
панель Plesk
debian 10
на старой версии пхп работает, куда копать не пойму, в логах пусто
прошу помочь)
3 Мар 2021
PHP:
//create default ban list and show it
if(!$user_site) {
//count activ bans
$query = mysql_query("SELECT COUNT(bid) FROM `".$config->db_prefix."_bans` WHERE `expired`=0") or die (mysql_error());
$ban_count[0]=mysql_result($query,0);
//count all bans
$query = mysql_query("SELECT COUNT(bid) FROM `".$config->db_prefix."_bans`") or die (mysql_error());
$ban_count[1]=mysql_result($query,0);
//calc max sites
$ban_page_max=ceil($ban_count[0] / $config->bans_per_page);
if(isset($_REQUEST["site"])) $page=(int)$_REQUEST["site"];
if(isset($_REQUEST["siteback_x"])) $page=(int)$_REQUEST["site"];
if(isset($_REQUEST["sitenext_x"])) $page=(int)$_REQUEST["site"];
if(isset($_REQUEST["sitestart_x"])) $page=1;
if(isset($_REQUEST["siteend_x"])) $page=$ban_page_max;
//check if site nr is valid
$ban_page_curr=($page==0 || $page>$ban_page_max) ? 1:$page;
//calc mysql limits from current site
$min=($config->bans_per_page * $ban_page_curr)-$config->bans_per_page;
//build array with site info
$ban_page=array(
"current" => $ban_page_curr, //current site
"max_page" => ($ban_page_max)? $ban_page_max:1, //last site
"per_page" => $config->bans_per_page, //bans per page
"first_ban" => ($ban_count[0])? $min + 1:$min, //+1: LIMIT 0 is the first ban
"max_ban" => $ban_count[0], //count activ bans
"all_ban" => $ban_count[1] //count all bans
);
//get bans for current page
$query = mysql_query("SELECT ba.*, se.gametype,se.timezone_fixx, aa.nickname FROM `".$config->db_prefix."_bans` AS ba
LEFT JOIN `".$config->db_prefix."_serverinfo` AS se ON ba.server_ip=se.address
LEFT JOIN `".$config->db_prefix."_amxadmins` AS aa ON (aa.steamid=ba.admin_nick OR aa.steamid=ba.admin_ip OR aa.steamid=ba.admin_id)
WHERE ba.expired=0 GROUP BY bid ORDER BY ban_created DESC LIMIT ".$min.",".$config->bans_per_page) or die(mysql_error());
//build ban list array
$ban_list=array();
$gi = geoip_open($config->path_root."/include/GeoIP.dat",GEOIP_STANDARD);
while($result = mysql_fetch_object($query)) {
if($result->expired==1) continue;
$steamid="";
$steamcomid="";
if(!empty($result->player_id)) {
$steamid = htmlentities($result->player_id, ENT_QUOTES);
$steamcomid = GetFriendId($steamid);
}
$cc="";
$cn="";
if(!empty($result->player_ip)) {
$cc = geoip_country_code_by_addr($gi, $result->player_ip);
$cn = geoip_country_name_by_addr($gi, $result->player_ip);
}
$ban_row=array(
"bid" => $result->bid,
"player_ip" => $result->player_ip,
"player_id" => $result->player_id,
"player_comid" => $steamcomid,
"player_nick" => htmlspecialchars($result->player_nick),
"admin_ip" => $result->admin_ip,
"admin_id" => $result->admin_id,
"admin_nick" => htmlspecialchars($result->admin_nick),
"ban_type" => $result->ban_type,
"ban_reason" => htmlspecialchars($result->ban_reason),
"ban_created" => ($result->ban_created + ($result->timezone_fixx * 60 * 60)),
"ban_length" => $result->ban_length,
"ban_end" => ($result->ban_created + ($result->ban_length * 60) + ($result->timezone_fixx * 60 * 60)),
"server_ip" => $result->server_ip,
"server_name" => htmlspecialchars($result->server_name),
"cc" => $cc,
"cn" => $cn
);
// get previous offences if any
$query2 = mysql_query("SELECT COUNT(*) AS count FROM `".$config->db_prefix."_bans` WHERE ((player_id = '".$result->player_id."' AND ban_type = 'S') OR (player_ip = '".$result->player_ip."' AND ban_type = 'SI')) AND expired = 1") or die(mysql_error());
while($result2 = mysql_fetch_object($query2)) {
$ban_row["bancount"] = $result2->count;
}
//if needed prune bans but after query to see it in the list once
if($config->auto_prune=="1") {
//first search for max offence bans
if(($ban_row["bancount"] + 1) >= $config->max_offences && $ban_row["ban_length"] >= "0") {
$ban_row["ban_length"] = "0";
$ban_row["ban_reason"] = $config->max_offences_reason;
$prune_query = mysql_query("UPDATE `".$config->db_prefix."_bans` SET `expired`=0,`ban_length`=0,`ban_reason`='".$config->max_offences_reason."' WHERE `bid`=".$result->bid);
$prune_query = mysql_query("INSERT INTO `".$config->db_prefix."_bans_edit` (`bid`,`edit_time`,`admin_nick`,`edit_reason`) VALUES (
'".$result->bid."',UNIX_TIMESTAMP(NOW()),'amxbans','".$config->max_offences_reason."')");
}
//prune expired bans
if($ban_row["ban_end"] < time() && $ban_row["ban_length"] != "0") {
$prune_query = mysql_query("UPDATE `".$config->db_prefix."_bans` SET `expired`=1 WHERE `bid`=".$result->bid);
$prune_query = mysql_query("INSERT INTO `".$config->db_prefix."_bans_edit` (`bid`,`edit_time`,`admin_nick`,`edit_reason`) VALUES (
'".$result->bid."','".$ban_row["ban_end"]."','amxbans','Bantime expired')");
}
}
if($result->server_ip=="") {
$ban_row["mod"]="html";
} else {
$ban_row["mod"]=($result->gametype=="" || $result->gametype=="website")?"html":$result->gametype;
$ban_row["nickname"]=htmlspecialchars($result->nickname);
}
if($config->show_kick_count=="1") {
$ban_row["kick_count"]=$result->ban_kicks;
$ban_page["show_kicks"]=1;
}
if($config->show_demo_count=="1") {
$ban_row["demo_count"]=sql_get_files_count($result->bid);
$ban_page["show_demos"]=1;
}
if($config->show_comment_count=="1") {
$ban_row["comment_count"]=sql_get_comments_count($result->bid);
$ban_page["show_comments"]=1;
}
$ban_list[]=$ban_row;
}
geoip_close($gi);
$smarty->assign("ban_list",$ban_list);
$smarty->assign("ban_page",$ban_page);
}