Commit Graph
651 Commits
Author SHA1 Message Date
Isaac Connor 462f6acc21 Merge remote-tracking branch 'upstream/master' into deprecate-php7
# Conflicts:
#	web/ajax/stream.php
#	web/includes/actions/options.php
#	web/views/image.php
2026-11-22 09:22:34 -05:00
Isaac Connor 68e5c60e74 Merge pull request #7230 from AJ0070/fix-vernum-three-digit
fix: verNum pads each version field to four digits so 1.39.100 sorts before 1.40.0
2026-11-21 21:56:19 -05:00
Isaac Connor b01462a351 Merge pull request #7070 from AJ0070/fix-export-sort-keeps-selection
fix: export page keeps the selected events when sorting and builds a valid query for restricted users
2026-11-21 21:24:08 -05:00
Jash fd51b3333a fix: verNum pads each version field to four digits so 1.39.100 sorts before 1.40.0 refs #7229 2026-11-22 00:17:30 +05:30
Jash d2f5a42da3 fix: table locale follows the user's language instead of always the system default refs #7165 2026-11-21 23:09:11 +05:30
Jash 5169620d45 fix: export page keeps the selected events when sorting and builds a valid query for restricted users refs #7069 2026-11-21 21:54:33 +05:30
Jash b959839fc1 fix: device On/Off reports when the X10 unit doesn't answer refs #6839 2026-11-19 13:44:44 +05:30
Jash 4a4faedaa6 fix: match nothing instead of IN () when a user can view no monitors refs #6709 2026-11-18 19:00:16 +05:30
Isaac Connor 65140665e7 Merge pull request #6644 from IgorA100/patch-644419
Feat: Enhance zone type selector with localization, tooltips, and theme-aware color coding
2026-11-17 21:05:31 -05:00
Isaac Connor b85fa0ab9e Merge pull request #6331 from AJ0070/fix-zone-editor-legacy-pixels
fix: zone editor inputs for inactive zones, player change tracking and legacy pixel zones
2026-11-17 19:15:43 -05:00
IgorA100 94a1490066 HTML Helpers (htmlSelect / htmlOptions):
Added a reusable htmlAttributes() helper function to cleanly render arbitrary HTML attributes (such as title, data-*, and boolean attributes) on <select> and <option> elements without breaking backward compatibility.
Preserved existing htmlspecialchars() encoding flags (double_encode = false) to avoid double-encoding regressions.
-------------------------------------
Zone View (zone.php & Localization):
Replaced raw enum strings in the Zone Type dropdown with localized labels via translate() and added explanatory title tooltips for each zone type (Active, Inclusive, Exclusive, Preclusive, Inactive, Privacy).
Assigned semantic CSS classes (zone-type-*) to options and the initial <select> element.
-------------------------------------
Dynamic Styling (zone.js & Skin CSS):
Updated applyZoneType() to dynamically sync the selected option's color class with the <select> element on page load and change events (CSP-compliant, no inline JS).
Added theme-specific color rules for .zone-type-* across light and dark skins to ensure proper contrast and readability.
2026-11-17 23:40:00 +03:00
Isaac Connor 186d0be12c Merge pull request #6343 from AJ0070/fix-monitor-edit-form
fix: monitor edit unticked boxes on redraw, Speaker save, return location presets and zone thresholds on resize
2026-11-17 08:42:43 -05:00
Isaac Connor e887a6f937 Merge pull request #6611 from AJ0070/fix-url-credentials-at-in-path
fix: keep an @ in the URL path or query out of the camera credentials
2026-11-17 08:21:30 -05:00
Jash 345dc84bc0 fix: keep an @ in the URL path or query out of the camera credentials refs #6610 2026-11-17 12:56:38 +05:30
Jash 4a192ea2b3 fix: events delete audit counts only the events actually deleted refs #6539 2026-11-17 08:57:57 +05:30
Jash fc595636dc fix: sortHeader and sortTag match legacy sort field names refs #6433 2026-11-16 15:52:47 +05:30
Jash 8d2f007e98 fix: monitor edit unticked boxes on redraw, Speaker save, return location presets and zone thresholds on resize refs #6342 2026-11-16 11:55:53 +05:30
Jash dfdbf81a3f fix: zone editor inputs for inactive zones, player change tracking and legacy pixel zones refs #6330 2026-11-16 11:26:05 +05:30
Isaac Connor 10235ebb37 Merge pull request #6060 from AJ0070/get-networks-names
fix: get_networks interface and route parsing
2026-11-15 21:13:49 -05:00
Jash c81186c4b2 fix: list bridge and VLAN interfaces in get_networks and skip routes on unlisted devices refs #6059 2026-11-16 01:12:01 +05:30
Jash a76b5e9f81 fix: build daemonStatus and zmcStatus strings the way zmdc.pl prints them refs #6027 2026-11-16 00:35:57 +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
Jash 15c10f12ca fix: return empty string from request value helpers given an array refs #5752 2026-11-14 23:55:50 +05:30
Jash cd4531655e fix: stop escapeshellcmd mangling escaped zmu and daemon arguments fixes #5688 2026-11-13 13:43:59 +05:30
Jash 3f1907960a perf: ask zmdc.pl whether ZoneMinder is running once a request fixes #5537 2026-11-11 19:49:28 +05:30
Isaac ConnorandClaude Opus 5.5 2353e6b137 refactor: remove PHP 4/5/7 compatibility code
PHP 8.0 is now the minimum, so these branches can no longer run:

- functions.php: str_starts_with/str_ends_with/str_contains polyfills;
  zm_random_bytes() fallbacks to mcrypt and openssl (random_bytes() is
  always there).
- auth.php: the password_hash() check in migrateHash().
- session.php: pre-7.3 setcookie()/session_set_cookie_params() forms
  without samesite, and the pre-5.4 is_session_started().
- stream.php: blocking sem_acquire() for PHP < 5.6.1, and the PHP < 5.6
  half of the 64 bit event id unpack check (the 32 bit PHP_INT_SIZE half
  stays).
- database.php: the magic quotes branch of dbEscape();
  get_magic_quotes_gpc() was removed in PHP 8.
- logger.php: the PHP >= 5.2 guards around error_get_last().
- Event.php, ImageComponent.php: the PHP < 4.3.10 sprintf('%.3f').
- image.php: the imagedestroy() branch for PHP < 8.

database.php keeps its PHP_VERSION_ID >= 80100 check, as 8.0 is still
supported.

Tests: tests/php/test_php_minimum.php checks the declared minimum in
composer.json, the platform check, the rpm and deb dependencies, and that
no PHP 4/5/7 version check is left in the web code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 23:05:05 -05:00
Nic BoetandClaude Opus 5.5 96804bca31 fix: allow CORS only for exact server and same-host origins
CORSHeaders() (web UI) and AppController::beforeFilter() (API) send
Access-Control-Allow-Origin with Access-Control-Allow-Credentials: true.
With no Servers rows and ZM_MIN_STREAMING_PORT set they reflected any
Origin, and with Servers rows they matched the Origin against each
server's Hostname and Name with a regex anchored only at the start, so
https://zm.example.com.evil.net was accepted for zm.example.com.

Both now call corsAllowedOrigin() in Network.php, which accepts an
Origin of the form scheme://host[:port] whose host equals a server's
Hostname or Name, or, without Servers rows and with streaming ports,
the host this request was made to. Any port is accepted, so multi-port
streaming keeps working. Same-origin and unlisted origins get no CORS
headers, as before; the web UI still warns about unlisted origins only
when Servers rows exist.

Tests: tests/php/test_cors_allowed_origin.php

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 17:21:45 -05:00
Nic BoetandClaude Opus 5.5 49ab7682ea fix: keep the auth relay out of PHP warnings on failed remote requests
When the other server of a multi-server install did not answer,
file_get_contents() raised a PHP warning whose text is the call and its
URL, ?auth=<hash> or user=/pass= included, and PHP wrote it to the web
server's error log (Event.php, Filter.php). The same happened with the
image proxy's digest retry (camera user:password@) and the X-Frame
check of a website monitor (get_headers()), which also took the false
it returns on failure for an array.

Fetch with @ and log lastErrorForLog(), the reason without the call
and its URL, next to urlForLog() of the URL. Server::SendToApi()
already used @ and now logs the reason too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 10:27:39 -05:00
Nic BoetandClaude Opus 5.5 82ce0be4bd fix: restrict <base> to the same origin in the web CSP
The policy allows any script that carries the page nonce, wherever it is
loaded from, and the skin's nonced scripts use relative srcs. Markup
injected into a page before them (an unescaped request value) could add
<base href> pointing at another host, and the browser then loaded and
ran that host's script with the nonce.

Add base-uri 'self'. ZoneMinder doesn't use <base>; jQuery's parseHTML
sets one to the page's own URL in a detached document, which 'self'
still allows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 23:01:19 -04:00
Isaac Connor 55248b88f7 Merge pull request #5391 from connortechnology/fix/ghsa-7hhq-stream-owner
fix: name zms command sockets after the user the stream serves (GHSA-7hhq)
2026-10-31 17:04:34 -04:00
Nic BoetandClaude Opus 4.8 1d6dcff83b fix: name zms command sockets after the user the stream serves refs GHSA-7hhq-xw65-4crf
ajax/stream.php sends stream commands (query, pause, seek, zoom, quit)
to the zms whose unix socket matches a connkey, with no permission
check. Connkeys are six random digits chosen when the stream starts,
so any logged-in user who guessed or saw one could read the status of
another user's stream, of a monitor they may not view included, and
pause or end it. A second zms started with the same connkey also waited
on the first one's lock and then took over its socket.

zms already authenticates the user and checks their access to the
monitor or event before it streams. Keep that user's id and put it in
the lock, command socket and reply socket names
(zms-<connkey>-<user id>s.sock); stream.php builds the names from the
caller's own id through zmsSocketPath(), so a request reaches only the
caller's streams. Without authentication the id is 0 on both sides.

Adds a StreamBase test in tests/zm_stream.cpp and
tests/php/test_zms_socket_path.php, which pin the same names. The
existing command-socket-teardown test is updated for the owner-suffixed
names (it postdates the reporter's base commit).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-31 11:11:01 -04:00
Nic Boet 35e36e4dda fix: give zmu a short-lived token instead of the password or auth hash
getZmuCommand() and the API's alarm action put the user's credentials on
zmu's command line, where every local user can read them (ps,
/proc/<pid>/cmdline): an auth hash with the default hashed relay, the
plaintext password with ZM_AUTH_RELAY=plain. The API also wrote the
whole command to the debug log. With the default ZM_AUTH_HASH_IPS=0 that
hash is accepted as an auth= login from any address for ZM_AUTH_HASH_TTL
hours.

zmuCredentials() builds them in one place: with a usable
ZM_AUTH_HASH_SECRET, an access token for the user that expires after a
minute (zmu -T, accepted with every relay). Without the secret zmu
refuses tokens, so it gets what it did before. The API logs the command
without the credentials.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 32bc2b3fee87b752590ba6f210403afd9222d9ff)
2026-10-30 19:30:27 -04: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
IgorA100 4c94855041 Enhance getLanguages function to use Locale class 2026-10-19 12:01:15 +03:00
Isaac ConnorandClaude Opus 5.5 c3d2e542bc fix: never build an object from an id the request sent as an array
ZM_Object's constructor treats an array as the object's row, and validInt()
and validCardinal() returned an array as they got it (preg_replace() does).
So wherever a request id reached `new ZM\X(...)`, raw or through those
validators, a crafted array built an object whose Id, UserId or MonitorId
the sender chose. The permission check then looked at those, and the delete
or update that followed used the Id. A user with Events=View deleted another
user's filter by posting Id[Id]=<filter>&Id[UserId]=<self> to the filter
delete action; the same shape reached events (MonitorId), users, reports,
snapshots and storage.

validInt() and validCardinal() now give '' for anything that isn't a single
value. The places that built an object from a raw $_REQUEST value (the
control and event ajax handlers, the event, filter, report, snapshot and
storage actions, view_hls, and the download and event detail modals) take
the id through validCardinal().

tests/php/test_request_ids_scalar.php covers the validators with arrays and
fails if web code builds an object straight from $_REQUEST, $_GET or $_POST.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 23:07:08 -04:00
Isaac ConnorandClaude Opus 5.5 16817e4ffc fix: only redirect back to a zone's Referer when it is on this server
After saving a zone, actions/zone.php redirected to the REFERER the zone form
posted, which the form fills from the Referer its page was loaded with. A
zone editor who reached the zone page through a link on another site was sent
to that site after saving: an open redirect, usable to lead someone from a
trusted ZoneMinder page to a look-alike login. Forging the POST itself is
blocked by the CSRF token, so it needs an editor who followed such a link.

localRedirectUrl() returns the target only if it is a query-only URL or an
absolute http(s) URL on the host and port of the current request, and the
fallback otherwise: another host, //host, backslashes, user@host, other
schemes and control characters all give the fallback. The zone save falls
back to the zones list, as it already does with no Referer (#5207).

tests/php/test_local_redirect_url.php covers 21 cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 11:16:14 -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 Connor 911362d873 fix: escape filter[query] in sortHeader() column links refs GHSA-626g-6988-pv4p
sortHeader() concatenated $_REQUEST['filter']['query'] into the href of
every export view column header without escaping, allowing reflected
HTML injection (iframe, meta refresh, style) via a crafted link. Pass it
through validHtmlStr() like the other request values in the same string
are passed through validInt()/validCardinal().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 7517018879f2be9ba1f9439e3364686ccee226ed)
2026-09-24 19:45:15 -04:00
Isaac ConnorandClaude Opus 5 465c3e2dfc fix: reject unrecognised zmBandwidth values instead of undefining every ZM_WEB_ constant
web/skins/classic/includes/config.php defines all 18 ZM_WEB_* constants inside
a switch on $_COOKIE['zmBandwidth'] with cases for high, medium and low and no
default. On any other value none of them are defined, and skin.js.php - emitted
in the footer of every page - reads ZM_WEB_VIEWING_TIMEOUT, ZM_WEB_AJAX_TIMEOUT
and ZM_WEB_REFRESH_NAVBAR. On PHP 8 an undefined constant is a fatal Error, so
every page including login stops rendering until the cookie is cleared, which
cannot be done from inside the interface.

skin.php only tested the value for empty, and nothing else validated it:

- the cookie is set client side by skin.js, so any value survives
- action=bandwidth put $_REQUEST['newBandwidth'] through validStr, which is
  only strip_tags, and persisted it
- ZM_BANDWIDTH_DEFAULT is a free-form string in ConfigData. The Options UI
  renders it as a select, but loadConfig lets a conf.d file override the
  database, so a typo there locks out everyone with no cookie yet

skin.php now validates both the cookie and ZM_BANDWIDTH_DEFAULT before falling
back to low, and the action rejects a value it does not recognise rather than
storing it.

tests/php/test_bandwidth_clamp.php checks the whitelist against the switch it
guards - the two must name the same profiles, since a value in one and not the
other reopens this - and that no arm of the switch defines a constant the
others do not.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015Y6FieTwEXuLhhR4e2yiax
2026-08-29 14:01:25 -04:00
Isaac ConnorandClaude Opus 5 f2424bcf59 fix: stop AUDIT log entries turning the navbar Log link red
logState() counted every row with Level < INFO and folded anything at or
below PANIC into the FATAL bucket. AUDIT is -5, so audit entries were
counted as fatals and pushed the state to alert/alarm.

Bound the count query at PANIC so AUDIT and NOLOG are left out.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GAFKf86P78WqniPEP2b45J
2026-08-28 17:29:00 -04:00
Isaac Connor d8f1a7d2d4 fix: stop CORSHeaders warning about empty and same-origin requests
Two cases produced a Warning for a request that needs no CORS headers at
all, so the log filled with noise that pointed at nothing wrong.

An empty Origin header satisfies isset(), so CORSHeaders() walked the
servers list, matched nothing, and logged " is not found in servers list."
with no value to print.  Treat an empty Origin the same as no Origin.

Browsers also send Origin on same-origin POST and fetch.  Such a request
needs no headers, but not finding the host in the Servers table still
warned, so any install reached on a hostname the Servers table does not
list warned on ordinary use.  Log that at Debug instead.  Genuine
cross-origin requests still warn.

Headers are unchanged; this only affects logging and the empty-Origin
short circuit.  The comparison ignores the scheme, so http:// against an
https-served HTTP_HOST counts as same-origin - that only suppresses a log
line, no header is emitted either way.

Checked with a standalone assert script over same-origin with and without
a port on both schemes, differing port, differing host, a suffix near-miss
(hamburg.local vs hamburg) and a missing HTTP_HOST; only the first three
go quiet.
2026-08-27 18:34:54 -04:00
Isaac Connor 10359bc011 fix: address the review comments on the stream error classification refs #5038
Three points raised on #5038 after it was merged.

ajaxError() documents the reason field as included "only when set", but
tested it for truthiness, which would also drop '' and '0'. None of the
four STREAM_ERR_ constants are falsy so nothing changed behaviour, but
the check now matches the documented contract. The client already treats
an empty reason as fatal, so a caller that does pass one still gets the
old handling.

The case 0 branch called ajaxError() twice in sequence and relied on the
first one exiting to keep the second from running on a timeout. Made the
two paths mutually exclusive so it no longer depends on that.

The test's "every ajaxError call is classified" assertion compared the
number of call sites to the number of STREAM_ERR_ occurrences anywhere in
the file. The four define()s are part of that count, so up to four calls
could lose their classification and the test would still pass - verified
by dropping the argument from one call, which the old assertion accepted.
It now matches each call to the end of its statement and requires every
one to carry a constant.
2026-08-07 21:06:58 -04:00
Isaac ConnorandClaude Opus 5 ae8c7db488 fix: stop orphaning zms when a stream command fails refs #5029
getStreamCmdResponse() responded to every ajax/stream.php failure the same way:
mint a fresh connkey and reload the img src. ajaxError() returns HTTP 200 with
result=Error, so these arrive in jQuery's done() rather than fail(), and all
twelve error paths in stream.php took that branch.

Only one of them means zms is gone. For the rest the process is still running
and streaming, and replacing the connkey makes it unaddressable: CMD_STOP,
CMD_QUIT and mode=single all then go to the new key, so nothing can reach the
old process and only SIGPIPE can stop it, which we know is unreliable. That is
why the reports of lingering zms after switching monitors were unaffected by
changes to what the stop path sends.

The timeout path made this routine rather than rare. On select() expiry
ajaxError is commented out, so the script carries on to socket_recvfrom() on a
now non-blocking socket. That returns false, and false == 0 under switch's loose
comparison, so a merely slow zms was reported as 'No data to read from socket'
and torn down.

stream.php now classifies each failure as no_socket, timeout, transient or
invalid, and sends it as 'reason'. The client restarts the stream only for
no_socket. A missing reason is still treated as fatal, so a php that predates
this keeps the old behaviour.

Before replacing the connkey the client now sends CMD_QUIT to the old one, so
the process we are about to lose track of is asked to exit. That is deliberately
not routed through streamCommand(): it must name its target explicitly, since
this.connKey is about to change, and its response must not feed back into
getStreamCmdResponse(), or a QUIT that also failed would re-enter the error path
and loop.

ajaxError() takes the classification as a third argument, named $reason because
$code is already the HTTP status, and only includes it when set, so the other
131 callers are unaffected.

Tests: tests/js covers the fatal/non-fatal decision including the no-reason
fallback, tests/php pins the classification mapping and the switch(false)
semantics the timeout branch depends on. Both verified to fail when the
behaviour is reverted.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-05 06:43:11 -04:00
Isaac ConnorandClaude Opus 4.8 c5f24a1d1f fix: loop the :// strip in detaintPath so it cannot be re-formed
detaintPath() and detaintPathAllowAbsolute() removed '://' with a single
str_replace() while the '../' removal below them already looped. One
pass is not enough, because removing a match can join its neighbours
into a fresh match: '::////' collapses to '://'. So
'php::////filter/read=string.rot13/resource=/etc/passwd' came back out
of the filter as 'php://filter/read=string.rot13/resource=/etc/passwd',
reinstating exactly the wrapper the strip exists to remove.

Loop the '://' removal the same way the '../' removal is looped. These
functions guard $view, $request, $action, the modal name and skin file
paths.

Refs GHSA-wgqf-6fjf-7gxw.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-19 13:13:06 -04:00
IgorA100andCopilot Autofix powered by AI 9053998247 Apply suggestions from code review
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-05-30 11:08:01 +03:00
IgorA100 4f9c905f64 The added class must be escaped using htmlspecialchars() (functions.php) 2026-05-29 12:10:39 +03:00
IgorA100 c2ebbc7ed5 Added the ability to specify a class for <select><option> in the htmlSelect() function (functions.php) 2026-05-28 12:44:59 +03:00
Isaac ConnorandClaude Opus 4.7 60d2e3d7a8 fix: polyfill str_starts_with/str_ends_with/str_contains for PHP 7
These functions are PHP 8.0+ but ZoneMinder is called from views on
PHP 7 installs (event.php uses str_ends_with at file scope, triggering
a fatal "Call to undefined function" before the page can render).

Add function_exists-guarded polyfills at the top of functions.php so
PHP 8+ keeps the native implementations and PHP 7.x picks up the
fallbacks. functions.php is required by index.php before any view, so
all four call sites (functions.php, event.php, views/image.php) are
covered.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-23 09:24:40 -04:00
IgorA100andCopilot Autofix powered by AI 8d3615a4af Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-05-13 10:22:33 +03:00