diff --git a/core/ajax/camera.ajax.php b/core/ajax/camera.ajax.php index 79007c9..dd995ca 100644 --- a/core/ajax/camera.ajax.php +++ b/core/ajax/camera.ajax.php @@ -31,7 +31,7 @@ if(!is_object($camera)){ throw new \Exception(__('Impossible de trouver la camera : ',__FILE__).init('id')); } - $rtspScript = dirname(__FILE__) . '/../../3rdparty/rtsp-to-hls-' . ($camera->getConfiguration('encodeX264RTSP', 0) == 1 ? 'x264' : 'copy') . '.sh '; + $rtspScript = dirname(__FILE__) . '/../../3rdparty/rtsp-to-hls-' . ($camera->getConfiguration('encodeX264RTSP', 0) == 1 ? 'x264' : 'copy') . '.sh '; if(count(system::ps('rtsp-to-hls-*.sh.*'.$camera->getConfiguration('localApiKey'))) == 0){ shell_exec('(ps ax || ps w) | grep ffmpeg.*'.$camera->getConfiguration('localApiKey').' | awk \'{print $2}\' | xargs sudo kill -9'); $replace = array( @@ -57,72 +57,70 @@ } $camera->setCache('lastStreamCall',strtotime('now')); shell_exec(system::getCmdSudo().' find '.__DIR__.'/../../data/segments/'.$camera->getConfiguration('localApiKey').'-*.ts -mmin +5 -type f -exec rm -f {} \; 2>&1 > /dev/null'); - ajax::success(); - } - - if (!isConnect('admin')) { - throw new Exception(__('401 - Accès non autorisé', __FILE__)); - } - - - - if (init('action') == 'addDiscoverCam') { - camera::addDiscoverCam(json_decode(init('config'), true)); - ajax::success(); - } - - if (init('action') == 'removeRecord') { - $file = init('file'); - $file = str_replace('..', '', $file); - $record_dir = calculPath(config::byKey('recordDir', 'camera')); - shell_exec('rm -rf ' . $record_dir . '/' . $file); - ajax::success(); + ajax::success(); + } + + if (init('action') == 'getCamera') { + if (init('object_id') == '') { + $object = jeeObject::byId($_SESSION['user']->getOptions('defaultDashboardObject')); + } else { + $object = jeeObject::byId(init('object_id')); } - - if (init('action') == 'removeAllSnapshot') { - $camera = camera::byId(init('id')); - if (!is_object($camera)) { - throw new Exception(__('Impossible de trouver la caméra : ' . init('id'), __FILE__)); - } - $camera->removeAllSnapshot(); - ajax::success(); + if (!is_object($object)) { + $object = jeeObject::rootObject(); } - - if (init('action') == 'getCamera') { - if (init('object_id') == '') { - $object = jeeObject::byId($_SESSION['user']->getOptions('defaultDashboardObject')); - } else { - $object = jeeObject::byId(init('object_id')); - } - if (!is_object($object)) { - $object = jeeObject::rootObject(); - } - $return = array(); - $return['eqLogics'] = array(); - if (init('object_id') == '') { - foreach (jeeObject::all() as $object) { - foreach ($object->getEqLogic(true, false, 'camera') as $camera) { - $return['eqLogics'][] = $camera->toHtml(init('version')); - } - } - } else { + $return = array(); + $return['eqLogics'] = array(); + if (init('object_id') == '') { + foreach (jeeObject::all() as $object) { foreach ($object->getEqLogic(true, false, 'camera') as $camera) { $return['eqLogics'][] = $camera->toHtml(init('version')); } - foreach (jeeObject::buildTree($object) as $child) { - $cameras = $child->getEqLogic(true, false, 'camera'); - if (count($cameras) > 0) { - foreach ($cameras as $camera) { - $return['eqLogics'][] = $camera->toHtml(init('version')); - } + } + } else { + foreach ($object->getEqLogic(true, false, 'camera') as $camera) { + $return['eqLogics'][] = $camera->toHtml(init('version')); + } + foreach (jeeObject::buildTree($object) as $child) { + $cameras = $child->getEqLogic(true, false, 'camera'); + if (count($cameras) > 0) { + foreach ($cameras as $camera) { + $return['eqLogics'][] = $camera->toHtml(init('version')); } } } - ajax::success($return); } - - throw new Exception(__('Aucune methode correspondante à : ', __FILE__) . init('action')); - /* * *********Catch exeption*************** */ - } catch (Exception $e) { - ajax::error(displayException($e), $e->getCode()); - } \ No newline at end of file + ajax::success($return); + } + + if (!isConnect('admin')) { + throw new Exception(__('401 - Accès non autorisé', __FILE__)); + } + + if (init('action') == 'addDiscoverCam') { + camera::addDiscoverCam(json_decode(init('config'), true)); + ajax::success(); + } + + if (init('action') == 'removeRecord') { + $file = init('file'); + $file = str_replace('..', '', $file); + $record_dir = calculPath(config::byKey('recordDir', 'camera')); + shell_exec('rm -rf ' . $record_dir . '/' . $file); + ajax::success(); + } + + if (init('action') == 'removeAllSnapshot') { + $camera = camera::byId(init('id')); + if (!is_object($camera)) { + throw new Exception(__('Impossible de trouver la caméra : ' . init('id'), __FILE__)); + } + $camera->removeAllSnapshot(); + ajax::success(); + } + + throw new Exception(__('Aucune methode correspondante à : ', __FILE__) . init('action')); + /* * *********Catch exeption*************** */ +} catch (Exception $e) { + ajax::error(displayException($e), $e->getCode()); +} diff --git a/desktop/modal/camera.history.php b/desktop/modal/camera.history.php index 3719990..d9ecce3 100644 --- a/desktop/modal/camera.history.php +++ b/desktop/modal/camera.history.php @@ -50,20 +50,25 @@ echo '