<?php
include 'dbc.php';
include 'func_user.php';
$expLevel = array (0,100,100,300,700,1200,2000,3000,5400,7800,9300,11000,12000,16000,17000,18000,20000,22000,28000,29000,30000,41000,52000,63000,74000,85000,99000,100000,100000,100000,100000,100000,100000,100000,150000,170000,180000,200000,300000,400000,500000,700000,850000,1000000,2000000,3500000,5000000,7000000,10000000,12000000,12700000,100000000,100000000,100000000,200000000,300000000,400000000,500000000,700000000,900000000,1300000000,180000000,280000000,580000000,980000000,1980000000,2980000000,3980000000,4980000000,6000000000,9000000000,14000000000,20000000000,27000000000,34000000000,42000000000,51000000000,60000000000,70000000000,85000000000,100000000000,130000000000,160000000000,200000000000,300000000000,500000000000,1000000000000,2000000000000,3000000000000,4000000000000,5000000000000,6000000000000,7000000000000,8000000000000,9000000000000,1000000000000,11000000000000,12000000000000,13000000000000,14000000000000,15000000000000,16000000000000,17000000000000,18000000000000,19000000000000,20000000000000,30000000000000,40000000000000,50000000000000,60000000000000,70000000000000,80000000000000,90000000000000,100000000000000,11000000000000
);
$title = '';
function Oput($the){ global $user;
global $expLevel;
global $dbc;
if($user['vip']== 1){ $the = $the*2;}
if($user['alt']>0){ $bub = $the * $user['alt'] / 100;
$bub = ceil($bub); $the = $the+$bub;}
if($user['clan']<=0){
$dbc->query("update `users` set `oput` = `oput` + ".$the.", `exp` = `exp`+".$the." where id = '".$user['id']."'");
}else{ $plan = $the*10/100; $dbc->query("update `users` set `clan_oput` = `clan_oput`+".$plan.",`oput`=`oput`+".$the." , `exp`=`exp`+".$the." , `day` = `day` +".$plan." where id = '".$user['id']."'");
$dbc->query("update `clan` set `clan_oput` = `clan_oput` + ".$plan." where id = '".$user['clan']."'"); }
if ($user['exp']>=$expLevel[$user['level']]){
$dbc->query("update `dop` set `boi`=`boi`+5 where `user`='".$user['id']."' ");
$dbc->query("UPDATE `users` SET
`level`=`level`+1,
`train`=`train`+1, `exp`=0 ,`gold`=`gold`+50,`strength`=`strength`+1,`defense`=`defense`+1
WHERE `id`='".$user['id']."'");
$_SESSION['message']='<center><span class="info">Вы получили новый уровень!</span></br>Свитков Охотника +5 золото +50';
}}
if ($user['oput']>=$expLevel[$user['level']]){ $_SESSION['message']='<center><img src="img/stat/up.png">Вы получили новый уровень!<img src="img/stat/up.png">'; }
function head($title){
global $expLevel;
global $dbc;
global $user;
include 'head.php';
/* Записываем где пользователь */
if($user['id']>1){
if($title !=$user['where']){
$dbc->query("UPDATE `users` SET `where`='".$title."' WHERE `id`='".$user['id']."'");
}
}
}
list ( $ms , $s ) = explode ( chr ( 32 ) , microtime ( ) );
$g = $s + $ms;
$time_beg=microtime();
date_default_timezone_set('Europe/Moscow');
define('TIME', time());
session_start();
/* Настройки системы */
/* Проверяем бан, если да дропаем куки*/
if($user['ban']==1)
{
head('Бан');
echo '<div class="main">
<div class="block_zero center">Ваш персонаж был заблокирован!<br>
Причина: <b>'.$user['ban_why'].'</b>
</div></div>';
include 'foot.php';
exit;
}
function Sec2Time($time){
if(is_numeric($time)){
$value = array(
"years" => 0, "days" => 0, "hours" => 0,
"minutes" => 0, "seconds" => 0,
);
if($time >= 31556926){
$value["years"] = floor($time/31556926);
$time = ($time%31556926);
}
if($time >= 36912000){
$value["days"] = floor($time/691200);
$time = ($time%691200);
}
if($time >= 3600){
$value["hours"] = floor($time/3600);
$time = ($time%3600);
}
if($time >= 60){
$value["minutes"] = floor($time/60);
$time = ($time%60);
}
$value["seconds"] = floor($time);
if($value["seconds"]>0){
$time3 = $value["seconds"].' сек. ';
}else{
$time3='';
}
if($value["minutes"]>0){
$time2 = $value["minutes"].' мин. ';
}else{
$time2='';
}
if($value["hours"]>0){
$time1 = $value["hours"].' ч. ';
}else{
$time1='';
}
if($value["years"]>0){
$time_y = $value["years"].' лет ';
}else{
$time_y='';
}
return $time_y.$time1.$time2.$time3;
## return (array) $value;
}else{
return (bool) FALSE;
}
}
function nifa($i) { if($i >= 10000 && $i < 1000000) { $i = number_format($i, 0, '', '.'); $i = floor($i); $i = round($i,3).'k';}elseif($i >= 1000000 and $i< 1000000000) { $i = number_format($i, 0, '', '.'); $i = round($i,3).'m'; } elseif($i >= 1000000000) { $i = number_format($i, 0, '', '.'); $i = round($i,3).'g'; } else { $i = number_format($i, 0, '', '\''); } return $i; }
/* Функция отфильтровки чисел */
function int($int)
{
return abs(intval($int));
}
/* Функция защиты от нежелательных действий */
function protect($text)
{
global $dbc;
$text=str_replace('%','-%-',$text);
return trim($dbc->real_escape_string(htmlspecialchars($text, ENT_QUOTES, 'utf-8')));
}
/* Проверка GET данных */
foreach ($_GET as $check_url)
{
if (is_array($check_url) and !preg_match('#^(?:[a-z0-9_\-/]+|\.+(?!/))*$#i', $check_url))
{
session_start();
$_SESSION['note'] = 'ERROR 403. Недопустимый запрос!';
header ("Location: ../index.php");
exit;
}
}
unset($check_url);
/* Время */
function clock($time)
{
global $user;
$timep= date("j M Y год H:i:s", $time);
$time_p[0]=date("j n Y", $time);
$time_p[1]=date("H:i:s", $time);
if ($time_p[0]==date("j n Y", time()))$timep='Сегодня '.$time_p['1'];
if ($time_p[0]==date("j n Y", time()-86400))$timep='Вчера '.$time_p['1'];
if ($time_p[0]==date("j n Y", time()-172800))$timep='Позавчера '.$time_p['1'];
if ($time_p[0]==date("j n Y", time()-259200))$timep='3 дня назад '.$time_p['1'];
if ($time_p[0]==date("j n Y", time()-604800))$timep='Неделю назад '.$time_p['1'];
if ($time_p[0]==date("j n Y", time()-1209600))$timep='2 недели назад '.$time_p['1'];
$months_eng = array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
$months_rus = array('Января','Февраля','Марта','Апреля','Мая','Июня','Июля','Августа','Сентября','Октября','Ноября','Декабря');
$timep = str_replace($months_eng,$months_rus,$timep);
return $timep;
}
/* Время */
function clock2($time)
{
global $user;
$timep= date("j:M:Y H:i:s", $time);
$time_p[0]=date("j:n:Y", $time);
$time_p[1]=date("H:i:s", $time);
if ($time_p[0]==date("j:n:Y", time()))$timep=''.$time_p['1'];
if ($time_p[0]==date("j:n:Y", time()-86400))$timep=''.$time_p['1'];
if ($time_p[0]==date("j:n:Y", time()-172800))$timep=''.$time_p['1'];
if ($time_p[0]==date("j:n:Y", time()-259200))$timep=''.$time_p['1'];
if ($time_p[0]==date("j:n:Y", time()-604800))$timep=''.$time_p['1'];
if ($time_p[0]==date("j:n:Y", time()-1209600))$timep=''.$time_p['1'];
$months_eng = array('01','02','03','04','05','06','07','08','09','10','11','12');
$months_rus = array('01','02','03','04','05','06','07','08','09','10','11','12');
$timep = str_replace($months_eng,$months_rus,$timep);
return $timep;
}
/* Функция постраничной навигации */
if($user['id']>0){
$page = isset($_GET['page']) ? int($_GET['page']) : 0; $i=0;
if($user['str'] != 0){
$set['str'] = $user['str'];
}
while($i<$page+$set['str'] or $i==0) $i = $i+100;
if($page+$set['str']>100) $pagefile = $page-$i+100;
else $pagefile = $page;
function pages($page, $total, $href, $num)
{
echo '<div class="text">';
if ($page) echo '<a class="page" href="'.$href.'page='.($page-$num).'"><center>←</center></a> ';
else echo '<span class="page">←</span>';
{
$minus = $page-($num*3);
$plus = $page+($num*4);
if($minus<$total && $minus>0) echo ' <a class="page" href="'.$href.'page=0">1</a> ... ';
for($i=$minus; $i<$plus;)
{
if($i<$total && $i>=0) {
$ii = floor(1+$i/$num);
if ($page==$i) echo ' <span class="page"><center>'.$ii.'</center></span>';
else echo ' <a class="page" href="'.$href.'page='.$i.'"><center>'.$ii.'</center></a>';
}
$i=$i+$num;
}
if ($total > $page + $num)
echo ' <a class="page" href="'.$href.'page='.($page + $num).'"><center>→</center></a>';
else echo '→';
if($plus<$total) {
$whole = ceil($total/$num);
echo ' ... <a class="page" href="'.$href.'page='.($whole*$num-$num).'"><center>'.$whole.'</center></a>';
}
if(isset($_GET['end'])){
$whole = ceil($total/$num);
header('Location: '.$href.'&page='.($whole*$num-$num).'');}}
echo '</div>';}
}
/* Функция только для НЕ зарегистрированных пользователей */
function unreg()
{
global $user;
if($user)
{
header("Location: ../index.php");
}
}
/* Функция для зарегистрированных */
function reg(){
global $user;
if(empty($user['login']) and empty($user['password'])){
header("Location: ../sign.php");
exit;
}
}
/* Функция для определения уровня пользователя */
function only_admin($level)
{
global $user;
if (!isset($user) or $user['admins'] < $level)
{
header("Location: ../index.php");exit;
}
}
/* Функция безопасного шифрования в MD5 */
function md5_sault($text)
{
return md5(md5('Game').md5(md5($text)));
}
if($user['id']>0){
/*Время в игре*/
}
/* Функция отображения низа */
function foot(){
global $user;
include 'foot.php';
}
function mesto($the){ return header('location: '.$the.'');}
$bili = $user['regen'] + $user['health'];
/* $prov = abs(intval(31)) + TIME;
if($user['dobav']>=1 AND $user['am1_time'] <= $prov){ $dbc->query('UPDATE `users` SET `strength` =`strength`-"'.$user['dobav'].'",`dobav`=0 WHERE `id` = "' . $user['id'] . '"');}
$sssi = $user['am1_time'] - time();
if($user['dobav']>=1 AND Sec2Time($sssi)<=31){ $dbc->query('UPDATE `users` SET `strength` =`strength`-"'.$user['dobav'].'",`dobav`=0 WHERE `id` = "' . $user['id'] . '" LIMIT 1');}
$unti = abs(intval(5)) + TIME;
if($user['health']< $user['max_health'] AND $user['time_a'] < time()) {
if($bili>= $user['max_health']){
$dbc->query("update `users` set `time_a` = ".$unti.",`health`='".$user['max_health']."' where id = '".$user['id']."'");}else{$dbc->query("update `users` set `time_a` = ".$unti.",`health`=`health`+'".$user['regen']."' where id = '".$user['id']."'");}}
*/
$regen = $user['time_a']- time();
$regen = abs($regen);
$mas = $user['regen']*$regen;
$mus = $mas/5;
$ups = $mus+$user['health'];
$mus = ($mus>0) ? $mus : 1;
if($user['health']< $user['max_health'] AND $regen > 5 and $user['mer']==0) {
if($ups>= $user['max_health']){
$dbc->query("update `users` set `time_a` = ".time().",`health`='".$user['max_health']."' where id = '".$user['id']."'");}else{$dbc->query("update `users` set `time_a` = ".time().",`health`=`health`+'".$mus."' where id = '".$user['id']."'");}}
$ab = $user['daytovip'] -time();
if(Sec2Time($ab) == 0 and $user['vip']==1){
$dbc->query("update `users` set `vip` = '0' where id = '".$user['id']."'");
}
function am_off(){ global $user; global $dbc;
$proverka=$dbc->query("SELECT `dobav` FROM `users`where `id`= '".$user['id']."' ")->fetch_assoc();
if($proverka['dobav']>=1){ $dbc->query('UPDATE `users` SET `dobav`=0 WHERE `id` = "' . $user['id'] . '"');} }
function err($text) {
$_SESSION['err']="<center><font color=red>$text</font></center>";
header('location:?');exit; }
?>