<?
require_once ('../system/func.php');

$h = date('H',time());
if($h >= 20 or $h <= 5){
$time = 3600*8;
}else{
$time = 3600*4;
}

$drakon = mysql_query("SELECT * FROM `drakon` ORDER BY `id` DESC LIMIT 1");
$drakon = mysql_fetch_array($drakon);

if($drakon['last'] <= time() and $drakon['start'] == 0){
mysql_query("UPDATE `drakon` SET `last` = '".(time()+(60*5))."', `start` = '1' WHERE `id` = '$drakon[id]' LIMIT 1");
}
if($drakon['last'] < time() and $drakon['start'] == 1){
mysql_query("UPDATE `drakon` SET `start` = '3' WHERE `id` = '$drakon[id]' LIMIT 1");
mysql_query("INSERT INTO `drakon` SET `last` = '".(time()+$time)."'");
}

$mertvec = mysql_query("SELECT * FROM `mertvec` ORDER BY `id` DESC LIMIT 1");
$mertvec = mysql_fetch_array($mertvec);

if($mertvec['last'] <= time() and $mertvec['start'] == 0){
mysql_query("UPDATE `mertvec` SET `last` = '".(time()+(60*5))."', `start` = '1' WHERE `id` = '$mertvec[id]' LIMIT 1");
}
if($mertvec['last'] < time() and $mertvec['start'] == 1){
mysql_query("UPDATE `mertvec` SET `start` = '3' WHERE `id` = '$mertvec[id]' LIMIT 1");
mysql_query("INSERT INTO `mertvec` SET `last` = '".(time()+$time)."'");
}
?>