Advertisement
Guest User

Untitled

a guest
Apr 4th, 2013
486
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 45.55 KB | None | 0 0
  1. <?PHP
  2. if($config['site']['shopguild_system'] == 1) {
  3.     if($logged)
  4.         $user_guild_points = $account_logged->getCustomField('guild_points');
  5.     else
  6.         $user_guild_points = 'Login first';
  7.  
  8. function getItemByID($id)
  9. {
  10.   $id = (int) $id;
  11.   $SQL = $GLOBALS['SQL'];
  12.   $data = $SQL->query('SELECT * FROM '.$SQL->tableName('z_shopguild_offer').' WHERE '.$SQL->fieldName('id').' = '.$SQL->quote($id).';')->fetch();
  13.   if ($data['offer_type'] == 'pacc')
  14.   {
  15.     $offer['id'] = $data['id'];
  16.     $offer['type'] = $data['offer_type'];
  17.     $offer['days'] = $data['count1'];
  18.     $offer['points'] = $data['points'];
  19.     $offer['description'] = $data['offer_description'];
  20.     $offer['name'] = $data['offer_name'];
  21.   }
  22.   elseif ($data['offer_type'] == 'item')
  23.   {
  24.     $offer['id'] = $data['id'];
  25.     $offer['type'] = $data['offer_type'];
  26.     $offer['item_id'] = $data['itemid1'];
  27.     $offer['item_count'] = $data['count1'];
  28.     $offer['points'] = $data['points'];
  29.     $offer['description'] = $data['offer_description'];
  30.     $offer['name'] = $data['offer_name'];
  31.   }
  32.   elseif ($data['offer_type'] == 'vipdays')
  33.   {
  34.     $offer['id'] = $data['id'];
  35.     $offer['type'] = $data['offer_type'];
  36.     $offer['days'] = $data['count1'];
  37.     $offer['points'] = $data['points'];
  38.     $offer['description'] = $data['offer_description'];
  39.     $offer['name'] = $data['offer_name'];
  40.   }
  41.   elseif ($data['offer_type'] == 'megaitems')
  42.   {
  43.     $offer['id'] = $data['id'];
  44.     $offer['type'] = $data['offer_type'];
  45.     $offer['item_id'] = $data['itemid1'];
  46.     $offer['item_count'] = $data['count1'];
  47.     $offer['points'] = $data['points'];
  48.     $offer['description'] = $data['offer_description'];
  49.     $offer['name'] = $data['offer_name'];
  50.   }
  51.   elseif ($data['offer_type'] == 'container')
  52.   {
  53.     $offer['id'] = $data['id'];
  54.     $offer['type'] = $data['offer_type'];
  55.     $offer['container_id'] = $data['itemid2'];
  56.     $offer['container_count'] = $data['count2'];
  57.     $offer['item_id'] = $data['itemid1'];
  58.     $offer['item_count'] = $data['count1'];
  59.     $offer['points'] = $data['points'];
  60.     $offer['description'] = $data['offer_description'];
  61.     $offer['name'] = $data['offer_name'];
  62.   }
  63.   elseif ($data['offer_type'] == 'unban')
  64.   {
  65.     $offer['id'] = $data['id'];
  66.     $offer['type'] = $data['offer_type'];
  67.     $offer['points'] = $data['points'];
  68.     $offer['description'] = $data['offer_description'];
  69.     $offer['name'] = $data['offer_name'];
  70.   }
  71.   elseif ($data['offer_type'] == 'redskull')
  72.   {
  73.     $offer['id'] = $data['id'];
  74.     $offer['type'] = $data['offer_type'];
  75.     $offer['points'] = $data['points'];
  76.     $offer['description'] = $data['offer_description'];
  77.     $offer['name'] = $data['offer_name'];
  78.   }
  79.   elseif ($data['offer_type'] == 'itemlogout')
  80.   {
  81.     $offer['id'] = $data['id'];
  82.     $offer['type'] = $data['offer_type'];
  83.     $offer['points'] = $data['points'];
  84.     $offer['description'] = $data['offer_description'];
  85.     $offer['pid'] = $data['pid'];
  86.     $offer['count1'] = $data['count1'];
  87.     $offer['item_id'] = $data['itemid1'];
  88.     $offer['free_cap'] = $data['free_cap'];
  89.   }
  90.   elseif ($data['offer_type'] == 'changename')
  91.   {
  92.     $offer['id'] = $data['id'];
  93.     $offer['type'] = $data['offer_type'];
  94.     $offer['points'] = $data['points'];
  95.     $offer['description'] = $data['offer_description'];
  96.     $offer['name'] = $data['offer_name'];
  97.   }
  98.   return $offer;
  99. }
  100.  
  101. function getOfferArray()
  102. {
  103.   $offer_list = $GLOBALS['SQL']->query('SELECT * FROM '.$GLOBALS['SQL']->tableName('z_shopguild_offer').';');
  104.   $i_pacc = 0;
  105.   $i_item = 0;
  106.   $i_vipdays = 0;
  107.   $i_megaitems = 0;
  108.   $i_container = 0;
  109.   $i_unban = 0;
  110.   $i_redskull = 0;
  111.   $i_itemlogout = 0;
  112.   $i_changename = 0;
  113.   while($data = $offer_list->fetch()) {
  114.     if ($data['offer_type'] == 'pacc')
  115.     {
  116.       $offer_array['pacc'][$i_pacc]['id'] = $data['id'];
  117.       $offer_array['pacc'][$i_pacc]['days'] = $data['count1'];
  118.       $offer_array['pacc'][$i_pacc]['points'] = $data['points'];
  119.       $offer_array['pacc'][$i_pacc]['description'] = $data['offer_description'];
  120.       $offer_array['pacc'][$i_pacc]['name'] = $data['offer_name'];
  121.       $i_pacc++;
  122.     }
  123.     elseif ($data['offer_type'] == 'item')
  124.     {
  125.       $offer_array['item'][$i_item]['id'] = $data['id'];
  126.       $offer_array['item'][$i_item]['item_id'] = $data['itemid1'];
  127.       $offer_array['item'][$i_item]['item_count'] = $data['count1'];
  128.       $offer_array['item'][$i_item]['points'] = $data['points'];
  129.       $offer_array['item'][$i_item]['description'] = $data['offer_description'];
  130.       $offer_array['item'][$i_item]['name'] = $data['offer_name'];
  131.       $i_item++;
  132.     }
  133.     elseif ($data['offer_type'] == 'vipdays')
  134.     {
  135.       $offer_array['vipdays'][$i_vipdays]['id'] = $data['id'];
  136.       $offer_array['vipdays'][$i_vipdays]['days'] = $data['count1'];
  137.       $offer_array['vipdays'][$i_vipdays]['points'] = $data['points'];
  138.       $offer_array['vipdays'][$i_vipdays]['description'] = $data['offer_description'];
  139.       $offer_array['vipdays'][$i_vipdays]['name'] = $data['offer_name'];
  140.       $i_vipdays++;
  141.     }
  142.     elseif ($data['offer_type'] == 'megaitems')
  143.     {
  144.       $offer_array['megaitems'][$i_megaitems]['id'] = $data['id'];
  145.       $offer_array['megaitems'][$i_megaitems]['item_id'] = $data['itemid1'];
  146.       $offer_array['megaitems'][$i_megaitems]['item_count'] = $data['count1'];
  147.       $offer_array['megaitems'][$i_megaitems]['points'] = $data['points'];
  148.       $offer_array['megaitems'][$i_megaitems]['description'] = $data['offer_description'];
  149.       $offer_array['megaitems'][$i_megaitems]['name'] = $data['offer_name'];
  150.       $i_megaitems++;
  151.     }
  152.     elseif ($data['offer_type'] == 'container')
  153.     {
  154.       $offer_array['container'][$i_container]['id'] = $data['id'];
  155.       $offer_array['container'][$i_container]['container_id'] = $data['itemid2'];
  156.       $offer_array['container'][$i_container]['container_count'] = $data['count2'];
  157.       $offer_array['container'][$i_container]['item_id'] = $data['itemid1'];
  158.       $offer_array['container'][$i_container]['item_count'] = $data['count1'];
  159.       $offer_array['container'][$i_container]['points'] = $data['points'];
  160.       $offer_array['container'][$i_container]['description'] = $data['offer_description'];
  161.       $offer_array['container'][$i_container]['name'] = $data['offer_name'];
  162.       $i_container++;
  163.     }
  164.     elseif ($data['offer_type'] == 'unban')
  165.     {
  166.       $offer_array['unban'][$i_unban]['id'] = $data['id'];
  167.       $offer_array['unban'][$i_unban]['points'] = $data['points'];
  168.       $offer_array['unban'][$i_unban]['description'] = $data['offer_description'];
  169.       $offer_array['unban'][$i_unban]['name'] = $data['offer_name'];
  170.       $i_unban++;
  171.     }
  172.     elseif ($data['offer_type'] == 'redskull')
  173.     {
  174.       $offer_array['redskull'][$i_redskull]['id'] = $data['id'];
  175.       $offer_array['redskull'][$i_redskull]['points'] = $data['points'];
  176.       $offer_array['redskull'][$i_redskull]['description'] = $data['offer_description'];
  177.       $offer_array['redskull'][$i_redskull]['name'] = $data['offer_name'];
  178.       $i_redskull++;
  179.     }
  180.     elseif ($data['offer_type'] == 'itemlogout')
  181.     {
  182.       $offer_array['itemlogout'][$i_itemlogout]['id'] = $data['id'];
  183.       $offer_array['itemlogout'][$i_itemlogout]['points'] = $data['points'];
  184.       $offer_array['itemlogout'][$i_itemlogout]['description'] = $data['offer_description'];
  185.       $offer_array['itemlogout'][$i_itemlogout]['name'] = $data['offer_name'];
  186.       $offer_array['itemlogout'][$i_itemlogout]['count1'] = $data['count1'];
  187.       $offer_array['itemlogout'][$i_itemlogout]['pid'] = $data['pid'];
  188.       $offer_array['itemlogout'][$i_itemlogout]['item_id'] = $data['itemid1'];
  189.       $offer_array['itemlogout'][$i_itemlogout]['free_cap'] = $data['free_cap'];
  190.       $i_itemlogout++;
  191.     }
  192.     elseif ($data['offer_type'] == 'changename')
  193.     {
  194.       $offer_array['changename'][$i_changename]['id'] = $data['id'];
  195.       $offer_array['changename'][$i_changename]['points'] = $data['points'];
  196.       $offer_array['changename'][$i_changename]['description'] = $data['offer_description'];
  197.       $offer_array['changename'][$i_changename]['name'] = $data['offer_name'];
  198.       $i_changename++;
  199.     }
  200.   }
  201.   return $offer_array;
  202. }
  203.  
  204.     if($action == '') {
  205.         unset($_SESSION['viewed_confirmation_page']);
  206.         $main_content .= '<div style="text-align: justify;"><center><h2>Welcome to '.$config['server']['serverName'].' Shop.</h2></center></div><div style="text-align: justify;"><center><font color="#2F4F4F"><font size="1"><b>Items comprados e depois <font color="#FF0000">duplicados</font> s&atilde;o <u>automaticamente</u> <font color="#FF0000">deletados</font> por sistemas implementados dentro do servidor.</center></div> <center>Que fique bem claro que n&oacute;s da <font color="#FF0000">Equipe</font> n&atilde;o temos a <u>obriga&ccedil;&atilde;o</u> e n&atilde;o iremos <font color="#FF0000">devolver</font> items <u>perdidos</u> ou <u>roubados</u>!</b></font></font><center><br />';
  207.         $offer_list = getOfferArray();
  208.             //show list of items offers
  209.             if(count($offer_list['vipdays']) > 0 or count($offer_list['container']) > 0 or count($offer_list['itemlogout']) > 0)
  210.                 $main_content .= '<center><table border="0" cellpadding="1" cellspacing="1" width="650"><tr width="650" bgcolor="#505050"><td colspan="3"><font color="white" size="4"><b>&nbsp;VIP DAYS</b></font></td></tr><tr bgcolor="#D4C0A1"><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>';
  211.                 if(count($offer_list['vipdays']) > 0) {
  212.                     foreach($offer_list['vipdays'] as $item) {
  213.                         $main_content .= '<tr bgcolor="#F1E0C6"><td align="center"><img src="item_images/'.$item['id'].'.gif"></td><td><b>'.$item['name'].'</b> ('.$item['points'].' points)<br />'.$item['description'].'</td><td align="center">';
  214.                         if(!$logged) $main_content .= '<b>Login to buy</b>'; else
  215.                         $main_content .= '<form action="index.php?subtopic=shopguild&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>';
  216.                         $main_content .= '</td></tr>';
  217.                     }
  218.                     $main_content .= '</table><br />';
  219.                 }
  220.             //show list of items offers
  221.             if(count($offer_list['megaitems']) > 0 or count($offer_list['container']) > 0 or count($offer_list['itemlogout']) > 0)
  222.                 $main_content .= '<center><table border="0" cellpadding="1" cellspacing="1" width="650"><tr width="650" bgcolor="#505050"><td colspan="3"><font color="white" size="4"><b>&nbsp;VIP ITEMS</b></font></td></tr><tr bgcolor="#D4C0A1"><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>';
  223.                 if(count($offer_list['megaitems']) > 0) {
  224.                     foreach($offer_list['megaitems'] as $item) {
  225.                         $main_content .= '<tr bgcolor="#F1E0C6"><td align="center"><img src="item_images/'.$item['id'].'.gif"></td><td><b>'.$item['name'].'</b> ('.$item['points'].' points)<br />'.$item['description'].'</td><td align="center">';
  226.                         if(!$logged) $main_content .= '<b>Login to buy</b>'; else
  227.                         $main_content .= '<form action="index.php?subtopic=shopguild&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>';
  228.                         $main_content .= '</td></tr>';
  229.                     }
  230.                     $main_content .= '</table><br />';
  231.                 }
  232.             //show list of items offers
  233.             if(count($offer_list['item']) > 0 or count($offer_list['container']) > 0 or count($offer_list['itemlogout']) > 0)
  234.                 $main_content .= '<center><table border="0" cellpadding="1" cellspacing="1" width="650"><tr width="650" bgcolor="#505050"><td colspan="3"><font color="white" size="4"><b>&nbsp;ITEMS</b></font></td></tr><tr bgcolor="#D4C0A1"><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>';
  235.                 if(count($offer_list['item']) > 0) {
  236.                     foreach($offer_list['item'] as $item) {
  237.                         $main_content .= '<tr bgcolor="#F1E0C6"><td align="center"><img src="item_images/'.$item['id'].'.gif"></td><td><b>'.$item['name'].'</b> ('.$item['points'].' points)<br />'.$item['description'].'</td><td align="center">';
  238.                         if(!$logged) $main_content .= '<b>Login to buy</b>'; else
  239.                         $main_content .= '<form action="index.php?subtopic=shopguild&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.                         $main_content .= '</td></tr>';
  241.                     }
  242.                     $main_content .= '</table><br />';
  243.                 }
  244.                 //show list of containers offers
  245.                 if(count($offer_list['container']) > 0) {
  246.                     $main_content .= '<table border="0" cellpadding="1" cellspacing="1" width="650"><tr width="650" bgcolor="#505050"><td colspan="3"><font color="white" size="4"><b>&nbsp;CONTAINERS WITH ITEMS</b></font></td></tr><tr bgcolor="#D4C0A1"><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>';
  247.                     foreach($offer_list['container'] as $container) {
  248.                         $main_content .= '<tr bgcolor="#F1E0C6"><td align="center"><img src="item_images/'.$container['id'].'.gif"></td><td><b>'.$container['name'].'</b> ('.$container['points'].' points)<br />'.$container['description'].'</td><td align="center">';
  249.                         if(!$logged) $main_content .= '<b>Login to buy</b>'; else
  250.                         $main_content .= '<form action="?subtopic=shopguild&action=select_player" method=POST><input type="hidden" name="buy_id" value="'.$container['id'].'"><input type="submit" value="Buy '.$container['name'].'"><br><b>for '.$container['points'].' points</b></form>';
  251.                         $main_content .= '</td></tr>';
  252.                     }
  253.                     $main_content .= '</table><br />';
  254.                 }
  255.                 if(count($offer_list['itemlogout']) > 0) {
  256.                     $main_content .= '<table border="0" cellpadding="1" cellspacing="1" width="650"><tr width="650" bgcolor="#505050"><td colspan="3"><font color="white" size="4"><b>&nbsp;Receive Item on Logout</b></font></td></tr><tr bgcolor="#D4C0A1"><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>';
  257.                     foreach($offer_list['itemlogout'] as $itemlogout) {
  258.                         $main_content .= '<tr bgcolor="#F1E0C6"><td align="center"><img src="item_images/'.$itemlogout['id'].'.gif"></td><td><b>'.$itemlogout['name'].'</b> ('.$itemlogout['points'].' points)<br />'.$itemlogout['description'].'</td><td align="center">';
  259.                         if(!$logged) $main_content .= '<b>Login to buy</b>'; else
  260.                         $main_content .= '<form action="index.php?subtopic=shopguild&action=select_player" method=POST><input type="hidden" name="buy_id" value="'.$itemlogout['id'].'"><input type="submit" value="Buy '.$itemlogout['name'].'"><br><b>for '.$itemlogout['points'].' points</b></form>';
  261.                         $main_content .= '</td></tr>';
  262.                     }
  263.                     $main_content .= '</table><br />';
  264.                 }
  265.             if(count($offer_list['changename']) > 0 or count($offer_list['pacc']) > 0 or count($offer_list['redskull']) > 0 or count($offer_list['unban']) > 0 )
  266.                 $main_content .= '<center><table border="0" cellpadding="1" cellspacing="1" width="650"><tr width="650" bgcolor="#505050"><td colspan="3"><font color="white" size="4"><b>&nbsp;Others</b></font></td></tr><tr bgcolor="#D4C0A1"><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>';
  267.                 //Pacc
  268.                 if(count($offer_list['pacc']) > 0)
  269.                     foreach($offer_list['pacc'] as $pacc) {
  270.                         $main_content .= '<tr bgcolor="#F1E0C6"><td align="center">'.$pacc['days'].'</td><td><b>'.$pacc['name'].'</b> ('.$pacc['points'].' points)<br />'.$pacc['description'].'</td><td align="center">';
  271.                         if(!$logged) $main_content .= '<b>Login to buy</b>'; else
  272.                         $main_content .= '<form action="index.php?subtopic=shopguild&action=select_player" method=POST><input type="hidden" name="buy_id" value="'.$pacc['id'].'"><input type="submit" value="Buy '.$pacc['name'].'"><br><b>for '.$pacc['points'].' points</b></form>';
  273.                     }
  274.                 //Change Name
  275.                 if(count($offer_list['changename']) > 0)
  276.                     foreach($offer_list['changename'] as $changename) {
  277.                         $main_content .= '<tr bgcolor="#F1E0C6"><td align="center">Change Name</td><td><b>'.$changename['name'].'</b> ('.$changename['points'].' points)<br />'.$changename['description'].'</td><td align="center">';
  278.                         if(!$logged) $main_content .= '<b>Login to buy</b>'; else
  279.                         $main_content .= '<form action="index.php?subtopic=shopguild&action=select_player" method=POST><input type="hidden" name="buy_id" value="'.$changename['id'].'"><input type="submit" value="Buy '.$changename['name'].'"><br><b>for '.$changename['points'].' points</b></form>';
  280.                     }
  281.                 //Remove Red Skull
  282.                 if(count($offer_list['redskull']) > 0)
  283.                     foreach($offer_list['redskull'] as $redskull) {
  284.                         $main_content .= '<tr bgcolor="#F1E0C6"><td align="center"><img src="item_images/'.$redskull['id'].'.gif"></td><td><b>'.$redskull['name'].'</b> ('.$redskull['points'].' points)<br />'.$redskull['description'].'</td><td align="center">';
  285.                         if(!$logged) $main_content .= '<b>Login to buy</b>'; else
  286.                         $main_content .= '<form action="index.php?subtopic=shopguild&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>';
  287.                         $main_content .= '</td></tr>';
  288.                     }
  289.                 //Unban
  290.                 if(count($offer_list['unban']) > 0)
  291.                     foreach($offer_list['unban'] as $unban){
  292.                         $main_content .= '<tr bgcolor="#F1E0C6"><td align="center">Unban</td><td><b>'.$unban['name'].'</b> ('.$unban['points'].' points)<br />'.$unban['description'].'</td><td align="center">';
  293.                         if(!$logged) $main_content .= '<b>Login to buy</b>'; else
  294.                         $main_content .= '<form action="index.php?subtopic=shopguild&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>';
  295.                         $main_content .= '</td></tr>';
  296.                     }
  297.                     $main_content .= '</table>';
  298.     }
  299.     elseif($action == 'select_player') {
  300.         unset($_SESSION['viewed_confirmation_page']);
  301.         if(!$logged) {
  302.             $main_content .= 'Please login first.';
  303.         } else {
  304.             $buy_id = (int) $_REQUEST['buy_id'];
  305.             if(empty($buy_id)) {
  306.                 $main_content .= 'Please <a href="index.php?subtopic=shopguild">select item</a> first.';
  307.             } else {
  308.                 $buy_offer = getItemByID($buy_id);
  309.                 if(isset($buy_offer['id'])) {  //item exist in database
  310.                     if($buy_offer['type'] != 'changename') {
  311.                         if($user_guild_points >= $buy_offer['points']) {
  312.                             $main_content .= '<center><h2>Select player</h2><table border="0" cellpadding="1" cellspacing="1" width="650">
  313.                                 <tr bgcolor="#505050"><td colspan="2"><font color="white" size="4"><b>Selected offer</b></font></td></tr>
  314.                                 <tr bgcolor="#F1E0C6"><td width="100"><b>Name:</b></td><td width="550">'.$buy_offer['name'].'</td></tr>
  315.                                 <tr bgcolor="#D4C0A1"><td width="100"><b>Description:</b></td><td width="550">'.$buy_offer['description'].'</td></tr>
  316.                                 </table><br /><form action="index.php?subtopic=shopguild&action=confirm_transaction" method=POST><input type="hidden" name="buy_id" value="'.$buy_id.'">
  317.                                 <table border="0" cellpadding="1" cellspacing="1" width="650">
  318.                                 <tr bgcolor="#505050"><td colspan="2"><font color="white" size="4"><b>Give item to a player from your account</b></font></td></tr>
  319.                                 <tr bgcolor="#F1E0C6"><td width="110"><b>Name:</b></td><td width="550"><select name="buy_name">';
  320.                                 $players_from_logged_acc = $account_logged->getPlayersList();
  321.                             if(count($players_from_logged_acc) > 0) {
  322.                                 $players_from_logged_acc->orderBy('name');
  323.                                 foreach($players_from_logged_acc as $player)
  324.                                     $main_content .= '<option>'.$player->getName().'</option>';
  325.                             } else {
  326.                                 $main_content .= 'You don\'t have any character on your account.';
  327.                             }
  328.                             $main_content .= '</select>&nbsp;<input type="submit" value="Give"></td></tr></table>
  329.                                 </form><br /><form action="index.php?subtopic=shopguild&action=confirm_transaction" method=POST><input type="hidden" name="buy_id" value="'.$buy_id.'">
  330.                                 <table border="0" cellpadding="1" cellspacing="1" width="650">
  331.  
  332.                                 </table><br /></form>';
  333.                         } else {
  334.                             $main_content .= 'For this item you need <b>'.$buy_offer['points'].'</b> points.<br>You have only <b>'.$user_guild_points.'</b> premium points. Please <a href="index.php?subtopic=shopguild">select other item</a> or buy premium points.';
  335.                         }
  336.                     } else {
  337.                     $main_content .= '<center><h2>Change Name</h2><form action="index.php?subtopic=shopguild&action=confirm_transaction" method=POST><input type="hidden" name="buy_id" value="'.$buy_id.'">
  338.                         <table border="0" cellpadding="1" cellspacing="1" width="650"><tr bgcolor="#505050"><td colspan="2"><font color="white" size="4"><b>Change Name:</b></font></td></tr>
  339.                         <tr bgcolor="#D4C0A1"><td width="110"><b>Name:</b></td><td width="550"><select name="buy_name">';
  340.                     $players_from_logged_acc = $account_logged->getPlayersList();
  341.                         if(count($players_from_logged_acc) > 0) {
  342.                             $players_from_logged_acc->orderBy('name');
  343.                             foreach($players_from_logged_acc as $player) {
  344.                                 $main_content .= '<option>'.$player->getName().'</option>';
  345.                             }
  346.                         } else {
  347.                             $main_content .= 'You don\'t have any character on your account.';
  348.                         }
  349.                         $main_content .= '</select></td></tr><tr bgcolor="#F1E0C6"><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>';
  350.                     }
  351.                 } else {
  352.                         $main_content .= 'Offer with ID <b>'.$buy_id.'</b> doesn\'t exist. Please <a href="index.php?subtopic=shopguild">select item</a> again.';
  353.                 }
  354.             }
  355.         }
  356.     }
  357.     elseif($action == 'confirm_transaction') {
  358.         if(!$logged) {
  359.             $main_content .= 'Please login first.';
  360.         } else {
  361.             $buy_id = (int) $_POST['buy_id'];
  362.             $buy_name = stripslashes(urldecode($_POST['buy_name']));
  363.             $buy_from = stripslashes(urldecode($_POST['buy_from']));
  364.             if(empty($buy_id)) {
  365.                 $main_content .= 'Please <a href="index.php?subtopic=shopguild">select item</a> first.';
  366.             } else {
  367.                 if($buy_offer['type'] == 'changename'){
  368.                     if(!check_name_new_char($buy_from)) {
  369.                         $main_content .= 'Invalid name format of new name.';
  370.                     }
  371.                 } else {
  372.                     $buy_offer = getItemByID($buy_id);
  373.                     $check_name_in_database = $ots->createObject('Player');
  374.                     $check_name_in_database->find($buy_from);
  375.                     if($buy_offer['type'] == 'changename'){
  376.                         if(!$check_name_in_database->isLoaded()) {
  377.                         }
  378.                     }
  379.                     if(isset($buy_offer['id'])) {  //item exist in database
  380.                         if($user_guild_points >= $buy_offer['points']) {
  381.                             if(check_name($buy_name)) {
  382.                                 $buy_player = new OTS_Player();
  383.                                 $buy_player->find($buy_name);
  384.                                 if($buy_player->isLoaded()) {
  385.                                     $buy_player_account = $buy_player->getAccount();
  386.                                     if($_SESSION['viewed_confirmation_page'] == 'yes' && $_POST['buy_confirmed'] == 'yes') {
  387.                                        
  388.                                        
  389.                                        
  390.             if($buy_offer['type'] == 'pacc') {
  391.                 $player_vip_time = $buy_player_account->getCustomField('vip_time');
  392.                 $player_lastlogin = $buy_player_account->getCustomField('lastday');
  393.                 $save_transaction = 'INSERT INTO '.$SQL->tableName('z_shopguild_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()).');';
  394.                 $SQL->query($save_transaction);
  395.                 if($player_vip_time > 0)
  396.                     $buy_player_account->setCustomField('vip_time', $player_vip_time + $buy_offer['days'] * 86400);
  397.                 else
  398.                     $buy_player_account->setCustomField('vip_time', time() + $buy_offer['days'] * 86400);
  399.                 $buy_player_account->setCustomField('guild_points', $user_guild_points-$buy_offer['points']);
  400.                 $user_guild_points = $user_guild_points - $buy_offer['points'];
  401.                 if ($player_vip_days >= 1) {
  402.                 }
  403.                 $main_content .= '<center><h2>VIP Days added!</h2><b>'.$buy_offer['days'].' days</b> of VIP days 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_guild_points.' premium points</b>.<br><br><a href="index.php?subtopic=shopguild">Go to Shop Site</a><br>';
  404.                 }
  405.             elseif($buy_offer['type'] == 'unban') {
  406.                 $my_acc_id = $account_logged->getCustomField('id');
  407.                 $datadata = $SQL->query('SELECT * FROM '.$SQL->tableName('bans').' WHERE value = '.$my_acc_id.';')->fetch();
  408.                     if($datadata['value'] == $my_acc_id) {
  409.                         if($SQL->query('DELETE FROM bans WHERE value= '.$my_acc_id.' LIMIT 1;')) {
  410.                         } else {
  411.                             $SQL->query('DELETE FROM bans WHERE account= '.$my_acc_id.' LIMIT 1;');
  412.                         }
  413.                         $account_logged->setCustomField('guild_points', $user_guild_points-$buy_offer['points']);
  414.                         $user_guild_points = $user_guild_points - $buy_offer['points'];
  415.                         $main_content .= '<center><h2>Ban Deleted!</h2><b>Your account has been unbanned for '.$buy_offer['points'].' premium points</b> from your account.
  416.                             <br>Now you have <b>'.$user_guild_points.' premium points</b>.<br><br><a href="index.php?subtopic=shopguild">Go to Shop Site</a><br>';
  417.                     } else {
  418.                         $main_content .= '<center><b>You don\'t have any bans in your account!</b><br><br><a href="index.php?subtopic=shopguild">Go back</a><br>';
  419.                     }
  420.                 }
  421.                                         ////////////////////////////////
  422.                                         elseif($buy_offer['type'] == 'itemlogout') {
  423.                                             $my_acc_id = $buy_player->getCustomField('id');
  424.                                             $playerinfo = $SQL->query('SELECT * FROM '.$SQL->tableName('players').' WHERE id = '.$my_acc_id.';')->fetch();
  425.                                             $playerslot = $SQL->query('SELECT * FROM '.$SQL->tableName('player_items').' WHERE player_id = '.$my_acc_id.';')->fetch();
  426.                                             if($playerinfo['online'] == '0') {
  427.                                                 if ($playerslot['pid'] != '10') {
  428.                                                     if ($datadata['cap'] >= $SQL->quote($buy_offer['free_cap'])) {
  429.                                                         $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']).');');
  430.                                                         $account_logged->setCustomField('guild_points', $user_guild_points-$buy_offer['points']);
  431.                                                         $user_guild_points = $user_guild_points - $buy_offer['points'];
  432.                                                         $main_content .= '<h2>Item received to player: '.$buy_player->getName().'!</h2><br>Now you have <b>'.$user_guild_points.' premium points</b>.
  433.                                                             <br><a href="index.php?subtopic=shopguild">Go to Shop Site</a>';
  434.                                                     } else {
  435.                                                         $main_content .= '<b>You need '.$SQL->quote($buy_offer['free_cap']).' or more of cap!</b><br><a href="index.php?subtopic=shopguild">Go back</a>';
  436.                                                     }
  437.                                                 } else {
  438.                                                     $main_content .= '<b>Please leave the arrow slot in blank to receive item!</b><br><a href="index.php?subtopic=shopguild">Go back</a>';
  439.                                                 }
  440.                                             } else {
  441.                                                 $main_content .= '<b>You need to be offline!</b><br><a href="index.php?subtopic=shopguild">Go back</a>';
  442.                                             }
  443.                                         }
  444.                                         ////////////////////////////////
  445.                                         elseif($buy_offer['type'] == 'changename') {
  446.                                         $erroName=0;
  447.                                         if(!check_name_new_char($buy_from)) {
  448.                                             $main_content .= 'Invalid name format of new name.';
  449.                                             $erroName++;
  450.                                         }
  451.                                        
  452.                                             $my_acc_id = $buy_player->getCustomField('id');
  453.                                             $playerinfo = $SQL->query('SELECT * FROM '.$SQL->tableName('players').' WHERE '.$SQL->fieldName('id').' = '.$my_acc_id.';')->fetch();
  454.                                             $checkname = $SQL->query('SELECT * FROM '.$SQL->tableName('players').' WHERE '.$SQL->fieldName('name').' = '. $SQL->quote($buy_from) .';')->fetch();
  455.                                             if($playerinfo['online'] == '0') {
  456.                                                
  457.                                                 if($checkname == false and $erroName == 0) {
  458.                                                     $SQL->query('UPDATE `players` SET `name` = '. $SQL->quote($buy_from) .' WHERE `id` = '. $my_acc_id.' ;');
  459.                                                     $account_logged->setCustomField('guild_points', $user_guild_points-$buy_offer['points']);
  460.                                                     $user_guild_points = $user_guild_points - $buy_offer['points'];
  461.                                                     $main_content .= '<center><h2>Your name has been changed to '.$buy_from.'.</h2><br><b>You have '.$user_guild_points.' premium points left</b>.
  462.                                                         <br><br><a href="index.php?subtopic=shopguild">Go to Shop Site</a><br>';
  463.                                                 } else {
  464.                                                     $main_content .= '<center><h2>Sorry, the name "<i>'.$buy_from.'</i>" does already exist.<br>Please select another name.</h2><br>';
  465.                                                 }
  466.                                             } else {
  467.                                                 $main_content .= '<center><h2>'.$buy_name.' has to be offline to complete transaction.</h2><br><br><a href="index.php?subtopic=shopguild">Go back</a><br>';
  468.                                             }
  469.                                         }
  470.                                         ////////////////////////////////
  471.                                         elseif($buy_offer['type'] == 'redskull') {
  472.                                             $my_acc_id = $buy_player->getCustomField('id');
  473.                                             $playerinfo = $SQL->query('SELECT * FROM '.$SQL->tableName('players').' WHERE '.$SQL->fieldName('id').' = '.$my_acc_id.';')->fetch();
  474.                                             if($playerinfo['skull'] == '4' AND $playerinfo['online'] >= '0' AND $playerinfo['skulltime'] > '0') {
  475.                                                 $SQL->query('UPDATE killers SET unjustified=0 WHERE id IN (SELECT kill_id FROM player_killers WHERE player_id='. $my_acc_id .');');
  476.                                                 $SQL->query('UPDATE players SET skulltime=0, skull=0 WHERE id='. $my_acc_id .';');
  477.                                                 $account_logged->setCustomField('guild_points', $user_guild_points-$buy_offer['points']);
  478.                                                 $user_guild_points = $user_guild_points - $buy_offer['points'];
  479.                                                 $main_content .= '<center><h2>RedSkull Removed!</h2><br><b>Your redskull has been removed from the player '.$buy_player->getName().'.</b>
  480.                                                     <br>Now you have<b> '.$user_guild_points.' premium points</b>.<br><br><a href="index.php?subtopic=shopguild">Go to Shop Site</a><br>';
  481.                                             } else {
  482.                                                 $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=shopguild">Go back</a><br>';
  483.                                             }
  484.                                         }
  485.                                         //////////////////////////
  486.                                         elseif($buy_offer['type'] == 'item') {
  487.                                             $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\');';
  488.                                             $SQL->query($sql);
  489.                                             $save_transaction = 'INSERT INTO '.$SQL->tableName('z_shopguild_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['item_id']).', \'wait\', '.$SQL->quote(time()).', \'0\');';
  490.                                             $SQL->query($save_transaction);
  491.                                             $account_logged->setCustomField('guild_points', $user_guild_points-$buy_offer['points']);
  492.                                             $user_guild_points = $user_guild_points - $buy_offer['points'];
  493.                                             $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_guild_points.' premium points</b>.<br><br><a href="index.php?subtopic=shopguild">GO TO MAIN SHOP SITE</a><br>';
  494.                                         }
  495.                                         if($buy_offer['type'] == 'vipdays') {
  496. $player_vip_time = $buy_player_account->getCustomField('vip_time');
  497. $player_lastlogin = $buy_player_account->getCustomField('lastday');
  498. $save_transaction = 'INSERT INTO '.$SQL->tableName('z_shopguild_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()).');';
  499. $SQL->query($save_transaction);
  500. if($player_vip_time > 0)
  501. $buy_player_account->setCustomField('vip_time', $player_vip_time + $buy_offer['days'] * 86400);
  502. else
  503. $buy_player_account->setCustomField('vip_time', time() + $buy_offer['days'] * 86400);
  504. $account_logged->setCustomField('guild_points', $user_guild_points-$buy_offer['points']);
  505. $user_guild_points = $user_guild_points - $buy_offer['points'];
  506. if ($player_vip_days >= 1) {
  507. }
  508. $main_content .= '<center><h2>VIP Days added!</h2><b>'.$buy_offer['days'].' days</b> of VIP days 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_guild_points.' premium points</b>.<br><br><a href="index.php?subtopic=shopguild">Go to Shop Site</a><br>';
  509. }  
  510.                                         elseif($buy_offer['type'] == 'megaitems') {
  511.                                             $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['megaitems_count']).', \'\', \'\', \'megaitems\', '.$SQL->quote($buy_offer['name']).', \'\', \'1\');';
  512.                                             $SQL->query($sql);
  513.                                             $save_transaction = 'INSERT INTO '.$SQL->tableName('z_shopguild_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['item_id']).', \'wait\', '.$SQL->quote(time()).', \'0\');';
  514.                                             $SQL->query($save_transaction);
  515.                                             $account_logged->setCustomField('guild_points', $user_guild_points-$buy_offer['points']);
  516.                                             $user_guild_points = $user_guild_points - $buy_offer['points'];
  517.                                             $main_content .= '<center><h2>Mega 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_guild_points.' premium points</b>.<br><br><a href="index.php?subtopic=shopguild">GO TO MAIN SHOP SITE</a><br>';
  518.                                         }
  519.                                         elseif($buy_offer['type'] == 'container') {
  520.                                             $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\');';
  521.                                             $SQL->query($sql);
  522.                                             $save_transaction = 'INSERT INTO '.$SQL->tableName('z_shopguild_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['item_id']).', \'wait\', '.$SQL->quote(time()).', \'0\');';
  523.                                             $SQL->query($save_transaction);
  524.                                             $account_logged->setCustomField('guild_points', $user_guild_points-$buy_offer['points']);
  525.                                             $user_guild_points = $user_guild_points - $buy_offer['points'];
  526.                                             $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_guild_points.' premium points</b>.<br><br><a href="index.php?subtopic=shopguild">GO TO MAIN SHOP SITE</a><br>';
  527.                                         }
  528.                                     } else {
  529.                                         if($buy_offer['type'] != 'changename') {
  530.                                             $set_session = TRUE;
  531.                                             $_SESSION['viewed_confirmation_page'] = 'yes';
  532.                                             $main_content .= '<center><h2>Confirm transaction</h2>
  533.                                                 <table border="0" cellpadding="1" cellspacing="1" width="700">
  534.                                                 <tr bgcolor="#505050"><td colspan="3"><font color="white" size="4"><b>Confirm transaction</b></font></td></tr>
  535.                                                 <tr bgcolor="#D4C0A1"><td width="100"><b>Name:</b></td><td width="550" colspan="2">'.$buy_offer['name'].'</td></tr>
  536.                                                 <tr bgcolor="#F1E0C6"><td width="100"><b>Description:</b></td><td width="550" colspan="2">'.$buy_offer['description'].'</td></tr>
  537.                                                 <tr bgcolor="#D4C0A1"><td width="100"><b>Cost:</b></td><td width="550" colspan="2"><b>'.$buy_offer['points'].' premium points</b> from your account</td></tr>
  538.                                                 <tr bgcolor="#F1E0C6"><td width="100"><b>For Player:</b></td><td width="550" colspan="2"><font color="red">'.$buy_player->getName().'</font></td></tr>
  539.                                                 <tr bgcolor="#D4C0A1"><td width="100"><b>From:</b></td><td width="550" colspan="2"><font color="red">'.$buy_from.'</font></td></tr>
  540.                                                 <tr bgcolor="#F1E0C6"><td width="100"><b>Transaction?</b></td><td width="275" align="left">
  541.                                                 <form action="index.php?subtopic=shopguild&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>
  542.                                                 <td align="right"><form action="index.php?subtopic=shopguild" method="POST"><input type="submit" value="Cancel"></form></td></tr>
  543.                                                 </table>';
  544.                                         } else {
  545.                                             $set_session = TRUE;
  546.                                             $_SESSION['viewed_confirmation_page'] = 'yes';
  547.                                             $main_content .= '<center><h2>Confirm Name Changing</h2>
  548.                                                 <table border="0" cellpadding="1" cellspacing="1" width="700">
  549.                                                 <tr bgcolor="#505050"><td colspan="3"><font color="white" size="4"><b>Confirm transaction</b></font></td></tr>
  550.                                                 <tr bgcolor="#D4C0A1"><td width="130"><b>Name:</b></td><td width="550" colspan="2">'.$buy_offer['name'].'</td></tr>
  551.                                                 <tr bgcolor="#F1E0C6"><td width="130"><b>Description:</b></td><td width="550" colspan="2">'.$buy_offer['description'].'</td></tr>
  552.                                                 <tr bgcolor="#D4C0A1"><td width="130"><b>Cost:</b></td><td width="550" colspan="2"><b>'.$buy_offer['points'].' premium points</b> from your account</td></tr>
  553.                                                 <tr bgcolor="#F1E0C6"><td width="130"><b>Current Name:</b></td><td width="550" colspan="2"><font color="red">'.$buy_player->getName().'</font></td></tr>
  554.                                                 <tr bgcolor="#D4C0A1"><td width="130"><b>New Name:</b></td><td width="550" colspan="2"><font color="red">'.$buy_from.'</font></td></tr>
  555.                                                 <tr bgcolor="#F1E0C6"><td width="130"><b>Change Name?</b></td><td width="275" align="left">
  556.                                                 <form action="index.php?subtopic=shopguild&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>
  557.                                                 <td align="right"><form action="index.php?subtopic=shopguild" method="POST"><input type="submit" value="Cancel"></form></td></tr>
  558.                                                 </table>';
  559.                                         }
  560.                                     }
  561.                                 } else {
  562.                                     $main_content .= 'Player with name <b>'.$buy_name.'</b> doesn\'t exist. Please <a href="index.php?subtopic=shopguild&action=select_player&buy_id='.$buy_id.'">select other name</a>.';
  563.                                 }
  564.                             } else {
  565.                                 $main_content .= 'Invalid name format. Please <a href="index.php?subtopic=shopguild&action=select_player&buy_id='.$buy_id.'">select other name</a> or contact with administrator.';
  566.                             }
  567.                         } else {
  568.                             $main_content .= 'For this item you need <b>'.$buy_offer['points'].'</b> points. You have only <b>'.$user_guild_points.'</b> premium points. Please <a href="index.php?subtopic=shopguild">select other item</a> or buy premium points.';
  569.                         }
  570.                         } else {
  571.                         $main_content .= 'Offer with ID <b>'.$buy_id.'</b> doesn\'t exist. Please <a href="index.php?subtopic=shopguild">select item</a> again.';
  572.                     }
  573.                 }
  574.             }
  575.         }
  576.         if(!$set_session) {
  577.             unset($_SESSION['viewed_confirmation_page']);
  578.         }
  579.     }
  580.  
  581.     elseif($action == 'show_history') {
  582.         if(!$logged) {
  583.             $main_content .= 'Please login first.';
  584.         } else{
  585.             $items_history_received = $SQL->query('SELECT * FROM '.$SQL->tableName('z_shopguild_history_item').' WHERE '.$SQL->fieldName('to_account').' = '.$SQL->quote($account_logged->getId()).' OR '.$SQL->fieldName('from_account').' = '.$SQL->quote($account_logged->getId()).';');
  586.             if(is_object($items_history_received)) {
  587.                 foreach($items_history_received as $item_received) {
  588.                     if($account_logged->getId() == $item_received['to_account'])
  589.                         $char_color = 'green';
  590.                     else
  591.                         $char_color = 'red';
  592.                         $items_received_text .= '<tr bgcolor="#F1E0C6"><td><font color="'.$char_color.'">'.$item_received['to_name'].'</font></td><td>';
  593.                     if($account_logged->getId() == $item_received['from_account'])
  594.                         $items_received_text .= '<i>Your account</i>';
  595.                     else
  596.                         $items_received_text .= $item_received['from_nick'];
  597.                        
  598.                         $items_received_text .= '</td><td>'.$item_received['offer_id'].'</td><td>'.$item_received['price'].' Points</td><td>'.date("j F Y, H:i:s", $item_received['trans_start']).'</td>';
  599.                    
  600.                    
  601.                    
  602.                    
  603.                     if($item_received['trans_real'] > 0)
  604.                         $items_received_text .= '<td>'.date("j F Y, H:i:s", $item_received['trans_real']).'</td>';
  605.                     else
  606.                         $items_received_text .= '<td><b><font color="red">Not realized yet.</font></b></td>';
  607.                         $items_received_text .= '</tr>';
  608.                 }
  609.             }
  610.             $paccs_history_received = $SQL->query('SELECT * FROM '.$SQL->tableName('z_shopguild_history_pacc').' WHERE '.$SQL->fieldName('to_account').' = '.$SQL->quote($account_logged->getId()).' OR '.$SQL->fieldName('from_account').' = '.$SQL->quote($account_logged->getId()).';');
  611.             if(is_object($paccs_history_received)) {
  612.                 foreach($paccs_history_received as $pacc_received) {
  613.                     if($account_logged->getId() == $pacc_received['to_account'])
  614.                         $char_color = 'green';
  615.                     else
  616.                         $char_color = 'red';
  617.                         $paccs_received_text .= '<tr bgcolor="#F1E0C6"><td><font color="'.$char_color.'">'.$pacc_received['to_name'].'</font></td><td>';
  618.                     if($account_logged->getId() == $pacc_received['from_account'])
  619.                         $paccs_received_text .= '<i>Your account</i>';
  620.                     else
  621.                         $paccs_received_text .= $pacc_received['from_nick'];
  622.                         $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>';
  623.                 }
  624.             }
  625.             $main_content .= '<center><h1>Transactions History</h1></center>';
  626.             if(!empty($items_received_text))
  627.                 $main_content .= '<center><table BORDER=0 CELLPADDING=1 CELLSPACING=1 WIDTH=95%><tr width="100%" bgcolor="#505050"><td colspan="6"><font color="white" size="4"><b>&nbsp;Item Transactions</b></font></td></tr><tr bgcolor="#D4C0A1"><td><b>To:</b></td><td><b>From:</b></td><td><b>Offer name</b></td><td><b>Cost</b></td><td><b>Bought on page</b></td><td><b>Received on '.$config['server']['serverName'].'</b></td></tr>'.$items_received_text.'</table><br />';
  628.             if(!empty($paccs_received_text))
  629.                 $main_content .= '<center><table BORDER=0 CELLPADDING=1 CELLSPACING=1 WIDTH=95%><tr width="100%" bgcolor="#505050"><td colspan="5"><font color="white" size="4"><b>&nbsp;Pacc Transactions</b></font></td></tr><tr bgcolor="#D4C0A1"><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 />';
  630.             if(empty($paccs_received_text) && empty($items_received_text))
  631.                 $main_content .= 'You did not buy/receive any items or PACC.';
  632.         }
  633.     }
  634.     if(!$logged)
  635.         $main_content .= 'Please login to see how much points you have.';
  636.     else
  637.         $main_content .= '<br><b><font color="green">You have premium points: </font></b>'.$user_guild_points;
  638.     }
  639. else
  640.     $main_content .= '<br><center><b>Shop System is currently disabled for this server.Please ask the admin for more information.</b></center>';
  641. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement