Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(0);
- session_start();
- if(!isset($_SESSION['username'])) {
- header('location:login.php'); }
- else { $username = $_SESSION['username']; }
- require_once("../connect.php");
- $query = mysql_query("SELECT * FROM user WHERE username = '$username'");
- $jumlah = mysql_num_rows($query);
- $hasil = mysql_fetch_array($query);
- ?>
- <?php if($username) {
- if ($jumlah == 0) {
- } else if($hasil['role'] !== 'Admin' && $hasil['role'] !== 'Reseller' && $hasil['role'] !== 'Member') { ?>
- <div class="alert alert-dismissible alert-danger">ERROR : No Access.</div>
- <? } else { ?>
- <?php
- require_once("../connect.php");
- $cat = $_POST['cat'];
- $hasilnya = $_POST['hasilnya'];
- $link = $_POST['link'];
- $quantity = (int) $_POST['quantity'];
- $user = $_SESSION['username'];
- if (is_int($quantity) == false) {
- echo "<div class=\"alert alert-danger\">Jumlah Harus Angka.</div>";
- exit;
- }
- $neko = mysql_query("SELECT * FROM services WHERE id = '$hasilnya'");
- $poi = mysql_fetch_array($neko);
- $minOrder = $poi['minOrder'];
- $rate = $poi['rate'];
- $name = $poi['name'];
- $juangkrik = $poi['peakerr'];
- if ($hasilnya) {
- $harga = $rate*$quantity;
- $ket = $name;
- $oper = $juangkrik;
- } else {
- $harga = 9999999;
- }
- if ($hasil['balance'] < $harga) { ?>
- <div class="alert alert-danger">
- ERROR: Saldo tidak mencukupi.
- </div>
- <? exit;?>
- <? } else if (!$cat || !$hasilnya || !$link || !$quantity) { ?>
- <div class="alert alert-danger">
- ERROR: Mohon isi data yang kosong.
- </div>
- <? exit; ?>
- <? } else if ($quantity < $minOrder) { ?>
- <div class="alert alert-danger">
- ERROR: Min. Order <?php echo $minOrder;?>
- </div>
- <? exit; ?>
- <? } else {
- date_default_timezone_set('Asia/Jakarta');
- $tanggal = date('d-m-Y H:i:s');
- if($hasilnya !== ''){
- if ($poi['provider'] == "PEAKERR") {
- class Api
- {
- public $api_url = 'http://peakerr.com/api/v2'; // API URL
- public $api_key = ''; // Your API key
- public function order($data) { // add order
- $post = array_merge(array('key' => $this->api_key, 'action' => 'add'), $data);
- return ($this->connect($post));
- }
- public function status($order_id) { // get order status
- return json_decode($this->connect(array(
- 'key' => $this->api_key,
- 'action' => 'status',
- 'id' => $order_id
- )));
- }
- public function services() { // get services
- return json_decode($this->connect(array(
- 'key' => $this->api_key,
- 'action' => 'services',
- )));
- }
- private function connect($post) {
- $_post = Array();
- if (is_array($post)) {
- foreach ($post as $name => $value) {
- $_post[] = $name.'='.urlencode($value);
- }
- }
- $ch = curl_init($this->api_url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
- if (is_array($post)) {
- curl_setopt($ch, CURLOPT_POSTFIELDS, join('&', $_post));
- }
- curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)');
- $result = curl_exec($ch);
- if (curl_errno($ch) != 0 && empty($result)) {
- $result = false;
- }
- curl_close($ch);
- return $result;
- }
- }
- } else if ($poi['provider'] == "BULK") {
- class Api
- {
- public $api_url = 'http://bulkandcheap.com/api/v2'; // API URL
- public $api_key = ''; // Your API key
- public function order($data) { // add order
- $post = array_merge(array('key' => $this->api_key, 'action' => 'add'), $data);
- return ($this->connect($post));
- }
- public function status($order_id) { // get order status
- return json_decode($this->connect(array(
- 'key' => $this->api_key,
- 'action' => 'status',
- 'id' => $order_id
- )));
- }
- public function services() { // get services
- return json_decode($this->connect(array(
- 'key' => $this->api_key,
- 'action' => 'services',
- )));
- }
- private function connect($post) {
- $_post = Array();
- if (is_array($post)) {
- foreach ($post as $name => $value) {
- $_post[] = $name.'='.urlencode($value);
- }
- }
- $ch = curl_init($this->api_url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
- if (is_array($post)) {
- curl_setopt($ch, CURLOPT_POSTFIELDS, join('&', $_post));
- }
- curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)');
- $result = curl_exec($ch);
- if (curl_errno($ch) != 0 && empty($result)) {
- $result = false;
- }
- curl_close($ch);
- return $result;
- }
- }
- }
- // Examples
- $api = new Api();
- $services = $api->services(); # return all services
- // add order
- $order = $api->order(array('service' => $oper, 'link' => $link, 'quantity' => $quantity)); # Default
- $pid = json_decode($order)->order;
- $prov = $poi['provider'];
- $simpan = mysql_query("UPDATE user SET balance=balance-$harga WHERE username = '$user'");
- $simpan = mysql_query("UPDATE user SET balance_used=balance_used+$harga WHERE username = '$user'");
- $simpan = mysql_query("INSERT INTO riwayat VALUES('','$pid','$link','$quantity','$harga','$ket','-','Pending','$user','$tanggal','$prov','no')");
- if($simpan) {
- $conf_subject = 'New Order';
- $conf_sender = 'Admin <admin@mediapanel.co>';
- $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";
- mail( 'alam.dwigunawan@gmail.com', $conf_subject, $msg, 'From: ' . $conf_sender );
- ?>
- <div class="alert alert-success">
- Terimakasih sudah membeli <?php echo $quantity; ?> <?php echo $ket; ?><br />
- Target/Username: <?php echo $link; ?><br />
- Harga: <?php echo "Rp.".number_format((double)$harga,0,',','.').""; ?><br>
- Tanggal: <?php echo $tanggal; ?> <br />
- </div>
- <div class="alert alert-warning">
- Mohon tunggu 1x24 jam..
- </div>
- <? } else { ?>
- ERROR
- <? }
- }
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement