</div>
<?php
define('UPATH', dirname(__FILE__));
-include "config.php";
-include "Classes/class-log.php";
-include "Classes/class-message.php";
-include "Classes/class-rpc.php";
+require_once "config.php";
+require_once UPATH . '/vendor/autoload.php';
+require_once "connection.php";
+require_once "Classes/class-log.php";
+require_once "Classes/class-message.php";
+require_once "Classes/class-rpc.php";
+
do_log($_POST);
if (!empty($_POST)) {
$duration .= $banlen_h;
}
- $rpc = new RPC();
- $rpc->set_method("user.get");
- $rpc->set_params(["nick" => "$user"]);
- $rpc->execute();
- $nick = ($rpc->result) ? $rpc->fetch_assoc() : NULL;
+ $nick = $rpc->user()->get($user);
if (!$nick)
{
Message::Fail("Could not find that user. Maybe they disconnected after you clicked this?");
return;
}
- $msg_msg = ($duration == "0" || $duration == "0w0d0h") ? "permanently" : "for $duration";
+ $msg_msg = ($duration == "0" || $duration == "0w0d0h") ? "permanently" : "for ".rpc_convert_duration_string($duration);
$reason = (isset($_POST['ban_reason'])) ? $_POST['ban_reason'] : "No reason";
- if (rpc_tkl_add($user, $bantype, $duration, $reason))
+ if ($rpc->serverban()->add($user, $bantype, $duration, $reason))
{
- $c = $nick['result']['client'];
- Message::Success($c['name'] . " (*@".$c['hostname'].") has been $bantype" . "d $msg_msg: $reason");
+ $c = $nick->client;
+ Message::Success($c->name . " (*@".$c->hostname.") has been $bantype" . "d $msg_msg: $reason");
}
}
}
foreach ($_POST as $key => $value) {
foreach ($value as $tok) {
$tok = explode(",", $tok);
- if (rpc_tkl_del(base64_decode($tok[0]), base64_decode($tok[1])))
- Message::Success(base64_decode($tok[1])." has been removed for ".base64_decode($tok[0]));
+ $ban = base64_decode($tok[0]);
+ $type = base64_decode($tok[1]);
+ if ($rpc->serverban()->delete($ban, $type))
+ Message::Success("$type has been removed for $ban");
+ else
+ Message::Fail("Unable to remove $type on $ban: $rpc->error");
}
}
foreach ($_POST as $key => $value) {
foreach ($value as $tok) {
$tok = explode(",", $tok);
- rpc_sf_del(base64_decode($tok[0]), base64_decode($tok[1]), base64_decode($tok[2]), base64_decode($tok[3]));
+ $name = base64_decode($tok[0]);
+ $match_type = base64_decode($tok[1]);
+ $spamfilter_targets = base64_decode($tok[2]);
+ $ban_action = base64_decode($tok[3]);
+ if ($rpc->spamfilter()->delete($name, $match_type, $spamfilter_targets, $ban_action))
+ Message::Success("Spamfilter on $name has been removed");
+ else
+ Message::Fail("Unable to remove spamfilter on $name: $rpc->error");
}
}
}
/* Some basic filtering for NICK */
if (isset($_POST['uf_nick']) && strlen($_POST['uf_nick']) &&
- strpos(strtolower($user['name']), strtolower($_POST['uf_nick'])) !== 0 &&
- strpos(strtolower($user['name']), strtolower($_POST['uf_nick'])) == false)
+ strpos(strtolower($user->name), strtolower($_POST['uf_nick'])) !== 0 &&
+ strpos(strtolower($user->name), strtolower($_POST['uf_nick'])) == false)
continue;
/* Some basic filtering for HOST */
if (isset($_POST['uf_host']) && strlen($_POST['uf_host']) &&
- strpos(strtolower($user['hostname']), strtolower($_POST['uf_host'])) !== 0 &&
- strpos(strtolower($user['hostname']), strtolower($_POST['uf_host'])) == false)
+ strpos(strtolower($user->hostname), strtolower($_POST['uf_host'])) !== 0 &&
+ strpos(strtolower($user->hostname), strtolower($_POST['uf_host'])) == false)
continue;
/* Some basic filtering for IP */
if (isset($_POST['uf_ip']) && strlen($_POST['uf_ip']) &&
- strpos(strtolower($user['ip']), strtolower($_POST['uf_ip'])) !== 0 &&
- strpos(strtolower($user['ip']), strtolower($_POST['uf_ip'])) == false)
+ strpos(strtolower($user->ip), strtolower($_POST['uf_ip'])) !== 0 &&
+ strpos(strtolower($user->ip), strtolower($_POST['uf_ip'])) == false)
continue;
/* Some basic filtering for ACCOUNT */
if (isset($_POST['uf_account']) && strlen($_POST['uf_account']) &&
- strpos(strtolower($user['user']['account']), strtolower($_POST['uf_account'])) !== 0 &&
- strpos(strtolower($user['user']['account']), strtolower($_POST['uf_account'])) == false)
+ strpos(strtolower($user->user->account), strtolower($_POST['uf_account'])) !== 0 &&
+ strpos(strtolower($user->user->account), strtolower($_POST['uf_account'])) == false)
continue;
echo "<tr>";
- echo "<td><input type=\"checkbox\" value='" . base64_encode($user['id'])."' name=\"userch[]\"></td>";
- echo "<td>".$user['name']."</td>";
- echo "<td>".$user['id']."</td>";
- echo "<td>".$user['hostname']." (".$user['ip'].")</td>";
- $account = (isset($user['user']['account'])) ? '<span class="label">'.$user['user']['account'].'</span>' : '<span class="label noaccount">None</span>';
+ echo "<td><input type=\"checkbox\" value='" . base64_encode($user->id)."' name=\"userch[]\"></td>";
+ $isBot = (strpos($user->user->modes, "B") !== false) ? ' <span class="label">Bot</span>' : "";
+ echo "<td>".$user->name.$isBot.'</td>';
+ echo "<td>".$user->id."</td>";
+ echo "<td>".$user->hostname." (".$user->ip.")</td>";
+ $account = (isset($user->user->account)) ? '<span class="label">'.$user->user->account.'</span>' : '<span class="label noaccount">None</span>';
echo "<td>".$account."</td>";
- $modes = (isset($user['user']['modes'])) ? "+" . $user['user']['modes'] : "<none>";
+ $modes = (isset($user->user->modes)) ? "+" . $user->user->modes : "<none>";
echo "<td>".$modes."</td>";
- $oper = (isset($user['user']['operlogin'])) ? '<span class="label">'.$user['user']['operlogin']."</span> <span class=\"label operclass-label\">".$user['user']['operclass']."</span>" : "";
+ $oper = (isset($user->user->operlogin)) ? '<span class="label">'.$user->user->operlogin."</span> <span class=\"label operclass-label\">".$user->user->operclass."</span>" : "";
if (!strlen($oper))
- $oper = (strpos($user['user']['modes'], "S") !== false) ? '<span class="label operclass-label">Service</span>' : "";
+ $oper = (strpos($user->user->modes, "S") !== false) ? '<span class="label secure-connection">Service</span>' : "";
echo "<td>".$oper."</td>";
- $secure = (isset($user['tls'])) ? "<span class=\"label secure-connection\">Secure</span>" : "<span class=\"label noaccount\">Insecure</span>";
+ $secure = (isset($user->tls)) ? "<span class=\"label secure-connection\">Secure</span>" : "<span class=\"label noaccount\">Insecure</span>";
echo "<td>".$secure."</td>";
- echo "<td>".$user['user']['servername']."</td>";
- echo "<td>".$user['user']['reputation']."</td>";
+ echo "<td>".$user->user->servername."</td>";
+ echo "<td>".$user->user->reputation."</td>";
}
?></table>
<label for="bantype">Apply action: </label><br>
foreach(RPC_List::$channel as $channel)
{
echo "<tr>";
- echo "<td>".$channel['name']."</td>";
- echo "<td>".$channel['creation_time']."</td>";
- echo "<td>".$channel['num_users']."</td>";
- $topic = (isset($channel['topic'])) ? $channel['topic'] : "";
+ echo "<td>".$channel->name."</td>";
+ echo "<td>".$channel->creation_time."</td>";
+ echo "<td>".$channel->num_users."</td>";
+ $topic = (isset($channel->topic)) ? $channel->topic : "";
echo "<td>".$topic."</td>";
- $setby = (isset($channel['topic'])) ? "By ".$channel['topic_set_by'] .", at ".$channel['topic_set_at'] : "";
+ $setby = (isset($channel->topic)) ? "By ".$channel->topic_set_by .", at ".$channel->topic_set_at : "";
echo "<td>".$setby."</td>";
- $modes = (isset($channel['modes'])) ? "+" . $channel['modes'] : "<none>";
+ $modes = (isset($channel->modes)) ? "+" . $channel->modes : "<none>";
echo "<td>".$modes."</td>";
}
?></table></div></div>
foreach(RPC_List::$tkl as $tkl)
{
echo "<tr>";
- echo "<td><input type=\"checkbox\" value='" . base64_encode($tkl['name']).",".base64_encode($tkl['type']) . "' name=\"tklch[]\"></td>";
- echo "<td>".$tkl['name']."</td>";
- echo "<td>".$tkl['type_string']."</td>";
- echo "<td>".$tkl['set_by']."</td>";
- echo "<td>".$tkl['set_at_string']."</td>";
- echo "<td>".$tkl['expire_at_string']."</td>";
- echo "<td>".$tkl['duration_string']."</td>";
- echo "<td>".$tkl['reason']."</td>";
+ echo "<td><input type=\"checkbox\" value='" . base64_encode($tkl->name).",".base64_encode($tkl->type) . "' name=\"tklch[]\"></td>";
+ echo "<td>".$tkl->name."</td>";
+ echo "<td>".$tkl->type_string."</td>";
+ echo "<td>".$tkl->set_by."</td>";
+ echo "<td>".$tkl->set_at_string."</td>";
+ echo "<td>".$tkl->expire_at_string."</td>";
+ echo "<td>".$tkl->duration_string."</td>";
+ echo "<td>".$tkl->reason."</td>";
}
?></table><p><input class="cute_button" type="submit" value="Delete selected"></p></form></div></div>
foreach(RPC_List::$spamfilter as $sf)
{
echo "<tr>";
- echo "<td><input type=\"checkbox\" value='" . base64_encode($sf['name']).",".base64_encode($sf['match_type']).",".base64_encode($sf['spamfilter_targets']).",".base64_encode($sf['ban_action']) . "' name=\"sf[]\"></td>";
- echo "<td>".$sf['name']."</td>";
- echo "<td>".$sf['type_string']."</td>";
- echo "<td>".$sf['set_by']."</td>";
- echo "<td>".$sf['set_at_string']."</td>";
- echo "<td>".$sf['expire_at_string']."</td>";
- echo "<td>".$sf['duration_string']."</td>";
- echo "<td>".$sf['match_type']."</td>";
- echo "<td>".$sf['ban_action']."</td>";
- echo "<td>".$sf['ban_duration_string']."</td>";
- for ($i = 0, $targs = ""; ($c = $sf['spamfilter_targets'][$i]); $i++)
+ echo "<td><input type=\"checkbox\" value='" . base64_encode($sf->name).",".base64_encode($sf->match_type).",".base64_encode($sf->spamfilter_targets).",".base64_encode($sf->ban_action) . "' name=\"sf[]\"></td>";
+ echo "<td>".$sf->name."</td>";
+ echo "<td>".$sf->type_string."</td>";
+ echo "<td>".$sf->set_by."</td>";
+ echo "<td>".$sf->set_at_string."</td>";
+ echo "<td>".$sf->expire_at_string."</td>";
+ echo "<td>".$sf->duration_string."</td>";
+ echo "<td>".$sf->match_type."</td>";
+ echo "<td>".$sf->ban_action."</td>";
+ echo "<td>".$sf->ban_duration_string."</td>";
+ for ($i = 0, $targs = ""; $i < strlen($sf->spamfilter_targets); $i++)
{
+ $c = $sf->spamfilter_targets[$i];
if ($c == "c")
$targs .= "Channel, ";
else if ($c == "p")
$targs .= "MessageTag, ";
else if ($c == "u")
$targs .= "Usermask, ";
-
- $targs = rtrim($targs,", ");
}
+ $targs = rtrim($targs,", ");
echo "<td>".$targs."</td>";
- echo "<td>".$sf['reason']."</td>";
+ echo "<td>".$sf->reason."</td>";
}
?></table><p><input class="cute_button" type="submit" value="Delete selected"></p></form></div></div>