Advertisement
Guest User

Untitled

a guest
May 4th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.02 KB | None | 0 0
  1. <?php
  2. session_start();
  3. date_default_timezone_set('Asia/Jakarta');
  4. if(!isset($_SESSION['email'])) {
  5. header('location:login-page.php'); }
  6. else { $email = $_SESSION['email']; }
  7. require_once("database.php");
  8. error_reporting(E_ALL & ~E_NOTICE);
  9. $query = mysql_query("SELECT * FROM user WHERE email = '$email'");
  10. $hasil = mysql_fetch_array($query);
  11. $username = $hasil['username'];
  12.  
  13. ////// LOAD DATABASE FROM HERE /////////
  14.  
  15. function order($panjang)
  16. {
  17.     $karakter= '1234567890';
  18.     $string = '';
  19.     for ($i = 0; $i < $panjang; $i++) {
  20.         $pos = rand(0, strlen($karakter)-1);
  21.         $string .= $karakter{$pos};
  22.     }
  23.     return $string;
  24. }
  25.   $id = order(4);
  26.   $sn = order(8);
  27.  
  28.  
  29. $username2 = $_POST['username'];
  30. $jumlah = $_POST['quantity'];
  31. $service = $_POST['service'];
  32.  
  33. if ($service == "1") {
  34.   $harga = $jumlah * 20; // Harga 2000 per 100
  35.   $barang = "Instagram Followers Server 1";
  36.  } else if ($service == "45") {
  37.   $harga = $jumlah * 17; // Harga 2200 per 100
  38.   $barang = "Instagram Followers Server 10";
  39.  } else if ($service == "47") {
  40.   $harga = $jumlah * 17; // Harga 1200 per 100
  41.   $barang = "Instagram Followers Server 11";
  42.  } else if ($service == "6") {
  43.   $harga = $jumlah * 20; // Harga 1200 per 100
  44.   $barang = "Instagram Followers Server 4";
  45.  } else if ($service == "17") {
  46.   $harga = $jumlah * 90; // Harga 1200 per 100
  47.   $barang = "Instagram Followers / Likes Indo Manual";
  48.  } else if ($service == "46") {
  49.   $harga = $jumlah * 10; // Harga 1200 per 100
  50.   $barang = "Instagram Likes Server 1";
  51.  } else if ($service == "26") {
  52.   $harga = $jumlah * 10; // Harga 1200 per 100
  53.   $barang = "Instagram Likes Server 2";
  54.  } else if ($service == "28") {
  55.   $harga = $jumlah * 18; // Harga 1200 per 100
  56.   $barang = "Instagram Views Server 1";
  57.  } else {
  58.   $error = "layanan_salah"; // kalo ga ada
  59.  }
  60. if ($hasil['saldo'] < $harga) {
  61. echo '<div class="alert alert-warning"><h4>Error!</h4>
  62. <b>Error</b> : Jumlah Saldo Kamu Kurang, Silahkan TopUp Dahulu.
  63. </div>';
  64. ?>
  65. <?} else {
  66. function file_get_con($Url){
  67.     if (!function_exists('curl_init')){
  68.         die('Sorry cURL is not installed!');
  69.     }
  70.  
  71.     $ch = curl_init();
  72.     curl_setopt($ch, CURLOPT_URL, $Url);
  73.     curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0");
  74.     curl_setopt($ch, CURLOPT_HEADER, 0);
  75.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  76.     curl_setopt($ch, CURLOPT_TIMEOUT, 10);
  77.     $output = curl_exec($ch);
  78.  
  79.     curl_close($ch);
  80.     return $output;
  81. }
  82. $Url = "http://api.2cartel.com/post/orders/add/$api/?type=$service&link=$username2&quantity=$jumlah";
  83. $api = "163fff0c-269a-4302-a178-547c98f4dc28";
  84. $return = file_get_con($api);
  85.  
  86. if($order == NULL){
  87. echo "Server Error";
  88. exit;
  89. }
  90. if($return->error == 1) {
  91. } else {
  92. $jam = date('H:i:s d-m-Y');
  93. $simpan = mysql_query("UPDATE user SET saldo=saldo-$harga WHERE email = '$email'");
  94. $simpan = mysql_query("INSERT INTO history VALUES('$id','$barang','$username','$jumlah','-','$jam','-')");
  95. if ($simpan) {
  96. ?>
  97.                                 <div class="table-responsive">
  98.                                     <table class="table">
  99.                                         <thead>
  100.                                             <tr>
  101.                                                 <th width="5%">No</th>
  102.                                                 <th width="30%">Order Description</th>
  103.                                                 <th width="50%" class="text-center">Username/Link</th>
  104.                                                 <th width="15%" class="text-center">Jumlah</th>
  105.                                                 <th width="15%" class="text-center">Harga</th>
  106.                                             </tr>
  107.                                         </thead>
  108.                                         <tbody>
  109.                                             <tr>
  110.                                                 <td class="valign-top text-center">1</td>
  111.                                                 <td>
  112.                                                     <h5 class="semibold mt0 mb5"><?php echo $barang;?></h5>
  113.                                                 </td>
  114.                                                 <td class="valign-top text-center"><span class="bold"><?php echo $username2;?></span></td>
  115.                                                 <td class="valign-top text-center"><span class="bold"><?php echo $jumlah;?></span></td>
  116.                                                 <td class="valign-top text-center"><span class="text-primary bold"><?php echo "Rp.".number_format((double)$harga,0,',','.').""; ?></span></td>
  117.                                             </tr>
  118.                                         </tbody>
  119.                                     </table>
  120.                                 </div>
  121.                                 <!--/ panel table -->
  122.                                 <!-- panel footer -->
  123.                                 <div class="panel-footer">
  124.                                     <ul class="list-table pa10">
  125.                                         <li>
  126.                                             <h5 class="semibold nm">TOTAL PAYABLE</h5>
  127.                                         </li>
  128.                                         <li class="text-right">
  129.                                             <h3 class="semibold nm text-success"><?php echo "Rp.".number_format((double)$harga,0,',','.').""; ?></h3>
  130.                                         </li>
  131.                                     </ul>
  132.                                     <ul class="list-table pa10">
  133.                                         <li>
  134.                                             <h5 class="semibold nm">INVOICE ID</h5>
  135.                                         </li>
  136.                                         <li class="text-right">
  137.                                             <h3 class="semibold nm text-success">#<?php echo $id; ?></h3>
  138.                                         </li>
  139.                                     </ul>
  140.                                 </div>
  141. <?php } else { ?>
  142. Gagal
  143. <?php
  144. }
  145. }
  146. }
  147. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement