Guest User

Untitled

a guest
Jun 18th, 2011
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 39.54 KB | None | 0 0
  1. <?PHP
  2. //  ALTER TABLE `z_shop_history_item` CHANGE `offer_id` `offer_id` VARCHAR( 255 ) NOT NULL;
  3. // UPDATE `z_shop_history_item`, `z_shop_offer` SET `z_shop_history_item`.`offer_id` = `z_shop_offer`.`offer_name` WHERE `z_shop_history_item`.`offer_id` = `z_shop_offer`.`id`;
  4. if($config['site']['shop_system'] == 1) {
  5.     if($logged)
  6.         $user_premium_points = $account_logged->getCustomField('premium_points');
  7.     else
  8.         $user_premium_points = 'Login first';
  9.  
  10. function getItemByID($id)
  11. {
  12.   $id = (int) $id;
  13.   $SQL = $GLOBALS['SQL'];
  14.   $data = $SQL->query('SELECT * FROM '.$SQL->tableName('z_shop_offer').' WHERE '.$SQL->fieldName('id').' = '.$SQL->quote($id).';')->fetch();
  15.   if ($data['offer_type'] == 'pacc')
  16.   {
  17.     $offer['id'] = $data['id'];
  18.     $offer['type'] = $data['offer_type'];
  19.     $offer['days'] = $data['count1'];
  20.     $offer['points'] = $data['points'];
  21.     $offer['description'] = $data['offer_description'];
  22.     $offer['name'] = $data['offer_name'];
  23.   }
  24.   elseif ($data['offer_type'] == 'item')
  25.   {
  26.     $offer['id'] = $data['id'];
  27.     $offer['type'] = $data['offer_type'];
  28.     $offer['item_id'] = $data['itemid1'];
  29.     $offer['item_count'] = $data['count1'];
  30.     $offer['points'] = $data['points'];
  31.     $offer['description'] = $data['offer_description'];
  32.     $offer['name'] = $data['offer_name'];
  33.   }
  34.   elseif ($data['offer_type'] == 'container')
  35.   {
  36.     $offer['id'] = $data['id'];
  37.     $offer['type'] = $data['offer_type'];
  38.     $offer['container_id'] = $data['itemid2'];
  39.     $offer['container_count'] = $data['count2'];
  40.     $offer['item_id'] = $data['itemid1'];
  41.     $offer['item_count'] = $data['count1'];
  42.     $offer['points'] = $data['points'];
  43.     $offer['description'] = $data['offer_description'];
  44.     $offer['name'] = $data['offer_name'];
  45.   }
  46.   elseif ($data['offer_type'] == 'unban')
  47.   {
  48.     $offer['id'] = $data['id'];
  49.     $offer['type'] = $data['offer_type'];
  50.     $offer['points'] = $data['points'];
  51.     $offer['description'] = $data['offer_description'];
  52.     $offer['name'] = $data['offer_name'];
  53.   }
  54.   elseif ($data['offer_type'] == 'redskull')
  55.   {
  56.     $offer['id'] = $data['id'];
  57.     $offer['type'] = $data['offer_type'];
  58.     $offer['points'] = $data['points'];
  59.     $offer['description'] = $data['offer_description'];
  60.     $offer['name'] = $data['offer_name'];
  61.   }
  62.   elseif ($data['offer_type'] == 'itemlogout')
  63.   {
  64.     $offer['id'] = $data['id'];
  65.     $offer['type'] = $data['offer_type'];
  66.     $offer['points'] = $data['points'];
  67.     $offer['description'] = $data['offer_description'];
  68.     $offer['pid'] = $data['pid'];
  69.     $offer['count1'] = $data['count1'];
  70.     $offer['item_id'] = $data['itemid1'];
  71.     $offer['free_cap'] = $data['free_cap'];
  72.   }
  73.   elseif ($data['offer_type'] == 'changename')
  74.   {
  75.     $offer['id'] = $data['id'];
  76.     $offer['type'] = $data['offer_type'];
  77.     $offer['points'] = $data['points'];
  78.     $offer['description'] = $data['offer_description'];
  79.     $offer['name'] = $data['offer_name'];
  80.   }
  81.   return $offer;
  82. }
  83.  
  84. function getOfferArray()
  85. {
  86.   $offer_list = $GLOBALS['SQL']->query('SELECT * FROM '.$GLOBALS['SQL']->tableName('z_shop_offer').';');
  87.   $i_pacc = 0;
  88.   $i_item = 0;
  89.   $i_container = 0;
  90.   $i_unban = 0;
  91.   $i_redskull = 0;
  92.   $i_itemlogout = 0;
  93.   $i_changename = 0;
  94.   while($data = $offer_list->fetch()) {
  95.     if ($data['offer_type'] == 'pacc')
  96.     {
  97.       $offer_array['pacc'][$i_pacc]['id'] = $data['id'];
  98.       $offer_array['pacc'][$i_pacc]['days'] = $data['count1'];
  99.       $offer_array['pacc'][$i_pacc]['points'] = $data['points'];
  100.       $offer_array['pacc'][$i_pacc]['description'] = $data['offer_description'];
  101.       $offer_array['pacc'][$i_pacc]['name'] = $data['offer_name'];
  102.       $i_pacc++;
  103.     }
  104.     elseif ($data['offer_type'] == 'item')
  105.     {
  106.       $offer_array['item'][$i_item]['id'] = $data['id'];
  107.       $offer_array['item'][$i_item]['item_id'] = $data['itemid1'];
  108.       $offer_array['item'][$i_item]['item_count'] = $data['count1'];
  109.       $offer_array['item'][$i_item]['points'] = $data['points'];
  110.       $offer_array['item'][$i_item]['description'] = $data['offer_description'];
  111.       $offer_array['item'][$i_item]['name'] = $data['offer_name'];
  112.       $i_item++;
  113.     }
  114.     elseif ($data['offer_type'] == 'container')
  115.     {
  116.       $offer_array['container'][$i_container]['id'] = $data['id'];
  117.       $offer_array['container'][$i_container]['container_id'] = $data['itemid2'];
  118.       $offer_array['container'][$i_container]['container_count'] = $data['count2'];
  119.       $offer_array['container'][$i_container]['item_id'] = $data['itemid1'];
  120.       $offer_array['container'][$i_container]['item_count'] = $data['count1'];
  121.       $offer_array['container'][$i_container]['points'] = $data['points'];
  122.       $offer_array['container'][$i_container]['description'] = $data['offer_description'];
  123.       $offer_array['container'][$i_container]['name'] = $data['offer_name'];
  124.       $i_container++;
  125.     }
  126.     elseif ($data['offer_type'] == 'unban')
  127.     {
  128.       $offer_array['unban'][$i_unban]['id'] = $data['id'];
  129.       $offer_array['unban'][$i_unban]['points'] = $data['points'];
  130.       $offer_array['unban'][$i_unban]['description'] = $data['offer_description'];
  131.       $offer_array['unban'][$i_unban]['name'] = $data['offer_name'];
  132.       $i_unban++;
  133.     }
  134.     elseif ($data['offer_type'] == 'redskull')
  135.     {
  136.       $offer_array['redskull'][$i_redskull]['id'] = $data['id'];
  137.       $offer_array['redskull'][$i_redskull]['points'] = $data['points'];
  138.       $offer_array['redskull'][$i_redskull]['description'] = $data['offer_description'];
  139.       $offer_array['redskull'][$i_redskull]['name'] = $data['offer_name'];
  140.       $i_redskull++;
  141.     }
  142.     elseif ($data['offer_type'] == 'itemlogout')
  143.     {
  144.       $offer_array['itemlogout'][$i_itemlogout]['id'] = $data['id'];
  145.       $offer_array['itemlogout'][$i_itemlogout]['points'] = $data['points'];
  146.       $offer_array['itemlogout'][$i_itemlogout]['description'] = $data['offer_description'];
  147.       $offer_array['itemlogout'][$i_itemlogout]['name'] = $data['offer_name'];
  148.       $offer_array['itemlogout'][$i_itemlogout]['count1'] = $data['count1'];
  149.       $offer_array['itemlogout'][$i_itemlogout]['pid'] = $data['pid'];
  150.       $offer_array['itemlogout'][$i_itemlogout]['item_id'] = $data['itemid1'];
  151.       $offer_array['itemlogout'][$i_itemlogout]['free_cap'] = $data['free_cap'];
  152.       $i_itemlogout++;
  153.     }
  154.     elseif ($data['offer_type'] == 'changename')
  155.     {
  156.       $offer_array['changename'][$i_changename]['id'] = $data['id'];
  157.       $offer_array['changename'][$i_changename]['points'] = $data['points'];
  158.       $offer_array['changename'][$i_changename]['description'] = $data['offer_description'];
  159.       $offer_array['changename'][$i_changename]['name'] = $data['offer_name'];
  160.       $i_changename++;
  161.     }
  162.   }
  163.   return $offer_array;
  164. }
  165.  
  166.     if($action == '') {
  167.         unset($_SESSION['viewed_confirmation_page']);
  168.         $main_content .= '<h2><center>Welcome to '.$config['server']['serverName'].' Shop.</center></h2>';
  169.         $offer_list = getOfferArray();
  170.             //show list of items offers
  171.             if(count($offer_list['item']) > 0 or count($offer_list['container']) > 0 or count($offer_list['itemlogout']) > 0)
  172.                 $main_content .= '<center><table border="0" cellpadding="1" cellspacing="1" width="100%"><tr width="1024" bgcolor="'.$config['site']['vdarkborder'].'"><td colspan="3"><font color="white" size="4"><b>&nbsp;ITEMS</b></font></td></tr><tr bgcolor="'.$config['site']['darkborder'].'"><td width="50" align="center"><b>Picture</b></td><td width="350" align="left"><b>Description</b></td><td width="250" align="center"><b>Select product</b></td></tr>';
  173.                 if(count($offer_list['item']) > 0) {
  174.                     foreach($offer_list['item'] as $item) {
  175.                         $main_content .= '<tr bgcolor="'.$config['site']['lightborder'].'"><td align="center"><img src="/images/item_images/'.$item['id'].'.gif"></td><td><b>'.$item['name'].'</b> ('.$item['points'].' points)<br />'.$item['description'].'</td><td align="center">';
  176.                         if(!$logged) $main_content .= '<b>Login to choose</b>'; else
  177.                         $main_content .= '<form action="index.php?subtopic=shopsystem&action=select_player" method=POST><input type="hidden" name="buy_id" value="'.$item['id'].'"><input type="submit" value="Choose '.$item['name'].'"><br><b>for '.$item['points'].' points</b></form>';
  178.                         $main_content .= '</td></tr>';
  179.                     }
  180.                     $main_content .= '</table><br />';
  181.                 }
  182.                 //show list of containers offers
  183.                 if(count($offer_list['container']) > 0) {
  184.                     $main_content .= '<table border="0" cellpadding="1" cellspacing="1" width="100%"><tr width="530" bgcolor="'.$config['site']['vdarkborder'].'"><td colspan="3"><font color="white" size="4"><b>&nbsp;CONTAINERS WITH ITEMS</b></font></td></tr><tr bgcolor="'.$config['site']['darkborder'].'"><td width="50" align="center"><b>Picture</b></td><td width="350" align="left"><b>Description</b></td><td width="250" align="center"><b>Select product</b></td></tr>';
  185.                     foreach($offer_list['container'] as $container) {
  186.                         $main_content .= '<tr bgcolor="'.$config['site']['lightborder'].'"><td align="center"><img src="/images/item_images/'.$container['id'].'.gif"></td><td><b>'.$container['name'].'</b> ('.$container['points'].' points)<br />'.$container['description'].'</td><td align="center">';
  187.                         if(!$logged) $main_content .= '<b>Login to Choose</b>'; else
  188.                         $main_content .= '<form action="?subtopic=shopsystem&action=select_player" method=POST><input type="hidden" name="buy_id" value="'.$container['id'].'"><input type="submit" value="Choose '.$container['name'].'"><br><b>for '.$container['points'].' points</b></form>';
  189.                         $main_content .= '</td></tr>';
  190.                     }
  191.                     $main_content .= '</table><br />';
  192.                 }
  193.                 if(count($offer_list['itemlogout']) > 0) {
  194.                     $main_content .= '<table border="0" cellpadding="1" cellspacing="1" width="530"><tr width="530" bgcolor="'.$config['site']['vdarkborder'].'"><td colspan="3"><font color="white" size="4"><b>&nbsp;Receive Item on Logout</b></font></td></tr><tr bgcolor="'.$config['site']['darkborder'].'"><td width="50" align="center"><b>Picture</b></font></td><td width="350" align="left"><b>Description</b></font></td><td width="250" align="center"><b>Select product</b></font></td></tr>';
  195.                     foreach($offer_list['itemlogout'] as $itemlogout) {
  196.                         $main_content .= '<tr bgcolor="'.$config['site']['lightborder'].'"><td align="center"><img src="/images/item_images/'.$itemlogout['id'].'.gif"></td><td><b>'.$itemlogout['name'].'</b> ('.$itemlogout['points'].' points)<br />'.$itemlogout['description'].'</td><td align="center">';
  197.                         if(!$logged) $main_content .= '<b>Login to Choose</b>'; else
  198.                         $main_content .= '<form action="index.php?subtopic=shopsystem&action=select_player" method=POST><input type="hidden" name="buy_id" value="'.$itemlogout['id'].'"><input type="submit" value="Choose '.$itemlogout['name'].'"><br><b>for '.$itemlogout['points'].' points</b></form>';
  199.                         $main_content .= '</td></tr>';
  200.                     }
  201.                     $main_content .= '</table><br />';
  202.                 }
  203.             if(count($offer_list['changename']) > 0 or count($offer_list['pacc']) > 0 or count($offer_list['redskull']) > 0 or count($offer_list['unban']) > 0 )
  204.                 $main_content .= '<center><table border="0" cellpadding="1" cellspacing="1" width="100%"><tr width="530" bgcolor="'.$config['site']['vdarkborder'].'"><td colspan="3"><font color="white" size="4"><b>&nbsp;Others</b></font></td></tr><tr bgcolor="'.$config['site']['darkborder'].'"><td width="50" align="center"><b>#</b></td><td width="350" align="left"><b>Description</b></td><td width="250" align="center"><b>Select product</b></td></tr>';
  205.                 //Pacc
  206.                 if(count($offer_list['pacc']) > 0)
  207.                     foreach($offer_list['pacc'] as $pacc) {
  208.                         $main_content .= '<tr bgcolor="'.$config['site']['lightborder'].'"><td align="center">'.$pacc['days'].'</td><td><b>'.$pacc['name'].'</b> ('.$pacc['points'].' points)<br />'.$pacc['description'].'</td><td align="center">';
  209.                         if(!$logged) $main_content .= '<b>Login to Choose</b>'; else
  210.                         $main_content .= '<form action="index.php?subtopic=shopsystem&action=select_player" method=POST><input type="hidden" name="buy_id" value="'.$pacc['id'].'"><input type="submit" value="Choose '.$pacc['name'].'"><br><b>for '.$pacc['points'].' points</b></form>';
  211.                     }
  212.                 //Change Name
  213.                 if(count($offer_list['changename']) > 0)
  214.                     foreach($offer_list['changename'] as $changename) {
  215.                         $main_content .= '<tr bgcolor="'.$config['site']['lightborder'].'"><td align="center">Change Name</td><td><b>'.$changename['name'].'</b> ('.$changename['points'].' points)<br />'.$changename['description'].'</td><td align="center">';
  216.                         if(!$logged) $main_content .= '<b>Login to Choose</b>'; else
  217.                         $main_content .= '<form action="index.php?subtopic=shopsystem&action=select_player" method=POST><input type="hidden" name="buy_id" value="'.$changename['id'].'"><input type="submit" value="Choose '.$changename['name'].'"><br><b>for '.$changename['points'].' points</b></form>';
  218.                     }
  219.                 //Remove Red Skull
  220.                 if(count($offer_list['redskull']) > 0)
  221.                     foreach($offer_list['redskull'] as $redskull) {
  222.                         $main_content .= '<tr bgcolor="'.$config['site']['lightborder'].'"><td align="center"><img src="/images/item_images/'.$redskull['id'].'.gif"></td><td><b>'.$redskull['name'].'</b> ('.$redskull['points'].' points)<br />'.$redskull['description'].'</td><td align="center">';
  223.                         if(!$logged) $main_content .= '<b>Login to buy</b>'; else
  224.                         $main_content .= '<form action="index.php?subtopic=shopsystem&action=select_player" method=POST><input type="hidden" name="buy_id" value="'.$redskull['id'].'"><input type="submit" value="Buy '.$redskull['name'].'"><br><b>for '.$redskull['points'].' points</b></form>';
  225.                         $main_content .= '</td></tr>';
  226.                     }
  227.                 //Unban
  228.                 if(count($offer_list['unban']) > 0)
  229.                     foreach($offer_list['unban'] as $unban){
  230.                         $main_content .= '<tr bgcolor="'.$config['site']['lightborder'].'"><td align="center">Unban</td><td><b>'.$unban['name'].'</b> ('.$unban['points'].' points)<br />'.$unban['description'].'</td><td align="center">';
  231.                         if(!$logged) $main_content .= '<b>Login to buy</b>'; else
  232.                         $main_content .= '<form action="index.php?subtopic=shopsystem&action=select_player" method=POST><input type="hidden" name="buy_id" value="'.$unban['id'].'"><input type="submit" value="Buy '.$unban['name'].'"><br><b>for '.$unban['points'].' points</b></form>';
  233.                         $main_content .= '</td></tr>';
  234.                     }
  235.                     $main_content .= '</table>';
  236.     }
  237.     elseif($action == 'select_player') {
  238.         unset($_SESSION['viewed_confirmation_page']);
  239.         if(!$logged) {
  240.             $main_content .= 'Please login first.';
  241.         } else {
  242.             $buy_id = (int) $_REQUEST['buy_id'];
  243.             if(empty($buy_id)) {
  244.                 $main_content .= 'Please <a href="index.php?subtopic=shopsystem">select item</a> first.';
  245.             } else {
  246.                 $buy_offer = getItemByID($buy_id);
  247.                 if(isset($buy_offer['id'])) {  //item exist in database
  248.                     if($buy_offer['type'] != 'changename') {
  249.                         if($user_premium_points >= $buy_offer['points']) {
  250.                             $main_content .= '<center><h2>Select player</h2><table border="0" cellpadding="1" cellspacing="1" width="530">
  251.                                 <tr bgcolor="'.$config['site']['vdarkborder'].'"><td colspan="2"><font color="white" size="4"><b>Selected offer</b></font></td></tr>
  252.                                 <tr bgcolor="'.$config['site']['lightborder'].'"><td width="100"><b>Name:</b></td><td width="550">'.$buy_offer['name'].'</td></tr>
  253.                                 <tr bgcolor="'.$config['site']['darkborder'].'"><td width="100"><b>Description:</b></td><td width="550">'.$buy_offer['description'].'</td></tr>
  254.                                 </table><br /><form action="index.php?subtopic=shopsystem&action=confirm_transaction" method=POST><input type="hidden" name="buy_id" value="'.$buy_id.'">
  255.                                 <table border="0" cellpadding="1" cellspacing="1" width="530">
  256.                                 <tr bgcolor="'.$config['site']['vdarkborder'].'"><td colspan="2"><font color="white" size="4"><b>Give item to a player from your account</b></font></td></tr>
  257.                                 <tr bgcolor="'.$config['site']['lightborder'].'"><td width="110"><b>Name:</b></td><td width="550"><select name="buy_name">';
  258.                                 $players_from_logged_acc = $account_logged->getPlayersList();
  259.                             if(count($players_from_logged_acc) > 0) {
  260.                                 $players_from_logged_acc->orderBy('name');
  261.                                 foreach($players_from_logged_acc as $player)
  262.                                     $main_content .= '<option>'.$player->getName().'</option>';
  263.                             } else {
  264.                                 $main_content .= 'You don\'t have any character on your account.';
  265.                             }
  266.                             $main_content .= '</select>&nbsp;<input type="submit" value="Give"></td></tr></table>
  267.                                 </form><br /><form action="index.php?subtopic=shopsystem&action=confirm_transaction" method=POST><input type="hidden" name="buy_id" value="'.$buy_id.'">
  268.                                 <table border="0" cellpadding="1" cellspacing="1" width="530">
  269.                                 <tr bgcolor="'.$config['site']['vdarkborder'].'"><td colspan="2"><font color="white" size="4"><b>Give item to other player</b></font></td></tr>
  270.                                 <tr bgcolor="'.$config['site']['darkborder'].'"><td width="110"><b>To player:</b></td><td width="550"><input type="text" name="buy_name"> - name of the player who should get item</td></tr>
  271.                                 <tr bgcolor="'.$config['site']['lightborder'].'"><td width="110"><b>From:</b></td><td width="550"><input type="text" name="buy_from">&nbsp;<input type="submit" value="Give"> - your nick, \'empty\' = Anonymous</td></tr>
  272.                                 </table><br /></form>';
  273.                         } else {
  274.                             $main_content .= 'For this item you need <b>'.$buy_offer['points'].'</b> points.<br>You have only <b>'.$user_premium_points.'</b> premium points. Please <a href="index.php?subtopic=shopsystem">select other item</a> or buy premium points.';
  275.                         }
  276.                     } else {
  277.                     $main_content .= '<center><h2>Change Name</h2><form action="index.php?subtopic=shopsystem&action=confirm_transaction" method=POST><input type="hidden" name="buy_id" value="'.$buy_id.'">
  278.                         <table border="0" cellpadding="1" cellspacing="1" width="530"><tr bgcolor="'.$config['site']['vdarkborder'].'"><td colspan="2"><font color="white" size="4"><b>Change Name:</b></font></td></tr>
  279.                         <tr bgcolor="'.$config['site']['darkborder'].'"><td width="110"><b>Name:</b></td><td width="550"><select name="buy_name">';
  280.                     $players_from_logged_acc = $account_logged->getPlayersList();
  281.                         if(count($players_from_logged_acc) > 0) {
  282.                             $players_from_logged_acc->orderBy('name');
  283.                             foreach($players_from_logged_acc as $player) {
  284.                                 $main_content .= '<option>'.$player->getName().'</option>';
  285.                             }
  286.                         } else {
  287.                             $main_content .= 'You don\'t have any character on your account.';
  288.                         }
  289.                         $main_content .= '</select></td></tr><tr bgcolor="'.$config['site']['lightborder'].'"><td width="110"><b>New name:</b></td><td width="550"><input type="text" name="buy_from">&nbsp;<input type="submit" value="Change Name"></td></tr></table><br /></form>';
  290.                     }
  291.                 } else {
  292.                         $main_content .= 'Offer with ID <b>'.$buy_id.'</b> doesn\'t exist. Please <a href="index.php?subtopic=shopsystem">select item</a> again.';
  293.                 }
  294.             }
  295.         }
  296.     }
  297.     elseif($action == 'confirm_transaction') {
  298.         if(!$logged) {
  299.             $main_content .= 'Please login first.';
  300.         } else {
  301.             $buy_id = (int) $_POST['buy_id'];
  302.             $buy_name = stripslashes(urldecode($_POST['buy_name']));
  303.             $buy_from = stripslashes(urldecode($_POST['buy_from']));
  304.             if(empty($buy_id)) {
  305.                 $main_content .= 'Please <a href="index.php?subtopic=shopsystem">select item</a> first.';
  306.             } else {
  307.                 if($buy_offer['type'] == 'changename'){
  308.                     if(!check_name_new_char($buy_from)) {
  309.                         $main_content .= 'Invalid name format of new name.';
  310.                     }
  311.                 } else {
  312.                     $buy_offer = getItemByID($buy_id);
  313.                     $check_name_in_database = $ots->createObject('Player');
  314.                     $check_name_in_database->find($buy_from);
  315.                     if($buy_offer['type'] == 'changename'){
  316.                         if(!$check_name_in_database->isLoaded()) {
  317.                         }
  318.                     }
  319.                     if(isset($buy_offer['id'])) {  //item exist in database
  320.                         if($user_premium_points >= $buy_offer['points']) {
  321.                             if(check_name($buy_name)) {
  322.                                 $buy_player = new OTS_Player();
  323.                                 $buy_player->find($buy_name);
  324.                                 if($buy_player->isLoaded()) {
  325.                                     $buy_player_account = $buy_player->getAccount();
  326.                                     if($_SESSION['viewed_confirmation_page'] == 'yes' && $_POST['buy_confirmed'] == 'yes') {
  327.                                         if($buy_offer['type'] == 'pacc') {
  328.                                             $player_premdays = $buy_player_account->getCustomField('premdays');
  329.                                             $player_lastlogin = $buy_player_account->getCustomField('lastday');
  330.                                             $save_transaction = 'INSERT INTO '.$SQL->tableName('z_shop_history_pacc').' (id, to_name, to_account, from_nick, from_account, price, pacc_days, trans_state, trans_start, trans_real) VALUES (NULL, '.$SQL->quote($buy_player->getName()).', '.$SQL->quote($buy_player_account->getId()).', '.$SQL->quote($buy_from).',  '.$SQL->quote($account_logged->getId()).', '.$SQL->quote($buy_offer['points']).', '.$SQL->quote($buy_offer['days']).', \'realized\', '.$SQL->quote(time()).', '.$SQL->quote(time()).');';
  331.                                             $SQL->query($save_transaction);
  332.                                             $buy_player_account->setCustomField('premdays', $player_premdays+$buy_offer['days']);
  333.                                             $account_logged->setCustomField('premium_points', $user_premium_points-$buy_offer['points']);
  334.                                             $user_premium_points = $user_premium_points - $buy_offer['points'];
  335.                                             if($player_premdays == 0) {
  336.                                                 $buy_player_account->setCustomField('lastday', time());
  337.                                             }
  338.                                             $main_content .= '<center><h2>Premium ACcount added!</h2><b>'.$buy_offer['days'].' days</b> of Premium Account added to the account of player <b>'.$buy_player->getName().'</b> for <b>'.$buy_offer['points'].' premium points</b> from your account.<br />Now you have <b>'.$user_premium_points.' premium points</b>.<br><br><a href="index.php?subtopic=shopsystem">Go to Shop Site</a><br>';
  339.                                             }
  340.                                         elseif($buy_offer['type'] == 'unban') {
  341.                                             $my_acc_id = $account_logged->getCustomField('id');
  342.                                             $datadata = $SQL->query('SELECT * FROM '.$SQL->tableName('bans').' WHERE value = '.$my_acc_id.';')->fetch();
  343.                                                 if($datadata['value'] == $my_acc_id) {
  344.                                                     if($SQL->query('DELETE FROM bans WHERE value= '.$my_acc_id.' LIMIT 1;')) {
  345.                                                     } else {
  346.                                                         $SQL->query('DELETE FROM bans WHERE account= '.$my_acc_id.' LIMIT 1;');
  347.                                                     }
  348.                                                     $account_logged->setCustomField('premium_points', $user_premium_points-$buy_offer['points']);
  349.                                                     $user_premium_points = $user_premium_points - $buy_offer['points'];
  350.                                                     $main_content .= '<center><h2>Ban Deleted!</h2><b>Your account has been unbanned for '.$buy_offer['points'].' premium points</b> from your account.
  351.                                                         <br>Now you have <b>'.$user_premium_points.' premium points</b>.<br><br><a href="index.php?subtopic=shopsystem">Go to Shop Site</a><br>';
  352.                                                 } else {
  353.                                                     $main_content .= '<center><b>You don\'t have any bans in your account!</b><br><br><a href="index.php?subtopic=shopsystem">Go back</a><br>';
  354.                                                 }
  355.                                             }
  356.                                         ////////////////////////////////
  357.                                         elseif($buy_offer['type'] == 'itemlogout') {
  358.                                             $my_acc_id = $buy_player->getCustomField('id');
  359.                                             $playerinfo = $SQL->query('SELECT * FROM '.$SQL->tableName('players').' WHERE id = '.$my_acc_id.';')->fetch();
  360.                                             $playerslot = $SQL->query('SELECT * FROM '.$SQL->tableName('player_items').' WHERE player_id = '.$my_acc_id.';')->fetch();
  361.                                             if($playerinfo['online'] == '0') {
  362.                                                 if ($playerslot['pid'] != '10') {
  363.                                                     if ($datadata['cap'] >= $SQL->quote($buy_offer['free_cap'])) {
  364.                                                         $SQL->query('INSERT INTO player_items (player_id, pid, itemtype, count) VALUES ('.$my_acc_id.', '.$SQL->quote($buy_offer['pid']).', '.$SQL->quote($buy_offer['item_id']).', '.$SQL->quote($buy_offer['count1']).');');
  365.                                                         $account_logged->setCustomField('premium_points', $user_premium_points-$buy_offer['points']);
  366.                                                         $user_premium_points = $user_premium_points - $buy_offer['points'];
  367.                                                         $main_content .= '<h2>Item received to player: '.$buy_player->getName().'!</h2><br>Now you have <b>'.$user_premium_points.' premium points</b>.
  368.                                                             <br><a href="index.php?subtopic=shopsystem">Go to Shop Site</a>';
  369.                                                     } else {
  370.                                                         $main_content .= '<b>You need '.$SQL->quote($buy_offer['free_cap']).' or more of cap!</b><br><a href="index.php?subtopic=shopsystem">Go back</a>';
  371.                                                     }
  372.                                                 } else {
  373.                                                     $main_content .= '<b>Please leave the arrow slot in blank to receive item!</b><br><a href="index.php?subtopic=shopsystem">Go back</a>';
  374.                                                 }
  375.                                             } else {
  376.                                                 $main_content .= '<b>You need to be offline!</b><br><a href="index.php?subtopic=shopsystem">Go back</a>';
  377.                                             }
  378.                                         }
  379.                                         ////////////////////////////////
  380.                                         elseif($buy_offer['type'] == 'changename') {
  381.                                             $my_acc_id = $buy_player->getCustomField('id');
  382.                                             $playerinfo = $SQL->query('SELECT * FROM '.$SQL->tableName('players').' WHERE '.$SQL->fieldName('id').' = '.$my_acc_id.';')->fetch();
  383.                                             $checkname = $SQL->query('SELECT * FROM '.$SQL->tableName('players').' WHERE '.$SQL->fieldName('name').' = '. $SQL->quote($buy_from) .';')->fetch();
  384.                                             if($playerinfo['online'] == '0') {
  385.                                                 if($checkname == false) {
  386.                                                     $SQL->query('UPDATE `players` SET `name` = '. $SQL->quote($buy_from) .' WHERE `id` = '. $my_acc_id.' ;');
  387.                                                     $account_logged->setCustomField('premium_points', $user_premium_points-$buy_offer['points']);
  388.                                                     $user_premium_points = $user_premium_points - $buy_offer['points'];
  389.                                                     $main_content .= '<center><h2>Your name has been changed to '.$buy_from.'.</h2><br><b>You have '.$user_premium_points.' premium points left</b>.
  390.                                                         <br><br><a href="index.php?subtopic=shopsystem">Go to Shop Site</a><br>';
  391.                                                 } else {
  392.                                                     $main_content .= '<center><h2>Sorry, the name "<i>'.$buy_from.'</i>" does already exist.<br>Please select another name.</h2><br>';
  393.                                                 }
  394.                                             } else {
  395.                                                 $main_content .= '<center><h2>'.$buy_name.' has to be offline to complete transaction.</h2><br><br><a href="index.php?subtopic=shopsystem">Go back</a><br>';
  396.                                             }
  397.                                         }
  398.                                         ////////////////////////////////
  399.                                         elseif($buy_offer['type'] == 'redskull') {
  400.                                             $my_acc_id = $buy_player->getCustomField('id');
  401.                                             $playerinfo = $SQL->query('SELECT * FROM '.$SQL->tableName('players').' WHERE '.$SQL->fieldName('id').' = '.$my_acc_id.';')->fetch();
  402.                                             if($playerinfo['skull'] == '4' AND $playerinfo['online'] >= '0' AND $playerinfo['skulltime'] > '0') {
  403.                                                 $SQL->query('UPDATE killers SET unjustified=0 WHERE id IN (SELECT kill_id FROM player_killers WHERE player_id='. $my_acc_id .');');
  404.                                                 $SQL->query('UPDATE players SET skulltime=0, skull=0 WHERE id='. $my_acc_id .';');
  405.                                                 $account_logged->setCustomField('premium_points', $user_premium_points-$buy_offer['points']);
  406.                                                 $user_premium_points = $user_premium_points - $buy_offer['points'];
  407.                                                 $main_content .= '<center><h2>RedSkull Removed!</h2><br><b>Your redskull has been removed from the player '.$buy_player->getName().'.</b>
  408.                                                     <br>Now you have<b> '.$user_premium_points.' premium points</b>.<br><br><a href="index.php?subtopic=shopsystem">Go to Shop Site</a><br>';
  409.                                             } else {
  410.                                                 $main_content .= '<center><b>'.$buy_player->getName().' has to be offline or have redskull to complete transaction!.</b><br><br><a href="index.php?subtopic=shopsystem">Go back</a><br>';
  411.                                             }
  412.                                         }
  413.                                         //////////////////////////
  414.                                         elseif($buy_offer['type'] == 'item') {
  415.                                             $sql = 'INSERT INTO '.$SQL->tableName('z_ots_comunication').' (id, name, type, action, param1, param2, param3, param4, param5, param6, param7, delete_it) VALUES (NULL, '.$SQL->quote($buy_player->getName()).', \'login\', \'give_item\', '.$SQL->quote($buy_offer['item_id']).', '.$SQL->quote($buy_offer['item_count']).', \'\', \'\', \'item\', '.$SQL->quote($buy_offer['name']).', \'\', \'1\');';
  416.                                             $SQL->query($sql);
  417.                                             $save_transaction = 'INSERT INTO '.$SQL->tableName('z_shop_history_item').' (id, to_name, to_account, from_nick, from_account, price, offer_id, trans_state, trans_start, trans_real) VALUES ('.$SQL->lastInsertId().', '.$SQL->quote($buy_player->getName()).', '.$SQL->quote($buy_player_account->getId()).', '.$SQL->quote($buy_from).',  '.$SQL->quote($account_logged->getId()).', '.$SQL->quote($buy_offer['points']).', '.$SQL->quote($buy_offer['name']).', \'wait\', '.$SQL->quote(time()).', \'0\');';
  418.                                             $SQL->query($save_transaction);
  419.                                             $account_logged->setCustomField('premium_points', $user_premium_points-$buy_offer['points']);
  420.                                             $user_premium_points = $user_premium_points - $buy_offer['points'];
  421.                                             $main_content .= '<center><h2>Item added!</h2><b>'.$buy_offer['name'].'</b> added to player <b>'.$buy_player->getName().'</b> for <b>'.$buy_offer['points'].' premium points</b> from your account.<br>Now you have <b>'.$user_premium_points.' premium points</b>.<br><br><a href="index.php?subtopic=shopsystem">GO TO MAIN SHOP SITE</a><br>';
  422.                                         }
  423.                                         elseif($buy_offer['type'] == 'container') {
  424.                                             $sql = 'INSERT INTO '.$SQL->tableName('z_ots_comunication').' (id, name, type, action, param1, param2, param3, param4, param5, param6, param7, delete_it) VALUES (NULL, '.$SQL->quote($buy_player->getName()).', \'login\', \'give_item\', '.$SQL->quote($buy_offer['item_id']).', '.$SQL->quote($buy_offer['item_count']).', '.$SQL->quote($buy_offer['container_id']).', '.$SQL->quote($buy_offer['container_count']).', \'container\', '.$SQL->quote($buy_offer['name']).', \'\', \'1\');';
  425.                                             $SQL->query($sql);
  426.                                             $save_transaction = 'INSERT INTO '.$SQL->tableName('z_shop_history_item').' (id, to_name, to_account, from_nick, from_account, price, offer_id, trans_state, trans_start, trans_real) VALUES ('.$SQL->lastInsertId().', '.$SQL->quote($buy_player->getName()).', '.$SQL->quote($buy_player_account->getId()).', '.$SQL->quote($buy_from).',  '.$SQL->quote($account_logged->getId()).', '.$SQL->quote($buy_offer['points']).', '.$SQL->quote($buy_offer['name']).', \'wait\', '.$SQL->quote(time()).', \'0\');';
  427.                                             $SQL->query($save_transaction);
  428.                                             $account_logged->setCustomField('premium_points', $user_premium_points-$buy_offer['points']);
  429.                                             $user_premium_points = $user_premium_points - $buy_offer['points'];
  430.                                             $main_content .= '<center><h2>Container of items added!</h2><b>'.$buy_offer['name'].'</b> added to player <b>'.$buy_player->getName().'</b> for <b>'.$buy_offer['points'].' premium points</b> from your account.<br />Now you have <b>'.$user_premium_points.' premium points</b>.<br><br><a href="index.php?subtopic=shopsystem">GO TO MAIN SHOP SITE</a><br>';
  431.                                         }
  432.                                     } else {
  433.                                         if($buy_offer['type'] != 'changename') {
  434.                                             $set_session = TRUE;
  435.                                             $_SESSION['viewed_confirmation_page'] = 'yes';
  436.                                             $main_content .= '<center><h2>Confirm transaction</h2>
  437.                                                 <table border="0" cellpadding="1" cellspacing="1" width="700">
  438.                                                 <tr bgcolor="'.$config['site']['vdarkborder'].'"><td colspan="3"><font color="white" size="4"><b>Confirm transaction</b></font></td></tr>
  439.                                                 <tr bgcolor="'.$config['site']['darkborder'].'"><td width="100"><b>Name:</b></td><td width="550" colspan="2">'.$buy_offer['name'].'</td></tr>
  440.                                                 <tr bgcolor="'.$config['site']['lightborder'].'"><td width="100"><b>Description:</b></td><td width="550" colspan="2">'.$buy_offer['description'].'</td></tr>
  441.                                                 <tr bgcolor="'.$config['site']['darkborder'].'"><td width="100"><b>Cost:</b></td><td width="550" colspan="2"><b>'.$buy_offer['points'].' premium points</b> from your account</td></tr>
  442.                                                 <tr bgcolor="'.$config['site']['lightborder'].'"><td width="100"><b>For Player:</b></td><td width="550" colspan="2"><font color="red">'.$buy_player->getName().'</font></td></tr>
  443.                                                 <tr bgcolor="'.$config['site']['darkborder'].'"><td width="100"><b>From:</b></td><td width="550" colspan="2"><font color="red">'.$buy_from.'</font></td></tr>
  444.                                                 <tr bgcolor="'.$config['site']['lightborder'].'"><td width="100"><b>Transaction?</b></td><td width="275" align="left">
  445.                                                 <form action="index.php?subtopic=shopsystem&action=confirm_transaction" method="POST"><input type="hidden" name="buy_confirmed" value="yes"><input type="hidden" name="buy_id" value="'.$buy_id.'"><input type="hidden" name="buy_from" value="'.urlencode($new_name).'"><input type="hidden" name="buy_name" value="'.urlencode($buy_name).'"><input type="submit" value="Accept"></form></td>
  446.                                                 <td align="right"><form action="index.php?subtopic=shopsystem" method="POST"><input type="submit" value="Cancel"></form></td></tr>
  447.                                                 </table>';
  448.                                         } else {
  449.                                             $set_session = TRUE;
  450.                                             $_SESSION['viewed_confirmation_page'] = 'yes';
  451.                                             $main_content .= '<center><h2>Confirm Name Changing</h2>
  452.                                                 <table border="0" cellpadding="1" cellspacing="1" width="700">
  453.                                                 <tr bgcolor="'.$config['site']['vdarkborder'].'"><td colspan="3"><font color="white" size="4"><b>Confirm transaction</b></font></td></tr>
  454.                                                 <tr bgcolor="'.$config['site']['darkborder'].'"><td width="130"><b>Name:</b></td><td width="550" colspan="2">'.$buy_offer['name'].'</td></tr>
  455.                                                 <tr bgcolor="'.$config['site']['lightborder'].'"><td width="130"><b>Description:</b></td><td width="550" colspan="2">'.$buy_offer['description'].'</td></tr>
  456.                                                 <tr bgcolor="'.$config['site']['darkborder'].'"><td width="130"><b>Cost:</b></td><td width="550" colspan="2"><b>'.$buy_offer['points'].' premium points</b> from your account</td></tr>
  457.                                                 <tr bgcolor="'.$config['site']['lightborder'].'"><td width="130"><b>Current Name:</b></td><td width="550" colspan="2"><font color="red">'.$buy_player->getName().'</font></td></tr>
  458.                                                 <tr bgcolor="'.$config['site']['darkborder'].'"><td width="130"><b>New Name:</b></td><td width="550" colspan="2"><font color="red">'.$buy_from.'</font></td></tr>
  459.                                                 <tr bgcolor="'.$config['site']['lightborder'].'"><td width="130"><b>Change Name?</b></td><td width="275" align="left">
  460.                                                 <form action="index.php?subtopic=shopsystem&action=confirm_transaction" method="POST"><input type="hidden" name="buy_confirmed" value="yes"><input type="hidden" name="buy_id" value="'.$buy_id.'"><input type="hidden" name="buy_from" value="'.urlencode($buy_from).'"><input type="hidden" name="buy_name" value="'.urlencode($buy_name).'"><input type="submit" value="Accept"></form></td>
  461.                                                 <td align="right"><form action="index.php?subtopic=shopsystem" method="POST"><input type="submit" value="Cancel"></form></td></tr>
  462.                                                 </table>';
  463.                                         }
  464.                                     }
  465.                                 } else {
  466.                                     $main_content .= 'Player with name <b>'.$buy_name.'</b> doesn\'t exist. Please <a href="index.php?subtopic=shopsystem&action=select_player&buy_id='.$buy_id.'">select other name</a>.';
  467.                                 }
  468.                             } else {
  469.                                 $main_content .= 'Invalid name format. Please <a href="index.php?subtopic=shopsystem&action=select_player&buy_id='.$buy_id.'">select other name</a> or contact with administrator.';
  470.                             }
  471.                         } else {
  472.                             $main_content .= 'For this item you need <b>'.$buy_offer['points'].'</b> points. You have only <b>'.$user_premium_points.'</b> premium points. Please <a href="index.php?subtopic=shopsystem">select other item</a> or buy premium points.';
  473.                         }
  474.                         } else {
  475.                         $main_content .= 'Offer with ID <b>'.$buy_id.'</b> doesn\'t exist. Please <a href="index.php?subtopic=shopsystem">select item</a> again.';
  476.                     }
  477.                 }
  478.             }
  479.         }
  480.         if(!$set_session) {
  481.             unset($_SESSION['viewed_confirmation_page']);
  482.         }
  483.     }
  484.  
  485.     elseif($action == 'show_history') {
  486.         if(!$logged) {
  487.             $main_content .= 'Please login first.';
  488.         } else{
  489.             $items_history_received = $SQL->query('SELECT * FROM '.$SQL->tableName('z_shop_history_item').' WHERE '.$SQL->fieldName('to_account').' = '.$SQL->quote($account_logged->getId()).' OR '.$SQL->fieldName('from_account').' = '.$SQL->quote($account_logged->getId()).';');
  490.             if(is_object($items_history_received)) {
  491.                 foreach($items_history_received as $item_received) {
  492.                     if($account_logged->getId() == $item_received['to_account'])
  493.                         $char_color = 'green';
  494.                     else
  495.                         $char_color = 'red';
  496.                         $items_received_text .= '<tr bgcolor="'.$config['site']['lightborder'].'"><td><font color="'.$char_color.'">'.$item_received['to_name'].'</font></td><td>';
  497.                     if($account_logged->getId() == $item_received['from_account'])
  498.                         $items_received_text .= '<i>Your account</i>';
  499.                     else
  500.                         $items_received_text .= $item_received['from_nick'];
  501.                         $items_received_text .= '</td><td>'.$item_received['offer_id'].'</td><td>'.date("j F Y, H:i:s", $item_received['trans_start']).'</td>';
  502.                     if($item_received['trans_real'] > 0)
  503.                         $items_received_text .= '<td>'.date("j F Y, H:i:s", $item_received['trans_real']).'</td>';
  504.                     else
  505.                         $items_received_text .= '<td><b><font color="red">Not realized yet.</font></b></td>';
  506.                         $items_received_text .= '</tr>';
  507.                 }
  508.             }
  509.             $paccs_history_received = $SQL->query('SELECT * FROM '.$SQL->tableName('z_shop_history_pacc').' WHERE '.$SQL->fieldName('to_account').' = '.$SQL->quote($account_logged->getId()).' OR '.$SQL->fieldName('from_account').' = '.$SQL->quote($account_logged->getId()).';');
  510.             if(is_object($paccs_history_received)) {
  511.                 foreach($paccs_history_received as $pacc_received) {
  512.                     if($account_logged->getId() == $pacc_received['to_account'])
  513.                         $char_color = 'green';
  514.                     else
  515.                         $char_color = 'red';
  516.                         $paccs_received_text .= '<tr bgcolor="'.$config['site']['lightborder'].'"><td><font color="'.$char_color.'">'.$pacc_received['to_name'].'</font></td><td>';
  517.                     if($account_logged->getId() == $pacc_received['from_account'])
  518.                         $paccs_received_text .= '<i>Your account</i>';
  519.                     else
  520.                         $paccs_received_text .= $pacc_received['from_nick'];
  521.                         $paccs_received_text .= '</td><td>'.$pacc_received['pacc_days'].' days</td><td>'.$pacc_received['price'].' Points</td><td>'.date("j F Y, H:i:s", $pacc_received['trans_real']).'</td></tr>';
  522.                 }
  523.             }
  524.             $main_content .= '<center><h1>Transactions History</h1></center>';
  525.             if(!empty($items_received_text))
  526.                 $main_content .= '<center><table BORDER=0 CELLPADDING=1 CELLSPACING=1 WIDTH=95%><tr width="100%" bgcolor="'.$config['site']['vdarkborder'].'"><td colspan="5"><font color="white" size="4"><b>&nbsp;Item Transactions</b></font></td></tr><tr bgcolor="'.$config['site']['darkborder'].'"><td><b>To:</b></td><td><b>From:</b></td><td><b>Offer name</b></td><td><b>Bought on page</b></td><td><b>Received on '.$config['server']['serverName'].'</b></td></tr>'.$items_received_text.'</table><br />';
  527.             if(!empty($paccs_received_text))
  528.                 $main_content .= '<center><table BORDER=0 CELLPADDING=1 CELLSPACING=1 WIDTH=95%><tr width="100%" bgcolor="'.$config['site']['vdarkborder'].'"><td colspan="5"><font color="white" size="4"><b>&nbsp;Pacc Transactions</b></font></td></tr><tr bgcolor="'.$config['site']['darkborder'].'"><td><b>To:</b></td><td><b>From:</b></td><td><b>Duration</b></td><td><b>Cost</b></td><td><b>Added:</b></td></tr>'.$paccs_received_text.'</table><br />';
  529.             if(empty($paccs_received_text) && empty($items_received_text))
  530.                 $main_content .= 'You did not buy/receive any items or PACC.';
  531.         }
  532.     }
  533.     if(!$logged)
  534.         $main_content .= 'Please login to see how much points you have.';
  535.     else
  536.         $main_content .= '<br><b><font color="green">You have premium points: </font></b>'.$user_premium_points;
  537.     }
  538. else
  539.     $main_content .= '<br><center><b>Donation shop is currently disabled, it will be active as soon as possible.</b></center>';
  540. ?>
Add Comment
Please, Sign In to add comment