View file includes/counters_black.php

File size: 5.73Kb
<?php
#-----------------------------------------------------#
#          ********* ROTORCMS *********               #
#              Made by  :  VANTUZ                     #
#               E-mail  :  [email protected]         #
#                 Site  :  http://pizdec.ru           #
#             WAP-Site  :  http://visavi.net          #
#                  ICQ  :  36-44-66                   #
#  Вы не имеете право вносить изменения в код скрипта #
#        для его дальнейшего распространения          #
#-----------------------------------------------------#
if (!defined('BASEDIR')) {
	header('Location:../index.php');
	exit;
} 

$days = floor((gmmktime(0, 0, 0, date("m"), date("d"), date("Y")) - gmmktime(0, 0, 0, 1, 1, 1970)) / 86400);
$hours = floor((gmmktime(date("H"), 0, 0, date("m"), date("d"), date("Y")) - gmmktime((date("Z") / 3600), 0, 0, 1, 1, 1970)) / 3600);

DB::run() -> query("DELETE FROM `online` WHERE `online_time`<?;", array(SITETIME-600));

$online = stats_online();
if ($online[1] < 150 || is_user()) {
	$newhost = 0;

	if (is_user()) {
		$queryonline = DB::run() -> querySingle("SELECT `online_id` FROM `online` WHERE `online_ip`=? OR `online_user`=? LIMIT 1;", array($ip, $log));
		if (empty($queryonline)) {
			DB::run() -> query("INSERT INTO `online` (`online_ip`, `online_brow`, `online_time`, `online_user`) VALUES (?, ?, ?, ?);", array($ip, $brow, SITETIME, $log));
			$newhost = 1;
		} else {
			DB::run() -> query("UPDATE `online` SET `online_ip`=?, `online_brow`=?, `online_time`=?, `online_user`=? WHERE `online_id`=? LIMIT 1;", array($ip, $brow, SITETIME, $log, $queryonline));
		} 
	} else {
		$queryonline = DB::run() -> querySingle("SELECT `online_id` FROM `online` WHERE `online_ip`=? LIMIT 1;", array($ip));
		if (empty($queryonline)) {
			DB::run() -> query("INSERT INTO `online` (`online_ip`, `online_brow`, `online_time`) VALUES (?, ?, ?);", array($ip, $brow, SITETIME));
			$newhost = 1;
		} else {
			DB::run() -> query("UPDATE `online` SET `online_brow`=?, `online_time`=?, `online_user`=? WHERE `online_id`=? LIMIT 1;", array($brow, SITETIME, '', $queryonline));
		} 
	} 
	// -----------------------------------------------------------//
	$counts = DB::run() -> queryFetch("SELECT * FROM `counter`;");

	if ($counts['count_hours'] != $hours) {
		DB::run() -> query("INSERT IGNORE INTO `counter24` (`count_hour`, `count_hosts`, `count_hits`) VALUES (?, ?, ?);", array($hours, $counts['count_hosts24'], $counts['count_hits24']));
		DB::run() -> query("UPDATE `counter` SET `count_hours`=?, `count_hosts24`=?, `count_hits24`=?;", array($hours, 0, 0));
		DB::run() -> query("DELETE FROM `counter24` WHERE `count_hour` < (SELECT MIN(`count_hour`) FROM (SELECT `count_hour` FROM `counter24` ORDER BY `count_hour` DESC LIMIT 24) AS del);");
	} 

	if ($counts['count_days'] != $days) {
		DB::run() -> query("INSERT IGNORE INTO `counter31` (`count_days`, `count_hosts`, `count_hits`) VALUES (?, ?, ?);", array($days, $counts['count_dayhosts'], $counts['count_dayhits']));
		DB::run() -> query("UPDATE `counter` SET `count_days`=?, `count_dayhosts`=?, `count_dayhits`=?;", array($days, 0, 0));
		DB::run() -> query("DELETE FROM `counter31` WHERE `count_days` < (SELECT MIN(`count_days`) FROM (SELECT `count_days` FROM `counter31` ORDER BY `count_days` DESC LIMIT 31) AS del);"); 
		// ---------------------------------------------------//
		$querycount = DB::run() -> query("SELECT `count_days`, `count_hosts` FROM `counter31` ORDER BY `count_days` DESC LIMIT 6;");
		$counts = $querycount -> fetchAssoc();

		$host_data = array();
		for ($i = 0, $tekdays = $days; $i < 6; $tekdays--, $i++) {
			array_unshift($host_data, (isset($counts[$tekdays])) ? $counts[$tekdays] : 0);
		} 

		file_put_contents(DATADIR.'temp/counter7.dat', serialize($host_data), LOCK_EX);
	} 
	// -----------------------------------------------------------//
	if (!empty($newhost)) {
		DB::run() -> query("UPDATE `counter` SET `count_allhosts`=`count_allhosts`+1, `count_allhits`=`count_allhits`+1, `count_dayhosts`=`count_dayhosts`+1, `count_dayhits`=`count_dayhits`+1, `count_hosts24`=`count_hosts24`+1, `count_hits24`=`count_hits24`+1;");
	} else {
		DB::run() -> query("UPDATE `counter` SET `count_allhits`=`count_allhits`+1, `count_dayhits`=`count_dayhits`+1, `count_hits24`=`count_hits24`+1;");
	} 
} 
// -------------------------- Онлайн ------------------------------//
if ($config['onlines'] == 1) {
	$online = stats_online();
	echo '<a href="'.BASEDIR.'pages/online.php?act=all&amp;'.SID.'">Online: '.$online[1].'</a><br />';
} 
// ----------------------- Статистика ----------------------------//
if ($config['incount'] > 0) {
	$count = stats_counter();

	if ($config['incount'] == 1) {
		echo '<a href="'.BASEDIR.'pages/counter.php?'.SID.'">Хосты: '.$count['count_dayhosts'].'<br/>
		Хосты всего: '.$count['count_allhosts'].'</a><br />';
	} 
	if ($config['incount'] == 2) {
		echo '<a href="'.BASEDIR.'pages/counter.php?'.SID.'">Хиты: '.$count['count_dayhits'].'<br/>
		Хиты всего: '.$count['count_allhits'].'</a><br />';
	} 
	if ($config['incount'] == 3) {
		echo '<a href="'.BASEDIR.'pages/counter.php?'.SID.'">Хосты: '.$count['count_dayhosts'].'<br/>
		Хиты: '.$count['count_dayhits'].'</a><br />';
	} 
	if ($config['incount'] == 4) {
		echo '<a href="'.BASEDIR.'pages/counter.php?'.SID.'">Хосты всего: '.$count['count_allhosts'].'<br/>
		Хиты всего: '.$count['count_allhits'].'</a><br />';
	} 
	if ($config['incount'] == 5) {
		echo '<a href="'.BASEDIR.'pages/counter.php?'.SID.'"><img src="'.BASEDIR.'upload/counters/counter.png?'.SITETIME.'" alt="counter" /></a><br />';
	} 
} 

?>