2013-05-02 06:41:59 +08:00
|
|
|
<?php
|
|
|
|
class MonitorsController extends AppController {
|
2013-05-23 09:18:43 +08:00
|
|
|
public $helpers = array('LiveStream');
|
2013-05-02 06:41:59 +08:00
|
|
|
|
|
|
|
public function index() {
|
2013-05-16 05:51:14 +08:00
|
|
|
$monitoroptions['fields'] = array('Name', 'Id', 'Function');
|
2013-05-05 07:22:09 +08:00
|
|
|
$this->set('monitors', $this->Monitor->find('all', $monitoroptions));
|
2013-05-08 21:37:56 +08:00
|
|
|
$monitors = $this->Monitor->find('list', array('fields' => array('Id')));
|
|
|
|
$intervals = array('HOUR', 'DAY', 'WEEK', 'MONTH');
|
|
|
|
foreach ($monitors as $monitor) {
|
|
|
|
foreach ($intervals as $interval) {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-05-02 06:41:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public function view($id = null) {
|
2013-05-07 23:15:06 +08:00
|
|
|
$this->loadModel('Config');
|
2013-05-02 06:41:59 +08:00
|
|
|
if (!$id) {
|
|
|
|
throw new NotFoundException(__('Invalid monitor'));
|
|
|
|
}
|
|
|
|
|
|
|
|
$monitor = $this->Monitor->findById($id);
|
|
|
|
if (!$monitor) {
|
|
|
|
throw new NotFoundException(__('Invalid monitor'));
|
|
|
|
}
|
|
|
|
$this->set('monitor', $monitor);
|
2013-05-07 22:29:34 +08:00
|
|
|
|
2013-05-07 23:15:06 +08:00
|
|
|
|
2013-05-07 22:29:34 +08:00
|
|
|
$zmBandwidth = $this->Cookie->read('zmBandwidth');
|
|
|
|
|
2013-05-07 23:15:06 +08:00
|
|
|
$ZM_MPEG_LIVE_FORMAT = $this->Config->find('first', array(
|
|
|
|
'fields' => array('Value'), 'conditions' => array('Name' => 'ZM_MPEG_LIVE_FORMAT')
|
2013-05-07 22:29:34 +08:00
|
|
|
));
|
2013-05-07 23:15:06 +08:00
|
|
|
|
|
|
|
$ZM_WEB_STREAM_METHOD = $this->Config->getWebOption('ZM_WEB_STREAM_METHOD', $zmBandwidth);
|
|
|
|
$ZM_WEB_VIDEO_BITRATE = $this->Config->getWebOption('ZM_WEB_VIDEO_BITRATE', $zmBandwidth);
|
|
|
|
$ZM_WEB_VIDEO_MAXFPS = $this->Config->getWebOption('ZM_WEB_VIDEO_MAXFPS', $zmBandwidth);
|
|
|
|
$ZM_MPEG_LIVE_FORMAT = $ZM_MPEG_LIVE_FORMAT['Config']['Value'];
|
2013-05-07 22:29:34 +08:00
|
|
|
$buffer = $monitor['Monitor']['StreamReplayBuffer'];
|
|
|
|
|
2013-05-07 23:15:06 +08:00
|
|
|
if ($ZM_WEB_STREAM_METHOD == 'mpeg' && $ZM_MPEG_LIVE_FORMAT) {
|
2013-05-07 22:29:34 +08:00
|
|
|
$this->set('streamSrc', "/cgi-bin/nph-zms?mode=mpeg&scale=100&maxfps=$ZM_WEB_VIDEO_MAXFPS&bitrate=$ZM_WEB_VIDEO_BITRATE&format=$ZM_MPEG_LIVE_FORMAT");
|
|
|
|
} else {
|
|
|
|
$this->set('streamSrc', "/cgi-bin/nph-zms?mode=jpeg&scale=100&maxfps=$ZM_WEB_VIDEO_MAXFPS&buffer=$buffer");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-05-02 06:41:59 +08:00
|
|
|
}
|
2013-05-02 09:03:25 +08:00
|
|
|
|
2013-05-03 09:31:05 +08:00
|
|
|
public function edit($id = null) {
|
|
|
|
if (!$id) {
|
|
|
|
throw new NotFoundException(__('Invalid monitor'));
|
|
|
|
}
|
|
|
|
|
|
|
|
$monitor = $this->Monitor->findById($id);
|
|
|
|
if (!$monitor) {
|
|
|
|
throw new NotFoundException(__('Invalid monitor'));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->request->is('put') || $this->request->is('post')) {
|
|
|
|
$this->Monitor->id = $id;
|
|
|
|
if ($this->Monitor->save($this->request->data)) {
|
|
|
|
$this->Session->setFlash('Your monitor has been updated.');
|
|
|
|
$this->redirect(array('action' => 'index'));
|
|
|
|
} else {
|
|
|
|
$this->Session->setFlash('Unable to update your monitor.');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$this->request->data) {
|
|
|
|
$this->request->data = $monitor;
|
|
|
|
}
|
|
|
|
}
|
2013-05-02 09:03:25 +08:00
|
|
|
|
2013-05-15 20:35:49 +08:00
|
|
|
public function add() {
|
|
|
|
if ($this->request->is('post')) {
|
|
|
|
$this->Monitor->create();
|
|
|
|
if ($this->Monitor->save($this->request->data)) {
|
|
|
|
$this->Session->setFlash('Your monitor has been created.');
|
|
|
|
$this->redirect(array('action' => 'index'));
|
|
|
|
} else {
|
|
|
|
$this->Session->setFlash('Unable to create your monitor.');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-02 06:41:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|