date_default_timezone_set('UTC'); $log = "/PATH/AND/FILENAME/TO/YOUR/LOGFILE/PLEASE.db"; /********** PREPARATION **********/ $db = new PDO('sqlite:' . $log); if (!is_object($db)) { // Failure, can't access Phergie Log. // Bail with an error message, not pretty, but works: echo "ERROR: Cannot access Phergie Log File, " . "please check the configuration & access privileges"; exit; } /********** DETECTION **********/ // Determine the mode of the application and call the appropriate handler function $mode = empty($_GET['m']) ? '' : $_GET['m']; switch ($mode) { case 'channel': show_days($db); break; case 'day': show_log($db); break; default: show_channels($db); } // Exit not really needed here, // but reminds us that everything below is support functions: exit; /********** MODES **********/ /** * show_channels * * Provide a list of all channel's that we are logging information for:
// Fail if we don't have a $dsn or $table if (!$dsn || !$table) { exit("ERROR: No DSN or Table configuration can be read."); } $db = new PDO($dsn, $user, $pass); if (!is_object($db)) { // Failure, can't access Phergie Log. exit("ERROR: Cannot access log, please check the configuration & access privileges"); } $db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ); /********** DETECTION **********/ // Determine the mode of the application and call the appropriate handler function $mode = empty($_GET['m']) ? '' : $_GET['m']; switch ($mode) { case 'channel': show_days($db, $table); break; case 'day': show_log($db, $table); break; default: show_channels($db, $table); } // Exit not really needed here, // but reminds us that everything below is support functions: exit; /********** MODES **********/ /** * show_channels * * Provide a list of all channel's that we are logging information for: