Размер файла: 4.31Kb
<?php
/**********************************
* @package: PerfCMS *
* @year: 2012 *
* @author: Artas *
* @link: http://perfcms.ru *
**********************************/
class Stat {
public function __construct() {}
public function last_news() {
global $db;
global $lang;
if($db->query("SELECT * FROM `news`")->rowCount() != 0) {
$last_news_q = $db->query("SELECT * FROM `news` ORDER BY time DESC LIMIT 1");
while($last_news = $last_news_q->fetch()) {
echo '<div class="post"><b>'. $last_news['name'].'</b> ('. rtime($last_news['time']) .')<br/>';
if(mb_strlen($last_news['text']) > 300) {
echo mb_substr(output($last_news['text']), 0, 300).'... <a href="/news/article/'.$last_news['id'].'/">'.$lang->word('read_more').'</a><br/>';
}
else {
echo output($last_news['text']).'<br/>';
}
echo '</div><div class="block"><a href="/news/'.$last_news['id'].'/comments/">'. $lang->word('comments') .'</a> ('.$db->query("SELECT * FROM `news_comms` WHERE `news_id` = '". $last_news['id'] ."'")->rowCount().')<br/>
</div>';
}
}
}
public function news() {
global $db;
$all_news = $db->query("SELECT * FROM `news`")->rowCount();
return '('.$all_news.')';
}
public function chat() {
global $db;
$user_chat = $db->query("SELECT * FROM `users` WHERE `time` > '". (time()-300) ."' AND `locate` = 'in_chat'")->rowCount();
return '(<span class="green">On: '.$user_chat.'</span>)';
}
public function forum() {
global $db;
$topics = $db->query("SELECT * FROM `forum_t`")->rowCount();
$posts = $db->query("SELECT * FROM `forum_pt`")->rowCount();
$new_posts = $db->query("SELECT * FROM `forum_pt` WHERE `time` > '". (time()-60*60*24) ."'")->rowCount();
return "(".$topics."/".$posts.")".($new_posts > 0 ? ' <a href="/forum/new_posts/"><span class="green">+'.$new_posts.'</span></a>' : NULL);
}
public function share() {
global $db;
$new_files = $db->query("SELECT * FROM `share_files` WHERE `time` > '". (time()-60*60*24) ."'")->rowCount();
$files = $db->query("SELECT * FROM `share_files`")->rowCount();
return '('.$files.')'.($new_files > 0 ? ' <a href="/share/new_files/"><span class="green">+'.$new_files.'</span></a>' : NULL);
}
public function users() {
global $db;
$users = $db->query("SELECT * FROM `users`")->rowCount();
$new_users = $db->query("SELECT * FROM `users` WHERE `reg_time` > '".(time()-60*60*24)."'")->rowCount();
return "(".$users."".($new_users>0 ? "/<span class=\"green\">+".$new_users."</span>" : NULL).")";
}
public function mail() {
global $db;
global $user;
$mail = $db->query("SELECT * FROM `mail` WHERE `who_id` = '". $user['id'] ."'")->rowCount();
$new_mail = $db->query("SELECT * FROM `mail` WHERE `who_id` = '". $user['id'] ."' AND `read` = '0'")->rowCount();
return $mail."".($new_mail>0 ? "/<span class=\"green\">+".$new_mail."</span>" : NULL)."";
}
public function online() {
global $db;
global $lang;
$on_u = $db->query("SELECT * FROM `users` WHERE `time` > '". (time()-300) ."'")->rowCount();
$on_g = $db->query("SELECT * FROM `guests` WHERE `time` > '". (time()-300) ."'")->rowCount();
$on_a = $on_u + $on_g;
return "". $lang->word('online') .": ". $on_a ." (<a href=\"/online/\">".$on_u."</a>/<a href=\"/guests/\">".$on_g."</a>)\n";
}
// PLEASE NOT DELETE //
public function footer() {
global $theme;
global $system;
// PLEASE NOT DELETE //
return '<small><div style="float: left; padding: 2px;"><a href="http://perfcms.ru">PerfCMS</a>, '. date('Y') .'</div>'.''.(!empty($theme['author']) ? '<div style="text-align: right; padding: 2px;">Design by '.(!empty($theme['link']) && !empty($theme['author']) ? '<a href="'. $theme['link'] .'">'. $theme['author'] .'</a>' : $theme['author']). '</div></small>' : NULL).'';
}
// PLEASE NOT DELETE //
public function ads($type='header') {
global $system;
if($type == 'header' && !empty($system['ads_header'])) {
return "<div class=\"block\">".$system['ads_header']."</div>";
} elseif($type == 'footer' && (!empty($system['ads_footer']) || !empty($system['ads_banners']))) {
return '<div class="block">'.(!empty($system['ads_footer']) ? $system['ads_footer'] : NULL).'
'.(!empty($system['ads_banners']) ? '<center>'.$system['ads_banners'].'</center>' : NULL).'</div>'."\n";
}
}
}