Advertisement
Guest User

contoh frii echo

a guest
Nov 16th, 2016
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.     require_once 'config-api.php';
  3.     //Get Parameter Data
  4.     $checkindate = str_replace('/', '-', $_GET['cidate']);
  5.     $checkoutdate = str_replace('/', '-', $_GET['codate']);
  6.  
  7.     $checkin = date('Y-m-d', strtotime($checkindate));
  8.     $checkout = date('Y-m-d', strtotime($checkoutdate));
  9.  
  10.     $username = $_GET['room'];
  11.     $password = $_GET['pass'];
  12.  
  13.     $time = $_GET['cotime'];
  14.     $status = $_GET['gtype'];
  15.     $firstname = 'frii';
  16.     $lastname = $_GET['pass'];
  17.     $note = '';
  18.     $datetime = "";
  19.     $fullname = $firstname." ".$lastname;
  20.     $reservation_id = intval(preg_replace('/[^0-9]+/', '', $_GET['resid']), 10);
  21.  
  22.     //Declare Data Radius
  23.     $username_radius = $customer_sid."@".$username."@".$password;
  24.  
  25.     /*Customer Checkin Method*/
  26.     if ($_GET['mode'] == 'checkin' && $status == '0') {
  27.  
  28.         //Check Validation Data
  29.         $query_pms = $db_pms->query("SELECT * FROM pms WHERE username = '".$username."' AND password = '".$password."' AND checkin = '".$checkin."' AND checkout = '".$checkout."' AND groupname = '".$customer_profile."' AND reservation_id='".$reservation_id."'");
  30.         $result_pms = $query_pms->num_rows;
  31.  
  32.         //Validation True
  33.         if (empty($result_pms)) {
  34.  
  35.             //Save to table pms
  36.             $insert_pms = $db_pms->query("INSERT INTO pms (username,password,fullname,firstname,lastname,checkin,checkout,note,datetime,groupname,reservation_id) VALUES ('".$username."','".$password."','".$fullname."','".$firstname."','".$lastname."','".$checkin."','".$checkout."','".$note."','".$datetime."','".$customer_profile."','".$reservation_id."')");
  37.            
  38.             if ($insert_pms) {
  39.  
  40.                 //Check Validation Data
  41.                 $query_radius = $db_radius->query("SELECT * FROM radcheck WHERE username='".$username_radius."' AND username_only='".$username."' AND value='".$password."' AND customer='".$customer_sid."' AND reservation_id='".$reservation_id."'");
  42.                 $result_radius = $query_radius->num_rows;
  43.  
  44.                 if (empty($result_radius)) {
  45.  
  46.                     //Save to table radcheck
  47.                     $insert_radius = $db_radius->query("INSERT INTO radcheck (username,attribute,op,value,username_only,firstname,lastname,type,customer,reservation_id) VALUES ('".$username_radius."','Cleartext-Password',':=','".$password."','".$username."','".$firstname."','".$lastname."','PMS','".$customer_sid."','".$reservation_id."')");
  48.                    
  49.                     if ($insert_radius) {
  50.  
  51.                         //Check Validation Data
  52.                         $query_radusergroup = $db_radius->query("SELECT * FROM radusergroup WHERE username = '".$username_radius."' AND groupname='".$customer_profile."' AND customer='".$customer_sid."'");
  53.                         $result_radusergroup = $query_radusergroup->num_rows;
  54.  
  55.                         if (empty($result_radusergroup)) {
  56.                            
  57.                             //Save to rable radusergroup
  58.                             $insert_radusergroup = $db_radius->query("INSERT INTO radusergroup(username,groupname,customer,priority) VALUES('".$username_radius."','".$customer_profile."','".$customer_sid."','1')");
  59.                         }
  60.                     }
  61.                 }
  62.             }
  63.         }else{
  64.             echo "Cannot save same customer data .Data is available (Mode Checkin)";
  65.             echo "<br>Mysql Error :<br><b>".mysql_error()."</b>";
  66.         }
  67.     }elseif($_GET['mode'] == 'checkout' && $status == '0'){
  68.         //Get Customer Data
  69.         $query_checkout = $db_pms->query("SELECT * FROM pms WHERE username= '".$username."' AND password='".$password."' AND groupname = '".$customer_profile."' AND reservation_id='".$reservation_id."'");
  70.         $result_checkout = $query_checkout->num_rows;
  71.  
  72.         if (!empty($result_checkout)) {
  73.             //if data available do delete
  74.             $delete_pms = $db_pms->query("DELETE FROM pms WHERE username= '".$username."' AND password='".$password."' AND groupname = '".$customer_profile."' AND reservation_id='".$reservation_id."'");
  75.             $delete_radius = $db_radius->query("DELETE FROM radcheck WHERE username='".$username_radius."' AND customer='".$customer_sid."' AND type='PMS' AND reservation_id='".$reservation_id."'");
  76.             $delete_radusergroup = $db_radius->query("DELETE FROM radusergroup WHERE username= '".$username_radius."' AND groupname='".$customer_profile."' AND customer='".$customer_sid."'");
  77.         }else{
  78.             echo "Data not available to delete. Customer is already checkout (Mode Checkout)<br>";
  79.             echo mysql_error();
  80.         }
  81.     }elseif($_GET['mode'] == 'update' && $status == '0'){
  82.         $checkroom = $db_pms->query("SELECT username FROM pms WHERE groupname='".$customer_profile."' AND username='".$username."'");
  83.         $count = $checkroom->num_rows;
  84.         if (!empty($count)) {
  85.             echo("Room Not Empty");
  86.         }elseif(empty($count)){
  87.             $query_update_pms = $db_pms->query("UPDATE pms SET username='".$username."',password='".$password."',checkin='".$checkin."',checkout='".$checkout."' WHERE groupname = '".$customer_profile."' AND reservation_id='".$reservation_id."'");
  88.             if ($query_update_pms) {
  89.                 $query_update_radius = $db_radius->query("UPDATE radcheck SET username='".$username_radius."', username_only='".$username."',value='".$password."' WHERE customer='".$customer_sid."' AND reservation_id='".$reservation_id."'");
  90.                 $query_update_radusergroup = $db_radius->query("UPDATE radusergroup SET username='".$username_radius."' WHERE customer='".$customer_sid."'");
  91.             }else{
  92.                 echo "Data cannot save to table PMS";
  93.                 echo "<br>Mysql Error : <br><b>".mysql_error()."</b>"; 
  94.             }
  95.         }
  96.     }else{
  97.         echo "Data cannot process , please check your parameter (Mode Update)";
  98.         echo "<br>Mysql Error : <br><b>".mysql_error()."</b>";
  99.     }
  100. $db_radius->close();
  101. $db_pms->close();
  102. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement