hb.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. header('Access-Control-Allow-Origin: *');
  3. header('Cache-Control: no-cache');
  4. header('Access-Control-Request-Headers: *');
  5. header('Access-Control-Allow-Headers: Content-Type');
  6. function gen_uuid() {
  7. return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
  8. // 32 bits for "time_low"
  9. mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
  10. // 16 bits for "time_mid"
  11. mt_rand( 0, 0xffff ),
  12. // 16 bits for "time_hi_and_version",
  13. // four most significant bits holds version number 4
  14. mt_rand( 0, 0x0fff ) | 0x4000,
  15. // 16 bits, 8 bits for "clk_seq_hi_res",
  16. // 8 bits for "clk_seq_low",
  17. // two most significant bits holds zero and one for variant DCE1.1
  18. mt_rand( 0, 0x3fff ) | 0x8000,
  19. // 48 bits for "node"
  20. mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff )
  21. );
  22. }
  23. $config_path = "/etc/AOB/";
  24. if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
  25. $config_path = "C:/AOB/";
  26. }
  27. if (file_exists("root.inf") && filesize("root.inf") > 0){
  28. $config_path = trim(file_get_contents("root.inf"));
  29. }
  30. $uuid = "win";
  31. if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
  32. //if this system is running under Windows environment
  33. if (!file_exists($config_path)) {
  34. mkdir($config_path, 0777, true);
  35. }
  36. if (!file_exists($config_path . "device_identity.config")){
  37. $configFile = fopen($config_path . "device_identity.config", "w") or die("Permission Error.");
  38. $uuid = gen_uuid();
  39. fwrite($configFile, $uuid);
  40. fclose($configFile);
  41. }else{
  42. $uuid = file_get_contents($config_path . "device_identity.config");
  43. }
  44. }else{
  45. //if this system is running under linux environment
  46. if (file_exists($config_path) && file_exists($config_path . "device_identity.config")){
  47. $uuid = file_get_contents($config_path . "device_identity.config");
  48. }else{
  49. $reuslt = '';
  50. system('sudo mkdir /etc/AOB/', $result);
  51. system('sudo chmod 777 /etc/AOB/', $result);
  52. $configFile = fopen($config_path . "device_identity.config", "w") or die("Permission Error.");
  53. $uuid = gen_uuid();
  54. fwrite($configFile, $uuid);
  55. fclose($configFile);
  56. }
  57. }
  58. echo "AOBP,Alive," . $uuid . "," . $_SERVER['SERVER_ADDR'];
  59. ?>