Advertisement
showtimeiNK

Untitled

May 28th, 2015
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.73 KB | None | 0 0
  1. <?php
  2. if(isset($_SESSION["isAdmin"]) && $_SESSION["isAdmin"] == 1){
  3. ?>
  4. <section id='mainSensorManagement'>
  5. <h1 style="color:rgba(53,149,225,1);margin-bottom: 25px;">Sensor Management</h1><hr>
  6. <table id="sensorTable" class="table">
  7.     <thead>
  8.     <tr>
  9.         <th>ID</th>
  10.         <th>Hostname</th>
  11.         <th>IP-Address</th>
  12.         <th>Is blocked?</th>
  13.         <th>Update</th>
  14.         <th>Delete</th>
  15.     </tr>
  16.     </thead>
  17.     <tbody>
  18.     <?php
  19.     //Execute query to MySQL database to get all monitors
  20.         $res = $db->query("SELECT * FROM tblMonitor");
  21.         while($arr = $res->fetch_assoc()){
  22.             $id = $arr["idMonitor"];
  23.             $name = $arr["dtMonitor"];
  24.             $ip = $arr["dtIP"];
  25.             $isBlocked = $arr["dtIsBlocked"];
  26.             echo "
  27.                <tr><form action='php/private/updateMonitor.php?id=$id' method='POST' onsubmit=\"return confirm('Do you really want to update this monitor?');\">
  28.                    <td><input type='text' name='idMonitor' value='".$id."' required".$id." placeholder='Name' disabled readonly class='form-control'></td>
  29.                    <td><input type='text' name='dtMonitor' value='".$name."' required".$name." placeholder='Name' class='form-control'></td>
  30.                    <td><input type='text' name='dtIP' value='".$ip."' required".$ip." placeholder='IP-Address' class='form-control'></td>";
  31.                     if(functions::sanitize_string_for_html($isBlocked, $db, 1) == 1)echo "<td><a href='php/private/setBlockState.php?fId=$id&fBlockState=0' id='".$id."IsBlocked'><img src='img/blocked.png' alt='Blocked' height='24'></a></td>";
  32.                     else echo "<td><a href='php/private/setBlockState.php?fId=$id&fBlockState=1' id='".$id."IsBlocked'><img src='img/notblocked.png' alt='Unblocked' height='24'></a></td>";
  33.                     echo "<td><input type='submit' name='fUpdate' value='Update' class='btn btn-primary'></td></form>
  34.                    <td><form action='php/private/deleteMonitor.php?id=$id' method='POST' onsubmit=\"return confirm('Do you really want to delete this monitor?');\"><input type='submit' name='fDelete' value='Delete' class='btn btn-danger'></form></td>
  35.                </tr>
  36.            ";
  37.         }
  38.     ?>
  39.     <tr><form action="php/private/addMonitor.php" method="POST">
  40.         <td><input type="text" name="fHostname" placeholder="Hostname" required class="form-control"></td>
  41.         <td><input type="text" name="fIP" placeholder="IP-Address" required class="form-control"></td>
  42.         <td><input type="submit" name="fAdd" value="Add" required class="btn btn-primary"></td>
  43.         <td></td>
  44.         <td></td>
  45.         <td></td></form>
  46.     </tr>
  47.  
  48.     </tbody>
  49. </table>
  50. </section>
  51. <?php
  52. }else header("Location:/");
  53. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement