X-Git-Url: https://jfr.im/git/irc/unrealircd/unrealircd-webpanel.git/blobdiff_plain/ef866d8c9503c717e53173655402b3769d529fec..7b1ba98c09418793d2bc46857b36ed27bc82f936:/index.php?ds=sidebyside diff --git a/index.php b/index.php index 3718721..28d71c0 100644 --- a/index.php +++ b/index.php @@ -1,9 +1,10 @@ - - +UnrealIRCd Panel + + +
-

UnrealIRCd Administration Panel


-
+

UnrealIRCd Administration Panel

Overview @@ -11,24 +12,238 @@ Channels Server Bans Spamfilter + News
$value) + { + if (substr($key, 0, 7) == "target_") + $targets[] = str_replace(["target_", "_"], ["", "-"], $key); + } + if (empty($targets)) + Message::Fail("No target was specified"); + + if (!isset($_POST['sf_bantype'])) + Message::Fail("No action was chosen"); + + else + { + + $bantype = $_POST['sf_bantype']; + $targ_chars = ""; + foreach($targets as $targ) + { + switch ($targ) { + case "channel": + $targ_chars .= "c"; + break; + case "private": + $targ_chars .= "p"; + break; + case "channel-notice": + $targ_chars .= "N"; + break; + case "private-notice": + $targ_chars .= "n"; + break; + case "part": + $targ_chars .= "P"; + break; + case "quit": + $targ_chars .= "q"; + break; + case "dcc": + $targ_chars .= "d"; + break; + case "away": + $targ_chars .= "a"; + break; + case "topic": + $targ_chars .= "t"; + break; + case "messagetag": + $targ_chars .= "T"; + break; + case "user": + $targ_chars .= "u"; + break; + } + } + /* duplicate code for now [= */ + $banlen_w = (isset($_POST['banlen_w'])) ? $_POST['banlen_w'] : NULL; + $banlen_d = (isset($_POST['banlen_d'])) ? $_POST['banlen_d'] : NULL; + $banlen_h = (isset($_POST['banlen_h'])) ? $_POST['banlen_h'] : NULL; + $duration = ""; + if (!$banlen_d && !$banlen_h && !$banlen_w) + $duration .= "0"; + + else + { + if ($banlen_w) + $duration .= $banlen_w; + if ($banlen_d) + $duration .= $banlen_d; + if ($banlen_h) + $duration .= $banlen_h; + } + $match_type = $_POST['matchtype']; // should default to 'simple' + $reason = isset($_POST['ban_reason']) ? $_POST['ban_reason'] : "No reason"; + $soft = (isset($_POST['soft'])) ? true : false; + if ($soft) + $targ_chars = "%" . $targ_chars; + if ($rpc->spamfilter()->add($sf, $match_type, $targ_chars, $bantype, $duration, $reason)) + Message::Success("Added spamfilter entry \"$sf\" [match type: $match_type] [targets: $targ_chars] [reason: $reason]"); + else + Message::Fail("Could not add spamfilter entry \"$sf\" [match type: $match_type] [targets: $targ_chars] [reason: $reason]: $rpc->error"); + } + + } + + else if (!($bantype = $_POST['bantype'])) // if it was a ban entry + { + } + else if (!($users = $_POST["userch"])) + { + /* check if this came from our Server Bans tab. */ + if (!($iphost = $_POST['tkl_add'])) + Message::Fail("No user was specified"); + + else /* It did */ + { + if (( + $bantype == "gline" || + $bantype == "gzline" || + $bantype == "shun" || + $bantype == "eline" + ) && strpos($iphost, "@") == false) // doesn't have full mask + $iphost = "*@" . $iphost; + + $soft = ($_POST['soft']) ? true : false; + + if ($soft) + $iphost = "%" . $iphost; + /* duplicate code for now [= */ + $banlen_w = (isset($_POST['banlen_w'])) ? $_POST['banlen_w'] : NULL; + $banlen_d = (isset($_POST['banlen_d'])) ? $_POST['banlen_d'] : NULL; + $banlen_h = (isset($_POST['banlen_h'])) ? $_POST['banlen_h'] : NULL; + $duration = ""; + if (!$banlen_d && !$banlen_h && !$banlen_w) + $duration .= "0"; + + else + { + if ($banlen_w) + $duration .= $banlen_w; + if ($banlen_d) + $duration .= $banlen_d; + if ($banlen_h) + $duration .= $banlen_h; + } + $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->serverban()->add($iphost, $bantype, $duration, $reason)) + { + Message::Success("Host / IP: $iphost has been $bantype" . "d $msg_msg: $reason"); + } + else + Message::Fail("The $bantype against \"$iphost\" could not be added: $rpc->error"); + } + } + else /* It came from the Users tab */ + { + foreach ($_POST["userch"] as $user) + { + $user = base64_decode($user); + $bantype = (isset($_POST['bantype'])) ? $_POST['bantype'] : NULL; + if (!$bantype) /* shouldn't happen? */ + { + Message::Fail("An error occured"); + return; + } + $banlen_w = (isset($_POST['banlen_w'])) ? $_POST['banlen_w'] : NULL; + $banlen_d = (isset($_POST['banlen_d'])) ? $_POST['banlen_d'] : NULL; + $banlen_h = (isset($_POST['banlen_h'])) ? $_POST['banlen_h'] : NULL; + + $duration = ""; + if (!$banlen_d && !$banlen_h && !$banlen_w) + $duration .= "0"; + + else + { + if ($banlen_w) + $duration .= $banlen_w; + if ($banlen_d) + $duration .= $banlen_d; + if ($banlen_h) + $duration .= $banlen_h; + } + + $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 ".rpc_convert_duration_string($duration); + $reason = (isset($_POST['ban_reason'])) ? $_POST['ban_reason'] : "No reason"; + if ($rpc->serverban()->add($user, $bantype, $duration, $reason)) + { + $c = $nick->client; + Message::Success($c->name . " (*@".$c->hostname.") has been $bantype" . "d $msg_msg: $reason"); + } + } + } + + if (!empty($_POST['tklch'])) + foreach ($_POST as $key => $value) { + foreach ($value as $tok) { + $tok = explode(",", $tok); + $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"); + } + } + + if (!empty($_POST['sf'])) + foreach ($_POST as $key => $value) { + foreach ($value as $tok) { + $tok = explode(",", $tok); + $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"); + } + } +} + +rpc_pop_lists(); ?>
@@ -43,40 +258,170 @@ rpc_pop_lists(); // populate our static lists (users, channels, tkl, spamfilter) Server bans Spamfilter entries
- +
-

+ + + + + + + +
Filter by: +
+ Nick: + +
+
+
+ Hostname: + +
+
+
+ IP: + +
+
+
+ Account: + +
+
+ + - + - + + 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) + 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) + 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) + continue; + echo ""; - echo ""; - echo ""; - echo ""; - $account = (isset($user['account'])) ? $user['account'] : ""; + echo ""; + $isBot = (strpos($user->user->modes, "B") !== false) ? ' Bot' : ""; + echo "'; + echo ""; + echo ""; + $account = (isset($user->user->account)) ? $user->user->account : 'None'; echo ""; - $modes = (isset($user['user']['modes'])) ? "+" . $user['user']['modes'] : ""; + $modes = (isset($user->user->modes)) ? "+" . $user->user->modes : ""; echo ""; - $oper = (isset($user['user']['operlogin'])) ? $user['user']['operlogin']." (".$user['user']['operclass'].")" : ""; + $oper = (isset($user->user->operlogin)) ? $user->user->operlogin." ".$user->user->operclass."" : ""; + if (!strlen($oper)) + $oper = (strpos($user->user->modes, "S") !== false) ? 'Service' : ""; echo ""; - $secure = (isset($user['tls'])) ? "✅" : "❌"; + $secure = (isset($user->tls)) ? "Secure" : "Insecure"; echo ""; - echo ""; - echo ""; + echo ""; + echo ""; } - ?>
Select all Nick UID Host / IP AccountUsermodesUsermodesℹ️ Oper Secure Connected toReputation ℹ️Reputation ℹ️
".$user['name']."".$user['id']."".$user['hostname']." (".$user['ip'].")".$user->name.$isBot.'".$user->id."".$user->hostname." (".$user->ip.")".$account."".$modes."".$oper."".$secure."".$user['user']['servername']."".$user['user']['reputation']."".$user->user->servername."".$user->user->reputation."
+ ?> +
+ +
+
+ + + +
+
+ + + +
@@ -93,14 +438,14 @@ rpc_pop_lists(); // populate our static lists (users, channels, tkl, spamfilter) foreach(RPC_List::$channel as $channel) { echo ""; - echo "".$channel['name'].""; - echo "".$channel['creation_time'].""; - echo "".$channel['num_users'].""; - $topic = (isset($channel['topic'])) ? $channel['topic'] : ""; + echo "".$channel->name.""; + echo "".$channel->creation_time.""; + echo "".$channel->num_users.""; + $topic = (isset($channel->topic)) ? $channel->topic : ""; echo "".$topic.""; - $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 "".$setby.""; - $modes = (isset($channel['modes'])) ? "+" . $channel['modes'] : ""; + $modes = (isset($channel->modes)) ? "+" . $channel->modes : ""; echo "".$modes.""; } ?>
@@ -108,8 +453,85 @@ rpc_pop_lists(); // populate our static lists (users, channels, tkl, spamfilter)
-

+
+ Add Server Ban +
+
+ +
+
IP / Host:

+
Ban Type:

+
+ + + +
+
+ Don't affect logged-in users (soft) +
+
+
+ + @@ -122,21 +544,116 @@ rpc_pop_lists(); // populate our static lists (users, channels, tkl, spamfilter) foreach(RPC_List::$tkl as $tkl) { echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; } - ?>
Select all Mask Type Set By
".$tkl['name']."".$tkl['type_string']."".$tkl['set_by']."".$tkl['set_at_string']."".$tkl['expire_at_string']."".$tkl['duration_string']."".$tkl['reason']."".$tkl->name."".$tkl->type_string."".$tkl->set_by."".$tkl->set_at_string."".$tkl->expire_at_string."".$tkl->duration_string."".$tkl->reason."
+ ?>

+
+ Add Spamfilter Entry +
+
+ +
+
Entry:

+
MatchType:

+
Action:

+ +
+ Channel messages
+
Private messages
+
Channel notices
+
Private notices
+
Part reason
+
DCC Filename
+
Away messages
+
Channel topic
+
MessageTags
+
Userhost (nick!user@host:realname)
+
+ + + +
+
+ Don't affect logged-in users (soft) +
+
+
+ + @@ -153,17 +670,19 @@ rpc_pop_lists(); // populate our static lists (users, channels, tkl, spamfilter) foreach(RPC_List::$spamfilter as $sf) { echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - for ($i = 0, $targs = ""; ($c = $sf['spamfilter_targets'][$i]); $i++) + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + for ($i = 0, $targs = ""; $i < strlen($sf->spamfilter_targets); $i++) { + $c = $sf->spamfilter_targets[$i]; if ($c == "c") $targs .= "Channel, "; else if ($c == "p") @@ -186,15 +705,20 @@ rpc_pop_lists(); // populate our static lists (users, channels, tkl, spamfilter) $targs .= "MessageTag, "; else if ($c == "u") $targs .= "Usermask, "; - - $targs = rtrim($targs,", "); } + $targs = rtrim($targs,", "); echo ""; - echo ""; + echo ""; } - ?>
Select all Mask Type Set By
".$sf['name']."".$sf['type_string']."".$sf['set_by']."".$sf['set_at_string']."".$sf['expire_at_string']."".$sf['duration_string']."".$sf['match_type']."".$sf['ban_action']."".$sf['ban_duration_string']."".$sf->name."".$sf->type_string."".$sf->set_by."".$sf->set_at_string."".$sf->expire_at_string."".$sf->duration_string."".$sf->match_type."".$sf->ban_action."".$sf->ban_duration_string."".$targs."".$sf['reason']."".$sf->reason."
+ ?>

+ + + +
+
+ + +
- - \ No newline at end of file