. */ include("./include/include.php"); admin_header(); if( !in_array("log_view", $_SESSION['sess_functions']) ) { echoln("You are not authorized to see this page."); }else { echoln("

Activity log

"); // Load the different sections $sections = array(); $sections[] = "[all]"; $query = "SELECT `section` FROM `log` GROUP BY `section` ORDER BY `section`"; if( @mysql_num_rows( $res=doquery($query) )>0 ) { while( $row=mysql_fetch_array($res) ) { $sections[] = $row['section']; } } // Load the different types $types = array(); $types[] = "[all]"; $query = "SELECT `type` FROM `log` GROUP BY `type` ORDER BY `type`"; if( @mysql_num_rows( $res=doquery($query) )>0 ) { while( $row=mysql_fetch_array($res) ) { $types[] = $row['type']; } } // Load the different users $users = array(); $users[] = "[all]"; $users[] = "[empty]"; $query = "SELECT `sess_name` FROM `log` WHERE `sess_name`!='' GROUP BY `sess_name` ORDER BY `sess_name`"; if( @mysql_num_rows( $res=doquery($query) )>0 ) { while( $row=mysql_fetch_array($res) ) { $users[] = $row['sess_name']; } } // Set the active section if( isset($_POST['section']) ) { if( in_array($_POST['section'], $sections) ) { $_SESSION['log_section'] = $_POST['section']; }else { echoln("Invalid section, please select from the list.

"); } } if( !isset($_SESSION['log_section']) || !in_array($_SESSION['log_section'], $sections) ) $_SESSION['log_section']="[all]"; // Set the active type if( isset($_POST['type']) ) { if( in_array($_POST['type'], $types) ) { $_SESSION['log_type'] = $_POST['type']; }else { echoln("Invalid type, please select from the list.

"); } } if( !isset($_SESSION['log_type']) || !in_array($_SESSION['log_type'], $types) ) $_SESSION['log_type']="[all]"; // Set the active user if( isset($_POST['user']) ) { if( in_array($_POST['user'], $users) ) { $_SESSION['log_user'] = $_POST['user']; }else { echoln("Invalid user, please select from the list.

"); } } if( !isset($_SESSION['log_user']) || !in_array($_SESSION['log_user'], $users) ) $_SESSION['log_user']="[all]"; // Select section, type and user echoln("

"); echoln(" Section: "); echoln(" "); echoln("   "); echoln(" Type: "); echoln(" "); echoln("   "); echoln(" User: "); echoln(" "); echoln("   "); echoln(" "); echoln("
"); $querywhere = "(".($_SESSION['log_section']=="[all]"?"1":"`section`='".addslashes($_SESSION['log_section'])."'")." AND "; $querywhere.= ($_SESSION['log_type']=="[all]"?"1":"`type`='".addslashes($_SESSION['log_type'])."'")." AND "; $querywhere.= ($_SESSION['log_user']=="[all]"?"1":"`sess_name`='".($_SESSION['log_user']=="[empty]"?"":addslashes($_SESSION['log_user']))."'").")"; $query = "SELECT COUNT(`id`) AS `tot_rows` FROM `log` WHERE ".$querywhere; if( @mysql_num_rows( $res=doquery($query) )!=1 ) { echoln("Failed selecting row count."); }else { $row = mysql_fetch_array($res); $tot_rows=$row["tot_rows"]; if( $tot_rows>$setup['MaxList'] ) { // There are more entries to show than fit on one page, split in pages $page_text = "Page"; for($i=0; $i<($tot_rows/$setup['MaxList']); $i++) { if( (isset($_REQUEST['start']) && $_REQUEST['start']==($i*$setup['MaxList'])) || (!isset($_REQUEST['start']) && $i==0) ) $page_text .= "  ".($i+1).""; else $page_text .= "  ".($i+1).""; } if( isset($_REQUEST['start']) && $_REQUEST['start']==-1 ) $page_text .= "   all rows"; else $page_text.="   all rows"; echoln("

".$page_text."

"); } if( isset($_REQUEST['start']) && $_REQUEST['start']==-1 ) { $sqllimit = ""; if( $tot_rows>0 ) echoln("

Showing rows 1 - $tot_rows ($tot_rows total).

"); }else { $start = get_int('start'); if( $start<0 || $start===false ) $start = 0; if( $start>$tot_rows ) $start = $tot_rows-$setup['MaxList']; $sqllimit = "LIMIT $start, ".$setup['MaxList']; if( $tot_rows>0 ) echoln("

Showing rows ".($start+1)." - ".min( ($start+$setup['MaxList']), $tot_rows )." ($tot_rows total).

"); } $query = "SELECT `id`, `date`, `section`, `message`, `type`, `sess_name` FROM `log` WHERE ".$querywhere; $query .= " ORDER BY `date` DESC $sqllimit"; if( @mysql_num_rows( $res=doquery($query) )<1 ) { echoln("Empty selection."); }else { echoln(""); echoln(" "); echoln(" "); echoln(" "); echoln(" "); echoln(" "); echoln(" "); echoln(" "); $i=0; while( $row=mysql_fetch_array($res) ) { $i++; if( ($i%2)==1 ) echoln(" "); else echoln(" "); echoln(" "); echoln(" "); echoln(" "); echoln(" "); echoln(" "); echoln(" "); } echoln("
DateSectionMessageTypeUser
".get_date($row['date'])."".$row['section']."".$row['message']."".$row['type']."".$row['sess_name']."
"); echoln("

Total: ".$tot_rows." log entries in current selection

"); if( isset($page_text) ) echoln("

".$page_text."

"); } } } admin_footer(); ?>