usbPorts.php 591 B

12345678910111213141516171819202122
  1. <?php
  2. include '../../../auth.php';
  3. ?>
  4. <?php
  5. if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
  6. //die('ERROR. Window not supported.');
  7. exec("USB_list.exe",$out);
  8. sleep(1);
  9. $USBlist = fopen("WIN32_USBlist.txt", "r") or die($out);
  10. $result = explode(",",substr(fread($USBlist,filesize("WIN32_USBlist.txt")),3));
  11. fclose($USBlist);
  12. header('Content-Type: application/json');
  13. echo json_encode($result);
  14. //$result;
  15. }else{
  16. $temp = shell_exec('lsusb');
  17. $temp = str_replace("\n",",",$temp);
  18. $host = explode(",",$temp);
  19. header('Content-Type: application/json');
  20. echo json_encode($host);
  21. }
  22. ?>