Файл: system/classes/Stat.php
Строк: 138
<?php
/**
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) 2013-2014, Taras Chornyi, Sergiy Mazurenko, Ivan Kotliar
* @link http://perf-engine.net
* @package PerfEngine
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
class Stat
{
public function __construct() {}
public static function last_news()
{
global $db;
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'].'/">'._t('read_more').'</a><br/>';
}
else
{
echo output($last_news['text']).'<br/>';
}
echo '</div><div class="block"><a href="/news/comments/'.$last_news['id'].'">'. _t('comments') .'</a> ('.$db->query("SELECT * FROM `news_comms` WHERE `news_id` = '". $last_news['id'] ."'")->rowCount().')<br/>
</div>';
}
}
}
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, $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 static function online()
{
global $db;
$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 _t('online') .": ". $on_a ." (<a href="/user/online/">".$on_u."</a>/<a href="/pages/guests/">".$on_g."</a>)n";
}
// PLEASE NOT DELETE //
public static function footer()
{
global $system;
// PLEASE NOT DELETE //
return '<a class="foot" href="http://perf-engine.net">'.$system['copyright'].'</a>';
}
//\ PLEASE NOT DELETE //\
public static function adsHeader()
{
global $db;
$ah_r = $db->query("SELECT * FROM `ads` WHERE `type` = '1'")->rowCount();
if($ah_r != 0)
{
echo '<div class="ads">';
$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 static function adsFooter()
{
global $db;
$af_r = $db->query("SELECT * FROM `ads` WHERE `type` = '2'")->rowCount();
if($af_r != 0)
{
echo '<div class="ads">';
$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";
}
echo '</div>';
}
self::adsBanners();
echo self::footer();
}
public static function adsBanners()
{
global $db;
$ab_r = $db->query("SELECT * FROM `ads` WHERE `type` = '3'")->rowCount();
if($ab_r != 0)
{
echo '<div class="ads" style="text-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 static function set_block()
{
global $lng;
return '<a href="'.(!User::logged() ? '/user/guest_lang/?return='.$_SERVER['REQUEST_URI'].'' : '/user/settings/').'">'._t('lang_name').'</a><span style="float:right;">'.(Core::TypeTheme() == 'wap' ? '<b>WAP</b> | <a href="/user/type_theme/?return='.$_SERVER['REQUEST_URI'].'">web</a>' : '<a href="/user/type_theme/?return='.$_SERVER['REQUEST_URI'].'">wap</a> | <b>WEB</b>').'</span>';
}
}