Advertisement
Guest User

Untitled

a guest
Jan 26th, 2020
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.01 KB | None | 0 0
  1. <?php
  2. session_start();
  3. require_once("../../mainconfig.php");
  4. $page_type = "deposit";
  5.  
  6. if (isset($_SESSION['user'])) {
  7. $sess_username = $_SESSION['user']['username'];
  8. $check_user = mysqli_query($db, "SELECT * FROM users WHERE username = '$sess_username'");
  9. $data_user = mysqli_fetch_assoc($check_user);
  10. if (mysqli_num_rows($check_user) == 0) {
  11. header("Location: ".$cfg_baseurl."logout.php");
  12. } else if ($data_user['status'] == "Suspended") {
  13. header("Location: ".$cfg_baseurl."logout.php");
  14. }
  15.  
  16. include("../../lib/header.php");
  17. $msg_type = "nothing";
  18. $check_depo = mysqli_query($db, "SELECT * FROM history_topup WHERE username = '$sess_username' AND status = 'NO'");
  19.  
  20. if (isset($_POST['submit'])) {
  21. $dip = random_number(3);
  22. $post_method = mysqli_real_escape_string($db, trim($_POST['method']));
  23. $post_quantity = mysqli_real_escape_string($db, trim($_POST['quantity']));
  24. $no_pengirim = mysqli_real_escape_string($db, trim($_POST['nopengirim']));
  25. $nohp=$no_pengirim;
  26. $min_depo = "10000";
  27. if(!preg_match('/[^+0-9]/',trim($nohp))){
  28. // cek apakah no hp karakter 1-3 adalah +62
  29. if(substr(trim($nohp), 0, 3)=='62'){
  30. $no_pengirim_pulsa = trim($nohp);
  31.  
  32. }
  33. // cek apakah no hp karakter 1 adalah 0
  34. else if(substr(trim($nohp), 0, 1)=='0'){
  35. $no_pengirim_pulsa = '62'.substr(trim($nohp), 1);
  36. }
  37. }
  38.  
  39. $check_data_history = mysqli_query($db, "SELECT * FROM history_topup WHERE jumlah_transfer = '$post_quantity' AND no_pengirim = '$no_pengirim_pulsa' AND datetime = '$date $time'");
  40. if ($post_quantity < $min_depo) {
  41. $msg_type = "error";
  42. $msg_content = "<b>Failed:</b> Minimum deposit adalah ".$min_depo.".";
  43. } else if (mysqli_num_rows($check_depo) == 1) {
  44. $msg_type = "error";
  45. $msg_content = "<b>Failed:</b> Anda memiliki deposito Pending, segera lunasi.";
  46.  
  47. } else {
  48.  
  49. $ch = curl_init();
  50. curl_setopt($ch, CURLOPT_URL, "https://serverh2h.id/order/deposit");
  51. curl_setopt($ch, CURLOPT_POST, 1);
  52. curl_setopt($ch, CURLOPT_POSTFIELDS, "api_key=Apikeymu&nopengirim=$no_pengirim&quantity=$post_quantity&provider=XL");
  53. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  54. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  55. $chresult = curl_exec($ch);
  56. // echo $chresult;
  57. curl_close($ch);
  58. $json_result = json_decode($chresult, true);
  59. $kodee=$json_result['code'];
  60. if($json_result['code']==TRUE){
  61.  
  62. $balance_amount=$post_quantity*0.88;
  63. $insert_topup = mysqli_query($db, "INSERT INTO history_topup (provider, amount, jumlah_transfer, username, no_pengirim, datetime, status, type, kode) VALUES ('XL','$balance_amount','$post_quantity','$sess_username','$no_pengirim_pulsa','$date $time','NO','WEB','$kodee')");
  64. if ($insert_topup == TRUE) {
  65. $msg_type = "success";
  66. $msg_content = "<b>Permintaan Telah Dikirim!</b><br />
  67. <b>Provider :</b> XL<br />
  68. <b>Jumlah:</b> ".number_format($post_quantity,0,',','.')."<br />
  69. <b>Saldo Yang Didapat :</b> $balance_amount
  70. <hr>
  71. Silakan transfer biaya sebesar <span style='color: red'><b>Rp. ".number_format($post_quantity,0,',','.')."</b></span> ke Nomor ".$json_result['tujuan']." <br /><br>
  72. <span style='color: red'>Wajib sesuai dengan Nominal. </span>.";
  73. } else {
  74. $msg_type = "error";
  75. $msg_content = "<b>Failed:</b> System error.";
  76. }
  77. }else{
  78. $msg_type = "error";
  79. $msg_content = "<b>Failed:</b>".$json_result['error'];
  80. }
  81. }
  82. }
  83. $check_user = mysqli_query($db, "SELECT * FROM users WHERE username = '$sess_username'");
  84. $data_user = mysqli_fetch_assoc($check_user);
  85.  
  86. if(isset($_POST['delet'])) {
  87. $post_code = $_POST['kode'];
  88.  
  89. $select = mysqli_query($db, "SELECT * FROM history_topup WHERE kode = '$post_code'");
  90. $datana = mysqli_fetch_assoc($select);
  91.  
  92. if(mysqli_num_rows($select) == 0) {
  93. $msg_type = "error";
  94. $msg_content = "</span></button><b>Gagal:</b> Data tidak di temukan. ";
  95. } else if($datana['status'] == "YES") {
  96. $msg_type = "error";
  97. $msg_content = "</span></button><b>Gagal:</b> Data tidak bisa di batalkan. ";
  98. } else {
  99. $ch = curl_init();
  100. curl_setopt($ch, CURLOPT_URL, "https://serverh2h.id/status/deposit_cancel");
  101. curl_setopt($ch, CURLOPT_POST, 1);
  102. curl_setopt($ch, CURLOPT_POSTFIELDS, "api_key=Apikeymu&code=$post_code&provider=XL");
  103. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  104. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  105. $chresult = curl_exec($ch);
  106. //echo $chresult;
  107. curl_close($ch);
  108. $json_result = json_decode($chresult, true);
  109. $update = mysqli_query($db, "UPDATE history_topup set status = 'CANCEL' WHERE kode = '$post_code'");
  110. if($update == TRUE) {
  111. $msg_type = "success";
  112. $msg_content = "</span></button> Berhasil membatalkan!";
  113. } else {
  114. $msg_type = "error";
  115. $msg_content = "</span></button>GAGAL MEMBATALKAN #1";
  116. }
  117. }
  118. }if(isset($_POST['confirm'])) {
  119. $post_code = $_POST['kode'];
  120.  
  121. $select = mysqli_query($db, "SELECT * FROM history_topup WHERE kode = '$post_code'");
  122. $datana = mysqli_fetch_assoc($select);
  123.  
  124. if(mysqli_num_rows($select) == 0) {
  125. $msg_type = "error";
  126. $msg_content = "</span></button><b>Gagal:</b> Data tidak di temukan. ";
  127. } else if($datana['status'] == "YES") {
  128. $msg_type = "error";
  129. $msg_content = "</span></button><b>Gagal:</b> Data tidak bisa di ubah. ";
  130. } else {
  131. $ch = curl_init();
  132. curl_setopt($ch, CURLOPT_URL, "https://serverh2h.id/status/deposit");
  133. curl_setopt($ch, CURLOPT_POST, 1);
  134. curl_setopt($ch, CURLOPT_POSTFIELDS, "api_key=Apikeymu&code=$post_code&provider=XL");
  135. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  136. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  137. $chresult = curl_exec($ch);
  138. //echo $chresult;
  139. curl_close($ch);
  140. $json_result = json_decode($chresult, true);
  141. if($json_result['jumlah']==TRUE){
  142. $amount=$datana['amount'];
  143. $username=$datana['username'];
  144. $update = mysqli_query($db, "UPDATE history_topup set status = 'YES' WHERE kode = '$post_code'");
  145. $update = mysqli_query($db, "UPDATE users set balance = balance+$amount WHERE username = '$username'");
  146. $update_order = mysqli_query($db, "INSERT INTO balance_history (username, action, quantity, msg, date, time) VALUES ('username', 'Penambahan Saldo', '$amount', 'Deposit Otomatis anda Via Pulsa XL telah berhasil ditambahkan oleh Server Sebesar : $amount', '$date', '$time')");
  147. if($update == TRUE) {
  148. $msg_type = "success";
  149. $msg_content = "</span></button> Berhasil Saldo Telah Di Tambahkan!";
  150. } else {
  151. $msg_type = "error";
  152. $msg_content = "</span></button>GAGAL KONFIRMASI #1";
  153. }
  154. }else{
  155. $msg_type = "error";
  156. $msg_content = "</span></button>".$json_result['error'];
  157. }
  158. }
  159. }
  160. ?>
  161. <!-- Script Deposit CURL By Atlantic-Group(DhifoAksa) -->
  162. <div class="row">
  163. <div class="col-lg-6">
  164. <div class="ibox float-e-margins">
  165. <div class="ibox-title">
  166. <h5><i class="fa fa-credit-card"></i> Deposit Otomatis</h5>
  167. </div>
  168. <div class="ibox-content">
  169. <?php
  170. if ($msg_type == "success") {
  171. ?>
  172. <div class="alert alert-success" role="alert">
  173. <button type="button" class="close" data-dismiss="alert" aria-label="Close">
  174. <span aria-hidden="true">&times;</span>
  175. </button>
  176. <i class="fa fa-check-circle"></i>
  177. <?php echo $msg_content; ?>
  178. </div>
  179.  
  180. <?php
  181. } else if ($msg_type == "error") {
  182. ?>
  183. <div class="alert alert-danger" role="alert">
  184. <button type="button" class="close" data-dismiss="alert" aria-label="Close">
  185. <span aria-hidden="true">&times;</span>
  186. </button>
  187. <i class="fa fa-times-circle"></i>
  188. <?php echo $msg_content; ?>
  189. </div>
  190. <?php
  191. }
  192. ?>
  193. <form class="form-horizontal" role="form" method="POST">
  194. <div class="form-group">
  195. <label>Tipe</label>
  196. <select class="form-control" name="method" id="depomethod">
  197. <option value="0">Pilih salah satu...</option>
  198. <option value="XL">XL</option> <!-- ///MASUKIN NOMOR LO -->
  199. </select>
  200. </div>
  201.  
  202. <div class="form-group">
  203. <label>Nomer Pengirim</label>
  204.  
  205. <input type="number" name="nopengirim" class="form-control" placeholder="081xxx" >
  206.  
  207. </div>
  208. <div id="rates1"></div>
  209. <input type="hidden" id="rate" value="0">
  210. <div class="form-group">
  211. <label>Jumlah Deposit</label>
  212.  
  213. <input type="number" name="quantity" class="form-control" placeholder="Jumlah" onkeyup="get_total(this.value).value;">
  214.  
  215. </div>
  216. <input type="hidden" id="rate" value="0">
  217. <div class="form-group">
  218. <label>Total Saldo</label>
  219. <div class="input-group">
  220. <div class="input-group-prepend">
  221. <span class="input-group-text">Rp</span>
  222. </div>
  223. <input type="number" class="form-control" id="total" value="0" readonly>
  224. </div>
  225. </div>
  226.  
  227. <button type="submit" class="pull-right btn btn-success btn-bordered waves-effect w-md waves-light" name="submit">Buat Permintaan Deposit</button>
  228. </form>
  229. <div class="clearfix"></div>
  230. </div>
  231. </div>
  232. <!-- /.tab-pane -->
  233. </div>
  234.  
  235.  
  236. <div class="col-lg-6">
  237. <div class="ibox float-e-margins">
  238. <div class="ibox-title">
  239. <h5><i class="fa fa-info-circle"></i> INFORMASI</h5>
  240. <div class="ibox-tools">
  241. <a class="collapse-link">
  242. <i class="fa fa-chevron-up"></i>
  243. </a>
  244. <a class="close-link">
  245. <i class="fa fa-times"></i>
  246. </a>
  247. </div>
  248. </div>
  249. <div class="ibox-content">
  250. <ul>
  251. <li><dt>Tipe</dt></li>
  252. Pilih Tipe Jenis auto
  253.  
  254. <li><dt>Jenis Pembayaran</dt></li>
  255. Pilih Jenis Pembayaran deposit yang diinginkan
  256. <li><dt>Jumlah</dt></li>
  257. Masukan jumlah deposit yang akan diisi
  258. <li><dt>Klik 'Kirim'</dt></li>
  259. Setelah data diisi semua, klik 'Kirim'.untuk memproses pengiriman saldo tersebut, Silakan lihat tabel dibawah ini dan lakukan transfer pulsa/bank sesuai nominal yang ditentukan.
  260. <li><dt>Lihat daftar permintaan deposit anda</dt></li>
  261. Untuk melihat daftar permintaan deposit telah dikirim klik <a href="<?php echo $cfg_baseurl; ?>deposit/history/">Daftar Deposit</a>
  262.  
  263. </dl>
  264.  
  265. </div>
  266. </div>
  267. </div>
  268.  
  269. <div class="col-lg-12">
  270. <div class="ibox float-e-margins">
  271. <div class="ibox-title">
  272. <h5><i class="fa fa-credit-card"></i> Riwayat Deposit</h5>
  273. </div>
  274. <div class="ibox-content">
  275. <form method="get" action="/deposit/history/index.php">
  276. <div class="row">
  277. <div class="form-group col-lg-5">
  278. <label>Filter Status</label>
  279. <select class="form-control" name="status">
  280. <option value="">Semua</option>
  281. <option value="Pending">Pending</option>
  282. <option value="Success">Success</option>
  283. <option value="Error">Error</option>
  284. </select>
  285. </div>
  286. <div class="form-group col-lg-5">
  287. <label>Kata Kunci Cari</label>
  288. <input type="text" class="form-control" name="search" placeholder="Kata Kunci..." value="">
  289. </div>
  290. <div class="form-group col-lg-2">
  291. <label>Submit</label>
  292. <button type="submit" class="btn btn-block btn-dark">Filter</button>
  293. </div>
  294. </div>
  295. </form>
  296. <div class="table-responsive">
  297. <table class="table table-bordered table-hover">
  298. <thead>
  299. <tr>
  300. <th>Tanggal/Waktu</th>
  301. <th>Provider</th>
  302. <th>Nomer Pengirim</th>
  303. <th>Jumlah</th>
  304. <th>Saldo didapat</th>
  305. <th>Status</th>
  306. <th>Action</th>
  307. </tr>
  308. </thead>
  309. <tbody>
  310. <?php
  311. // start paging config
  312. $query_order = "SELECT * FROM history_topup WHERE username = '$sess_username' ORDER BY id DESC"; // edit
  313. $records_per_page = 30; // edit
  314.  
  315. $starting_position = 0;
  316. if(isset($_GET["page_no"])) {
  317. $starting_position = ($_GET["page_no"]-1) * $records_per_page;
  318. }
  319. $new_query = $query_order." LIMIT $starting_position, $records_per_page";
  320. $new_query = mysqli_query($db, $new_query);
  321. // end paging config
  322. while ($data_order = mysqli_fetch_assoc($new_query)) {
  323. if($data_order['status'] == "NO") {
  324. $statusnya="Waiting";
  325. $label = "warning";
  326. } else if($data_order['status'] == "CANCEL") {
  327. $statusnya="Canceled";
  328. $label = "danger";
  329. } else if($data_order['status'] == "YES") {
  330. $statusnya="Success";
  331. $label = "success";
  332. }
  333. $no_pengirimnya=$data_order['no_pengirim'];
  334. $no_pengrim_asli=str_replace('62','0',$no_pengirimnya);
  335. ?>
  336. <tr>
  337. <th><?php echo $data_order['datetime']; ?></th>
  338.  
  339. <td><?php echo $data_order['provider']; ?></td>
  340. <td><?php echo $no_pengrim_asli; ?></td>
  341. <td>Rp <?php echo number_format($data_order['jumlah_transfer'],0,',','.'); ?></td>
  342. <td>Rp <?php echo number_format($data_order['amount'],0,',','.'); ?></td>
  343. <td><label class="badge badge-<?php echo $label; ?>"><?php echo $statusnya; ?></label></td>
  344. <?php if($data_order['status'] == "NO") { ?>
  345. <td> <form action="" method="POST">
  346. <input type="hidden" name="kode" value="<?php echo $data_order['kode']; ?>">
  347. <button type="submit" class="btn btn-danger btn-xs"name="delet"><strong><span class="fa fa-remove"></span> Cancel</strong></button></form>
  348. <form action="" method="POST">
  349. <input type="hidden" name="kode" value="<?php echo $data_order['kode']; ?>">
  350. <button type="submit" class="btn btn-success btn-xs"name="confirm"><strong><span class="fa fa-check"></span> Confirm</strong></button></form>
  351. </td> <?php } else { ?>
  352. <td><span class="badge badge-success"><strong>Not Action</strong></span> </td>
  353. <?php } ?>
  354. </tr>
  355. <?php
  356. }
  357. ?>
  358. </tbody>
  359. </table>
  360.  
  361. <ul class="pagination">
  362. <?php
  363. // start paging link
  364. $self = $_SERVER['PHP_SELF'];
  365. $query_order = mysqli_query($db, $query_order);
  366. $total_no_of_records = mysqli_num_rows($query_order);
  367. echo "<li class='page-item disabled'><a class='page-link' href='#'>Total: ".$total_no_of_records."</a></li>";
  368. if($total_no_of_records > 0) {
  369. $total_no_of_pages = ceil($total_no_of_records/$records_per_page);
  370. $current_page = 1;
  371. if(isset($_GET["page_no"])) {
  372. $current_page = $_GET["page_no"];
  373. }
  374. if($current_page != 1) {
  375. $previous = $current_page-1;
  376. echo "<li class='page-item'><a class='page-link' href='".$self."?page_no=1'>← First</a></li>";
  377. echo "<li class='page-item'><a class='page-link' href='".$self."?page_no=".$previous."'>Previous</a></li>";
  378. }
  379. for($i=1; $i<=$total_no_of_pages; $i++) {
  380. if($i==$current_page) {
  381. echo "<li class='page-item active'><a class='page-link' href='".$self."?page_no=".$i."'>".$i." <span class='sr-only'>(current)</span></a></li>";
  382. } else {
  383. echo "<li class='page-item'><a class='page-link' href='".$self."?page_no=".$i."'>".$i."</a></li>";
  384. }
  385. }
  386. if($current_page!=$total_no_of_pages) {
  387. $next = $current_page+1;
  388. echo "<li class='page-item'><a class='page-link' href='".$self."?page_no=".$next."'>Next</a></li>";
  389. echo "<li class='page-item'><a class='page-link' href='".$self."?page_no=".$total_no_of_pages."'>Last →</a></li>";
  390. }
  391. }
  392. // end paging link
  393. ?>
  394. </ul>
  395. </div>
  396. </div>
  397. </div>
  398. </div>
  399. </div>
  400. <script type="text/javascript" src="https://code.jquery.com/jquery-1.10.2.js"></script>
  401. <script type="text/javascript">
  402. var htmlobjek;
  403. $(document).ready(function(){
  404. $("#depomethod").change(function(){
  405. var depomethod = $("#depomethod").val();
  406. $.ajax({
  407. url: '<?php echo $cfg_baseurl; ?>inc/deposit_method.php',
  408. data: 'depomethod='+depomethod,
  409. type: 'POST',
  410. dataType: 'html',
  411. success: function(msg){
  412. $("#rates1").html(msg);
  413. }
  414. });
  415. });
  416. });
  417. function get_total(quantity) {
  418. var rate = $("#rate").val();
  419. var result = eval(quantity)*0.88;
  420. $('#total').val(result);
  421. }
  422. </script>
  423. <!-- end row -->
  424. <?php
  425. include("../../lib/footer.php");
  426. } else {
  427. header("Location: ".$cfg_baseurl);
  428. }
  429. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement