Advertisement
Guest User

proses

a guest
Aug 27th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.37 KB | None | 0 0
  1. <?php
  2. error_reporting(0);
  3. session_start();
  4. if(!isset($_SESSION['username'])) {
  5. header('location:login.php'); }
  6. else { $username = $_SESSION['username']; }
  7. require_once("../connect.php");
  8.  
  9. $query = mysql_query("SELECT * FROM user WHERE username = '$username'");
  10. $jumlah = mysql_num_rows($query);
  11. $hasil = mysql_fetch_array($query);
  12. ?>
  13. <?php if($username) {
  14. if ($jumlah == 0) {
  15. } else if($hasil['role'] !== 'Admin' && $hasil['role'] !== 'Reseller' && $hasil['role'] !== 'Member') { ?>
  16. <div class="alert alert-dismissible alert-danger">ERROR : No Access.</div>
  17. <? } else { ?>
  18. <?php
  19. require_once("../connect.php");
  20. $cat = $_POST['cat'];
  21. $hasilnya = $_POST['hasilnya'];
  22. $link = $_POST['link'];
  23. $quantity = (int) $_POST['quantity'];
  24. $user = $_SESSION['username'];
  25. if (is_int($quantity) == false) {
  26. echo "<div class=\"alert alert-danger\">Jumlah Harus Angka.</div>";
  27. exit;
  28. }
  29.  
  30. $neko = mysql_query("SELECT * FROM services WHERE id = '$hasilnya'");
  31. $poi = mysql_fetch_array($neko);
  32. $minOrder = $poi['minOrder'];
  33. $rate = $poi['rate'];
  34. $name = $poi['name'];
  35. $juangkrik = $poi['peakerr'];
  36.  
  37. if ($hasilnya) {
  38. $harga = $rate*$quantity;
  39. $ket = $name;
  40. $oper = $juangkrik;
  41.  
  42. } else {
  43. $harga = 9999999;
  44. }
  45. if ($hasil['balance'] < $harga) { ?>
  46. <div class="alert alert-danger">
  47. ERROR: Saldo tidak mencukupi.
  48. </div>
  49. <? exit;?>
  50. <? } else if (!$cat || !$hasilnya || !$link || !$quantity) { ?>
  51. <div class="alert alert-danger">
  52. ERROR: Mohon isi data yang kosong.
  53. </div>
  54. <? exit; ?>
  55. <? } else if ($quantity < $minOrder) { ?>
  56. <div class="alert alert-danger">
  57. ERROR: Min. Order <?php echo $minOrder;?>
  58. </div>
  59. <? exit; ?>
  60. <? } else {
  61. date_default_timezone_set('Asia/Jakarta');
  62. $tanggal = date('d-m-Y H:i:s');
  63. if($hasilnya !== ''){
  64. if ($poi['provider'] == "PEAKERR") {
  65. class Api
  66. {
  67. public $api_url = 'http://peakerr.com/api/v2'; // API URL
  68.  
  69. public $api_key = ''; // Your API key
  70.  
  71. public function order($data) { // add order
  72. $post = array_merge(array('key' => $this->api_key, 'action' => 'add'), $data);
  73. return ($this->connect($post));
  74. }
  75.  
  76. public function status($order_id) { // get order status
  77. return json_decode($this->connect(array(
  78. 'key' => $this->api_key,
  79. 'action' => 'status',
  80. 'id' => $order_id
  81. )));
  82. }
  83.  
  84. public function services() { // get services
  85. return json_decode($this->connect(array(
  86. 'key' => $this->api_key,
  87. 'action' => 'services',
  88. )));
  89. }
  90.  
  91.  
  92. private function connect($post) {
  93. $_post = Array();
  94. if (is_array($post)) {
  95. foreach ($post as $name => $value) {
  96. $_post[] = $name.'='.urlencode($value);
  97. }
  98. }
  99. $ch = curl_init($this->api_url);
  100. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  101. curl_setopt($ch, CURLOPT_POST, 1);
  102. curl_setopt($ch, CURLOPT_HEADER, 0);
  103. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  104. if (is_array($post)) {
  105. curl_setopt($ch, CURLOPT_POSTFIELDS, join('&', $_post));
  106. }
  107. curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)');
  108. $result = curl_exec($ch);
  109. if (curl_errno($ch) != 0 && empty($result)) {
  110. $result = false;
  111. }
  112. curl_close($ch);
  113. return $result;
  114. }
  115. }
  116. } else if ($poi['provider'] == "BULK") {
  117. class Api
  118. {
  119. public $api_url = 'http://bulkandcheap.com/api/v2'; // API URL
  120.  
  121. public $api_key = ''; // Your API key
  122.  
  123. public function order($data) { // add order
  124. $post = array_merge(array('key' => $this->api_key, 'action' => 'add'), $data);
  125. return ($this->connect($post));
  126. }
  127.  
  128. public function status($order_id) { // get order status
  129. return json_decode($this->connect(array(
  130. 'key' => $this->api_key,
  131. 'action' => 'status',
  132. 'id' => $order_id
  133. )));
  134. }
  135.  
  136. public function services() { // get services
  137. return json_decode($this->connect(array(
  138. 'key' => $this->api_key,
  139. 'action' => 'services',
  140. )));
  141. }
  142.  
  143.  
  144. private function connect($post) {
  145. $_post = Array();
  146. if (is_array($post)) {
  147. foreach ($post as $name => $value) {
  148. $_post[] = $name.'='.urlencode($value);
  149. }
  150. }
  151. $ch = curl_init($this->api_url);
  152. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  153. curl_setopt($ch, CURLOPT_POST, 1);
  154. curl_setopt($ch, CURLOPT_HEADER, 0);
  155. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  156. if (is_array($post)) {
  157. curl_setopt($ch, CURLOPT_POSTFIELDS, join('&', $_post));
  158. }
  159. curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)');
  160. $result = curl_exec($ch);
  161. if (curl_errno($ch) != 0 && empty($result)) {
  162. $result = false;
  163. }
  164. curl_close($ch);
  165. return $result;
  166. }
  167. }
  168. }
  169. // Examples
  170.  
  171. $api = new Api();
  172.  
  173. $services = $api->services(); # return all services
  174.  
  175. // add order
  176.  
  177. $order = $api->order(array('service' => $oper, 'link' => $link, 'quantity' => $quantity)); # Default
  178. $pid = json_decode($order)->order;
  179. $prov = $poi['provider'];
  180. $simpan = mysql_query("UPDATE user SET balance=balance-$harga WHERE username = '$user'");
  181. $simpan = mysql_query("UPDATE user SET balance_used=balance_used+$harga WHERE username = '$user'");
  182. $simpan = mysql_query("INSERT INTO riwayat VALUES('','$pid','$link','$quantity','$harga','$ket','-','Pending','$user','$tanggal','$prov','no')");
  183. if($simpan) {
  184.  
  185. $conf_subject = 'New Order';
  186. $conf_sender = 'Admin <admin@mediapanel.co>';
  187. $msg = "\n\nHalo Admin ada orderan baru nih ".$quantity." ".$ket." \n\n Username:".$link."\n Date:".$tanggal." \n Mohon di Proses yak.. \n\n Terima Kasih \n #BOT";
  188. mail( 'alam.dwigunawan@gmail.com', $conf_subject, $msg, 'From: ' . $conf_sender );
  189.  
  190. ?>
  191. <div class="alert alert-success">
  192. Terimakasih sudah membeli <?php echo $quantity; ?> <?php echo $ket; ?><br />
  193. Target/Username: <?php echo $link; ?><br />
  194. Harga: <?php echo "Rp.".number_format((double)$harga,0,',','.').""; ?><br>
  195. Tanggal: <?php echo $tanggal; ?> <br />
  196. </div>
  197. <div class="alert alert-warning">
  198. Mohon tunggu 1x24 jam..
  199. </div>
  200. <? } else { ?>
  201. ERROR
  202. <? }
  203. }
  204. }
  205. }
  206. }
  207. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement