index.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. if (cfr('MODELS')) {
  3. $modelCraft = new ModelCraft();
  4. //module controls here
  5. show_window('', $modelCraft->renderControls());
  6. if (ubRouting::checkGet($modelCraft::ROUTE_EXPLORER)) {
  7. //onvif-explorer interface
  8. show_window(__('ONVIF device explorer'), $modelCraft->renderExploreForm());
  9. }
  10. //performing device exploration on request
  11. $exploreRequest = array(
  12. $modelCraft::PROUTE_EXPLORE,
  13. $modelCraft::PROUTE_EXPLORE_IP,
  14. $modelCraft::PROUTE_EXPLORE_LOGIN,
  15. $modelCraft::PROUTE_EXPLORE_PASSWORD
  16. );
  17. if (ubRouting::checkPost($exploreRequest)) {
  18. if (zb_PingICMP(ubRouting::post($modelCraft::PROUTE_EXPLORE_IP))) {
  19. $pollingResult = $modelCraft->pollDevice(
  20. ubRouting::post($modelCraft::PROUTE_EXPLORE_IP),
  21. ubRouting::post($modelCraft::PROUTE_EXPLORE_LOGIN),
  22. ubRouting::post($modelCraft::PROUTE_EXPLORE_PASSWORD)
  23. );
  24. if (!empty($pollingResult)) {
  25. show_window(__('Device data'), $modelCraft->renderPollingResults($pollingResult));
  26. } else {
  27. show_error(__('Strange exception') . ': ' . __('Something went wrong') . '. ' . __('Device polling data is empty') . '.');
  28. }
  29. } else {
  30. show_error(__('The device is currently unavailable'));
  31. }
  32. } else {
  33. if (!ubRouting::checkGet($modelCraft::ROUTE_EXPLORER)) { //rendering custom templates list here
  34. show_window(__('Custom device templates'), $modelCraft->renderCustomTemplatesList());
  35. }
  36. }
  37. //new custom device template creation
  38. $templateRequest = array(
  39. $modelCraft::PROUTE_TPLCREATE_DEV,
  40. $modelCraft::PROUTE_TPLCREATE_MAIN,
  41. $modelCraft::PROUTE_TPLCREATE_SUB,
  42. $modelCraft::PROUTE_TPLCREATE_PROTO,
  43. $modelCraft::PROUTE_TPLCREATE_PORT,
  44. );
  45. if (ubRouting::checkPost($templateRequest)) {
  46. $modelCraft->createCustomTemplate(
  47. ubRouting::post($modelCraft::PROUTE_TPLCREATE_DEV),
  48. ubRouting::post($modelCraft::PROUTE_TPLCREATE_PROTO),
  49. ubRouting::post($modelCraft::PROUTE_TPLCREATE_MAIN),
  50. ubRouting::post($modelCraft::PROUTE_TPLCREATE_SUB),
  51. ubRouting::post($modelCraft::PROUTE_TPLCREATE_PORT),
  52. ubRouting::post($modelCraft::PROUTE_TPLCREATE_SOUND),
  53. ubRouting::post($modelCraft::PROUTE_TPLCREATE_PTZ)
  54. );
  55. ubRouting::nav($modelCraft::URL_ME);
  56. }
  57. //existing template deletion
  58. if (ubRouting::checkGet($modelCraft::ROUTE_TPL_DEL)) {
  59. $deletionResult = $modelCraft->deleteCustomTemplate(ubRouting::get($modelCraft::ROUTE_TPL_DEL));
  60. if (empty($deletionResult)) {
  61. ubRouting::nav($modelCraft::URL_ME);
  62. } else {
  63. show_error($deletionResult);
  64. }
  65. }
  66. } else {
  67. show_error(__('Access denied'));
  68. }