<?php
function stats_site() {
global $config;
if (@filemtime(FLEVEL.'local/temp/site.dat') < time()-$config['cache_counters']) {
$book = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `book`"), 0);
$forum_topics = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `forum_topics`"), 0);
$forum_msg = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `forum_msg`"), 0);
$news = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `news`"), 0);
$news_comm = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `news_comm`"), 0);
$loads_comm = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `loads_comm`"), 0);
$photos = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `photos`"), 0);
$photos_comm = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `photos_comm`"), 0);
$put = 'Сообщений в гостевой: '.$book.'<br />
Тем в форуме: '.$forum_topics.'<br />
Сообщений в форуме: '.$forum_msg.'<br />
Всего новостей: '.$news.'<br />
Комментариев в новостях: '.$news_comm.'<br />
Комментариев в загрузках: '.$loads_comm.'<br />
Фото в галерее: '.$photos.'<br />
Комментариев в галерее: '.$photos_comm.'<br />
Зарегистрированных: '.stats_users();
file_put_contents(FLEVEL.'local/temp/site.dat', $put, LOCK_EX);
}
return file_get_contents(FLEVEL.'local/temp/site.dat');
}
function stats_newcomers() {
global $config;
if (@filemtime(FLEVEL.'local/temp/newcomers.dat') < time()-$config['cache_counters']) {
$put = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `users` WHERE `regtime` > '".(time()-86400 * 3)."'"), 0);
file_put_contents(FLEVEL.'local/temp/newcomers.dat', $put, LOCK_EX);
}
return file_get_contents(FLEVEL.'local/temp/newcomers.dat');
}
function stats_chat() {
global $config;
if (@filemtime(FLEVEL.'local/temp/chat.dat') < time()-$config['cache_counters']) {
$total = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `chat`"), 0);
$total_new = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `chat` WHERE `time` > '".(time()-86400)."'"), 0);
$new = '';
if ($total_new > 0) {
$new = '<span style="color:green">+'.$total_new.'</span>';
}
$put = $total.' '.$new;
file_put_contents(FLEVEL.'local/temp/chat.dat', $put, LOCK_EX);
}
return file_get_contents(FLEVEL.'local/temp/chat.dat');
}
function stats_online() {
global $config;
if (@filemtime(FLEVEL.'local/temp/online.dat') < TIME - $config['cache_counters']) {
$query_us = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `online` WHERE `id_user` > 0"), 0);
$query_all = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `online`"), 0);
$put = $query_us.'/'.$query_all;
file_put_contents(FLEVEL.'local/temp/online.dat', $put, LOCK_EX);
}
return file_get_contents(FLEVEL.'local/temp/online.dat');
}
function stats_book() {
global $config;
if (@filemtime(FLEVEL.'local/temp/book.dat') < time()-$config['cache_counters']) {
$total = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `book`"), 0);
$total_new = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `book` WHERE `time` > '".(time()-86400)."'"), 0);
$new = '';
if ($total_new > 0) {
$new = '<span style="color:green">+'.$total_new.'</span>';
}
$put = $total.' '.$new;
file_put_contents(FLEVEL.'local/temp/book.dat', $put, LOCK_EX);
}
return file_get_contents(FLEVEL.'local/temp/book.dat');
}
function stats_blog() {
global $config;
if (@filemtime(FLEVEL.'local/temp/blogs.dat') < time()-$config['cache_counters']) {
$total = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `blogs`"), 0);
$total_new = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `blogs` WHERE `time` > '".(time()-86400)."'"), 0);
$new = '';
if ($total_new > 0) {
$new = '<span style="color:green">+'.$total_new.'</span>';
}
$put = $total.' '.$new;
file_put_contents(FLEVEL.'local/temp/blogs.dat', $put, LOCK_EX);
}
return file_get_contents(FLEVEL.'local/temp/blogs.dat');
}
function stats_photos() {
global $config;
if (@filemtime(FLEVEL.'local/temp/photos.dat') < time()-$config['cache_counters']) {
$total = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `photos`"), 0);
$total_new = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `photos` WHERE `time` > '".(time()-86400)."'"), 0);
$new = '';
if ($total_new > 0) {
$new = '<span style="color:green">+'.$total_new.'</span>';
}
$put = $total.' '.$new;
file_put_contents(FLEVEL.'local/temp/photos.dat', $put, LOCK_EX);
}
return file_get_contents(FLEVEL.'local/temp/photos.dat');
}
function stats_forum() {
global $config;
if (@filemtime(FLEVEL.'local/temp/forum.dat') < time()-$config['cache_counters']) {
$forum_topics = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `forum_topics`"), 0);
$forum_msg = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `forum_msg`"), 0);
$forum_msg_new = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `forum_msg` WHERE `time` > '".(time()-86400)."'"), 0);
$new = '';
if ($forum_msg_new > 0) {
$new = '<span style="color:green">+'.$forum_msg_new.'</span>';
}
$put = '('.$forum_topics.'/'.$forum_msg.') '.$new;
file_put_contents(FLEVEL.'local/temp/forum.dat', $put, LOCK_EX);
}
return file_get_contents(FLEVEL.'local/temp/forum.dat');
}
function stats_loads() {
global $config;
if (@filemtime(FLEVEL.'local/temp/loads.dat') < time()-$config['cache_counters']) {
$total = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `loads` WHERE `ok` = 1"), 0);
$total_new = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `loads` WHERE `time` > '".(time()-86400)."' and `ok` = 1"), 0);
$new = '';
if ($total_new > 0) {
$new = '<span style="color:green">+'.$total_new.'</span>';
}
$put = $total.' '.$new;
file_put_contents(FLEVEL.'local/temp/loads.dat', $put, LOCK_EX);
}
return file_get_contents(FLEVEL.'local/temp/loads.dat');
}
function stats_users() {
global $config;
if (@filemtime(FLEVEL.'local/temp/users.dat') < time()-$config['cache_counters']) {
$total = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `users`"), 0);
$total_new = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `users` WHERE `regtime` > '".(time()-86400)."'"), 0);
$new = '';
if ($total_new > 0) {
$new = ' <span style="color:green">+'.$total_new.'</span>';
}
$put = ''.$total.''.$new;
file_put_contents(FLEVEL.'local/temp/users.dat', $put, LOCK_EX);
}
return file_get_contents(FLEVEL.'local/temp/users.dat');
}
function stats_admins() {
global $config;
if (@filemtime(FLEVEL.'local/temp/admins.dat') < time()-$config['cache_counters']) {
$put = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `users` WHERE `access` > 0"), 0);
file_put_contents(FLEVEL.'local/temp/admins.dat', $put, LOCK_EX);
}
return file_get_contents(FLEVEL.'local/temp/admins.dat');
}
function news_index() {
global $config;
if (@filemtime(FLEVEL.'local/temp/news_index.dat') < time()-$config['cache_counters']) {
$news_r = mysql_query("SELECT * FROM `news` ORDER BY `time` DESC LIMIT 1");
$news = mysql_fetch_assoc($news_r);
if (isset($news['id'])) {
mb_internal_encoding('UTF-8');
$comm = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `news_comm` WHERE `id_news` = '$news[id]'"), 0);
$put = '<div class="title"><img src="../images/news.png"> <a href="news">Новости</a></div><div class="text_info"><a href="news/index.php?act=view&id='.$news['id'].'"><b>'.$news['name'].'</b></a>: '.ccdate($news['time'], 0).'<br />'.bb(mb_substr($news['text'], 0, 50)).'...<br /><a href="news/index.php?act=comm&id='.$news['id'].'">Комментарии</a> ('.$comm.')</div>';
}
file_put_contents(FLEVEL.'local/temp/news_index.dat', $put, LOCK_EX);
}
return file_get_contents(FLEVEL.'local/temp/news_index.dat');
}
function ftopics_index() {
global $config;
if (@filemtime(FLEVEL.'local/temp/ftopics_index.dat') < time()-$config['cache_counters']) {
file_put_contents(FLEVEL.'local/temp/ftopics_index.dat', '', LOCK_EX);
$ftopic_r = mysql_query("SELECT * FROM `forum_topics` ORDER BY `last_time` DESC LIMIT 4");
while ($t = mysql_fetch_array($ftopic_r)) {
$t_msg = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `forum_msg` WHERE `id_topic` = '$t[id]'"), 0);
if ($t['stuck']) {
$pic = '<img src="images/forum_tstuck.gif">';
} elseif($t['closed'] == 1 and empty($t['stuck'])) {
$pic = '<img src="images/forum_tclosed.png">';
} else {
$pic = '<img src="images/forum_t.gif">';
}
$put = $pic.' <a href="forum/topic.php?id='.$t['id'].'">'.$t['title'].'</a> ('.$t_msg.') <a href="forum/topic.php?act=end&id='.$t['id'].'">»»</a><br />';
file_put_contents(FLEVEL.'local/temp/ftopics_index.dat', $put, FILE_APPEND | LOCK_EX);
}
}
return file_get_contents(FLEVEL.'local/temp/ftopics_index.dat');
}
?>