Skip to content

Commit

Permalink
$outputbits and $sectionbits
Browse files Browse the repository at this point in the history
  • Loading branch information
tommyrot committed Jan 31, 2010
1 parent 667e599 commit 369d715
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 46 deletions.
22 changes: 11 additions & 11 deletions HTML.class.php
Expand Up @@ -37,7 +37,7 @@ final class HTML
private $db_user = '';
private $minLines = 500;
private $minRows = 3;
private $outputbits = 31;
private $sectionbits = 31;
private $stylesheet = 'default.css';
private $userstats = FALSE;

Expand Down Expand Up @@ -68,7 +68,7 @@ final class HTML
'db_user' => 'string',
'minLines' => 'int',
'minRows' => 'int',
'outputbits' => 'int',
'sectionbits' => 'int',
'stylesheet' => 'string',
'userstats' => 'bool');
private $year = '';
Expand Down Expand Up @@ -194,7 +194,7 @@ public function makeHTML()
/**
* Activity section
*/
if ($this->outputbits & 1) {
if ($this->sectionbits & 1) {
$this->output .= '<div class="head">Activity</div>'."\n";
$this->output .= $this->makeTable_MostActiveTimes(array('head' => 'Most Active Times'));
$this->output .= $this->makeTable_Activity(array('type' => 'days', 'head' => 'Daily Activity'));
Expand All @@ -210,7 +210,7 @@ public function makeHTML()
/**
* General Chat section
*/
if ($this->outputbits & 2) {
if ($this->sectionbits & 2) {
$output = '';
$output .= $this->makeTable(array('size' => 'small', 'rows' => 5, 'head' => 'Most Talkative Chatters', 'key1' => 'Lines/Day', 'key2' => 'User', 'decimals' => 1, 'percentage' => FALSE, 'query' => 'SELECT (`l_total` / `activeDays`) AS `v1`, `csNick` AS `v2` FROM `query_lines` JOIN `user_details` ON `query_lines`.`UID` = `user_details`.`UID` JOIN `user_status` ON `query_lines`.`UID` = `user_status`.`UID` WHERE `status` != 3 AND `l_total` >= '.$this->minLines.' ORDER BY `v1` DESC, `v2` ASC LIMIT 5'));
$output .= $this->makeTable(array('size' => 'small', 'rows' => 5, 'head' => 'Most Fluent Chatters', 'key1' => 'Words/Line', 'key2' => 'User', 'decimals' => 1, 'percentage' => FALSE, 'query' => 'SELECT (`words` / `l_total`) AS `v1`, `csNick` AS `v2` FROM `query_lines` JOIN `user_details` ON `query_lines`.`UID` = `user_details`.`UID` JOIN `user_status` ON `query_lines`.`UID` = `user_status`.`UID` WHERE `status` != 3 AND `l_total` >= '.$this->minLines.' ORDER BY `v1` DESC, `v2` ASC LIMIT 5'));
Expand Down Expand Up @@ -242,7 +242,7 @@ public function makeHTML()
/**
* Modes section
*/
if ($this->outputbits & 4) {
if ($this->sectionbits & 4) {
$output = '';
$modes = array('Most Ops \'+o\', Given' => array('Ops', 'm_op')
,'Most Ops \'+o\', Received' => array('Ops', 'm_opped')
Expand All @@ -265,7 +265,7 @@ public function makeHTML()
/**
* Events section
*/
if ($this->outputbits & 8) {
if ($this->sectionbits & 8) {
$output = '';
$output .= $this->makeTable(array('size' => 'large', 'rows' => 5, 'head' => 'Most Kicks', 'key1' => 'Kicks', 'key2' => 'User', 'key3' => 'Example', 'decimals' => 0, 'percentage' => FALSE, 'query' => 'SELECT `kicks` AS `v1`, `csNick` AS `v2`, `ex_kicks` AS `v3` FROM `query_events` JOIN `user_details` ON `query_events`.`UID` = `user_details`.`UID` JOIN `user_status` ON `query_events`.`UID` = `user_status`.`UID` WHERE `status` != 3 AND `kicks` != 0 ORDER BY `v1` DESC, `v2` ASC LIMIT 5', 'query_total' => 'SELECT SUM(`kicks`) AS `total` FROM `query_events`'));
$output .= $this->makeTable(array('size' => 'large', 'rows' => 5, 'head' => 'Most Kicked', 'key1' => 'Kicked', 'key2' => 'User', 'key3' => 'Example', 'decimals' => 0, 'percentage' => FALSE, 'query' => 'SELECT `kicked` AS `v1`, `csNick` AS `v2`, `ex_kicked` AS `v3` FROM `query_events` JOIN `user_details` ON `query_events`.`UID` = `user_details`.`UID` JOIN `user_status` ON `query_events`.`UID` = `user_status`.`UID` WHERE `status` != 3 AND `kicked` != 0 ORDER BY `v1` DESC, `v2` ASC LIMIT 5', 'query_total' => 'SELECT SUM(`kicked`) AS `total` FROM `query_events`'));
Expand All @@ -285,7 +285,7 @@ public function makeHTML()
/**
* Smileys section
*/
if ($this->outputbits & 16) {
if ($this->sectionbits & 16) {
$output = '';
$smileys = array('Big Cheerful Smile' => array('=]', 's_01')
,'Cheerful Smile' => array('=)', 's_02')
Expand Down Expand Up @@ -1004,25 +1004,25 @@ private function output($type, $msg)

switch ($type) {
case 'debug':
if ($this->outputLevel & 8) {
if ($this->outputbits & 8) {
echo $dateTime.' [debug] '.$msg."\n";
}

break;
case 'notice':
if ($this->outputLevel & 4) {
if ($this->outputbits & 4) {
echo $dateTime.' [notice] '.$msg."\n";
}

break;
case 'warning':
if ($this->outputLevel & 2) {
if ($this->outputbits & 2) {
echo $dateTime.' [warning] '.$msg."\n";
}

break;
case 'critical':
if ($this->outputLevel & 1) {
if ($this->outputbits & 1) {
echo $dateTime.' [critical] '.$msg."\n";
}

Expand Down
12 changes: 6 additions & 6 deletions Maintenance.class.php
Expand Up @@ -38,7 +38,7 @@ final class Maintenance
private $db_pass = '';
private $db_port = 0;
private $db_user = '';
private $outputLevel = 1;
private $outputbits = 1;
private $sanitisationDay = 'mon';

/**
Expand All @@ -51,7 +51,7 @@ final class Maintenance
'db_pass' => 'string',
'db_port' => 'int',
'db_user' => 'string',
'outputLevel' => 'int',
'outputbits' => 'int',
'sanitisationDay' => 'string');

/**
Expand Down Expand Up @@ -308,25 +308,25 @@ private function output($type, $msg)

switch ($type) {
case 'debug':
if ($this->outputLevel & 8) {
if ($this->outputbits & 8) {
echo $dateTime.' [debug] '.$msg."\n";
}

break;
case 'notice':
if ($this->outputLevel & 4) {
if ($this->outputbits & 4) {
echo $dateTime.' [notice] '.$msg."\n";
}

break;
case 'warning':
if ($this->outputLevel & 2) {
if ($this->outputbits & 2) {
echo $dateTime.' [warning] '.$msg."\n";
}

break;
case 'critical':
if ($this->outputLevel & 1) {
if ($this->outputbits & 1) {
echo $dateTime.' [critical] '.$msg."\n";
}

Expand Down
12 changes: 6 additions & 6 deletions Parser.class.php
Expand Up @@ -32,7 +32,7 @@ abstract class Parser
private $minStreak = 5;
private $nick_maxLen = 255;
private $nick_minLen = 1;
private $outputLevel = 1;
private $outputbits = 1;
private $quote_prefLen = 25;
private $wordTracking = FALSE;

Expand Down Expand Up @@ -86,7 +86,7 @@ abstract class Parser
'minStreak' => 'int',
'nick_maxLen' => 'int',
'nick_minLen' => 'int',
'outputLevel' => 'int',
'outputbits' => 'int',
'quote_prefLen' => 'int',
'wordTracking' => 'bool');
private $smileys = array(
Expand Down Expand Up @@ -201,25 +201,25 @@ final protected function output($type, $msg)

switch ($type) {
case 'debug':
if ($this->outputLevel & 8) {
if ($this->outputbits & 8) {
echo $dateTime.' [debug] '.$msg."\n";
}

break;
case 'notice':
if ($this->outputLevel & 4) {
if ($this->outputbits & 4) {
echo $dateTime.' [notice] '.$msg."\n";
}

break;
case 'warning':
if ($this->outputLevel & 2) {
if ($this->outputbits & 2) {
echo $dateTime.' [warning] '.$msg."\n";
}

break;
case 'critical':
if ($this->outputLevel & 1) {
if ($this->outputbits & 1) {
echo $dateTime.' [critical] '.$msg."\n";
}

Expand Down
14 changes: 8 additions & 6 deletions nicklinker.php
Expand Up @@ -26,7 +26,8 @@ final class nicklinker
private $db_pass = '';
private $db_port = 0;
private $db_user = '';
private $outputLevel = 1;
private $outputbits = 1;
private $timezone = '';

/**
* Variables that shouldn't be tampered with.
Expand All @@ -38,7 +39,8 @@ final class nicklinker
'db_pass' => 'string',
'db_port' => 'int',
'db_user' => 'string',
'outputLevel' => 'int');
'outputbits' => 'int',
'timezone' => 'string');
private $settings_required_list = array('db_host', 'db_name', 'db_pass', 'db_port', 'db_user', 'timezone');

/**
Expand Down Expand Up @@ -202,25 +204,25 @@ private function output($type, $msg)

switch ($type) {
case 'debug':
if ($this->outputLevel & 8) {
if ($this->outputbits & 8) {
echo $dateTime.' [debug] '.$msg."\n";
}

break;
case 'notice':
if ($this->outputLevel & 4) {
if ($this->outputbits & 4) {
echo $dateTime.' [notice] '.$msg."\n";
}

break;
case 'warning':
if ($this->outputLevel & 2) {
if ($this->outputbits & 2) {
echo $dateTime.' [warning] '.$msg."\n";
}

break;
case 'critical':
if ($this->outputLevel & 1) {
if ($this->outputbits & 1) {
echo $dateTime.' [critical] '.$msg."\n";
}

Expand Down
2 changes: 1 addition & 1 deletion sss.conf
Expand Up @@ -19,6 +19,6 @@ logfileSuffix = ".log"
# Below is a short list of commented out options you might find interesting to
# have a look at. The values shown are their defaults.

# outputLevel = "1"
# outputbits = "1"
# userstats = "FALSE"
# wordTracking = "FALSE"
34 changes: 18 additions & 16 deletions sss.php
Expand Up @@ -26,7 +26,8 @@ final class sss
private $logfileFormat = '';
private $logfilePrefix = '';
private $logfileSuffix = '';
private $outputLevel = 1;
private $outputbits = 1;
private $timezone = '';
private $writeData = TRUE;

/**
Expand All @@ -39,7 +40,8 @@ final class sss
'logfileFormat' => 'string',
'logfilePrefix' => 'string',
'logfileSuffix' => 'string',
'outputLevel' => 'int',
'outputbits' => 'int',
'timezone' => 'string',
'writeData' => 'bool');
private $settings_required_list = array('channel', 'db_host', 'db_name', 'db_pass', 'db_port', 'db_user', 'logfileDateFormat', 'logfileFormat', 'logfilePrefix', 'logfileSuffix', 'timezone');

Expand Down Expand Up @@ -68,7 +70,7 @@ public function __construct()
}

if (array_key_exists('b', $options)) {
$this->settings['outputbits'] = $options['b'];
$this->settings['sectionBits'] = $options['b'];
}

if (array_key_exists('i', $options)) {
Expand Down Expand Up @@ -124,25 +126,25 @@ private function output($type, $msg)

switch ($type) {
case 'debug':
if ($this->outputLevel & 8) {
if ($this->outputbits & 8) {
echo $dateTime.' [debug] '.$msg."\n";
}

break;
case 'notice':
if ($this->outputLevel & 4) {
if ($this->outputbits & 4) {
echo $dateTime.' [notice] '.$msg."\n";
}

break;
case 'warning':
if ($this->outputLevel & 2) {
if ($this->outputbits & 2) {
echo $dateTime.' [warning] '.$msg."\n";
}

break;
case 'critical':
if ($this->outputLevel & 1) {
if ($this->outputbits & 1) {
echo $dateTime.' [critical] '.$msg."\n";
}

Expand All @@ -155,7 +157,7 @@ private function output($type, $msg)
*/
private function parseLog($filedir)
{
$filedir = preg_replace('/YESTERDAY/', date($this->settings['logfileDateFormat'], strtotime('yesterday')), $filedir);
$filedir = preg_replace('/YESTERDAY/', date($this->logfileDateFormat, strtotime('yesterday')), $filedir);

if (($rp = realpath($filedir)) !== FALSE) {
if (is_dir($rp)) {
Expand All @@ -180,8 +182,8 @@ private function parseLog($filedir)
$needMaintenance = FALSE;

foreach ($logfiles as $logfile) {
if ((empty($this->settings['logfilePrefix']) || stripos(basename($logfile), $this->settings['logfilePrefix']) !== FALSE) && (empty($this->settings['logfileSuffix']) || stripos(basename($logfile), $this->settings['logfileSuffix']) !== FALSE)) {
$date = str_replace(array($this->settings['logfilePrefix'], $this->settings['logfileSuffix']), '', basename($logfile));
if ((empty($this->logfilePrefix) || stripos(basename($logfile), $this->logfilePrefix) !== FALSE) && (empty($this->logfileSuffix) || stripos(basename($logfile), $this->logfileSuffix) !== FALSE)) {
$date = str_replace(array($this->logfilePrefix, $this->logfileSuffix), '', basename($logfile));
$date = date('Y-m-d', strtotime($date));

if ($date == date('Y-m-d')) {
Expand All @@ -195,7 +197,7 @@ private function parseLog($filedir)
}
}

$parser_class = 'Parser_'.$this->settings['logfileFormat'];
$parser_class = 'Parser_'.$this->logfileFormat;
$parser = new $parser_class($this->settings);
$parser->setValue('date', $date);
$parser->parseLog($logfile);
Expand All @@ -220,10 +222,10 @@ private function parseLog($filedir)
*/
private function printManual()
{
$man = 'usage: php sss.php [-c <config>] [-i <logfile|logdir>] [-o <statspage> [-b <outputbits>]]'."\n"
$man = 'usage: php sss.php [-c <config>] [-i <logfile|logdir>] [-o <statspage> [-b <sectionbits>]]'."\n"
. ' php sss.php [-c <config>] [-m]'."\n\n"
. 'the options are:'."\n"
. ' -b set <outputbits>, add up the bits corresponding to the sections'."\n"
. ' -b set <sectionbits>, add up the bits corresponding to the sections'."\n"
. ' you want to be included on the statspage:'."\n"
. ' 1 activity'."\n"
. ' 2 general chat'."\n"
Expand Down Expand Up @@ -286,10 +288,10 @@ private function readConfig($file)
}
}

if (date_default_timezone_set($this->settings['timezone']) !== FALSE) {
$this->output('notice', 'readConfig(): switched to timezone: \''.$this->settings['timezone'].'\'');
if (date_default_timezone_set($this->timezone) !== FALSE) {
$this->output('notice', 'readConfig(): switched to timezone: \''.$this->timezone.'\'');
} else {
$this->output('critical', 'readConfig(): invalid timezone: \''.$this->settings['timezone'].'\'');
$this->output('critical', 'readConfig(): invalid timezone: \''.$this->timezone.'\'');
}
} else {
$this->output('critical', 'readConfig(): failed to open file: \''.$rp.'\'');
Expand Down

0 comments on commit 369d715

Please sign in to comment.