Removes fixed statistics files
This commit is contained in:
parent
cd91ab68cf
commit
8abf97334b
@ -1,141 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* edit entry panel
|
||||
*
|
||||
* Type:
|
||||
* Name:
|
||||
* Date:
|
||||
* Purpose:
|
||||
* Input:
|
||||
*
|
||||
* @author NoWhereMan <real_nowhereman at users dot sf dot com>
|
||||
*
|
||||
*/
|
||||
|
||||
class admin_entry_stats extends AdminPanelAction {
|
||||
|
||||
function format_number($num, $sep) {
|
||||
$ss = $sep * $sep;
|
||||
$i = 0;
|
||||
while ( $num > $ss ) {
|
||||
$num = (float) $num / $sep;
|
||||
$i++;
|
||||
}
|
||||
|
||||
return array(number_format((int)$num), $i);
|
||||
|
||||
}
|
||||
|
||||
function setup() {
|
||||
global $lang;
|
||||
$lang ['admin'] ['entry'] ['stats'] = array();
|
||||
}
|
||||
|
||||
function main() {
|
||||
|
||||
global $fpdb;
|
||||
|
||||
$fpdb->query(array(
|
||||
'count' => -1, // show all
|
||||
'fullparse' => true
|
||||
));
|
||||
|
||||
$q = $fpdb->getQuery();
|
||||
|
||||
$comments =
|
||||
$entries = array(
|
||||
'count' => 0,
|
||||
'words' => 0,
|
||||
'chars' => 0,
|
||||
'size' => 0,
|
||||
'topten' => array()
|
||||
);
|
||||
|
||||
$entries ['comments'] = 0;
|
||||
|
||||
$toplist = array();
|
||||
|
||||
while ($q->hasMore()) {
|
||||
|
||||
list($id, $e) = $q->getEntry();
|
||||
|
||||
$entries ['count'] ++;
|
||||
$entries ['words'] += str_word_count($e ['subject']) + str_word_count($e ['content']);
|
||||
|
||||
$entries ['chars'] += strlen($e ['subject']) + strlen($e ['content']);
|
||||
|
||||
$entries ['size'] += filesize(entry_exists($id));
|
||||
|
||||
$cc = $q->hasComments();
|
||||
$entries ['comments'] += $cc;
|
||||
$toplist [$id] = $cc;
|
||||
$toplistsubj [$id] = $e ['subject'];
|
||||
|
||||
$comments ['count'] += $cc;
|
||||
|
||||
while ($q->comments->hasMore()) {
|
||||
list($cid, $c) = $q->comments->getComment();
|
||||
$comments ['words'] += str_word_count($c ['content']);
|
||||
$comments ['chars'] += strlen($c ['content']);
|
||||
$comments ['size'] += filesize(comment_exists($id, $cid));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
arsort($toplist);
|
||||
|
||||
$i = 0;
|
||||
foreach($toplist as $k => $v) {
|
||||
if ($i >= 10 || $v < 1)
|
||||
break;
|
||||
|
||||
$entries ['topten'] [$k] = array(
|
||||
'subject' => $toplistsubj [$k],
|
||||
'comments' => $v
|
||||
);
|
||||
$i++;
|
||||
}
|
||||
|
||||
$decunit = array('', 'Thousand', 'Million', 'Billion', 'Trillion', 'Zillion', 'Gazillion');
|
||||
$binunit = array('Bytes', 'KiloBytes', 'MegaBytes', 'GigaBytes', 'TeraBytes', 'Many', 'ManyBytes');
|
||||
|
||||
|
||||
list($count, $approx) = $this->format_number($entries ['count'], 1000);
|
||||
$entries ['count'] = $count . ' ' . $decunit [$approx];
|
||||
|
||||
list($count, $approx) = $this->format_number($entries ['words'], 1000);
|
||||
$entries ['words'] = $count . ' ' . $decunit [$approx];
|
||||
|
||||
list($count, $approx) = $this->format_number($entries ['chars'], 1000);
|
||||
$entries ['chars'] = $count . ' ' . $decunit [$approx];
|
||||
|
||||
list($count, $approx) = $this->format_number($entries ['comments'], 1000);
|
||||
$entries ['comments'] = $count . ' ' . $decunit [$approx];
|
||||
|
||||
list($count, $approx) = $this->format_number($entries ['size'], 1024);
|
||||
$entries ['size'] = $count . ' ' . $binunit [$approx];
|
||||
|
||||
|
||||
$this->smarty->assign('entries', $entries);
|
||||
|
||||
|
||||
|
||||
list($count, $approx) = $this->format_number($comments ['count'], 1000);
|
||||
$comments ['count'] = $count . ' ' . $decunit [$approx];
|
||||
|
||||
list($count, $approx) = $this->format_number($comments ['words'], 1000);
|
||||
$comments ['words'] = $count . ' ' . $decunit [$approx];
|
||||
|
||||
list($count, $approx) = $this->format_number($comments ['chars'], 1000);
|
||||
$comments ['chars'] = $count . ' ' . $decunit [$approx];
|
||||
|
||||
list($count, $approx) = $this->format_number($comments ['size'], 1024);
|
||||
$comments ['size'] = $count . ' ' . $binunit [$approx];
|
||||
|
||||
|
||||
$this->smarty->assign('comments', $comments);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
<h2>{$panelstrings.head}</h2>
|
||||
|
||||
{include file="shared:errorlist.tpl"}
|
||||
|
||||
<h3>{$panelstrings.entries}</h3>
|
||||
<p>{$panelstrings.you_have} <strong>{"%s"|sprintf:$entries.count}</strong>
|
||||
{$panelstrings.entries_using} <strong>{"%s"|sprintf:$entries.chars}</strong> {$panelstrings.characters_in} <strong>{"%s"|sprintf:$entries.words}</strong> {$panelstrings.words}.</p>
|
||||
<p>{$panelstrings.total_disk_space_is} <strong>{"%s"|sprintf:$entries.size}</strong>.</p>
|
||||
|
||||
<h3>{$panelstrings.comments}</h3>
|
||||
<p>{$panelstrings.you_have} <strong>{"%s"|sprintf:$comments.count}</strong>
|
||||
{$panelstrings.comments_using} <strong>{"%s"|sprintf:$comments.chars}</strong> {$panelstrings.characters_in} <strong>{"%s"|sprintf:$comments.words}</strong> {$panelstrings.words}.</p>
|
||||
<p>{$panelstrings.total_disk_space_is} <strong>{"%s"|sprintf:$comments.size}</strong>.</p>
|
||||
|
||||
|
||||
{if $entries.topten}
|
||||
|
||||
<h3>{$panelstrings.the} {$entries.topten|@count} {$panelstrings.most_commented_entries} </h3>
|
||||
|
||||
<ol>
|
||||
{foreach from=$entries.topten key=id item=this_entry}
|
||||
<li><a href="{$panel_url|action_link:commentlist}&entry={$id}">{$this_entry.subject}</a> ({$this_entry.comments})</li>
|
||||
{/foreach}
|
||||
</ol>
|
||||
|
||||
{/if}
|
||||
|
Loading…
x
Reference in New Issue
Block a user