File size: 5.05Kb
<?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;
$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') .": ". $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">'.$system['copyright'].'</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 $db;
if($type == 'header') {
$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>';
}
} elseif($type == 'footer') {
$af_r = $db->query("SELECT * FROM `ads` WHERE `type` = '2'")->rowCount();
if($af_r != 0) {
if($af_r != 0) {
$af_q = $db->query("SELECT * FROM `ads` WHERE `type` = '2'");
while($af = $af_q->fetch()) {
return "<a href=\"".($af['redirect'] == 1 ? '/pages/redirect?url=' : NULL) ."". $af['link'] ."\">". output($af['name']) ."</a><br/>\n";
}
}
}
} elseif($type='banner') {
$ab_r = $db->query("SELECT * FROM `ads` WHERE `type` = '3'")->rowCount();
if($ab_r != 0) {
$ab_q = $db->query("SELECT * FROM `ads` WHERE `type` = '3'");
while($ab = $ab_q->fetch()) {
return "<a href=\"".($ab['redirect'] == 1 ? '/pages/redirect?url=' : NULL) ."". $ab['link'] ."\"><img src=\"". $ab['image'] ."\" alt=\"". $ab['name'] ."\"/></a><br/>\n";
}
}
}
}
}