= '".addslashes($row['dt'])."' ORDER BY dt, id"; }else{ echo 'Could not find any logs for user '.htmlspecialchars($_REQUEST['u']); $sql = ''; } }else{ if($_REQUEST['d']){ $date = $_REQUEST['d']; }else{ $date = date('Y-m-d'); } $sql = "SELECT id, DATE(dt) as d, TIME(dt) as t, user, type, msg FROM messages WHERE DATE(dt) = DATE('".addslashes($date)."') ORDER BY dt, id"; } if($sql) $res = mysql_query($sql,$dbh); if($date){ echo '
'; echo '
Log for
'; echo '
'; }elseif($sql && $_REQUEST['u']){ echo '
Log since last login of '.htmlspecialchars($_REQUEST['u']).'
'; }elseif($sql && $_REQUEST['s']){ echo '
Matching lines for '.htmlspecialchars($_REQUEST['s']).'
'; echo '
Click the timestamp to see the line in context.
'; } echo '
'; if($sql) while($row = mysql_fetch_array($res, MYSQL_ASSOC)){ echo '
'; echo '
'; echo '['.$row['t'].']'; echo '
'; if($row['type'] == 'public'){ echo '
'.htmlspecialchars($row['user']).'
'; }else{ echo '
*
'; } $msg = htmlspecialchars( $row['msg']); $msg = preg_replace_callback('/((https?|ftp):\/\/[\w-?&;#~=\.\/\@%:]+[\w\/])/ui', 'format_link',$msg); if(substr($msg,0,3) == '/me'){ $msg = '
'.htmlspecialchars($row['user']).substr($msg,3).'
'; } echo $msg; echo '
'; echo '
'; } echo '
'; $sql = "SELECT DISTINCT DATE(dt) as d, DAY(dt) as day FROM messages WHERE dt > DATE_SUB(NOW(), INTERVAL 30 DAY) ORDER BY dt"; $res = mysql_query($sql,$dbh); echo '
Last 30 days: '; while($row = mysql_fetch_array($res, MYSQL_ASSOC)){ echo '
'.$row['day'].'
'; } echo '
'; ?>