<?
require_once('db.class.php');

///Комменты новостей
$news = DB :: $dbs -> queryFetch ("SELECT * FROM `news` ORDER BY `id` DESC LIMIT 1");
$sql = DB::$dbs->query("SELECT * FROM news ORDER BY time DESC LIMIT 1");
while($a = $sql->fetch()) {
$news_comm = DB::$dbs->querySingle("SELECT COUNT(*) FROM news_comm WHERE id_news = ?", [$a['id']]);
}
///Админ форум
$adm_topic = DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `adm_topic`");
$adm_mess = DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `adm_mess`");
$adm_topic_new = DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `adm_topic` WHERE `time`>'" . (time () - 86400) . "'");
$adm_mess_new = DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `adm_mess` WHERE `time`>'" . (time () - 86400) . "'");
//Форум
$forum_topic = DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `forum_topic`");
$forum_topic_new =  DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `forum_topic` WHERE `time`>'" . (time () - 86400) . "'");
$forum_mess = DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `forum_mess`");
$forum_mess_new = DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `forum_mess` WHERE `time`>'" . (time () - 86400) . "'");
//Загрузки
$downs = DB::$dbs -> querySingle ("SELECT COUNT(*) FROM `downs` WHERE `mod` = ?",[0]); 
$downs_new =  DB::$dbs->querySingle ("SELECT COUNT(*) FROM `downs` WHERE `time`> ? AND `mod` = ?", [time()-86400,0]);
///Мазагин
$magazin_file = DB::$dbs -> querySingle ("SELECT COUNT(*) FROM `magazin_file`");
$magazin_file_new = DB::$dbs->querySingle ("SELECT COUNT(*) FROM `magazin_file` WHERE `time`> ?", [time()-86400]); 

//Хуйня всякая
///Гости
$guest_new = DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `guest` WHERE `time`>'" . (time () - 86400) . "'");
$guest = DB::$dbs -> querySingle("SELECT COUNT(*) FROM `guest`");

///Фазаилы
$ked_new = DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `ked` WHERE `time`>'" . (time () - 86400) . "'");
$ked = DB::$dbs -> querySingle("SELECT COUNT(*) FROM `ked`");

///Пиздешь всякий
$otzyvy_new = DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `otzyvy` WHERE `time`>'" . (time () - 86400) . "'");
$otzyvy = DB::$dbs -> querySingle("SELECT COUNT(*) FROM `otzyvy`");

///Лента
$lenta_new = DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `lenta` WHERE `time`>'" . (time () - 86400) . "'");
$lenta = DB::$dbs -> querySingle("SELECT COUNT(*) FROM `lenta`");

//Газета
$gazeta_article = DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `gazeta_article`");
$gazeta_article_new =  DB::$dbs->querySingle ("SELECT COUNT(*) FROM `gazeta_article` WHERE `time`> ?", [time()-86400]); 

//Букавки какиеты
$codes_code = DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `codes_code`");
$codes_code_new = DB::$dbs->querySingle ("SELECT COUNT(*) FROM `codes_code` WHERE `time`> ?", [time()-86400]); 

///Тут можно подрочить 
$album_foto = DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `album_foto`");
$album_comm = DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `album_comm`");

$blogger = DB::$dbs->querySingle("SELECT count(id) FROM `blogger` WHERE `last` > ?", [time()-3600]);
$guests = DB::$dbs->querySingle("SELECT count(*) FROM `guests` WHERE `date` > ?", [time()-3600]);

DB::$dbs->query("UPDATE `counts` SET `news_comm` = '".$news_comm."',
									`adm_topic` = '".$adm_topic."',
									`adm_mess` = '".$adm_mess."',
									`adm_topic_new` = '".$adm_topic_new."',
									`adm_mess_new` = '".$adm_mess_new."',
									`forum_topic` = '".$forum_topic."',
									`forum_topic_new` = '".$forum_topic_new."',
									`forum_mess` = '".$forum_mess."',
									`forum_mess_new` = '".$forum_mess_new."',
									`downs` = '".$downs."',
									`downs_new` = '".$downs_new."',
									`magazin_file` = '".$magazin_file."',
									`magazin_file_new` = '".$magazin_file_new."',
									`guest` = '".$guest."',
									`guest_new` = '".$guest_new."',
									`ked` = '".$ked."',
									`ked_new` = '".$ked_new."',							
									`otzyvy` = '".$otzyvy."',
									`otzyvy_new` = '".$otzyvy_new."',
									`lenta` = '".$lenta."',
									`lenta_new` = '".$lenta_new."',									
									`gazeta_article` = '".$gazeta_article."',
									`gazeta_article_new` = '".$gazeta_article_new."',
									`codes_code` = '".$codes_code."',
									`codes_code_new` = '".$codes_code_new."',										
									`album_foto` = '".$album_foto."',
									`album_comm` = '".$album_comm."',
									`blogger` = '".$blogger."',
									`guests` = '".$guests."' WHERE `id` = ?", [1]);
?>