#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
global $db;
global $_USER;
if (!$PARAMS) {
define('TITLE', __('Tags statistics'));
echo '
';
echo '';
$query = $db->send("SELECT `tag`, COUNT(`id`) FROM tags_n WHERE (UNIX_TIMESTAMP() - `timestamp`) < 604800 GROUP BY `tag` ORDER BY COUNT(`id`) DESC LIMIT 5");
echo '
| '.__('Name').' | '.__('Number of posts').' |
';
while ($row = mysql_fetch_row($query)) {
echo '| #'.$row[0].' | '.$row[1].' |
';
}
echo '
';
echo '';
$query = $db->send("SELECT `tag`, COUNT(`id`) FROM tags_n WHERE (UNIX_TIMESTAMP() - `timestamp`) < 86400 GROUP BY `tag` ORDER BY COUNT(`id`) DESC LIMIT 5");
echo '
| '.__('Name').' | '.__('Number of posts').' |
';
while ($row = mysql_fetch_row($query)) {
echo '| #'.$row[0].' | '.$row[1].' |
';
}
echo '
';
echo '';
$query = $db->send("SELECT `tag`, COUNT(`id`) FROM tags_n GROUP BY `tag` ORDER BY COUNT(`id`) DESC LIMIT 5");
echo '
| '.__('Name').' | '.__('Number of posts').' |
';
while ($row = mysql_fetch_row($query)) {
echo '| #'.$row[0].' | '.$row[1].' |
';
}
echo '
';
echo '';
$query = $db->send("SELECT `tag`, COUNT(`id`) FROM tags_n WHERE (UNIX_TIMESTAMP() - `timestamp`) < 18144000 GROUP BY `tag` ORDER BY COUNT(`id`) DESC LIMIT 5");
echo '
| '.__('Name').' | '.__('Number of posts').' |
';
while ($row = mysql_fetch_row($query)) {
echo '| #'.$row[0].' | '.$row[1].' |
';
}
echo '
';
echo '';
$query = $db->send("SELECT t2.tag, t1.name, (UNIX_TIMESTAMP() - t1.timestamp) as `timestamp`, COUNT(t2.id) as `count`, ROUND((COUNT(t2.id)/(UNIX_TIMESTAMP() - t1.timestamp))*60, 2) as `calc` FROM `tags_c` AS t1, `tags_n` AS t2 WHERE t1.name = t2.tag GROUP BY t2.tag ORDER BY `calc` DESC LIMIT 5");
echo '
| '.__('Name').' | '.__('Writing rate').' | '.__('Number of posts').' |
';
while ($row = mysql_fetch_row($query)) {
echo '| #'.$row[0].' | '.$row[4].' | '.$row[3].' |
';
}
echo '
';
echo '';
$query = $db->send("SELECT founder, name, COUNT(name) FROM tags_c GROUP BY founder ORDER BY COUNT(name) DESC LIMIT 5");
echo '
| '.__('Nickname').' | '.__('Created tags').' |
';
while ($row = mysql_fetch_row($query)) {
$nickname = $db->getUserInfo($row[0]);
echo '| @'.$nickname['username'].' | '.$row[2].' |
';
}
echo '
';
echo '
';
}
else {
if (strlen($PARAMS) > 20) header('Location: '.BASE.'home');
else {
$PARAMS = utf8_htmlentities(mysql_escape_string($PARAMS));
define('TITLE', __('Tag').' #'.$PARAMS);
echo '';
echo '';
if (!$db->checkTag($PARAMS)) echo showStatus(__("There are no notes with this tag."), 'warning');
else {
if (isset($_GET['p'])) $start = getStart($_GET['p']); else $start = getStart(1);
$result = $db->getNotes('tag', $start, NOTES_PER_PAGE, $PARAMS);
$count = $db->countNotes('tag', $PARAMS);
foreach ($result as $note) showNote($note, false, false, true);
echo getPaginationString($PARAMS, $count, $_GET['p'], NOTES_PER_PAGE, 1, '?p=');
}
echo '
';
}
}
?>