Commit Graph
137 Commits
Author SHA1 Message Date
Jash a8cd088df4 fix: frame TimeStampShort uses a MySQL format and the frame's own time refs #6563 2026-11-17 10:02:34 +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
singhharsh1708 d3f7098ecc fix: event status for a recording event formats a null end time 2026-11-16 04:00:10 +05:30
Isaac Connor 598a84f3b5 Merge pull request #5689 from AJ0070/zmu-credentials-escaping
fix: stop escapeshellcmd mangling escaped zmu and daemon arguments
2026-11-15 11:24:34 -05:00
Isaac Connor cfae90a186 Merge pull request #5753 from AJ0070/php8-array-params
fix: avoid PHP 8 TypeErrors from request params of the wrong type
2026-11-14 23:33:01 -05:00
Isaac Connor feb3c663ab Merge pull request #5721 from AJ0070/status-fix
perf: bound status events/frames lists and load the monitor once
2026-11-14 23:31:30 -05:00
Isaac Connor 79309d35e5 Merge pull request #5725 from AJ0070/status-stale-cols
fix: remove dropped DefaultView from status monitor elements
2026-11-14 19:55:58 -05:00
Jash 80b619a361 fix: return an error for an unknown status entity instead of a TypeError refs #5752 2026-11-14 23:55:50 +05:30
Jash 93b08a1848 fix: avoid TypeError in status FrameRate when id is an array refs #5752 2026-11-14 23:55:50 +05:30
Jash 06122bdf7c perf: default to a LIMIT for status events and frames lists refs #5720 2026-11-14 23:09:15 +05:30
Jash 054952a15d perf: build the Monitor once for status entity=monitor refs #5720 2026-11-14 23:09:15 +05:30
Jash b00e2b5b08 fix: find prev and next events in ascending order when sorting by a column other than Id or StartDateTime refs #5774 2026-11-14 18:16:29 +05:30
Jash 47f0891918 fix: remove dropped Monitors.DefaultView from status monitor elements refs #5724 2026-11-14 17:46:33 +05:30
Jash cd4531655e fix: stop escapeshellcmd mangling escaped zmu and daemon arguments fixes #5688 2026-11-13 13:43:59 +05:30
Jash fd449b822d perf: read the monitor state from shared memory in the status poll instead of running zmu fixes #5543 2026-11-11 23:01:58 +05:30
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 0b53412f8f fix: don't constrain prev/next events by StartDateTime when sorting by another field
getNearEvents() built the prev/next query from the full (sort value, Id) tuple,
which already orders events strictly in the chosen sort, but then also added
AND E.StartDateTime >= / <= the current event's time. That extra predicate is
only consistent when the sort field is StartDateTime. When events are sorted by
another field -- MonitorName to group cameras, or Id -- it dropped events that
are correctly next in that order but started earlier or later than the current
one: the next monitor's first event (which often started before the current
monitor's last), or a concurrently recorded event with a higher Id. Gapless
playback then skipped over the events of every monitor but the first.

A fresh, single-timeline database rarely shows this because Id order tracks
time order; a database with several monitors recording in parallel, or one
migrated from another system, makes the two diverge and exposes it.

Drop the StartDateTime constraint and let the tuple be the whole ordering. It
cannot reintroduce the earlier playback loop because (sort value, Id) is a
strict total order. refs #4186

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-20 08:06:24 -04:00
Isaac Connor db9ba436b7 fix: break sort-value ties by Id when finding prev/next events
getNearEvents compared only the sort column with >= / <= and excluded the
current event, using Id solely as a secondary ORDER BY. When several events
share a sort value - most often StartDateTime, which has one-second
resolution, with multiple monitors recording in step - the later event of
a tie chose the earlier one as its Next. Event playback, gapless or not,
then looped between the two and the Next button could not escape.

Compare the full (sort value, Id) tuple so ordering is strict in both
directions. Read the current event's sort value through the same
Events/Monitors join as the searches, which also makes Prev/Next work
when sorting by MonitorName (the value was previously looked up in the
Events row and was always NULL).
2026-09-28 07:55:57 -04:00
Isaac ConnorandClaude Opus 5 33661907d1 feat: persist the peak audio level on each frame row
zm_update-1.39.31.sql gave monitors audio detection, but the level only ever
existed in shared memory, so it was gone the moment the frame passed and there
was nothing for the event view to plot. Add Frames.AudioLevel next to Score, on
the same 0-100 dBFS-derived scale the threshold uses.

What is stored is the peak since the previous row, not the level at the instant
the row was written. Frames rows are written well below the capture rate --
only alarm, bulk and score-increasing frames get one -- so sampling at write
time would drop exactly the short loud noises worth seeing on a timeline.
AudioDetector accumulates the peak as it decodes and Event::AddFrame takes it
where the row is built, which clears it so each row covers its own interval.
The Event constructor takes and discards it once, otherwise an event's first
row reports the loudest moment since the previous event ended.

