Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.21 KB | None | 0 0
  1. <?php
  2. use Maythiwat\WalletAPI;
  3. require_once(__DIR__ . '/../application/_truewallet.php');
  4. require_once 'application/_loginTW.php';
  5.  
  6. $sql_wallet = 'SELECT * FROM wallet_account WHERE id = 1';
  7. $query_wallet = $connect->query($sql_wallet);
  8.  
  9. if($query_wallet->num_rows == 1)
  10. {
  11. $f_wallet = $query_wallet->fetch_assoc();
  12. $wallet_email = $f_wallet['email'];
  13. $wallet_password = $f_wallet['password'];
  14. $wallet_phone = $f_wallet['phone'];
  15. $wallet_name = $f_wallet['name'];
  16. $wallet_message = $f_wallet['message'];
  17. $wallet_reference_token = $f_wallet['reference_token'];
  18. }
  19.  
  20. /* ห้ามแก้ไข */
  21. $config_tw = array(
  22. 'email' => $wallet_email,
  23. 'password' => $wallet_password,
  24. 'referen_token' => $wallet_reference_token
  25. );
  26. /* จบการห้าม */
  27.  
  28. function curl($url) {
  29. global $config_tw;
  30. $ch = curl_init();
  31. $post = [
  32. 'email' => $config_tw['email'],
  33. 'password' => $config_tw['password'],
  34. 'referen_token' => $config_tw['referen_token']
  35. ];
  36. curl_setopt($ch, CURLOPT_URL, $url);
  37. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  38. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
  39. curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
  40. $data = curl_exec($ch);
  41. curl_close($ch);
  42. return $data;
  43. }
  44. ?>
  45. <script type="text/javascript">
  46. function NumbersOnly(e){
  47. var keynum;
  48. var keychar;
  49. var numcheck;
  50. if(window.event) {// IE
  51. keynum = e.keyCode;
  52. } else if(e.which) {// Netscape/Firefox/Opera
  53. keynum = e.which;
  54. }
  55. if(keynum == 13 || keynum == 8 || typeof(keynum) == "undefined"){
  56. return true;
  57. }
  58. keychar= String.fromCharCode(keynum);
  59. numcheck = /^[0-9]$/; // อยากจะพิมพ์อะไรได้มั่ง เติม regular expression ได้ที่ line นี้เลยคับ
  60. return numcheck.test(keychar);
  61. }
  62. </script>
  63. <div class="card-header bg-info btn-line-b black_line" style="color:#FFF;">
  64. <h5 class="mb-0">
  65. <i class="fas fa-credit-card"></i> เติมเงิน
  66. </h5>
  67. </div>
  68. <div class="card-body bg-white">
  69. <?php
  70. if(!isset($_SESSION['uid']) || !isset($_SESSION['username']))
  71. {
  72. include_once 'template/alertLogin.php';
  73. }
  74. else
  75. {
  76. ?>
  77. <div class="row">
  78. <?php
  79. if(!isset($_POST['btn_wallet']) && !isset($_POST['btn_truemoney']))
  80. {
  81. ?>
  82. <div class="col-md-12 mb-1">
  83. <div class="alert alert-info text-center">
  84. <i class="fas fa-exclamation-triangle text-dark"></i>
  85. โอนเงินผ่าน Wallet ได้ที่เบอร์ <strong><?php echo $wallet_phone; ?></strong>
  86. <br/>
  87. ชื่อบัญชี: <?php echo $wallet_name; ?>
  88. <br/>
  89. <?php
  90. if($wallet_message != '0')
  91. {
  92. ?>
  93. ตอนโอนให้พิมพ์ข้อความว่า: <strong><?php echo $wallet_message; ?></strong>
  94. <?php
  95. }
  96. ?>
  97. </div>
  98. </div>
  99. <?php
  100. }
  101.  
  102. if(isset($_POST['btn_wallet']))
  103. {
  104. /* ห้ามแก้ไข หากไม่รู้ */
  105. $url_truewallet = "https://api.jamebies.com/wallet/truewallet.php?transaction=";
  106. /* จบการห้ามแก้ไข */
  107.  
  108. /* GET TRANSACTION */
  109. if(empty($_POST['wallet_transaction']))
  110. {
  111. $msg = 'กรุณาอย่าเว้นว่างช่องหมายเลขอ้างอิง';
  112. $alert = 'error';
  113. $msg_alert = 'เกิดข้อผิดพลาด!';
  114. }
  115. else
  116. {
  117. $tw = json_decode(curl($url_truewallet.$_POST['wallet_transaction']));
  118. if($tw->code == 100)
  119. {
  120. $fti_u = $tw->transaction; // หมายเลขอ้างอิง
  121. $ftam_u = $tw->amount; // จำนวนเงิน
  122. $ftm_u = $tw->message_transfer; // ข้อความ
  123. $ftphone_u = $tw->phone; // เบอร์ที่โอนมา
  124. $fttime_u = $tw->time; // วันที่และเวลาที่ทำรายการ
  125.  
  126. $sql_check_reportid = 'SELECT * FROM activities WHERE transaction = "'.$fti_u.'" LIMIT 1';
  127. $query_check_reportid = $connect->query($sql_check_reportid);
  128. $numrows_check_reportid = $query_check_reportid->num_rows;
  129.  
  130. if($numrows_check_reportid != 0)
  131. {
  132. $msg = 'หมายเลขอ้างอิงนี้มีการเติมเข้ามาแล้ว';
  133. $alert = 'error';
  134. $msg_alert = 'เกิดข้อผิดพลาด!';
  135.  
  136. //* ประกาศ
  137. echo '<div class="col-md-12 mb-1"><div class="alert alert-info"><i class="fa fa-spinner fa-spin fa-lg"></i> <strong>หมายเลขอ้างอิงนี้มีการเติมเข้ามาแล้ว</strong></div></div>';
  138.  
  139. //* REFRESH
  140. echo "<meta http-equiv='refresh' content='3 ;'>";
  141. }
  142. else
  143. {
  144. $activities_action = "TOPUP Truewallet";
  145. $time_date = date("Y-m-d H:i");
  146. $sql_insert_log = 'INSERT INTO activities (uid,username,action,date,topup_amount,transaction) VALUES("'.$_SESSION['uid'].'","'.$_SESSION['username'].'","'.$activities_action.'","'.$time_date.'","'.$ftam_u.'","'.$fti_u.'")';
  147. $query_insert_log = $connect->query($sql_insert_log);
  148. if($query_insert_log)
  149. {
  150. $sql_wallet = 'SELECT * FROM wallet_account WHERE id = 1';
  151. $query_wallet = $connect->query($sql_wallet);
  152. $wallet = $query_wallet->fetch_assoc();
  153.  
  154. if($wallet['message'] == '0')
  155. {
  156. $mutiple_amount = $ftam_u * $wallet['mutiple'];
  157.  
  158. $query_list_rp = $connect->query($sql_list_rp);
  159. if($query_list_rp->num_rows != 0)
  160. {
  161. $list_rp = $query_list_rp->fetch_assoc();
  162. $rp_update = $list_rp['rp'];
  163. }
  164. else
  165. {
  166. $rp_update = 0;
  167. }
  168.  
  169. $sql_updatep = 'UPDATE authme SET points = points+"'.$mutiple_amount.'", topup = topup+"'.$ftam_u.'", topup_w = topup_w+"'.$ftam_u.'" WHERE id = "'.$_SESSION['uid'].'"';
  170. $connect->query($sql_updatep);
  171.  
  172. $msg = 'คุณได้ทำการเติมเงินด้วยการโอน Truewallet จำนวน '.$ftam_u.' บาท';
  173. $alert = 'success';
  174. $msg_alert = 'สำเร็จ!';
  175. }
  176. else
  177. {
  178. if($ftm_u == $wallet['message'])
  179. {
  180. $mutiple_amount = $ftam_u * $wallet['mutiple'];
  181.  
  182. $query_list_rp = $connect->query($sql_list_rp);
  183. if($query_list_rp->num_rows != 0)
  184. {
  185. $list_rp = $query_list_rp->fetch_assoc();
  186. $rp_update = $list_rp['rp'];
  187. }
  188. else
  189. {
  190. $rp_update = 0;
  191. }
  192.  
  193. $sql_updatep = 'UPDATE authme SET points = points+"'.$mutiple_amount.'", rp = rp+"'.$rp_update.'", topup = topup+"'.$ftam_u.'", topup_w = topup_w+"'.$ftam_u.'" WHERE id = "'.$_SESSION['uid'].'"';
  194. $connect->query($sql_updatep);
  195.  
  196. $msg = 'คุณได้ทำการเติมเงินด้วยการโอน Truewallet จำนวน '.$ftam_u.' บาท';
  197. $alert = 'success';
  198. $msg_alert = 'สำเร็จ!';
  199. }
  200. else
  201. {
  202. $sql_delete_transaction = 'DELETE FROM activities WHERE transaction = "'.$fti_u.'"';
  203. $connect->query($sql_delete_transaction);
  204.  
  205. $msg = 'เกิดข้อผิดพลาด ข้อความไม่ตรงกับระบบ<br/>กรุณากรอกข้อความตอนโอนว่า '.$wallet['message'];
  206. $alert = 'error';
  207. $msg_alert = 'เกิดข้อผิดพลาด!';
  208. }
  209. }
  210. }
  211. else
  212. {
  213. $msg = 'กรุณาลองใหม่ภายหลัง';
  214. $alert = 'error';
  215. $msg_alert = 'เกิดข้อผิดพลาด!';
  216.  
  217. //* ประกาศ
  218. echo '<div class="col-md-12 mb-1"><div class="alert alert-info"><i class="fa fa-spinner fa-spin fa-lg"></i> <strong>เกิดข้อผิดพลาด กรุณาลองใหม่ภายหลัง</strong></div></div>';
  219. //* REFRESH
  220. echo "<meta http-equiv='refresh' content='3 ;'>";
  221. }
  222. }
  223. }
  224. elseif($tw->code == '404(3)')
  225. {
  226. $msg = 'เกิดข้อผิดพลาด หรือ ไม่พบหมายเลขอ้างอิงนี้';
  227. $alert = 'error';
  228. $msg_alert = 'เกิดข้อผิดพลาด!';
  229.  
  230. //* ประกาศ
  231. echo '<div class="col-md-12 mb-1"><div class="alert alert-info"><i class="fa fa-spinner fa-spin fa-lg"></i> <strong>เกิดข้อผิดพลาด หรือ ไม่พบหมายเลขอ้างอิงนี้</strong></div></div>';
  232. //* REFRESH
  233. echo "<meta http-equiv='refresh' content='3 ;'>";
  234. }
  235. else
  236. {
  237. $msg = 'เกิดข้อผิดพลาด ไม่ทราบสาเหตุ';
  238. $alert = 'error';
  239. $msg_alert = 'เกิดข้อผิดพลาด!';
  240.  
  241. //* ประกาศ
  242. echo '<div class="col-md-12 mb-1"><div class="alert alert-info"><i class="fa fa-spinner fa-spin fa-lg"></i> <strong>เกิดข้อผิดพลาด ไม่ทราบสาเหตุ</strong></div></div>';
  243. //* REFRESH
  244. echo "<meta http-equiv='refresh' content='3 ;'>";
  245. }
  246. }
  247.  
  248. ?>
  249. <script>
  250. swal("<?php echo $msg_alert; ?>", "<?php echo $msg; ?>", "<?php echo $alert; ?>", {
  251. button: "Reload",
  252. })
  253. .then((value) => {
  254. window.location.href = window.location.href;
  255. });
  256. </script>
  257. <?php
  258.  
  259. }
  260.  
  261. if(isset($_POST['btn_truemoney']))
  262. {
  263. /* ห้ามแก้ไข หากไม่รู้ */
  264. $url_truemoney = "https://api.jamebies.com/wallet/truemoney.php?tmn=";
  265. @$tw_card = $connect->real_escape_string($_POST['truemoney_password']);
  266. $tmn = json_decode(curl($url_truemoney.$tw_card));
  267. /* จบการห้ามแก้ไข */
  268.  
  269. if($tmn->code == '100')
  270. {
  271. $objtw_amount = $tmn->amount;
  272. $sql_search = 'SELECT * FROM truemoney WHERE amount = "'.$objtw_amount.'"';
  273. $query_search = $connect->query($sql_search);
  274.  
  275. if($query_search->num_rows != 0)
  276. {
  277. $fetch_search = $query_search->fetch_assoc();
  278. $update_amount = $fetch_search['points'];
  279. }
  280. else
  281. {
  282. $update_amount = 0;
  283. }
  284.  
  285. $sql_updatepoints = 'UPDATE authme SET points = points+"'.$update_amount.'", topup = topup+"'.$objtw_amount.'", topup_m = topup_m+"'.$objtw_amount.'" WHERE id = "'.$_SESSION['uid'].'"';
  286. $query_updatepoints = $connect->query($sql_updatepoints);
  287. if($query_updatepoints)
  288. {
  289. $activities_action = "TOPUP TrueMoney";
  290. $time_date = date("Y-m-d H:i");
  291. $sql_insert_log = 'INSERT INTO activities (uid,username,action,date,topup_amount,transaction) VALUES ("'.$_SESSION['uid'].'","'.$_SESSION['username'].'","'.$activities_action.'","'.$time_date.'","'.$objtw_amount.'","'.$tw_card.'")';
  292. $connect->query($sql_insert_log);
  293.  
  294. $msg = 'คุณได้ทำการเติมเงินด้วยบัตรทรูมันนี่ '.$objtw_amount.' บาท';
  295. $alert = 'success';
  296. $msg_alert = 'สำเร็จ!';
  297. }
  298. }
  299. elseif($tmn->code == '404(3)')
  300. {
  301. $msg = 'รหัสบัตรทรูมันนี่ถูกใช้งานแล้ว หรือ รหัสบัตรทรูมันนี่ผิด';
  302. $alert = 'error';
  303. $msg_alert = 'เกิดข้อผิดพลาด!';
  304. }
  305. elseif($tmn->code == '404(2)')
  306. {
  307. $msg = 'เกิดข้อผิดพลาด รหัสบัตรเงินสดทรูมันนี่ไม่ถูกต้อง';
  308. $alert = 'error';
  309. $msg_alert = 'เกิดข้อผิดพลาด!';
  310. }
  311. elseif($tmn->code == '404(1)')
  312. {
  313. $msg = 'เกิดข้อผิดพลาด กรุณาแจ้งแอดมินติดต่อผู้พัฒนา (WEBSHOP)';
  314. $alert = 'error';
  315. $msg_alert = 'เกิดข้อผิดพลาด!';
  316. }
  317. else
  318. {
  319. $msg = 'เกิดข้อผิดพลาด ไม่ทราบสาเหตุ';
  320. $alert = 'error';
  321. $msg_alert = 'เกิดข้อผิดพลาด!';
  322. }
  323.  
  324. ?>
  325. <script>
  326. swal("<?php echo $msg_alert; ?>", "<?php echo $msg; ?>", "<?php echo $alert; ?>", {
  327. button: "Reload",
  328. })
  329. .then((value) => {
  330. window.location.href = window.location.href;
  331. });
  332. </script>
  333. <?php
  334.  
  335. }
  336. ?>
  337. <div class="col-md-12">
  338. <h5 class="text-center">เติมเงินด้วย <img src="<?php echo $config['site']."/img/wallet-logo.png"; ?>" alt="Wallet" style="width:18%"></h5>
  339. <hr class="mb-3"/>
  340. <form name="topup_wallet" method="POST">
  341. <div class="row">
  342. <div class="input-group col-md-8 mb-2">
  343. <input name="wallet_transaction" type="text" onkeypress="return NumbersOnly(event);" class="form-control" placeholder="เลขอ้างอิง 14 หลัก #ได้หลังจากการโอนเงิน" required="" maxlength="14">
  344. </div>
  345. <div class="input-group col-md-4 mb-2">
  346. <button name="btn_wallet" type="submit" class="btn btn-primary btn-block">
  347. เติมเงิน
  348. </button>
  349. </div>
  350. </div>
  351. </form>
  352. <span class="is-divider" data-content="หรือเติมเงินด้วย TrueMoney" style="margin: 1.5rem 0;"></span>
  353. <div class="col-md-12 col-12 text-center text-dark">
  354. <h5>อัตราการเติมเงินด้วย TrueMoney</h5>
  355. <table class="table text-dark text-center">
  356. <thead>
  357. <tr>
  358. <td class="py-1">ราคาเติม</td>
  359. <td class="py-1">พ้อยที่ได้</td>
  360. </tr>
  361. </thead>
  362. <tbody>
  363. <tr>
  364. <?php
  365. $sql_truemoney_points = 'SELECT * FROM truemoney ORDER BY amount ASC';
  366. $query_truemoney_points = $connect->query($sql_truemoney_points);
  367.  
  368. while($truemoney_points = $query_truemoney_points->fetch_assoc())
  369. {
  370. ?>
  371. <td class="py-1"><?php echo $truemoney_points['amount']; ?> บาท</td>
  372. <td class="py-1"><?php echo $truemoney_points['points']; ?> <i class="fas fa-coins text-dark"></i></td>
  373. </tr><tr>
  374. <?php
  375. }
  376. ?>
  377. </tr>
  378. </tbody>
  379. </table>
  380. </div>
  381. <form name="topup_truemoney" method="POST">
  382. <div class="row">
  383. <div class="input-group col-md-8 mb-2">
  384. <input name="truemoney_password" type="text" onkeypress="return NumbersOnly(event);" class="form-control" placeholder="รหัสบัตรทรูมันนี่ 14 หลัก" required="" maxlength="14">
  385. </div>
  386. <div class="input-group col-md-4 mb-2">
  387. <button name="btn_truemoney" type="submit" class="btn btn-primary btn-block">
  388. เติมเงิน
  389. </button>
  390. </div>
  391. </div>
  392. </form>
  393. </div>
  394. </div>
  395. <?php
  396. }
  397. ?>
  398. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement