= $config['site']['access_admin_panel']) {
$offertype = $_REQUEST['offer_type'];
if((empty($action)) AND (empty($offertype))) {
$main_content .= '
ADD SHOP OFFER
VIEW SHOP OFFER (EDIT/DELETE)
ADD POINTS';
}
if($action == "addoffer"){
$shop_points = stripslashes(ucwords(strtolower(trim($_REQUEST['shop_points']))));
$shop_offer_type = stripslashes(trim($_REQUEST['offer_type']));
if(empty($shop_points)) {
$main_content .= '
| Select offer type: |
| Item | Container | Pacc | Redskull |
Unban | Changename | |
|
';
$main_content .= '
';
$main_content .= '';
} else {
$shop_points = stripslashes(trim($_POST['shop_points']));
$shop_offer_type = stripslashes(trim($_REQUEST['offer_type']));
$shop_itemid1 = stripslashes(trim($_POST['shop_itemid1']));
$shop_count1 = stripslashes(trim($_POST['shop_count1']));
$shop_itemid2 = stripslashes(trim($_POST['shop_itemid2']));
$shop_count2 = stripslashes(trim($_POST['shop_count2']));
$shop_offer_description = stripslashes(trim($_POST['shop_offer_description']));
$shop_offer_name = stripslashes(trim($_POST['shop_offer_name']));
$SQL->query('INSERT INTO `z_shop_offer` (id, points, itemid1, count1, itemid2, count2, offer_type, offer_description, offer_name, pid) VALUES (NULL, '.$SQL->quote($shop_points).', '.$SQL->quote($shop_itemid1).', '.$SQL->quote($shop_count1).', '.$SQL->quote($shop_itemid2).', '.$SQL->quote($shop_count2).', '.$SQL->quote($shop_offer_type).', '.$SQL->quote($shop_offer_description).', '.$SQL->quote($shop_offer_name).', 0)');
$main_content .= 'Added to Shop:
| Points: |
'.$shop_points.' |
';
if($shop_offer_type == 'container'){
$main_content .= '| Container ID: |
'.$shop_itemid1.' |
| Count Container: |
'.$shop_count1.' |
| Item ID (in Container): |
'.$shop_itemid2.' |
| Count Item (in Container): |
'.$shop_count2.' |
';
}
if ($shop_offer_type == 'item'){
$main_content .= '| Item ID: |
'.$shop_itemid1.' |
| Count Item: |
'.$shop_count1.' |
';
}
if ($shop_offer_type == 'pacc'){
$main_content .= '| Days: |
'.$shop_count1.' |
';
}
$main_content .= '| Offer Type: |
'.$shop_offer_type.' |
| Offer Description: |
'.$shop_offer_description.' |
| Offer Name: |
'.$shop_offer_name.' |
';
}
}
if($action == "viewoffer") {
$items = simplexml_load_file($config['site']['server_path'].'/data/items/items.xml') or die('Could not load items!');
foreach($items->item as $v)
$itemList[(int)$v['id']] = $v['name'];
$order = array("id" => "id", "points" => "points", "offer_type" => "offer_type", "itemid1" => "itemid1", "itemid2" => "itemid2");
$main_content .= '| ID: | Points: |
Item ID: | Count: | Container ID: | Count: | Offer Type: |
Offer Description: | Offer Name: | |
';
$shopoffers = $SQL->query('SELECT id, points, itemid1, count1, itemid2, count2, offer_type, offer_description, offer_name, pid FROM z_shop_offer ' . makeOrder($order, 'order', 'id'));
foreach($shopoffers as $shop) {
$main_content .= '| '.$shop['id'].' | '.$shop['points'].' | ';
if($shop['itemid1'] == "0") {
$main_content .= ''.$shop['itemid1'].'
| ';
} else {
$main_content .= ''.$shop['itemid1'].' (' . $itemList[(int)$shop['itemid1']] . ') | ';
}
$main_content .= ''.$shop['count1'].' | ';
if($shop['itemid2'] == "0") {
$main_content .= ''.$shop['itemid2'].' | ';
} else {
$main_content .= ''.$shop['itemid2'].' (' . $itemList[(int)$shop['itemid2']] . ') | ';
}
$main_content .= ''.$shop['count2'].' | '.$shop['offer_type'].' | '.$shop['offer_description'].' | '.$shop['offer_name'].' | ';
$main_content .= '
 | ';
}
$main_content .= '
';
}
if($action == "deleteoffer") {
$id = (int) $_REQUEST['id'];
$SQL->query('DELETE FROM z_shop_offer WHERE id = '.$id.' LIMIT 1;');
$main_content .= 'Shop offer has been deleted.
';
}
if($action == "editoffer") {
$id = (int) $_REQUEST['id'];
$shopoffers = $SQL->query('SELECT * FROM z_shop_offer WHERE id = '.$id.' LIMIT 1;');
foreach($shopoffers as $shop) {
$main_content .= '';
}
}
if($action == "edited") {
$id = (int) $_REQUEST['id'];
$shop_points = stripslashes(trim($_POST['shop_points']));
$shop_offer_type = stripslashes(trim($_POST['shop_offer_type']));
$shop_itemid1 = stripslashes(trim($_POST['shop_itemid1']));
$shop_count1 = stripslashes(trim($_POST['shop_count1']));
$shop_itemid2 = stripslashes(trim($_POST['shop_itemid2']));
$shop_count2 = stripslashes(trim($_POST['shop_count2']));
$shop_offer_description = stripslashes(trim($_POST['shop_offer_description']));
$shop_offer_name = stripslashes(trim($_POST['shop_offer_name']));
$SQL->query('UPDATE `z_shop_offer` SET `points` = '.$shop_points.', `itemid1` = '.$SQL->quote($shop_itemid1).', `count1` = '.$SQL->quote($shop_count1).', `itemid2` = '.$SQL->quote($shop_itemid2).', `count2` = '.$SQL->quote($shop_count2).', `offer_type` = '.$SQL->quote($shop_offer_type).', `offer_description` = '.$SQL->quote($shop_offer_description).', `offer_name` = '.$SQL->quote($shop_offer_name).' WHERE `id` = '.$id.';');
$main_content .= 'Shop offer successfully edited.
';
}
if($action == "points") {
$player = stripslashes(ucwords(strtolower(trim($_REQUEST['character']))));
$points = $_POST['points'];
if(empty($player)) {
$main_content .= '';
} else {
$player_data = $SQL->query("SELECT * FROM `players` WHERE `name` = '".$player."';")->fetch();
$SQL->query("UPDATE `accounts` SET `premium_points` = `premium_points` + '".$points."' WHERE `id` = '".$player_data['account_id']."'");
$main_content .= ''.$points.' Premium Points added to the account of '.$player.' !
';
}
}
} else {
$main_content .= 'Sorry, you have not the rights to access this page.';
}
?>