Файл: gold.php
Строк: 398
<?php
include_once ('./core/base.php');
falseauth();
$header = 'Золото';
include_once ('./core/head.php');
echo '<div class="b">';
echo '<div class="title">Золото</div>';
echo '<center><div class="border"><img style="width: 100%; max-width: 336px;" src="/images/places/gold_and_dragon.png"></div></center>';
switch($_GET['action']){
default:
echo '<div class="event"><center>Золото - самая ценная валюта в Авалоре!<br/>
Его много не бывает!</center></div>';
echo '<a class="btn" href="/gold/exchange_silver/"><img src="/images/icons/money_bag.png"> Обменник <img src="/images/icons/silver.png"> на <img src="/images/icons/gold.png"></a>';
echo '<a class="btn" href="/gold/exchange_gold/"><img src="/images/icons/money_bag.png"> Обменник <img src="/images/icons/gold.png"> на <img src="/images/icons/silver.png"></a>';
echo '<a class="btn" href="/gold/vip/"><img src="/images/icons/vip.png"> Стать <font color="gold">VIP</font> игроком</a>';
echo '<a class="btn" href="/gold/skin/"><img src="/images/icons/user.png"> Образы</a>';
echo '<a class="btn" href="/gold/background/"><img src="/images/icons/location.png" width="24px"> Сменить фон</a>';
echo '<a class="btn" href="/gold/color/"><img src="/images/icons/blue_fearrow.png"> Сменить цвет ника</a>';
echo '<a class="btn" href="/wapkassa/"><img src="/images/icons/gold_24.png"> <font color="gold"><b>Приобрести золото</b></font></a>';
break;
case 'exchange_silver':
$cost_10 = 5000;
$cost_25 = 12500;
$cost_50 = 25000;
$cost_100 = 50000;
$_GET['sum'] = fl($_GET['sum']);
if($_GET['sum'] != ''){
if($_GET['sum'] == 10){
if($u['silver'] < $cost_10){
$_SESSION['message'] = 'Недостаточно серебра.';
header('Location: /gold/exchange_silver/');
exit;
}else{
$base -> query('UPDATE `users` SET `gold` = `gold` + "10", `silver` = `silver` - "'.$cost_10.'" WHERE `id` = "'.$u['id'].'" LIMIT 1');
$_SESSION['message'] = 'Обмен прошёл успешно.';
header('Location: /gold/exchange_silver/');
exit;
}
}elseif($_GET['sum'] == 25){
if($u['silver'] < $cost_25){
$_SESSION['message'] = 'Недостаточно серебра.';
header('Location: /gold/exchange_silver/');
exit;
}else{
$base -> query('UPDATE `users` SET `gold` = `gold` + "25", `silver` = `silver` - "'.$cost_25.'" WHERE `id` = "'.$u['id'].'" LIMIT 1');
$_SESSION['message'] = 'Обмен прошёл успешно.';
header('Location: /gold/exchange_silver/');
exit;
}
}elseif($_GET['sum'] == 50){
if($u['silver'] < $cost_50){
$_SESSION['message'] = 'Недостаточно серебра.';
header('Location: /gold/exchange_silver/');
exit;
}else{
$base -> query('UPDATE `users` SET `gold` = `gold` + "50", `silver` = `silver` - "'.$cost_50.'" WHERE `id` = "'.$u['id'].'" LIMIT 1');
$_SESSION['message'] = 'Обмен прошёл успешно.';
header('Location: /gold/exchange_silver/');
exit;
}
}elseif($_GET['sum'] == 100){
if($u['silver'] < $cost_100){
$_SESSION['message'] = 'Недостаточно серебра.';
header('Location: /gold/exchange_silver/');
exit;
}else{
$base -> query('UPDATE `users` SET `gold` = `gold` + "100", `silver` = `silver` - "'.$cost_100.'" WHERE `id` = "'.$u['id'].'" LIMIT 1');
$_SESSION['message'] = 'Обмен прошёл успешно.';
header('Location: /gold/exchange_silver/');
exit;
}
}
}
echo '<div class="title">Обменник</div>';
echo '<div class="event"><center>Золото - самая ценная валюта в Авалоре!<br/>
Его много не бывает!</center></div>';
echo '<a class="btn" href="/gold/exchange_silver/10/">Обменять <img src="/images/icons/silver_24.png">'.n_f($cost_10).' на <img src="/images/icons/gold_24.png">10</a>';
echo '<a class="btn" href="/gold/exchange_silver/25/">Обменять <img src="/images/icons/silver_24.png">'.n_f($cost_25).' на <img src="/images/icons/gold_24.png">25</a>';
echo '<a class="btn" href="/gold/exchange_silver/50/">Обменять <img src="/images/icons/silver_24.png">'.n_f($cost_50).' на <img src="/images/icons/gold_24.png">50</a>';
echo '<a class="btn" href="/gold/exchange_silver/100/">Обменять <img src="/images/icons/silver_24.png">'.n_f($cost_100).' на <img src="/images/icons/gold_24.png">100</a>';
echo '<br/><a class="btn" href="/gold/"><img src="/images/icons/back.png"> Назад</a>';
break;
case 'exchange_gold':
$cost_10 = 2500;
$cost_25 = 6250;
$cost_50 = 12500;
$cost_100 = 25000;
$_GET['sum'] = fl($_GET['sum']);
if($_GET['sum'] != ''){
if($_GET['sum'] == 10){
if($u['gold'] < 10){
$_SESSION['message'] = 'Недостаточно золота.';
header('Location: /gold/exchange_gold/');
exit;
}else{
$base -> query('UPDATE `users` SET `silver` = `silver` + "'.$cost_10.'", `gold` = `gold` - "10" WHERE `id` = "'.$u['id'].'" LIMIT 1');
$_SESSION['message'] = 'Обмен прошёл успешно.';
header('Location: /gold/exchange_gold/');
exit;
}
}elseif($_GET['sum'] == 25){
if($u['gold'] < 25){
$_SESSION['message'] = 'Недостаточно золота.';
header('Location: /gold/exchange_gold/');
exit;
}else{
$base -> query('UPDATE `users` SET `silver` = `silver` + "'.$cost_25.'", `gold` = `gold` - "25" WHERE `id` = "'.$u['id'].'" LIMIT 1');
$_SESSION['message'] = 'Обмен прошёл успешно.';
header('Location: /gold/exchange_gold/');
exit;
}
}elseif($_GET['sum'] == 50){
if($u['gold'] < 50){
$_SESSION['message'] = 'Недостаточно золота.';
header('Location: /gold/exchange_gold/');
exit;
}else{
$base -> query('UPDATE `users` SET `silver` = `silver` + "'.$cost_50.'", `gold` = `gold` - "50" WHERE `id` = "'.$u['id'].'" LIMIT 1');
$_SESSION['message'] = 'Обмен прошёл успешно.';
header('Location: /gold/exchange_gold/');
exit;
}
}elseif($_GET['sum'] == 100){
if($u['gold'] < 100){
$_SESSION['message'] = 'Недостаточно золота.';
header('Location: /gold/exchange_gold/');
exit;
}else{
$base -> query('UPDATE `users` SET `silver` = `silver` + "'.$cost_100.'", `gold` = `gold` - "100" WHERE `id` = "'.$u['id'].'" LIMIT 1');
$_SESSION['message'] = 'Обмен прошёл успешно.';
header('Location: /gold/exchange_gold/');
exit;
}
}
}
echo '<div class="title">Обменник</div>';
echo '<div class="event"><center>Серебро не золото, но без него никуда!</center></div>';
echo '<a class="btn" href="/gold/exchange_gold/10/">Обменять <img src="/images/icons/gold_24.png">10 на <img src="/images/icons/silver_24.png">'.n_f($cost_10).'</a>';
echo '<a class="btn" href="/gold/exchange_gold/25/">Обменять <img src="/images/icons/gold_24.png">25 на <img src="/images/icons/silver_24.png">'.n_f($cost_25).'</a>';
echo '<a class="btn" href="/gold/exchange_gold/50/">Обменять <img src="/images/icons/gold_24.png">50 на <img src="/images/icons/silver_24.png">'.n_f($cost_50).'</a>';
echo '<a class="btn" href="/gold/exchange_gold/100/">Обменять <img src="/images/icons/gold_24.png">100 на <img src="/images/icons/silver_24.png">'.n_f($cost_100).'</a>';
echo '<br/><a class="btn" href="/gold/"><img src="/images/icons/back.png"> Назад</a>';
break;
case 'vip':
$cost_1 = 500;
$cost_7 = 3000;
$cost_30 = 10000;
$_GET['days'] = fl($_GET['days']);
if($_GET['days'] != ''){
if($_GET['days'] == 1){
$vip_type = 1;
$vip_cost = $cost_1;
$vip_time = time() + (60 * 60 * 24);
}
if($_GET['days'] == 7){
$vip_type = 2;
$vip_cost = $cost_7;
$vip_time = time() + (60 * 60 * 24 * 7);
}
if($_GET['days'] == 30){
$vip_type = 3;
$vip_cost = $cost_30;
$vip_time = time() + (60 * 60 * 24 * 30);
}
if($u['vip'] == $vip_type){
$_SESSION['message'] = 'VIP статус уже активирован.';
header('Location: /gold/vip/');
exit;
}else{
if($_GET['days'] !=1 AND $_GET['days'] != 7 AND $_GET['days'] != 30){
header('Location: /gold/vip/');
exit;
}else{
if($_GET['days'] == 1){
$vip_type = 1;
$vip_cost = $cost_1;
$vip_time = time() + (60 * 60 * 24);
}
if($_GET['days'] == 7){
$vip_type = 2;
$vip_cost = $cost_7;
$vip_time = time() + (60 * 60 * 24 * 7);
}
if($_GET['days'] == 30){
$vip_type = 3;
$vip_cost = $cost_30;
$vip_time = time() + (60 * 60 * 24 * 30);
}
if($u['gold'] >= $vip_cost){
$base -> query('UPDATE `users` SET `vip` = "'.$vip_type.'", `vip_time` = "'.$vip_time.'", `gold` = `gold` - "'.$vip_cost.'" WHERE `id` = "'.$u['id'].'" LIMIT 1');
$_SESSION['message'] = 'VIP статус активирован.';
header('Location: /gold/vip/');
exit;
}else{
$_SESSION['message'] = 'Недостаточно золота.';
header('Location: /gold/vip/');
exit;
}
}
}
}
echo '<div class="title">Стать VIP игроком</div>';
if($u['vip'] > 0){
if($u['vip'] == 1) $type_vip = 'сутки';
if($u['vip'] == 2) $type_vip = 'неделю';
if($u['vip'] == 3) $type_vip = 'месяц';
echo '<div class="event"><center>У вас действует <img src="/images/icons/vip.png"><font color="gold">VIP</font> на '.$type_vip.'.<br/>
Окончание: <b>'.tm($u['vip_time']).'</b></center></div>';
}
echo '<div class="event"><center>С VIP статусом вы будете получать больше опыта и серебра с наград за победу.</center>
- VIP на день даёт бонус +50% к награде за победу.<br/>
- VIP на неделю даёт бонус +100% к награде за победу.<br/>
- VIP на месяц даёт бонус +150% к награде за победу.<br/></div>';
echo '<a class="btn" href="/gold/vip/1/"><img src="/images/icons/vip.png">VIP на день за <img src="/images/icons/gold_24.png">'.n_f($cost_1).'</a>';
echo '<a class="btn" href="/gold/vip/7/"><img src="/images/icons/vip.png">VIP на неделю за <img src="/images/icons/gold_24.png">'.n_f($cost_7).'</a>';
echo '<a class="btn" href="/gold/vip/30/"><img src="/images/icons/vip.png">VIP на месяц за <img src="/images/icons/gold_24.png">'.n_f($cost_30).' <small><font color="gold">(ВЫГОДНО)</font></small></a>';
echo '<br/><a class="btn" href="/gold/"><img src="/images/icons/back.png"> Назад</a>';
break;
case 'skin':
$_GET['skin'] = fl($_GET['skin']);
$new_skin_q = $base -> query("SELECT * FROM `skin_shop` WHERE `skin` = '".$_GET['skin']."' LIMIT 1");
$new_skin = $new_skin_q -> fetch_assoc();
if($_GET['skin'] != ''){
if($new_skin == 0){
header('Location: /gold/skin/');
$_SESSION['message'] = 'Ошибка.';
exit;
}else{
$have_skin = $base -> query("SELECT * FROM `users_skins` WHERE `skin` = '".$new_skin['skin']."' AND `user` = '".$u['id']."' LIMIT 1") -> num_rows;
if($have_skin > 0){
header('Location: /gold/skin/');
$_SESSION['message'] = 'У вас уже есть этот образ.';
exit;
}else{
if($u['gold'] >= $new_skin['cost']){
$skin = $base -> query("SELECT * FROM `skins` WHERE `id` = '".$new_skin['skin']."' LIMIT 1") -> fetch_assoc();
$base -> query("INSERT INTO `users_skins` SET
`user` = '".$u['id']."',
`skin` = '".$skin['id']."'");
$base -> query('UPDATE `users` SET `skin` = "'.$skin['skin'].'", `gold` = `gold` - "'.$new_skin['cost'].'" WHERE `id` = "'.$u['id'].'" LIMIT 1');
header('Location: /gold/skin/');
$_SESSION['message'] = 'Образ успешно приобретён, спасибо за покупку!';
exit;
}else{
header('Location: /gold/skin/');
$_SESSION['message'] = 'Недостаточно золота.';
exit;
}
}
}
}
echo '<div class="title">Купить образы</div>';
echo '<div class="event"><center>Нажмите на образ, что бы открыть дополнительную информацию.
Приобретённый образ попадёт в <img src="/images/icons/user.png"><a href="/skins/"><b>Мои образы</b></a>, где вы сможете его использовать.</center></div>';
$sex = fl($_GET['sex']);
if(!$sex) $sex = 1;
if($sex == 1) echo '<center><div class="btn_small_pressed">Мужские</div> <a class="btn_small" href="/gold/skin/girl/">Женские</a></center>';
elseif($sex == 2) echo '<center><a class="btn_small" href="/gold/skin/boy/">Мужские</a> <div class="btn_small_pressed">Женские</div></center>';
$count = $base -> query("SELECT * FROM `skin_shop` WHERE `sex` = '".$sex."'") -> num_rows;
$k_page = k_page($count,15);
$page = page($k_page);
$start = 15 * $page-15;
$sql = $base -> query("SELECT * FROM `skin_shop` WHERE `sex` = '".$sex."' ORDER BY `id` ASC LIMIT $start,15");
if($count > 0){
echo '<table width="100%">';
$i = 1;
while($shop_skin = $sql -> fetch_assoc()){
$skin = $base -> query("SELECT * FROM `skins` WHERE `id` = '".$shop_skin['skin']."' LIMIT 1") -> fetch_assoc();
$have_skin = $base -> query("SELECT * FROM `users_skins` WHERE `skin` = '".$skin['id']."' AND `user` = '".$u['id']."' LIMIT 1") -> num_rows;
if($skin['sex'] == 1) $sex = 'Мужской';
elseif($skin['sex'] == 2) $sex = 'Женский';
if($i == 1) echo '<tr>';
if($have_skin > 0){
echo '<td width="50%"><div class="btn_pressed" style="height: 62px; margin: 0px; font-size: 12px;"><img style="float: left;" src="/images/skins/'.$skin['skin'].'.gif"> <b>'.$skin['name'].'</b><br/>
<img src="/images/icons/yes.png" height="12px"><font style="font-size: 11px; color:limegreen;">Имеется</font></div></td>';
}else{
echo '<td width="50%"><a class="btn" style="height: 62px; margin: 0px; font-size: 12px;" href="/gold/skin/info/'.$skin['skin'].'/"><img style="float: left;" src="/images/skins/'.$skin['skin'].'.gif"> <b>'.$skin['name'].'</b><br/>
<font color="#B1B1B1">Цена:</font> <img src="/images/icons/gold_24.png" width="16px"><font color="gold"><b>'.n_f($shop_skin['cost']).'</b></font>
'.$have.'</a></td>';
}
if($i == 2){
$i = 0;
echo '</tr>';
}
$i ++;
}
echo '</table>';
if($count > '15'){
echo str('?',$k_page,$page);
}
}else{
echo '<center>Нет образов в продаже...</center>';
}
echo '<br/><a class="btn" href="/gold/"><img src="/images/icons/back.png"> Назад</a>';
break;
case 'background':
$_GET['background'] = fl($_GET['background']);
$new_background_q = $base -> query("SELECT * FROM `background_shop` WHERE `id` = '".$_GET['background']."' LIMIT 1");
$new_background = $new_background_q -> fetch_assoc();
if($_GET['background'] != ''){
if($new_background == 0){
header('Location: /gold/background/');
$_SESSION['message'] = 'Ошибка.';
}else{
if($u['background'] == $new_background['image']){
header('Location: /gold/background/');
$_SESSION['message'] = 'Ошибка.';
}else{
if($u['gold'] >= $new_background['cost']){
$base -> query('UPDATE `users` SET `background` = "'.$new_background['image'].'", `gold` = `gold` - "'.$new_background['cost'].'" WHERE `id` = "'.$u['id'].'" LIMIT 1');
header('Location: /gold/background/');
$_SESSION['message'] = 'Фон успешно изменён.';
}else{
header('Location: /gold/background/');
$_SESSION['message'] = 'Недостаточно золота.';
}
}
}
}
echo '<div class="title">Изменить фон</div>';
echo '<div class="event"><center>На выбранном фоне, ваш персонаж будет отображаться в профиле.</center></div>';
$background_q = $base -> query("SELECT * FROM `background_shop` ORDER BY `cost` ASC");
while ($background = $background_q -> fetch_assoc()){
echo '<a class="btn" href="/gold/background/'.$background['id'].'/"><img src="/images/locations/backgrounds/'.$background['image'].'.png" width="84px"> Выбрать за <img src="/images/icons/gold.png">'.n_f($background['cost']).'</a>';
}
echo '<br/><a class="btn" href="/gold/"><img src="/images/icons/back.png"> Назад</a>';
break;
case 'color':
$_GET['color'] = fl($_GET['color']);
$new_color_q = $base -> query("SELECT * FROM `color_shop` WHERE `id` = '".$_GET['color']."' LIMIT 1");
$new_color = $new_color_q -> fetch_assoc();
if($_GET['color'] != ''){
if($new_color == 0){
header('Location: /gold/color/');
$_SESSION['message'] = 'Ошибка.';
}else{
if($u['login_color'] == $new_color['color']){
header('Location: /gold/color/');
$_SESSION['message'] = 'Ошибка.';
}else{
if($u['gold'] >= $new_color['cost']){
$base -> query('UPDATE `users` SET `login_color` = "'.$new_color['color'].'", `gold` = `gold` - "'.$new_color['cost'].'" WHERE `id` = "'.$u['id'].'" LIMIT 1');
header('Location: /gold/color/');
$_SESSION['message'] = 'Цвет ника успешно изменён.';
}else{
header('Location: /gold/color/');
$_SESSION['message'] = 'Недостаточно золота.';
}
}
}
}
echo '<div class="title">Изменить цвет ника</div>';
echo '<div class="event"><center>Выбранный цвет ника будут видеть все остальные игроки.</center></div>';
$color_q = $base -> query("SELECT * FROM `color_shop` ORDER BY `cost` ASC");
while ($color = $color_q -> fetch_assoc()){
echo '<a class="btn" href="/gold/color/'.$color['id'].'/"><img src="/images/icons/blue_fearrow.png"> <font color="'.$color['color'].'"><b>'.$u['login'].'</b></font> - Выбрать за <img src="/images/icons/gold.png">'.n_f($color['cost']).'</a>';
}
echo '<br/><a class="btn" href="/gold/"><img src="/images/icons/back.png"> Назад</a>';
break;
}
echo '</div>';
include_once ('./core/foot.php');
?>