azerak

admin.php

Feb 13th, 2013
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.34 KB | None | 0 0
  1. <?php
  2.  ob_start();
  3. ?>
  4. <?php
  5. if (isset($_SESSION['user_id']) and (strpos($_SESSION['user_permissions'], "user") !== false))
  6. {
  7.     $pagetitle = "Manage users";
  8.     $delresult = '';
  9.    
  10.     if (isset($_POST["user"]))
  11.     {
  12.         $deluser = $_POST["user"];
  13.        
  14.         for ($i = 0; $i < count($deluser); $i++)
  15.         {
  16.             mysql_query("INSERT INTO `log_tool` (`action`, `user`, `timestamp`) VALUES ('DELETED USER: ".$deluser[$i]."', '{$_SESSION['login']}', NOW())");
  17.             mysql_query("DELETE FROM `users` WHERE `id` = '".$deluser[$i]."'") or die(mysql_error());
  18.            
  19.             $delresult .= '<div id="message-green">
  20.                 <table border="0" width="100%" cellpadding="0" cellspacing="0"><tr>
  21.                 <td class="green-left">User '.$deluser[$i].' successfully removed!</td>
  22.                 <td class="green-right"><a class="close-green"><img src="images/forms/icon_close_green.gif" alt="" /></a></td>
  23.                 </tr></table>
  24.                 </div>';
  25.  
  26.             //echo($aDoor[$i]);
  27.         }
  28.     }
  29.     else if (isset($_GET['register']))
  30.     { ?>
  31.         <div id="dvPopup" style="display: none; width: 900px; height: 450px; border: 4px solid #000000; background-color: #FFFFFF;">
  32.             <a id="closebutton" style="float: right;" href="#" onclick="HideModalPopup('dvPopup'); return false;"><img src="images/forms/action_delete.gif" alt="" /></a><br />
  33.             <?php include_once('modules/register.php'); ?>
  34.         </div>
  35.         <script>ShowModalPopup('dvPopup');</script>
  36.     <?php }
  37.     else
  38.     {
  39.         mysql_query("INSERT INTO `log_tool` (`action`, `user`, `timestamp`) VALUES ('MANAGE USERS', '{$_SESSION['login']}', NOW())");
  40.     }
  41.  
  42.     $res = mysql_query("SELECT * FROM `users` ORDER BY `id` ASC") or die(mysql_error());
  43.     $number = mysql_num_rows($res);
  44.     $users = '';
  45.     while ($row = mysql_fetch_array($res)) { $users .= '<tr><td align="center"><input name="user[]" value="'.$row['id'].'" type="checkbox"/></td><td>'.$row['id'].'</td><td>'.$row['login'].'</td><td>'.$row['permissions'].'</td><td>'.$row['lastlogin'].'</td></tr>'; }
  46.  
  47.     ?>
  48.  
  49.     <div id="page-heading">
  50.         <title><?php echo $pagetitle." - ".$sitename; ?></title>
  51.         <h1><?php echo $pagetitle; ?></h1>
  52.     </div>
  53.  
  54.     <table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table">
  55.         <tr>
  56.             <th rowspan="3" class="sized"><img src="images/forms/side_shadowleft.jpg" width="20" height="300" alt="" /></th>
  57.             <th class="topleft"></th>
  58.             <td id="tbl-border-top">&nbsp;</td>
  59.             <th class="topright"></th>
  60.             <th rowspan="3" class="sized"><img src="images/forms/side_shadowright.jpg" width="20" height="300" alt="" /></th>
  61.         </tr>
  62.         <tr>
  63.             <td id="tbl-border-left"></td>
  64.             <td>
  65.                 <div id="content-table-inner">
  66.                     <?php echo $delresult; ?>
  67.                     <div id="related-activities">
  68.                         <div id="related-act-top">
  69.                             <img width="271" height="43" alt="" src="images/forms/header_related_act.gif">
  70.                         </div>
  71.                         <div id="related-act-bottom">
  72.                             <div id="related-act-inner">
  73.                                 <div class="left"><a href="#" onclick="ShowModalPopup('dvPopup'); return false;">
  74.                                     <img width="21" height="21" alt="" src="images/forms/icon_plus.gif"></a>
  75.                                 </div>
  76.                                 <div class="right">
  77.                                     <h5><a href="index.php?view=admin&register">Add user</a></h5>
  78.                                 </div>
  79.                                 <div class="clear"></div>
  80.                             </div>
  81.                         </div>
  82.                     </div>
  83.                     <div id="table-content">
  84.                         <form action="index.php?view=admin" method="post">
  85.                             <table border="1" width="75%" cellpadding="0" cellspacing="0" id="product-table">
  86.                             <tr>
  87.                                 <th class="table-header-repeat line-left"><a href="">Delete</a></th>
  88.                                 <th class="table-header-repeat line-left" width="5%"><a href="">Id</a>  </th>
  89.                                 <th class="table-header-repeat line-left minwidth-1" width="30%"><a href="">Username</a></th>
  90.                                 <th class="table-header-repeat line-left minwidth-1" width="45%"><a href="">Permissions</a></th>
  91.                                 <th class="table-header-repeat line-left minwidth-1" width="20%"><a href="">Last access</a></th>
  92.                             </tr>
  93.                             <?php echo $users; ?>              
  94.                             </table>
  95.                             <input type="submit" class="submit-login"  />
  96.                         </form>
  97.                     </div>
  98.                     <div class="clear"></div>
  99.                 </div>
  100.             </td>
  101.             <td id="tbl-border-right"></td>
  102.         </tr>
  103.         <tr>
  104.             <th class="sized bottomleft"></th>
  105.             <td id="tbl-border-bottom">&nbsp;</td>
  106.             <th class="sized bottomright"></th>
  107.         </tr>
  108.     </table>
  109.     <div class="clear">&nbsp;</div>
  110.  
  111. <?php
  112. }
  113. else
  114. {
  115. header('Location: index.php');
  116. }
  117. ob_end_flush();
  118. ?>
Advertisement
Add Comment
Please, Sign In to add comment