Advertisement
lowheartrate

admin module 3

Nov 15th, 2016
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.54 KB | None | 0 0
  1. // starts admin 3 panel
  2.  
  3.         // if $adminLevel > 2 display module
  4.         if ($adminLevel > 2) {
  5.  
  6.           // if user is level 3 put in div.col-lg-4 row
  7.           if ($adminLevel == 3) {
  8.             echo '
  9.  
  10.            <div class="col-lg-4">
  11.  
  12.            <!-- heading here -->
  13.            <h3>Admin Level 3 Panel</h3>
  14.            <p>Use this module to get rid of corrupt level 2 admins</p>
  15.  
  16.            <button class="btn btn-default hideshow3">show/hide</button>
  17.  
  18.            <div class="content3">
  19.  
  20.            <div class="admin_module">
  21.  
  22.            <!-- content here -->
  23.            ';
  24.  
  25.             // get query to get all users that are level == 2
  26.             $getLevel2Admins = dbConnect()->prepare("SELECT * FROM users WHERE level = 2");
  27.             $getLevel2Admins->execute();
  28.             $levelTwoAdmins = $getLevel2Admins->fetchAll();
  29.  
  30.           echo '
  31.  
  32.            <table class="nonAdmins" border="1">
  33.              <tr>
  34.                <td class="table_header">ID</td>
  35.                <td class="table_header">Register Date</td>
  36.                <td class="table_header">Username</td>
  37.                <td class="table_header">Level 1</td>
  38.                <td class="table_header">Level 2</td>
  39.              </tr>
  40.          ';
  41.  
  42.           // start to fetch users that aren't admins
  43.           foreach($levelTwoAdmins as $row2) {
  44.  
  45.             echo '
  46.  
  47.            <tr>
  48.              <td class="table_content">' .$row2['id']. '</td>
  49.              <td class="table_content">' .$row2['register_date']. '</td>
  50.              <td class="table_content">' .$row2['username']. '</td>
  51.  
  52.              <td class="table_content">
  53.              <form method="post" class="table_content_form">
  54.                <button class="btn btn-default" type="submit" name="demoteLevel">Demote to level 1</button>
  55.                <input type="hidden" name="user_id2" value="' .$row2['id']. '"/>
  56.                <input type="hidden" name="user_level2" value="1"/>
  57.              </form>
  58.              </td>
  59.  
  60.              <td class="table_content">
  61.              <form method="post" class="table_content_form">
  62.                <button class="btn btn-default" type="submit" name="demoteLevel">Demote to level 0</button>
  63.                <input type="hidden" name="user_id2" value="' .$row2['id']. '"/>
  64.                <input type="hidden" name="user_level2" value="0"/>
  65.              </form>
  66.              </td>
  67.            </tr>
  68.  
  69.            </div>
  70.            ';
  71.  
  72.           }
  73.  
  74.  
  75.           // if users hits a change level 1/2 button;
  76.           if(isset($_POST['demoteLevel'])) {
  77.  
  78.           // set $username var
  79.           $userid2 = $_POST['user_id2'];
  80.           $newLevel2 = $_POST['user_level2'];
  81.  
  82.           // update user in that row to level 1 in database
  83.           $demoteLevel = dbConnect()->prepare("UPDATE users SET level = :level WHERE id = :id");
  84.           $demoteLevel->bindParam(':id', $userid2);
  85.           $demoteLevel->bindParam(':level', $newLevel2);
  86.           $demoteLevel->execute();
  87.  
  88.           // echo success message and redirect?
  89.           echo '<p class="success">user with ID# ' .$userid2. ' has been demoted to level ' .$newLevel2. '</p>';
  90.  
  91.         }
  92.  
  93.             echo'
  94.  
  95.            <!-- ends div.admin_module -->
  96.            </div>
  97.  
  98.            <!-- ends div.col-lg-4 for admin panel 3 -->
  99.            </div>
  100.            ';
  101.           }
  102.  
  103.         }
  104.  
  105.         echo '
  106.          <!-- end of div.row -->
  107.          </div>
  108.  
  109.        <!-- end of div.container-fluid -->
  110.        </div>
  111.        ';
  112.         }
  113.  
  114.       }
  115.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement