@link http://blog.idleman.fr @licence CC by nc sa @version 1.0.0 @description Visualisation en streaming de camera(s) IP */ function ipcam_action(){ global $_,$conf; switch($_['action']){ case 'ipcam_save_camera': Action::write( function($_,&$response){ require_once('Camera.class.php'); $camera = new Camera(); if(empty($_['labelCamera'])) throw new Exception("Le nom est obligatoire"); if(empty($_['ipCamera'])) throw new Exception("L'IP est obligatoire"); $camera = !empty($_['id']) ? $camera->getById($_['id']): new Camera(); $camera->label = $_['labelCamera']; $camera->location = $_['locationCamera']; $camera->pattern = $_['patternCamera']; $camera->ip = $_['ipCamera']; $camera->login = $_['loginCamera']; $camera->password = $_['passwordCamera']; $camera->save(); $response['message'] = 'Caméra enregistrée avec succès'; }, array('ipcam'=>'c') ); break; case 'ipcam_delete_camera': Action::write( function($_,$response){ require_once('Camera.class.php'); $camera = new Camera(); $camera->delete(array('id'=>$_['id'])); }, array('ipcam'=>'d') ); break; case 'ipcam_load_widget': require_once(dirname(__FILE__).'/../dashboard/Widget.class.php'); Action::write( function($_,&$response){ $widget = new Widget(); $widget = $widget->getById($_['id']); $parameters = $widget->data(); if(empty($parameters['camera'])){ $content = 'Choisissez une camera en cliquant sur l \'icone de la barre du widget'; }else{ global $conf; require_once('Camera.class.php'); $camera = new Camera(); $camera = $camera->getById($parameters['camera']); $room = new Room(); $room = $room->getById($camera->location); $response['title'] = 'Sonde '.$camera->label.' ('.$room->getName().')'; $content = ' '; $url = str_replace(array( '{{login}}', '{{password}}', '{{ip}}' ),array( $camera->login, $camera->password, $camera->ip ),$camera->pattern); ///pour ma cam, a la fin de l'ip : http://{{login}}:{{password}}@{{ip}}/videostream.cgi $content .= '
'; $content .= ' '; } $response['content'] = $content; } ); break; case 'ipcam_edit_widget': require_once(dirname(__FILE__).'/../dashboard/Widget.class.php'); require_once(dirname(__FILE__).'/Camera.class.php'); $widget = new Widget(); $widget = $widget->getById($_['id']); $data = $widget->data(); $camera = new Camera(); $cameras = $camera->populate(); $content = 'Gestion des cameras IP