Advertisement
Guest User

shopadmin.php

a guest
May 9th, 2014
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.29 KB | None | 0 0
  1. <?php
  2. if(!defined('INITIALIZED'))
  3. exit;
  4.  
  5. if($config['site']['shop_system'])
  6. {
  7. if($logged)
  8. {
  9. $user_premium_points = $account_logged->getCustomField('premium_points');
  10. }
  11. else
  12. {
  13. $user_premium_points = 'Login first';
  14. }
  15. function getItemByID($id)
  16. {
  17. $id = (int) $id;
  18. $SQL = $GLOBALS['SQL'];
  19. $data = $SQL->query('SELECT * FROM '.$SQL->tableName('z_shop_offer').' WHERE '.$SQL->fieldName('id').' = '.$SQL->quote($id).';')->fetch();
  20. if($data['offer_type'] == 'item')
  21. {
  22. $offer['id'] = $data['id'];
  23. $offer['type'] = $data['offer_type'];
  24. $offer['item_id'] = $data['itemid1'];
  25. $offer['item_count'] = $data['count1'];
  26. $offer['points'] = $data['points'];
  27. $offer['description'] = $data['offer_description'];
  28. $offer['name'] = $data['offer_name'];
  29. }
  30. elseif($data['offer_type'] == 'container')
  31. {
  32. $offer['id'] = $data['id'];
  33. $offer['type'] = $data['offer_type'];
  34. $offer['container_id'] = $data['itemid1'];
  35. $offer['container_count'] = $data['count1'];
  36. $offer['item_id'] = $data['itemid2'];
  37. $offer['item_count'] = $data['count2'];
  38. $offer['points'] = $data['points'];
  39. $offer['description'] = $data['offer_description'];
  40. $offer['name'] = $data['offer_name'];
  41. }
  42. return $offer;
  43. }
  44.  
  45. function getOfferArray()
  46. {
  47. $offer_list = $GLOBALS['SQL']->query('SELECT * FROM '.$GLOBALS['SQL']->tableName('z_shop_offer').';');
  48. $i_item = 0;
  49. $i_container = 0;
  50. while($data = $offer_list->fetch())
  51. {
  52. if($data['offer_type'] == 'item')
  53. {
  54. $offer_array['item'][$i_item]['id'] = $data['id'];
  55. $offer_array['item'][$i_item]['item_id'] = $data['itemid1'];
  56. $offer_array['item'][$i_item]['item_count'] = $data['count1'];
  57. $offer_array['item'][$i_item]['points'] = $data['points'];
  58. $offer_array['item'][$i_item]['description'] = $data['offer_description'];
  59. $offer_array['item'][$i_item]['name'] = $data['offer_name'];
  60. $i_item++;
  61. }
  62. elseif($data['offer_type'] == 'container')
  63. {
  64. $offer_array['container'][$i_container]['id'] = $data['id'];
  65. $offer_array['container'][$i_container]['container_id'] = $data['itemid1'];
  66. $offer_array['container'][$i_container]['container_count'] = $data['count1'];
  67. $offer_array['container'][$i_container]['item_id'] = $data['itemid2'];
  68. $offer_array['container'][$i_container]['item_count'] = $data['count2'];
  69. $offer_array['container'][$i_container]['points'] = $data['points'];
  70. $offer_array['container'][$i_container]['description'] = $data['offer_description'];
  71. $offer_array['container'][$i_container]['name'] = $data['offer_name'];
  72. $i_container++;
  73. }
  74. }
  75. return $offer_array;
  76. }
  77. if(($action == '') or ($action == 'item') or ($action == 'container'))
  78. {
  79. unset($_SESSION['viewed_confirmation_page']);
  80. $offer_list = getOfferArray();
  81.  
  82. if(empty($action))
  83. {
  84. if(count($offer_list['item']) > 0)
  85. $action = 'item';
  86. elseif(count($offer_list['container']) > 0)
  87. $action = 'container';
  88. }
  89.  
  90. function selectcolor($value)
  91. {
  92. if($GLOBALS['action'] == $value)
  93. return '#505050; color: #FFFFFF';
  94. else
  95. return '#303030; color: #aaaaaa';
  96. }
  97.  
  98. if((count($offer_list['item']) > 0) or (count($offer_list['container']) > 0))
  99. {
  100. $main_content .= '<TABLE WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=4><TR><TD BGCOLOR="'.$config['site']['vdarkborder'].'" ALIGN=left CLASS=white colspan="2"><B>Choose a categorie: </B>';
  101. if(count($offer_list['item']) > 0) $main_content .= '<a href="?subtopic=shopsystem&action=item" style="padding: 5px 5px 7px 5px; margin: 5px 1px 0px 1px; background-color: '.selectcolor('item').';">ITEMS</a>';
  102. if(count($offer_list['container']) > 0) $main_content .= '<a href="?subtopic=shopsystem&action=container" style="padding: 5px 5px 7px 5px; margin: 5px 1px 0px 1px; background-color: '.selectcolor('container').';">CONTAINERS</a>';
  103. $main_content .= '</TD></TR></TD></TR></table><table BORDER=0 CELLPaDDING="4" CELLSPaCING="1" style="width:100%;font-weight:bold;text-align:center;"><tr style="background:#505050;"><td colspan="3" style="height:px;"></td></tr></table>';
  104. }
  105.  
  106. //show list of items offers
  107. if((count($offer_list['item']) > 0) and ($action == 'item'))
  108. {
  109. $main_content .= '<table border="0" cellpadding="4" cellspacing="1" width="100%"><tr bgcolor="'.$config['site']['vdarkborder'].'"><td width="8%" align="center" class="white"><b>Points</b></td><td width="9%" align="center" class="white"><b>Picture</b></td><td width="350" align="left" class="white"><b>Description</b></td><td width="250" align="center" class="white"><b>Select product</b></td></tr>';
  110. foreach($offer_list['item'] as $item)
  111. {
  112. if(!is_int($number_of_rows / 2)) { $bgcolor = $config['site']['darkborder']; } else { $bgcolor = $config['site']['lightborder']; } $number_of_rows++;
  113. $main_content .= '<tr bgcolor="'.$bgcolor.'"><td align="center"><b>'.$item['points'].'</b></td><td align="center"><img src="' . $config['site']['item_images_url'] . $item['item_id'] . $config['site']['item_images_extension'] . '"></td><td><b>'.htmlspecialchars($item['name']).'</b> ('.$item['points'].' points)<br />'.htmlspecialchars($item['description']).'</td><td align="center">';
  114. if(!$logged)
  115. {
  116. $main_content .= '<b>Login to buy</b>';
  117. }
  118. else
  119. {
  120. $main_content .= '<form action="?subtopic=shopsystem&action=select_player" method="POST" name="itemform_'.$item['id'].'"><input type="hidden" name="buy_id" value="'.$item['id'].'"><div class="navibutton"><a href="" onClick="itemform_'.$item['id'].'.submit();return false;">BUY</a></div></form>';
  121. }
  122. $main_content .= '</td></tr>';
  123. }
  124. $main_content .= '</table>';
  125. }
  126. //show list of containers offers
  127. if((count($offer_list['container']) > 0) and ($action == 'container'))
  128. {
  129. if(!is_int($number_of_rows / 2)) { $bgcolor = $config['site']['darkborder']; } else { $bgcolor = $config['site']['lightborder']; } $number_of_rows++;
  130. $main_content .= '<table border="0" cellpadding="4" cellspacing="1" width="100%"><tr bgcolor="'.$config['site']['vdarkborder'].'"><td width="8%" align="center" class="white"><b>Points</b></td><td width="9%" align="center" class="white"><b>Picture</b></td><td width="350" align="left" class="white"><b>Description</b></td><td width="250" align="center" class="white"><b>Select product</b></td></tr>';
  131. foreach($offer_list['container'] as $container)
  132. {
  133. $main_content .= '<tr bgcolor="'.$bgcolor.'"><td align="center"><b>'.$container['points'].'</b></td><td align="center"><img src="' . $config['site']['item_images_url'] . $container['item_id'] . $config['site']['item_images_extension'] . '"></td><td><b>'.htmlspecialchars($container['name']).'</b> ('.$container['points'].' points)<br />'.htmlspecialchars($container['description']).'</td><td align="center">';
  134. if(!$logged)
  135. {
  136. $main_content .= '<b>Login to buy</b>';
  137. }
  138. else
  139. {
  140. $main_content .= '<form action="?subtopic=shopsystem&action=select_player" method="POST" name="contform_'.$container['id'].'"><input type="hidden" name="buy_id" value="'.$container['id'].'"><div class="navibutton"><a href="" onClick="contform_'.$container['id'].'.submit();return false;">BUY</a></div></form>';
  141. }
  142. $main_content .= '</td></tr>';
  143. }
  144. $main_content .= '</table>';
  145. }
  146.  
  147. if((count($offer_list['item']) > 0) or (count($offer_list['container']) > 0))
  148. {
  149. $main_content .= '<table BORDER=0 CELLPaDDING="4" CELLSPaCING="1" style="width:100%;font-weight:bold;text-align:center;">
  150. <tr style="background:#505050;">
  151. <td colspan="3" style="height:px;"></td>
  152. </tr>
  153. </table>';
  154. }
  155. }
  156. if($action == 'select_player')
  157. {
  158. unset($_SESSION['viewed_confirmation_page']);
  159. if(!$logged) {
  160. $errormessage .= 'Please login first.';
  161. }
  162. else
  163. {
  164. $buy_id = (int) $_REQUEST['buy_id'];
  165. if(empty($buy_id))
  166. {
  167. $errormessage .= 'Please <a href="?subtopic=shopsystem">select item</a> first.';
  168. }
  169. else
  170. {
  171. $buy_offer = getItemByID($buy_id);
  172. if(isset($buy_offer['id'])) //item exist in database
  173. {
  174. if($user_premium_points >= $buy_offer['points'])
  175. {
  176. $main_content .= '<table border="0" cellpadding="4" cellspacing="1" width="100%">
  177. <tr bgcolor="'.$config['site']['vdarkborder'].'"><td colspan="2" class="white"><b>Selected Offer</b></td></tr>
  178. <tr bgcolor="'.$config['site']['lightborder'].'"><td width="100"><b>Name:</b></td><td width="550">'.htmlspecialchars($buy_offer['name']).'</td></tr>
  179. <tr bgcolor="'.$config['site']['darkborder'].'"><td width="100"><b>Description:</b></td><td width="550">'.htmlspecialchars($buy_offer['description']).'</td></tr>
  180. </table><br />
  181. <form action="?subtopic=shopsystem&action=confirm_transaction" method="POST"><input type="hidden" name="buy_id" value="'.$buy_id.'">
  182. <table border="0" cellpadding="4" cellspacing="1" width="100%">
  183. <tr bgcolor="'.$config['site']['vdarkborder'].'"><td colspan="2" class="white"><b>Give item to player from your account</b></td></tr>
  184. <tr bgcolor="'.$config['site']['lightborder'].'"><td width="110"><b>Name:</b></td><td width="550"><select name="buy_name">';
  185. $players_from_logged_acc = $account_logged->getPlayersList();
  186. if(count($players_from_logged_acc) > 0)
  187. {
  188. foreach($players_from_logged_acc as $player)
  189. {
  190. $main_content .= '<option>'.htmlspecialchars($player->getName()).'</option>';
  191. }
  192. }
  193. else
  194. {
  195. $main_content .= 'You don\'t have any character on your account.';
  196. }
  197. $main_content .= '</select>&nbsp;<input type="submit" value="Give"></td></tr>
  198. </table>
  199. </form><br /><form action="?subtopic=shopsystem&action=confirm_transaction" method="POST"><input type="hidden" name="buy_id" value="'.$buy_id.'">
  200. <table border="0" cellpadding="4" cellspacing="1" width="100%">
  201. <tr bgcolor="'.$config['site']['vdarkborder'].'"><td colspan="2" class="white"><b>Give item to other player</b></td></tr>
  202. <tr bgcolor="'.$config['site']['lightborder'].'"><td width="110"><b>To player:</b></td><td width="550"><input type="text" name="buy_name"> - name of player</td></tr>
  203. <tr bgcolor="'.$config['site']['darkborder'].'"><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>
  204. </table><br />
  205. </form>';
  206.  
  207. }
  208. else
  209. {
  210. $errormessage .= '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.';
  211. }
  212. }
  213. else
  214. {
  215. $errormessage .= 'Offer with ID <b>'.$buy_id.'</b> doesn\'t exist. Please <a href="?subtopic=shopsystem">select item</a> again.';
  216. }
  217. }
  218. }
  219. if(!empty($errormessage))
  220. {
  221. $main_content .= '<TABLE WIDTH=100% BORDER=0 CELLSPACING=1 CELLPADDING=4>
  222. <TR><TD BGCOLOR="'.$config['site']['vdarkborder'].'" ALIGN=left CLASS=white><B>Informations</B></TD></TR>
  223. <TR><TD BGCOLOR="'.$config['site']['lightborder'].'" ALIGN=left><b>'.$errormessage.'</b></TD></TR>
  224. </table>';
  225. }
  226. }
  227. elseif($action == 'confirm_transaction')
  228. {
  229. if(!$logged)
  230. {
  231. $errormessage .= 'Please login first.';
  232. }
  233. else
  234. {
  235. $buy_id = (int) $_POST['buy_id'];
  236. $buy_name = trim($_POST['buy_name']);
  237. $buy_from = trim($_POST['buy_from']);
  238. if(empty($buy_from))
  239. {
  240. $buy_from = 'Anonymous';
  241. }
  242. if(empty($buy_id))
  243. {
  244. $errormessage .= 'Please <a href="?subtopic=shopsystem">select item</a> first.';
  245. }
  246. else
  247. {
  248. if(!check_name($buy_from))
  249. {
  250. $errormessage .= 'Invalid nick ("from player") format. Please <a href="?subtopic=shopsystem&action=select_player&buy_id='.$buy_id.'">select other name</a> or contact with administrator.';
  251. }
  252. else
  253. {
  254. $buy_offer = getItemByID($buy_id);
  255. if(isset($buy_offer['id'])) //item exist in database
  256. {
  257. if($user_premium_points >= $buy_offer['points'])
  258. {
  259. if(check_name($buy_name))
  260. {
  261. $buy_player = new Player();
  262. $buy_player->find($buy_name);
  263. if($buy_player->isLoaded())
  264. {
  265. $buy_player_account = $buy_player->getAccount();
  266. if($_SESSION['viewed_confirmation_page'] == 'yes' && $_POST['buy_confirmed'] == 'yes')
  267. {
  268. if($buy_offer['type'] == 'item')
  269. {
  270. $sql = 'INSERT INTO '.$SQL->tableName('z_ots_comunication').' ('.$SQL->fieldName('id').','.$SQL->fieldName('name').','.$SQL->fieldName('type').','.$SQL->fieldName('action').','.$SQL->fieldName('param1').','.$SQL->fieldName('param2').','.$SQL->fieldName('param3').','.$SQL->fieldName('param4').','.$SQL->fieldName('param5').','.$SQL->fieldName('param6').','.$SQL->fieldName('param7').','.$SQL->fieldName('delete_it').') VALUES (NULL, '.$SQL->quote($buy_player->getName()).', '.$SQL->quote('login').', '.$SQL->quote('give_item').', '.$SQL->quote($buy_offer['item_id']).', '.$SQL->quote($buy_offer['item_count']).', '.$SQL->quote('').', '.$SQL->quote('').', '.$SQL->quote('item').', '.$SQL->quote($buy_offer['name']).', '.$SQL->quote('').', '.$SQL->quote(1).');';
  271. $SQL->query($sql);
  272. $save_transaction = 'INSERT INTO '.$SQL->tableName('z_shop_history_item').' ('.$SQL->fieldName('id').','.$SQL->fieldName('to_name').','.$SQL->fieldName('to_account').','.$SQL->fieldName('from_nick').','.$SQL->fieldName('from_account').','.$SQL->fieldName('price').','.$SQL->fieldName('offer_id').','.$SQL->fieldName('trans_state').','.$SQL->fieldName('trans_start').','.$SQL->fieldName('trans_real').') VALUES ('.$SQL->lastInsertId().', '.$SQL->quote($buy_player->getName()).', '.$SQL->quote($buy_player_account->getId()).', '.$SQL->quote($buy_from).', '.$SQL->quote($account_logged->getId()).', '.$SQL->quote($buy_offer['points']).', '.$SQL->quote($buy_offer['name']).', '.$SQL->quote('wait').', '.$SQL->quote(time()).', '.$SQL->quote(0).');';
  273. $SQL->query($save_transaction);
  274. $account_logged->setCustomField('premium_points', $user_premium_points-$buy_offer['points']);
  275. $user_premium_points = $user_premium_points - $buy_offer['points'];
  276. $main_content .= '<TABLE WIDTH=100% BORDER=0 CELLSPACING=1 CELLPADDING=4>
  277. <TR><TD BGCOLOR="'.$config['site']['vdarkborder'].'" ALIGN=left CLASS=white><B>Item added!</B></TD></TR>
  278. <TR><TD BGCOLOR="'.$config['site']['lightborder'].'" ALIGN=left><b>'.htmlspecialchars($buy_offer['name']).'</b> added to player <b>'.htmlspecialchars($buy_player->getName()).'</b> items (he will get this items after relog) for <b>'.$buy_offer['points'].' premium points</b> from your account.<br />Now you have <b>'.$user_premium_points.' premium points</b>.<br /><a href="?subtopic=shopsystem">GO TO MAIN SHOP SITE</a></TD></TR>
  279. </table>';
  280. }
  281. elseif($buy_offer['type'] == 'container')
  282. {
  283. $sql = 'INSERT INTO '.$SQL->tableName('z_ots_comunication').' ('.$SQL->fieldName('id').','.$SQL->fieldName('name').','.$SQL->fieldName('type').','.$SQL->fieldName('action').','.$SQL->fieldName('param1').','.$SQL->fieldName('param2').','.$SQL->fieldName('param3').','.$SQL->fieldName('param4').','.$SQL->fieldName('param5').','.$SQL->fieldName('param6').','.$SQL->fieldName('param7').','.$SQL->fieldName('delete_it').') VALUES (NULL, '.$SQL->quote($buy_player->getName()).', '.$SQL->quote('login').', '.$SQL->quote('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']).', '.$SQL->quote('container').', '.$SQL->quote($buy_offer['name']).', '.$SQL->quote('').', '.$SQL->quote(1).');';
  284. $SQL->query($sql);
  285. $save_transaction = 'INSERT INTO '.$SQL->tableName('z_shop_history_item').' ('.$SQL->fieldName('id').','.$SQL->fieldName('to_name').','.$SQL->fieldName('to_account').','.$SQL->fieldName('from_nick').','.$SQL->fieldName('from_account').','.$SQL->fieldName('price').','.$SQL->fieldName('offer_id').','.$SQL->fieldName('trans_state').','.$SQL->fieldName('trans_start').','.$SQL->fieldName('trans_real').') VALUES ('.$SQL->lastInsertId().', '.$SQL->quote($buy_player->getName()).', '.$SQL->quote($buy_player_account->getId()).', '.$SQL->quote($buy_from).', '.$SQL->quote($account_logged->getId()).', '.$SQL->quote($buy_offer['points']).', '.$SQL->quote($buy_offer['name']).', '.$SQL->quote('wait').', '.$SQL->quote(time()).', '.$SQL->quote(0).');';
  286. $SQL->query($save_transaction);
  287. $account_logged->setCustomField('premium_points', $user_premium_points-$buy_offer['points']);
  288. $user_premium_points = $user_premium_points - $buy_offer['points'];
  289. $main_content .= '<TABLE WIDTH=100% BORDER=0 CELLSPACING=1 CELLPADDING=4>
  290. <TR><TD BGCOLOR="'.$config['site']['vdarkborder'].'" ALIGN=left CLASS=white><B>Container of items added!</B></TD></TR>
  291. <TR><TD BGCOLOR="'.$config['site']['lightborder'].'" ALIGN=left><b>'.htmlspecialchars($buy_offer['name']).'</b> added to player <b>'.htmlspecialchars($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 />Now you have <b>'.$user_premium_points.' premium points</b>.<br /><a href="?subtopic=shopsystem">GO TO MAIN SHOP SITE</a></TD></TR>
  292. </table>';
  293. }
  294. }
  295. else
  296. {
  297. $set_session = TRUE;
  298. $_SESSION['viewed_confirmation_page'] = 'yes';
  299. $main_content .= '<table border="0" cellpadding="4" cellspacing="1" width="100%">
  300. <tr bgcolor="'.$config['site']['vdarkborder'].'"><td colspan="3" class="white"><b>Confirm Transaction</b></td></tr>
  301. <tr bgcolor="'.$config['site']['lightborder'].'"><td width="100"><b>Name:</b></td><td width="550" colspan="2">'. htmlspecialchars($buy_offer['name']).'</td></tr>
  302. <tr bgcolor="'.$config['site']['darkborder'].'"><td width="100"><b>Description:</b></td><td width="550" colspan="2">'. htmlspecialchars($buy_offer['description']).'</td></tr>
  303. <tr bgcolor="'.$config['site']['lightborder'].'"><td width="100"><b>Cost:</b></td><td width="550" colspan="2"><b>'. htmlspecialchars($buy_offer['points']).' premium points</b> from your account</td></tr>
  304. <tr bgcolor="'.$config['site']['darkborder'].'"><td width="100"><b>For Player:</b></td><td width="550" colspan="2"><font color="red">'.htmlspecialchars($buy_player->getName()).'</font></td></tr>
  305. <tr bgcolor="'.$config['site']['lightborder'].'"><td width="100"><b>From:</b></td><td width="550" colspan="2"><font color="red">'.htmlspecialchars($buy_from).'</font></td></tr>
  306. <tr bgcolor="'.$config['site']['darkborder'].'"><td colspan="3"></td></tr>
  307. <tr bgcolor="'.$config['site']['darkborder'].'"><td width="100"><b>Transaction?</b></td><td width="275" align="left">
  308. <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="'.htmlspecialchars($buy_from).'"><input type="hidden" name="buy_name" value="'.htmlspecialchars($buy_name).'"><input type="submit" value="Accept"></form></td>
  309. <td align="right"><form action="?subtopic=shopsystem" method="POST"><input type="submit" value="Cancel"></form></td></tr>
  310. <tr bgcolor="'.$config['site']['darkborder'].'"><td colspan="3"></td></tr>
  311. </table>
  312. ';
  313. }
  314. }
  315. else
  316. {
  317. $errormessage .= 'Player with name <b>'.htmlspecialchars($buy_name).'</b> doesn\'t exist. Please <a href="?subtopic=shopsystem&action=select_player&buy_id='.$buy_id.'">select other name</a>.';
  318. }
  319. }
  320. else
  321. {
  322. $errormessage .= 'Invalid name format. Please <a href="?subtopic=shopsystem&action=select_player&buy_id='.$buy_id.'">select other name</a> or contact with administrator.';
  323. }
  324. }
  325. else
  326. {
  327. $errormessage .= '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.';
  328. }
  329. }
  330. else
  331. {
  332. $errormessage .= 'Offer with ID <b>'.$buy_id.'</b> doesn\'t exist. Please <a href="?subtopic=shopsystem">select item</a> again.';
  333. }
  334. }
  335. }
  336. }
  337. if(!empty($errormessage))
  338. {
  339. $main_content .= '<TABLE WIDTH=100% BORDER=0 CELLSPACING=1 CELLPADDING=4>
  340. <TR><TD BGCOLOR="'.$config['site']['vdarkborder'].'" ALIGN=left CLASS=white><B>Informations</B></TD></TR>
  341. <TR><TD BGCOLOR="'.$config['site']['lightborder'].'" ALIGN=left><b>'.$errormessage.'</b></TD></TR>
  342. </table>';
  343. }
  344. if(!$set_session)
  345. {
  346. unset($_SESSION['viewed_confirmation_page']);
  347. }
  348. }
  349. elseif($action == 'show_history')
  350. {
  351. if(!$logged)
  352. {
  353. $errormessage .= 'Please login first.';
  354. }
  355. else
  356. {
  357. $items_history_received = $SQL->query('SELECT * FROM '.$SQL->tableName('z_shop_history_item').' WHERE '.$SQL->fieldName('to_account').' = '.$SQL->quote($account_logged->getId()).' OR '.$SQL->fieldName('from_account').' = '.$SQL->quote($account_logged->getId()).';');
  358. if(is_object($items_history_received))
  359. {
  360. foreach($items_history_received as $item_received)
  361. {
  362. if($account_logged->getId() == $item_received['to_account'])
  363. $char_color = 'green';
  364. else
  365. $char_color = 'red';
  366. $items_received_text .= '<tr bgcolor="'.$config['site']['lightborder'].'"><td><font color="'.$char_color.'">'.htmlspecialchars($item_received['to_name']).'</font></td><td>';
  367. if($account_logged->getId() == $item_received['from_account'])
  368. $items_received_text .= '<i>Your account</i>';
  369. else
  370. $items_received_text .= htmlspecialchars($item_received['from_nick']);
  371. $items_received_text .= '</td><td>'.htmlspecialchars($item_received['offer_id']).'</td><td>'.date("j F Y, H:i:s", $item_received['trans_start']).'</td>';
  372. if($item_received['trans_real'] > 0)
  373. $items_received_text .= '<td>'.date("j F Y, H:i:s", $item_received['trans_real']).'</td>';
  374. else
  375. $items_received_text .= '<td><b><font color="red">Not realized yet.</font></b></td>';
  376. $items_received_text .= '</tr>';
  377. }
  378. }
  379. $main_content .= '<TABLE WIDTH=100% BORDER=0 CELLSPACING=1 CELLPADDING=4>
  380. <TR><TD BGCOLOR="'.$config['site']['vdarkborder'].'"></TD></TR>
  381. <TR><TD BGCOLOR="'.$config['site']['vdarkborder'].'" ALIGN=left CLASS=white><center><B>Transactions History</B></center></TD></TR>
  382. <TR><TD BGCOLOR="'.$config['site']['vdarkborder'].'"></TD></TR>
  383. </table><br>';
  384.  
  385. if(!empty($items_received_text))
  386. {
  387. $main_content .= '<TABLE WIDTH=100% BORDER=0 CELLSPACING=1 CELLPADDING=4>
  388. <TR><TD BGCOLOR="'.$config['site']['vdarkborder'].'" ALIGN=left CLASS=white colspan="5"><B>Item Transactions</B></TD></TR>
  389. <tr bgcolor="'.$config['site']['darkborder'].'"><td><b>To:</b></td><td><b>From:</b></td><td><b>Offer name</b></td><td><b>Bought on page</b></td><td><b>Received on OTS</b></td></tr>
  390. '.$items_received_text.'
  391. </table><br />';
  392. }
  393. if(empty($items_received_text))
  394. $errormessage .= 'You did not buy/receive any item.';
  395. }
  396. if(!empty($errormessage))
  397. {
  398. $main_content .= '<TABLE WIDTH=100% BORDER=0 CELLSPACING=1 CELLPADDING=4>
  399. <TR><TD BGCOLOR="'.$config['site']['vdarkborder'].'" ALIGN=left CLASS=white><B>Informations</B></TD></TR>
  400. <TR><TD BGCOLOR="'.$config['site']['lightborder'].'" ALIGN=left><b>'.$errormessage.'</b></TD></TR>
  401. </table>';
  402. }
  403. }
  404. $main_content .= '<br><TABLE WIDTH=100% BORDER=0 CELLSPACING=1 CELLPADDING=4>
  405. <TR><TD BGCOLOR="'.$config['site']['vdarkborder'].'" ALIGN=left CLASS=white><B>Premium Points</B></TD></TR>
  406. <TR><TD BGCOLOR="'.$config['site']['lightborder'].'" ALIGN=left><b><font color="green">You have premium points: </font></b>'.$user_premium_points.'</TD></TR>
  407. </table>';
  408. }
  409. else
  410. $main_content .= '<TABLE WIDTH=100% BORDER=0 CELLSPACING=1 CELLPADDING=4>
  411. <TR><TD BGCOLOR="'.$config['site']['vdarkborder'].'" ALIGN=center CLASS=white ><B>Shop Information</B></TD></TR>
  412. <TR><TD BGCOLOR="'.$config['site']['darkborder'].'"><center>Shop is currently closed. [to admin: edit it in \'config/config.php\']</TD></TR>
  413. </table>';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement