index.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. set_time_limit(0);
  3. /**
  4. * WolfRecorder RemoteAPI implementation
  5. */
  6. if (ubRouting::checkGet('key')) {
  7. $key = ubRouting::get('key', 'mres');
  8. $serial = wr_SerialGet();
  9. if (!empty($serial)) {
  10. if ($key == $serial) {
  11. //key is ok
  12. if (ubRouting::checkGet('action')) {
  13. //Loading separate api calls controllers
  14. $allRemoteApiModules = rcms_scandir(REMOTEAPI_PATH, '*.php');
  15. if (!empty($allRemoteApiModules)) {
  16. foreach ($allRemoteApiModules as $rmodIndex => $eachRModuleController) {
  17. $eachRModuleControllerName = basename($eachRModuleController, '.php');
  18. require_once (REMOTEAPI_PATH . $eachRModuleController);
  19. }
  20. }
  21. /*
  22. * Exceptions handling
  23. */
  24. } else {
  25. die('ERROR:GET_NO_ACTION');
  26. }
  27. } else {
  28. die('ERROR:GET_WRONG_KEY');
  29. }
  30. } else {
  31. die('ERROR:NO_UBSERIAL_EXISTS');
  32. }
  33. } else {
  34. /*
  35. * WolfRecorder instance identify handler
  36. */
  37. if (ubRouting::checkGet('action')) {
  38. if (ubRouting::get('action') == 'identify') {
  39. $serial = wr_SerialGet();
  40. if (!empty($serial)) {
  41. $idserial = $serial;
  42. } else {
  43. $idserial = wr_SerialInstall();
  44. }
  45. //saving serial into temp file required for initial crontab setup
  46. if (@ubRouting::get('param') == 'save') {
  47. file_put_contents('exports/wrserial', $idserial);
  48. }
  49. //render result
  50. die(substr($idserial, -4));
  51. }
  52. } else {
  53. die('ERROR:GET_NO_KEY');
  54. }
  55. }