Tested with the real camera reached as 2.54.237.28:8080 (port forward). It
reports its services and URIs at its LAN address 192.168.200.118:
GetCapabilities XAddrs http://192.168.200.118:8080/onvif/..., stream URIs
rtsp://192.168.200.118:554/...
toto.php
- initialize(): a service URL (media, device, ptz) on another host than
the one the device service was reached at is moved to that address,
keeping its path (_reachableUri). GetVideoSources went to
192.168.200.118 and failed with "Couldn't connect", and the UI said
"Credentials are Wrong!". A service on the same host is unchanged.
doCameraOperation.php
- Stream / snapshot URIs are split with parse_url (camMediaUri):
protocol, port (scheme default if none) and path + query, whatever the
host is. Before, only "proto://<ip of the record>" was removed, so with
the LAN host the whole URL was stored as the path. The two copies of
that code are replaced by the helper.
Real camera, request of the camera editor (CID=5, AU=7, CMD=3) through
the real login (users table / session): before, status "error" (LAN
address unreachable). Now status "ok", credentials, auth mode and PTZ
token stored, 3 profiles: mainStream 1920x1080
/Streaming/Channels/101?..., subStream, thirdStream; snapshot http:8080
/onvif-http/snapshot?Profile_n.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
Ponvif::initialize() -> media_GetVideoSources() ended the whole request on
PHP 8, past the callers' try { } catch (Exception $e):
- a camera answering with an HTML page (e.g. HTTP 401): _xml2array()
found no <Envelope>, simplexml_load_string() returned false, and
$xml->getName() threw an Error;
- a reply without <VideoSources>: _getActiveSources() called count(null),
which throws a TypeError.
toto.php
- _xml2array() never throws: an empty, HTML or non-SOAP reply becomes a
Fault ("reply is not a SOAP envelope", "empty reply", ...). The HTTP
status is added in _send_request() ("HTTP 401: ...").
- initialize() throws an Exception when there is no media service, no
video source or no profile. Any other PHP Error inside is re-thrown as
an Exception. The time query catches Throwable.
- The "Communication error" exceptions (19) give the reason: the HTTP
fault above, or the SOAP Fault text of the camera.
- A camera with ONE profile or video source works: a single XML element
decodes to an associative array, so count() counted its fields and no
source was found.
- _getOnvifVersion(), GetVideoSources and the profile fields (RateControl
is optional in ONVIF) are read with isset(). Warnings displayed by PHP
would otherwise end up in the AJAX JSON reply.
doCameraOperation.php
- The 7 try blocks catch Throwable, and "Provided Credentials are Wrong!"
now shows the reason, e.g. "GetVideoSources: Communication error
(HTTP 401: reply is not a SOAP envelope)".
Tested with PHP 8.3 and a fake ONVIF camera. HTML 401 page and empty
<VideoSources>: before, a fatal Error/TypeError ended the script; now an
Exception with the reason, and a JSON reply from doCameraOperation. An
empty 401 body and a good camera behave as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
Every request (19 builders) put the user name, profile / preset / node
tokens, preset name, stream and protocol into the SOAP XML unescaped.
A user name such as "a&b" or a token containing "&" or "<" made the
request malformed. The camera rejected it, and the UI reported "Provided
Credentials are Wrong!".
- _xesc() / _xescAll(): htmlspecialchars(ENT_XML1 | ENT_QUOTES, UTF-8)
on string values. Numbers and booleans are replaced as before.
- The password itself is not affected: only its digest is sent.
Tested against a fake ONVIF camera with user "us&er<1>", password
'p&ss"word' and profile token "main&0", adding the camera on a custom
port. Before, the camera got malformed XML after GetSystemDateAndTime.
Now the camera, its login and its stream are stored.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
PHP ignores the host time zone: without date.timezone in php.ini (the
installer does not set it) it uses UTC, so session labels, event times,
the hour nodes and the live log were shown in UTC while la_mojo names
report folders/files in local time.
- lib/php/host_timezone.php: sets PHP's default time zone from the host
(/etc/localtime as maintained by timedatectl, then /etc/timezone, then
TZ); loaded right after settings.php by ajax_asm, assembler, js_asm,
soap_asm and ui_asm; added to files.list.
- Calendar day key: getHistoryDates returns the host-local noon of each
day and getHistoryDay uses it directly. The old "local midnight +
current UTC offset" (applied twice) only worked east of UTC and could be
off by a day across a DST change.
- Video download file name uses the host-local time from getVideoInfo
instead of the browser's time zone.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
la_mojo now writes one report database per local hour into the day
folder (data/reports/YYYY/MM/DD/report_HH.db) instead of a single
report.db. Days recorded earlier keep their report.db; a day during the
upgrade has both.
- lib/php/db/report_files.php (loaded by ajax_asm.php, added to
files.list): lists a day's report files and maps ids. Row ids are per
file, so ids sent to the browser are global:
id = slot * 10000000 + rowid (slot 0..23 = hour, 24 = legacy report.db)
The JavaScript treats ids as opaque, so no JavaScript changes are needed.
Report files are never created by the web UI (existence is checked).
- getHistoryDay: sessions and "Events by Hours" from all files of the day
(legacy file split by hour as before, one node per hourly file).
- getHistoryEvents, getBubbleAnalysis, setPermanentBubbles: BID..EID range
resolved to its file.
- getVideoInfo, getPictureInfo, getFrames: event/video ids resolved to
their file; video ids returned as global ids.
- getStatus (live log): newest hourly file of the newest day; LSID from a
previous hour/day restarts at the beginning of the new file.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16