-
Notifications
You must be signed in to change notification settings - Fork 1
/
search.php
176 lines (149 loc) · 6.25 KB
/
search.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<?php
/*
AMXBans v6.0
Copyright 2009, 2010 by SeToY & |PJ|ShOrTy
This file is part of AMXBans.
AMXBans is free software, but it's licensed under the
Creative Commons - Attribution-NonCommercial-ShareAlike 2.0
AMXBans is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
You should have received a copy of the cc-nC-SA along with AMXBans.
If not, see <http://creativecommons.org/licenses/by-nc-sa/2.0/>.
*/
session_start();
require_once("include/config.inc.php");
require_once("include/access.inc.php");
require_once("include/menu.inc.php");
require_once("include/steam.inc.php");
require_once("include/sql.inc.php");
require_once("include/logfunc.inc.php");
require_once("include/functions.inc.php");
// Template generieren
$title = "_TITLESEARCH";
$smarty = new dynamicPage;
//get all admins ever
//$admins=sql_get_search_amxadmins();
sql_get_search_amxadmins($amxadmins,$admins);
//get all servers ever
$servers=sql_get_search_servers();
//get all reasons ever
//removed in 6.0beta4, made problems with big dbs
//$reasons=sql_get_search_reasons();
if ((isset($_POST['nick'])) || (isset($_POST['steamid'])) || (isset($_POST['ip'])) || (isset($_POST['reason'])) || (isset($_POST['date'])) || (isset($_POST['timesbanned'])) || (isset($_POST['admin'])) || (isset($_POST['server']))) {
if(isset($_POST["nick"])) {
$nick=trim($_POST["nick"]);
if(validate_value($nick,"name",$msg,2,31,"USERNAME")) {
$search_query="`player_nick` LIKE '%".sql_safe($nick)."%'";
} #else { $msg="_INVALIDNAME"; }
}
if(isset($_POST["steamid"])) {
$steamid=trim($_POST["steamid"]);
if(validate_value($steamid,"name",$msg,2,35,"STEAM")) { //validate only for length
$search_query="`player_id` LIKE '%".sql_safe($steamid)."%'";
} #else { $msg="_INVALIDSTEAMID"; }
}
if(isset($_POST["ip"])) {
$ip=trim($_POST["ip"]);
if(validate_value($ip,"name",$msg,2,15,"IP")) { //validate only for length
$search_query="`player_ip` LIKE '%".sql_safe($ip)."%'";
} #else { $msg="_INVALIDIP"; }
}
if(isset($_POST["reason"])) {
$reason=trim($_POST["reason"]);
if(validate_value($reason,"name",$msg,2,15,"REASON")) { //validate only for length
$search_query="`ban_reason` LIKE '%".sql_safe($reason)."%'";
} #else { $msg="_INVALIDREASON"; }
}
//if(isset($_POST["reason"]) && $_POST["reason"]<>"") $search_query="`ban_reason` LIKE '%".sql_safe($_POST["reason"])."%'";
if(isset($_POST["date"]) && $_POST["date"]<>"") {
$date = substr_replace($_POST['date'], '', 2, 1);
$date = substr_replace($date, '', 4, 1);
$search_query="FROM_UNIXTIME(ban_created,'%d%m%Y') LIKE '".sql_safe($date)."'";
}
if(isset($_POST["admin"]) && $_POST["admin"]<>"") $search_query="`admin_id`='".sql_safe($_POST["admin"])."'";
if(isset($_POST["server"]) && $_POST["server"]<>"") {
if($_POST["server"]=="website") {
$search_query="`server_name`='".sql_safe($_POST["server"])."'";
} else {
$search_query="`server_ip`='".sql_safe($_POST["server"])."'";
}
}
$count_aktiv=0;
$count_exp=0;
if($search_query) {
$ban_list_aktiv=sql_get_search_bans($search_query,1,$count_aktiv);
$ban_list_exp=sql_get_search_bans($search_query,0,$count_exp);
}
if(isset($_POST["timesbanned"]) && is_numeric($_POST["timesbanned"])) {
//$query=mysql_query("SELECT * FROM ".$config->db_prefix."_bans WHERE player_id IN (SELECT player_id FROM ".$config->db_prefix."_bans GROUP BY player_id HAVING COUNT(*)>=".(int)$_POST["timesbanned"].") ORDER BY player_id,ban_created DESC") or die (mysql_error());
$query = mysql_query("SELECT *,COUNT(*) as bancount FROM ".$config->db_prefix."_bans GROUP BY player_id HAVING COUNT(*) >= ".(int)$_POST["timesbanned"]." ORDER BY ban_created DESC,player_id");
while($result = mysql_fetch_object($query)) {
if(!empty($result->player_id)) {
$steamid = html_safe($result->player_id);
$steamcomid = GetFriendId($steamid);
}
//search for a activ ban and make it as ref
$query2=mysql_query("SELECT * FROM ".$config->db_prefix."_bans WHERE `player_id`='".$result->player_id."' AND `expired`=0 ORDER BY ban_created DESC LIMIT 1");
if(mysql_num_rows($query2)) {
$result2 = mysql_fetch_object($query2);
$result2->bancount=$result->bancount;
$result=$result2;
}
//make array
$ban_row=array(
"bid" => $result->bid,
"player_ip" => $result->player_ip,
"player_id" => $result->player_id,
"player_comid" => $steamcomid,
"player_nick" => html_safe($result->player_nick),
"admin_ip" => $result->admin_ip,
"admin_id" => $result->admin_id,
"admin_nick" => html_safe($result->admin_nick),
"ban_type" => $result->ban_type,
"ban_reason" => html_safe($result->ban_reason),
"ban_created" => $result->ban_created,
"ban_length" => $result->ban_length,
"ban_end" => ($result->ban_created + ($result->ban_length * 60)),
"server_ip" => $result->server_ip,
"server_name" => html_safe($result->server_name),
"bancount" => $result->bancount
);
$count++;
if($result->expired==0) {
$ban_list_aktiv[]=$ban_row;
$count_aktiv++;
} else {
$ban_list_exp[]=$ban_row;
$count_exp++;
}
}
}
//echo "DEBUG: ".$count_aktiv."/".$count_exp.":".$search_query;
$smarty->assign("ban_list_aktiv",$ban_list_aktiv);
$smarty->assign("ban_list_aktiv_count",$count_aktiv);
$smarty->assign("ban_list_exp",$ban_list_exp);
$smarty->assign("ban_list_exp_count",$count_exp);
$smarty->assign("search_done",1);
}
$smarty->assign("amxadmins",$amxadmins);
$smarty->assign("admins",$admins);
$smarty->assign("servers",$servers);
//$smarty->assign("reasons",$reasons);
$smarty->assign("meta","");
$smarty->assign("title",$title);
$smarty->assign("version_web",$config->v_web);
// amxbans.css available in design? if not, take default one.
if(file_exists("templates/".$config->design."/amxbans.css")) {
$smarty->assign("design",$config->design);
}
$smarty->assign("dir",$config->document_root);
$smarty->assign("this",$_SERVER['PHP_SELF']);
$smarty->assign("menu",$menu);
$smarty->assign("msg",$msg);
$smarty->assign("banner",$config->banner);
$smarty->assign("banner_url",$config->banner_url);
$smarty->display('main_header.tpl');
$smarty->display('search.tpl');
$smarty->display('main_footer.tpl');
?>