2010-11-06 00:48:57 +08:00
|
|
|
<?php
|
2010-11-11 06:20:29 +08:00
|
|
|
/*
|
|
|
|
* actions.php is created by Jai Dhar, FPS-Tech, for use with eyeZm
|
|
|
|
* iPhone application. This is not intended for use with any other applications,
|
|
|
|
* although source-code is provided under GPL.
|
|
|
|
*
|
|
|
|
* For questions, please email jdhar@eyezm.com (http://www.eyezm.com)
|
|
|
|
*
|
|
|
|
*/
|
2010-11-06 00:48:57 +08:00
|
|
|
/* Parse any specific actions here */
|
|
|
|
if (isset($_GET['action'])) {
|
|
|
|
$action = $_GET['action'];
|
2011-02-20 04:25:22 +08:00
|
|
|
if (!strcmp($action, "devent")) {
|
2010-11-06 07:41:09 +08:00
|
|
|
/* ACTION: Delete an Event. Parms: <eid> */
|
2010-11-06 00:48:57 +08:00
|
|
|
if (!canEdit('Events')) {
|
2010-11-19 03:07:37 +08:00
|
|
|
logXmlErr("User ".$user['Username']. " doesn't have edit Events perms");
|
2010-11-06 00:48:57 +08:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
if (!isset($_REQUEST['eid'])) {
|
2010-11-19 03:07:37 +08:00
|
|
|
logXmlErr("EID not set for action delete-event");
|
2010-11-06 00:48:57 +08:00
|
|
|
exit;
|
|
|
|
}
|
2011-02-20 04:25:22 +08:00
|
|
|
$eid = validInteger($_REQUEST['eid']);
|
2010-11-06 00:48:57 +08:00
|
|
|
$url = "./index.php?view=request&request=event&id=".$eid."&action=delete";
|
|
|
|
header("Location: ".$url);
|
|
|
|
exit;
|
2010-11-06 07:41:09 +08:00
|
|
|
|
2011-02-20 04:25:22 +08:00
|
|
|
} else if (!strcmp($action, "spawn264")) {
|
2010-11-11 06:20:29 +08:00
|
|
|
/* ACTION: Spawn 264 streaming process.
|
2010-11-13 07:04:09 +08:00
|
|
|
* Parms: <monitor>[br|width|height] */
|
|
|
|
if (!canView('Stream')) {
|
2010-11-19 03:07:37 +08:00
|
|
|
logXmlErr("User ".$user['Username']. " doesn't have view Stream perms");
|
2010-11-13 07:04:09 +08:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
if (!isset($_GET['monitor'])) {
|
2010-11-19 03:07:37 +08:00
|
|
|
logXmlErr("Not all parameters specified for spawn264");
|
2010-11-11 06:20:29 +08:00
|
|
|
exit;
|
|
|
|
}
|
2011-02-20 04:25:22 +08:00
|
|
|
$monitor = validInteger($_REQUEST['monitor']);
|
|
|
|
if (!isMonitor($monitor)) exit;
|
2010-11-13 07:04:09 +08:00
|
|
|
$dims = getMonitorDims($monitor);
|
2011-02-20 04:25:22 +08:00
|
|
|
$width = validInteger(getset('width', $dims['Width']));
|
|
|
|
$height = validInteger(getset('height', $dims['Height']));
|
2011-02-20 04:25:54 +08:00
|
|
|
$br = validString(getset('br', ZM_EYEZM_H264_DEFAULT_BR));
|
2010-11-19 03:09:51 +08:00
|
|
|
/* Check that we can stream first */
|
|
|
|
if (!canStream264()) {
|
|
|
|
/* canStream264 will print out error */
|
|
|
|
exit;
|
|
|
|
}
|
2010-11-11 06:20:29 +08:00
|
|
|
$streamUrl = stream264fn($monitor, $width, $height, $br);
|
2010-11-11 13:25:43 +08:00
|
|
|
logXml("Using H264 Pipe Function: ".$streamUrl);
|
2010-11-11 06:20:29 +08:00
|
|
|
$pid = shell_exec($streamUrl);
|
2010-11-11 13:25:43 +08:00
|
|
|
logXml("Streaming Process for monitor ".$monitor." ended, cleaning up files");
|
2010-11-11 06:20:29 +08:00
|
|
|
eraseH264Files($monitor);
|
|
|
|
exit;
|
|
|
|
|
2011-02-20 04:25:22 +08:00
|
|
|
} else if (!strcmp($action, "kill264")) {
|
2010-11-11 06:20:29 +08:00
|
|
|
/* ACTION: Kill existing H264 stream process and cleanup files.
|
|
|
|
* Parms: <monitor>.
|
|
|
|
* NOTE: This will be called directly by path, so include files
|
|
|
|
* may not be available */
|
2010-11-19 03:09:18 +08:00
|
|
|
session_start();
|
2010-11-11 06:20:29 +08:00
|
|
|
require_once(dirname(__FILE__)."/../includes/functions.php");
|
|
|
|
if (!isset($_GET['monitor'])) {
|
2010-11-19 03:07:37 +08:00
|
|
|
logXmlErr("Not all parameters specified for kill264");
|
2010-11-11 06:20:29 +08:00
|
|
|
exit;
|
|
|
|
}
|
2011-02-20 04:25:22 +08:00
|
|
|
$monitor = validInteger($_GET['monitor']);
|
2010-11-11 06:20:29 +08:00
|
|
|
kill264proc($monitor);
|
2010-11-11 13:25:43 +08:00
|
|
|
logXml("Killed Segmenter process for monitor ".$monitor);
|
2010-11-11 06:20:29 +08:00
|
|
|
exit;
|
|
|
|
|
2011-02-20 04:25:22 +08:00
|
|
|
} else if (!strcmp($action, "chk264")) {
|
2010-11-11 06:20:29 +08:00
|
|
|
/* ACTION: Simply stalls while checking for 264 file.
|
2010-11-13 07:04:09 +08:00
|
|
|
* Parms: <monitor><timeout>
|
2010-11-11 06:20:29 +08:00
|
|
|
* NOTE: This will be called directly by path, so include files
|
|
|
|
* may not be available */
|
2010-11-19 03:09:18 +08:00
|
|
|
session_start();
|
2010-11-19 03:07:37 +08:00
|
|
|
require_once(dirname(__FILE__)."/../includes/functions.php");
|
2010-11-13 07:04:09 +08:00
|
|
|
if (!isset($_GET['monitor']) || !isset($_GET['timeout'])) {
|
2010-11-19 03:07:37 +08:00
|
|
|
logXmlErr("Monitor not specified for chk264");
|
2010-11-11 06:20:29 +08:00
|
|
|
exit;
|
|
|
|
}
|
2011-02-20 04:25:22 +08:00
|
|
|
$monitor = validInteger($_GET['monitor']);
|
2010-11-11 06:20:29 +08:00
|
|
|
$path = getTempDir()."/".m3u8fname($monitor);
|
2010-11-13 07:04:09 +08:00
|
|
|
/* Wait for the second sample to become available */
|
|
|
|
$tsfile = getTempDir()."/sample_".$monitor."-2.ts";
|
2010-11-11 06:20:29 +08:00
|
|
|
/* Setup timeout */
|
|
|
|
$startTime = time();
|
2011-02-20 04:25:22 +08:00
|
|
|
$timeout = validInteger($_GET['timeout']);
|
2010-11-13 07:04:09 +08:00
|
|
|
while (!file_exists($path) || !file_exists($tsfile)) {
|
2010-11-11 06:20:29 +08:00
|
|
|
if (time() > $startTime + $timeout) {
|
2010-11-19 03:07:37 +08:00
|
|
|
logXmlErr("Timed out waiting for stream to start, exiting...");
|
2010-11-11 06:20:29 +08:00
|
|
|
kill264proc($monitor);
|
|
|
|
exit;
|
|
|
|
}
|
2010-11-13 07:04:09 +08:00
|
|
|
usleep(10000);
|
2010-11-11 06:20:29 +08:00
|
|
|
}
|
2010-11-11 13:25:43 +08:00
|
|
|
logXml("File exists, stream created after ".(time()-$startTime)." sec");
|
2010-11-11 06:20:29 +08:00
|
|
|
exit;
|
|
|
|
|
2011-02-20 04:25:22 +08:00
|
|
|
} else if (!strcmp($action, "feed")) {
|
2011-04-19 08:09:34 +08:00
|
|
|
/* ACTION: View a feed. Parms: <monitor> [height|width|fps|scale|vcodec|br] */
|
2010-11-06 00:48:57 +08:00
|
|
|
if (!canView('Stream')) {
|
2010-11-19 03:07:37 +08:00
|
|
|
logXmlErr("User ".$user['Username']. " doesn't have view Stream perms");
|
2010-11-06 00:48:57 +08:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
/* Check that required variables are set */
|
2010-11-12 12:26:31 +08:00
|
|
|
if (!isset($_REQUEST['monitor'])) {
|
2010-11-19 03:07:37 +08:00
|
|
|
logXmlErr("Not all parameters set for action view-feed");
|
2010-11-06 00:48:57 +08:00
|
|
|
exit;
|
|
|
|
}
|
2011-02-20 04:25:22 +08:00
|
|
|
$monitor = validInteger($_REQUEST['monitor']);
|
|
|
|
if (!isMonitor($monitor)) exit;
|
2010-11-13 07:04:09 +08:00
|
|
|
$dims = getMonitorDims($monitor);
|
2011-02-20 04:25:22 +08:00
|
|
|
$width = validInteger(getset('width', $dims['Width']));
|
|
|
|
$height = validInteger(getset('height', $dims['Height']));
|
|
|
|
$fps = validInteger(getset('fps', ZM_WEB_VIDEO_MAXFPS));
|
|
|
|
$scale = validInteger(getset('scale', 100));
|
2011-02-20 04:25:54 +08:00
|
|
|
$vcodec = validString(getset('vcodec', ZM_EYEZM_FEED_VCODEC));
|
2010-11-19 03:09:51 +08:00
|
|
|
/* Select which codec we want */
|
|
|
|
if (!strcmp($vcodec, "h264")) {
|
|
|
|
/* Validate that we can in fact stream H264 */
|
|
|
|
if (!canStream264()) {
|
|
|
|
/* canStream264 will print out error if
|
|
|
|
* there is one */
|
2011-02-20 04:25:54 +08:00
|
|
|
echo "Server cannot stream H264. Check eyeZm log for details";
|
2010-11-19 03:09:51 +08:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
if (!requireVer("1", "2")) {
|
|
|
|
echo "H264 Streaming requires eyeZm v1.2 or above";
|
|
|
|
logXmlErr("H264 Streaming requires eyeZm v1.2 or above");
|
|
|
|
exit;
|
|
|
|
}
|
2011-02-20 04:25:54 +08:00
|
|
|
$br = validString(getset('br', ZM_EYEZM_H264_DEFAULT_BR));
|
2010-11-11 06:20:29 +08:00
|
|
|
/* H264 processing */
|
|
|
|
noCacheHeaders();
|
|
|
|
/* Kill any existing processes and files */
|
|
|
|
kill264proc($monitor);
|
|
|
|
eraseH264Files($monitor);
|
2010-11-12 12:26:31 +08:00
|
|
|
logXml("Streaming H264 on Monitor ".$monitor.", ".$width."x".$height." @".$br);
|
2010-11-19 03:07:37 +08:00
|
|
|
/* Get thumbnail source */
|
|
|
|
$thumbsrc =
|
|
|
|
getStreamSrc( array(
|
|
|
|
"mode=single",
|
|
|
|
"monitor=".$monitor,
|
|
|
|
"scale=".$scale,
|
|
|
|
"maxfps=".$fps,
|
|
|
|
"buffer=1000"
|
|
|
|
) );
|
|
|
|
logXml("Using thumbnail image from ".$thumbsrc);
|
2010-11-11 06:20:29 +08:00
|
|
|
/* Generate H264 Web-page */
|
2011-04-19 08:09:50 +08:00
|
|
|
echo "<meta name=\"viewport\" content=\"width=".$width."\" />\n";
|
2010-11-19 03:07:37 +08:00
|
|
|
h264vidHtml($width, $height, $monitor, $br, $thumbsrc);
|
2010-11-12 12:26:31 +08:00
|
|
|
} else if (!strcmp($vcodec, "mjpeg")) {
|
2010-11-11 06:20:29 +08:00
|
|
|
/* MJPEG streaming */
|
2011-04-19 08:09:34 +08:00
|
|
|
/* If $fps=0, get a single-shot */
|
|
|
|
if (!$fps) {
|
|
|
|
/* single-shot */
|
|
|
|
$streamSrc =
|
|
|
|
getStreamSrc( array(
|
|
|
|
"mode=single",
|
|
|
|
"monitor=".$monitor,
|
|
|
|
"scale=".$scale,
|
|
|
|
"maxfps=0",
|
|
|
|
"buffer=1000"
|
|
|
|
) );
|
|
|
|
} else {
|
|
|
|
$streamSrc =
|
|
|
|
getStreamSrc( array(
|
|
|
|
"mode=jpeg",
|
|
|
|
"monitor=".$monitor,
|
|
|
|
"scale=".$scale,
|
|
|
|
"maxfps=".$fps,
|
|
|
|
"buffer=1000"
|
|
|
|
) );
|
|
|
|
}
|
2010-11-11 06:20:29 +08:00
|
|
|
noCacheHeaders();
|
|
|
|
xhtmlHeaders( __FILE__, "Stream" );
|
2010-11-12 12:26:31 +08:00
|
|
|
logXml("Streaming MJPEG on Monitor ".$monitor.", ".$width."x".$height." @".$fps."fps");
|
2011-04-19 08:09:20 +08:00
|
|
|
echo "<meta name=\"viewport\" content=\"width=".$width."\" />\n";
|
2010-11-11 06:20:29 +08:00
|
|
|
echo "<body>\n";
|
|
|
|
echo "<div style=\"border: 0px solid; padding: 0px; background-color: black; position: absolute; top: 0px; left; 0px; margin: 0px; width: ".$width."px; height: ".$height."px;\">\n";
|
2010-11-19 03:09:51 +08:00
|
|
|
logXml("Using stream source: ".$streamSrc);
|
2010-11-11 06:20:29 +08:00
|
|
|
outputImageStream("liveStream", $streamSrc, $width, $height, "stream");
|
|
|
|
echo "</div></body></html>";
|
2010-11-12 12:26:31 +08:00
|
|
|
} else {
|
2010-11-19 03:07:37 +08:00
|
|
|
logXmlErr("Unsupported codec ".$vcodec." selected for streaming");
|
2010-11-13 07:04:09 +08:00
|
|
|
echo("Unsupported codec ".$vcodec." selected for streaming");
|
2010-11-11 06:20:29 +08:00
|
|
|
}
|
2010-11-06 00:48:57 +08:00
|
|
|
exit;
|
2010-11-06 07:41:09 +08:00
|
|
|
|
2011-02-20 04:25:22 +08:00
|
|
|
} else if (!strcmp($action, "vevent")) {
|
2010-11-19 03:07:37 +08:00
|
|
|
/* ACTION: View an event. Parms: <eid> [fps|vcodec|br] */
|
2010-11-06 00:48:57 +08:00
|
|
|
if (!canView('Events')) {
|
2010-11-19 03:07:37 +08:00
|
|
|
logXmlErr("User ".$user['Username']. " doesn't have view Events perms");
|
2010-11-06 00:48:57 +08:00
|
|
|
exit;
|
|
|
|
}
|
2010-11-06 07:41:09 +08:00
|
|
|
if (!isset($_GET['eid'])) {
|
2010-11-19 03:07:37 +08:00
|
|
|
logXmlErr("Not all parameters set for Action View-event");
|
2010-11-06 00:48:57 +08:00
|
|
|
exit;
|
|
|
|
}
|
2010-11-06 07:41:09 +08:00
|
|
|
/* Grab event from the database */
|
2011-02-20 04:25:22 +08:00
|
|
|
$eid = validInteger($_GET['eid']);
|
|
|
|
$eventsSql = "select E.Id, E.MonitorId, E.Name, E.StartTime, E.Length, E.Frames from Events as E where (E.Id = ".$eid.")";
|
|
|
|
$event = dbFetchOne(escapeSql($eventsSql));
|
|
|
|
/* Check if exists */
|
|
|
|
if (!$event) {
|
|
|
|
logxmlErr("Requested event ID ".$eid." does not exist");
|
|
|
|
exit;
|
|
|
|
}
|
2010-11-06 07:41:09 +08:00
|
|
|
/* Calculate FPS */
|
2011-02-20 04:25:22 +08:00
|
|
|
$fps = validInteger(getset('fps',ceil($event['Frames'] / $event['Length'])));
|
2011-02-20 04:25:54 +08:00
|
|
|
$vcodec = validString(getset('vcodec', ZM_EYEZM_EVENT_VCODEC));
|
2010-11-07 12:05:16 +08:00
|
|
|
$baseURL = ZM_PATH_WEB."/".getEventPathSafe($event);
|
2010-11-19 03:07:37 +08:00
|
|
|
/* Here we validate the codec.
|
2010-11-19 03:09:51 +08:00
|
|
|
* Check that FFMPEG exists and supports codecs */
|
2010-11-19 03:07:37 +08:00
|
|
|
if (!strcmp($vcodec, "mpeg4")) {
|
2010-11-19 03:09:51 +08:00
|
|
|
if (!ffmpegSupportsCodec("mpeg4")) {
|
|
|
|
logXmlErr("FFMPEG not installed, accessible in path/ZM_PATH_FFMPEG, or doesn't support mpeg4");
|
2010-11-19 03:07:37 +08:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
/* Can generate, we are good to go */
|
|
|
|
$fname = "capture.mov";
|
2011-02-20 04:25:54 +08:00
|
|
|
$ffparms = "-vcodec mpeg4 -r ".ZM_EYEZM_EVENT_FPS." ".$baseURL."/".$fname." 2> /dev/null";
|
2010-11-19 03:07:37 +08:00
|
|
|
|
|
|
|
} else if (!strcmp($vcodec, "h264")) {
|
2010-11-19 03:09:51 +08:00
|
|
|
if (!ffmpegSupportsCodec("libx264")) {
|
|
|
|
logXmlErr("FFMPEG not installed, accessible in path/ZM_PATH_FFMPEG, or doesn't support H264");
|
2010-11-19 03:07:37 +08:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
if (!requireVer("1","2")) {
|
|
|
|
logXmlErr("H264 Event viewing requires eyeZm v1.2 or greater");
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
/* Good to go */
|
|
|
|
$fname = "capture.mp4";
|
|
|
|
$ffparms = getFfmpeg264FoutParms(
|
2011-02-20 04:25:54 +08:00
|
|
|
validString(getset('br',ZM_EYEZM_H264_DEFAULT_EVBR)),
|
2010-11-19 03:07:37 +08:00
|
|
|
$baseURL."/".$fname);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
logXmlErr("Unknown codec ".$vcodec." selected for event viewing");
|
|
|
|
exit;
|
|
|
|
}
|
2010-11-19 03:09:51 +08:00
|
|
|
logXml("Selected ".$vcodec." for viewing event ".$event['Id']);
|
2010-11-19 03:07:37 +08:00
|
|
|
$fnameOut = $baseURL."/".$fname;
|
2010-12-30 20:35:14 +08:00
|
|
|
$shellCmd = getFfmpegPath()." -y -r ".$fps." -i ".$baseURL."/%0".ZM_EVENT_IMAGE_DIGITS."d-capture.jpg";
|
2010-11-19 03:07:37 +08:00
|
|
|
$shellCmd .= " ".$ffparms;
|
2010-11-12 12:26:31 +08:00
|
|
|
logXml("Encoding event with command: ".$shellCmd);
|
2010-11-06 00:48:57 +08:00
|
|
|
$shellOutput = shell_exec($shellCmd);
|
2010-11-19 03:07:37 +08:00
|
|
|
/* Check that file exists */
|
|
|
|
if (!file_exists(trim($fnameOut))) {
|
|
|
|
logXmlErr("Generate Event ".$event['Id']." file ".$fnameOut." does not exist");
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
$url = "./".getEventPathSafe($event)."/".$fname;
|
|
|
|
logXml("Loading Event URL ".$url);
|
2010-11-06 07:41:09 +08:00
|
|
|
header("Location: ".$url);
|
|
|
|
exit;
|
|
|
|
|
2011-02-20 04:25:22 +08:00
|
|
|
} else if (!strcmp($action, "vframe")) {
|
2011-04-19 08:09:20 +08:00
|
|
|
/* ACTION: View a frame given by an event and frame-id. Parms: <eid> <frame> [alarm | analyze | qty | scale]
|
2010-11-06 09:37:32 +08:00
|
|
|
* If 'alarm' is set, the returned frame will be the <frame>-th alarm frame. If 'analyze' is set,
|
|
|
|
* the returned frame will be the %03d-analyse frame instead of %03d-capture, if ZM_CREATE_ANALYSIS_IMAGES
|
2011-04-19 08:09:20 +08:00
|
|
|
* is set. Otherwise it just returns the captured frame.
|
|
|
|
* If qty is set, it will apply a quality factor from 0-100, and if width is set, it will scale the jpeg accordingly
|
|
|
|
*/
|
2010-11-06 07:41:09 +08:00
|
|
|
if (!isset($_GET['eid']) || !isset($_GET['frame'])) {
|
2010-11-19 03:07:37 +08:00
|
|
|
logXmlErr("Not all parameters set for action view-frame");
|
2010-11-06 07:41:09 +08:00
|
|
|
exit;
|
|
|
|
}
|
2011-02-20 04:25:22 +08:00
|
|
|
$eid = validInteger($_GET['eid']);
|
|
|
|
$frame = validInteger($_GET['frame']);
|
|
|
|
$eventsSql = "select E.Id, E.MonitorId, E.Name, E.StartTime, E.Length, E.Frames from Events as E where (E.Id = ".$eid.")";
|
|
|
|
$event = dbFetchOne(escapeSql($eventsSql));
|
2011-04-19 08:09:20 +08:00
|
|
|
$qty = validInteger(getset('qty', 100));
|
|
|
|
if ($qty > 100) $qty = 100;
|
|
|
|
$scale = validInteger(getset('scale', 100));
|
2011-02-20 04:25:22 +08:00
|
|
|
if (!$event) {
|
|
|
|
logxmlErr("Requested event ID ".$eid." does not exist");
|
|
|
|
exit;
|
|
|
|
}
|
2010-11-06 09:37:32 +08:00
|
|
|
/* Figure out the frame number. If 'alarm' is not set, this is just equal to the <frame> parameter.
|
|
|
|
* If 'alarm' is set, need to query DB and grab the <frame>-th item */
|
|
|
|
if (isset($_GET['alarm'])) {
|
2011-02-20 04:25:22 +08:00
|
|
|
$frameSql = escapeSql("select * from Frames as F where (F.EventId = ".$eid.") ");
|
|
|
|
$frameSql .= " and (F.Type = 'Alarm') order by F.FrameId";
|
2010-11-06 09:37:32 +08:00
|
|
|
$i=0;
|
|
|
|
foreach (dbFetchAll($frameSql) as $dbframe) {
|
2011-02-20 04:25:22 +08:00
|
|
|
if ($i == $frame) {
|
2010-11-06 09:37:32 +08:00
|
|
|
$frame = $dbframe['FrameId'];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
$i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (isset($_GET['analyze']) && ZM_CREATE_ANALYSIS_IMAGES) {
|
|
|
|
$suffix = "analyse";
|
|
|
|
} else {
|
|
|
|
$suffix = "capture";
|
2010-11-06 07:41:09 +08:00
|
|
|
}
|
2011-02-20 04:25:22 +08:00
|
|
|
/* A frame index of 0 is invalid, so if we see this, just use frame 1 */
|
|
|
|
if (!$frame) $frame = 1;
|
2010-11-06 09:37:32 +08:00
|
|
|
/* Suffix based on 'analyze' */
|
2010-12-30 20:35:14 +08:00
|
|
|
$fname = sprintf("%0".ZM_EVENT_IMAGE_DIGITS."d-%s.jpg", $frame, $suffix);
|
2010-11-07 12:05:16 +08:00
|
|
|
$url = "./".getEventPathSafe($event)."/".$fname;
|
2010-11-07 09:23:08 +08:00
|
|
|
if (!file_exists($url)) {
|
2011-04-19 08:09:20 +08:00
|
|
|
logXmlErr("Invalid frame image requested: ".$url);
|
2010-11-07 09:23:08 +08:00
|
|
|
$url = "./skins/xml/views/notfound.png";
|
|
|
|
}
|
2011-04-19 08:09:20 +08:00
|
|
|
/* Check if the image needs any processing - check for GD if requested */
|
|
|
|
if (($scale != 100) || ($qty < 100)) {
|
|
|
|
if (!gdExists()) {
|
|
|
|
logXmlErr("Lib GD is not loaded, but required for image scaling functions");
|
|
|
|
$url = "./skins/xml/views/notfound.png";
|
|
|
|
} else if (!$img = imagecreatefromjpeg($url)) {
|
|
|
|
logXmlErr("Could not load JPEG from ".$url);
|
|
|
|
$url = "./skins/xml/views/notfound.png";
|
|
|
|
} else {
|
|
|
|
/* GD exists and we read the file ok */
|
|
|
|
header('Content-type: image/jpeg');
|
|
|
|
/* Check if resizing is needed */
|
|
|
|
if ($scale != 100) {
|
|
|
|
list($width_orig, $height_orig) = getimagesize($url);
|
|
|
|
$width_new = $width_orig * ($scale/100);
|
|
|
|
$height_new = $height_orig * ($scale/100);
|
|
|
|
$img_new = imagecreatetruecolor($width_new, $height_new);
|
|
|
|
imagecopyresampled($img_new, $img, 0, 0, 0, 0, $width_new, $height_new, $width_orig, $height_orig);
|
|
|
|
imagejpeg($img_new, NULL, $qty);
|
|
|
|
} else {
|
|
|
|
imagejpeg($img, NULL, $qty);
|
|
|
|
}
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
}
|
2010-11-06 07:41:09 +08:00
|
|
|
header("Location: ".$url);
|
|
|
|
exit;
|
|
|
|
|
2011-02-20 04:25:22 +08:00
|
|
|
} else if (!strcmp($action, "state")) {
|
2010-11-06 07:41:09 +08:00
|
|
|
/* ACTION: Change the state of the system. Parms: <state> */
|
2010-11-06 00:48:57 +08:00
|
|
|
if (!canEdit('System')) {
|
2010-11-19 03:07:37 +08:00
|
|
|
logXmlErr("User ".$user['Username']. " doesn't have edit System perms");
|
2010-11-06 00:48:57 +08:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
if (!isset($_GET['state'])) {
|
2010-11-19 03:07:37 +08:00
|
|
|
logXmlErr("Server state not specified for action");
|
2010-11-06 00:48:57 +08:00
|
|
|
exit;
|
|
|
|
}
|
2011-02-20 04:25:22 +08:00
|
|
|
$url = "./index.php?view=none&action=state&runState=".validString($_GET['state']);
|
2010-11-06 00:48:57 +08:00
|
|
|
header("Location: ".$url);
|
|
|
|
exit;
|
2010-11-06 07:41:09 +08:00
|
|
|
|
2011-02-20 04:25:22 +08:00
|
|
|
} else if (!strcmp($action, "func")) {
|
2010-11-06 07:41:09 +08:00
|
|
|
/* ACTION: Change state of the monitor. Parms: <mid><func><en> */
|
2010-11-06 00:48:57 +08:00
|
|
|
if (!canEdit('Monitors')) {
|
2010-11-19 03:07:37 +08:00
|
|
|
logXmlErr("User ".$user['Username']. " doesn't have monitors Edit perms");
|
2010-11-06 00:48:57 +08:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
if (!isset($_GET['mid']) || !isset($_GET['func']) || !isset($_GET['en'])) {
|
2010-11-19 03:07:37 +08:00
|
|
|
logXmlErr("Not all parameters specified for action Monitor state");
|
2010-11-06 00:48:57 +08:00
|
|
|
exit;
|
|
|
|
}
|
2011-02-20 04:25:22 +08:00
|
|
|
$mid = validInteger($_GET['mid']);
|
|
|
|
if (!isMonitor($mid)) exit;
|
|
|
|
$url = "./index.php?view=none&action=function&mid=".$mid."&newFunction=".validString($_GET['func'])."&newEnabled=".validString($_GET['en']);
|
2010-11-06 00:48:57 +08:00
|
|
|
header("Location: ".$url);
|
|
|
|
exit;
|
2011-02-20 04:25:22 +08:00
|
|
|
|
|
|
|
} else if (!strcmp($action, "vlog")) {
|
2010-11-19 03:09:18 +08:00
|
|
|
/* ACTION: View log file. Must have debug and log to file enabled, and sufficient perms
|
|
|
|
* Parms: [lines] */
|
|
|
|
if (!canEdit('System')) {
|
|
|
|
logXmlErr("Insufficient permissions to view log file");
|
|
|
|
echo "Insufficient permissions to view log file";
|
|
|
|
exit;
|
|
|
|
}
|
2011-02-20 04:25:54 +08:00
|
|
|
if (!ZM_EYEZM_DEBUG || !ZM_EYEZM_LOG_TO_FILE) {
|
|
|
|
echo "eyeZm Debug (EYEZM_DEBUG) or log-to-file (EYEZM_LOG_TO_FILE) not enabled. Please enable first";
|
2010-11-19 03:09:18 +08:00
|
|
|
exit;
|
|
|
|
}
|
2011-02-20 04:25:54 +08:00
|
|
|
if (!file_exists(ZM_EYEZM_LOG_FILE)) {
|
|
|
|
echo "Log file ".ZM_EYEZM_LOG_FILE." doesn't exist";
|
2010-11-19 03:09:18 +08:00
|
|
|
exit;
|
|
|
|
}
|
2011-02-20 04:25:54 +08:00
|
|
|
$lines = validInteger(getset('lines',ZM_EYEZM_LOG_LINES));
|
|
|
|
logXml("Returning last ".$lines." lines of eyeZm Log from ".ZM_EYEZM_LOG_FILE);
|
|
|
|
echo shell_exec("tail -n ".$lines." ".ZM_EYEZM_LOG_FILE);
|
2010-11-19 03:09:18 +08:00
|
|
|
echo "\n\n--- Showing last ".$lines." lines ---\n";
|
|
|
|
echo "--- End of Log ---\n\n";
|
2010-11-06 00:48:57 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|