123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
-
- <?
- if (!$logged_me_in_successfully234)
- return;
- include "qrcode.php";
- if (isset($_POST['delete']) && isset($_POST['id']) )
- {
- $id_remove = htmlentities(mysqli_real_escape_string($link, $_POST['id']));
- $query = "DELETE FROM device_requests WHERE id='$id_remove'";
- $result = mysqli_query($link, $query) or die("Ошибка " . mysqli_error($link));
- }
- if (isset($_POST['new']) == 1)
- {$new=$_POST['new'];
- $rand=rand(1,1000);
- $query1 = mysqli_query($link, "SELECT id FROM devices");
- while ($res1 = mysqli_fetch_array($query1)) {
- if ($res1['id']=$rand)
- {$rand=rand(1,1000);}
- }
- $id =$rand;
- ?>
- <script src="validate.js" type="text/javascript"></script>
- <?
- echo '<form action="?act=devices" method="post">
- <b>Отсканируйте данный QR-код для привязки устройства!</b>
- <br></form>';
- echo "<br>";
- $company = $companyID;
- $dateToBin=pack("Cl*",3, $id);
- $datebase64=base64_encode($dateToBin);
- echo "$datebase64<br>";
- $filename = $PNG_TEMP_DIR . $id . md5('binddevice'. '|' . $errorCorrectionLevel . '|7') . '.png';
- QRcode::png($datebase64, $filename, $errorCorrectionLevel, 7, 2);
- echo '<img src="' . $PNG_WEB_DIR . basename($filename) . '" />';
- ?>
- <form method='POST'">
- <span id="message"></span>
- <?php
- echo "<input type='hidden' id='max' name='max' value=$id>";
- ?>
- </form>
- <?php
- ?>
- <script src="buttonClick.js" type="text/javascript"></script>
- <?
- echo "<button class='button' data-url=$id >переход по ссылке</button>";
- }
- else
- {
- ?>
- <form method='POST'">
- <span id="message"></span>
- <?php
- echo "
- <form id='form2' action='?act=devices' name='form2' method='POST'>
- <input type='submit' value='Добавить новое устройство'>
- <input type='hidden' name='new' value='1'>
- </form> ";
- $query1 = mysqli_query($link, "SELECT * FROM device_requests ORDER BY date DESC");
- echo "
- <form id='form1' name='form1' method='post'>";
- echo"<table border='1px' cellspacing='0'>
- <tr>
- <th >Date:</th>
- <th >Device ID:</th>
- <th ></th>
- <tr>";
- while ($res1 = mysqli_fetch_array($query1)) {
- echo "<tr>";
- echo "<td border='1px'>" . $res1['date'] . "</td>";
- echo "<td border='1px'>" . $res1['device_id'] . "</td>";
- echo "<td border='1px'>
- <form id='form2' action='?act=devices' name='form2' method='POST'>
- <input type='submit' name='delete' value='удалить'>
- <input type='hidden' name='id' value='$res1[id]'></td>
- </form>
- </tr >";
- }
- echo"</table>";
- /* $query1 = mysqli_query($link, "SELECT * FROM devices ORDER BY date DESC");
- echo "
- <form id='form1' name='form1' method='post'>";
- echo"<table border='1px' cellspacing='0'>
- <tr>
- <th >Date:</th>
- <th >Device ID:</th>
- <th>Name</th>
- <th>OS</th>
- <th >Company_id</th>
- <th ></th>
- </tr>";
- while ($res1 = mysqli_fetch_array($query1)) {
- echo "<td border='1px'>". $res1['date'] . "</td>";
- echo "<td border='1px'>". $res1['id'] . "</td>";
- echo "<td border='1px'>". $res1['name'] . "</td>";
- echo "<td border='1px'>". $res1['os'] . "</td>";
- echo "<td border='1px'>". $res1['company_id'] . "</td>";
- echo "<td border='1px'>
- <form id='form2' action='?act=devices' name='form2' method='POST'>
- <input type='submit' name='delete' value='удалить'>
- <input type='hidden' name='id' value='$res1[id]'></td>
- </form>
- </tr >";
- }
- echo"</table>";
- */
- }
- ?>
|