Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 59 additions & 61 deletions core/ajax/camera.ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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());
}
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());
}
17 changes: 11 additions & 6 deletions desktop/modal/camera.history.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,25 @@
echo '<div class="cameraThumbnailContainer">';
krsort($file);
foreach ($file as $time => $filename) {
$fontType = 'fas-camera';
$fontType = 'fa-camera';
if (strpos($filename, '.mp4')) {
$fontType = 'fas-video-camera';
$fontType = 'fa-video';
$i++;
}
echo '<div class="cameraDisplayCard" style="padding:5px;height:170px;">';
echo '<center><i class="fas ' . $fontType . ' pull-right"></i> ' . str_replace('-', ':', $time) . '</center>';
echo '<div class="cameraDisplayCard" style="padding:5px;height:170px !important;">';
echo '<center><i class="fas ' . $fontType . ' pull-right" style="padding-top:3px;"></i> ' . str_replace('-', ':', $time) . '</center>';
if (strpos($filename, '.mp4')) {
echo '<video class="displayVideo" width="150" height="100" controls loop data-src="core/php/downloadFile.php?pathfile=' . urlencode($dir . '/' . $filename) . '" style="cursor:pointer"><source src="core/php/downloadFile.php?pathfile=' . urlencode($dir . '/' . $filename) . '">Your browser does not support the video tag.</video>';
} else {
echo '<center><img class="img-responsive cursor displayImage" src="core/php/downloadFile.php?pathfile=' . urlencode($dir . '/' . $filename) . '" width="150" style="max-height:80px;"/></center>';
}
echo '<center style="margin-top:5px;"><a target="_blank" href="core/php/downloadFile.php?pathfile=' . urlencode($dir . '/' . $filename) . '" class="btn btn-success btn-xs" style="color : white"><i class="fas fa-download"></i></a>';
echo ' <a class="btn btn-danger bt_removeCameraFile btn-xs" style="color : white" data-filename="' . $camera->getId() . '/' . $filename . '"><i class="fas fa-trash"></i></a></center>';
echo '<center style="margin-top:5px;">';
echo '<a target="_blank" href="core/php/downloadFile.php?pathfile=' . urlencode($dir . '/' . $filename) . '" class="btn btn-success btn-xs" style="color : white"><i class="fas fa-download"></i></a>';
echo ' <a class="btn btn-danger bt_removeCameraFile btn-xs" style="color : white" data-filename="' . $camera->getId() . '/' . $filename . '"><i class="fas fa-trash"></i></a>';
if (strpos($filename, '.mp4')) {
echo ' <a class="btn btn-info displayVideo btn-xs" style="color : white" data-src="core/php/downloadFile.php?pathfile=' . urlencode($dir . '/' . $filename) . '"><i class="icon far fa-window-maximize"></i></a>';
}
echo '</center>';
echo '</div>';
}
echo '</div>';
Expand Down
Loading