Файл: system/classes/stat.php
Строк: 188
<?php
/**********************************
* @package: PerfCMS *
* @year: 2012 *
* @author: Artas *
* @link: http://perfcms.net *
**********************************/
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']) > 500) {
echo mb_substr(output($last_news['text']), 0, 500).'... <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 mini_chat() {
global $db;
$mini_chat = $db->query("SELECT * FROM `mini_chat`")->rowCount();
$mini_chat_new_posts = $db->query("SELECT * FROM `mini_chat` WHERE `time` > '". (time()-60*60*24) ."'")->rowCount();
return '['.$mini_chat.'] '.($mini_chat_new_posts > 0 ? ' <span class="green">+'.$mini_chat_new_posts.'</span>' : NULL);
}
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 library() {
global $db;
$new_notes = $db->query("SELECT * FROM `library` WHERE `time` > '". (time()-60*60*24) ."'")->rowCount();
$notes = $db->query("SELECT * FROM `library`")->rowCount();
return '['.$notes.']'.($new_notes > 0 ? ' <span class="green">+'.$new_notes.'</span>' : 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;
$new_mail = $db->query("SELECT * FROM `mail` WHERE `who_id` = '". $user['id'] ."' AND `read` = '0'")->rowCount();
return "".($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') .": [ <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><a href="http://perfclub.ru">© '.$system['copyright'].'</a></small>';
}
// PLEASE NOT DELETE //
public function adsHeader()
{
global $db;
$ah_r = $db->query("SELECT * FROM `ads` WHERE `type` = '1'")->rowCount();
if($ah_r != 0)
{
echo '<div class="block">';
$ah_q = $db->query("SELECT * FROM `ads` WHERE `type` = '1'");
while($ah = $ah_q->fetch())
{
echo "<a href="".($ah['redirect'] == 1 ? '/pages/redirect?url=' : NULL) ."". $ah['link'] ."">". output($ah['name']) ."</a><br/>n";
}
echo '</div>';
}
}
public function adsFooter()
{
global $db;
$af_r = $db->query("SELECT * FROM `ads` WHERE `type` = '2'")->rowCount();
if($af_r != 0)
{
echo '<div class="block">';
$af_q = $db->query("SELECT * FROM `ads` WHERE `type` = '2'");
while($af = $af_q->fetch())
{
echo "<a href="".($af['redirect'] == 1 ? '/pages/redirect?url=' : NULL) ."". $af['link'] ."">". output($af['name']) ."</a><br/>n";
}
$this->adsBanners();
echo '</div>';
}
}
public function adsBanners()
{
global $db;
$ab_r = $db->query("SELECT * FROM `ads` WHERE `type` = '3'")->rowCount();
if($ab_r != 0)
{
echo '<div align="center">';
$ab_q = $db->query("SELECT * FROM `ads` WHERE `type` = '3'");
while($ab = $ab_q->fetch())
{
echo "<a href="".($ab['redirect'] == 1 ? '/pages/redirect?url=' : NULL) ."". $ab['link'] .""><img src="". $ab['image'] ."" alt="". $ab['name'] .""/></a>n";
}
echo '</div>';
}
}
public function downloads()
{
global $db;
$new_files = $db->query("SELECT * FROM `downloads_files` WHERE `time` > '". (time()-60*60*24) ."'")->rowCount();
$files = $db->query("SELECT * FROM `downloads_files`")->rowCount();
return '['.$files.']'.($new_files > 0 ? ' <a href="/downloads/new_files/"><span class="green">+'.$new_files.'</span></a>' : NULL);
}
}