/
export_bans.php
139 lines (107 loc) · 3.36 KB
/
export_bans.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
<?php
// Start session
session_start();
// Require basic site files
require("include/config.inc.php"); // General configuration settings for the site
if ($config->error_handler == "enabled") {
include("$config->error_handler_path");
}
include("$config->path_root/include/functions.lang.php");
include("$config->path_root/include/accesscontrol.inc.php");
if($_SESSION['bans_export'] != "yes") {
echo "You do not have the required credentials to view this page.";
exit();
}
if (!isset($_POST['gtype'])) {
$gtype = "all";
} else {
$gtype = $_POST['gtype'];
}
if (!isset($_POST['bantype'])) {
$bantype = "perm";
} else {
$bantype = $_POST['bantype'];
}
// Make the array for the gametypes
$resource = mysql_query("SELECT DISTINCT gametype FROM $config->servers") or die (mysql_error());
$gametypes = array();
while($result = mysql_fetch_object($resource)) {
$gametype = $result->gametype;
// Asign variables to the array used in the template
$gametypes_info = array(
"gametype" => $gametype
);
$gametypes[] = $gametypes_info;
}
if (isset($_REQUEST['submitted'])) {
//echo "<pre>";
//print_r($_POST);
//echo "</pre>";
if ((isset($_POST['include_reason'])) && ($_POST['include_reason'] == "include")) {
$reason = "on";
} else {
$reason = "off";
}
$now = date('F j, Y, \a\t g:i A');
// Format the query based on submitted data
if($gtype != "all") {
$table = "$config->bans, $config->servers";
} else {
$table = "$config->bans";
}
if($bantype == "temp") {
$list_exportbans = "SELECT player_id, ban_reason FROM $table WHERE ban_length != '0'";
} else if ($bantype == "both") {
$list_exportbans = "SELECT player_id, ban_reason FROM $table WHERE 1";
} else {
$list_exportbans = "SELECT player_id, ban_reason FROM $table WHERE ban_length = '0'";
}
if($gtype != "all") {
$list_exportbans = $list_exportbans." AND $config->bans.server_ip = $config->servers.address AND $config->servers.gametype = '$gtype'";
}
$list_exportbans = $list_exportbans." ORDER BY $config->bans.player_id ASC";
$exportedbans = mysql_query($list_exportbans) or die (mysql_error());
$data = array();
while($myexportbans = mysql_fetch_object($exportedbans)) {
// Asign variables to the array used in the template
$mybans = array(
"steamid" => $myexportbans->player_id,
"reason" => $myexportbans->ban_reason
);
$data[] = $mybans;
}
/*
while ($myexportbans = mysql_fetch_array($exportedbans)) {
$data[]=$myexportbans[player_id] ;
}
*/
if ($data == 0) {
echo lang("_NOBANMATCH")."</td></tr>";
echo "<br>";
exit();
}
}
/****************************************************************
* Template parsing
****************************************************************/
// Header
$title = lang("_EXPORT");
// Section
$section = "export";
// Parsing
$smarty = new dynamicPage;
$smarty->assign("meta","");
$smarty->assign("title",$title);
$smarty->assign("section",$section);
$smarty->assign("dir",$config->document_root);
$smarty->assign("this",$_SERVER['PHP_SELF']);
$smarty->assign("gametypes",$gametypes);
$smarty->assign("submitted",get_post('submitted'));
$smarty->assign("exported_bans", isset($data) ? $data : "");
$smarty->assign("include_reason", isset($reason) ? $reason : "");
$smarty->assign("gtype",$gtype);
$smarty->assign("bantype",$bantype);
$smarty->display('main_header.tpl');
$smarty->display('export_bans.tpl');
$smarty->display('main_footer.tpl');
?>