Advertisement
Guest User

Untitled

a guest
Jul 24th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.56 KB | None | 0 0
  1.  
  2.  
  3. html
  4.  
  5. <?php
  6. $random = rand();
  7. session_start();
  8. include("dbconn.php");
  9. if (isset($_GET['site'])) {
  10. if ($_GET['site'] == "nolabel") {
  11. $_SESSION['site'] = null;
  12. unset($_SESSION['site']);
  13. } else {
  14. $_SESSION['site'] = $_GET['site'];
  15. }
  16. }
  17. if (isset($_POST['rows'])) {
  18. $_SESSION['rows'] = $_POST['rows'];
  19. $rows = $_POST['rows'];
  20. } else {
  21. if (isset($_SESSION['rows'])) {
  22. $rows = $_SESSION['rows'];
  23. } else {
  24. $rows = 7;
  25. }
  26. }
  27. if (isset($_SESSION['site'])) {
  28. $sql = "SELECT COUNT(*) AS total FROM datbs";
  29. $result = $db->query($sql) or die ("SQL error: " . $error);
  30. foreach ($result as $row) $total_datbs = $row['total'];
  31. $sql = "SELECT COUNT(*) AS total FROM datbs WHERE SUBSTR(name,1,4) = '" . $_SESSION['site'] . "'";
  32. $result = $db->query($sql) or die ("SQL error: " . $error);
  33. foreach ($result as $row) $site_datbs = $row['total'];
  34.  
  35. $sql = "SELECT * FROM datbs WHERE SUBSTR(name,1,4) = '" . $_SESSION['site'] . "' ORDER BY name";
  36. if ($rows != "all") {
  37. $sql .= " LIMIT " . $rowstart . "," . $rows . "";
  38. }
  39. } else {
  40. $sql = "SELECT * FROM datbs WHERE SUBSTR(name,1,2) = 'HP' ORDER BY name";
  41. }
  42. $result = $db->query($sql) or die ("SQL error2: " . $error);
  43. foreach ($result as $row) {
  44. //calculate uptime to show status up or down
  45. $uptime = strtotime(date("Y-m-d H:i:s")) - strtotime($row['timestamp']);
  46. $rdphost = substr($row['rdp'],0,-5);
  47. if ($rdphost != "") {
  48. $cmd = "nslookup $rdphost | find \"Name\"";
  49. $getrdpname = exec($cmd);
  50. $rdpname = substr($getrdpname,5);
  51. $rdpname = substr($rdpname,0,strpos($rdpname,"."));
  52. } else {
  53. $rdpname = "not set";
  54. }
  55. if (trim($rdpname) == "") $rdpname = $rdphost; //could not find DNS name
  56.  
  57. //$html .= "<dr>\n";
  58.  
  59. $html .= "<td colspan='8'></td><dr>\n";
  60.  
  61. if ($uptime < 300) {
  62.  
  63. $html .= "<td align='center' colspan='8' bgcolor='Green'>" . $row['name'] . "<br>" . $row['ip'] . "<br>" ."</td>\n";
  64.  
  65. }
  66. else {
  67. $html .= "<td align='center' colspan='8' bgcolor='Red'>" . $row['name'] . "<br>" . $row['ip'] . "<br>" ."</td>\n";
  68.  
  69. }
  70. }
  71.  
  72. $sql = "SELECT SUBSTR(name,1,4) as site FROM datbs GROUP BY name";
  73. $result = $db->query($sql) or die ("SQL error: " . $error);
  74.  
  75. foreach ($result as $row) {
  76. $site = $row['site'];
  77.  
  78. if ($site <> $lastsite) {
  79.  
  80. if ($site == $_SESSION['site']) {
  81. $siteselect .= "<option selected>" . $site . "</option>\n";
  82. } else {
  83. $siteselect .= "<option>" . $site . "</option>\n";
  84. }
  85.  
  86. $lastsite = $site;
  87. }
  88. }
  89.  
  90. ?>
  91. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  92. <html xmlns="http://www.w3.org/1999/xhtml">
  93. <html>
  94. <head>
  95. <title>Server Mon</title>
  96. <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
  97. <META HTTP-EQUIV="Expires" CONTENT="-1">
  98. <META NAME="code_monkey" CONTENT="Tim Beacham">
  99. <link rel="stylesheet" href="style.css" type="text/css" />
  100.  
  101. </head>
  102. <body>
  103.  
  104. <div id="navcontainer">
  105. <table border="1" width="100%" border="1" cellpadding="1" cellspacing="1">
  106. <tr>
  107. <td colspan="8">
  108. <li>
  109. <?php echo $html; ?>
  110. </li>
  111. </td>
  112.  
  113. </tr>
  114. </div>
  115. </body>
  116. </html>
  117.  
  118. CSS
  119.  
  120. #navcontainer ul
  121. {
  122. margin: 0;
  123. padding: 0;
  124. list-style-type: disc;
  125. columns: 7;
  126. -webkit-columns: 7;
  127. -moz-columns: 7;
  128. list-style-position: inline;
  129. }
  130. #navcontainer li
  131. {
  132. float: left;
  133. width: 100%;
  134. }
  135. #navcontainer ul li a
  136. {
  137. text-decoration: none;
  138. padding: 5px;
  139. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement