2008-07-14 21:54:50 +08:00
< ? php
2017-12-07 23:31:25 +08:00
if ( $_REQUEST [ 'entity' ] == 'navBar' ) {
2018-02-14 23:44:48 +08:00
$data = array ();
if ( ZM_OPT_USE_AUTH && ZM_AUTH_RELAY == 'hashed' ) {
2018-02-15 02:15:22 +08:00
$data [ 'auth' ] = generateAuthHash ( ZM_AUTH_HASH_IPS );
2018-02-14 23:44:48 +08:00
}
2018-02-15 00:57:45 +08:00
$data [ 'message' ] = getNavBarHtml ( 'reload' );
2018-02-14 23:44:48 +08:00
ajaxResponse ( $data );
return ;
2017-11-30 12:04:38 +08:00
}
2008-07-14 21:54:50 +08:00
$statusData = array (
2017-11-04 03:09:19 +08:00
'system' => array (
'permission' => 'System' ,
'table' => 'Monitors' ,
'limit' => 1 ,
'elements' => array (
2017-12-07 23:31:25 +08:00
'MonitorCount' => array ( 'sql' => 'count(*)' ),
2017-11-04 03:09:19 +08:00
'ActiveMonitorCount' => array ( 'sql' => " count(if(Function != 'None',1,NULL)) " ),
2017-12-07 23:31:25 +08:00
'State' => array ( 'func' => 'daemonCheck()?' . translate ( 'Running' ) . ':' . translate ( 'Stopped' ) ),
'Load' => array ( 'func' => 'getLoad()' ),
'Disk' => array ( 'func' => 'getDiskPercent()' ),
2008-07-14 21:54:50 +08:00
),
2016-06-27 22:26:37 +08:00
),
2017-11-04 03:09:19 +08:00
'monitor' => array (
'permission' => 'Monitors' ,
'table' => 'Monitors' ,
'limit' => 1 ,
2017-12-07 23:31:25 +08:00
'selector' => 'Monitors.Id' ,
2017-11-04 03:09:19 +08:00
'elements' => array (
2017-12-07 23:31:25 +08:00
'Id' => array ( 'sql' => 'Monitors.Id' ),
'Name' => array ( 'sql' => 'Monitors.Name' ),
2017-11-04 03:09:19 +08:00
'Type' => true ,
'Function' => true ,
'Enabled' => true ,
'LinkedMonitors' => true ,
'Triggers' => true ,
'Device' => true ,
'Channel' => true ,
'Format' => true ,
'Host' => true ,
'Port' => true ,
'Path' => true ,
2017-12-07 23:31:25 +08:00
'Width' => array ( 'sql' => 'Monitors.Width' ),
'Height' => array ( 'sql' => 'Monitors.Height' ),
2017-11-04 03:09:19 +08:00
'Palette' => true ,
'Orientation' => true ,
'Brightness' => true ,
'Contrast' => true ,
'Hue' => true ,
'Colour' => true ,
'EventPrefix' => true ,
'LabelFormat' => true ,
'LabelX' => true ,
'LabelY' => true ,
'LabelSize' => true ,
'ImageBufferCount' => true ,
'WarmupCount' => true ,
'PreEventCount' => true ,
'PostEventCount' => true ,
'AlarmFrameCount' => true ,
'SectionLength' => true ,
'FrameSkip' => true ,
'MotionFrameSkip' => true ,
'MaxFPS' => true ,
'AlarmMaxFPS' => true ,
'FPSReportInterval' => true ,
'RefBlendPerc' => true ,
'Controllable' => true ,
'ControlId' => true ,
'ControlDevice' => true ,
'ControlAddress' => true ,
'AutoStopTimeout' => true ,
'TrackMotion' => true ,
'TrackDelay' => true ,
'ReturnLocation' => true ,
'ReturnDelay' => true ,
'DefaultView' => true ,
'DefaultRate' => true ,
'DefaultScale' => true ,
'WebColour' => true ,
'Sequence' => true ,
2017-12-07 23:31:25 +08:00
'MinEventId' => array ( 'sql' => '(SELECT min(Events.Id) FROM Events WHERE Events.MonitorId = Monitors.Id' ),
'MaxEventId' => array ( 'sql' => '(SELECT max(Events.Id) FROM Events WHERE Events.MonitorId = Monitors.Id' ),
'TotalEvents' => array ( 'sql' => '(SELECT count(Events.Id) FROM Events WHERE Events.MonitorId = Monitors.Id' ),
'Status' => array ( 'zmu' => '-m ' . escapeshellarg ( $_REQUEST [ 'id' ][ 0 ]) . ' -s' ),
'FrameRate' => array ( 'zmu' => '-m ' . escapeshellarg ( $_REQUEST [ 'id' ][ 0 ]) . ' -f' ),
2008-07-14 21:54:50 +08:00
),
2016-06-27 22:26:37 +08:00
),
2017-11-04 03:09:19 +08:00
'events' => array (
'permission' => 'Events' ,
'table' => 'Events' ,
2017-12-07 23:31:25 +08:00
'selector' => 'Events.MonitorId' ,
2017-11-04 03:09:19 +08:00
'elements' => array (
'Id' => true ,
'Name' => true ,
'Cause' => true ,
'Notes' => true ,
'StartTime' => true ,
'StartTimeShort' => array ( 'sql' => " date_format( StartTime, ' " . MYSQL_FMT_DATETIME_SHORT . " ' ) " ),
'EndTime' => true ,
'Width' => true ,
'Height' => true ,
'Length' => true ,
'Frames' => true ,
'AlarmFrames' => true ,
'TotScore' => true ,
'AvgScore' => true ,
'MaxScore' => true ,
2016-06-27 22:26:37 +08:00
),
),
2017-11-04 03:09:19 +08:00
'event' => array (
'permission' => 'Events' ,
'table' => 'Events' ,
'limit' => 1 ,
2017-12-07 23:31:25 +08:00
'selector' => 'Events.Id' ,
2017-11-04 03:09:19 +08:00
'elements' => array (
2017-12-07 23:31:25 +08:00
'Id' => array ( 'sql' => 'Events.Id' ),
2017-11-04 03:09:19 +08:00
'MonitorId' => true ,
2017-12-07 23:31:25 +08:00
'MonitorName' => array ( 'sql' => '(SELECT Monitors.Name FROM Monitors WHERE Monitors.Id = Events.MonitorId)' ),
2017-11-04 03:09:19 +08:00
'Name' => true ,
'Cause' => true ,
'StartTime' => true ,
'StartTimeShort' => array ( 'sql' => " date_format( StartTime, ' " . MYSQL_FMT_DATETIME_SHORT . " ' ) " ),
'EndTime' => true ,
'Width' => true ,
'Height' => true ,
'Length' => true ,
'Frames' => true ,
'DefaultVideo' => true ,
'AlarmFrames' => true ,
'TotScore' => true ,
'AvgScore' => true ,
'MaxScore' => true ,
'Archived' => true ,
'Videoed' => true ,
'Uploaded' => true ,
'Emailed' => true ,
'Messaged' => true ,
'Executed' => true ,
'Notes' => true ,
2017-12-07 23:31:25 +08:00
'MinFrameId' => array ( 'sql' => '(SELECT min(Frames.FrameId) FROM Frames WHERE EventId=Events.Id)' ),
'MaxFrameId' => array ( 'sql' => '(SELECT max(Frames.FrameId) FROM Frames WHERE Events.Id = Frames.EventId)' ),
'MinFrameDelta' => array ( 'sql' => '(SELECT min(Frames.Delta) FROM Frames WHERE Events.Id = Frames.EventId)' ),
'MaxFrameDelta' => array ( 'sql' => '(SELECT max(Frames.Delta) FROM Frames WHERE Events.Id = Frames.EventId)' ),
2016-06-27 22:26:37 +08:00
),
),
2017-11-17 10:03:03 +08:00
'frames' => array (
'permission' => 'Events' ,
'table' => 'Frames' ,
'selector' => 'EventId' ,
'elements' => array (
'EventId' => true ,
'FrameId' => true ,
'Type' => true ,
'Delta' => true ,
),
),
2017-11-04 03:09:19 +08:00
'frame' => array (
'permission' => 'Events' ,
'table' => 'Frames' ,
'limit' => 1 ,
2017-12-08 00:18:10 +08:00
'selector' => array ( array ( 'table' => 'Events' , 'join' => 'Events.Id = Frames.EventId' , 'selector' => 'Events.Id' ), 'Frames.FrameId' ),
2017-11-04 03:09:19 +08:00
'elements' => array (
2017-12-07 23:31:25 +08:00
//'Id' => array( 'sql' => 'Frames.FrameId' ),
2017-11-04 03:09:19 +08:00
'FrameId' => true ,
'EventId' => true ,
'Type' => true ,
'TimeStamp' => true ,
'TimeStampShort' => array ( 'sql' => " date_format( StartTime, ' " . MYSQL_FMT_DATETIME_SHORT . " ' ) " ),
'Delta' => true ,
'Score' => true ,
//'Image' => array( 'postFunc' => 'getFrameImage' ),
2016-06-27 22:26:37 +08:00
),
),
2017-11-04 03:09:19 +08:00
'frameimage' => array (
'permission' => 'Events' ,
2017-12-07 23:31:25 +08:00
'func' => 'getFrameImage()'
2016-06-27 22:26:37 +08:00
),
2017-11-04 03:09:19 +08:00
'nearframe' => array (
'permission' => 'Events' ,
2017-12-07 23:31:25 +08:00
'func' => 'getNearFrame()'
2016-06-27 22:26:37 +08:00
),
2017-11-04 03:09:19 +08:00
'nearevents' => array (
'permission' => 'Events' ,
2017-12-07 23:31:25 +08:00
'func' => 'getNearEvents()'
2016-06-27 22:26:37 +08:00
)
);
2008-07-14 21:54:50 +08:00
2016-06-27 22:26:37 +08:00
function collectData () {
global $statusData ;
2008-07-14 21:54:50 +08:00
2016-06-27 22:26:37 +08:00
$entitySpec = & $statusData [ strtolower ( validJsStr ( $_REQUEST [ 'entity' ]))];
#print_r( $entitySpec );
if ( ! canView ( $entitySpec [ 'permission' ] ) )
ajaxError ( 'Unrecognised action or insufficient permissions' );
2008-07-14 21:54:50 +08:00
2016-06-27 22:26:37 +08:00
if ( ! empty ( $entitySpec [ 'func' ]) ) {
2017-12-07 23:31:25 +08:00
$data = eval ( 'return( ' . $entitySpec [ 'func' ] . " ); " );
2016-06-27 22:26:37 +08:00
} else {
$data = array ();
$postFuncs = array ();
2008-07-14 21:54:50 +08:00
2016-06-27 22:26:37 +08:00
$fieldSql = array ();
$joinSql = array ();
$groupSql = array ();
2008-07-14 21:54:50 +08:00
2016-06-27 22:26:37 +08:00
$elements = & $entitySpec [ 'elements' ];
$lc_elements = array_change_key_case ( $elements );
2008-07-14 21:54:50 +08:00
2016-06-27 22:26:37 +08:00
$id = false ;
if ( isset ( $_REQUEST [ 'id' ]) )
if ( ! is_array ( $_REQUEST [ 'id' ]) )
$id = array ( validJsStr ( $_REQUEST [ 'id' ]) );
else
$id = array_values ( $_REQUEST [ 'id' ] );
2008-07-14 21:54:50 +08:00
2016-06-27 22:26:37 +08:00
if ( ! isset ( $_REQUEST [ 'element' ]) )
$_REQUEST [ 'element' ] = array_keys ( $elements );
else if ( ! is_array ( $_REQUEST [ 'element' ]) )
$_REQUEST [ 'element' ] = array ( validJsStr ( $_REQUEST [ 'element' ]) );
2008-07-14 21:54:50 +08:00
2016-06-27 22:26:37 +08:00
if ( isset ( $entitySpec [ 'selector' ]) ) {
if ( ! is_array ( $entitySpec [ 'selector' ]) )
$entitySpec [ 'selector' ] = array ( $entitySpec [ 'selector' ] );
foreach ( $entitySpec [ 'selector' ] as $selector )
if ( is_array ( $selector ) && isset ( $selector [ 'table' ]) && isset ( $selector [ 'join' ]) )
2017-12-07 23:31:25 +08:00
$joinSql [] = 'left join ' . $selector [ 'table' ] . ' on ' . $selector [ 'join' ];
2016-06-27 22:26:37 +08:00
}
2008-07-14 21:54:50 +08:00
2016-06-27 22:26:37 +08:00
foreach ( $_REQUEST [ 'element' ] as $element ) {
if ( ! ( $elementData = $lc_elements [ strtolower ( $element )]) )
2017-12-07 23:31:25 +08:00
ajaxError ( 'Bad ' . validJsStr ( $_REQUEST [ 'entity' ]) . ' element ' . $element );
2016-06-27 22:26:37 +08:00
if ( isset ( $elementData [ 'func' ]) )
2017-12-07 23:31:25 +08:00
$data [ $element ] = eval ( 'return( ' . $elementData [ 'func' ] . " ); " );
2016-06-27 22:26:37 +08:00
else if ( isset ( $elementData [ 'postFunc' ]) )
$postFuncs [ $element ] = $elementData [ 'postFunc' ];
else if ( isset ( $elementData [ 'zmu' ]) )
2017-12-07 23:31:25 +08:00
$data [ $element ] = exec ( escapeshellcmd ( getZmuCommand ( ' ' . $elementData [ 'zmu' ] ) ) );
2016-06-27 22:26:37 +08:00
else {
if ( isset ( $elementData [ 'sql' ]) )
2017-12-07 23:31:25 +08:00
$fieldSql [] = $elementData [ 'sql' ] . ' as ' . $element ;
2016-06-27 22:26:37 +08:00
else
$fieldSql [] = $element ;
if ( isset ( $elementData [ 'table' ]) && isset ( $elementData [ 'join' ]) ) {
2017-12-07 23:31:25 +08:00
$joinSql [] = 'left join ' . $elementData [ 'table' ] . ' on ' . $elementData [ 'join' ];
2016-06-27 22:26:37 +08:00
}
if ( isset ( $elementData [ 'group' ]) ) {
$groupSql [] = $elementData [ 'group' ];
2008-07-14 21:54:50 +08:00
}
2016-06-27 22:26:37 +08:00
}
}
2008-07-14 21:54:50 +08:00
2016-06-27 22:26:37 +08:00
if ( count ( $fieldSql ) ) {
2017-12-07 23:31:25 +08:00
$sql = 'select ' . join ( ', ' , $fieldSql ) . ' from ' . $entitySpec [ 'table' ];
2016-06-27 22:26:37 +08:00
if ( $joinSql )
2017-12-07 23:31:25 +08:00
$sql .= ' ' . join ( ' ' , array_unique ( $joinSql ) );
2016-06-27 22:26:37 +08:00
if ( $id && ! empty ( $entitySpec [ 'selector' ]) ) {
$index = 0 ;
$where = array ();
$values = array ();
foreach ( $entitySpec [ 'selector' ] as $selector ) {
if ( is_array ( $selector ) ) {
$where [] = $selector [ 'selector' ] . ' = ?' ;
$values [] = validInt ( $id [ $index ]);
} else {
$where [] = $selector . ' = ?' ;
$values [] = validInt ( $id [ $index ]);
}
$index ++ ;
}
2017-12-07 23:31:25 +08:00
$sql .= ' where ' . join ( ' and ' , $where );
2016-06-27 22:26:37 +08:00
}
if ( $groupSql )
2017-12-07 23:31:25 +08:00
$sql .= ' GROUP BY ' . join ( ',' , array_unique ( $groupSql ) );
2016-06-27 22:26:37 +08:00
if ( ! empty ( $_REQUEST [ 'sort' ]) )
2017-12-07 23:31:25 +08:00
$sql .= ' order by ' . $_REQUEST [ 'sort' ];
2016-06-27 22:26:37 +08:00
if ( ! empty ( $entitySpec [ 'limit' ]) )
$limit = $entitySpec [ 'limit' ];
elseif ( ! empty ( $_REQUEST [ 'count' ]) )
$limit = validInt ( $_REQUEST [ 'count' ]);
2017-12-07 23:31:25 +08:00
$limit_offset = '' ;
2016-06-27 22:26:37 +08:00
if ( ! empty ( $_REQUEST [ 'offset' ]) )
2017-12-07 23:31:25 +08:00
$limit_offset = validInt ( $_REQUEST [ 'offset' ]) . ', ' ;
2016-06-27 22:26:37 +08:00
if ( ! empty ( $limit ) )
2017-12-07 23:31:25 +08:00
$sql .= ' limit ' . $limit_offset . $limit ;
2016-06-27 22:26:37 +08:00
if ( isset ( $limit ) && $limit == 1 ) {
if ( $sqlData = dbFetchOne ( $sql , NULL , $values ) ) {
foreach ( $postFuncs as $element => $func )
$sqlData [ $element ] = eval ( 'return( ' . $func . '( $sqlData ) );' );
$data = array_merge ( $data , $sqlData );
}
} else {
$count = 0 ;
foreach ( dbFetchAll ( $sql , NULL , $values ) as $sqlData ) {
foreach ( $postFuncs as $element => $func )
$sqlData [ $element ] = eval ( 'return( ' . $func . '( $sqlData ) );' );
$data [] = $sqlData ;
if ( isset ( $limi ) && ++ $count >= $limit )
break ;
2008-07-14 21:54:50 +08:00
}
2016-06-27 22:26:37 +08:00
}
2008-07-14 21:54:50 +08:00
}
2016-06-27 22:26:37 +08:00
}
#print_r( $data );
return ( $data );
2008-07-14 21:54:50 +08:00
}
$data = collectData ();
2016-06-27 22:26:37 +08:00
if ( ! isset ( $_REQUEST [ 'layout' ]) ) {
2017-11-04 03:09:19 +08:00
$_REQUEST [ 'layout' ] = 'json' ;
2008-07-14 21:54:50 +08:00
}
2016-06-27 22:26:37 +08:00
switch ( $_REQUEST [ 'layout' ] ) {
case 'xml NOT CURRENTLY SUPPORTED' :
2008-07-14 21:54:50 +08:00
{
2016-06-27 22:26:37 +08:00
header ( " Content-type: application/xml " );
2017-12-13 04:46:50 +08:00
echo ( '<?xml version="1.0" encoding="iso-8859-1"?>' . " \n " );
echo '<' . strtolower ( $_REQUEST [ 'entity' ]) . " > \n " ;
2016-06-27 22:26:37 +08:00
foreach ( $data as $key => $value ) {
$key = strtolower ( $key );
echo " < $key > " . htmlentities ( $value ) . " </ $key > \n " ;
}
2017-12-13 04:46:50 +08:00
echo '</' . strtolower ( $_REQUEST [ 'entity' ]) . " > \n " ;
2016-06-27 22:26:37 +08:00
break ;
2008-07-14 21:54:50 +08:00
}
2016-06-27 22:26:37 +08:00
case 'json' :
2008-07-14 21:54:50 +08:00
{
2016-06-27 22:26:37 +08:00
$response = array ( strtolower ( validJsStr ( $_REQUEST [ 'entity' ])) => $data );
if ( isset ( $_REQUEST [ 'loopback' ]) )
$response [ 'loopback' ] = validJsStr ( $_REQUEST [ 'loopback' ]);
ajaxResponse ( $response );
break ;
2008-07-14 21:54:50 +08:00
}
2016-06-27 22:26:37 +08:00
case 'text' :
2008-07-14 21:54:50 +08:00
{
2017-12-13 04:46:50 +08:00
header ( 'Content-type: text/plain' );
2017-12-07 23:31:25 +08:00
echo join ( ' ' , array_values ( $data ) );
2016-06-27 22:26:37 +08:00
break ;
2008-07-14 21:54:50 +08:00
}
}
2016-06-27 22:26:37 +08:00
function getFrameImage () {
$eventId = $_REQUEST [ 'id' ][ 0 ];
$frameId = $_REQUEST [ 'id' ][ 1 ];
2008-07-14 21:54:50 +08:00
2016-06-27 22:26:37 +08:00
$sql = 'select * from Frames where EventId = ? and FrameId = ?' ;
if ( ! ( $frame = dbFetchOne ( $sql , NULL , array ( $eventId , $frameId ) )) ) {
$frame = array ();
$frame [ 'EventId' ] = $eventId ;
$frame [ 'FrameId' ] = $frameId ;
2017-11-04 03:09:19 +08:00
$frame [ 'Type' ] = 'Virtual' ;
2016-06-27 22:26:37 +08:00
}
$event = dbFetchOne ( 'select * from Events where Id = ?' , NULL , array ( $frame [ 'EventId' ] ) );
$frame [ 'Image' ] = getImageSrc ( $event , $frame , SCALE_BASE );
return ( $frame );
2008-07-14 21:54:50 +08:00
}
2016-06-27 22:26:37 +08:00
function getNearFrame () {
$eventId = $_REQUEST [ 'id' ][ 0 ];
$frameId = $_REQUEST [ 'id' ][ 1 ];
2008-07-14 21:54:50 +08:00
2016-06-27 22:26:37 +08:00
$sql = 'select FrameId from Frames where EventId = ? and FrameId <= ? order by FrameId desc limit 1' ;
if ( ! $nearFrameId = dbFetchOne ( $sql , 'FrameId' , array ( $eventId , $frameId ) ) ) {
$sql = 'select * from Frames where EventId = ? and FrameId > ? order by FrameId asc limit 1' ;
if ( ! $nearFrameId = dbFetchOne ( $sql , 'FrameId' , array ( $eventId , $frameId ) ) ) {
return ( array () );
2008-07-14 21:54:50 +08:00
}
2016-06-27 22:26:37 +08:00
}
2017-11-04 03:09:19 +08:00
$_REQUEST [ 'entity' ] = 'frame' ;
2016-06-27 22:26:37 +08:00
$_REQUEST [ 'id' ][ 1 ] = $nearFrameId ;
return ( collectData () );
2008-07-14 21:54:50 +08:00
}
2016-06-27 22:26:37 +08:00
function getNearEvents () {
global $user , $sortColumn , $sortOrder ;
2008-07-14 21:54:50 +08:00
2016-06-27 22:26:37 +08:00
$eventId = $_REQUEST [ 'id' ];
2017-11-04 03:09:19 +08:00
$event = dbFetchOne ( 'SELECT * FROM Events WHERE Id=?' , NULL , array ( $eventId ) );
2008-07-14 21:54:50 +08:00
2016-06-27 22:26:37 +08:00
parseFilter ( $_REQUEST [ 'filter' ] );
parseSort ();
2008-07-14 21:54:50 +08:00
2016-06-27 22:26:37 +08:00
if ( $user [ 'MonitorIds' ] )
2017-12-07 23:31:25 +08:00
$midSql = ' and MonitorId in (' . join ( ',' , preg_split ( '/["\'\s]*,["\'\s]*/' , $user [ 'MonitorIds' ] ) ) . ')' ;
2016-06-27 22:26:37 +08:00
else
$midSql = '' ;
2008-07-14 21:54:50 +08:00
2018-01-29 06:30:49 +08:00
# When listing, it may make sense to list them in descending order. But when viewing Prev should timewise earlier and Next should be after.
if ( $sortColumn == 'E.Id' or $sortColumn == 'E.StartTime' ) {
$sortOrder = 'asc' ;
}
2017-11-04 03:09:19 +08:00
$sql = " SELECT E.Id AS Id, E.StartTime AS StartTime FROM Events AS E INNER JOIN Monitors AS M ON E.MonitorId = M.Id WHERE $sortColumn " . ( $sortOrder == 'asc' ? '<=' : '>=' ) . " ' " . $event [ $_REQUEST [ 'sort_field' ]] . " ' " . $_REQUEST [ 'filter' ][ 'sql' ] . $midSql . " ORDER BY $sortColumn " . ( $sortOrder == 'asc' ? 'desc' : 'asc' ) . ' LIMIT 2' ;
2016-06-27 22:26:37 +08:00
$result = dbQuery ( $sql );
while ( $id = dbFetchNext ( $result , 'Id' ) ) {
if ( $id == $eventId ) {
$prevEvent = dbFetchNext ( $result );
break ;
2008-07-14 21:54:50 +08:00
}
2016-06-27 22:26:37 +08:00
}
2008-07-14 21:54:50 +08:00
2017-11-04 03:09:19 +08:00
$sql = " SELECT E.Id AS Id, E.StartTime AS StartTime FROM Events AS E INNER JOIN Monitors AS M ON E.MonitorId = M.Id WHERE $sortColumn " . ( $sortOrder == 'asc' ? '>=' : '<=' ) . " ' " . $event [ $_REQUEST [ 'sort_field' ]] . " ' " . $_REQUEST [ 'filter' ][ 'sql' ] . $midSql . " ORDER BY $sortColumn $sortOrder LIMIT 2 " ;
2016-06-27 22:26:37 +08:00
$result = dbQuery ( $sql );
while ( $id = dbFetchNext ( $result , 'Id' ) ) {
if ( $id == $eventId ) {
$nextEvent = dbFetchNext ( $result );
break ;
2008-07-14 21:54:50 +08:00
}
2016-06-27 22:26:37 +08:00
}
2008-07-14 21:54:50 +08:00
2016-06-27 22:26:37 +08:00
$result = array ( 'EventId' => $eventId );
$result [ 'PrevEventId' ] = empty ( $prevEvent ) ? 0 : $prevEvent [ 'Id' ];
$result [ 'NextEventId' ] = empty ( $nextEvent ) ? 0 : $nextEvent [ 'Id' ];
2017-09-30 09:44:57 +08:00
$result [ 'PrevEventStartTime' ] = empty ( $prevEvent ) ? 0 : $prevEvent [ 'StartTime' ];
$result [ 'NextEventStartTime' ] = empty ( $nextEvent ) ? 0 : $nextEvent [ 'StartTime' ];
2017-10-07 23:56:15 +08:00
$result [ 'PrevEventDefVideoPath' ] = empty ( $prevEvent ) ? 0 : ( getEventDefaultVideoPath ( $prevEvent [ 'Id' ]));
$result [ 'NextEventDefVideoPath' ] = empty ( $nextEvent ) ? 0 : ( getEventDefaultVideoPath ( $nextEvent [ 'Id' ]));
2016-06-27 22:26:37 +08:00
return ( $result );
2008-07-14 21:54:50 +08:00
}
?>