Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require("mainconfig.php");
- header("Content-Type: application/json");
- if (isset($_POST['key']) AND isset($_POST['action'])) {
- $post_key = mysqli_real_escape_string($db, trim($_POST['key']));
- $post_action = $_POST['action'];
- if (empty($post_key) || empty($post_action)) {
- $array = array("error" => "Incorrect request");
- } else {
- $check_user = mysqli_query($db, "SELECT * FROM users WHERE api_key = '$post_key'");
- $data_user = mysqli_fetch_assoc($check_user);
- if (mysqli_num_rows($check_user) == 1) {
- $username = $data_user['username'];
- if ($post_action == "add") {
- if (isset($_POST['service']) AND isset($_POST['link']) AND isset($_POST['quantity'])) {
- $post_service = $_POST['service'];
- $post_link = $_POST['link'];
- $post_quantity = $_POST['quantity'];
- if (empty($post_service) || empty($post_link) || empty($post_quantity)) {
- $array = array("error" => "Incorrect request");
- } else {
- $check_service = mysqli_query($db, "SELECT * FROM services WHERE sid = '$post_service' AND status = 'Active'");
- $data_service = mysqli_fetch_assoc($check_service);
- if (mysqli_num_rows($check_service) == 0) {
- $array = array("error" => "Service not found");
- } else {
- $oid = rand(0000000,9999999);
- $rate = $data_service['price'] / 1000;
- $price = $rate*$post_quantity;
- $service = $data_service['service'];
- $provider = $data_service['provider'];
- $pid = $data_service['pid'];
- $wujudjnd=number_format($post_quantity,0,',','.');
- if ($post_quantity < $data_service['min']) {
- $array = array("error" => "Quantity inccorect");
- } else if ($post_quantity > $data_service['max']) {
- $array = array("error" => "Quantity inccorect");
- } else if ($data_user['balance'] < $price) {
- $array = array("error" => "Low balance");
- } else {
- $check_provider = mysqli_query($db, "SELECT * FROM provider WHERE code = '$provider'");
- $data_provider = mysqli_fetch_assoc($check_provider);
- $provider_key = $data_provider['api_key'];
- $provider_link = $data_provider['link'];
- if ($provider == "MANUAL") {
- $provider_key="your key";
- $provider_link="";
- $api_postdata = "";
- $to ="mhmdsyalsa@gmail.com";
- $subject = "Orderan Manual";
- $messages ="Hallo kak Andre nih data Orderanya
- Pemesan :$sess_username
- Service : $service
- Quantity: $wujudjnd
- Harga : $price
- Link : $post_link";
- $headers .= 'From: support@andremedia.co' . ""; //bagian ini diganti sesuai dengan email dari pengirim
- $send_mail=@mail($to, $subject, $messages, $headers);
- $to ="noveranitaamelia@gmail.com";
- $subject = "Orderan Manual nih gblg";
- $messages ="Hallo kak Andre nih data Orderanya
- Pemesan :$sess_username
- Service : $service
- Quantity: $wujudjnd
- Harga : $price
- Link : $post_link";
- $headers .= 'From: support@andremedia.co' . ""; //bagian ini diganti sesuai dengan email dari pengirim
- $send_mail=@mail($to, $subject, $messages, $headers);
- } else if ($provider == "") {
- $provider_key="";
- $provider_link="";
- $provider_postdata="key=$provider_key&action=add_order&service=$pid&link=$post_link&quantity=$post_quantity";
- } else if ($provider == "") {
- $provider_key="";
- $provider_link="http:///api.php";
- $provider_postdata="key=$provider_key&action=add&service=$pid&link=$post_link&quantity=$post_quantity";
- } else {
- die("System Error!");
- }
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, "$provider_link");
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $provider_postdata);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- $chresult = curl_exec($ch);
- curl_close($ch);
- $json_result = json_decode($chresult, true);
- if ($provider == "TL" AND $json_result['error'] == TRUE) {
- $msg_type = "error";
- $msg_content = "<b>Gagal:</b> Server Maintenance (1).";
- } else if ($provider == "ST" AND $json_result['error'] == TRUE) {
- $msg_type = "error";
- $msg_content = "<b>Gagal:</b> Server Maintenance (2).";
- } else {
- if ($provider == "TL") {
- $poid = $json_result['order_id'];
- } else if ($provider == "ST") {
- $poid = $json_result['order_id'];
- } else if ($provider == "MANUAL") {
- $poid= $oid;
- }
- $update_user = mysqli_query($db, "UPDATE users SET balance = balance-$price WHERE username = '$username'");
- if ($update_user == TRUE) {
- $insert_order = mysqli_query($db, "INSERT INTO orders (oid, poid, user, service, link, quantity, price, status, date, provider, place_from) VALUES ('$oid', '$poid', '$username', '$service', '$post_link', '$post_quantity', '$price', 'Pending', '$date', '$provider', 'API')");
- if ($insert_order == TRUE) {
- $array = array("order_id" => "'.$oid.'");
- } else {
- $array = array("error" => "System error");
- }
- } else {
- $array = array("error" => "System error");
- }
- }
- }
- }
- }
- } else {
- $array = array("error" => "Incorrect request");
- }
- } else if ($post_action == "add_premium") {
- if (isset($_POST['service']) AND isset($_POST['link']) AND isset($_POST['quantity'])) {
- $post_service = $_POST['service'];
- $post_link = $_POST['link'];
- $post_quantity = $_POST['quantity'];
- $leve_user = $data_user['level'];
- if($leve_user == 'Premium'){
- if (empty($post_service) || empty($post_link) || empty($post_quantity)) {
- $array = array("error" => "Incorrect request");
- } else {
- $check_service = mysqli_query($db, "SELECT * FROM services1 WHERE sid = '$post_service' AND status = 'Active'");
- $data_service = mysqli_fetch_assoc($check_service);
- if (mysqli_num_rows($check_service) == 0) {
- $array = array("error" => "Service not found");
- } else {
- $oid1 = rand(0000000,9999999);
- $rate = $data_service['price'] / 1000;
- $price = $rate*$post_quantity;
- $service = $data_service['service'];
- $provider = $data_service['provider'];
- $pid = $data_service['pid'];
- $wujudjnd=number_format($post_quantity,0,',','.');
- if ($post_quantity < $data_service['min']) {
- $array = array("error" => "Quantity inccorect");
- } else if ($post_quantity > $data_service['max']) {
- $array = array("error" => "Quantity inccorect");
- } else if ($data_user['balance'] < $price) {
- $array = array("error" => "Low balance");
- } else {
- $check_provider = mysqli_query($db, "SELECT * FROM provider WHERE code = '$provider'");
- $data_provider = mysqli_fetch_assoc($check_provider);
- $provider_key = $data_provider['api_key'];
- $provider_link = $data_provider['link'];
- if ($provider == "MANUAL") {
- $provider_key="your key";
- $provider_link="";
- $api_postdata = "";
- $to ="mhmdsyalsa@gmail.com";
- $subject = "Orderan Manual";
- $messages ="Hallo kak Andre nih data Orderanya
- Pemesan :$sess_username
- Service : $service
- Quantity: $wujudjnd
- Harga : $price
- Link : $post_link";
- $headers .= 'From: support@andremedia.co' . ""; //bagian ini diganti sesuai dengan email dari pengirim
- $send_mail=@mail($to, $subject, $messages, $headers);
- $to ="noveranitaamelia@gmail.com";
- $subject = "Orderan Manual nih gblg";
- $messages ="Hallo kak Andre nih data Orderanya
- Pemesan :$sess_username
- Service : $service
- Quantity: $wujudjnd
- Harga : $price
- Link : $post_link";
- $headers .= 'From: support@andremedia.co' . ""; //bagian ini diganti sesuai dengan email dari pengirim
- $send_mail=@mail($to, $subject, $messages, $headers);
- } else if ($provider == "") {
- $provider_key="";
- $provider_link="";
- $provider_postdata="key=$provider_key&action=add_order&service=$pid&link=$post_link&quantity=$post_quantity";
- } else if ($provider == "") {
- $provider_key="";
- $provider_link="";
- $provider_postdata="key=$provider_key&action=add&service=$pid&link=$post_link&quantity=$post_quantity";
- }else{
- die("System Error!");
- }
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, "$provider_link");
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $provider_postdata);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- $chresult = curl_exec($ch);
- curl_close($ch);
- $json_result = json_decode($chresult, true);
- if ($provider == "TL" AND $json_result['error'] == TRUE) {
- $msg_type = "error";
- $msg_content = "<b>Gagal:</b> Server Maintenance (1).";
- } else if ($provider == "ST" AND $json_result['error'] == TRUE) {
- $msg_type = "error";
- $msg_content = "<b>Gagal:</b> Server Maintenance (2).";
- } else {
- if ($provider == "TL") {
- $poid = $json_result['order_id'];
- } else if ($provider == "ST") {
- $poid = $json_result['order_id'];
- }else if ($provider == "MANUAL") {
- $poid= $oid1;
- }
- $update_user = mysqli_query($db, "UPDATE users SET balance = balance-$price WHERE username = '$username'");
- if ($update_user == TRUE) {
- $insert_order = mysqli_query($db, "INSERT INTO orders (oid, poid, user, service, link, quantity, price, status, date, provider, place_from) VALUES ('$oid1', '$poid', '$username', '$service', '$post_link', '$post_quantity', '$price', 'Pending', '$date', '$provider', 'API')");
- if ($insert_order == TRUE) {
- $array = array("order_id" => "'.$oid1.'");
- } else {
- $array = array("error" => "System error");
- }
- } else {
- $array = array("error" => "System error");
- }
- }
- }
- }
- }
- } else {
- $array = array("error" => "Your Not Premium User");
- }
- } else {
- $array = array("error" => "Incorrect request");
- }
- } else if ($post_action == "status") {
- if (isset($_POST['order_id'])) {
- $post_oid = $_POST['order_id'];
- $post_oid = $_POST['order_id'];
- $check_order = mysqli_query($db, "SELECT * FROM orders WHERE oid = '$post_oid' AND user = '$username'");
- $data_order = mysqli_fetch_array($check_order);
- if (mysqli_num_rows($check_order) == 0) {
- $array = array("error" => "Order not found");
- } else {
- $array = array("charge" => $data_order['price'], "start_count" => $data_order['start_count'], "status" => $data_order['status'], "remains" => $data_order['remains']);
- }
- } else {
- $array = array("error" => "Incorrect request");
- }
- } else if($post_action == "services") {
- $check_service = mysqli_query($db, "SELECT * FROM services");
- while ($data_service = mysqli_fetch_assoc($check_service)) {
- $array[] = array(
- "provider_id" => $data_service['sid'],
- "category" => $data_service['category'],
- "service" => $data_service['service'],
- "min_order" => $data_service['min'],
- "max_order" => $data_service['max'],
- "note" => $data_service['note'],
- "price" => $data_service['price']
- );
- }
- } else{
- $array = array("error" => "Wrong action");
- }
- } else {
- $array = array("error" => "Invalid API key");
- }
- }
- } else {
- $array = array("error" => "Incorrect request");
- }
- $print = json_encode($array);
- print_r($print);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement