Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- date_default_timezone_set('Asia/Jakarta');
- if(!isset($_SESSION['email'])) {
- header('location:login-page.php'); }
- else { $email = $_SESSION['email']; }
- require_once("database.php");
- error_reporting(E_ALL & ~E_NOTICE);
- $query = mysql_query("SELECT * FROM user WHERE email = '$email'");
- $hasil = mysql_fetch_array($query);
- $username = $hasil['username'];
- ////// LOAD DATABASE FROM HERE /////////
- function order($panjang)
- {
- $karakter= '1234567890';
- $string = '';
- for ($i = 0; $i < $panjang; $i++) {
- $pos = rand(0, strlen($karakter)-1);
- $string .= $karakter{$pos};
- }
- return $string;
- }
- $id = order(4);
- $sn = order(8);
- $username2 = $_POST['username'];
- $jumlah = $_POST['quantity'];
- $service = $_POST['service'];
- if ($service == "1") {
- $harga = $jumlah * 20; // Harga 2000 per 100
- $barang = "Instagram Followers Server 1";
- } else if ($service == "45") {
- $harga = $jumlah * 17; // Harga 2200 per 100
- $barang = "Instagram Followers Server 10";
- } else if ($service == "47") {
- $harga = $jumlah * 17; // Harga 1200 per 100
- $barang = "Instagram Followers Server 11";
- } else if ($service == "6") {
- $harga = $jumlah * 20; // Harga 1200 per 100
- $barang = "Instagram Followers Server 4";
- } else if ($service == "17") {
- $harga = $jumlah * 90; // Harga 1200 per 100
- $barang = "Instagram Followers / Likes Indo Manual";
- } else if ($service == "46") {
- $harga = $jumlah * 10; // Harga 1200 per 100
- $barang = "Instagram Likes Server 1";
- } else if ($service == "26") {
- $harga = $jumlah * 10; // Harga 1200 per 100
- $barang = "Instagram Likes Server 2";
- } else if ($service == "28") {
- $harga = $jumlah * 18; // Harga 1200 per 100
- $barang = "Instagram Views Server 1";
- } else {
- $error = "layanan_salah"; // kalo ga ada
- }
- if ($hasil['saldo'] < $harga) {
- echo '<div class="alert alert-warning"><h4>Error!</h4>
- <b>Error</b> : Jumlah Saldo Kamu Kurang, Silahkan TopUp Dahulu.
- </div>';
- ?>
- <?} else {
- function file_get_con($Url){
- if (!function_exists('curl_init')){
- die('Sorry cURL is not installed!');
- }
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $Url);
- curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0");
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_TIMEOUT, 10);
- $output = curl_exec($ch);
- curl_close($ch);
- return $output;
- }
- $Url = "http://api.2cartel.com/post/orders/add/$api/?type=$service&link=$username2&quantity=$jumlah";
- // COntoh Code Sebelumnya (SEbelum diedit)
- $api = "163fff0c-269a-4302-a178-547c98f4dc28";
- $return = file_get_contents($api);
- // Contoh code setelah diubah
- $api = "163fff0c-269a-4302-a178-547c98f4dc28";
- $return = file_get_con($api);
- if($return->error == 1) {
- } else {
- $jam = date('H:i:s d-m-Y');
- $simpan = mysql_query("UPDATE user SET saldo=saldo-$harga WHERE email = '$email'");
- $simpan = mysql_query("INSERT INTO history VALUES('$id','$barang','$username','$jumlah','-','$jam','-')");
- if ($simpan) {
- ?>
- <div class="table-responsive">
- <table class="table">
- <thead>
- <tr>
- <th width="5%">No</th>
- <th width="30%">Order Description</th>
- <th width="50%" class="text-center">Username/Link</th>
- <th width="15%" class="text-center">Jumlah</th>
- <th width="15%" class="text-center">Harga</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td class="valign-top text-center">1</td>
- <td>
- <h5 class="semibold mt0 mb5"><?php echo $barang;?></h5>
- </td>
- <td class="valign-top text-center"><span class="bold"><?php echo $username2;?></span></td>
- <td class="valign-top text-center"><span class="bold"><?php echo $jumlah;?></span></td>
- <td class="valign-top text-center"><span class="text-primary bold"><?php echo "Rp.".number_format((double)$harga,0,',','.').""; ?></span></td>
- </tr>
- </tbody>
- </table>
- </div>
- <!--/ panel table -->
- <!-- panel footer -->
- <div class="panel-footer">
- <ul class="list-table pa10">
- <li>
- <h5 class="semibold nm">TOTAL PAYABLE</h5>
- </li>
- <li class="text-right">
- <h3 class="semibold nm text-success"><?php echo "Rp.".number_format((double)$harga,0,',','.').""; ?></h3>
- </li>
- </ul>
- <ul class="list-table pa10">
- <li>
- <h5 class="semibold nm">INVOICE ID</h5>
- </li>
- <li class="text-right">
- <h3 class="semibold nm text-success">#<?php echo $id; ?></h3>
- </li>
- </ul>
- </div>
- <?php } else { ?>
- Gagal
- <?php
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement