]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blobdiff - users/index.php
Merge pull request #50 from TehPeGaSuS/patch-2
[irc/unrealircd/unrealircd-webpanel.git] / users / index.php
index f47ce4999fefb63c50870575d574dd8791dd5266..40c813057993c92c8c8099260a62fd3348c64bd7 100644 (file)
@@ -1,6 +1,5 @@
 <?php
 require_once "../inc/common.php";
-require_once "../inc/connection.php";
 require_once "../inc/header.php";
 
 if (!empty($_GET))
@@ -15,8 +14,9 @@ if (!empty($_GET))
                $_POST['servicesonly'] = $_GET['servicesonly'];
 }
 
-if (!empty($_POST))
+if (!empty($_POST) && current_user_can(PERMISSION_BAN_USERS))
 {
+       require_once "../inc/connection.php";
        do_log($_POST);
        $bantype = (isset($_POST['bantype'])) ? $_POST['bantype'] : NULL;
 
@@ -85,38 +85,17 @@ if (!empty($_POST))
 Click on a username to view more information.
 
 <div class="usertable">
-       
-       <?php
-
-       if (isset($_POST['uf_nick']) && strlen($_POST['uf_nick']))
-               Message::Info("Listing users which match nick: \"" . $_POST['uf_nick'] . "\"");
-
-       if (isset($_POST['uf_ip']) && strlen($_POST['uf_ip']))
-               Message::Info("Listing users which match IP: \"" . $_POST['uf_ip'] . "\"");
-
-       if (isset($_POST['uf_host']) && strlen($_POST['uf_host']))
-               Message::Info("Listing users which match hostmask: \"" . $_POST['uf_host'] . "\"");
-
-       if (isset($_POST['uf_account']) && strlen($_POST['uf_account']))
-               Message::Info("Listing users which match account: \"" . $_POST['uf_account'] . "\"");
-
-       if (isset($_POST['uf_server']) && strlen($_POST['uf_server']))
-               Message::Info("Listing users connected to servers matching: \"" . $_POST['uf_server'] . "\"");
-
-
-       ?>
+       <form method="post">
 
        <!-- The user list -->
-       <table id="data_list" class="container-xxl table table-sm table-responsive caption-top table-striped">
+       <table id="data_list" class="table-striped display responsive nowrap" style="width:100%">
        <thead class="table-primary">
                <th scope="col"><input type="checkbox" label='selectall' onClick="toggle_user(this)" /></th>
                <th scope="col">Nick</th>
                <th class="countrycol" scope="col">Country</th>
                <th class="hostname" scope="col">Host / IP</th>
                <th class="accountcol" scope="col"><span data-toggle="tooltip" data-placement="bottom" title="The services account name, if the user identified to services." style="border-bottom: 1px dotted #000000">Account</span></th>
-               <th class="umodescol" scope="col">Usermodes <a href="https://www.unrealircd.org/docs/User_modes" target="_blank">ℹ️</a></th>
                <th class="opercol" scope="col">Oper</th>
-               <th class="securecol" scope="col"><span data-toggle="tooltip" data-placement="bottom" title="This shows [Secure] if the user is using SSL/TLS or is on localhost." style="border-bottom: 1px dotted #000000">Secure</span></th>
                <th class="uplinkcol" scope="col">Connected to</th>
                <th class="reputationcol" scope="col"><span id="reputationheader" data-toggle="tooltip" data-placement="bottom" title="The reputation score gets higher when someone with this IP address has been connected in the past weeks. A low reputation score (like <10) is an indication of a new IP." style="border-bottom: 1px dotted #000000">Rep.</span> <a href="https://www.unrealircd.org/docs/Reputation_score" target="_blank">ℹ️</a></th>
        </thead>
@@ -184,14 +163,16 @@ Click on a username to view more information.
        
        <label for="ban_reason">Reason: </label>
        <input class="form-control" type="text" name="ban_reason" id="ban_reason" value="No reason">
-       <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">
+       <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#ban_confirmation">
                        Apply
        </button></td></table>
-       <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="confirmModalCenterTitle" aria-hidden="true">
+
+       <!-- Ban confirmation modal -->
+       <div class="modal fade" id="ban_confirmation" tabindex="-1" role="dialog" aria-labelledby="confirmModalCenterTitle" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered" role="document">
                <div class="modal-content">
                <div class="modal-header">
-                       <h5 class="modal-title" id="myModalLabel">Apply ban</h5>
+                       <h5 class="modal-title" id="ban_confirmation_label">Apply ban</h5>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                        </button>
@@ -243,98 +224,9 @@ Click on a username to view more information.
                <div id="rclick_opt2" class="item list-group-item-action">Kill</div>
                <div id="rclick_opt3" class="item list-group-item-action">Copy
        </div>
-
-<?php /* ?>
-       <h3>Top country</h3>
-       <div id="top-country">
-               <ul>
-               <?php
-                       arsort($registrationOfaAllFlags);
-                       foreach($registrationOfaAllFlags as $country_code => $count){
-                               echo '<li>
-                               <div class="drag"><img src="https://flagcdn.com/108x81/'.htmlspecialchars(strtolower($country_code)).'.png" width="108" height="81"><br />
-                               '.$country_code . '
-                               </div>
-                               <div class="count">' . $count . ' <span>connected</span></div>
-                               </li>';
-                       }
-               ?>
-               </ul>
-       </div>
-<?php */ ?>
-
 </div>
 
 <script>
-       function resize_check()
-       {
-               var width = window.innerWidth;
-               var show_elements = '';
-               var hide_elements = '';
-               if (width < 500)
-               {
-                       show_elements = '';
-                       hide_elements = '.hostname, .opercol, .uplinkcol, .securecol, .umodescol, .countrycol';
-               } else
-               if (width < 600)
-               {
-                       show_elements = '.countrycol';
-                       hide_elements = '.hostname, .opercol, .uplinkcol, .securecol, .umodescol';
-               } else
-               if (width < 700)
-               {
-                       show_elements = '.umodescol, .countrycol';
-                       hide_elements = '.hostname, .opercol, .uplinkcol, .securecol';
-               } else
-               if (width < 768)
-               {
-                       show_elements = '.securecol, .umodescol, .countrycol';
-                       hide_elements = '.hostname, .opercol, .uplinkcol';
-               } else
-               if (width < 875)
-               {
-                       // left nav kicks in at 768+ so need to drop one column between 768..875
-                       show_elements = '.umodescol, .countrycol';
-                       hide_elements = '.hostname, .opercol, .uplinkcol, .securecol';
-               } else if (width < 1000)
-               {
-                       show_elements = '.securecol, .umodescol, .countrycol';
-                       hide_elements = '.hostname, .uplinkcol, .opercol';
-               } else if (width < 1200)
-               {
-                       show_elements = '.opercol, .securecol, .umodescol, .countrycol';
-                       hide_elements = '.hostname, .uplinkcol';
-               } else if (width < 1550)
-               {
-                       show_elements = '.opercol, .uplinkcol, .securecol, .umodescol, .countrycol';
-                       hide_elements = '.hostname';
-               } else if (width < 1750)
-               {
-                       show_elements = '.hostname, .opercol, .securecol, .umodescol, .countrycol';
-                       hide_elements = '.uplinkcol';
-               } else {
-                       show_elements = '.hostname, .opercol, .uplinkcol, .securecol, .umodescol, .countrycol';
-                       hide_elements = '';
-               }
-
-               if (show_elements != '')
-               {
-                       show_elements=document.querySelectorAll(show_elements);
-                       for (let i = 0; i < show_elements.length; i++)
-                               show_elements[i].style.display = '';
-               }
-
-               if (hide_elements != '')
-               {
-                       hide_elements=document.querySelectorAll(hide_elements);
-                       for (let i = 0; i < hide_elements.length; i++)
-                               hide_elements[i].style.display = 'none';
-               }
-       }
-       resize_check();
-       window.addEventListener('resize', function() {
-               resize_check();
-       });
        var rclickmenu = document.getElementById('rclickmenu');
        var scopes = document.querySelectorAll('.userselector');
        document.addEventListener("click", (e) =>
@@ -365,35 +257,44 @@ Click on a username to view more information.
 });
 
 $(document).ready( function () {
-       $('#data_list').DataTable({
+       args = {
+               'responsive': true,
+               'fixedHeader': {
+                       header: true,
+                       headerOffset: 53
+               },
                'ajax': {
                        'url': '<?php echo get_config("base_url"); ?>api/users.php',
                        dataSrc: ''
                },
                'pageLength':100,
                'order':[[1,'asc']],
-               'dom': 'Pfrtip',
-               'searchPanes': {
+               'columns': [
+                       { 'data': 'Select', 'responsivePriority': 1 },
+                       { 'data': 'Nick', 'responsivePriority': 1 },
+                       { 'data': 'Country', 'className':'countrycol', 'responsivePriority': 2 },
+                       { 'data': 'Host/IP', 'className':'hostname', 'responsivePriority': 5 },
+                       { 'data': 'Account', 'className':'accountcol', 'responsivePriority': 3 },
+                       { 'data': 'Oper', 'className':'opercol', 'responsivePriority': 8 },
+                       { 'data': 'Connected to', 'className':'uplinkcol', 'responsivePriority': 6 },
+                       { 'data': 'Reputation', 'className':'reputationcol', 'responsivePriority': 4 },
+               ],
+       };
+       /* Hide on mobile */
+       if (window.innerWidth > 800)
+       {
+               args['dom'] = 'Pfrtip';
+               args['searchPanes'] = {
                        'initCollapsed': 'true',
-                       'columns': [2,8],
+                       'columns': [2,6],
                        'dtOpts': {
                                select: { style: 'multi'},
                                order: [[ 1, "desc" ]]
-                       }
-               },
-               'columns': [
-                       { 'data': 'Select' },
-                       { 'data': 'Nick' },
-                       { 'data': 'Country' },
-                       { 'data': 'Host/IP' },
-                       { 'data': 'Account' },
-                       { 'data': 'Usermodes', 'name':'Usermodes', 'searchPanes': { 'name':'Usermodes' } },
-                       { 'data': 'Oper' },
-                       { 'data': 'Secure' },
-                       { 'data': 'Connected to' },
-                       { 'data': 'Reputation' },
-               ],
-       });
+                       },
+               }
+       }
+
+       $('#data_list').DataTable(args);
 } );
 
 </script>