A hint: This file contains one or more very long lines, so maybe it is better readable using the pure text view mode that shows the contents as wrapped lines within the browser window.
1 <? 2 require_once("connect.php"); 3 if ($_SESSION["isloggedin"] != $glbl_hash) { 4 header("Location: ".$nr_url."login.php?referrer=db-maintenance.php"); 5 exit; 6 } else if (($_SESSION["isloggedin"] == $glbl_hash) && ($_SESSION["isadmin"] != $glbl_hash)) { 7 header("Location: ".$nr_url); 8 exit; 9 } 10 11 $title = "Database Maintenance"; 12 require_once("header.php"); 13 14 15 16 17 if (($_POST["submit"] == "Proceed w/ Removal") && ($_POST["del_sure"] == 1)) { 18 // Records older than '$old' will be deleted according to 'time' field 19 $now = mktime(); 20 $old = $now - (intval($_POST['timespan']) * intval($_POST['num'])); 21 $query1 = "SELECT id,time FROM alert_log WHERE resolved<>'N'"; 22 $result1 = db_query($query1); 23 $count = 0; 24 while ($r = db_fetch_array($result1)) { 25 $id = $r["id"]; 26 $time = $r["time"]; 27 if ((int)$time < $old) { 28 $query2 = "DELETE FROM alert_log WHERE id='$id'"; 29 $result2 = db_query($query2); 30 $count++; 31 } 32 } 33 34 if (!$count) { 35 echo '<div align="center" class="errmsg">There were no records that old.</div><br><br>'; 36 } else { 37 echo '<div align="center" class="errmsg">'.$count.' Record(s) Successfully Deleted.</div><br><br>'; 38 } 39 40 41 } 42 43 44 echo ' 45 <table width="760" border="0" cellspacing="0" cellpadding="3" align="center"> 46 <form action="'.$_SERVER['PHP_SELF'].'" method="post"> 47 <tr valign="top"> 48 <td height="42"> 49 <span style="border-bottom:1px solid #A00000;font-weight:bold;color:#A00000;">HISTORICAL LOG CLEANUP:</span><font size="1"><br><br></font> 50 <font color="red"><b>CAUTION: This function will PERMANENTLY remove historical log records. This is the data that is collected to display downtime statistics for each node. It is recommended that you do not use this feature unless you are running low on disk space. Proceed with caution.</b></font> 51 </td> 52 </tr> 53 <tr> 54 <td> 55 <p>Remove ALL records 56 <input type="text" name="num" size="2" value="90"> 57 <select name="timespan"> 58 <option value="60">MINUTE(S)</option> 59 <option value="3600">HOUR(S)</option> 60 <option value="86400" selected>DAY(S)</option> 61 </select> 62 older than today\'s date and time.</p> 63 <p>Today\'s Date: <b>'. date("m/d/Y H:i:s", mktime()) .'</b></p> 64 <p><input type="checkbox" name="del_sure" value="1"> 65 I\'m sure. 66 <input type="submit" name="submit" value="Proceed w/ Removal"> 67 </form></p> 68 </td> 69 </tr> 70 </table> 71 '; 72 73 74 require_once("footer.php"); 75 76 ?>