1
|
|
|
<?php |
2
|
|
|
/* zKillboard |
3
|
|
|
* Copyright (C) 2012-2015 EVE-KILL Team and EVSCO. |
4
|
|
|
* |
5
|
|
|
* This program is free software: you can redistribute it and/or modify |
6
|
|
|
* it under the terms of the GNU Affero General Public License as published by |
7
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
8
|
|
|
* (at your option) any later version. |
9
|
|
|
* |
10
|
|
|
* This program is distributed in the hope that it will be useful, |
11
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
12
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13
|
|
|
* GNU Affero General Public License for more details. |
14
|
|
|
* |
15
|
|
|
* You should have received a copy of the GNU Affero General Public License |
16
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
$message = ""; |
20
|
|
|
if (!User::isLoggedIn()) { |
21
|
|
|
$app->render("login.html"); |
22
|
|
|
die(); |
23
|
|
|
} |
24
|
|
|
$info = User::getUserInfo(); |
25
|
|
|
if (!User::isModerator()) $app->redirect("/"); |
26
|
|
|
|
27
|
|
|
if($_POST) |
28
|
|
|
{ |
29
|
|
|
$status = Util::getPost("status"); |
30
|
|
|
$reply = Util::getPost("reply"); |
31
|
|
|
$report = Util::getPost("report"); |
32
|
|
|
$delete = Util::getPost("delete"); |
33
|
|
|
$deleteapi = Util::getPost("deleteapi"); |
34
|
|
|
$manualpull = Util::getPost("manualpull"); |
35
|
|
|
|
36
|
|
|
if(isset($status)) |
37
|
|
|
{ |
38
|
|
|
Db::execute("UPDATE zz_tickets SET status = :status WHERE id = :id", array(":status" => $status, ":id" => $id)); |
39
|
|
|
if ($status == 0) $app->redirect(".."); |
40
|
|
|
} |
41
|
|
|
if(isset($reply)) |
42
|
|
|
{ |
43
|
|
|
$name = $info["username"]; |
44
|
|
|
$moderator = $info["moderator"]; |
45
|
|
|
$check = Db::query("SELECT * FROM zz_tickets_replies WHERE reply = :reply AND userid = :userid", array(":reply" => $reply, ":userid" => $info["id"]), 0); |
46
|
|
|
if(!$check) |
47
|
|
|
{ |
48
|
|
|
Db::execute("INSERT INTO zz_tickets_replies (userid, belongsTo, name, reply, moderator) VALUES (:userid, :belongsTo, :name, :reply, :moderator)", array(":userid" => $info["id"], ":belongsTo" => $id, ":name" => $name, ":reply" => $reply, ":moderator" => $moderator)); |
49
|
|
|
$tic = Db::query("SELECT name,email FROM zz_tickets WHERE id = :id", array(":id" => $id)); |
50
|
|
|
$ticname = $tic[0]["name"]; |
51
|
|
|
$ticmail = $tic[0]["email"]; |
52
|
|
|
$subject = "zKillboard Ticket"; |
53
|
|
|
global $baseAddr; |
54
|
|
|
$message = "$ticname, there is a new reply to your ticket from $name - https://$baseAddr/tickets/view/$id/"; |
55
|
|
|
if ($moderator == 0) Log::ircAdmin("User replied to ticket: |g|$name|n| https://$baseAddr/moderator/tickets/$id/"); |
56
|
|
|
if ($moderator != 0) Email::send($ticmail, $subject, $message); |
57
|
|
|
if(isset($report)) |
58
|
|
|
$app->redirect("/moderator/reportedkills/$id/"); |
59
|
|
|
$app->redirect("/moderator/tickets/$id/"); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
if(isset($delete)) |
63
|
|
|
{ |
64
|
|
|
if($delete < 0) |
65
|
|
|
{ |
66
|
|
|
Util::deleteKill($delete); |
67
|
|
|
Db::execute("DELETE FROM zz_tickets WHERE id = :id", array(":id" => $id)); |
68
|
|
|
Db::execute("DELETE FROM zz_tickets_replies WHERE belongsTo = :belongsTo", array(":belongsTo" => $id)); |
69
|
|
|
$app->redirect("/moderator/reportedkills/"); |
70
|
|
|
} |
71
|
|
|
$message = "Error, kill is positive, and thus api verified.. something is wrong!"; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
if(isset($manualpull) ) |
75
|
|
|
{ |
76
|
|
|
$message = "ah"; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
if(isset($deleteapi)){ |
80
|
|
|
Api::deleteKey($deleteapi); |
81
|
|
|
$message = "The Api had been deleted"; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
if ($req == "") { |
87
|
|
|
$app->redirect("tickets/"); |
88
|
|
|
die(); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
if($req == "tickets" && $id) |
92
|
|
|
{ |
93
|
|
|
$info["ticket"] = Db::query("SELECT * FROM zz_tickets WHERE id = :id", array(":id" => $id), 0); |
94
|
|
|
$info["replies"] = Db::query("SELECT * FROM zz_tickets_replies WHERE belongsTo = :id", array(":id" => $id), 0); |
95
|
|
|
} |
96
|
|
|
elseif($req == "tickets") |
97
|
|
|
{ |
98
|
|
|
$limit = 30; |
99
|
|
|
$offset = ($page - 1) * $limit; |
100
|
|
|
$info = Db::query("SELECT t.*, count(r.belongsTo) replyCount FROM zz_tickets t left join zz_tickets_replies r on (t.id = r.belongsTo) WHERE killID = 0 GROUP BY 1 ORDER BY status DESC, count(r.belongsTo) != 0, datePosted DESC LIMIT $offset, $limit", array(), 0); |
101
|
|
|
foreach($info as $key => $val) |
|
|
|
|
102
|
|
|
{ |
103
|
|
|
//if($val["tags"]) $info[$key]["tags"] = explode(",", $val["tags"]); |
104
|
|
|
} |
105
|
|
|
} |
106
|
|
|
elseif($req == "users") |
107
|
|
|
{ |
108
|
|
|
$info = Moderator::getUsers($page); |
109
|
|
|
} |
110
|
|
|
if($req == "reportedkills" && $id) |
111
|
|
|
{ |
112
|
|
|
$info["ticket"] = Db::query("SELECT * FROM zz_tickets WHERE id = :id", array(":id" => $id), 0); |
113
|
|
|
$info["replies"] = Db::query("SELECT * FROM zz_tickets_replies WHERE belongsTo = :id", array(":id" => $id), 0); |
114
|
|
|
} |
115
|
|
|
elseif($req == "reportedkills") |
116
|
|
|
{ |
117
|
|
|
$limit = 30; |
118
|
|
|
$offset = ($page - 1) * $limit; |
119
|
|
|
$info = Db::query("SELECT * FROM zz_tickets WHERE killID != 0 ORDER BY status DESC LIMIT $offset, $limit", array(), 0); |
120
|
|
|
foreach($info as $key => $val) |
|
|
|
|
121
|
|
|
{ |
122
|
|
|
//if($val["tags"]) $info[$key]["tags"] = explode(",", $val["tags"]); |
123
|
|
|
} |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
$app->render("moderator/moderator.html", array("id" => $id, "info" => $info, "key" => $req, "url"=>"moderator", "message" => $message, "page" => $page)); |
127
|
|
|
|
This check looks for
foreach
loops that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.Consider removing the loop.