This needs no shared memory change: zma is now an offline re-analysis tool and
the live analysis runs in a thread of zmc, alongside the capture thread that
runs the decoder, so the peak can stay in the AudioDetector. SharedData keeps
its documented 888-byte layout and its fixed offsets.

The frames ajax returns the column, and Score with it. elements in
web/ajax/status.php is a whitelist that never listed Score, which is why the
event view's cue strip has been reading an undefined Score off every frame.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JpiSWBmtQkR5bcgpHWY4ME
2026-09-20 18:17:43 -05:00
singhharsh1708 aad6c4bfcb refactor: retire the FrameSkip column refs #3570 2026-09-02 20:28:37 +05:30
IgorA100 35151e0a4b Added $data['getLogStatusHTML'] = logState() (status.php) 2026-06-08 20:37:34 +03:00
Isaac ConnorandClaude Opus 4.6 191130dcf3 fix: validate eventId in getNearEvents() in ajax/status.php
Apply validCardinal() to $_REQUEST['id'], consistent with the
validation now used in getNearFrame() and getFrameImage().

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 16:52:26 -05:00
Isaac ConnorandClaude Opus 4.6 24a2126def fix: validate eventId and frameId in getNearFrame() in ajax/status.php
Apply validCardinal() to $_REQUEST['id'] values, consistent with
getFrameImage() which already validates the same kind of inputs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 16:50:59 -05:00
Isaac ConnorandClaude Opus 4.6 89c358a6c0 fix: remove print_r object dump from permission error in ajax/status.php
The canView() failure path was dumping the entire Monitor object via
print_r() into the AJAX error response. This leaked all monitor
properties (Host, Path, ControlAddress, etc.) to users who fail the
permission check. Replace with a minimal error message containing
only the entity type and id.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 15:26:25 -05:00
Isaac ConnorandClaude Opus 4.6 0392d0ef27 fix: add early per-object canView() check in ajax/status.php
The monitor entity's func/zmu elements (Status, FrameRate) execute
in the element loop before the post-SQL canView() check, allowing
any authenticated user to query any monitor via zmu commands.

Add an early permission check after the id is determined but before
the element processing loop. When the entity spec has an 'object'
key and an id is provided, construct the object and call canView()
which respects per-group and per-role permissions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 14:44:42 -05:00
Isaac ConnorandClaude Opus 4.6 e163d3b9b8 fix: replace eval() with call_user_func() in ajax/status.php
Replace all four eval() call sites with call_user_func(). Entity-level
funcs (getFrameImage, getNearFrame, getNearEvents) are now callable
strings. Element-level funcs (daemonCheck, getLoad, getDiskPercent)
are now closures. postFunc handlers use call_user_func with $sqlData
passed as the argument.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 14:11:58 -05:00
Isaac ConnorandClaude Opus 4.6 1d89736b65 fix: harden ORDER BY sort field validation in ajax/status.php
The sort field whitelist check compared bare field names against
$fieldSql entries that could be backtick-wrapped or aliased SQL
expressions, so the check would often fail to match legitimate
fields.  When it failed, execution fell through to append the sort
direction (ASC/DESC) without a field name, producing malformed SQL.
The error log call also passed the wrong variable to join().

Rewrite the sort handling to:
- Skip invalid fields with continue instead of falling through
- Match field names against bare, backtick-wrapped, and aliased forms
- Collect valid ORDER BY clauses into an array before appending
- Backtick-wrap field names in the output SQL
- Only append ORDER BY when valid clauses exist

