]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blobdiff - index.php
Allow soft-bans (doesn't affect logged-in users)
[irc/unrealircd/unrealircd-webpanel.git] / index.php
index 5706cc4aec5e409aae73f6683a2d4887c71f07e9..fbb29c89ebeb3c6c6a35f9c66c7dfcd804c18a81 100644 (file)
--- a/index.php
+++ b/index.php
@@ -26,15 +26,63 @@ require_once "Classes/class-rpc.php";
 do_log($_POST);
 
 if (!empty($_POST)) {
-       if (!($bantype = $_POST['bantype'])) {
+       if (!($bantype = $_POST['bantype']))
+       {
+       } 
+       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 if (!($users = $_POST["userch"])) {
-               Message::Fail("No user was specified");
-       } else {
-               foreach ($_POST["userch"] as $user) {
+               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)
+                       if (!$bantype) /* shouldn't happen? */
                        {
                                Message::Fail("An error occured");
                                return;
@@ -210,11 +258,11 @@ rpc_pop_lists();
                        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>';
+                       $account = (isset($user->user->account)) ? $user->user->account : '<span class="label noaccount">None</span>';
                        echo "<td>".$account."</td>";
                        $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)) ? $user->user->operlogin." <span class=\"label operclass-label\">".$user->user->operclass."</span>" : "";
                        if (!strlen($oper))
                                $oper = (strpos($user->user->modes, "S") !== false) ? '<span class="label secure-connection">Service</span>' : "";
                        echo "<td>".$oper."</td>";
@@ -313,7 +361,82 @@ rpc_pop_lists();
 
        <div class="tab-content\">
        <div id="TKL" data-tab-content>
-       
+       <div class="tkl_add_boxheader">
+               Add Server Ban
+       </div>
+       <div class="tkl_add_form">
+               
+               <form action="" method="post">
+                       <div class="align_label">IP / Host:</div><input class="input_text" type="text" id="tkl_add" name="tkl_add"><br>
+                       <div class="align_label">Ban Type:</div><select name="bantype" id="bantype">
+                               <option value=""></option>
+                               <optgroup label="Bans">
+                                       <option value="kline">Kill Line (KLine)</option>
+                                       <option value="gline">Global Kill Line (GLine)</option>
+                                       <option value="zline">Zap Line (ZLine)</option>
+                                       <option value="gzline">Global Zap Line (GZLine)</option>
+                                       
+                               </optgroup>
+                               <optgroup label="Restrictions">
+                                       <option value="local-qline">Reserve Nick Locally(QLine)</option>
+                                       <option value="qline">Reserve Nick Globally (QLine)</option>
+                                       <option value="shun">Shun</option>
+
+                               </optgroup>
+                               <optgroup label="Settings">
+                                       <option value="except">Global Exception (ELine)</option>
+                                       <option value="local-exception">Local Exception (ELine)</option>
+                               </optgroup>
+                       </select><br>
+                       <div class="align_label"><label for="banlen_w">Duration: </label></div>
+                                       <select name="banlen_w" id="banlen_w">
+                                                       <?php
+                                                       for ($i = 0; $i <= 56; $i++)
+                                                       {
+                                                               if (!$i)
+                                                                       echo "<option value=\"0w\"></option>";
+                                                               else
+                                                               {
+                                                                       $w = ($i == 1) ? "week" : "weeks";
+                                                                       echo "<option value=\"$i" . "w\">$i $w" . "</option>";
+                                                               }
+                                                       }
+                                                       ?>
+                                       </select>
+                                       <select name="banlen_d" id="banlen_d">
+                                                       <?php
+                                                       for ($i = 0; $i <= 31; $i++)
+                                                       {
+                                                               if (!$i)
+                                                                       echo "<option value=\"0d\"></option>";
+                                                               else
+                                                               {
+                                                                       $d = ($i == 1) ? "day" : "days";
+                                                                       echo "<option value=\"$i" . "d\">$i $d" . "</option>";
+                                                               }
+                                                       }
+                                                       ?>
+                                       </select>
+                                       <select name="banlen_h" id="banlen_h">
+                                                       <?php
+                                                       for ($i = 0; $i <= 24; $i++)
+                                                       {
+                                                               if (!$i)
+                                                                       echo "<option value=\"0d\"></option>";
+                                                               else
+                                                               {
+                                                                       $h = ($i == 1) ? "hour" : "hours";
+                                                                       echo "<option value=\"$i" . "h\">$i $h" . "</option>";
+                                                               }
+                                                       }
+                                                       ?>
+                                       </select>
+                                       <br><div class="align_label"><label for="ban_reason">Reason: </label></div>
+                                       <input class="input_text" type="text" id="ban_reason" name="ban_reason"><br>
+                                       <input class="input_text" type="checkbox" id="soft" name="soft">Don't affect logged-in users (soft)
+                                       <div class="align_right_button_tkl_add"><input class="cute_button" type="submit" id="submit" value="Submit"></div>
+               </form>
+       </div>
        <table class='users_overview'>
        <form action="" method="post">
        <th><input type="checkbox" label='selectall' onClick="toggle_tkl(this)" />Select all</th>