Permalink
Browse files

big boring reformatting commit to please my IDE and OCD

  • Loading branch information...
1 parent d56fdd6 commit dc0f2075afbdde345149a29fe5aaa058bc6cab04 @tommyrot committed Oct 16, 2013
Showing with 314 additions and 305 deletions.
  1. +45 −45 MANUAL
  2. +3 −3 base.php
  3. +38 −36 html.php
  4. +3 −7 maintenance.php
  5. +16 −16 parser.php
  6. +26 −24 parser_eggdrop.php
  7. +16 −15 parser_hexchat.php
  8. +23 −22 parser_irssi.php
  9. +16 −14 parser_limechat.php
  10. +27 −22 parser_mirc6.php
  11. +8 −8 parser_nodelog.php
  12. +17 −17 parser_supybot.php
  13. +17 −14 parser_textual.php
  14. +20 −18 parser_znc.php
  15. +4 −4 sss.conf
  16. +8 −13 sss.php
  17. +3 −3 urltools.php
  18. +9 −9 www/history.php
  19. +14 −14 www/user.php
  20. +1 −1 www/vars.php
View
@@ -1,50 +1,50 @@
-usage: php sss.php [-c <file>] [-i <file|directory>]
- [-o <file> [-b <numbits>]]
- php sss.php [-c <file>] [-e <file>]
- php sss.php [-c <file>] [-n <file>]
- php sss.php [-c <file>] [-s]
+usage: php sss.php [-c <file>] [-i <file|directory>]
+ [-o <file> [-b <numbits>]]
+ php sss.php [-c <file>] [-e <file>]
+ php sss.php [-c <file>] [-n <file>]
+ php sss.php [-c <file>] [-s]
options:
- -b <numbits>
- Specifies which sections to display on the stats page. Add up
- the bits corresponding to the sections you want to enable:
- 1 Activity
- 2 General Chat
- 4 Modes
- 8 Events
- 16 Smileys
- 32 URLs
- 64 Words
- 128 Milestones
- This option overrides the value from the configuration file.
-
- -c <file>
- Read settings from <file>. By default "./sss.conf" is read.
-
- -e <file>
- Export all user relations from the database to <file>.
-
- -i <file|directory>
- Parse logfile <file>, or all logfiles in <directory>. After the
- last logfile has been parsed database maintenance will commence
- to verify, sort and index data.
-
- -n <file>
- Import user relations from <file> into the database. Existing
- relationships will be unset prior to any updates made. It is
- highly recommended to keep an export as backup. Nicks contained
- in <file> are treated as case insensitive and nicks which don't
- exist in the database will be ignored.
-
- -o <file>
- Generate statistics and output to <file>.
-
- -s
- Export settings from the configuration file in the format
- "vars.php" accepts them. See "vars.php" for details.
+ -b <numbits>
+ Specifies which sections to display on the stats page. Add up
+ the bits corresponding to the sections you want to enable:
+ 1 Activity
+ 2 General Chat
+ 4 Modes
+ 8 Events
+ 16 Smileys
+ 32 URLs
+ 64 Words
+ 128 Milestones
+ This option overrides the value from the configuration file.
+
+ -c <file>
+ Read settings from <file>. By default "./sss.conf" is read.
+
+ -e <file>
+ Export all user relations from the database to <file>.
+
+ -i <file|directory>
+ Parse logfile <file>, or all logfiles in <directory>. After the
+ last logfile has been parsed database maintenance will commence
+ to verify, sort and index data.
+
+ -n <file>
+ Import user relations from <file> into the database. Existing
+ relationships will be unset prior to any updates made. It is
+ highly recommended to keep an export as backup. Nicks contained
+ in <file> are treated as case insensitive and nicks which don't
+ exist in the database will be ignored.
+
+ -o <file>
+ Generate statistics and output to <file>.
+
+ -s
+ Export settings from the configuration file in the format
+ "vars.php" accepts them. See "vars.php" for details.
examples:
- Parse all logfiles found in "/home/foo/bar/" and create a stats page
- named "/var/www/foobar.html" containing only Activity and URLs data:
+ Parse all logfiles found in "/home/foo/bar/" and create a stats page
+ named "/var/www/foobar.html" containing only Activity and URLs data:
- $ php sss.php -i /home/foo/bar/ -o /var/www/foobar.html -b 33
+ $ php sss.php -i /home/foo/bar/ -o /var/www/foobar.html -b 33
View
@@ -47,13 +47,13 @@
foreach ($columns as $key) {
if (is_int($this->$key) && $this->$key != 0) {
$queryparts['columnlist'][] = $key;
- $queryparts['values'][] = $this->$key;
$queryparts['update-assignments'][] = $key.' = '.$key.' + '.$this->$key;
+ $queryparts['values'][] = $this->$key;
} elseif (is_string($this->$key) && $this->$key != '') {
$value = '\''.$sqlite3->escapeString($this->$key).'\'';
$queryparts['columnlist'][] = $key;
- $queryparts['values'][] = $value;
$queryparts['update-assignments'][] = $key.' = '.$value;
+ $queryparts['values'][] = $value;
}
}
@@ -77,8 +77,8 @@
return null;
}
- $this->prevoutput[] = $msg;
$datetime = date('M d H:i:s');
+ $this->prevoutput[] = $msg;
if (substr($datetime, 4, 1) === '0') {
$datetime = substr_replace($datetime, ' ', 4, 1);
View
@@ -213,20 +213,20 @@ public function make_html($sqlite3)
$date_max = $result['date'];
$l_max = $result['l_total'];
$this->output = '<!DOCTYPE html>'."\n\n"
- . '<html>'."\n\n"
- . '<head>'."\n"
- . '<meta charset="utf-8">'."\n"
- . '<title>'.htmlspecialchars($this->channel).', seriously.</title>'."\n"
- . '<link rel="stylesheet" href="'.$this->stylesheet.'">'."\n"
- . '<style type="text/css">'."\n"
- . ' .act-year { width:'.(2 + (($this->datetime['years'] + ($this->estimate ? 1 : 0)) * 34)).'px }'."\n"
- . '</style>'."\n"
- . '</head>'."\n\n"
- . '<body><div id="container">'."\n"
- . '<div class="info">'.htmlspecialchars($this->channel).', seriously.<br><br>'
- . number_format($dayslogged).' day'.($dayslogged > 1 ? 's logged from '.date('M j, Y', strtotime($date_first)).' to '.date('M j, Y', strtotime($date_last)) : ' logged on '.date('M j, Y', strtotime($date_first))).'.<br><br>'
- . 'Logs contain '.number_format($this->l_total).' line'.($this->l_total > 1 ? 's' : '').' &ndash; an average of '.number_format($l_avg).' line'.($l_avg > 1 ? 's' : '').' per day.<br>'
- . 'Most active day was '.date('M j, Y', strtotime($date_max)).' with a total of '.number_format($l_max).' line'.($l_max > 1 ? 's' : '').' typed.'.($this->addhtml_head != '' ? '<br><br>'.trim(file_get_contents($this->addhtml_head)) : '').'</div>'."\n";
+ . '<html>'."\n\n"
+ . '<head>'."\n"
+ . '<meta charset="utf-8">'."\n"
+ . '<title>'.htmlspecialchars($this->channel).', seriously.</title>'."\n"
+ . '<link rel="stylesheet" href="'.$this->stylesheet.'">'."\n"
+ . '<style type="text/css">'."\n"
+ . ' .act-year { width:'.(2 + (($this->datetime['years'] + ($this->estimate ? 1 : 0)) * 34)).'px }'."\n"
+ . '</style>'."\n"
+ . '</head>'."\n\n"
+ . '<body><div id="container">'."\n"
+ . '<div class="info">'.htmlspecialchars($this->channel).', seriously.<br><br>'
+ . number_format($dayslogged).' day'.($dayslogged > 1 ? 's logged from '.date('M j, Y', strtotime($date_first)).' to '.date('M j, Y', strtotime($date_last)) : ' logged on '.date('M j, Y', strtotime($date_first))).'.<br><br>'
+ . 'Logs contain '.number_format($this->l_total).' line'.($this->l_total > 1 ? 's' : '').' &ndash; an average of '.number_format($l_avg).' line'.($l_avg > 1 ? 's' : '').' per day.<br>'
+ . 'Most active day was '.date('M j, Y', strtotime($date_max)).' with a total of '.number_format($l_max).' line'.($l_max > 1 ? 's' : '').' typed.'.($this->addhtml_head != '' ? '<br><br>'.trim(file_get_contents($this->addhtml_head)) : '').'</div>'."\n";
/**
* Activity section.
@@ -623,8 +623,6 @@ public function make_html($sqlite3)
}
if (!empty($result)) {
- arsort($result);
- array_splice($result, 9);
$smileys = array(
's_01' => array(':)', 'Happy'),
's_02' => array(';)', 'Wink'),
@@ -676,6 +674,8 @@ public function make_html($sqlite3)
's_48' => array(':[', 'Sad'),
's_49' => array('>:(', 'Angry'),
's_50' => array(';o', 'Joking'));
+ arsort($result);
+ array_splice($result, 9);
foreach ($result as $key => $value) {
$t = new table($smileys[$key][1], $this->minrows, $this->maxrows);
@@ -833,26 +833,26 @@ private function make_table_activity($sqlite3, $type)
if ($type == 'day') {
$class = 'act';
$columns = 24;
+ $head = 'Activity by Day';
+ $query = $sqlite3->query('SELECT date, l_total, l_night, l_morning, l_afternoon, l_evening FROM channel_activity WHERE date > \''.date('Y-m-d', mktime(0, 0, 0, $this->datetime['month'], $this->datetime['dayofmonth'] - 24, $this->datetime['year'])).'\'') or $this->output('critical', basename(__FILE__).':'.__LINE__.', sqlite3 says: '.$sqlite3->lastErrorMsg());
for ($i = $columns - 1; $i >= 0; $i--) {
$dates[] = date('Y-m-d', mktime(0, 0, 0, $this->datetime['month'], $this->datetime['dayofmonth'] - $i, $this->datetime['year']));
}
-
- $head = 'Activity by Day';
- $query = $sqlite3->query('SELECT date, l_total, l_night, l_morning, l_afternoon, l_evening FROM channel_activity WHERE date > \''.date('Y-m-d', mktime(0, 0, 0, $this->datetime['month'], $this->datetime['dayofmonth'] - 24, $this->datetime['year'])).'\'') or $this->output('critical', basename(__FILE__).':'.__LINE__.', sqlite3 says: '.$sqlite3->lastErrorMsg());
} elseif ($type == 'month') {
$class = 'act';
$columns = 24;
+ $head = 'Activity by Month';
+ $query = $sqlite3->query('SELECT SUBSTR(date, 1, 7) AS date, SUM(l_total) AS l_total, SUM(l_night) AS l_night, SUM(l_morning) AS l_morning, SUM(l_afternoon) AS l_afternoon, SUM(l_evening) AS l_evening FROM channel_activity WHERE date > \''.date('Y-m', mktime(0, 0, 0, $this->datetime['month'] - 24, 1, $this->datetime['year'])).'%\' GROUP BY SUBSTR(date, 1, 7)') or $this->output('critical', basename(__FILE__).':'.__LINE__.', sqlite3 says: '.$sqlite3->lastErrorMsg());
for ($i = $columns - 1; $i >= 0; $i--) {
$dates[] = date('Y-m', mktime(0, 0, 0, $this->datetime['month'] - $i, 1, $this->datetime['year']));
}
-
- $head = 'Activity by Month';
- $query = $sqlite3->query('SELECT SUBSTR(date, 1, 7) AS date, SUM(l_total) AS l_total, SUM(l_night) AS l_night, SUM(l_morning) AS l_morning, SUM(l_afternoon) AS l_afternoon, SUM(l_evening) AS l_evening FROM channel_activity WHERE date > \''.date('Y-m', mktime(0, 0, 0, $this->datetime['month'] - 24, 1, $this->datetime['year'])).'%\' GROUP BY SUBSTR(date, 1, 7)') or $this->output('critical', basename(__FILE__).':'.__LINE__.', sqlite3 says: '.$sqlite3->lastErrorMsg());
} elseif ($type == 'year') {
$class = 'act-year';
$columns = $this->datetime['years'];
+ $head = 'Activity by Year';
+ $query = $sqlite3->query('SELECT SUBSTR(date, 1, 4) AS date, SUM(l_total) AS l_total, SUM(l_night) AS l_night, SUM(l_morning) AS l_morning, SUM(l_afternoon) AS l_afternoon, SUM(l_evening) AS l_evening FROM channel_activity GROUP BY SUBSTR(date, 1, 4)') or $this->output('critical', basename(__FILE__).':'.__LINE__.', sqlite3 says: '.$sqlite3->lastErrorMsg());
for ($i = $columns - 1; $i >= 0; $i--) {
$dates[] = $this->datetime['year'] - $i;
@@ -862,9 +862,6 @@ private function make_table_activity($sqlite3, $type)
$columns++;
$dates[] = 'estimate';
}
-
- $head = 'Activity by Year';
- $query = $sqlite3->query('SELECT SUBSTR(date, 1, 4) AS date, SUM(l_total) AS l_total, SUM(l_night) AS l_night, SUM(l_morning) AS l_morning, SUM(l_afternoon) AS l_afternoon, SUM(l_evening) AS l_evening FROM channel_activity GROUP BY SUBSTR(date, 1, 4)') or $this->output('critical', basename(__FILE__).':'.__LINE__.', sqlite3 says: '.$sqlite3->lastErrorMsg());
}
$result = $query->fetchArray(SQLITE3_ASSOC);
@@ -1126,10 +1123,21 @@ private function make_table_people($sqlite3, $type)
return null;
}
+ $rankings = false;
+
if ($type == 'alltime') {
$head = 'Most Talkative People &ndash; Alltime';
$historylink = '<a href="history.php?cid='.urlencode($this->cid).'">History</a>';
- $query = $sqlite3->query('SELECT csnick, l_total, l_night, l_morning, l_afternoon, l_evening, quote, (SELECT MAX(lastseen) FROM uid_details WHERE ruid = ruid_lines.ruid) AS lastseen, (SELECT rank FROM ruid_rankings WHERE ruid = ruid_lines.ruid AND date = \''.date('Y-m', mktime(0, 0, 0, $this->datetime['month'] - 1, 1, $this->datetime['year'])).'\') AS prevrank FROM ruid_lines JOIN uid_details ON ruid_lines.ruid = uid_details.uid WHERE status NOT IN (3,4) AND l_total != 0 ORDER BY l_total DESC, ruid_lines.ruid ASC LIMIT '.$this->maxrows_people_alltime) or $this->output('critical', basename(__FILE__).':'.__LINE__.', sqlite3 says: '.$sqlite3->lastErrorMsg());
+
+ /**
+ * Don't try to calculate changes in rankings if we're dealing with the first month of activity.
+ */
+ if (date('Y-m', mktime(0, 0, 0, $this->datetime['month'], 1, $this->datetime['year'])) == $this->datetime['firstyearmonth']) {
+ $query = $sqlite3->query('SELECT csnick, l_total, l_night, l_morning, l_afternoon, l_evening, quote, (SELECT MAX(lastseen) FROM uid_details WHERE ruid = ruid_lines.ruid) AS lastseen FROM ruid_lines JOIN uid_details ON ruid_lines.ruid = uid_details.uid WHERE status NOT IN (3,4) AND l_total != 0 ORDER BY l_total DESC, ruid_lines.ruid ASC LIMIT '.$this->maxrows_people_alltime) or $this->output('critical', basename(__FILE__).':'.__LINE__.', sqlite3 says: '.$sqlite3->lastErrorMsg());
+ } else {
+ $query = $sqlite3->query('SELECT csnick, l_total, l_night, l_morning, l_afternoon, l_evening, quote, (SELECT MAX(lastseen) FROM uid_details WHERE ruid = ruid_lines.ruid) AS lastseen, (SELECT rank FROM ruid_rankings WHERE ruid = ruid_lines.ruid AND date = \''.date('Y-m', mktime(0, 0, 0, $this->datetime['month'] - 1, 1, $this->datetime['year'])).'\') AS prevrank FROM ruid_lines JOIN uid_details ON ruid_lines.ruid = uid_details.uid WHERE status NOT IN (3,4) AND l_total != 0 ORDER BY l_total DESC, ruid_lines.ruid ASC LIMIT '.$this->maxrows_people_alltime) or $this->output('critical', basename(__FILE__).':'.__LINE__.', sqlite3 says: '.$sqlite3->lastErrorMsg());
+ $rankings = true;
+ }
} elseif ($type == 'month') {
$head = 'Most Talkative People &ndash; '.$this->datetime['monthname'].' '.$this->datetime['year'];
$historylink = '<a href="history.php?cid='.urlencode($this->cid).'&amp;year='.$this->datetime['year'].'&amp;month='.$this->datetime['month'].'">History</a>';
@@ -1181,16 +1189,10 @@ private function make_table_people($sqlite3, $type)
}
}
- if ($type == 'alltime') {
- if (date('Y-m', mktime(0, 0, 0, $this->datetime['month'], 1, $this->datetime['year'])) == $this->datetime['firstyearmonth']) {
- $pos = $i;
- } elseif (is_null($result['prevrank']) || $i < $result['prevrank']) {
- $pos = '<span class="green">&#x25B2;'.$i.'</span>';
- } elseif ($i > $result['prevrank']) {
- $pos = '<span class="red">&#x25BC;'.$i.'</span>';
- } else {
- $pos = $i;
- }
+ if ($rankings && (is_null($result['prevrank']) || $i < $result['prevrank'])) {
+ $pos = '<span class="green">&#x25B2;'.$i.'</span>';
+ } elseif ($rankings && $i > $result['prevrank']) {
+ $pos = '<span class="red">&#x25BC;'.$i.'</span>';
} else {
$pos = $i;
}
View
@@ -26,10 +26,6 @@
* all appear in $settings_list[] along with their type.
*/
private $rankings = false;
-
- /**
- * Variables that shouldn't be tampered with.
- */
private $settings_list = array(
'outputbits' => 'int',
'rankings' => 'bool');
@@ -59,7 +55,7 @@ public function __construct($settings)
}
/**
- * Calculate on which dates a user reached certain milestones.
+ * Calculate on which date a user reached certain milestone.
*/
public function calculate_milestones($sqlite3)
{
@@ -126,8 +122,8 @@ public function calculate_rankings($sqlite3)
return null;
}
- $query->reset();
$channel_activity_by_month = array_fill_keys($scope, 0);
+ $query->reset();
$ruid_activity_by_month = array();
while ($result = $query->fetchArray(SQLITE3_ASSOC)) {
@@ -178,8 +174,8 @@ public function calculate_rankings($sqlite3)
$rank = 1;
}
- $sqlite3->exec('INSERT INTO ruid_rankings (ruid, date, rank, l_total, percentage) VALUES ('.$values['ruid'].', \''.$values['date'].'\', '.$rank.', '.$values['l_total'].', '.round(($values['l_total'] / $channel_activity_by_month_cumulative[$values['date']]) * 100, 2).')') or $this->output('critical', basename(__FILE__).':'.__LINE__.', sqlite3 says: '.$sqlite3->lastErrorMsg());
$prevdate = $values['date'];
+ $sqlite3->exec('INSERT INTO ruid_rankings (ruid, date, rank, l_total, percentage) VALUES ('.$values['ruid'].', \''.$values['date'].'\', '.$rank.', '.$values['l_total'].', '.round(($values['l_total'] / $channel_activity_by_month_cumulative[$values['date']]) * 100, 2).')') or $this->output('critical', basename(__FILE__).':'.__LINE__.', sqlite3 says: '.$sqlite3->lastErrorMsg());
$rank++;
}
}
Oops, something went wrong.

0 comments on commit dc0f207

Please sign in to comment.