Advertisement
Guest User

Untitled

a guest
Jun 28th, 2016
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 33.99 KB | None | 0 0
  1. <?PHP
  2. $user_premium_points = $logged ? $account_logged->getPremiumPoints() : 0;
  3.  
  4. function getItemByID($id) {
  5.     global $SQL;
  6.     if(!$data = $SQL->query('SELECT * FROM z_shop_offer WHERE id = '.quote($id))->fetch())
  7.         return 0;
  8.     $a = array();
  9.     if ($data['offer_type'] == 'pacc')
  10.     {
  11.         $a['id'] = $data['id'];
  12.         $a['type'] = $data['offer_type'];
  13.         $a['days'] = $data['count1'];
  14.         $a['points'] = $data['points'];
  15.         $a['description'] = $data['offer_description'];
  16.         $a['name'] = $data['offer_name'];
  17.     }
  18.     elseif ($data['offer_type'] == 'item' || $data['offer_type'] == 'package')
  19.     {
  20.         $a['id'] = $data['id'];
  21.         $a['type'] = $data['offer_type'];
  22.         $a['item_id'] = $data['itemid1'];
  23.         $a['item_count'] = $data['count1'];
  24.         $a['points'] = $data['points'];
  25.         $a['description'] = $data['offer_description'];
  26.         $a['name'] = $data['offer_name'];
  27.     }
  28.     elseif ($data['offer_type'] == 'container')
  29.     {
  30.         $a['id'] = $data['id'];
  31.         $a['type'] = $data['offer_type'];
  32.         $a['container_id'] = $data['itemid2'];
  33.         $a['container_count'] = $data['count2'];
  34.         $a['item_id'] = $data['itemid1'];
  35.         $a['item_count'] = $data['count1'];
  36.         $a['points'] = $data['points'];
  37.         $a['description'] = $data['offer_description'];
  38.         $a['name'] = $data['offer_name'];
  39.     }
  40.     elseif ( in_array($data['offer_type'], array('unban','redskull','changename')) ) {
  41.         $a['id'] = $data['id'];
  42.         $a['type'] = $data['offer_type'];
  43.         $a['points'] = $data['points'];
  44.         $a['description'] = $data['offer_description'];
  45.         $a['name'] = $data['offer_name'];
  46.     }
  47.     return $a;
  48. }
  49.  
  50. if($action == '')
  51. {
  52.     unset($_SESSION['viewed_confirmation_page']);
  53.     $main_content .= '<h2><center>Welcome to '.$config['server']['serverName'].' shop</center></h2>';
  54.     $offer_list = array();
  55.     foreach($SQL->query('SELECT * FROM z_shop_offer')->fetchAll() as $q) {
  56.         if ($q['offer_type'] == 'pacc') {
  57.             $offer_list['pacc'][] = array(
  58.                 'id' => $q['id'],
  59.                 'days' => $q['count1'],
  60.                 'points' => $q['points'],
  61.                 'description' => $q['offer_description'],
  62.                 'name' => $q['offer_name']
  63.             );
  64.         }
  65.         elseif ($q['offer_type'] == 'item' || $q['offer_type'] == 'package') {
  66.             $a = array(
  67.                 'id' => $q['id'],
  68.                 'item_id' => $q['itemid1'],
  69.                 'item_count' => $q['count1'],
  70.                 'points' => $q['points'],
  71.                 'description' => $q['offer_description'],
  72.                 'name' => $q['offer_name']
  73.             );
  74.             if($q['offer_type'] == 'item')
  75.                 $offer_list[$q['offer_type']][(int)$q['group']][] = $a;
  76.             else
  77.                 $offer_list[$q['offer_type']][] = $a;
  78.         }
  79.         elseif ($q['offer_type'] == 'container') {
  80.             $offer_list['container'][] = array(
  81.                 'id' => $q['id'],
  82.                 'item_id' => $q['itemid1'],
  83.                 'item_count' => $q['count1'],
  84.                 'container_id' => $q['itemid2'],
  85.                 'container_count' => $q['count2'],
  86.                 'points' => $q['points'],
  87.                 'description' => $q['offer_description'],
  88.                 'name' => $q['offer_name']
  89.             );
  90.         }
  91.         elseif ( in_array($q['offer_type'], array('unban','redskull','changename')) ) {
  92.             $offer_list[$q['offer_type']][] = array(
  93.                 'id' => $q['id'],
  94.                 'points' => $q['points'],
  95.                 'description' => $q['offer_description'],
  96.                 'name' => $q['offer_name']
  97.             );
  98.         }
  99.     }
  100.  
  101. $tabs = array("all","packages","weapons","equipment","tools","others");
  102.     $main_content .= '
  103. <style type="text/css">
  104. #tabs tr td {
  105.     border: 1px solid rgb(216, 175, 106);
  106.     background-color: rgb(248, 220, 155);
  107.     padding: 5px;
  108.     cursor: pointer;
  109.     font-size: 8pt;
  110.     font-weight: 700;
  111. }
  112. #tabs tr td:hover {
  113.     background-color: rgb(255, 255, 255);
  114. }
  115. #tabs tr td.active {
  116.     background-color: rgb(255, 255, 255);
  117. }
  118. .tabStyle, .tabStyleActive {
  119.     float:left;
  120.     margin-left:5px;
  121.     padding:5px;
  122.     border-top-right-radius:5px;
  123.     border-top-left-radius:5px;
  124.     border:1px black solid;
  125.     border-bottom:none;
  126.     position:relative;
  127.     top:1px;
  128.     z-index:8;
  129. }
  130. .tabStyleActive {
  131.     z-index:10;
  132.     background-color: #A78520;
  133. }
  134. .tabBox {
  135.     background-color: #A78520;
  136.     padding:5px;
  137.     clear:left;
  138.     position:relative;
  139.     border-radius:5px;
  140.     box-shadow:0 0 10px #222;
  141.     border:1px black solid;
  142.     z-index:9;
  143. }
  144. </style>
  145. <script type="text/javascript">
  146. var a = [';
  147. foreach($tabs as $i => $v)
  148.     $main_content .= ($i === 0 ? '' : ',').'"'.$v.'"';
  149. $main_content .= '];
  150. var active = \'all\';
  151.  
  152. function tab(e){
  153.     if(active===e) {
  154.         return;
  155.     }
  156.     active = e;
  157.     for(var i in a) {
  158.         var v = a[i];
  159.         document.getElementById(\'t_\'+v).style.display = (v == e ? \'block\' : \'none\');
  160.         document.getElementById(\'tab_\'+v).className = (v == e ? \'tabStyleActive\' : \'tabStyle\');
  161.     }
  162. }
  163. </script>
  164. ';
  165. foreach($tabs as $v)
  166.     $main_content .= '<div id="tab_'.$v.'"'.($v === 'all' ? ' class="tabStyleActive"' : ' class="tabStyle"').'><a href="javascript:tab(\''.$v.'\');">'.strtoupper($v).'</a></div>';
  167. $main_content .= '
  168. <div class="tabBox">';
  169.  
  170. $all = array();
  171. $main_content .= '<table border="0" cellpadding="4" cellspacing="1" width="100%" id="t_all" style="display:block;"><tr bgcolor="'.$config['site']['vdarkborder'].'"><td colspan="3"><font color="gold" size="4"><b>&nbsp;ALL OFFERS</b></font></td></tr><tr bgcolor="'.$config['site']['darkborder'].'"><td width="50" align="center"><font color=red><b>Picture</b></font></td><td width="350" align="left"><font color=red><b>Description</b></font></td><td width="250" align="center"><font color=red><b>Select product</b></font></td></tr>';
  172.  
  173. function displayArray($e, $type) {
  174.     ob_start();
  175.     global $i, $config, $logged;
  176.     foreach($e as $item) {
  177.         ++$i;
  178.         if($type === 'package') {
  179.             $s = explode(',', $item['item_id']);
  180.             $item['item_id'] = end($s);
  181.         }
  182.         echo '<tr bgcolor="'.($type === 'unban' ? 'gold' : $config['site'][$i & 1  ? 'lightborder' : 'darkborder']).'"><td align="center">';
  183.         if(in_array($type, array('package', 'item', 'container')))
  184.             echo '<img src="'.($type == 'package' ? 'images/items/'.$item['item_id'].'.gif' : 'item_images/'.$item['id'].'.jpg').'">';
  185.         elseif($type === 'unban')
  186.             echo 'Unban';
  187.         elseif($type === 'changename')
  188.             echo 'Change<br/>Name';
  189.         elseif($type === 'pacc')
  190.             echo $item['days'];
  191.  
  192.         echo '</td><td><b>'.$item['name'].'</b> ('.$item['points'].' points)<br />'.$item['description'].'</td><td align="center">';
  193.         if(!$logged)
  194.             echo '<b>Login to buy</b>';
  195.         else
  196.             echo '<form action="?subtopic=shopsystem&action=select_player" method="post"><input type="hidden" name="buy_id" value="'.$item['id'].'"><input type="submit" value="Buy '.$item['name'].'"><br/><b>for '.$item['points'].' points</b></form>';
  197.         echo '</td></tr>';
  198.     }
  199.     $GLOBALS['main_content'] .= ob_get_clean();
  200. }
  201.  
  202. $i = 0;
  203. foreach($offer_list as $type => $v) {
  204.     if($type == 'item') {
  205.         foreach($v as $item)
  206.             displayArray($item, 'item');
  207.     }
  208.     else
  209.         displayArray($v, $type);
  210. }
  211. $main_content .= '</table>';
  212.  
  213.     if(!empty($offer_list['package'])) {
  214.         $main_content .= '<table border="0" cellpadding="4" cellspacing="1" width="100%" id="t_packages" style="display:none;"><tr bgcolor="'.$config['site']['vdarkborder'].'"><td colspan="3"><font color="gold" size="4"><b>&nbsp;PACKAGES</b></font></td></tr><tr bgcolor="'.$config['site']['darkborder'].'"><td width="50" align="center"><font color=red><b>Picture</b></font></td><td width="350" align="left"><font color=red><b>Description</b></font></td><td width="250" align="center"><font color=red><b>Select product</b></font></td></tr>';
  215.         foreach($offer_list['package'] as $i => $item) {
  216.             $item['item_id'] = explode(',', $item['item_id']);
  217.             $main_content .= '<tr bgcolor="'.$config['site'][$i & 1  ? 'darkborder' : 'lightborder'].'"><td align="center"><img src="images/items/'.end($item['item_id']).'.gif"></td><td><b>'.$item['name'].'</b> ('.$item['points'].' points)<br />'.$item['description'].'</td><td align="center">';
  218.             if(!$logged) {
  219.                 $main_content .= '<b>Login to buy</b>';
  220.             }
  221.             else {
  222.                 $main_content .= '<form action="?subtopic=shopsystem&action=select_player" method=POST><input type="hidden" name="buy_id" value="'.$item['id'].'"><input type="submit" value="Buy '.$item['name'].'"><br><b>for '.$item['points'].' points</b></form>';
  223.             }
  224.             $main_content .= '</td></tr>';
  225.         }
  226.         $main_content .= '</table>';
  227.     }
  228.  
  229.     if(!empty($offer_list['item'])) {
  230.         $tab = array(0 => 'weapons', 1 => 'equipment', 2 => 'tools');
  231.         foreach($offer_list['item'] as $group => $k) {
  232.             $main_content .= '<table border="0" cellpadding="4" cellspacing="1" width="100%" id="t_'.$tab[$group].'" style="display:none"><tr bgcolor="'.$config['site']['vdarkborder'].'"><td colspan="3"><font color="gold" size="4"><b>&nbsp;'.strtoupper($tab[$group]).'</b></font></td></tr><tr bgcolor="'.$config['site']['darkborder'].'"><td width="50" align="center"><font color=red><b>Picture</b></font></td><td width="350" align="left"><font color=red><b>Description</b></font></td><td width="250" align="center"><font color=red><b>Select product</b></font></td></tr>';
  233.             foreach($k as $i => $item) {
  234.                 $main_content .= '<tr bgcolor="'.$config['site'][$i & 1  ? 'darkborder' : 'lightborder'].'"><td align="center"><img src="item_images/'.$item['id'].'.jpg"></td><td><b>'.$item['name'].'</b> ('.$item['points'].' points)<br />'.$item['description'].'</td><td align="center">';
  235.                 if(!$logged) {
  236.                     $main_content .= '<b>Login to buy</b>';
  237.                 }
  238.                 else {
  239.                     $main_content .= '<form action="?subtopic=shopsystem&action=select_player" method=POST><input type="hidden" name="buy_id" value="'.$item['id'].'"><input type="submit" value="Buy '.$item['name'].'"><br><b>for '.$item['points'].' points</b></form>';
  240.                 }
  241.                 $main_content .= '</td></tr>';
  242.             }
  243.             $main_content .= '</table>';
  244.         }
  245.     }
  246.  
  247.     $main_content .= '<table border="0" cellpadding="4" cellspacing="1" width="100%" id="t_others" style="display:none;"><tr bgcolor="'.$config['site']['vdarkborder'].'"><td colspan="3"><font color="gold" size="4"><b>&nbsp;OTHERS</b></font></td></tr><tr bgcolor="'.$config['site']['darkborder'].'"><td width="50" align="center"><font color=red><b></b></font></td><td width="350" align="left"><font color=red><b>Description</b></font></td><td width="250" align="center"><font color=red><b>Select product</b></font></td></tr>';
  248.     if(!empty($offer_list['pacc']))
  249.     $i = 0;
  250.     foreach($offer_list['pacc'] as $pacc)
  251.     {
  252.         $main_content .= '<tr bgcolor="'.$config['site'][(is_int($i/2))  ? 'lightborder' : 'darkborder'].'"><td align="center"><font color="black">'.$pacc['days'].'</td><td><font color="black"<b>'.$pacc['name'].'</b> ('.$pacc['points'].' points)<br />'.$pacc['description'].'</td><td align="center">';
  253.         $i++;      
  254.         if(!$logged)
  255.         {
  256.         $main_content .= '<b>Login to buy</b>';
  257.         }
  258.         else
  259.         {
  260.         $main_content .= '<form action="?subtopic=shopsystem&action=select_player" method=POST><input type="hidden" name="buy_id" value="'.$pacc['id'].'"><input type="submit" value="Buy '.$pacc['name'].'"><br><font color="black"<b>for '.$pacc['points'].' points</b></form>';
  261.         }
  262.     }
  263.     if(!empty($offer_list['changename']))
  264.     foreach($offer_list['changename'] as $changename)
  265.     {
  266.         $main_content .= '<tr bgcolor="'.$config['site'][$i & 1  ? 'darkborder' : 'lightborder'].'"><td align="center"><font color="black">Change Name</td><td><font color="black"<b>'.$changename['name'].'</b> ('.$changename['points'].' points)<br />'.$changename['description'].'</td><td align="center">';
  267.         if(!$logged)
  268.         {
  269.         $main_content .= '<b>Login to buy</b>';
  270.         }
  271.         else
  272.         {
  273.         $main_content .= '<form action="?subtopic=shopsystem&action=select_player" method=POST><input type="hidden" name="buy_id" value="'.$changename['id'].'"><input type="submit" value="Buy '.$changename['name'].'"><br><font color="black"<b>for '.$changename['points'].' points</b></form>';
  274.         }
  275.     }
  276.     if(!empty($offer_list['redskull']))
  277.     //Remove Red Skull
  278.     foreach($offer_list['redskull'] as $redskull)
  279.     {
  280.         $main_content .= '<tr bgcolor="gold"><td align="center"><img src="item_images/'.$redskull['id'].'.jpg"></td><td><font color="black"<b>'.$redskull['name'].'</b> ('.$redskull['points'].' points)<br />'.$redskull['description'].'</td><td align="center">';
  281.         if(!$logged)
  282.         {
  283.         $main_content .= '<b>Login to buy</b>';
  284.         }
  285.         else
  286.         {
  287.         $main_content .= '<form action="?subtopic=shopsystem&action=select_player" method=POST><input type="hidden" name="buy_id" value="'.$redskull['id'].'"><input type="submit" value="Buy '.$redskull['name'].'"><br><font color="black"<b>for '.$redskull['points'].' points</b></form>';
  288.         }
  289.         $main_content .= '</td></tr>';
  290.     }
  291.     if(!empty($offer_list['unban']))
  292.     //Unban
  293.     foreach($offer_list['unban'] as $unban)
  294.     {
  295.         $main_content .= '<tr bgcolor="gold"><td align="center"><font color="black">Unban</td><td><font color="black"<b>'.$unban['name'].'</b> ('.$unban['points'].' points)<br />'.$unban['description'].'</td><td align="center">';
  296.         if(!$logged)
  297.         {
  298.         $main_content .= '<b>Login to buy</b>';
  299.         }
  300.         else
  301.         {
  302.         $main_content .= '<form action="?subtopic=shopsystem&action=select_player" method=POST><input type="hidden" name="buy_id" value="'.$unban['id'].'"><input type="submit" value="Buy '.$unban['name'].'"><br><font color="black"<b>for '.$unban['points'].' points</b></form>';
  303.         }
  304.         $main_content .= '</td></tr>';
  305.     }
  306.     $main_content .= '</table></div>'; // sec
  307. }
  308.  
  309. elseif($action == 'select_player')
  310. {
  311.     unset($_SESSION['viewed_confirmation_page']);
  312.     if(!$logged) {
  313.     $main_content .= 'Please login first.';
  314.     }
  315.     else
  316.     {
  317.     $buy_id = (int) $_REQUEST['buy_id'];
  318.     if(empty($buy_id))
  319.     {
  320.         $main_content .= 'Please <a href="?subtopic=shopsystem">select item</a> first.';
  321.     }
  322.     else
  323.     {
  324.         if($buy_offer = getItemByID($buy_id)) //item exist in database
  325.         {
  326.         if($buy_offer['type'] != 'changename') {
  327.         if($user_premium_points >= $buy_offer['points'])
  328.         {
  329.             $main_content .= '<h2>Select player</h2>
  330.             <table border="0" cellpadding="1" cellspacing="1" width="100%">
  331.             <tr bgcolor="'.$config['site']['vdarkborder'].'"><td colspan="2"><font color="gold" size="4"><b>Selected offer</b></font></td></tr>
  332.             <tr bgcolor="gold"><td width="100"><b>Name:</b></td><td width="550">'.$buy_offer['name'].'</td></tr>
  333.             <tr bgcolor="gold"><td width="100"><b>Description:</b></td><td width="550">'.$buy_offer['description'].'</td></tr>
  334.             </table><br />
  335.             <form action="?subtopic=shopsystem&action=confirm_transaction" method=POST><input type="hidden" name="buy_id" value="'.$buy_id.'">
  336.             <table border="0" cellpadding="1" cellspacing="1" width="100%">
  337.             <tr bgcolor="'.$config['site']['vdarkborder'].'"><td colspan="2"><font color="gold" size="4"><b>Give item/pacc* to player from your account</b></font></td></tr>
  338.             <tr bgcolor="gold"><td width="110"><b>Name:</b></td><td width="550"><select name="buy_name">';
  339.             $players_from_logged_acc = $account_logged->getPlayersList();
  340.             if(count($players_from_logged_acc) > 0)
  341.             {
  342.             $players_from_logged_acc->orderBy('name');
  343.             foreach($players_from_logged_acc as $player)
  344.             {
  345.                 $main_content .= '<option>'.$player->getName().'</option>';
  346.             }
  347.             }
  348.             else
  349.             {
  350.             $main_content .= 'You don\'t have any character on your account.';
  351.             }
  352.             $main_content .= '</select>&nbsp;<input type="submit" value="Give"></td></tr>
  353.             </table>
  354.             </form><br /><form action="?subtopic=shopsystem&action=confirm_transaction" method=POST><input type="hidden" name="buy_id" value="'.$buy_id.'">
  355.             <table border="0" cellpadding="1" cellspacing="1" width="100%">
  356.             <tr bgcolor="'.$config['site']['vdarkborder'].'"><td colspan="2"><font color="gold" size="4"><b>Give item/pacc* to other player</b></font></td></tr>
  357.             <tr bgcolor="gold"><td width="110"><b>To player:</b></td><td width="550"><input type="text" name="buy_name"> - name of player on</td></tr>
  358.             <tr bgcolor="gold"><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>
  359.             </table><br />
  360.             </form>';
  361.  
  362.             $main_content .= '*PACC is for all characters from account of selected player name';
  363.         }
  364.         else
  365.         {
  366.             $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="?subtopic=shopsystem">select other item</a> or buy premium points.';
  367.         }
  368.         }
  369.         else
  370.         {
  371.             $main_content .= '<form action="?subtopic=shopsystem&action=confirm_transaction" method=POST><input type="hidden" name="buy_id" value="'.$buy_id.'">
  372.             <table border="0" cellpadding="1" cellspacing="1" width="100%">
  373.             <tr bgcolor="'.$config['site']['vdarkborder'].'"><td colspan="2"><font color="gold" size="4"><b>Change Name:</b></font></td></tr>
  374.             <tr bgcolor="gold"><td width="110"><b>Name:</b></td><td width="550"><select name="buy_name">';
  375.             $players_from_logged_acc = $account_logged->getPlayersList();
  376.             if(count($players_from_logged_acc) > 0)
  377.             {
  378.             $players_from_logged_acc->orderBy('name');
  379.             foreach($players_from_logged_acc as $player)
  380.             {
  381.                 $main_content .= '<option>'.$player->getName().'</option>';
  382.             }
  383.             }
  384.             else
  385.             {
  386.             $main_content .= 'You don\'t have any character on your account.';
  387.             }
  388.             $main_content .= '</select></td></tr>
  389.             <tr bgcolor="gold"><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>
  390.             </table><br />
  391.             </form>';
  392.             }
  393.         }
  394.         else
  395.         {
  396.         $main_content .= 'Offer with ID <b>'.$buy_id.'</b> doesn\'t exist. Please <a href="?subtopic=shopsystem">select item</a> again.';
  397.         }
  398.     }
  399.     }
  400. }
  401. elseif($action == 'confirm_transaction')
  402. {
  403.     if(!$logged) {
  404.         $main_content = 'Please login first.';
  405.         return;
  406.     }
  407.  
  408.     if(($buy_id = (int) $_POST['buy_id']) < 1) {
  409.         $main_content = 'Please <a href="?subtopic=shopsystem">select item</a> first.';
  410.         return;
  411.     }
  412.    
  413.     if($buy_offer = getItemByID($buy_id)) {
  414.         if($user_premium_points >= $buy_offer['points']) {
  415.             $buy_name = stripslashes(urldecode($_POST['buy_name']));
  416.             if(check_name($buy_name)) {
  417.                 $buy_player = new OTS_Player();
  418.                 $buy_player->find($buy_name);
  419.                 if($buy_player->isLoaded()) {
  420.                     $buy_player_account = $buy_player->getAccount();
  421.                     $buy_from = stripslashes(urldecode($_POST['buy_from']));
  422.                     if($_SESSION['viewed_confirmation_page'] == 'yes' && $_POST['buy_confirmed'] == 'yes') {
  423.                         if($buy_offer['type'] == 'pacc') {
  424.                             $player_premdays = $buy_player_account->getCustomField('premdays');
  425.                             $player_lastlogin = $buy_player_account->getCustomField('lastday');
  426.                             $save_transaction = 'INSERT INTO z_shop_history_pacc (id, to_name, to_account, from_nick, from_account, price, pacc_days, trans_state, trans_start, trans_real) VALUES (NULL, '.quote($buy_player->getName()).', '.quote($buy_player_account->getId()).', '.quote($buy_from).',  '.quote($account_logged->getId()).', '.quote($buy_offer['points']).', '.quote($buy_offer['days']).', \'realized\', '.quote(time()).', '.quote(time()).');';
  427.                             $SQL->query($save_transaction);
  428.                             $buy_player_account->setCustomField('premdays', $player_premdays+$buy_offer['days']);
  429.                             $account_logged->setCustomField('premium_points', $user_premium_points-$buy_offer['points']);
  430.                             $user_premium_points = $user_premium_points - $buy_offer['points'];
  431.                             if($player_premdays == 0)
  432.                             {
  433.                                 $buy_player_account->setCustomField('lastday', time());
  434.                             }
  435.                             $main_content .= '<h2>PACC added!</h2><b>'.$buy_offer['days'].' days</b> of Premium Account added to account of player <b>'.$buy_player->getName().'</b> for <b>'.$buy_offer['points'].' premium points</b> from your account.<br />You now have <b>'.$user_premium_points.' premium points</b>.<br /><a href="?subtopic=shopsystem">GO TO MAIN SHOP SITE</a>';
  436.                         }
  437.                         elseif($buy_offer['type'] == 'unban') {
  438.                             if($SQL->query('DELETE FROM bans WHERE value= '.$account_logged->getId().' LIMIT 1')) {
  439.                                 $account_logged->setCustomField('premium_points', $user_premium_points-$buy_offer['points']);
  440.                                 $user_premium_points = $user_premium_points - $buy_offer['points'];
  441.                                 $main_content .= '
  442.                                 <h2>
  443.                                     Ban Deleted!
  444.                                 </h2>
  445.                                 <b>
  446.                                     Your account has been unbanned for '.$buy_offer['points'].' premium points
  447.                                 </b>
  448.                                 from your account.
  449.                                 <br>
  450.                                 You now have
  451.                                     <b>
  452.                                     '.$user_premium_points.' premium points
  453.                                     </b>.
  454.                                 <br>
  455.                                 <a href="?subtopic=shopsystem">
  456.                                     GO TO MAIN SHOP SITE
  457.                                 </a>';
  458.                             }
  459.                             else {
  460.                                 $main_content .= '
  461.                                 <b>
  462.                                 You don\'t have any bans in your account!
  463.                                 </b>
  464.                                 <br>
  465.                                 <a href="?subtopic=shopsystem">
  466.                                 GO BACK
  467.                                 </a>';
  468.                             }
  469.                         }
  470. ////////////////////////////////
  471. //////////////////////////
  472.                         elseif($buy_offer['type'] == 'changename') {
  473.                             if(strlen($buy_from) > 2 && strlen($buy_from) < 26 && strspn("$buy_from", "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM ") === strlen($buy_from) && check_name_new_char($buy_from)) {
  474.                                 $id = $buy_player->getId();
  475.                                 if($SQL->query('SELECT 1 FROM players WHERE id = '.$id.' AND online=0')->rowCount()) {
  476.                                     $buy_from = quote(ucwords(strtolower($buy_from)));
  477.                                     if(!$SQL->query('SELECT 1 FROM players WHERE name = '. $buy_from)->rowCount()) {
  478.                                         $SQL->query('UPDATE `players` SET `name` = '. $buy_from .' WHERE `id` = '. $id);
  479.  
  480.                                         $account_logged->setCustomField('premium_points', $user_premium_points-$buy_offer['points']);
  481.                                         $user_premium_points = $user_premium_points - $buy_offer['points'];
  482.                                         $main_content .= '
  483.                             <h2>Your name has changed to '.$buy_from.'</h2>
  484.                             You have <b>'.$user_premium_points.'</b> premium points left.<br/>
  485.                             <a href="?subtopic=shopsystem">GO TO MAIN SHOP SITE</a>';
  486.                                     } else
  487.                                         $main_content .= '<b>The name <b>'.$buy_from.'</b> is already used.</b>';
  488.                                 } else
  489.                                     $main_content .= '<b>'.$buy_name.' has to be offline to complete transaction.</b>';
  490.                             } else
  491.                                 $main_content .= '<b>Invalid name.</b>';
  492.                             $main_content .= '<br/><a href="?subtopic=shopsystem">GO BACK</a>';
  493.                         }
  494. //////////////////////////
  495.     ////////////////////////////////
  496.                         elseif($buy_offer['type'] == 'redskull') {
  497.                             //Obtener id ed la cuenta
  498.                             $my_acc_id = $buy_player->getId();;
  499.                             $dataget = $SQL->query('SELECT * FROM players WHERE id = '.$my_acc_id.';')->fetch();
  500.                             if($dataget['redskull'] == '1' AND $dataget['online'] >= '0' AND $dataget['redskulltime'] > '0') {
  501.  
  502.                                     $SQL->query('UPDATE players SET redskull=0, redskulltime=0 WHERE id='. $my_acc_id .';');
  503.                                 $account_logged->setCustomField('premium_points', $user_premium_points-$buy_offer['points']);
  504.                                 $user_premium_points = $user_premium_points - $buy_offer['points'];
  505.                                 $main_content .= '
  506.                                 <h2>
  507.                                     RedSkull Removed!
  508.                                 </h2>
  509.                                 <b>
  510.                                     Your redskull has been removed to the player '.$buy_player->getName().',
  511.                                 <br>
  512.                                 You now have
  513.                                     <b>
  514.                                     '.$user_premium_points.' premium points
  515.                                     </b>.
  516.                                 <br>
  517.                                 <a href="?subtopic=shopsystem">
  518.                                     GO TO MAIN SHOP SITE
  519.                                 </a>';
  520.                             } else
  521.                             {
  522.                                 $main_content .= '
  523.                                 <b>
  524.                                 '.$buy_player->getName().' has to be offline and have redskull to complete transaction!.
  525.                                 </b>
  526.                                 <br>
  527.                                 <a href="?subtopic=shopsystem">
  528.                                 GO BACK
  529.                                 </a>';
  530.                             }
  531.                         }
  532. //////////////////////////
  533.                         elseif($buy_offer['type'] == 'item' || $buy_offer['type'] == 'package') {
  534.                             $SQL->query('INSERT INTO z_ots_comunication (id, guid, type, action, param1, param2, param3, param4, param5, param6) VALUES (NULL, '.quote($buy_player->getId()).', \'login\', \'give_item\', '.quote($buy_offer['item_id']).', '.quote($buy_offer['item_count']).', \'\', \'\', \''.$buy_offer['type'].'\', '.quote($buy_offer['name']).');');
  535.                             $SQL->query('INSERT INTO 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().', '.quote($buy_player->getName()).', '.$buy_player_account->getId().', '.quote($buy_from).',  '.$account_logged->getId().', '.$buy_offer['points'].', '.quote($buy_offer['name']).', \'wait\', '.time().', \'0\');');
  536.                             $account_logged->setCustomField('premium_points', $user_premium_points-$buy_offer['points']);
  537.                             $user_premium_points = $user_premium_points - $buy_offer['points'];
  538.                             $main_content .= '<h2>Item added!</h2><b>'.$buy_offer['name'].'</b> added to player <b>'.$buy_player->getName().'</b> items for <b>'.$buy_offer['points'].' premium points</b> from your account.<br />You now have <b>'.$user_premium_points.' premium points</b>.<br /><a href="?subtopic=shopsystem">GO TO MAIN SHOP SITE</a>';
  539.                         }
  540.                         elseif($buy_offer['type'] == 'container') {
  541.                             $SQL->query('INSERT INTO z_ots_comunication (id, guid, type, action, param1, param2, param3, param4, param5, param6) VALUES (NULL, '.quote($buy_player->getId()).', \'login\', \'give_item\', '.quote($buy_offer['item_id']).', '.quote($buy_offer['item_count']).', '.quote($buy_offer['container_id']).', '.quote($buy_offer['container_count']).', \'container\', '.quote($buy_offer['name']).');');
  542.                             $SQL->query('INSERT INTO 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().', '.quote($buy_player->getName()).', '.quote($buy_player_account->getId()).', '.quote($buy_from).',  '.quote($account_logged->getId()).', '.quote($buy_offer['points']).', '.quote($buy_offer['name']).', \'wait\', '.quote(time()).', \'0\');');
  543.                             $account_logged->setCustomField('premium_points', $user_premium_points-$buy_offer['points']);
  544.                             $user_premium_points = $user_premium_points - $buy_offer['points'];
  545.                             $main_content .= '<h2>Container of items added!</h2><b>'.$buy_offer['name'].'</b> added to player <b>'.$buy_player->getName().'</b> items (he will get this container with items after relog) for <b>'.$buy_offer['points'].' premium points</b> from your account.<br />You now have <b>'.$user_premium_points.' premium points</b>.<br /><a href="?subtopic=shopsystem">GO TO MAIN SHOP SITE</a>';
  546.                         }
  547.                     }
  548.                     else {
  549.                         $set_session = TRUE;
  550.                         $_SESSION['viewed_confirmation_page'] = 'yes';
  551.                         if($buy_offer['type'] != 'changename') {
  552.                             $main_content .= '<h2>Confirm transaction</h2>
  553.                             <table border="0" cellpadding="1" cellspacing="1" width="100%">
  554.                             <tr bgcolor="'.$config['site']['vdarkborder'].'"><td colspan="3"><font color="gold" size="4"><b>Confirm transaction</b></font></td></tr>
  555.                             <tr bgcolor="gold"><td width="100"><b>Name:</b></td><td width="550" colspan="2">'.$buy_offer['name'].'</td></tr>
  556.                             <tr bgcolor="gold"><td width="100"><b>Description:</b></td><td width="550" colspan="2">'.$buy_offer['description'].'</td></tr>
  557.                             <tr bgcolor="gold"><td width="100"><b>Cost:</b></td><td width="550" colspan="2"><b>'.$buy_offer['points'].' premium points</b> from your account</td></tr>
  558.                             <tr bgcolor="gold"><td width="100"><b>For Player:</b></td><td width="550" colspan="2"><font color="red">'.$buy_player->getName().'</font></td></tr>
  559.                             <tr bgcolor="gold"><td width="100"><b>From:</b></td><td width="550" colspan="2"><font color="red">'.$buy_from.'</font></td></tr>
  560.                             <tr bgcolor="red"><td width="100"><b>Transaction?</b></td><td width="275" align="left">
  561.                             <form action="?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>
  562.                             <td align="right"><form action="?subtopic=shopsystem" method="POST"><input type="submit" value="Cancel"></form></td></tr>
  563.                             </table>
  564.                             ';
  565.                         }
  566.                         else {
  567.                             $main_content .= '<h2>Confirm change name</h2>
  568.                             <table border="0" cellpadding="1" cellspacing="1" width="100%">
  569.                             <tr bgcolor="'.$config['site']['vdarkborder'].'"><td colspan="3"><font color="gold" size="4"><b>Confirm transaction</b></font></td></tr>
  570.                             <tr bgcolor="gold"><td width="100"><b>Name:</b></td><td width="550" colspan="2">'.$buy_offer['name'].'</td></tr>
  571.                             <tr bgcolor="gold"><td width="100"><b>Description:</b></td><td width="550" colspan="2">'.$buy_offer['description'].'</td></tr>
  572.                             <tr bgcolor="gold"><td width="100"><b>Cost:</b></td><td width="550" colspan="2"><b>'.$buy_offer['points'].' premium points</b> from your account</td></tr>
  573.                             <tr bgcolor="gold"><td width="100"><b>Current Name:</b></td><td width="550" colspan="2"><font color="red">'.$buy_player->getName().'</font></td></tr>
  574.                             <tr bgcolor="gold"><td width="100"><b>New Name:</b></td><td width="550" colspan="2"><font color="red">'.$buy_from.'</font></td></tr>
  575.                             <tr bgcolor="red"><td width="100"><b>Change Name?</b></td><td width="275" align="left">
  576.                             <form action="?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>
  577.                             <td align="right"><form action="?subtopic=shopsystem" method="POST"><input type="submit" value="Cancel"></form></td></tr>
  578.                             </table>
  579.                             ';
  580.                         }
  581.                     }
  582.                 }
  583.                 else {
  584.                     $main_content .= 'Player with name <b>'.$buy_name.'</b> doesn\'t exist. Please <a href="?subtopic=shopsystem&action=select_player&buy_id='.$buy_id.'">select other name</a>.';
  585.                 }
  586.             }
  587.             else {
  588.                 $main_content .= 'Invalid name format. Please <a href="?subtopic=shopsystem&action=select_player&buy_id='.$buy_id.'">select other name</a> or contact with administrator.';
  589.             }
  590.         }
  591.         else {
  592.             $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="?subtopic=shopsystem">select other item</a> or buy premium points.';
  593.         }
  594.     }
  595.     else {
  596.         $main_content .= 'Offer with ID <b>'.$buy_id.'</b> doesn\'t exist. Please <a href="?subtopic=shopsystem">select item</a> again.';
  597.     }
  598.  
  599.     if(!isset($set_session)) {
  600.         unset($_SESSION['viewed_confirmation_page']);
  601.     }
  602. }
  603. elseif($action == 'show_history')
  604. {
  605.     if(!$logged) {
  606.     $main_content .= 'Please login first.';
  607.     }
  608.     else
  609.     {
  610.     $items_history_received = $SQL->query('SELECT * FROM z_shop_history_item WHERE to_account = '.quote($account_logged->getId()).' OR from_account = '.quote($account_logged->getId()).';');
  611.     if(is_object($items_history_received)) {
  612.         foreach($items_history_received as $item_received)
  613.         {
  614.         if($account_logged->getId() == $item_received['to_account'])
  615.             $char_color = 'green';
  616.         else
  617.             $char_color = 'red';
  618.         $items_received_text .= '<tr bgcolor="gold"><td><font color="'.$char_color.'">'.$item_received['to_name'].'</font></td><td>';
  619.         if($account_logged->getId() == $item_received['from_account'])
  620.             $items_received_text .= '<i>Your account</i>';
  621.         else
  622.             $items_received_text .= $item_received['from_nick'];
  623.         $items_received_text .= '</td><td>'.$item_received['offer_id'].'</td><td>'.date("j F Y, H:i:s", $item_received['trans_start']).'</td>';
  624.         if($item_received['trans_real'] > 0)
  625.             $items_received_text .= '<td>'.date("j F Y, H:i:s", $item_received['trans_real']).'</td>';
  626.         else
  627.             $items_received_text .= '<td><b><font color="red">Not realized yet.</font></b></td>';
  628.         $items_received_text .= '</tr>';
  629.         }
  630.     }
  631.     $paccs_history_received = $SQL->query('SELECT * FROM z_shop_history_pacc WHERE to_account = '.quote($account_logged->getId()).' OR from_account = '.quote($account_logged->getId()).';');
  632.     if(is_object($paccs_history_received)) {
  633.         foreach($paccs_history_received as $pacc_received)
  634.         {
  635.         if($account_logged->getId() == $pacc_received['to_account'])
  636.             $char_color = 'green';
  637.         else
  638.             $char_color = 'red';
  639.         $paccs_received_text .= '<tr bgcolor="gold"><td><font color="'.$char_color.'">'.$pacc_received['to_name'].'</font></td><td>';
  640.         if($account_logged->getId() == $pacc_received['from_account'])
  641.             $paccs_received_text .= '<i>Your account</i>';
  642.         else
  643.             $paccs_received_text .= $pacc_received['from_nick'];
  644.         $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>';
  645.         }
  646.     }
  647.     $main_content .= '<center><h1>Transactions History</h1></center>';
  648.     if(!empty($items_received_text))
  649.     {
  650.         $main_content .= '<h2>Item transactions</h2><table BORDER=0 CELLPADDING=1 CELLSPACING=1 WIDTH=100%><tr bgcolor="gold"><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 OTS</b></td></tr>'.$items_received_text.'</table><br />';
  651.     }
  652.     if(!empty($paccs_received_text))
  653.     {
  654.         $main_content .= '<h2>PACC transactions</h2><table BORDER=0 CELLPADDING=1 CELLSPACING=1 WIDTH=100%><tr bgcolor="gold"><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 />';
  655.     }
  656.     if(empty($paccs_received_text) && empty($items_received_text))
  657.         $main_content .= 'You did not buy/receive any item or PACC.';
  658.     }
  659. }
  660. if($logged)
  661.     $main_content .= '<br/><br/>
  662.     <div style="width: 100%">
  663.         <div style="width: 350px; margin: 0px auto; background-color:white; text-align: center; border-radius: 5px; padding-top: 5px; padding-bottom:5px; box-shadow:0 0 10px #222; border:1px black solid;">
  664.             <span style="color:green;font-weight:bold">Premium Points: </span></b>'.$user_premium_points.' (<a href="?subtopic=buypoints">Get points!</a>)
  665.         </div>
  666.     </div>';
  667. if($logged && $group_id_of_acc_logged >= $config['site']['access_admin_panel']) {
  668.     $pl2 = $SQL->query('SELECT COUNT(*) FROM z_shop_points_bought WHERE amount')->fetch();
  669.     $ppx = explode('\' \'',file_get_contents('ipn/paypal.log'));
  670.     $ppe = 0;
  671.     $i = 0;
  672.     foreach ($ppx as $p) {
  673.         if ($i % 4 == 3)
  674.             $ppe += (int)$p;
  675.         $i += 1;
  676.     }
  677.     setlocale(LC_MONETARY, 'en_US');
  678.     $main_content .= '
  679.     <div><br><br><b>Payment Stats</b>
  680.     <br>ContenidoPago Earnings: '.number_format( ($pl2[0]*4.40)*0.6, 2, ',', ' ').'
  681.     <br>Paypal Earnings: '.number_format( ($ppe)*0.95, 2, ',', ' ').'
  682.     </div>
  683.     ';
  684.     }
  685. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement