\n"; echo "\n"; echo "\n"; echo "\n"; echo "

Search Results For: " . $which . "

\n"; echo "

\n"; echo ""; echo "" . ""; echo ""; $c = 0; for($i = 0 ; $i < $rowcount ; $i++) { if($c == 0) $color = $color1; else $color = $color2; $user = mysql_result($result, $i, $usernameField) . "    "; $activity = mysql_result($result, $i, $eventField); $fromHost = mysql_result($result, $i, $addrField) . "    "; $dateOccured = mysql_result($result, $i, $dateField); $comments = mysql_result($result, $i, $commentsField); if(mysql_result($result, $i, $eventField) == 'INVALID') $color = 'ff2727'; $popupScript = "newwin=window.open(\"\", \"comments\", \"scrollbars=yes, resizable=yes, width=600, height=400\"); newwin.document.open(); newwin.document.write(\"Log Comments/Details" . $comments . "\"); newwin.document.close(); return false;"; echo "\n"; if($c == 1) $c = 0; else $c = 1; } echo "
Total: $rowcount<< Back
UserActivityFrom HostDate
" . $user . "" . $activity ."    " . $fromHost . "" . $dateOccured . "


"; echo "
"; echo ""; echo "
"; echo "
"; echo "


"; } // show the search/query page (default action) function do_main() { global $PHP_SELF, $version; echo "\n"; echo "\n"; echo "SquirrelMail User Activity Log Tools (v" . $version . ")\n"; echo "\n"; echo "\n"; echo "\n"; echo "

SquirrelMail User Activity Log Tools

\n"; echo "


\n"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
Log Viewing Functions
Show All activity
Search for Logins
Search for Logouts
Search for Timeouts
Search for Invalid Logins
Search for Errors
Search for Mass Mailings
 
Search for user:   \n"; echo "
(Hint: You can search for partial user names like ant instead of anthony)
\n"; echo "


"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
 
Management functions
Delete data older than   "; echo "
(WARNING: This will NOT ask for verification!)
\n"; } // return the current date function dateNow($format="%Y%m%d") { return(strftime($format,time())); } // get a date to use for example in delete query function getolddate() { $this_year = dateNow("%Y"); $this_month = dateNow("%m"); return($this_year . "-" . $this_month . "-01"); } // delete old data from the database // $_deldate = date to use (delete all data prior to this date) // Returns: nothing function deleteOldData($_deldate) { global $tableName, $dateField; global $db, $dbuser, $dbpasswd, $dbhost; if($_deldate != null) { // check that it's a valid date so we aren't doing something stupid $tmp = explode("-", $_deldate); $_yr = $tmp[0]; $_mo = $tmp[1]; $_da = $tmp[2]; if(checkdate($_mo, $_da, $_yr)) { // good to go $query = "delete from $tableName where $dateField < '" . $_deldate . " 00:00:00'"; $conn = mysql_connect($dbhost, $dbuser, $dbpasswd); mysql_select_db($db, $conn); $result = mysql_query($query); if(!$result) { echo "



ERROR: " . mysql_error() . "\n"; echo "
Delete failed.
\n"; mysql_close(); return; } mysql_close(); echo "



\n"; echo "Deleted data prior to " . $_deldate . "

"; echo "
\n"; echo "
\n"; } else { echo "



\n"; echo "Please enter a valid date!

"; echo "
\n"; echo "
\n"; } } } // Execute a database query // $query = query string to use // Returns: result set (empty if nothing found) function doQuery($query) { global $db, $dbuser, $dbpasswd, $dbhost; $conn = mysql_connect($dbhost, $dbuser, $dbpasswd); mysql_select_db($db, $conn); $result = mysql_query($query . " order by date"); mysql_close(); $err = mysql_error(); if($err) { echo "ERROR: Error code = " . $err . "\n"; echo "
Search failed.\n"; exit; } return($result); }