128) die("Please select a valid hostname!"); // number of results must be specified if ($numresults == "") die("Please specify a valid number of messages to display per page!"); // Be sure the $numresults variable is numerical if (is_numeric($numresults)) { } else { echo "The number of results to view is invalid!"; exit(); } // Check num results string length. The max number of // results per page is 100 so no more than three // numbers should be entered if (strlen($numresults) > 3) die("Please select a valid number of results to view!"); // Check message string length. Only 20 because there is no // need to type a lot in this field. if (strlen($message) > 20) die("Please select a keyword or small phrase!"); // The message and date field is not required // so if either or both are blank then use a wildcard // search. if ($message == "") {$message = '%';} if ($date == "") {$date = '%';} // For the pagination, set the number of pages to 0, initially. if(!isset($start)) $start = 0; // Ensure $start variable is numerical if (is_numeric($start)) { } else { echo "The pagination number is invalid!"; exit(); } if (strlen($start) > 5) die("Please select a valid starting point to view results!"); // Make connection $connection = mysql_connect ($hostname,$username,$password) or die ("Unable to connect to MySQL server."); // connect to the database mysql_select_db ($databasename,$connection) or die ("Unable to select the database."); // sql query to return results $sql = quotemeta("SELECT host, date, time, message FROM syslogTB WHERE host = '$host' AND date LIKE '%$date%' AND message LIKE '%$message%' ORDER BY date DESC,time DESC LIMIT " . $start . ", " . $numresults . ""); // Execute the query $sql_result = mysql_query($sql,$connection) or die(mysql_errno() . ": " . mysql_error(). "\n"); if (mysql_num_rows($sql_result) == 0 ) { echo "The query returned no results!
"; exit(); } else { // Colors for the result table $color1 = "#CCCCCC"; $color2 = "#ffffff"; $row_count = 0; echo ""; // Page header echo "

Julie Syslog Messages for \"$host\"

"; echo "

"; echo "

New Search"; echo "

"; // Start table for results echo "

"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; // Array to return results while ($row = mysql_fetch_array($sql_result)) { // print the results // equation for the alternating colors $row_color = ($row_count % 2) ? $color1 : $color2; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; // Add one to the row count $row_count++; } echo "
HostDateTimeMessage
"; echo trim($row["host"]); echo ""; echo trim($row["date"]); echo ""; echo trim($row["time"]); echo ""; echo trim($row["message"]); echo "
"; // Make connection $connection = mysql_connect ($hostname,$username,$password) or die ("Unable to connect to MySQL server."); #connect to the database mysql_select_db ($databasename,$connection) or die ("Unable to select the database."); // Query to return the pagination $query = "SELECT count(*) as count FROM syslogTB WHERE host = '$host'"; // Execute query $result = mysql_query($query) or die("Couldn't execute pagination query!"); // print results $row = mysql_fetch_array($result); // Only display the next and previous links if the number or results is greater // than the number of results to display. if ($numrows > $numresults) { } else { $numrows = $row['count']; if($start > 0) echo "
Previous      Back to beginning
"; echo "    "; if($numrows > ($start + $numresults)) echo "
Next
"; } } ?>