<?
//
//
error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING); // Отключает ошибки
//
//
/*
ini_set('error_reporting', E_ALL);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
*/
//
//
session_start(); // запускаем ссесию
ob_start(); // включаем буферизацию вывода, нужно для заголовков header
mb_internal_encoding("UTF-8"); // внутренния кодировка сайта
function is($i){
$is = explode("/",checking($_GET['is']));
return $is[$i];
}
//
//
//
//
try{
$BaseConnect = new PDO("mysql:host=localhost;dbname=e99663xd_test",'e99663xd_test','e99663xd_test1');
}
catch(PDOException $e){
die('Нет соединения с базой данных!');
}
$BaseConnect->exec("set names utf8");
//
//фильтрация текста
function checking($text) {
$text = trim(htmlspecialchars($text));
return $text;
}
//фильтрация цифр
function number($num) {
$num = abs(intval($num));
return $num;
}
//
//Для обычного запроса
function cnt($sql, $params = array()) {
global $BaseConnect;
$stmt = $BaseConnect -> prepare($sql);
$stmt -> execute($params);
$stmt = $stmt->rowCount();
return $stmt;
}
//
//Работаем с базой данных
function qry($sql, $params = array()) {
global $BaseConnect;
$stmt = $BaseConnect -> prepare($sql);
$stmt -> execute($params);
return $stmt;
}
//
//Для вывода ассоциотивного массива
function fch($sql, $params = array()) {
global $BaseConnect;
$stmt = $BaseConnect -> prepare($sql);
$stmt -> execute($params);
$stmt = $stmt->fetch();
return $stmt;
}
//
//
//
function logi($log){if($log != null){$_SESSION['log'][] = $log;}}
function logs(){
$count = count($_SESSION['log']);for($i = '0';$i <= $count;$i++){$text = $text."<div>".$_SESSION['log'][$i]."</div>";}
if($count > '0'){
return $text.logn();
}
}
function logn(){unset($_SESSION['log']);}
function err($err){
if($err != null){
logi("<div class='cntr'><span class = 'red'>".$err."</span></div>");
}
}
function err2($err2){
if($err2 != null){
logi("<span class = 'lime'>".$err2."</span></div>");
}
}
function ruby($ruby){
if($ruby == null){
logi("<div class='tophead2 cntr'><span class = 'red'>Недостаточно рубинов</span> - <a href='/paywk'><span class = 'color'>[купить]</span></a></div>");
}
}
function msg2($msg2){
if($msg2 != null){
logi("<span class = 'lime'>".$msg2."</span></div>");
}
}
function msg($msg){
if($msg != null){
logi("<div class='cntr'><span class = 'lime'>".$msg."</span></div>");
}
}
//
//
function page($num,$str,$result){
// обработчик страниц
$num = number($num);
if($num < '1'){$num = '1';}$start = $str * $num - $str;
$endpage = ceil($result/$str);
if($num > $endpage){$start = '0';}
return $start;
}
function ppage($url,$num,$str,$result){
// панель страниц
$num = number($num); // текущая страница
$endpage = ceil($result/$str); // последняя страница
if($endpage < '1'){$endpage = '1';}
if($endpage < $num or $num < '1'){$num = '1';};
if($str < $result){
echo "
<div class = 'tophead pages'>
";
$n_4 = number($num - 4);
$n_3 = number($num - 3);
$n_2 = number($num - 2);
$n_1 = number($num - 1);
$n1 = '1';
$p1 = number($num + 1);
$p2 = number($num + 2);
$p3 = number($num + 3);
$p4 = number($num + 4);
if($num != '1'){
echo "<a class = 'page' href = '".$url.$n1."/' data-page = '".$n1."'><</a> ";
}
else{
echo "<span class = 'page-current'><</span> ";
}
if($num > '4' && $endpage - 1 < $num){
echo "<a title = 'Перейти на страницу ".($n_4)."' class = 'page' href = '".$url.$n_4."/' data-page = '".$n_4."'>".$n_4."</a> ";
}
if($num > '3' && $endpage - 2 < $num){
echo "<a title = 'Перейти на страницу ".($n_3)."' class = 'page' href = '".$url.$n_3."/' data-page = '".$n_3."'>".$n_3."</a> ";
}
if($num > '2'){
echo "<a title = 'Перейти на страницу ".($n_2)."' class = 'page' href = '".$url.$n_2."/' data-page = '".$n_2."'>".$n_2."</a> ";
}
if($num > '1'){
echo "<a title = 'Перейти на страницу ".($n_1)."' class = 'page' href = '".$url.$n_1."/' data-page = '".$n_1."'>".$n_1."</a> ";
}
echo " <span class = 'page-current'>".$num."</span> ";
if($endpage - 1 > $num){
echo "<a class = 'page' href = '".$url.$p1."/' data-page = '".$p1."'>".$p1."</a> ";
}
if($endpage - 2 > $num){
echo "<a class = 'page' href = '".$url.$p2."/' data-page = '".$p2."'>".$p2."</a> ";
}
if($endpage - 3 > $num && $num <= '2'){
echo "<a class = 'page' href = '".$url.$p3."/' data-page = '".$p3."'>".$p3."</a> ";
}
if($endpage - 4 > $num && $num <= '1'){
echo "<a class = 'page' href = '".$url.$p4."/' data-page = '".$p4."'>".$p4."</a> ";
}
if($endpage != $num){
if($endpage - 3 < $num){
echo "<a title = 'Перейти на страницу ".($endpage)."' class = 'page' href = '".$url.$endpage."/' data-page = '".$endpage."'>".$endpage."</a> ";
}
echo "<a class = 'page' href = '".$url.$endpage."/' data-page = '".$endpage."'>></a> ";
}
else{
echo "<span class = 'page-current'>></span> ";
}
echo "</div>";
}
}
//обрезаем текст
function text_msg( $text, $maxwords = 100, $maxchar = 105 ){
$sep=' ';
$words = explode($sep,$text);
$char = iconv_strlen($text,'utf-8');
if (count($words) > $maxwords){
$text = join($sep, array_slice($words, 0, $maxwords));
}
if ( $char > $maxchar ){
$sep2='...';
$text = iconv_substr( $text, 0, $maxchar, 'utf-8' );
}
return $text;
}
//
function clock($time=NULL){
global $user;
if ($time==NULL)$time=time();
if (isset($user))$time=$time+60;
$timep="".date("j M Y в H:i", $time)."";
$time_p[0]=date("j n Y", $time);
$time_p[1]=date("H:i", $time);
if ($time_p[0]==date("j n Y"))$timep = date("H:i:s", $time);
if (isset($user)){
if ($time_p[0]==date("j n Y", time()+60))$timep = "Сегодня в ".date("H:i:s", $time);
if ($time_p[0]==date("j n Y", time()-60*60*24))$timep="Вчера в $time_p[1]";}
else{
if ($time_p[0]==date("j n Y"))$timep=date("H:i:s", $time);
if ($time_p[0]==date("j n Y", time()-60*60*24))$timep="Вчера в $time_p[1]";}
$timep=str_replace("Jan","Янв",$timep);
$timep=str_replace("Feb","Фев",$timep);
$timep=str_replace("Mar","Марта",$timep);
$timep=str_replace("May","Мая",$timep);
$timep=str_replace("Apr","Апр",$timep);
$timep=str_replace("Jun","Июня",$timep);
$timep=str_replace("Jul","Июля",$timep);
$timep=str_replace("Aug","Авг",$timep);
$timep=str_replace("Sep","Сент",$timep);
$timep=str_replace("Oct","Окт",$timep);
$timep=str_replace("Nov","Ноября",$timep);
$timep=str_replace("Dec","Дек",$timep);
return $timep;
}
//
//
function timer($var){
$timer = $var - time();
$isDay = floor($timer/86400);
$isHour = floor($timer/3600);
$isMin = floor($timer/60);
$hourOs = $isHour - ($isDay*24); // Остаток часов от дня
$minOs = $isMin - ($isHour * 60); // Остаток минут от часов
$secOs = $timer - ($isMin * 60); // остаток секунд от часов
if($isDay > '0'){$day = $isDay." д ";}
if($hourOs > '0'){$hour = $hourOs." ч ";}
if($minOs > '0'){$minute = $minOs." м ";}
if($secOs > '0'){$sec = $secOs ." с ";}
$times = $day.$hour.$minute.$sec;
return $times;
}
//
//
function month($i){
$month = array("1" => "Январь","2" => "Февраль","3" => "Март","4" => "Апрель","5" => "Май","6" => "Июнь","7" => "Июль","8" => "Август","9" => "Сентябрь","10" => "Октябрь","11" => "Ноябрь","12" => "Декабрь");
return $month[$i];
}
//
//
function renum($num){
if($num >= '1000' && $num < '1000000'){$num = round($num/1000,2)."k";}
elseif($num >= '1000000' && $num < '1000000000'){$num = round($num/1000000,2)."m";}
elseif($num >= '1000000000' && $num < '1000000000000'){$num = round($num/1000000000,2)."g";}
elseif($num >= '1000000000000'){$num = round($num/1000000000000,2)."T";}
return $num;
}
//
//
//
function bbcode($text){
$str_search = array(
"/\[(\/?)(br|b|i|u|s)\s*\]/",
"#\[smile(.+?)\]#is",
"#\[div class = (.+?)\](.+?)\[\/div\]#is",
"#\[span class = (.+?)\](.+?)\[\/span\]#is",
"#///n#is",
"#\[code\](.+?)\[\/code\]#is",
"#\[quote\](.+?)\[\/quote\]#is",
"#\[url=(.+?)\](.+?)\[\/url\]#is",
"#\[url\](.+?)\[\/url\]#is",
"#\[img=(.+?)\](.+?)\[\/img\]#is",
"#\[cntr\](.+?)\[\/cntr\]#is",
"#\[size=(.+?)\](.+?)\[\/size\]#is",
"#\[color=(.+?)\](.+?)\[\/color\]#is",
"#\[list\](.+?)\[\/list\]#is",
"#\[listn](.+?)\[\/listn\]#is",
"#\[\*\](.+?)\[\/\*\]#"
);
$str_replace = array(
"<$1$2>",
"<img src = '/images/emoji/\\1.png'>",
"<div class = '\\1'>\\2</div>",
"<span class = '\\1'>\\2</span>",
"<br/>",
"<code class='code'>\\1</code>",
"<table width = '95%'><tr><td>Цитата</td></tr><tr><td class='quote'>\\1</td></tr></table>",
"<a href = '\\1'>\\2</a>",
"<a href = '\\1'>\\1</a>",
"<img src = '\\1' width='\\2' height='\\2' alt = 'Изображение' />",
"<center>\\1</center>",
"<span style = 'font-size:\\1%'>\\2</span>",
"<font color = '\\1'>\\2</font>",
"<ul>\\1</ul>",
"<ol>\\1</ol>",
"<li>\\1</li>"
);
return preg_replace($str_search, $str_replace, $text);
}
//
//
///
//
// Второстепенные функции
//
//
//
//
$uid= checking($_COOKIE['uid']);
$password= checking($_COOKIE['password']);
//
//
//
//
if($uid and $password) {
$BaseUser = $BaseConnect->prepare("SELECT * FROM `users` WHERE `id` = ? and `password` = ?");
$BaseUser -> execute(array($uid, $password));
$user = $BaseUser->fetch(PDO :: FETCH_ASSOC);
if(!$user) {
setcookie('uid', '', time() - 86400 * 365, '/');
setcookie('password', '', time() - 86400 * 365, '/');
}
}
//
//
//
//
$uid = number($user['id']);
//
//
//
//
if($uid == '0' && $location == true){
header("Location:/");
exit();
}
//
//
//
//
function UserEnter($uid,$password){
$uid = number($uid);
$password = checking($password);
$_SESSION['uid'] = $uid;
$_SESSION['password'] = $password;
setcookie("uid", $uid, time()+86400*365, "/");
setcookie("password", $password, time()+86400*365, "/");
}
//
//
//
//
function UserExit($uid){
unset($_SESSION['uid']);
unset($_SESSION['password']);
setcookie("uid", $uid, time()-86400*365, "/");
setcookie("password", $password, time()-86400*365, "/");
}
//
//
function user($users){
$user = fch("SELECT * FROM `users` WHERE `id` = ? LIMIT 1", array(number($users)));
//
//
$list = '<small>'.$user['login'].'</small>';
return $list;
}
//
//
//
function user_list2($users){
$user = fch("SELECT * FROM `users` WHERE `id` = ? LIMIT 1", array(number($users)));
//
//
if($user['premium_time'] > time())$inf = '
<img src = "/images/vip.png" width="15" height="15">
<span class="orange">
';
else
$inf = '
<img src = "/style/'.$user['sex'].'.png" width="16" height="16">
<span class="color">
';
//
//
$list = '
<a href="/mail/'.$user['id'].'/user" class="">
'.$inf.'
<small>
'.$user['login'].'
</small>
</span>
</a>';
return $list;
}
//
//
//
//
function user_list($users){
$user = fch("SELECT * FROM `users` WHERE `id` = ? LIMIT 1", array(number($users)));
//
//
if($user['premium_time'] > time())$inf = '
<img src = "/images/vip.png" width="15" height="15">
<span class="orange">
';
else
$inf = '
<img src = "/style/'.$user['sex'].'.png" width="16" height="16">
<span class="color">
';
//
//
$list = '<a href="/profile.php?id='.$user['id'].'" class="">
'.$inf.'
<small>
'.$user['login'].'
</small>
</span>
</a>
';
return $list;
}
//
//
if($uid)qry("UPDATE `users` SET `time_on` = ? WHERE `id` = ? LIMIT 1", array(time(),number($uid)));
//
//
//голова
function head($title,$uid){
//
global $user;
//
//
$title = checking($title);
//
//
require_once($_SERVER['DOCUMENT_ROOT']."/core/level.php");
//
//
?>
<!DOCTYPE html>
<html lang="ru">
<head>
<meta name="viewport" content="initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=yes" />
<meta charset="utf-8">
<link type="Image/x-icon" href="https://<? echo ''.$_SERVER['HTTP_HOST'].''; ?>/style/favicon.ico" rel="icon">
<meta name="keywords" content="Королевство, Онлайн игра, Захват замков, играть в игру, мобильная игра, online game">
<meta name="description" content="Мобильная онлайн-игра "Королевство Лионес". Погрузись в мир средневековья и стань одним из лидирующих рыцарей.>
<title><?=$title;?></title>
<link rel="stylesheet" href="https://<? echo ''.$_SERVER['HTTP_HOST'].''; ?>/style/style.css?v=0.0.1" />
<meta name="author" content="no" />
</head>
<body>
<?
//
if($user['start'] >= 4){
$new_msg = fch("SELECT * FROM `mail` WHERE `id_ank` = ? AND `check` =? LIMIT 1", array(number($uid),1));
?>
<div class="hrs"></div>
<div class="title cntr"><span class="color"><?=$title;?></span></div>
<div class="tophead2 cntr">
<font size="3">
<span style="float: left;">
<img class="img1" src="/images/level.png" width="17px" height="17px"><span class="lime">
<? echo $user['level']; ?> ур </span>
</span>
<img src="/images/power.png" width="17px" height="17px"><? echo $user['power']; ?>
<img src="/images/block.png" width="17px" height="17px"><? echo $user['block']; ?>
<img src="/images/health.png" width="17px" height="17px"><? echo $user['health']; ?>
<span style="float: right;">
<?
if($new_msg > 0){
?>
<a href="/contacts/"><img class="img2" src="/images/mail.png" width="17px" height="17px"><a>
<?
}else{
?>
<img class="img2" src="/images/exp.png" width="17px" height="17px">
<span class="orange"><? echo ' '.round($user['exp']/$user_level[$user['level']]*100,1).'%'; ?> </span>
<?
}
?>
</span>
</font>
</div><div class="tophead2">
<div class="progress-bar exp">
<div style="width:<? echo ''.round($user['exp']/$user_level[$user['level']]*100,1).''; ?>%;" class="progress _green"> </div>
</div>
</div>
<br>
<div class="wp200 alc pos-r lptp comp_menu_right"><div class="tophead2 cntr">
<div class="title cntr"><span class="color">Новостной блок</span></div>
<li>Заменили всех персонажей в арене</li>
</div></div>
<div class="wp200 alc pos-r lptp comp_menu_left"> <div class="tophead2">
<img class="round_image" src="/images/avatar/<?=$user['sex'];?>/<?=$user['avatar'];?>.png" width=100" height="100" alt="*">
<br> </div>
<div class="tophead2">
<span style="float: left;">
<img src="/images/power.png" width="17px" height="17px"><? echo $user['power']; ?> </span>
<img src="/images/block.png" width="17px" height="17px"><? echo $user['block']; ?>
<span style="float: right;"><img src="/images/health.png" width="17px" height="17px"><? echo $user['health']; ?> </span>
</div>
<a class="button_200px" href="/profile.php">
<div class="button_200px_image"><img src="/style/profile.png" width="20px" height="20px" alt=""></div>
<div class="tophead">Профиль </div></a>
<a class="button_200px" href="/item.php"><div class="button_200px_image"><img src="/images/snar.png" width="20px" height="20px" alt=""></div><div class="tophead">Снаряжение</div></a>
<a class="button_200px" href="/skill.php">
<div class="button_200px_image"><img src="/images/ability.png" width="20px" height="20px" alt=""></div>
<div class="tophead">Умения </div></a>
<a class="button_200px" href="/gold.php">
<div class="button_200px_image"><img src="/images/gold.png" width="20px" height="20px" alt=""></div>
<div class="tophead">Обменник </div></a>
<table class="w100 alc tbs0"><tbody><tr><td width="33%">
<a class="button_200px" href="/contacts/"><div class="button_200px_image" style="position: relative"><img src="/images/mail.png" width="20px" height="20px" alt=""></div></a></td>
<td width="33%"><div class="button_200px"><div class="button_200px_image" style="position: relative"><span class="small black"><?=$user['level'];?>ур.</span></div></div></td><td width="33%"><a class="button_200px" href="/index.php"><div class="button_200px_image" style="position: relative"><img src="/style/home.png" width="20px" height="20px" alt=""></div></a></td></tr></tbody></table><br>
<a class="button_200px" href="/paywk/"><div class="button_200px_image"><img src="/images/ruby.png" width="20px" height="20px" alt=""></div><div class="tophead">Купить рубины</div></a><div class="ven"></div>
</div>
<?
//
//
//
//
$get2= fch("SELECT * FROM `newyear_get` WHERE `id` = ? LIMIT 1", array($new2['level']));
//
//
if($_SERVER['PHP_SELF'] == '/index.php' && $user['save'] == 1 && $user['start'] >= 10)echo '<a href="/save.php" class="tophead cntr">Сохраните игру и получите! <br><small><span class="tomato"> <img src="/images/ruby.png" width="16px" height="16px" alt=""> 10 рубинов</span> и <img src="/images/vip.png" width="16px" height="16px" alt=""> <span class="orange">Премиум-аккаунт</span></small></a>';
//
//
echo logs();
?>
<?
}
//
}
//
//
//
//ноги
function foot($uid){
//
//
global $user;
//
//
$on = qry("SELECT (id) FROM `users` WHERE `time_on` > '".(time()-10800)."'")->rowCount();
//
//
if($uid){
if($_SERVER['PHP_SELF'] == '/index.php' && $user['save'] >= 2 && $user['id'] == 0){
?>
<div class="tophead2 cntr">
<span class="orange">
Новогодние акции
</span>
<br>
<font color=#888>
<small>
Бонус 100% при покупке от 100 рубинов
<br>
Скидка 30% на снаряжение
<br>
Скидка 30% на руны
<br>
Скидка 30% на заточку
</small>
</font>
</div>
<?
}
?>
<div class="tophead2">
<table style='width:100%;'>
<tr>
<td style='width: 1%;' class='cntr'>
<a class="tophead" href="/"><img src="/style/homes.png" width="65px" height="59px" alt=""></a>
</td>
<td style='width: 1%;' class='cntr'>
<a class="tophead" href="/profile.php"><img src="/style/profils.png" width="65px" height="59px" alt=""></a>
</td>
</td>
</tr>
</table>
</div>
<div class="cntr">
<div class="hrs"></div>
<a href="/news/"><?
if($user['news'] != 0)echo '<span class="lime">';
?>Новости</span></a> | <a href="/chat/"><?
if($user['chat_check'] != 0)echo '<span class="lime">';
?>Чат</span></a> | <a href="/online/">Онлайн: <? echo $on; ?></a>
<br> <a href="/index.php?help=1">Помощь по игре</a> | <a href="/settings.php">Настройки</a>
</div>
<div class="hrs"></div>
</body></html>
<?
//
}
//
}
//
//
//
//
//Задания
//
$yyy = $BaseConnect->query("SELECT * FROM `quest` ORDER BY `id` ASC");
//
while($post = $yyy->fetch(PDO::FETCH_ASSOC)){
//
$quest = fch("SELECT * FROM `quest_user` WHERE `id_quest` = ? AND `id_user` = ? ORDER BY `id` DESC LIMIT 1", array($post['id'],$uid));
//
if(!$quest && $uid >= 1){
//
qry("INSERT INTO `quest_user` SET `id_user` = ?, `id_quest` = ?, `max_koll` = ?", array($uid,$post['id'],$post['koll']));
//
}
}
//
//
$dat = array('1' => 'Реклама / Спам', '2' => 'Мат', '3' => 'Продажа / Покупка персонажа', '4' => 'Продажа / Покупка гильдии', '5' => 'Использование багов');
//
//
$dat2 = array('1' => 'Молчанка', '2' => 'Блокировка');
//
//
$ban = fch("SELECT * FROM `ban` WHERE `id_user` = ? AND `time` > ? ORDER BY `id` DESC LIMIT 1", array($uid,time()));
//
//
if($ban['tipe'] == 2 && $ban['time'] > time()){
//
//
head("Блокировка",$uid); # Голова
//
//
?>
<div class="tophead cntr">
<span class="tomato">
Мы с тобой больше не играем
</span>
</div>
<?
//
//
foot($uid);
exit();
}
//
//
//
//
$param_skill =array(
'',
'3',
'10',
'90',
'10',
'10',
'10',
'2',
'0',
'10',
'10',
'10',
'10',
'0',
'0',
'0'
);
//
//
$time_skill =array(
'',
'60',
'40',
'60',
'40',
'40',
'50',
'40',
'40',
'40',
'40',
'50',
'50',
'60',
'40',
'60'
);
//
//
$reset_skill =array(
'',
'0',
'5',
'0',
'5',
'5',
'0',
'0',
'4',
'3',
'5',
'5',
'4',
'0',
'4',
'4'
);
//
//
$tavern = fch("SELECT * FROM `tavern` WHERE `id_user` = ? LIMIT 1", array($uid));
//
//
$lec = fch("SELECT * FROM `lec_user` WHERE `id_user` = ? LIMIT 1", array($uid));
//
//
if(!$tavern && $uid != 0){
qry("INSERT INTO `tavern` SET `id_user` = ?", array($uid));
qry("INSERT INTO `lec_user` SET `id_user` = ?", array($uid));
header('location:?');
exit();
}
//
//
$skills = fch("SELECT * FROM `skills` WHERE `id_user` = ? AND `type` = ? LIMIT 1", array($uid,1));
if(!$skills && $uid != 0){
//
//
for($c=1;$c<=4;$c++){
//
//
qry("INSERT INTO `skills_fight` SET `id_user` = ?, `type` = ? ", array($uid,$c));
//
//
}
//
//
for($i=1;$i<=15;$i++){
//
//
$param = $param_skill[$i];
$time = $time_skill[$i];
$reset = $reset_skill[$i];
//
//
qry("INSERT INTO `skills` SET `id_user` = ?, `type` = ?, `time_max` = ?, `reset_max` = ?, `param` = ?", array($uid,$i,$time,$reset,$param));
//
//
}
//
//
header('location:?');
exit();
}
//
//
?>