daily pastebin goal
25%
SHARE
TWEET

Untitled

a guest Mar 24th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. require_once("../mainconfig.php");
  3.  
  4. $delete = mysqli_query($db, "DELETE FROM service_pulsa");
  5. $delete = mysqli_query($db, "DELETE FROM service_pulsa_cat");
  6. if($delete) {
  7.     $cek_provider = mysqli_query($db, "SELECT * FROM provider WHERE coe 'RETROPULSA'");
  8.     $data_provider = mysqli_fetch_assoc($cek_provider);
  9.     $api_key = $data_provider['api_key'];
  10.     $url = $data_provider['link'];
  11.     $postdata = "api_key=$api_key&action=layanan";
  12.  
  13.     $ch = curl_init();
  14.     curl_setopt($ch, CURLOPT_URL, $url);
  15.     curl_setopt($ch, CURLOPT_POST, 1);
  16.     curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
  17.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  18.     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  19.     $chresult = curl_exec($ch);
  20.     curl_close($ch);
  21.     $json_result = json_decode($chresult, true);
  22. }
  23.  
  24. $no = "0";
  25. $retro = "1";
  26. $hitung = count($json_result['data']);
  27. while ($no < $hitung) {
  28.     $json_input = $json_result['data'][$no];
  29.     $cat = $json_input['category'];
  30.     $opt = $json_input['operator'];
  31.     $serv = $json_input['service'];
  32.     $cod = $json_input['code'];
  33.     $price = $json_input['price'];
  34.     $status = $json_input['status'];
  35.  
  36.  
  37.     $harga = $price + 200; //Tambah harga biar lo untung
  38.  
  39.     $cek_cat = mysqli_query($db, "SELECT * FROM service_pulsa_cat WHERE code = '$cod'");
  40.     if (mysqli_num_rows($cek_cat) > 0) {
  41.     } else {
  42.         $rtr = mysqli_query($db, "INSERT INTO service_pulsa_cat VALUES('$retro','$opt','$opt','$cat')");
  43.     }
  44.     $cek_serv = mysqli_query($db, "SELECT * FROM service_pulsa WHERE sid = '$cod'");
  45.     if (mysqli_num_rows($cek_serv) > 0) {
  46.         $result = "DATA SUDAH ADA DI DALAM DATABASE";
  47.     } else {
  48.         $rtr = mysqli_query($db, "INSERT INTO service_pulsa VALUES('sesuaikan sama struktur db kamu')");
  49.         $result = "
  50.         ==========================<br />
  51.         Succesfully Add Service
  52.         Category: $cat<br />
  53.         operator: $opt<br />
  54.         Service: $serv<br />
  55.         Harga: $harga<br />
  56.         Provider: RETRO PULSA<br />
  57.         ==========================<br />
  58.         ";
  59.     }
  60.     $no++;
  61.     $retro++;
  62.     echo $result;
  63. }
  64. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top