Advertisement
eqeqwan21

Untitled

Sep 26th, 2024
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.44 KB | None | 0 0
  1. public function get_prf() {
  2.  
  3.         global $config;
  4.         $db = new ods_db();
  5.  
  6.         $phone = $this->num;
  7.         $filePath = __DIR__ . '/../../cities.txt';
  8.         $cityIds = [];
  9.         if (file_exists($filePath)) {
  10.             $cityData = file_get_contents($filePath);
  11.             $cityIds = $cityData ? explode(',', $cityData) : [];
  12.         }
  13.  
  14.         if (!empty($cityIds)) {
  15.             $placeholders = implode(',', array_fill(0, count($cityIds), '?'));
  16.         } else {
  17.             header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
  18.             exit();
  19.         }
  20.  
  21.         if($db->open()) {
  22.             $sql = "SELECT * FROM Devices WHERE Phone = ? AND Town_id NOT IN ($placeholders) LIMIT 1";
  23.             $statement = $db->db->prepare($sql);
  24.  
  25.             $params = array_merge([$phone], $cityIds);
  26.             $statement->execute($params);
  27.             $device = $statement->fetch();
  28.  
  29.             if ($device) {
  30.                 $prf = $this->dev_prf(isset($_GET['crc2']), isset($_GET['crc']));
  31.                 if ($prf['error'] === '') {
  32.                     $this->output($prf['str'], $this->num . '.pref.txt', isset($_GET['gz']));
  33.                 } else {
  34.                     header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
  35.                     exit();
  36.                 }
  37.             } else {
  38.                 header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
  39.                 exit();
  40.             }
  41.         }
  42.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement