PClib demo site

<?php
/* project: Eventlog, file: eventlog.php */

//Include pclib framework
require 'pclib/pclib.php';

//Create pclib application
$app = new PCApp('demo');

$datasource 'pdo_mysql://user:password@localhost/test';

$app->db = new PCDb($datasource);

//Get control variables
$action $app->action;
$id $_GET['id'];

//Initialize logger
$logger = new PCLogger('app-monitor');

//action - LOG IT!
if ($app->action) {
  switch (
$app->action) {
  case 
'warning1'$logger->log('WARNING''demo/eventlog/warning1');     break;
  default:         
$logger->log('NOTICE''demo/eventlog/'.$actionnull$id); break;
  }
  
header('Location: index.php?r=eventlog');
}

// show last 100 records in the log
$log = new PCGrid('tpl/eventlog.tpl');
//$log->setArray( $logger->getLog(-1) );
$log->setArray$logger->getLog(100) );

//We will keep privacy of visitors and hide last part of IP address in the loglist
function filter_ip($obj$id$sub$val) {
  if (
$sub) return 1;
  print 
substr($val,0,strrpos($val'.')).'.xxx';
}

$log->_IP->onprint "filter_ip";

print 
$log;

?>

Elapsed time: 375.98 ms