Файл: panel/drops.php
Строк: 93
<?php
include_once ('../core/base.php');
$header = 'Дропы';
include_once ('../core/head.php');
falseauth();
adm();
if($u['admin'] == 3){
echo '<div class="b">';
switch($_GET['act']){
default:
echo '<div class="title">Список дропов</div>';
$count = $base -> query("SELECT * FROM `drops`") -> num_rows;
$k_page = k_page($count,10);
$page = page($k_page);
$start = 10 * $page - 10;
$sql = $base -> query("SELECT * FROM `drops` ORDER BY `id` ASC LIMIT $start,10");
if($count > 0){
while($drop = $sql -> fetch_assoc()){
$mob = $base -> query('SELECT * FROM `mobs` WHERE `id` = "'.$drop['mob'].'"') -> fetch_assoc();
$item = $base -> query('SELECT * FROM `items` WHERE `id` = "'.$drop['item'].'"') -> fetch_assoc();
$chance = $drop['chance'] / 100;
echo '<a class="btn" style="width: 90%; display: inline-block;" href="/panel/drops/'.$drop['id'].'/"><img src="/images/icons/money_bag.png"> '.$mob['name'].' - '.$item['name'].' ('.$chance.'%)</a> <a class="btn" style="display: inline-block" href="/panel/drops/'.$drop['id'].'/delete/"><img src="/images/icons/no.png"></a>';
}
if($count > '10'){
echo str('?',$k_page,$page);
}
}else{
echo '<br/><center>Дропов нет.</center>';
}
echo '<br/><a class="btn" href="/panel/drops/new/"><img src="/images/icons/admin.png"> Добавить дроп</a>';
break;
case 'new':
if(isset($_REQUEST['success'])){
$mob = fl($_POST['mob']);
$item = fl($_POST['item']);
$chance = fl($_POST['chance']);
if(empty($mob)) error('Введите ID моба.');
elseif(empty($item)) error('Введите ID предмета.');
elseif(empty($chance)) error('Введите шанс выпадения.');
else{
$base -> query("INSERT INTO `drops` SET
`mob` = '$mob',
`item` = '$item',
`chance` = '$chance'");
$_SESSION['message'] = 'Дроп успешно добавлен.';
header('location: /panel/drops/');
exit;
}
}
echo '<div class="title">Добавить дроп</div>';
echo '<center>';
echo '<form action="" method="POST">';
echo 'ID моба:<br/>';
echo '<input type="text" name="mob" /> <br/>';
echo 'ID предмета: <br/>';
echo '<input type="text" name="item" /> <br/>';
echo 'Шанс дропа: (0-10000, 1% = 100) <br/>';
echo '<input type="text" name="chance" /> <br/>';
echo '<input type="submit" name="success" value="Добавить">';
echo '</form>';
echo '</center>';
echo '<a class="btn" href="/panel/drops/"><img src="/images/icons/back.png"> Назад</a>';
break;
case 'edit':
$id = fl($_GET['id']);
$drop = $base -> query('SELECT * FROM `drops` WHERE `id` = "'.$id.'"') -> fetch_assoc();
if(isset($_REQUEST['success'])){
$mob = fl($_POST['mob']);
$item = fl($_POST['item']);
$chance = fl($_POST['chance']);
if(empty($mob)) error('Введите ID моба.');
elseif(empty($item)) error('Введите ID предмета.');
elseif(empty($chance)) error('Введите шанс выпадения.');
else{
$base -> query("UPDATE `drops` SET
`mob` = '$mob',
`item` = '$item',
`chance` = '$chance' WHERE `id` = '".$drop['id']."' ");
$_SESSION['message'] = 'Дроп успешно сохранен.';
header('location: /panel/drops/');
exit;
}
}
echo '<div class="title">'.$drop['name'].'</div>';
echo '<center>';
echo '<form action="" method="POST">';
echo 'ID моба:<br/>';
echo '<input type="text" name="mob" value="'.$drop['mob'].'" /> <br/>';
echo 'ID предмета: <br/>';
echo '<input type="text" name="item" value="'.$drop['item'].'" /> <br/>';
echo 'Шанс дропа: (0-10000, 1% = 100) <br/>';
echo '<input type="text" name="chance" value="'.$drop['chance'].'" /> <br/>';
echo '<input type="submit" name="success" value="Сохранить">';
echo '</form>';
echo '</center>';
echo '<a class="btn" href="/panel/drops/"><img src="/images/icons/back.png"> Назад</a>';
break;
case 'delete':
$id = fl($_GET['id']);
$drop = $base -> query('SELECT * FROM `drops` WHERE `id` = "'.$id.'"') -> fetch_assoc();
if($drop > 0) $base -> query('DELETE FROM `drops` WHERE `id` = "'.$drop['id'].'"');
$_SESSION['message'] = 'Дроп успешно удален.';
header('location: /panel/drops/');
exit;
break;
}
echo '</div>';
}else{
header('Location: /panel/');
exit;
}
include_once ('../core/foot.php');
?>