Advertisement
kiler129

Untitled

Aug 3rd, 2014
357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. <?php
  2. //This config is shared across all modules
  3. define("DEBUG", true); //Enable debug mode
  4.  
  5. date_default_timezone_set("Europe/Warsaw"); //Timezone
  6.  
  7. define("RFID_DEVICES_PATTERNS", '/dev/ttyUSB*[0-99] /dev/usbserial /dev/cu.usb*'); //Separate by space, patterns here should NOT contain " - it's quirk only for command line
  8. define("RFID_BAUD", 19200);
  9. define("STTY_PATH", "/bin/stty");
  10. define("RFID_START", "#"); //Set to NULL if your device doesn't send specific character
  11. define("RFID_END", "\n"); //Some RFID readers use \r\n, some \n and some other character
  12. define("RFID_PAYLOAD_LEN", 16); //Packet length in bytes (NOT including START and END)
  13.  
  14.  
  15. //Some runtimes - DO NOT MODIFY!!!
  16. /********************************************************************************************************************************************************************************************************************/
  17. define("L_INF", "INFO");
  18. define("L_ERR", "ERROR");
  19. define("L_FTL", "FATAL");
  20. define("L_WRN", "WARNING");
  21. define("L_DBG", "DEBUG");
  22.  
  23. if(DEBUG) error_reporting(E_ALL);
  24. set_time_limit(0);
  25.  
  26. $uname = strtolower(php_uname("s"));
  27. if($uname === "darwin" || strpos($uname, "bsd") !== false) { pLog("Running on $uname [BSD-compilant]", L_DBG); define("IS_BSD", true); }
  28. elseif(strpos($uname, "linux") !== false) { pLog("Running on Linux OS", L_DBG); define("IS_BSD", false); }
  29. elseif(strpos($uname, "windows") === 0) pLog('Running in Win$hit environment is not supported and NEVER will', L_FTL);
  30. else pLog("Unknown OS detected - $uname", L_FTL);
  31.  
  32.  
  33.  
  34. function pLog($txt, $code=L_INF) {
  35. if(!DEBUG && $code === L_INF) return;
  36. $txt = str_replace(array("\n", "\r"), array('\n', '\r'), $txt);
  37.  
  38. switch($code) {
  39. case L_INF: $color = "[1;32m"; break; //Green
  40. case L_FTL:
  41. case L_ERR: $color = "[0;31m"; break; //Red
  42. case L_WRN: $color = "[1;33m"; break; //Yellow
  43. case L_DBG: $color = "[0;37m"; break; //Light grey
  44. default:
  45. $color = "[0;90m"; //Dark grey
  46. $code = "UNKNOWN-$code";
  47. }
  48.  
  49. echo chr(27).$color."<".date("d.m.Y H:i:s")."> [$code] $txt\n".chr(27).chr(27)."[0m".chr(27);
  50. if($code === L_FTL) die();
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement