Example #1
0
function getNearEvents()
{
    global $user, $sortColumn, $sortOrder;
    $eventId = $_REQUEST['id'];
    $event = dbFetchOne('select * from Events where Id = ?', NULL, array($eventId));
    parseFilter($_REQUEST['filter']);
    parseSort();
    if ($user['MonitorIds']) {
        $midSql = " and MonitorId in (" . join(",", preg_split('/["\'\\s]*,["\'\\s]*/', $user['MonitorIds'])) . ")";
    } else {
        $midSql = '';
    }
    $sql = "select E.* 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');
    $result = dbQuery($sql);
    while ($id = dbFetchNext($result, 'Id')) {
        if ($id == $eventId) {
            $prevEvent = dbFetchNext($result);
            break;
        }
    }
    $sql = "select E.* 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}";
    $result = dbQuery($sql);
    while ($id = dbFetchNext($result, 'Id')) {
        if ($id == $eventId) {
            $nextEvent = dbFetchNext($result);
            break;
        }
    }
    $result = array('EventId' => $eventId);
    $result['PrevEventId'] = empty($prevEvent) ? 0 : $prevEvent['Id'];
    $result['NextEventId'] = empty($nextEvent) ? 0 : $nextEvent['Id'];
    $result['PrevEventDefVideoPath'] = empty($prevEvent) ? 0 : getEventDefaultVideoPath($prevEvent);
    $result['NextEventDefVideoPath'] = empty($nextEvent) ? 0 : getEventDefaultVideoPath($nextEvent);
    return $result;
}
Example #2
0
    return;
}
if (!empty($_REQUEST['execute'])) {
    executeFilter($tempFilterName);
}
$countSql = 'SELECT count(E.Id) AS EventCount FROM Monitors AS M INNER JOIN Events AS E ON (M.Id = E.MonitorId) WHERE';
$eventsSql = 'SELECT E.Id,E.MonitorId,M.Name AS MonitorName,M.DefaultScale,E.Name,E.Width,E.Height,E.Cause,E.Notes,E.StartTime,E.Length,E.Frames,E.AlarmFrames,E.TotScore,E.AvgScore,E.MaxScore,E.Archived FROM Monitors AS M INNER JOIN Events AS E on (M.Id = E.MonitorId) WHERE';
if ($user['MonitorIds']) {
    $user_monitor_ids = ' M.Id in (' . $user['MonitorIds'] . ')';
    $countSql .= $user_monitor_ids;
    $eventsSql .= $user_monitor_ids;
} else {
    $countSql .= " 1";
    $eventsSql .= " 1";
}
parseSort();
parseFilter($_REQUEST['filter']);
$filterQuery = $_REQUEST['filter']['query'];
if ($_REQUEST['filter']['sql']) {
    $countSql .= $_REQUEST['filter']['sql'];
    $eventsSql .= $_REQUEST['filter']['sql'];
}
$eventsSql .= " ORDER BY {$sortColumn} {$sortOrder}";
if (isset($_REQUEST['page'])) {
    $page = validInt($_REQUEST['page']);
} else {
    $page = 0;
}
if (isset($_REQUEST['limit'])) {
    $limit = validInt($_REQUEST['limit']);
} else {
Example #3
0
    $_REQUEST['view'] = "error";
    return;
}
$midSql = '';
if ($user['MonitorIds']) {
    $midSql = " and MonitorId in (" . join(",", preg_split('/["\'\\s]*,["\'\\s]*/', $user['MonitorIds'])) . ")";
}
$sql = 'select E.*,M.Name as MonitorName,M.Width,M.Height from Events as E inner join Monitors as M on E.MonitorId = M.Id where E.Id = ?' . $midSql;
$event = dbFetchOne($sql, NULL, array($_REQUEST['eid']));
if (!empty($_REQUEST['fid'])) {
    $frame = dbFetchOne('SELECT * FROM Frames WHERE EventID = ? AND FrameId = ?', NULL, array($_REQUEST['eid'], $_REQUEST['fid']));
} elseif (isset($_REQUEST['fid'])) {
    $frame = dbFetchOne('SELECT * FROM Frames WHERE EventID = ? AND Score = ?', NULL, array($_REQUEST['eid'], $event['MaxScore']));
    $_REQUEST['fid'] = $frame['FrameId'];
}
parseSort(true, '&amp;');
parseFilter($_REQUEST['filter'], true, '&amp;');
$filterQuery = $_REQUEST['filter']['query'];
if ($sortOrder == 'asc') {
    $sql = "select E.* from Events as E inner join Monitors as M on E.MonitorId = M.Id where {$sortColumn} <= ?" . $_REQUEST['filter']['sql'] . $midSql . " order by {$sortColumn} desc";
} else {
    $sql = "select E.* from Events as E inner join Monitors as M on E.MonitorId = M.Id where {$sortColumn} >= ?" . $_REQUEST['filter']['sql'] . $midSql . " order by {$sortColumn} asc";
}
$result = dbQuery($sql, array($event[$_REQUEST['sort_field']]));
while ($row = dbFetchNext($result)) {
    if ($row['Id'] == $_REQUEST['eid']) {
        $prevEvent = dbFetchNext($result);
        break;
    }
}
$sql = "select E.* from Events as E inner join Monitors as M on E.MonitorId = M.Id where {$sortColumn} " . ($sortOrder == 'asc' ? '>=' : '<=') . ' ?' . $_REQUEST['filter']['sql'] . $midSql . " order by {$sortColumn} {$sortOrder}";