Advertisement
Guest User

Untitled

a guest
Apr 9th, 2020
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.85 KB | None | 0 0
  1. <?php
  2.  
  3. require "db.php";
  4.  
  5. if(isset($_POST['api_key'], $_POST['cpu'])) {
  6.  
  7.    
  8.     $sql_key = $connSettings->prepare('SELECT * FROM `api` WHERE `name`="api_key"');
  9.     $sql_key->execute();
  10.     $sql_key_res = $sql_key->get_result();
  11.  
  12.     if($sql_key_res->num_rows > 0) {
  13.         $info = $sql_key_res->fetch_object();
  14.         $key = $info->value;
  15.  
  16.         if ($_POST['api_key'] == $key) {
  17.  
  18.             $cpu = strtoupper($_POST['cpu']);
  19.  
  20.  
  21.             $sql_dizzy = $connDizzy->prepare('SELECT * FROM `consoles` WHERE `cpukey`=?');
  22.             $sql_dizzy->bind_param('s', $cpu);
  23.             $sql_dizzy->execute();
  24.             $sql_dizzy_res = $sql_dizzy->get_result();
  25.  
  26.             if($sql_dizzy_res->num_rows == 1) {
  27.  
  28.                 $infoClient = $sql_dizzy_res->fetch_array();
  29.                
  30.                 if(isset($_POST['unbanned'])) {
  31.  
  32.                     $unbanned_r = $infoClient['kvtime'];
  33.                     $expire_time = strtotime($infoClient['expire']);
  34.  
  35.                     $unbanned_f = strtotime($unbanned_r);
  36.                     $now = time();
  37.                     $difference = $now - $unbanned_f;
  38.                     $unbanned = $difference;
  39.                     $seconds_unbanned = $unbanned % 60;
  40.                     $minutes_unbanned = (($unbanned - $seconds_unbanned) / 60) % 60;
  41.                     $hours_unbanned = (((($unbanned - $seconds_unbanned) / 60) - $minutes_unbanned) / 60) % 24;
  42.                     $days_unbanned = floor(((((($unbanned - $seconds_unbanned) / 60)- $minutes_unbanned) / 60) / 24) );
  43.  
  44.                    
  45.                     $expires = $expire_time;
  46.                     $seconds_expires = $expires % 60;
  47.                     $minutes_expires = (($expires - $seconds_expires) / 60) % 60;
  48.                     $hours_expires = (((($expires - $seconds_expires) / 60) - $minutes_expires) / 60) % 24;
  49.                     $days_expires = floor(((((($expires - $seconds_expires) / 60)- $minutes_expires) / 60) / 24) );
  50.  
  51.                     if($expire_time > $now) {
  52.                         $expire = 'Expired';
  53.                     }
  54.                     else {
  55.                         $expire = $days_expires . "D " . $hours_expires . "H " . $minutes_expires . "M";
  56.                     }
  57.  
  58.                     $response = array(
  59.                         'unbanned' => $days_unbanned . "D " . $hours_unbanned . "H " . $minutes_unbanned . "M",
  60.                         'name' => $infoClient['name'],
  61.                         'expire' => $expire
  62.                     );
  63.                    
  64.                     echo json_encode($response, JSON_PRETTY_PRINT);
  65.  
  66.                 }
  67.  
  68.             }
  69.             else {
  70.                 echo "Wrong cpu";
  71.             }
  72.         }
  73.         else {
  74.             echo "Authentication-Key Error!";
  75.         }
  76.     }
  77.     else {
  78.         echo "Authentication Error!";
  79.     }
  80. }
  81.  
  82. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement