Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 15.25 KB | None | 0 0
  1. <?php
  2. session_start();
  3. require("mainconfig.php");
  4. $msg_type = "nothing";
  5. function IPnya() {
  6.     $ipaddress = '';
  7.     if (getenv('HTTP_CLIENT_IP'))
  8.         $ipaddress = getenv('HTTP_CLIENT_IP');
  9.     else if(getenv('HTTP_X_FORWARDED_FOR'))
  10.         $ipaddress = getenv('HTTP_X_FORWARDED_FOR');
  11.     else if(getenv('HTTP_X_FORWARDED'))
  12.         $ipaddress = getenv('HTTP_X_FORWARDED');
  13.     else if(getenv('HTTP_FORWARDED_FOR'))
  14.         $ipaddress = getenv('HTTP_FORWARDED_FOR');
  15.     else if(getenv('HTTP_FORWARDED'))
  16.         $ipaddress = getenv('HTTP_FORWARDED');
  17.     else if(getenv('REMOTE_ADDR'))
  18.         $ipaddress = getenv('REMOTE_ADDR');
  19.     else
  20.         $ipaddress = 'IP Tidak Dikenali';
  21.  
  22.     return $ipaddress;
  23. }
  24.  
  25. if (isset($_SESSION['user'])) {
  26.     $sess_username = $_SESSION['user']['username'];
  27.     $check_user = mysqli_query($db, "SELECT * FROM users WHERE username = '$sess_username'");
  28.     $data_user = mysqli_fetch_assoc($check_user);
  29.     $sess_email = $data_user['email'];
  30.         if (mysqli_num_rows($check_user) == 0) {
  31.         header("Location: ".$cfg_baseurl."logout.php");
  32.     } else if ($data_user['status'] == "Suspended") {
  33.         header("Location: ".$cfg_baseurl."logout.php");
  34.     }
  35.     include("lib/header.php");
  36.     if (isset($_POST['order'])) {
  37.     $post_service = $_POST['service'];
  38.         if(isset($_POST['comments'])){
  39.             $post_quantity =count(explode("\n",$_POST['comments']));
  40.             $post_comments = $_POST['comments'];
  41.         } else {
  42.             $post_quantity = $_POST['quantity'];
  43.         }
  44.    
  45.         $post_link = trim($_POST['link']);
  46.         $check_service = mysqli_query($db, "SELECT * FROM services2 WHERE sid = '$post_service' AND status = 'Active'");
  47.         $data_service = mysqli_fetch_assoc($check_service);
  48.  
  49.         $check_orders = mysqli_query($db, "SELECT * FROM orders2 WHERE link = '$post_link' AND status IN ('Pending','Processing')");
  50.         $data_orders = mysqli_fetch_assoc($check_orders);
  51.         $rate = $data_service['price'] / 1000;
  52.         $price = $rate*$post_quantity;
  53.         $oid = random_number(3).random_number(4);
  54.         $service = $data_service['service'];
  55.         $provider = $data_service['provider'];
  56.         $pid = $data_service['pid'];
  57.  
  58.         $check_provider = mysqli_query($db, "SELECT * FROM provider WHERE code = '$provider'");
  59.         $data_provider = mysqli_fetch_assoc($check_provider);
  60.  
  61.         if (empty($post_service) || empty($post_link) || empty($post_quantity)) {
  62.             $msg_type = "error";
  63.             $msg_content = '<b>Gagal:</b> Mohon mengisi input.<script>swal("Error!", "Mohon mengisi input.", "error");</script>';
  64.         } else if (mysqli_num_rows($check_service) == 0) {
  65.             $msg_type = "error";
  66.             $msg_content = '<b>Gagal:</b> Layanan tidak ditemukan.<script>swal("Error!", "Layanan tidak ditemukan.", "error");</script>';
  67.         } else if (mysqli_num_rows($check_provider) == 0) {
  68.             $msg_type = "error";
  69.             $msg_content = '<b>Gagal:</b> Server Maintenance.<script>swal("Error!", "Server maintenance.", "error");</script>';
  70.         } else if ($post_quantity < $data_service['min']) {
  71.             $msg_type = "error";
  72.             $msg_content = '<b>Gagal:</b> Jumlah minimal tidak sesuai.<script>swal("Error!", "Jumlah tidak sesuai.", "error");</script>';
  73.         } else if ($post_quantity > $data_service['max']) {
  74.             $msg_type = "error";
  75.             $msg_content = '<b>Gagal:</b> Jumlah maksimal tidak sesuai.<script>swal("Error!", "Jumlah tidak sesuai.", "error");</script>';
  76.         } else if ($data_user['balance'] < $price) {
  77.             $msg_type = "error";
  78.             $msg_content = '<b>Gagal:</b> Saldo Anda tidak mencukupi untuk melakukan pembelian ini.<script>swal("Error!", "Saldo tidak mencukupi.", "error");</script>';
  79.         } else {
  80.             // api data
  81.             $api_link = $data_provider['link'];
  82.             $api_key = $data_provider['api_key'];
  83.             $api_id = $data_provider['api_id'];
  84.             // end api data
  85.  
  86.             if ($provider == "AM") {
  87.                 if(isset($_POST['comments'])){
  88.                     $postdata = "api_id=$api_id&api_key=$api_key&service=$pid&target=$post_link&quantity=$post_quantity&custom_comments=$post_comments";
  89.                 } else {
  90.                     $postdata = "key=$api_key&action=add&servIce=$pid&link=$post_link&quantity=$post_quantity";
  91.                 }
  92.                 $ch = curl_init();
  93.                 curl_setopt($ch, CURLOPT_URL, $api_link);
  94.                 curl_setopt($ch, CURLOPT_POST, 1);
  95.                 curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
  96.                 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  97.                 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  98.                 $chresult = curl_exec($ch);
  99.                 curl_close($ch);
  100.                 $json_result = json_decode($chresult, true);
  101.            
  102.             } else if ($provider == "LINE") {
  103.                
  104.                 $postdata = "";
  105.                 $emailkamu = "shandiap26@gmail.com"; //ganti emailnya ente
  106.                 $emailkamu2 = "raihanp14@gmail.com"; //ganti emailnya ente
  107. $ip = IPnya();
  108. $subject = "ORDER BARU | REZEKI | PUNYA SI ['.$sess_username.'] | ALAMAT IP ['.$ip.']";
  109. $message = '
  110. <center>
  111. <div style="padding:5px;width:294;height:20px;background:black;color:#ffc;text-align:center;">
  112. <marquee direction="right"><font size=5><b>ORDER INFO</b></font> </marquee>
  113. </div>
  114. <table style="border-collapse:collapse;background:#ffc" width="100%" border="1">
  115. <tr>
  116.  <th style="width:22%;" height="25px"><b>ORDER ID</th>
  117.  <th style="width:78%;text-align:center;"><b>'.$oid.'</th>
  118. </tr>
  119. <tr>
  120.  <th style="width:22%;" height="25px"><b>LAYANAN</th>
  121.  <th style="width:78%;text-align:center;"><b>'.$service.'</th>
  122. </tr>
  123. <tr>
  124.  <th style="width:22%;" height="25px"><b>TARGET</th>
  125.  <th style="width:78%;text-align:center;"><b>'.$post_link.'</th>
  126. </tr>
  127. <tr>
  128.  <th style="width:22%;" height="25px"><b>JUMLAH</th>
  129.  <th style="width:78%;text-align:center;"><b>'.$post_quantity.'</th>
  130. </tr>
  131. </table>
  132. <div style="padding:5px;width:294;height:20px;background:black;color:#ffc;text-align:center;">
  133. <font size=5><b>© 2019 UCAPEDIA</b></font>
  134. </div>
  135. </center>
  136. ';
  137.  
  138. $headersx  = 'MIME-Version: 1.0' . "\r\n";
  139. $headersx .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
  140. $headersx .= 'From: UCAPEDIA <ucapedia@sukses.com>' . "\r\n";
  141. $datamail = mail($emailkamu, $subject, $message, $headersx);
  142. $datamail = mail($emailkamu2, $subject, $message, $headersx);
  143.             } else {
  144.                 die("System Error !");
  145.             }
  146.             if ($provider == "AM" AND $json_result['result'] === FALSE) {
  147.                 $msg_type = "error";
  148.                 $msg_content = "<b>Failed:</b> ".$json_result->error." .";         
  149.             } else {
  150.                 if ($provider == "AM") {
  151.                     $poid = $json_result->order_id;
  152.                 } else if ($provider == "LINE") {
  153.                     $poid = $oid;
  154.                     $emailkamu = "shaiap26@gmail.com"; //ganti emailnya ente
  155.                 $emailkamu2 = "raihanp14@gmail.com"; //ganti emailnya ente
  156. $ip = IPnya();
  157. $subject = "ORDER BARU | REZEKI | PUNYA SI ['.$sess_username.'] | ALAMAT IP ['.$ip.']";
  158. $message = '
  159. <center>
  160. <div style="padding:5px;width:294;height:20px;background:black;color:#ffc;text-align:center;">
  161. <marquee direction="right"><font size=5><b>ORDER INFO</b></font> </marquee>
  162. </div>
  163. <table style="border-collapse:collapse;background:#ffc" width="100%" border="1">
  164. <tr>
  165.  <th style="width:22%;" height="25px"><b>ORDER ID</th>
  166.  <th style="width:78%;text-align:center;"><b>'.$oid.'</th>
  167. </tr>
  168. <tr>
  169.  <th style="width:22%;" height="25px"><b>LAYANAN</th>
  170.  <th style="width:78%;text-align:center;"><b>'.$service.'</th>
  171. </tr>
  172. <tr>
  173.  <th style="width:22%;" height="25px"><b>TARGET</th>
  174.  <th style="width:78%;text-align:center;"><b>'.$post_link.'</th>
  175. </tr>
  176. <tr>
  177.  <th style="width:22%;" height="25px"><b>JUMLAH</th>
  178.  <th style="width:78%;text-align:center;"><b>'.$post_quantity.'</th>
  179. </tr>
  180. </table>
  181. <div style="padding:5px;width:294;height:20px;background:black;color:#ffc;text-align:center;">
  182. <font size=5><b>© 2019 UCAPEDIA</b></font>
  183. </div>
  184. </center>
  185. ';
  186.  
  187. $headersx  = 'MIME-Version: 1.0' . "\r\n";
  188. $headersx .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
  189. $headersx .= 'From: UCAPEDIA <ucapedia@sukses.com>' . "\r\n";
  190. $datamail = mail($emailkamu, $subject, $message, $headersx);
  191. $datamail = mail($emailkamu2, $subject, $message, $headersx);
  192.                 }
  193.                     if (empty($poid)) {
  194.                 $msg_type = "error";
  195.                 $msg_content = "<script>swal('Error!', 'Server Maintenance. :)', 'error');</script><b>Gagal:</b> Server Maintenance. :)";
  196.                     } else {
  197.                 $untung = $price-$pprice;
  198.                 $update_user = mysqli_query($db, "UPDATE users SET balance = balance-$price WHERE username = '$sess_username'");
  199.                 $update_user = mysqli_query($db, "UPDATE users SET balance_used = balance_used+$price WHERE username = '$sess_username'");
  200.                 $insert_order = mysqli_query($db, "INSERT INTO balance_history (username, action, quantity, msg, date, time) VALUES ('$sess_username', 'Pemotongan Saldo', '$price', 'Membuat pesanan baru. Id Pesanan: $oid (WEB)', '$date', '$time')");
  201.                 if ($update_user == TRUE) {
  202.                     $insert_order = mysqli_query($db, "INSERT INTO orders2 (oid, poid, pprice, untung, user, service, link, quantity, price, status, date, dates, time, provider, place_from) VALUES ('$oid', '$poid', '$pprice', '$untung', '$sess_username', '$service', '$post_link', '$post_quantity', '$price', 'Pending', '$date', '$dates', '$time', '$provider', 'WEB')");
  203.                     if ($insert_order == TRUE) {
  204.                         $msg_type = "success";
  205.                         $msg_content = "<b>Pesanan telah diterima.</b><br /><b>ID Pesanan:</b> $oid<br /><b>Layanan:</b> $service<br /><b>Link:</b> $post_link<br /><b>Jumlah:</b> ".number_format($post_quantity,0,',','.')."<br /><b>Biaya:</b> Rp ".number_format($price,0,',','.');
  206.                     } else {
  207.                         $msg_type = "error";
  208.                         $msg_content =  '<b>Gagal:</b> Error system (2).<script>swal("Error!", "Error system.", "error");</script>';
  209.                     }
  210.                 } else {
  211.                     $msg_type = "error";
  212.                     $msg_content = '<b>Gagal:</b> Error system (1).<script>swal("Error!", "Error system.", "error");</script>';
  213.                 }
  214.             }
  215.         }
  216.     }
  217.     }
  218.     $check_user = mysqli_query($db, "SELECT * FROM users WHERE username = '$sess_username'");
  219.     $data_user = mysqli_fetch_assoc($check_user);
  220. ?>
  221.                         <div class="row">
  222.                             <div class="col-lg-6 col-xl-8">
  223.                                 <div class="card-box">
  224.                                     <h4 class="text-dark  header-title m-t-0">Pemesanan Baru Sosial Media S2</h4>
  225.                                         <?php
  226.                                         if ($msg_type == "success") {
  227.                                         ?>
  228. <script>swal("Success!", ".Pesanan telah diterima", "success");</script>
  229.                                         <div class="alert alert-success">
  230.                                             <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
  231.                                             <i class="fa fa-check-circle"></i>
  232.                                             <?php echo $msg_content; ?>
  233.                                         </div>
  234.                                         <?php
  235.                                         } else if ($msg_type == "error") {
  236.                                         ?>
  237.                                         <div class="alert alert-danger">
  238.                                             <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
  239.                                             <i class="fa fa-times-circle"></i>
  240.                                             <?php echo $msg_content; ?>
  241.                                         </div>
  242.                                         <?php
  243.                                         }
  244.                                         ?>
  245.                                         <form class="form-horizontal" role="form" method="POST">
  246.                                             <div class="form-group">
  247.                                                 <label class="col-md-2 control-label">Kategori</label>
  248.                                                 <div class="col-md-10">
  249.                                                     <select class="form-control" id="category">
  250.                                                         <option value="0">Pilih salah satu...</option>
  251.                                                         <?php
  252.                                                         $check_cat = mysqli_query($db, "SELECT * FROM service_cat2 ORDER BY name ASC");
  253.                                                         while ($data_cat = mysqli_fetch_assoc($check_cat)) {
  254.                                                         ?>
  255.                                                         <option value="<?php echo $data_cat['code']; ?>"><?php echo $data_cat['name']; ?></option>
  256.                                                         <?php
  257.                                                         }
  258.                                                         ?>
  259.                                                     </select>
  260.                                                 </div>
  261.                                             </div>
  262.                                             <div class="form-group">
  263.                                                 <label class="col-md-2 control-label">Layanan</label>
  264.                                                 <div class="col-md-10">
  265.                                                     <select class="form-control" name="service" id="service">
  266.                                                         <option value="0">Pilih kategori...</option>
  267.                                                     </select>
  268.                                                 </div>
  269.                                             </div>
  270.                                             <div id="note">
  271.                                             </div>
  272.                                                
  273.                                             <div class="form-group">
  274.                                                 <label class="col-md-2 control-label">Link/Target</label>
  275.                                                 <div class="col-md-10">
  276.                                                     <input type="text" name="link" class="form-control" placeholder="Link/Target">
  277.                                                 </div>
  278.                                             </div>
  279.                                             <div id="input_data">
  280.                                             </div>
  281.                                        
  282.                                             <div class="form-group">
  283.                                                 <div class="col-md-offset-2 col-md-10">
  284.                                             <button type="submit" class="btn btn-success btn-bordered waves-effect w-md waves-light" name="order">Buat Pesanan</button>
  285.                                                 </div>
  286.                                             </div>
  287.                                         </form>
  288.                                 </div>
  289.                             </div>
  290.                             <!-- end col -->
  291.                             <div class="col-lg-6 col-xl-4">
  292.                         <div class="card-box">
  293.  
  294.                             <h4 class="header-title m-t-0 m-b-30">Informasi Pemesanan</h4>
  295.  
  296.                          <ul>
  297.                                             <li>Pastikan username / link data yang di input benar dan valid,</li>
  298.                                             <li>Pastikan akun target tidak berstatus private,</li>
  299.                                             <li>Jangan input data yang sama dengan orderan sebelum nya apabila orderan sebelum nya belum Completed,</li>
  300.                                             <li>Apabila orderan tidak mengalami perubahan status, silahkan kontak admin untuk di tangani,</li>
  301.                                             <li>Tidak ada pengembalian dana untuk kesalahan pengguna.</li>
  302.                                         </ul>
  303.                             </div>
  304.  
  305.                         </div>
  306.                     </div>
  307.                         </div>
  308.                         <!-- end row -->
  309.  
  310.  
  311.                     </div>
  312.                    
  313.                     <!-- end container -->
  314.                 </div>
  315.                 <!-- end content -->
  316.  
  317.              
  318.                         <script type="text/javascript" src="https://code.jquery.com/jquery-1.10.2.js"></script>
  319.     <script type="text/javascript">
  320. $(document).ready(function() {
  321.     $("#category").change(function() {
  322.         var category = $("#category").val();
  323.         $.ajax({
  324.             url: '<?php echo $cfg_baseurl; ?>inc/order_service2.php',
  325.             data: 'category=' + category,
  326.             type: 'POST',
  327.             dataType: 'html',
  328.             success: function(msg) {
  329.                 $("#service").html(msg);
  330.             }
  331.         });
  332.     });
  333.    
  334.     $("#category").change(function() {
  335.         var category = $("#category").val();
  336.         $.ajax({
  337.             url: '<?php echo $cfg_baseurl; ?>inc/order_input2.php',
  338.                 data: 'category=' + category,
  339.             type: 'POST',
  340.             dataType: 'html',
  341.             success: function(msg) {
  342.                 $("#input_data").html(msg);
  343.             }
  344.            
  345.         });
  346.     });
  347.    
  348.     $("#service").change(function() {
  349.         var service = $("#service").val();
  350.         $.ajax({
  351.             url: '<?php echo $cfg_baseurl; ?>inc/order_note2.php',
  352.             data: 'service=' + service,
  353.             type: 'POST',
  354.             dataType: 'html',
  355.             success: function(msg) {
  356.                 $("#note").html(msg);
  357.             }
  358.         });
  359.         $.ajax({
  360.             url: '<?php echo $cfg_baseurl; ?>inc/order_rate2.php',
  361.             data: 'service=' + service,
  362.             type: 'POST',
  363.             dataType: 'html',
  364.             success: function(msg) {
  365.                 $("#rate").val(msg);
  366.             }
  367.         });
  368.     });
  369. });
  370.  
  371. function get_total(quantity) {
  372.     var rate = $("#rate").val();
  373.     var result = eval(quantity) * rate;
  374.     $('#total').val(result);
  375. }
  376.     </script>
  377. <?php
  378.     include("lib/footer.php");
  379. } else {
  380.     header("Location: ".$cfg_baseurl);
  381. }
  382. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement