Commit Graph
122 Commits
Author SHA1 Message Date
Jash e6f61fda43 fix: archive and unarchive report events they could not change refs #6837 2026-11-19 13:33:41 +05:30
Jash 1d5c473575 fix: sort the events list by StorageId when asked to sort by Storage refs #6588 2026-11-17 12:08:49 +05:30
Jash da07e5def3 fix: handle scalar and array request params in events/status ajax, page the last slow-path page and skip deleted monitors in counts refs #6413 2026-11-16 14:55:08 +05:30
Isaac Connor b9c2e1fcf7 Merge pull request #5976 from AJ0070/event-delete-result
fix: report refused or failed event deletes
2026-11-15 11:27:09 -05:00
Isaac Connor ee167773e1 Merge pull request #5540 from AJ0070/5539-events-tag-request
fix: filter the events list on Tags for a Tag request value
2026-11-15 10:31:30 -05:00
Jash e20a2f58eb fix: report a refused or failed event delete instead of success refs #5975 2026-11-15 12:54:58 +05:30
Jash fb933326c7 perf: page the events list in SQL instead of fetching every event fixes #5535 2026-11-15 09:49:31 +05:30
Jash d2487dafef fix: include the monitor name in the events list search refs #5898 2026-11-14 22:49:50 +05:30
Jash 0b7efd4b9b fix: accept Tag=0 in an events list request so it lists untagged events refs #5539 2026-11-14 21:21:10 +05:30
Jash 4426f3f637 fix: filter the events list on Tags for a Tag request value fixes #5539 2026-11-14 21:21:10 +05:30
Isaac ConnorandClaude Opus 5.5 fca88d3b19 fix: report the whole search result as the events total, not the page refs #5417
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>
2026-11-01 17:19:47 -05:00
Isaac ConnorandClaude Opus 5.5 e8298d91cb fix: leave out deleted monitors' events in the events query, not after paging refs #5417
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>
2026-11-01 17:19:32 -05:00
Isaac ConnorandClaude Opus 5 696b479a88 fix: qualify the remaining logger calls in the web ui, and test for them
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
2026-10-28 18:01:26 -05:00
Isaac ConnorandClaude Opus 4.8 08b32b58db fix: coerce request event ids to a plain id before constructing ZM\Event
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>
2026-10-23 23:55:50 -04:00
Isaac ConnorandClaude Opus 5.5 44339b0fe7 fix: authorize event delete, archive and edits on the event's monitor refs GHSA-34x2-mw89-c52f
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>
2026-09-28 19:34:36 -04:00
Isaac ConnorandClaude Opus 4.8 52a398c472 feat: constrain events list to attribute-filtered monitors refs #4976
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>
2026-07-19 21:43:11 -04:00
Isaac ConnorandClaude Opus 4.8 50a60b107d fix: report empty events as zero-span in events ajax and montage query
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>
2026-07-16 15:55:45 -04:00
Isaac Connor b23aac4665 Merge branch 'master' of github.com:ZoneMinder/zoneminder 2026-06-11 14:21:54 -04:00
Isaac Connor d5feebc5fb feat: build per-column directional ORDER BY for event list via Filter::buildSortSql 2026-06-10 00:01:27 -04:00
Isaac Connor 5f623078cd feat: parse comma-separated event sort expressions with NULLs-last idiom 2026-06-09 13:10:13 -04:00
IgorA100 2bbb80b056 Merge branch 'master' into patch-180448 2026-06-04 10:19:52 +03:00
Steve GilvarryandClaude Opus 4.8 0538bd48fc fix: apply filter result limit when an empty Tags term is present
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>
2026-06-04 00:08:34 +10:00
IgorA100 964ea784fc - Do not check the M3u8 file if currentView === 'frames'
- 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.
2026-05-26 19:23:59 +03:00
IgorA100 11a9218748 Use $event->Duration() instead of "($event->EndDateTimeSecs() - $event->StartDateTimeSecs())" (events.php) 2026-05-24 00:46:44 +03:00
Isaac ConnorandClaude Opus 4.7 214aa7bfa0 fix: only emit HLS/duration attrs for events with video (events.php)
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>
2026-05-23 09:19:29 -04:00
IgorA100 c4417c81b8 The "data-video-hls-src" attribute should always reference the "index.m3u8" manifest file, even if the physical file is missing. (events.php)
This will reduce the load on the file system.
2026-05-21 18:56:04 +03:00
IgorA100 c794364d32 Added the "data-video-duration-secs" attribute to VIDEO (events.php) 2026-05-19 23:28:51 +03:00
IgorA100 2d1788357b Add a link to playback the recorded event using HLS to the IMG tag if there is an index.m3u8 file. (events.php) 2026-05-17 01:19:37 +03:00
Isaac Connor 327b8d4a89 Merge branch 'master' of github.com:ZoneMinder/zoneminder 2026-05-14 07:40:14 -04:00
Isaac ConnorandClaude Opus 4.7 7b9c1ee1d2 fix: derive event end time from Length when EndDateTime is missing
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>
2026-05-14 06:46:01 -04:00
Isaac Connor 644716b4ea fix: sanitize reflected user input in ajax error messages
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.
2026-05-13 22:54:02 -04:00
Isaac Connor 5ee5ba17c0 fix: do not return SQL error text to client in events ajax
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.
2026-05-13 16:51:38 -04:00
Isaac Connor 7cac112c69 fix: remove reflected user input from events ajax XSS sinks
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.
2026-05-13 16:11:16 -04:00
Isaac ConnorandClaude Opus 4.6 99f766e187 fix: sort events by Tags column alias, not T.Name
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>
2026-04-16 15:35:11 -04:00
Isaac Connor 39ab3b225e Fix width=>Width 2026-03-11 16:25:54 -04:00
Isaac Connor 15807eb419 Handle event having no width or height 2026-03-11 16:25:49 -04:00
Isaac ConnorandClaude Opus 4.6 61b025b85f fix: calculate optimal thumbnail overlay scale from monitor dimensions
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>
2026-02-26 12:16:56 -05:00
Ben DaileyandClaude Opus 4.5 fd5bd63808 feat: add status bar to thumbnail overlay with LIVE indicator and wall clock time
- 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>
2026-01-28 21:09:57 -05:00
Ben DaileyandClaude Opus 4.5 8d655af63f feat: replace in-place thumbnail zoom with centered overlay popout
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>
2026-01-27 17:12:25 -05:00
Isaac Connor 1ac5e0ddc1 Add footer to the events table with sum of diskspace and duration in it. 2026-01-22 22:17:42 -05:00
Simpler1 3a0d8d7c8f Fix(tags): "No Tag" filter now works properly. 2025-12-08 15:09:01 -05:00
Isaac Connor 7f9cde76b5 More gracefully handle NaN so that hopefully the real error won't get lost in the noise 2025-06-19 17:03:38 -04:00
Isaac Connor d42040d7c3 Add grouping by Monitor. Apparently mysql is complaining about not having it now. 2024-11-27 13:54:24 -05:00
Isaac Connor 0f722c11fc Notes can be null and should not be passed to htmlspecialchars 2024-09-06 15:00:46 -04:00
Simpler1 b166fdb840 fix(): Comment debug statement 2024-04-10 15:21:59 -04:00
Simpler1 ebf1e8b1cc Fix(filter): Set tags operator to = instead of LIKE 2024-04-10 15:14:36 -04:00
Isaac Connor ef926f4437 Return an array of string error messages instead of an array of arrays of arrays in deleting events. 2024-01-18 13:15:25 -05:00
Isaac Connor ea3d91b46f Actually fix problem by not putting () on an integer has-post_sql_conditions 2023-12-14 09:32:32 -05:00
Isaac Connor d910585ed9 Be a little more specific about what we are int'ing. https://forums.zoneminder.com/viewtopic.php?t=32942 has a weird error report that this might address 2023-12-13 19:39:11 -05:00
Isaac Connor 8e0793f5e7 Do not format StartDateTime and EndDateTime in ajax events results. Do the formatting in js. 2023-11-16 10:34:43 -05:00