Advertisement
Guest User

Untitled

a guest
Jan 12th, 2021
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.41 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. *
  5. * @package uam.skeleton
  6. * @subpackage controllers
  7. * @author Codenome Developpers - Main Developer: Ricardo <http://codenome.com>
  8. * @copyright Copyright (c) 2018, Codenome. (http://myara.net/)
  9. * @license GPL v3
  10. * @link http://uam.codenome.com
  11. * @since Version 0.0.1
  12. * @filesource
  13. */
  14.  
  15. /**
  16. * @param $status
  17. * @param $msg
  18. * @return array
  19. */
  20. function getStatus($status, $msg)
  21. {
  22. $data = [];
  23. $data['error'] = $status;
  24. $data['msg'] = $msg;
  25. return $data;
  26. }
  27.  
  28. /**
  29. * @param $rk
  30. * @return bool
  31. */
  32. $verifica_rk = function ($rk) use ($SQL, $account_logged) {
  33. $acc_rk = $account_logged->getKey();
  34. if ($acc_rk == strtoupper($rk)) {
  35. return TRUE;
  36. } else {
  37. return false;
  38. }
  39. };
  40.  
  41. /**
  42. * @param $player_id int
  43. * @param $price_type int
  44. * @param $price int
  45. * @param $rk String
  46. * @return string
  47. */
  48. $add_sell_character = function ($player_id, $price_type, $price, $rk) use ($verifica_rk, $account_logged, $config, $SQL) {
  49. $reqs = valida_multiplas_reqs();
  50. $vrk = $verifica_rk($rk);
  51. if ($vrk) {
  52. if ($reqs) {
  53. $va = $SQL->query("SELECT player_sell_bank FROM accounts WHERE id = {$account_logged->getID()}")->fetchAll();
  54. $va = $va[0]['player_sell_bank'];
  55. if ($va != NULL && $va != '' && $va != '0' && $va != 0 || !Website::getWebsiteConfig()->getValue('sell_by_gold')) {
  56. if ($va != $player_id || !Website::getWebsiteConfig()->getValue('sell_by_gold')) {
  57. $player_id = (int) $player_id;
  58. $price_type = (int) $price_type;
  59. $price = (int) $price;
  60. $player = new Player();
  61. $player->loadById($player_id);
  62. $account = new Account();
  63. $account->loadById($player->getAccountID());
  64. $date = new DateTime();
  65. $now = $date->format('Y-m-d H:i:s');
  66. $valid = date_add($date, date_interval_create_from_date_string('5 days'))->format('Y-m-d H:i:s');
  67. $price_coin = 0;
  68. $price_gold = 0;
  69. if (Website::getWebsiteConfig()->getValue('sell_by_gold')) {
  70. $price_type = ($price_type == 0 ? 0 : 1);
  71. } else {
  72. $price_type = 0;
  73. }
  74. if ($price_type == 0) {
  75. $price_coin = $price;
  76. $price_max = Website::getWebsiteConfig()->getValue('max_price_coin');
  77. } else {
  78. $price_gold = $price;
  79. $price_max = Website::getWebsiteConfig()->getValue('max_price_gold');
  80. }
  81. if (!$player->isOnline()) {
  82. if ($price > 0 && $price <= $price_max) {
  83. $valida = $SQL->query("SELECT id_player FROM account_character_sale where id_player = {$player_id}")->rowCount();
  84. if ($account_logged->getID()) {
  85. if ($valida == 0) {
  86. $query = $SQL->prepare("SELECT * FROM players WHERE id = :p_id AND level >= " . Website::getWebsiteConfig()->getValue("min_lvl_to_sell"));
  87. $query->execute(['p_id' => $player_id]);
  88. $valida = $query->rowCount();
  89. if ($valida > 0) {
  90. if ($player->getAccountID() == $account_logged->getID()) {
  91. $query = $SQL->prepare("INSERT INTO `account_character_sale`
  92. (`id_account`,`id_player`,`status`, `price_type`,`price_coins`,`price_gold`, `dta_insert`,`dta_valid`)
  93. VALUES (:account_id, :player_id, 0, :price_type, :price_coin, :price_gold, :now, :valid);");
  94. $query->execute(['account_id' => $player->getAccountID(), 'player_id' => $player_id, 'price_type' => $price_type, 'price_coin' => $price_coin, 'price_gold' => $price_gold, 'now' => $now, 'valid' => $valid]);
  95.  
  96. $query = $SQL->prepare("UPDATE `players` SET `account_id` = :account_id WHERE `id` = :player_id;");
  97. $query->execute(['account_id' => $config['sell']['account_seller_id'], 'player_id' => $player_id]);
  98. $query = $SQL->prepare("INSERT INTO account_character_sale_history
  99. (id_old_account, id_new_account, id_player,dta_insert, dta_sale)
  100. VALUES (:account_id, NULL , :player_id, :now, NULL);");
  101. $query->execute(['account_id' => $player->getAccountID(), 'player_id' => $player_id, 'now' => $now]);
  102.  
  103. if (Website::getWebsiteConfig()->getValue('sell_by_gold')) {
  104. $data = getStatus(false, 'Player inserido com sucesso.');
  105. } else {
  106. $data = getStatus(false, 'Player inserido com sucesso. A venda via GOLD está inativa portanto o valor escolhido será tratado como coins.');
  107. }
  108. return json_encode($data);
  109. } else {
  110. $data = getStatus(TRUE, 'O player que você tentou vender não pertence à essa account.');
  111. return json_encode($data);
  112. }
  113. } else {
  114. $data = getStatus(TRUE, 'Este player está abaixo do Level necessário para venda.');
  115. return json_encode($data);
  116. }
  117. } else {
  118. $data = getStatus(TRUE, 'Esse player já se encontra em venda.');
  119. return json_encode($data);
  120. }
  121. }
  122. } else {
  123. $data = getStatus(TRUE, "Preço deve estar entre 1 e " . number_format($price_max, 0, ',', '.'));
  124. return json_encode($data);
  125. }
  126. } else {
  127. $data = getStatus(TRUE, "O jogador deve estar offline");
  128. return json_encode($data);
  129. }
  130. } else {
  131. $data = getStatus(TRUE, "Você não pode vender seu char que está recebendo o dinheiro de suas compras.");
  132. return json_encode($data);
  133. }
  134. } else {
  135. $data = getStatus(TRUE, "Você não pode vender sem antes selecionar um player para receber o valor das suas vendas realizadas em coins.");
  136. return json_encode($data);
  137. }
  138. } else {
  139. $data = getStatus(TRUE, "Número máximo de requisições por minuto atingido.");
  140. return json_encode($data);
  141. }
  142. } else {
  143. $data = getStatus(TRUE, "A RK(recovery key) digitada não é compatível com a RK da conta logada.");
  144. return json_encode($data);
  145. }
  146. };
  147.  
  148. /**
  149. * @param $player_id
  150. * @return bool
  151. */
  152. $remove_sell_characters = function ($player_id, $rk) use ($config, $SQL, $account_logged, $verifica_rk) {
  153. $req = valida_multiplas_reqs();
  154. $vrk = $verifica_rk($rk);
  155. if ($vrk) {
  156. if ($req) {
  157. $player_id = (int) $player_id;
  158. $valida = $SQL->prepare("SELECT `id_account` FROM `account_character_sale` WHERE id_player = :id_player AND id_account = :id_account");
  159. $valida->execute(['id_player' => $player_id, 'id_account' => $account_logged->getID()]);
  160. // var_dump($valida->rowCount(), $valida->fetchAll());
  161. if ($valida->rowCount() > 0) {
  162. $account_id = $valida->fetchAll()[0]['id_account'];
  163. $query = $SQL->prepare("UPDATE players SET account_id = :account_id WHERE id = :player_id");
  164. $query->execute(['account_id' => $account_id, 'player_id' => $player_id]);
  165. $query = $SQL->prepare("DELETE FROM `account_character_sale` WHERE `id_player` = :player_id");
  166. $query->execute(['player_id' => $player_id]);
  167. $data = getStatus(false, 'Player removido da venda com sucesso');
  168. return json_encode($data);
  169. } else {
  170. $data = getStatus(TRUE, 'Falha ao remover este player ou ele não se encontra em venda ou não pertence à sua account.');
  171. return json_encode($data);
  172. }
  173. } else {
  174. $data = getStatus(TRUE, "Número máximo de requisições por minuto atingido.");
  175. return json_encode($data);
  176. }
  177. } else {
  178. $data = getStatus(TRUE, "A RK(recovery key) digitada não é compatível com a RK da conta logada.");
  179. return json_encode($data);
  180. }
  181. };
  182.  
  183.  
  184. /**
  185. * Só deve ser utilizado por administradores do site!
  186. * @param $id
  187. */
  188. $extorna_venda_by_id_venda = function ($id) use ($SQL) {
  189. $q = $SQL->query("SELECT * FROM account_character_sale_history WHERE id = $id")->fetchAll();
  190. if ($q[0]['dta_sale'] != NULL && $q[0]['extornada'] != 1) {
  191. $id_old = $q[0]['id_old_account'];
  192. $id_pla = $q[0]['id_player'];
  193. $id_new = $q[0]['id_new_account'];
  194. $price_type = $q[0]['price_type'];
  195. $price = $q[0]['price'];
  196. $pbankid = $q[0]['char_id'];
  197. $bank_char_id = $SQL->query("SELECT player_sell_bank from accounts WHERE id = $id_old")->fetchAll();
  198. $bank_char_id = (int) $bank_char_id[0]['player_sell_bank'];
  199. $percent = Website::getWebsiteConfig()->getValue('percent_sellchar_sale') / 100;
  200. $SQL->query("UPDATE account_character_sale_history SET extornada = 1 WHERE id = $id")->fetchAll();
  201. if ($price_type == 0) {
  202. $SQL->query("UPDATE accounts SET coins = (coins+$price) WHERE id = $id_new")->fetchAll();
  203. $SQL->query("UPDATE accounts SET coins = (coins-($price-($price*$percent))) WHERE id = $id_old")->fetchAll();
  204. } else {
  205. $SQL->query("UPDATE players SET balance = (balance+$price) WHERE id = $pbankid")->fetchAll();
  206. $p = new Player();
  207. $p->loadById($bank_char_id);
  208. $p->setBalance($p->getBalance() - $price);
  209. $p->save();
  210. }
  211. $SQL->query("UPDATE players SET account_id = $id_old WHERE id = $id_pla")->fetchAll();
  212. } else {
  213. echo "erro";
  214. }
  215. };
  216.  
  217. /**
  218. * @param $player_id
  219. * @param $account_id
  220. * @param null $char_id
  221. * @return string
  222. */
  223. $buy_character_in_sale = function ($player_id, $account_id, $char_id = NULL) use ($config, $SQL, $account_logged) {
  224. $req = valida_multiplas_reqs();
  225. if ($req) {
  226. if ($account_id == $account_logged->getID()) {
  227. $valida_acc = $SQL->prepare("SELECT id_player,id_account FROM account_character_sale WHERE id_player = :player_id AND id_account = :account_id");
  228. $valida_acc->execute(['player_id' => $player_id, 'account_id' => $account_id]);
  229. $valida_id = $SQL->prepare("SELECT id_player,id_account FROM account_character_sale WHERE id_player = :player_id");
  230. $valida_id->execute(['player_id' => $player_id]);
  231. if ($valida_id->rowCount() != 0) {
  232. if ($valida_acc->rowCount() == 0) {
  233. $v = $SQL->prepare("SELECT * FROM account_character_sale WHERE id_player = :id_player");
  234. $v->execute(['id_player' => $player_id]);
  235. $p = $v->fetchAll();
  236. if ($char_id != NULL) {
  237. $s = new Player();
  238. $s->loadById($char_id);
  239. //trava o codigo caso o player não seja da conta do maluco logado
  240. if ($account_logged->getID() != $s->getAccountID()) {
  241. $data = getStatus(TRUE, 'Você não tem permissão pra isso.');
  242. return json_encode($data);
  243. }
  244. $balance = $s->getBalance();
  245. } else {
  246. $balance = 0;
  247. }
  248. $price = ($p[0]['price_type'] == 0 ? $p[0]['price_coins'] : $p[0]['price_gold']);
  249. $old_id = $valida_id->fetchAll();
  250. $old_id = $old_id[0]['id_account'];
  251. $dta = new DateTime();
  252. $dta = $dta->format('Y-m-d H:i:s');
  253. $percent = Website::getWebsiteConfig()->getValue('percent_sellchar_sale') / 100;
  254. if ($p[0]['price_type'] == 0) {
  255. $saldo = $account_logged->getPremiumPoints();
  256. if ($price <= $saldo) {
  257. $query = $SQL->prepare("INSERT INTO account_character_sale_history (id_old_account, id_player, id_new_account,price_type,price, dta_insert,dta_sale) VALUES (:old_id, :player_id, :account_id, :price_type, :price, $dta, :dta)");
  258. $query->execute(['old_id' => $old_id, 'player_id' => $player_id, 'account_id' => $account_id, 'price_type' => $p[0]['price_type'], 'price' => $price, 'dta' => $dta]);
  259. $query = $SQL->prepare("DELETE FROM account_character_sale WHERE id_player = :id");
  260. $query->execute(['id' => $player_id]);
  261. $query = $SQL->prepare("UPDATE accounts SET coins = (coins-:price) WHERE id = :account_id");
  262. $query->execute(['price' => $price, 'account_id' => $account_id]);
  263. $query = $SQL->prepare("UPDATE accounts SET coins = (coins+(:price-(:price*($percent)))) WHERE id = :account_id");
  264. $query->execute(['price' => $price, 'account_id' => $old_id]);
  265. $query = $SQL->prepare("UPDATE players SET account_id = :acc_id WHERE id = :pl_id");
  266. $query->execute(['acc_id' => $account_logged->getID(), 'pl_id' => $player_id]);
  267. $data = getStatus(false, 'Você comprou este personagem com sucesso.');
  268. return json_encode($data);
  269. } else {
  270. $data = getStatus(TRUE, 'Você não tem saldo suficiente para essa compra.');
  271. return json_encode($data);
  272. }
  273. } else {
  274. if ($char_id > 0) {
  275. $saldo = $balance;
  276. if ($price <= $saldo) {
  277. $verifica_logado = $SQL->prepare("SELECT * FROM players_online WHERE player_id = :pid");
  278. $verifica_logado->execute(['pid' => $char_id]);
  279. if ($verifica_logado->rowCount() == 0) {
  280. $bank_char_id = $SQL->query("SELECT player_sell_bank from accounts WHERE id = $old_id")->fetchAll();
  281. $bank_char_id = $bank_char_id[0]['player_sell_bank'];
  282. $query = $SQL->prepare("INSERT INTO account_character_sale_history (id_old_account, id_player, id_new_account,price_type,price,char_id,dta_insert, dta_sale) VALUES (:old_id, :player_id, :account_id, :price_type, :price, :char_id, $dta, :dta)");
  283. $query->execute(['old_id' => $old_id, 'player_id' => $player_id, 'account_id' => $account_id, 'price_type' => $p[0]['price_type'], 'price' => $price, 'char_id' => $char_id, 'dta' => $dta]);
  284. $query = $SQL->prepare("DELETE FROM account_character_sale WHERE id_player = :id");
  285. $query->execute(['id' => $player_id]);
  286. $query = $SQL->prepare("UPDATE players SET balance = (balance-:price) WHERE id = :p_id");
  287. $query->execute(['price' => $price, 'p_id' => $char_id]);
  288. $query = $SQL->prepare("UPDATE players SET balance = (balance+(:price-(:price*($percent)))) WHERE id = :p_id");
  289. $query->execute(['price' => $price, 'p_id' => $bank_char_id]);
  290. $query = $SQL->prepare("UPDATE players SET account_id = :acc_id WHERE id = :pl_id");
  291. $query->execute(['acc_id' => $account_logged->getID(), 'pl_id' => $player_id]);
  292. $data = getStatus(false, 'Você comprou este personagem com sucesso.');
  293. return json_encode($data);
  294. } else {
  295. $data = getStatus(TRUE, 'Seu personagem não pode estar logado ao realizar essa compra. Por favor faça logout e tente novamente.');
  296. return json_encode($data);
  297. }
  298. } else {
  299. $data = getStatus(TRUE, 'Você não tem saldo suficiente para essa compra.');
  300. return json_encode($data);
  301. }
  302. } else {
  303. $data = getStatus(TRUE, 'Para essa operação você precisa selecionar um personagem cujo qual será utilizado o saldo do balance para a compra.');
  304. return json_encode($data);
  305. }
  306. }
  307. } else {
  308. $data = getStatus(TRUE, 'Você não pode comprar seu próprio personagem.');
  309. return json_encode($data);
  310. }
  311. } else {
  312. $data = getStatus(TRUE, "Você não tem permissão pra isso.");
  313. return json_encode($data);
  314. }
  315. } else {
  316. $data = getStatus(TRUE, "Você não tem permissão pra isso.");
  317. return json_encode($data);
  318. }
  319. } else {
  320. $data = getStatus(TRUE, "Número máximo de requisições por minuto atingido.");
  321. return json_encode($data);
  322. }
  323. };
  324. $select_player_bank = function ($id) use ($config, $SQL, $account_logged) {
  325. $req = valida_multiplas_reqs();
  326. if ($req) {
  327. if ($id > 0) {
  328. $val = $SQL->query("SELECT * FROM players WHERE id = $id AND account_id = {$account_logged->getID()}")->fetchAll();
  329. if (count($val) > 0) {
  330. $q = $SQL->prepare("UPDATE accounts SET player_sell_bank = $id WHERE id = {$account_logged->getID()}");
  331. $q->execute();
  332. $data = getStatus(false, 'Você atualizou o player com sucesso. Caso venda algum character via Gold os golds serão entregues à ele.');
  333. return json_encode($data);
  334. } else {
  335. $data = getStatus(TRUE, 'Esse player não pertence à você');
  336. return json_encode($data);
  337. }
  338. } else {
  339. $data = getStatus(TRUE, 'Selecione um player!');
  340. return json_encode($data);
  341. }
  342. } else {
  343. $data = getStatus(TRUE, "Número máximo de requisições por minuto atingido.");
  344. return json_encode($data);
  345. }
  346. };
  347.  
  348. $type = $_POST['type'];
  349. if ($_POST['type']) {
  350. if ($type == 1) {
  351. $rk = $_REQUEST['rk'];
  352. $player_sell_id = (int) $_POST['id'];
  353. $sell_type = (int) $_POST['price_type'];
  354. $price = (int) $_POST['price'];
  355. echo $add_sell_character($player_sell_id, $sell_type, $price, $rk);
  356. die();
  357. }
  358. if ($type == 2) {
  359. $rk = $_REQUEST['rk'];
  360. $remove_id = $_POST['remove_id'];
  361. echo $remove_sell_characters($remove_id, $rk);
  362. die();
  363. }
  364. if ($type == 3) {
  365. $player_id = (int) $_POST['id'];
  366. if (isset($_POST['char_id'])) {
  367. $char_id = (int) $_POST['char_id'];
  368. echo $buy_character_in_sale($player_id, $account_logged->getID(), $char_id);
  369. die();
  370. } else {
  371. echo $buy_character_in_sale($player_id, $account_logged->getID());
  372. die();
  373. }
  374. }
  375. if ($type == 4) {
  376. $id = $_POST['id'];
  377. echo $select_player_bank($id);
  378. die();
  379. }
  380. } else {
  381. $main_content .= "
  382. <p>Welcome to our character selling system, look carefully at the information below so you can make a safe and trouble-free sale of your character.</p>
  383. <p><b>Who can sell, and how?</b></p>
  384. <p>Anyone who has a character above the <b>level " . Website::getWebsiteConfig()->getValue('min_lvl_to_sell') . "</b>, that is not banned you can put it on sale. The process is simple, you will choose the character you want to sell, then put the value (in premium points) that you will ask for it.</p>
  385. <p style='text-align: center'><b>Attention!</b></p>
  386. <p style='text-align: center'>Será cobrado uma porcentagem de (" . Website::getWebsiteConfig()->getValue('percent_sellchar_sale') . "%) para cada venda realizada.</p>
  387. <p>Antes de fazer uma venda você precisa escolher um player para receber o gold das vendas - Esse player não poderá ser vendido.</p>";
  388. $q = $SQL->query("SELECT id FROM players WHERE account_id = {$account_logged->getID()}")->fetchAll();
  389. $selected = $SQL->query("SELECT player_sell_bank FROM accounts WHERE id = {$account_logged->getID()}")->fetchAll();
  390. $selected = $selected[0]['player_sell_bank'];
  391. $main_content .= "<form id='select_player_bank' method='post' action='./?subtopic=accountmanagement&action=sellchar'>
  392. <input type='hidden' value='4' name='type'>
  393. <select name='id'>
  394. <option value='0' " . ($selected == NULL ? "selected" : "") . ">-->SELECT PLAYER<--</option>";
  395. foreach ($q as $play) {
  396. $pl = new Player();
  397. $pl->loadById($play['id']);
  398. $main_content .= "
  399. <option value='{$pl->getID()}' " . ($selected == $pl->getID() ? "selected" : "") . " name='{$pl->getID()}'>{$pl->getName()}</option>";
  400. }
  401. $main_content .= "</select>
  402. <input type='submit' value='escolher'>
  403. </form>";
  404. $main_content .= "
  405. <script>
  406. $('#select_player_bank').submit(function() {
  407. var form = $(this);
  408. var data = form.serialize();
  409. var url = form.attr('action');
  410. var type = form.attr('method');
  411. $.ajax({
  412. url: url,
  413. data: data,
  414. type: type,
  415. dataType: 'json',
  416. beforeSend: function(){
  417. // $('.se-pre-con').fadeIn('fast');
  418. iziToast.show({
  419. title: 'Now...',
  420. message: 'Loading!!',
  421. position:'topRight',
  422. timeout:2000
  423. });
  424. },
  425. success: function(response) {
  426. if(response.error === true){
  427. $('.se-pre-con').fadeOut('slow');
  428. iziToast.error({
  429. title: 'ERROR:',
  430. message: response.msg,
  431. position: 'topRight', // bottomRight, bottomLeft, topRight, topLeft, topCenter, bottomCenter, center
  432. timeout: 3000
  433. });
  434. }else{
  435. $('.se-pre-con').fadeOut('slow');
  436. iziToast.success({
  437. title:'Success:',
  438. message:response.msg,
  439. position:'topRight',
  440. timeout: 4000
  441. });
  442. }
  443. }
  444. });
  445. return false;
  446. });
  447. </script>";
  448. $main_content .= "
  449. <p>Check correctly if the character you are selling is what you really want to sell, and also the price of it, once you post the sale you can just give up the sale a day later. Below is the list of characters you can sell.</p>";
  450. $main_content .= '<div class="sell_error_handler"></div>';
  451. $main_content .= '<div class="TableContainer">';
  452. $main_content .= $make_content_header("Character");
  453. $main_content .= $make_table_header();
  454. $main_content .= '
  455. <tr style="height: 40px">
  456. <td width="8%"><strong>*</strong></td>
  457. <td><strong>Character</strong></td>
  458. <td align="center"><strong>Recovery Key</strong></td>
  459. <td align="center"><strong>Offer Type</strong></td>
  460. <td align="center"><strong>Offer Value<br></strong></td>
  461. <td width="15%" align="center"><strong>Sell</strong></td>
  462. </tr>';
  463.  
  464. $p = $account_logged->getPlayersList()->data;
  465. $i = 0;
  466. if (count($p) > 0) {
  467. foreach ($p as $players) {
  468. $pl = new Player();
  469. $bgcolor = (($i++ % 2 == 1) ? $config['site']['darkborder'] : $config['site']['lightborder']);
  470. $pl->loadById($players['id']);
  471. $main_content .= "<form id='sell_char_" . $pl->getID() . "' method='post' action='./?subtopic=accountmanagement&action=sellchar'>";
  472. $main_content .= '<tr class="char_' . $pl->getID() . '" style="background-color:' . $bgcolor . ';">';
  473. $main_content .= "<td><img class='Outfit' src='" . $pl->makeOutfitUrl() . "' alt='' name=''></td>";
  474. $main_content .= "<td><a href='./?subtopic=characters&name=" . urlencode($pl->getName()) . "' <b>" . $pl->getName() . "</b></a><br/><small>" . $pl->getVocationName() . "<br/>lvl: " . $pl->getLevel() . "</small></td>";
  475. $main_content .= "<td><input type='text' name='rk' style='text-transform: uppercase' required></td>";
  476. $main_content .= "
  477. <td>
  478. <select name='price_type' required>
  479. <option value='0' name='0'>Coins</option>
  480. <option value='1' name='1'>Gold</option>
  481. </select>
  482. </td>";
  483. $main_content .= "<td><input type='number' name='price' required></td>";
  484. $main_content .= "<input type='hidden' name='type' value='1'>";
  485. $main_content .= "<input type='hidden' name='id' value='" . $pl->getID() . "'>";
  486. $main_content .= "<td align='center'><input type='submit' name='submit' value='Vender'></td>";
  487. $main_content .= '
  488. <script>
  489. var q = $("#sell_char_' . $pl->getID() . '");
  490. q.submit(function() {
  491. var form = $(this);
  492. var data = form.serialize();
  493. var url = form.attr("action");
  494. var type = form.attr("method");
  495. $.ajax({
  496. url: url,
  497. data: data,
  498. type: type,
  499. dataType: "json",
  500. beforeSend: function(){
  501. $(".se-pre-con").fadeIn("fast");
  502. },
  503. success: function(response) {
  504. if(response.error === true){
  505. $(".se-pre-con").fadeOut("slow");
  506. iziToast.error({
  507. title: "ERROR:",
  508. message: response.msg,
  509. position: \'topRight\', // bottomRight, bottomLeft, topRight, topLeft, topCenter, bottomCenter, center
  510. timeout: 2500
  511. });
  512. }else{
  513. $(".char_' . $pl->getID() . '").fadeOut("slow");
  514. $(".se-pre-con").fadeOut("slow");
  515. iziToast.success({
  516. title:"Success:",
  517. message:response.msg,
  518. position:"topRight",
  519. timeout: 2500,
  520. onClosing: function (instance, toast, closedBy) {
  521. // console.info(\'closedBy: \' + closedBy);
  522. window.location.replace("./?subtopic=accountmanagement&action=sellchar");
  523. }
  524. });
  525. }
  526. }
  527. });
  528. return false;
  529. });
  530. </script>
  531. ';
  532. $main_content .= '</tr>';
  533. $main_content .= "</form>";
  534. }
  535. } else {
  536. $main_content .= '
  537. <tr style="background-color:#F1E0C6;">
  538. <td colspan="6">Você ainda não possui personagens em sua conta.</td>
  539. </tr>';
  540. }
  541. $main_content .= $make_table_footer();
  542. $main_content .= '</div>';
  543.  
  544. $main_content .= '<p>Once put up for sale, you can only withdraw after of <span style="color: #5b0600">(1 hours)</span></p>';
  545.  
  546. $main_content .= '<div class="TableContainer">';
  547. $main_content .= $make_content_header("Characters for sale");
  548. $main_content .= $make_table_header();
  549. $main_content .= '
  550. <tr style="height: 40px;">
  551. <td width="8%"><strong>*</strong></td>
  552. <td width="15%"><strong>Character</strong></td>
  553. <td align="center"><strong>Value</strong></td>
  554. <td width="25%" align="center"><strong>Date</strong></td>
  555. <td width="25%" align="center"><strong>Recovery Key</strong></td>
  556. <td width="15%" align="center"><strong>Cancel</strong></td>
  557. </tr>';
  558. $sellers = $SQL->query("SELECT * FROM account_character_sale WHERE id_account = {$account_logged->getID()}")->fetchAll();
  559. if (count($sellers) > 0) {
  560. $i = 0;
  561. foreach ($sellers as $seller) {
  562. $pl = new Player();
  563. $pl->loadById($seller['id_player']);
  564. $bgcolor = (($i++ % 2 == 1) ? $config['site']['darkborder'] : $config['site']['lightborder']);
  565. $main_content .= "<form id='remove_sell_player_{$pl->getID()}' method='post' action='./?subtopic=accountmanagement&action=sellchar'>";
  566. $main_content .= "<tr style='background-color: {$bgcolor}'>";
  567. $main_content .= "<td><img class='Outfit' src='{$pl->makeOutfitUrl()}'' alt='' name=''></td>";
  568. $main_content .= "<td><a href='./?subtopic=characters&name=" . urlencode($pl->getName()) . "' <b>" . $pl->getName() . "</b></a> <br/> <small>{$pl->getVocationName()}<br/>lvl: {$pl->getLevel()}</small></td>";
  569. $main_content .= "<td>" . ($seller['price_type'] == 0 ? number_format($seller['price_coins'], 0, ',', '.') . " Coins" : number_format($seller['price_gold'], 0, ',', '.') . " Gold") . "</td>";
  570. $main_content .= "<td>{$seller['dta_valid']}</td>";
  571. $main_content .= "<td><input type='text' style='text-transform: uppercase' name='rk' required></td>";
  572. $main_content .= "<input type='hidden' value='2' name='type'>";
  573. $main_content .= "<input type='hidden' value='{$pl->getID()}' name='remove_id'>";
  574. $main_content .= "<td align='center'><input type='submit' value='remover'></td>";
  575. $main_content .= "</tr>";
  576. $main_content .= "</form>";
  577. $main_content .= "
  578. <script>
  579. $('#remove_sell_player_{$pl->getID()}').submit(function() {
  580. var form = $(this);
  581. var data = form.serialize();
  582. var url = form.attr(\"action\");
  583. var type = form.attr(\"method\");
  584. $.ajax({
  585. url: url,
  586. data: data,
  587. type: type,
  588. dataType: \"json\",
  589. beforeSend: function(){
  590. $(\".se-pre-con\").fadeIn(\"fast\");
  591. },
  592. success: function(response) {
  593. console.log(response.error);
  594. if(response.error === true){
  595. $(\".se-pre-con\").fadeOut(\"slow\");
  596. iziToast.error({
  597. title: \"ERROR:\",
  598. message: response.msg,
  599. position: 'topRight', // bottomRight, bottomLeft, topRight, topLeft, topCenter, bottomCenter, center
  600. timeout: 2500
  601. });
  602. }else{
  603. $(\".se-pre-con\").fadeOut(\"slow\");
  604. iziToast.success({
  605. title:\"Success:\",
  606. message:response.msg,
  607. position:\"topRight\",
  608. timeout: 2500,
  609. onClosing: function (instance, toast, closedBy) {
  610. // console.info('closedBy: ' + closedBy);
  611. window.location.replace(\"./?subtopic=accountmanagement&action=sellchar\");
  612. }
  613. });
  614. }
  615. }
  616. });
  617. return false;
  618. })
  619. </script>
  620. ";
  621. }
  622. } else {
  623. $main_content .= '
  624. <tr style="background-color:#F1E0C6;">
  625. <td colspan="6">Você não possui personagens à venda.</td>
  626. </tr>';
  627. }
  628.  
  629. $main_content .= $make_table_footer();
  630. $main_content .= '</div>';
  631. }
  632.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement