With the search or advanced search box in use, the total was counted after
the rows were cut down to the requested page, so it equalled the page size
and the table could not page through the results. Count them first.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Events list hid events of soft-deleted monitors (Monitors.Deleted) while
building the rows, after the filter limit, the page slice and the totals. Pages
came up short, the footer counted and summed events that were never listed,
and a filter limit counted hidden events too.
Exclude M.Deleted in both SELECTs of queryRequest() so the limit, paging and
totals only see listed events, and drop the per-row skip. The new test runs
queryRequest() against the database inside a rolled-back transaction.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Looking for other instances of the CronTab.php fatal in the previous commit
found eleven, in ten files, dating from 2019 to 2023. Each is a call to a
logger function from the global namespace without the \ZM\ prefix, so each is
a fatal the moment its branch runs:
web/ajax/console.php, events.php, reports.php, add_monitors.php, status.php
web/includes/actions/snapshot.php (two), donate.php
web/includes/functions.php, session.php
web/views/image.php
They have survived this long because of where they sit. Every one is on an
error or diagnostic path -- an invalid sort order, a zero byte download, a
failed read lock -- so the call is only reached when something has already
gone wrong, and then it turns a handled problem into a blank 500. That is the
shape of the bug on the monitor save: the write had worked, and the thing that
broke was the attempt to log.
Verified before changing any of them that each file is in the global
namespace, does not define the function itself and does not import it, so the
call really does not resolve.
Tests: tests/php/test_logger_calls_qualified.php, 16 checks. It tokenizes
every php file under web/ and reports unqualified calls, with the function
names read out of logger.php rather than listed, so a new one is covered the
day it is added. web/api is skipped as cakephp with its own logging, and
assets as third party.
Php's own tokenizer rather than a regex, because the distinctions matter: a
method call on an object that happens to have an Error() method is fine, as
is a definition, a mention, a qualified call, the same call from inside
namespace ZM, and the name appearing in a comment or a string. There is a
check for each of those, since a scan that quietly matched nothing would pass
the tree-wide check on its own.
Verified the scan fails when the Debug() in CronTab.php is put back.
Ran: tests/php/test_logger_calls_qualified.php (16 passed), the rest of
tests/php and tests/js, npx eslint . (clean), utils/check-homoglyphs.py
(clean). test_bandwidth_clamp.php fails on this box for an unrelated reason:
it cannot read /etc/zm/conf.d/03custom.conf and the permission warning lands
in its captured output.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JpiSWBmtQkR5bcgpHWY4ME
ZM_Object's constructor takes either an id (which it loads from the database)
or an array, which it trusts as the record's own fields. Several request-fed
call sites passed the raw request value straight to new ZM\Event(), so a request
that sends an array instead of a scalar -- eid[Id]=...&eid[MonitorId]=... -- had
its fields adopted as the event row. The request then chose the MonitorId that
canView() checks and the StorageId/Scheme/Id that Path() is built from.
Impact: view_video.php turned this into an arbitrary file read (forge a viewable
MonitorId, point Path() at any directory, append file=); ajax/events.php let a
forged row pass the per-event permission check so archive/delete acted on a row
the user could not see, and delete ran unlink on the forged Path().
validInt()/validCardinal() already return '' for a non-scalar, so route the
request value through them first; an array becomes '' and ZM\Event loads the
real row (or none). Fixed at the two affected sinks and centrally in
getAffectedIds(), which several action handlers use to build the id list.
Addresses GHSA-6h8f-gx4m-qqw4.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The classic event actions checked only the global Events permission and
then acted on whatever event ids the request supplied, so a user denied a
monitor could still change that monitor's events:
- deleteEvent() deleted when the user had Events=Edit. It now requires
Event::canEdit(), which also requires access to the event's monitor.
This covers the events form, the event form and monitor deletion.
- The events form archive/unarchive updated Events by id. Each event now
needs canEdit().
- ajax events archiveRequest() updated by id under the page-wide Events
view check. Archive now needs canView() on the event and unarchive
canEdit(), keeping the intent that viewers may archive.
- actions/event.php returned early whenever an eid was supplied, so none
of its actions ran. Fix that inverted test, and require canEdit() on the
event for rename, detail edits, archive, unarchive and delete, rather
than the global permission.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The monitor-attribute filters (Status/Capturing/Analysing/Recording/ServerId/
StorageId/MonitorName/Source) shared via the zmFilter_* cookies have no Events
column, so they can't be event filter terms. Add getFilteredMonitorIds() which
resolves them to the set of viewable monitor ids (mirroring buildMonitorsFilters,
intersected with visibleMonitor), returning null when none is active. The events
query path (ajax/events.php) adds a MonitorId IN (...) term from it, so a monitor
selection made on the console now narrows the events list too. Group and Monitor
remain first-class event terms and are excluded from the resolver.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
web/ajax/events.php and the montagereview.php event query carried the same
EndTimeSecs fallback just fixed in the Event API model: an event with no
EndDateTime and Length 0 (an empty crash-orphaned event) reported its end
as NOW(), so it appeared to span from its start until now and overlapped
every later event.
Change the ELSE branch of both the EndDateTime and EndTimeSecs CASE
expressions from NOW() to StartDateTime, so an empty event has no span.
Both columns are changed together so a single row stays consistent.
Verified against the database: for a Length-0 event with no EndDateTime the
CASE now yields EndTimeSecs == StartTimeSecs, while length-based and
properly-closed events are unaffected.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The event filter "Limit to first N" stopped being honored in 1.38. Using
"List Matches" on a filter that should return N events returned all
matching events instead. This was a regression from 1.36, triggered by
the Tags feature.
Root cause chain:
1. The events view adds a default, empty `Tags` term to unsaved filters.
That term is invalid (empty value) so Filter::sql() correctly omits it
from the WHERE clause, but pre_sql_conditions()/post_sql_conditions()
counted it regardless of validity.
2. Tags was classified as a post-sql condition, even though it is filtered
in SQL (sql_attr() returns T.Id, with EXISTS/NOT EXISTS for any/no tag)
and its post-sql test() was a no-op stub. So the empty Tags term made
has_post_sql_conditions true.
3. has_post_sql_conditions being true disabled the SQL LIMIT fast-path in
ajax/events.php, leaving the PHP-side trim as the only limit enforcement
-- and that trim used an inverted comparison (limit > row count), so it
never trimmed when there were more rows than the limit.
Fixes:
- Filter::pre_sql_conditions()/post_sql_conditions() now require
term->valid(), so empty default terms no longer count as conditions and
the SQL LIMIT fast-path stays enabled.
- FilterTerm::is_post_sql() no longer returns true for Tags, since Tags is
handled in SQL.
- ajax/events.php filter-limit trim comparison corrected to '<' so the
limit is applied when there are more matches than the limit (matches the
pagination trim below it). This covers genuine post-sql filters such as
ExistsInFileSystem.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- When executing Length() and Duration() , do not write the result to the database.
- When assigning a value to the "data-video-duration-secs" attribute, first check the Length in $row['Length'] and, if it is 0, only then check the file's Duration.
- If the M3u8 file is missing or invalid, do not cache the server response.
Move data-video-hls-src and data-video-duration-secs inside the
DefaultVideo() guard so jpeg-only events don't get an HLS hint that
would fail at playback. Also parenthesize the duration subtraction —
PHP string-concat / subtract precedence was computing
("'.start) - (end.'"') rather than (end - start).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
When zmc is killed or crashes without writing EndDateTime, three code
paths invent a fake end of NOW(), so an event from hours ago appears to
extend across the entire down-time. Montage review then paints a bar
that makes it look like recorded video exists where it doesn't.
Length is flushed to the DB every few seconds during recording, so even
crashed events have an accurate last-known duration. Fall back to
StartDateTime + Length when EndDateTime IS NULL, and only fall back to
NOW() when Length is also 0 (event has no recorded data yet).
- web/api/app/Model/Event.php: EndTimeSecs and EndTime virtual fields,
which is what the montagereview JS actually reads via the API.
- web/ajax/events.php: same fix in the AJAX events list SQL.
- web/skins/classic/views/montagereview.php: \$eventsSql kept in sync
even though it is no longer executed directly.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Earlier commits in this branch dropped reflected user input from
ajaxError() messages entirely to close Snyk XSS findings, but that
lost useful diagnostic information ("Unrecognised action <name>",
"Insufficient permissions for user <user>"). Use validHtmlStr()
(htmlspecialchars with ENT_QUOTES) so the values still appear in
the message and Snyk recognises the sanitization. Affects
add_monitors.php, device.php, event.php, events.php, log.php.
ajaxError(dbError(\$sql)) leaked the failing SQL statement (which
contains user-controlled filter/search terms) to the response body.
Log the SQL error server-side, return a generic message to the
client.
Four sites in events.php reflected user-controlled data into
ajaxError() / ZM\\Fatal() — three "Insufficient permissions for user
<name>" messages and the default-task handler echoing $_REQUEST['task'].
Replace with static messages; the task value is still logged
server-side via ZM\\Warning.
queryRequest translated sort=Tags into ORDER BY T.Name, but T.Name is
not guaranteed to be in scope — the query groups by event and the
Tags column exposed to the client is an aggregate alias. Use that
alias so the sort operates on the value the user actually sees.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add data-monitor-width and data-monitor-height attributes to thumbnail
img elements in console.php, events.php, watch.php, and monitor.php.
Use these to calculate the scale parameter as a ratio of overlay size to
monitor native resolution, clamped to 5-100%, instead of hardcoding
scale=75 (overlay) and scale=32 (fallback).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add status bar below video with LIVE indicator for live streams
- Show pulsing red dot animation for live streams
- Display wall clock time that updates as recorded video plays
- Add event start time data attribute to console and events pages
- Hide status bar when no content to display
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Thumbnail hover now creates a separate overlay element centered
on-screen instead of transforming the original thumbnail in place.
The overlay shows the cached still image as a background for instant
display, with the stream or video layered on top.
When an event has an mp4 file (DefaultVideo), the overlay uses a
<video> tag at 5x playback speed for smooth hardware-decoded
playback. Falls back to MJPEG <img> stream with scale=32 when
no mp4 is available. On mouseout the stream/video connection is
explicitly stopped before the overlay is removed.
Removes the old .zoom/.zoom-console CSS classes and the console
overflow workarounds that were needed for the in-place approach.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>