· 8 years ago · Dec 30, 2017, 04:56 AM
1<script type="text/javascript">
2 $(function() {
3 $("#accordion").accordion({
4 autoHeight: false,
5 navigation: true
6 });
7 });
8</script>
9<?PHP
10//Product Types
11//Categories :
12//
13//[ 1 - Account Modifications ]
14//1 - Premium
15//2 - Remove Skull (ANY)
16//3 - UnBan Account
17//4 - Change Name
18//
19//[ 2 - Items ]
20//5 - Items
21//
22//[ 3 - Container Fully of Items ]
23//6 - Bag of Items
24//7 - Backpack of Items
25//
26//[ 4 - Addons Items ]
27//8 - Addon Items
28//
29//HOWTO PUT IMAGES FOR TYPES 1-4 [ Account Modifications ]
30//Go to public/images/ folder and create a GIF image (Or put)
31//With the ID of the type [See at the top of the script]
32//Ex. Type (1) - Premium Account (public/images/1.gif)
33
34
35//Variables
36require("config.php");
37include("config/functions.php");
38require("config/config.php");
39$this->load->helper("url");
40$ots = POT::getInstance();
41$ots->connect(POT::DB_MYSQL, connection());
42$SQL = $ots->getDBHandle();
43$SHOP = new shop;
44$ide = new IDE;
45$action = $this->uri->segment(4);
46$categories = array(1 => 'Modificar Conta', 2 => 'Items', 3 => 'Bolsas', 4 => 'Roupas');
47if ($_SESSION['logged'] == 1) {
48 if ($SHOP->isInstalled()) {
49 if ($action == '') {
50 if($ide->isAdmin()) {
51 echo "<div class='toolbar' align='center'>";
52 echo "<a href='".WEBSITE."/index.php/p/v/shop/admin'>Shop Admin Panel</a>";
53 echo "</div>";
54 }
55
56alert("<b></center>DICA:</b><br><font color='green'>Para garantir seu recebimento do produto, certifique se que sua <b>POKEBAG</b> esteja vazia.</font>");
57 echo '<div id="accordion">';
58 $i = 0;
59 foreach($categories as $key=>$value) {
60 echo '<h3><a href="#">'.$categories[$key].'</a></h3>
61 <div>';
62 if($SQL->query('SELECT * FROM shop_offer WHERE category = '.$key.'')->fetch()) {
63 echo '<table border="0" cellspacing="1" cellpadding="4" width="100%">
64 <tr>
65 <td width="20%" class="white" style="text-align: center; font-weight: bold;">Imagem</td>
66 <td width="40%" class="white" style="text-align: center; font-weight: bold;">Nome do Produto</td>
67 <td width="20%" class="white" style="text-align: center; font-weight: bold;">Crystals</td>
68 <td width="20%" class="white" style="text-align: center; font-weight: bold;">Ativar</td>
69 </tr>';
70 foreach($SQL->query('SELECT * FROM shop_offer WHERE category = '.$key.'') as $item) {
71 if (is_int($i / 2))
72 $bgcolor = "#ececec";
73 else
74 $bgcolor = "#ffffff";
75 $i++;
76 echo '<tr class="highlight" bgcolor="'.$bgcolor.'" style="text-align: center;">
77 <td>';
78 if($item['category'] == '1')
79 $image = 'public/images/'.$item['type'].'.gif';
80 else
81 $image = 'public/images/items/'.$item['item'].'.gif';
82 if(!file_exists($image))
83 echo 'NO IMAGE';
84 else
85 echo '<img height="32px" width="32px" src="'.WEBSITE.'/'.$image.'"/>';
86 echo '</td>
87 <td><b>'.$item['name'].'</b><br>'.$item['description'].'</td>
88 <td>'.$item['points'].'</td>
89 <td><font color="#FF0000"><button type="submit" onClick="window.location.href=\''.WEBSITE.'/index.php/p/v/shop/buy/'.$item['id'].'\';" class="ide_button"><font color="#071918">Selecionar</button></td>
90 </tr>';
91 }
92 echo '</table></div>';
93 }
94 else {
95 alert("This category doesn't have products.");
96 echo '</div>';
97 }
98 }
99 echo '</div>';
100 echo '<br><center><font style="color:#87CEFA; font-weight: bold; font-size: 12px">Sua conta tem: <font color="#838B8B">'.$SHOP->points($_SESSION['name']).'</font> Crystals.</font></center>';
101 }
102 elseif ($action == 'buy') {
103 $product = $this->uri->segment(5);
104 $productact = $this->uri->segment(6);
105 if (!$product) {
106 alert("Você ainda não selecionou um Produto.");
107 echo '<div align="right"><a href="'.WEBSITE.'/index.php/p/v/shop">Voltar pro Shop</a></div>';
108 }
109 else {
110 if($SQL->query('SELECT * FROM shop_offer WHERE id = '.$product.'')->fetch()) {
111 $info = $SQL->query('SELECT * FROM shop_offer WHERE id = '.$product.'')->fetch();
112 if($productact == '' || !$productact) {
113 if ($SHOP->points($_SESSION['name']) < $info['points']) {
114 alert("Você não tem Crystals (<b>".$info['points']."</b>)");
115 echo '<div align="right"><a href="'.WEBSITE.'/index.php/p/v/shop">Voltar pro Shop</a></div>';
116 }
117 else {
118 echo '<div id="accordion">';
119 echo '<h3><a href="#">Produto Selecionado</a></h3>
120 <div>';
121 echo '<table border="0" cellspacing="1" cellpadding="4" width="100%">
122 <tr>
123 <td width="25%" class="white" style="text-align: center; font-weight: bold;">Imagem</td>
124 <td width="50%" class="white" style="text-align: center; font-weight: bold;">Produto</td>
125 <td width="25%" class="white" style="text-align: center; font-weight: bold;">Crystals-</td>
126 </tr>';
127 echo '<tr class="highlight" style="text-align: center">
128 <td>';
129 if($info['category'] == '1')
130 $image = 'public/images/'.$info['type'].'.gif';
131 else
132 $image = 'public/images/items/'.$info['item'].'.gif';
133 if(!file_exists($image))
134 echo 'NO IMAGE';
135 else
136 echo '<img height="32px" width="32px" src="'.WEBSITE.'/'.$image.'"/>';
137 echo '</td>
138 <td><b>'.$info['name'].'</b><br>'.$info['description'].'</td>
139 <td>'.$info['points'].'</td>
140 </tr>';
141 echo '</table></div>
142 <h3><a href="#">Enviar</a></h3>
143 <div>
144 <center><table border="0" cellspacing="7" cellpadding="4" width="50%">
145 <tr>
146 <td><form method="post" action="'.WEBSITE.'/index.php/p/v/shop/buy/'.$info['id'].'/send">';
147 if($info['type'] == '4')
148 echo 'Character to Change Name:';
149 else
150 echo 'De:';
151 echo '</td>
152 <td><select name="my_char">';
153 foreach($SHOP->CharacterList($_SESSION['name']) as $row)
154 echo '<option>'.$row['name'].'</option>';
155 echo '</select></td>
156 </tr>
157 <tr>
158 <td>';
159 if($info['type'] == '4')
160 echo 'New Name:';
161 else
162 echo 'Para:<br>';
163
164 echo '</td>
165 <td><input type="text" name="other_char" size="10"/></td>
166 </tr>
167 <tr>
168 <td></td>
169 <td><button type="submit" name="submit" value="true" class="ide_button">Enviar</td>
170 </tr></table></center></div></div>';
171 echo '<div align="right"><a href="'.WEBSITE.'/index.php/p/v/shop/">Voltar pro Shop</a></div>';
172 }
173 }
174 elseif ($productact == 'send') {
175 if(!$_POST['submit'])
176 header("Location: ".WEBSITE."/index.php/p/v/shop");
177 else {
178 $info = $SQL->query('SELECT * FROM shop_offer WHERE id = '.$product.'')->fetch();
179 if ($SHOP->points($_SESSION['name']) < $info['points']) {
180 alert("Você não tem Crystals (<b>".$info['points']."</b>)");
181 echo '<div align="right"><a href="'.WEBSITE.'/index.php/p/v/shop">Voltar pro Shop</a></div>';
182 } else {
183 if($info['type'] != '4') {
184 if($_POST['other_char']) {
185 if($SQL->query('SELECT * FROM players WHERE name = "'.$_POST['other_char'].'"')->fetch()) {
186 $destination = $_POST['other_char'];
187 $send = true;
188 } else {
189 alert('<b>'.$_POST['other_char'].'</b> doesn\'t exists.');
190 echo '<div align="right"><a href="'.WEBSITE.'/index.php/p/v/shop/buy/'.$info['id'].'">Voltar pro Shop</a></div>';
191 $send = false;
192 }
193 }
194 else {
195 $destination = $_POST['my_char'];
196 $send = true;
197 }
198 }
199 else {
200 $destination = $_POST['my_char'];
201 $send = true;
202 }
203
204 if($send == true) {
205 $errors = '';
206 $processed = 0;
207 if ($info['type'] == '1') {
208 $processed = 1;
209 $finish = true;
210 $SHOP->AddPremium($destination,$info['count']);
211 }
212 elseif ($info['type'] == '2') {
213 $skulltime = $SQL->query('SELECT skull,skulltime FROM players WHERE name = "'.$destination.'"')->fetch();
214 if ($SHOP->isOnline($destination) == 1) {
215 $errors .= 'Sorry, but <b>'.$destination.'</b> is On-Line right now.<br>';
216 $finish = false;
217 }
218 elseif ($skulltime['skull'] == '0' && $skulltime['skulltime'] == '0') {
219 $errors .= 'Sorry, but <b>'.$destination.'</b> doesn\'t have any skull.<br>';
220 $finish = false;
221 }
222 else {
223 $processed = 1;
224 $finish = true;
225 $SQL->query('UPDATE players SET skull = 0, skulltime = 0 WHERE name = "'.$destination.'"');
226 }
227 }
228 elseif ($info['type'] == '3') {
229 if ($SHOP->isOnline($destination) == 1) {
230 $errors .= 'Sorry, but <b>'.$destination.'</b> is On-Line right now.<br>';
231 $finish = false;
232 }
233 else {
234 if ($SHOP->isBanned($destination)->fetch()) {
235 $processed = 1;
236 $finish = true;
237 $SHOP->UnBan($destination);
238 }
239 else {
240 $errors .= 'Sorry, but <b>'.$destination.'</b>\'s Account isn\'t banned at the moment.<br>';
241 $finish = false;
242 }
243 }
244 }
245 elseif ($info['type'] == '4') {
246 if ($SHOP->isOnline($destination) == 1) {
247 $errors .= 'Sorry, but <b>'.$destination.'</b> is On-Line right now.<br>';
248 $finish = false;
249 }
250 else {
251 if ($SQL->query('SELECT * FROM players WHERE name = "'.$_POST['other_char'].'"')->fetch()) {
252 $finish = false;
253 $errors .= 'Sorry, but <b>'.$_POST['other_char'].'</b> already exists.<br>';
254 }
255 else {
256 if(!$_POST['other_char']) {
257 $finish = false;
258 $errors .= 'Sorry, but you didn\'t put a new name for your character.<br>';
259 }
260 else {
261 if (!preg_match('/[^A-Z a-z_-]/', $_POST['other_char'])) {
262 $processed = 1;
263 $finish = true;
264 $SQL->query('UPDATE players SET name = "'.$_POST['other_char'].'" WHERE name = "'.$destination.'"');
265 }
266 else {
267 $finish = false;
268 $errors .= 'Sorry, but <b>'.$_POST['other_char'].'</b> contains invalid characters (Use only: A-Z, a-z).<br>';
269 }
270 }
271 }
272 }
273 }
274 else {
275 $finish = true;
276 }
277 if ($finish == true) {
278 echo '<div style="text-align: center; font-size: 15px; color: #4EBF37; font-weight: bold;">Pedido efetuada com Sucesso!</div><br>';
279 if($info['type'] == '4')
280 echo '<center>You have changed the name of <b>'.$destination.'</b> to <b>'.$_POST['other_char'].'</b>.</center>';
281 elseif($info['type'] == '3')
282 echo '<center>You have UnBanned <b>'.$destination.'</b>\'s Account.</center>';
283 else
284 echo '<center>Você comprou <b>'.$info['name'].'</b> e foi enviado para <b>'.$destination.'</b>.</center>';
285 echo '<div align="right"><a href="'.WEBSITE.'/index.php/p/v/shop">Continuar Comprando</a></div>';
286 $SQL->query('UPDATE accounts SET premium_points = '.($SHOP->points($_SESSION['name']) - $info['points']).' WHERE name = "'.$_SESSION['name'].'"');
287 $SQL->query('INSERT INTO shop_history (`id`, `product`, `session`, `player`, `date`, `processed`) VALUES (NULL, \''.$info['id'].'\',\''.$_SESSION['name'].'\', \''.$destination.'\', \''.time().'\',\''.$processed.'\')');;
288 }
289 else {
290 alert($errors);
291 echo '<div align="right"><a href="'.WEBSITE.'/index.php/p/v/shop/buy/'.$info['id'].'">Continuar Comprando</a></div>';
292 }
293 }
294 }
295 }
296 }
297 }
298 else {
299 header("Location: ".WEBSITE."/index.php/p/v/shop");
300 }
301 echo '<br><center><font style="color: #4F82CB; font-weight: bold; font-size: 12px">Sua conta tem: <font color="#58FAF4">'.$SHOP->points($_SESSION['name']).'</font> Crystals.</font></center>';
302 }
303 }
304 elseif ($action == 'history') {
305 if ($SQL->query('SELECT * FROM shop_history WHERE session = "'.$_SESSION['name'].'" ORDER BY date DESC LIMIT 30')->fetch()) {
306echo '<div style="text-align: center; font-weight: bold;"><h1>Histórico</div>
307 <table border="0" cellspacing="1" cellpadding="4" width="100%">
308 <tr>
309 <td class="white" style="text-align: center; font-weight: bold;">Imagem</td>
310 <td class="white" style="text-align: center; font-weight: bold;">Produto</td>
311 <td class="white" style="text-align: center; font-weight: bold;">Para</td>
312 <td class="white" style="text-align: center; font-weight: bold;">Data</td>
313 <td class="white" style="text-align: center; font-weight: bold;">Processado</td>
314 </tr>';
315 foreach($SQL->query('SELECT `z`.`player` AS `destination`, `z`.`date` AS `date`, `z`.`processed` AS `processed`, `o`.`category` AS `category`,`o`.`type` AS `type`,`o`.`item` AS `item`,`o`.`name` AS `name` FROM `shop_history` z LEFT JOIN `shop_offer` o ON `z`.`product` = `o`.`id` WHERE `z`.`session` = \''.$_SESSION['name'].'\' ORDER BY `z`.`date` DESC LIMIT 30') as $hist) {
316 echo '<tr class="highlight" style="text-align: center"><td>';
317 if($hist['category'] == '1')
318 $image = 'public/images/'.$hist['type'].'.gif';
319 else
320 $image = 'public/images/items/'.$hist['item'].'.gif';
321 if(!file_exists($image))
322 echo 'NO IMAGE';
323 else
324 echo '<img height="32px" width="32px" src="'.WEBSITE.'/'.$image.'"/>';
325 echo '</td>
326 <td>'.$hist['name'].'</td>
327 <td>'.$hist['destination'].'</td>
328 <td>'.date("d-m-Y - H:i a", $hist["date"]).'</td>';
329 if ($hist['processed'] == '1')
330 echo '<td><img src="'.WEBSITE.'/public/images/true.gif"/></td>';
331 else
332 echo '<td><img src="'.WEBSITE.'/public/images/false.gif"/></td>';
333 echo '</tr>';
334 }
335 echo '</table>';
336 }
337 else {
338 alert('You didn\'t made any transactions');
339 }
340 }
341 elseif ($action == 'donate') {
342 $show = $this->uri->segment(5);
343 if ($show == 'history') {
344 if ($SQL->query('SELECT * FROM shop_donation_history WHERE buyer = "'.$_SESSION['name'].'" ORDER BY date DESC LIMIT 30')->fetch()) {
345 echo '<div style="text-align: center; font-weight: bold;">Latest 30 Donations</div>
346 <table border="0" cellspacing="1" cellpadding="4" width="100%">
347 <tr>
348 <td class="white" style="text-align: center; font-weight: bold;">Method</td>
349 <td class="white" style="text-align: center; font-weight: bold;">ID/Mail</td>
350 <td class="white" style="text-align: center; font-weight: bold;">To Account</td>
351 <td class="white" style="text-align: center; font-weight: bold;">Points Added</td>
352 <td class="white" style="text-align: center; font-weight: bold;">Date</td>
353 </tr>';
354 foreach($SQL->query('SELECT * FROM shop_donation_history WHERE buyer = "'.$_SESSION['name'].'" ORDER BY date DESC LIMIT 30') as $hist) {
355 echo '<tr class="highlight" style="text-align: center">
356 <td>'; echo ($hist['method'] == 'PayPal')?'<img src="https://www.paypal.com/en_US/i/logo/paypal_logo.gif" height="50px" width="100px">':($hist['method'] == 'ContenidoPago')?'<img src="http://www.contenidopago.com/img/logo_ft.jpg" height="50px" width="100px">':''; echo '</td>
357 <td>'.$hist['receiver'].'</td>
358 <td>'.$hist['account'].'</td>
359 <td>'.$hist['points'].'</td>
360 <td>'.date("d-m-Y - H:i a", $hist["date"]).'</td>
361 </tr>';
362 }
363 echo '</table>';
364 }
365 else {
366 alert('You didn\'t donated');
367 }
368 }
369 elseif (!$show || $show == '') {
370 alert("".$config['server_name']."'s Administration <b>is not responsible</b> for <b>cases of loss of products</b>.<br><br> ".$config['server_name']."'s Administration <b>is responsible</b> for <b>cases of loss of points which have been sent to users</b>.");
371 echo '<div id="accordion">';
372 foreach ($config['donations']['methods'] as $method => $active) {
373 if ($active == true) {
374 echo '<h3><a href="#">'.$method.'</a></h3>
375 <div>';
376
377
378if ($method == 'ContenidoPago') {
379
380
381
382if(!isset($_POST['mysubmit'])) {
383 echo '<form method="post" action="" >
384 <fieldset style="border:1px solid #990000; width:450px; margin:auto;">
385 <legend style="font-weight:bold;font-size:12px;">Automatic SMS Donation</legend>
386 <ol style="list-style:none;">
387 <li style="padding-bottom:5px;"><label style="width:100px;float:left;text-align:left;">Account Name:</label><input type="text" style="border:1px solid #CCCCCC;" size="30" name="name" /></li>
388 <li style="padding-bottom:5px;"><label style="width:100px;float:left;text-align:left;">Code received:</label><input type="text" style="border:1px solid #CCCCCC;" size="30" name="codigo" /></li>
389
390 </ol>
391 <center><input type="submit" name="mysubmit" style="padding:3px;margin-bottom:10px;color:#FFFFFF;background-color:#990000;border:1px solid #000000;" value="Enviar" /></center>
392 </fieldset>
393 </form>';
394 }
395 else {
396 $codigo=$_POST['codigo'];
397 $name=$_POST['name'];
398 $QueryString = "LinkUrl=http://".urlencode($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
399 $QueryString .= "&codigo=" .urlencode($codigo);
400 $QueryString .= "&idservicio=" .$config['donations']['contenidopago']['Product'];
401
402
403 if(intval(get_cfg_var('allow_url_fopen')) && function_exists('file_get_contents')) {
404 $result=@file_get_contents("http://contenidopago.com/codigoval.php?".$QueryString);
405 }
406 elseif(intval(get_cfg_var('allow_url_fopen')) && function_exists('file')) {
407 if($content = @file("http://contenidopago.com/codigoval.php?".$QueryString))
408 $result=@join('', $content);
409 }
410 elseif(function_exists('curl_init')) {
411 $ch = curl_init ("http://contenidopago.com/codigoval.php?".$QueryString);
412 curl_setopt ($ch, CURLOPT_HEADER, 0);
413 curl_exec ($ch);
414
415 if(curl_error($ch))
416 alert("Error processing request");
417
418 curl_close ($ch);
419 }
420 else {
421 alert("It appears that your web host has disabled all functions for handling remote pages and as a result the BackLinks software will not function on your web page. Please contact your web host for more information.");
422 }
423
424 if ($result =='ok')
425 {
426
427 if(!(empty($name)))
428 {
429 if(!$SQL->query("SELECT * FROM accounts WHERE name = '".$name."'")->fetch())
430 {
431 alert('This username does not exist: <font color="blue">'.$name.'</font>');
432 }
433 else {
434 $SQL->query("UPDATE accounts SET premium_points = premium_points + ".$config['donations']['contenidopago']['Points']." WHERE name = '".$name."'");
435 alert("Codigo : $codigo validado, puntos sumados correctamente");
436 $SQL->query("INSERT INTO shop_donation_history (`id`, `method`, `receiver`, `buyer`, `account`, `points`, `date`) VALUES (NULL, 'ContenidoPago', '".$config['donations']['contenidopago']['Product']."', '".$_SESSION['name']."', '".$name."', '".$config['donations']['contenidopago']['Points']."', '".time()."');");
437 }
438 }
439 else {
440
441 alert('You did not set the user!');
442 }
443
444 }
445
446 if ($result =='no')
447 {
448 alert('El codigo no es valido o ya esta usado');
449 }
450 }
451 echo '<center><iframe src ="http://www.contenidopago.com/prom/microcodigo.php" width="270px" height="340px" frameborder="0">
452 <p>Your browser does not support iframes.</p>
453 </iframe></center>';
454 }
455 elseif ($method == 'PayPal') {
456 alert("The donation costs <b>".$config['donations']['paypal']['Amount']." ".$config['donations']['paypal']['Money']." (incl. VAT)</b>.<br>
457 After the donation you will receive a total of <b>".$config['donations']['paypal']['Points']." points</b> automatically.<br><br>
458 <b>REMEMBER:</b><br>
459 You need a <u>creditcard</u> <b>or</b> a <u>PayPal account</u> with a minimun of <b>".$config['donations']['paypal']['Amount']." ".$config['donations']['paypal']['Money']."</b>.<br><br>
460 You <b>MUST</b> fill the <b>Account Name</b> with a <u>valid one</u>.");
461 echo '<center><form action="https://www.paypal.com/cgi-bin/webscr" method="post">
462 <input type="hidden" name="cmd" value="_donations">
463 <input type="hidden" name="business" value="'.$config['donations']['paypal']['Mail'].'">
464 <input type="hidden" name="lc" value="GB">
465
466 <input type="hidden" name="item_name" value="'.$config['donations']['paypal']['Product'].'">
467 <b>Account Name:</b> <input type="text" name="custom" value="">
468 <input type="hidden" name="item_number" value="1">
469 <input type="hidden" name="amount" value="'.$config['donations']['paypal']['Amount'].'">
470 <input type="hidden" name="currency_code" value="'.$config['donations']['paypal']['Money'].'">
471 <input type="hidden" name="no_note" value="0">
472 <input type="hidden" name="no_shipping" value="0">
473 <input type="hidden" name="notify_url" value="'.WEBSITE.'index.php/p/v/paypal">
474 <input type="hidden" name="return" value="'.WEBSITE.'">
475 <input type="hidden" name="session" value="'.$_SESSION['name'].'">
476 <input type="hidden" name="rm" value="0">
477 <input type="hidden" name="bn" value="PP-DonationsBF:btn_donateCC_LG_global.gif:NonHosted"><br>
478 <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online.">
479 <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
480 </form></center>';
481 }
482
483
484
485 echo '</div>';
486 }
487 }
488 echo '</div>';
489 }
490 else {
491 header("Location: ".WEBSITE."");
492 }
493
494
495
496
497 }
498 elseif ($action == 'admin') {
499 if($ide->isAdmin()) {
500 $manage = $this->uri->segment(5);
501 echo "<div class='toolbar' align='center'>";
502 echo "<a href='".WEBSITE."/index.php/p/v/shop/admin/add/1'>Add new Product</a> | ";
503 echo "<a href='".WEBSITE."/index.php/p/v/shop/admin/delete'>Delete Existing Product</a> | ";
504 echo "<a href='".WEBSITE."/index.php/p/v/shop/admin/points'>Add/Remove Points to Player</a>";
505 echo "</div>";
506
507 if ($manage == '' || !$manage) {
508 echo '<center>Welcome to Shop Admin Panel</center>';
509 }
510 elseif ($manage == 'add') {
511 $types[1] = array(1 => 'Premium Account', 2 => 'Remove Skull', 3 => 'UnBan Account', 4 => 'Change Name');
512 $types[2] = array(5 => 'Item');
513 $types[3] = array(6 => 'Bag with Items', 7 => 'Backpack with Items');
514 $types[4] = array(8 => 'Addon Items');
515 $step = $this->uri->segment(6);
516 if ($step == '1') {
517 echo '<form method="post" action="'.WEBSITE.'/index.php/p/v/shop/admin/add/2">Select Category: <select name="category">';
518 foreach($categories as $key=>$value) {
519 echo '<option value="'.$key.'">'.$categories[$key].'</option>';
520 }
521 echo '</select> <button type="submit" class="ide_button">Select Category</form>';
522 }
523 elseif ($step == '2' && $_POST['category']) {
524 echo '<form method="post" action="'.WEBSITE.'/index.php/p/v/shop/admin/add/3">
525 <input type="hidden" name="category" value="'.$_POST['category'].'"/>
526 Select Type: <select name="type">';
527 foreach($types[$_POST['category']] as $key=>$value) {
528 echo '<option value="'.$key.'">'.$types[$_POST['category']][$key].'</option>';
529 }
530 echo '</select> <button type="submit" class="ide_button">Select Type</form>';
531 }
532 elseif ($step == '3' && $_POST['category'] && $_POST['type']) {
533 echo '<form method="post" action="'.WEBSITE.'/index.php/p/v/shop/admin/add/4">
534 <input type="hidden" name="category" value="'.$_POST['category'].'"/>
535 <input type="hidden" name="type" value="'.$_POST['type'].'"/>
536 <table border="0" cellspacing="1" cellpadding="4" width="100%">
537 <tr>
538 <td width="25%">Product Name:</td>
539 <td width="25%"><input name="name" type="text" size="18" maxlength="256" /></td>
540 <td width="50%" style="font-size: 9px; color: red; font-weight: bold;">The name of the product</td>
541 </tr>
542 <tr>
543 <td width="25%">Point Cost:</td>
544 <td width="25%"><input name="points" type="text" value="0" size="10" maxlength="11" /></td>
545 <td width="50%" style="font-size: 9px; color: red; font-weight: bold;">Cost of the Product (Points)</td>
546 </tr>';
547 if ($_POST['type'] == '1') {
548 echo '<tr>
549 <td width="25%">Premium Days:</td>
550 <td width="25%"><input name="count" type="text" value="0" size="1" maxlength="3" /></td>
551 <td width="50%" style="font-size: 9px; color: red; font-weight: bold;">Days of Premium Account</td>
552 </tr>';
553 }
554 elseif ($_POST['type'] == '5' || $_POST['type'] == '6' || $_POST['type'] == '7' || $_POST['type'] == '8') {
555 echo '<tr>
556 <td width="25%">Item ID:</td>
557 <td width="25%"><input name="item" type="text" value="0" size="3" maxlength="5" /></td>
558 <td width="50%" style="font-size: 9px; color: red; font-weight: bold;">ID of item to give</td>
559 </tr>
560 <tr>
561 <td width="25%">Count:</td>
562 <td width="25%"><input name="count" type="text" value="0" size="1" maxlength="3" /></td>
563 <td width="50%" style="font-size: 9px; color: red; font-weight: bold;">Count of item (max. 100) (When selecting \'Backpack of Items\' or \'Bag of Items\' type, the ITEM with that count will fill the container!)</td>
564 </tr>';
565 }
566 echo '<tr>
567 <td width="25%">Product Description:</td>
568 <td width="25%"><textarea style="width: 120px; height: 80px;" name="description"></textarea></td>
569 <td width="50%" style="font-size: 9px; color: red; font-weight: bold;">Description (Shown of \'SHOP\' Page)</td>
570 </tr>
571 </table>
572 <br><center><button type="submit" name="done" value="true" class="ide_button">Add Product</form></center>';
573 }
574 elseif ($step == '4' && $_POST['done'] == 'true') {
575 $errors = '';
576 if ($_POST['points'] || $_POST['item'] || $_POST['count']) {
577 if($_POST['points']) {
578 if (!(!preg_match('/[^0-9]/', $_POST['points'])))
579 $errors .= '1';
580 }
581 elseif($_POST['item']) {
582 if (!(!preg_match('/[^0-9]/', $_POST['item'])))
583 $errors .= '2';
584 }
585 elseif($_POST['count']) {
586 if (!(!preg_match('/[^0-9]/', $_POST['count'])))
587 $errors .= '3';
588 }
589 }
590 if ($errors == '') {
591 echo '<div style="text-align: center; font-size: 15px; color: #4EBF37; font-weight: bold;">Product Added!</div><br>
592 <table border="0" cellspacing="1" cellpadding="4" width="100%">
593 <tr class="highlight">
594 <td style="font-weight: bold;" width="50%">Product Name:</td>
595 <td width="50%">'.$_POST['name'].'</td>
596 </tr>
597 <tr class="highlight">
598 <td style="font-weight: bold;" width="50%">Category:</td>
599 <td width="50%">'.$categories[$_POST['category']].'</td>
600 </tr>
601 <tr class="highlight">
602 <td style="font-weight: bold;" width="50%">Type:</td>
603 <td width="50%">'.$types[$_POST['category']][$_POST['type']].'</td>
604 </tr>
605 <tr class="highlight">
606 <td style="font-weight: bold;" width="50%">Point Cost:</td>
607 <td width="50%">'.$_POST['points'].'</td>
608 </tr>';
609 if($_POST['type'] == '1') {
610 echo '<tr class="highlight"><td style="font-weight: bold;" width="50%">Premium Days:</td>
611 <td width="50%">'.$_POST['count'].'</td>
612 </tr>';
613 }
614 elseif ($_POST['type'] == '5' || $_POST['type'] == '6' || $_POST['type'] == '7' || $_POST['type'] == '8') {
615 echo '<tr class="highlight"><td style="font-weight: bold;" width="50%">Item ID:</td>
616 <td width="50%">'.$_POST['item'].'</td>
617 </tr>
618 <tr class="highlight"><td style="font-weight: bold;" width="50%">Count:</td>
619 <td width="50%">'.$_POST['count'].'</td>
620 </tr>';
621 }
622 echo '<tr class="highlight"><td style="font-weight: bold;" width="50%">Description:</td>
623 <td width="50%">'.$_POST['description'].'</td>
624 </tr></table>';
625 $PostItem = (!isset($_POST['item']))?'0':$_POST['item'];
626 $PostCount = (!isset($_POST['count']))?'0':$_POST['count'];
627 $SQL->query("INSERT INTO shop_offer (`id`, `points`, `category`, `type`, `item`, `count`, `description`, `name`) VALUES (NULL, '".$_POST['points']."', '".$_POST['category']."', '".$_POST['type']."', '".$PostItem."', '".$PostCount."', '".$_POST['description']."', '".$_POST['name']."')");
628 echo '<div align="right"><a href="'.WEBSITE.'/index.php/p/v/shop/admin">Go Back to Shop Admin</a></div>';
629 }
630 else {
631 alert('Sorry but 1 or more spaces contains invalid characters.');
632 echo '<div align="right"><a href="'.WEBSITE.'/index.php/p/v/shop/admin">Go Back to Shop Admin</a></div>';
633 }
634 }
635 else {
636 header("Location: ".WEBSITE."/index.php/p/v/shop/admin/add/1");
637 }
638 }
639 elseif ($manage == 'delete') {
640 $product = $this->uri->segment(6);
641 if (!$product) {
642 echo '<div id="accordion">';
643 $i = 0;
644 foreach($categories as $key=>$value) {
645 echo '<h3><a href="#">'.$categories[$key].'</a></h3>
646 <div>';
647 if($SQL->query('SELECT * FROM shop_offer WHERE category = '.$key.'')->fetch()) {
648 echo '<table border="0" cellspacing="1" cellpadding="4" width="100%">
649 <tr>
650 <td width="20%" class="white" style="text-align: center; font-weight: bold;">Imagem</td>
651 <td width="40%" class="white" style="text-align: center; font-weight: bold;">Product</td>
652 <td width="20%" class="white" style="text-align: center; font-weight: bold;">Points</td>
653 <td width="20%" class="white" style="text-align: center; font-weight: bold;">Action</td>
654 </tr>';
655 foreach($SQL->query('SELECT * FROM shop_offer WHERE category = '.$key.'') as $item) {
656 if (is_int($i / 2))
657 $bgcolor = "#ececec";
658 else
659 $bgcolor = "#ffffff";
660 $i++;
661 echo '<tr class="highlight" bgcolor="'.$bgcolor.'" style="text-align: center;">
662 <td>';
663 if($item['category'] == '1')
664 $image = 'public/images/'.$item['type'].'.gif';
665 else
666 $image = 'public/images/items/'.$item['item'].'.gif';
667 if(!file_exists($image))
668 echo 'NO IMAGE';
669 else
670 echo '<img height="32px" width="32px" src="'.WEBSITE.'/'.$image.'"/>';
671 echo '</td>
672 <td><b>'.$item['name'].'</b><br>'.$item['description'].'</td>
673 <td>'.$item['points'].'</td>
674 <td><button type="submit" onClick="window.location.href=\''.WEBSITE.'/index.php/p/v/shop/admin/delete/'.$item['id'].'\';" class="ide_button">Delete Offer</button></td>
675 </tr>';
676 }
677 echo '</table></div>';
678 }
679 else {
680 alert("This category doesn't have products.");
681 echo '</div>';
682 }
683 }
684 echo '</div>';
685 }
686 else {
687 if($SQL->query('SELECT * FROM shop_offer WHERE id = '.$product.'')->fetch()) {
688 $SQL->query('DELETE FROM shop_offer WHERE id = '.$product.'');
689 $SQL->query('DELETE FROM shop_history WHERE product = '.$product.'');
690 echo '<div style="text-align: center; font-size: 15px; color: #4EBF37; font-weight: bold;">Product Deleted!</div><br>
691 <center>The product ID <b>'.$product.'</b> has been deleted from DataBase.</center>';
692 echo '<div align="right"><a href="'.WEBSITE.'/index.php/p/v/shop/admin">Go Back to Shop Admin</a></div>';
693 }
694 else {
695 header("Location: ".WEBSITE."/index.php/p/v/shop/admin/delete");
696 }
697 }
698 }
699 elseif ($manage == 'points') {
700 if (!isset($_POST['submit'])) {
701 echo '<div id="accordion">
702 <h3><a href="#">Add Points</a></h3>
703 <div>
704 <table border="0" cellspacing="1" cellpadding="4" width="100%">
705 <tr>
706 <form method="post" action="'.$_SERVER['PHP_SELF'].'">
707 <td>Select Player:</td>
708 <td><select name="player">';
709 foreach($SQL->query('SELECT * FROM players ORDER BY name DESC') as $player) {
710 echo '<option value="'.$player['id'].'">'.$player['name'].'</option>';
711 }
712 echo '</select></td>
713 </tr><tr>
714 <td>Or Type a Name:</td>
715 <td><input type="text" name="other_char" size="10"/></td>
716 </tr><tr>
717 <td>Points to Add:</td>
718 <td><input type="text" name="points" size="10"/></td>
719 </tr><tr>
720 <td></td>
721 <td><button type="submit" name="submit" value="add" class="ide_button"><button class="ide_button">Add Points</button></td>
722 </tr>
723 </table></form>
724 </div>
725 <h3><a href="#">Remove Points</a></h3>
726 <div>
727 <table border="0" cellspacing="1" cellpadding="4" width="100%">
728 <tr>
729 <form method="post" action="'.$_SERVER['PHP_SELF'].'">
730 <td>Select Player:</td>
731 <td><select name="player">';
732 foreach($SQL->query('SELECT * FROM players ORDER BY name DESC') as $player) {
733 echo '<option value="'.$player['id'].'">'.$player['name'].'</option>';
734 }
735 echo '</select></td>
736 </tr><tr>
737 <td>Or Type a Name:</td>
738 <td><input type="text" name="other_char" size="10"/></td>
739 </tr><tr>
740 <td>Points to Remove:</td>
741 <td><input type="text" name="points" size="10"/></td>
742 </tr><tr>
743 <td></td>
744 <td><button type="submit" name="submit" value="remove" class="ide_button"><button class="ide_button">Remove Points</button></td>
745 </tr>
746 </table></form>
747 </div>
748 </div>';
749 }
750 else {
751 $errors = "";
752 if(!isset($_POST['other_char']) || $_POST['other_char'] == '') {
753 $destination = $_POST['player'];
754 }
755 else {
756 $ID = $SQL->query('SELECT id FROM players WHERE name = "'.$_POST['other_char'].'"')->fetch();
757 if($ID)
758 $destination = $ID['id'];
759 else
760 $errors .= "Player <b>".$_POST['other_char']."</b> doesn't exists.<br>";
761 }
762 if($_POST['points'] == '0' || $_POST['points'] < '0')
763 $errors .= "Points quantity must be higher than 0!<br>";
764 elseif (!(!preg_match('/[^0-9]/', $_POST['points'])))
765 $errors .= "Point quantity must be a <b>numeric value</b>!";
766
767 if(isset($destination)) {
768 $player = $SQL->query('SELECT name FROM players WHERE id = "'.$destination.'"')->fetch();
769 $account = $SHOP->getPlayerAccount($player['name'])->fetch();
770 if ($_POST['submit'] == 'remove') {
771 if ($SHOP->points($account['name']) == '0' || $SHOP->points($account['name']) < '0')
772 $errors .= "Player <b>".$player['name']."</b> doesn't have any points.<br>";
773 }
774 }
775
776 if ($errors == '') {
777 $player = $SQL->query('SELECT name FROM players WHERE id = "'.$destination.'"')->fetch();
778 $account = $SHOP->getPlayerAccount($player['name'])->fetch();
779 echo '<div style="text-align: center; font-size: 15px; color: #4EBF37; font-weight: bold;">Points '; echo ($_POST['submit'] == 'add')?'added':'removed'; echo '!</div><br>
780 <center>You have '; echo ($_POST['submit'] == 'add')?'added':'removed'; echo ' <b>'.$_POST['points'].'</b> points to <b>'.$player['name'].'</b>\'s Account.</center>';
781 echo '<div align="right"><a href="'.WEBSITE.'/index.php/p/v/shop/admin/points">Go Back to Points Manage</a></div>';
782 if($_POST['submit'] == 'add')
783 $SQL->query('UPDATE accounts SET premium_points = '.($SHOP->points($account['name']) + $_POST['points']).' WHERE name = "'.$account['name'].'"');
784 elseif($_POST['submit'] == 'remove')
785 $SQL->query('UPDATE accounts SET premium_points = '.($SHOP->points($account['name']) - $_POST['points']).' WHERE name = "'.$account['name'].'"');
786 }
787 else {
788 alert($errors);
789 echo '<div align="right"><a href="'.WEBSITE.'/index.php/p/v/shop/admin/points">Go Back to Points Manage</a></div>';
790 }
791 }
792 }
793 else {
794 header("Location: ".WEBSITE."/index.php/p/v/shop/admin");
795 }
796 }
797 else {
798 header("Location: ".WEBSITE."/index.php");
799 }
800 }
801 else {
802 header("Location: ".WEBSITE."/index.php/p/v/shop");
803 }
804 }
805 elseif(!$SHOP->isInstalled()) {
806 if($ide->isAdmin()) {
807 $SHOP->install();
808 echo '<div style="text-align: center; font-size: 15px; color: #4EBF37; font-weight: bold;">Shop System Succesfully Installed!</div><br>
809 <center>Your shop system has been installed succesfully!! click <a href="'.WEBSITE.'/index.php/p/v/shop">HERE</a> to see your shop</center>';
810 }
811 else {
812 header("Location: ".WEBSITE."/index.php");
813 }
814
815 }
816}
817else {
818 header("Location: ".WEBSITE."/index.php");
819}
820?>