123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- <?php
- include "auth.php";
- include "qrcode.php";
- if (isset($_POST['max'])) {
- $max = htmlentities(mysqli_real_escape_string($link, $_POST['max']));
- $query = "SELECT name FROM devices WHERE id= $max";
- $result = mysqli_query($link, $query) or die("Ошибка " . mysqli_error($link));
- $res1 = mysqli_fetch_array($result);
- if ($res1['name']!="")
- {
- echo "valid";
- }
- else
- {
- echo "invalid";
- }
- }
- if(isset($_GET['company']) && isset($_GET['name']) && isset($_GET['id'])){
- $name = htmlentities(mysqli_real_escape_string($link, $_GET['name']));
- $os=getOS();
- $id = htmlentities(mysqli_real_escape_string($link, $_GET['id']));
- $company = htmlentities(mysqli_real_escape_string($link, $_GET['company']));
- $query = "INSERT INTO devices VALUES('$id','$os','$company','$name', NOW())";
- $result = mysqli_query($link, $query) or die("Ошибка " . mysqli_error($link));
- $query = "SELECT * FROM devices WHERE id= $id";
- $result = mysqli_query($link, $query) or die("Ошибка " . mysqli_error($link));
- while ($res12 = mysqli_fetch_array($result)) {
- $codeID = $res12['id'] . $res12['os'] . $res12['company_id'] . $res12['name'];
- }
- echo $codeID;
- $dateToBin=pack("Cl*",$codeID);
- $datebase64=base64_encode($dateToBin);
- // $datebase64=base64_encode($codeID);
- $query = "INSERT INTO device_requests VALUES(NULL,'$datebase64',NOW())";
- $result = mysqli_query($link, $query) or die("Ошибка " . mysqli_error($link));
- /*
- $id_remove=$id;
- $query = "DELETE FROM devices WHERE id='$id_remove'";
- $result = mysqli_query($link, $query) or die("Ошибка " . mysqli_error($link));
- echo "true";
- */
- }
- $user_agent = $_SERVER['HTTP_USER_AGENT'];
- function getOS()
- {
- global $user_agent;
- $os_platform = "Unknown OS Platform";
- $os_array = array(
- '/windows nt 10/i' => 'Windows 10',
- '/windows nt 6.3/i' => 'Windows 8.1',
- '/windows nt 6.2/i' => 'Windows 8',
- '/windows nt 6.1/i' => 'Windows 7',
- '/windows nt 6.0/i' => 'Windows Vista',
- '/windows nt 5.2/i' => 'Windows Server 2003/XP x64',
- '/windows nt 5.1/i' => 'Windows XP',
- '/windows xp/i' => 'Windows XP',
- '/windows nt 5.0/i' => 'Windows 2000',
- '/windows me/i' => 'Windows ME',
- '/win98/i' => 'Windows 98',
- '/win95/i' => 'Windows 95',
- '/win16/i' => 'Windows 3.11',
- '/macintosh|mac os x/i' => 'Mac OS X',
- '/mac_powerpc/i' => 'Mac OS 9',
- '/linux/i' => 'Linux',
- '/ubuntu/i' => 'Ubuntu',
- '/iphone/i' => 'iPhone',
- '/ipod/i' => 'iPod',
- '/ipad/i' => 'iPad',
- '/android/i' => 'Android',
- '/blackberry/i' => 'BlackBerry',
- '/webos/i' => 'Mobile'
- );
- foreach ($os_array as $regex => $value) {
- if (preg_match($regex, $user_agent)) {
- $os_platform = $value;
- }
- }
- return $os_platform;
- }
- ?>
|