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