Also parameterize the prev-event sort comparison in getNearEvents()
and add the missing sort_field bind parameter to both prev and next
event queries.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 14:02:15 -05:00
Isaac Connor 52b7c47fd4 Fix Secondary Order SQL Infection in via Stored Event Name and Cause Fields. Fixes GHSA-r6gm-478g-f2c4 2026-02-06 13:58:27 -05:00
Isaac Connor ffeec4cdec Add E.Id != and use >= and <= when comparing StartDateTime so that we don't skip events with the same startDateTime. Fixes #4186 2024-12-09 17:27:56 -05:00
Isaac Connor 359330b384 When loading prev/next event, sort by StartDateTime, not Id. Id's are not guaranteed to be time-wise sequential. Maybe Fixes #4186 2024-11-27 13:55:50 -05:00
Isaac Connor 51ad77c6b9 Always add auth_relay info to status requests 2024-06-06 18:10:23 -04:00
Isaac Connor ad6a8c376b Add new auth_hash to any status request. Fixed auth timeout when using rtsp2web or janus 2024-06-06 17:51:05 -04:00
Isaac Connor f9ea031581 Merge branch 'patch-6' of github.com:IgorA100/zoneminder into IgorA100-patch-6 2024-03-14 17:15:46 -04:00
Isaac Connor 5120baa9ee Implement object permissions vs entity permissions so that we can handle the new group based permissions on Monitors. This fixes status updates when MOnitors=None but there is a per-monitor group based view permission. 2024-03-05 14:00:23 -05:00
IgorA100 cd8ffa08dc Add getCpuUsageHTML() 2024-02-27 16:49:29 +03:00
Isaac Connor 9669f1e3ef Sanitize entity before outputting it preventing XSS 2024-01-24 19:22:47 -05:00
Isaac Connor e9362f1a10 Fix duplicated Capturing in monitor status elements. Add Recording. Fix MinEventId, MaxEventId, TotalEvents. Ad CaptureFPS, AnalysisFPS and CaptureBandwidth 2024-01-02 16:28:49 -05:00
Isaac Connor 23a0e561eb Remove depth of nested if's by returning early. 2023-11-21 10:49:09 -05:00
Isaac Connor 50ece0ae57 Turn off debugging of status ajax results. Can be a lot of info and can be gotten from browser dev tools 2023-10-26 09:25:45 -04:00
Isaac Connor f8c89a0405 Merge branch 'master' into tags 2023-09-14 16:42:06 -04:00
Isaac Connor b44216d3da Merge branch 'master' of github.com:ZoneMinder/zoneminder 2023-09-08 14:19:09 -04:00
Isaac Connor 473d34e220 Update events frameimage status code to use Event object. Make not finding the frame a debug because of bulk frames. 2023-09-08 14:17:36 -04:00
Simpler1 18d74ed7ac (feat): Tags
fix(tag): Create tags on mobile

chore(tags): Change TagName to Name

chore(tags): eslint

chore(tags): dbFetchAll to dbQuery for removetag

chore(events): eslint (attempt 2)

feat(tags): Better handling of keyboard

fix(tags): Enter key for creating new tag

fix(tags): Don't allow space as a tag name

feat(tags): Delete tag if last assignment removed

fix(tags): Increase height of dropdown

in progress

fix(Tags): Use T.Id on the events page dropdown

fix(Tags): Remove $availableTags from events.php

chore(sql): Formatting sql statements

feat(Tags): Working OR on filters and events pages

fix(filter): Populate availableTags

chore(Tags): code formatting

fix(tag): Add tag on create tag

Fix(tags): Remove tag from available if last

feat(tags): Add zm_update.sql

fix(chosen): Undo css width

fix(chosen): tags dropdown width

fix(tags): dropdown over timeline

fix(tags): Full width input

fix(events): Refresh table on page show

chore(filter): Clean up availableTags

chore(event): Clean up available & selected Tags

fix(event): Update available tags on remove

fix(event): Remove hack for selected tags

feat(tags): Blur input after adding tag

doc(tags): Initial tags documentation

fix(tags): Dark theme dropdown

fix(tags): Dark theme for tags on input

fix(tags): Dark theme for highlight in dropdown

fix(tags): Populate filter tags droplist

chore(): Bump zm_update to 1.37.42

chore(tags): Move mobile check to skin.js

chore(tags): Comment debug statements

fix(tags): Enter key to create tag on mobile Chome

chore(tags): Space in 'All Tags' for translation

Temporary commit to handle cookie expiration times

chore(tags): Remove unnecessary Tag(s) from en_gb

chore(): Cleanup unnecessary Error and Debug

chore(): Resolve merge conflicts

chore(): Address merge conflicts with master
2023-08-31 15:50:08 -04:00
Alejandro Criado-Pérez 6fd119157a Text corrections 2023-08-27 02:00:59 +02:00
Isaac Connor d31f918abc Change the api for frameimage status request to split id into eid and fid instead of having id as an array. 2023-08-15 09:15:24 -04:00
Isaac Connor 03155da5b6 Use the full integer value instead of the first char of mi. Fixes failure to get status on janus viewing pages 2023-07-25 15:18:35 -04:00
Isaac Connor 59ff7f3a31 Improve logged wrt insufficient permissions 2023-06-08 09:17:16 -04:00
Isaac Connor 969baa3891 Convert user from an array to a User object 2023-04-23 12:57:29 -04:00
Isaac Connor 1c538a4bf0 Include Capturing, Analysing, Recording instead of Function 2022-12-14 08:28:21 -05:00
Isaac Connor 0a28a3e659 Add check for REQUEST['entity']. Add missing quotes around state word because it gets executed as code 2022-12-12 13:06:13 -05:00