Advertisement
Guest User

Untitled

a guest
May 4th, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.13 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. // COntoh Code Sebelumnya (SEbelum diedit)
  84. $api = "163fff0c-269a-4302-a178-547c98f4dc28";
  85. $return = file_get_contents($api);
  86.  
  87. // Contoh code setelah diubah
  88. $api = "163fff0c-269a-4302-a178-547c98f4dc28";
  89. $return = file_get_con($api);
  90.  
  91. if($return->error == 1) {
  92. } else {
  93. $jam = date('H:i:s d-m-Y');
  94. $simpan = mysql_query("UPDATE user SET saldo=saldo-$harga WHERE email = '$email'");
  95. $simpan = mysql_query("INSERT INTO history VALUES('$id','$barang','$username','$jumlah','-','$jam','-')");
  96. if ($simpan) {
  97. ?>
  98. <div class="table-responsive">
  99. <table class="table">
  100. <thead>
  101. <tr>
  102. <th width="5%">No</th>
  103. <th width="30%">Order Description</th>
  104. <th width="50%" class="text-center">Username/Link</th>
  105. <th width="15%" class="text-center">Jumlah</th>
  106. <th width="15%" class="text-center">Harga</th>
  107. </tr>
  108. </thead>
  109. <tbody>
  110. <tr>
  111. <td class="valign-top text-center">1</td>
  112. <td>
  113. <h5 class="semibold mt0 mb5"><?php echo $barang;?></h5>
  114. </td>
  115. <td class="valign-top text-center"><span class="bold"><?php echo $username2;?></span></td>
  116. <td class="valign-top text-center"><span class="bold"><?php echo $jumlah;?></span></td>
  117. <td class="valign-top text-center"><span class="text-primary bold"><?php echo "Rp.".number_format((double)$harga,0,',','.').""; ?></span></td>
  118. </tr>
  119. </tbody>
  120. </table>
  121. </div>
  122. <!--/ panel table -->
  123. <!-- panel footer -->
  124. <div class="panel-footer">
  125. <ul class="list-table pa10">
  126. <li>
  127. <h5 class="semibold nm">TOTAL PAYABLE</h5>
  128. </li>
  129. <li class="text-right">
  130. <h3 class="semibold nm text-success"><?php echo "Rp.".number_format((double)$harga,0,',','.').""; ?></h3>
  131. </li>
  132. </ul>
  133. <ul class="list-table pa10">
  134. <li>
  135. <h5 class="semibold nm">INVOICE ID</h5>
  136. </li>
  137. <li class="text-right">
  138. <h3 class="semibold nm text-success">#<?php echo $id; ?></h3>
  139. </li>
  140. </ul>
  141. </div>
  142. <?php } else { ?>
  143. Gagal
  144. <?php
  145. }
  146. }
  147. }
  148. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement