CMD 3 for a camera (the editor's "Set credentials" button) set
status "ok" before the ONVIF check. When the check failed (wrong
credentials, unreachable camera, unusable reply), the page saw "ok",
reloaded the list and never showed the message. The two failure
branches now set status "error", so the reason is shown.
Tested through the real ajax_asm.php / web.php login (users table and
session id) with the editor's request (UID, SID, CID=5, UU, PP, AU,
CMD=3):
- camera unreachable: error, "GetCapabilities: Communication error
(Failed to connect to ... port 8080 ...)"
- fake camera, good: ok, credentials and stream stored
- fake camera, HTML 401 page: error, "GetVideoSources: Communication
error (HTTP 401: reply is not a SOAP envelope)"
- wrong SID: redirected (302)
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
The camera address is ip + port + onvif_ctrl (la_mojo builds
http://ip[:port]onvif_ctrl). The web UI broke it for cameras whose ONVIF
interface isn't on port 80.
doCameraOperation.php, CMD 4 (change IP / credentials)
- An address without ":port" set port=NULL. The camera editor showed the
IP without the port, so changing only the credentials moved a camera on
8080 back to port 80. Now "ip:port" sets the port and "ip" keeps the
stored one.
- A port kept inside onvif_ctrl (":8080/onvif/device_service", cameras
added by discovery) is moved to `port`. Once port was set too, la_mojo
built http://ip:8080:8080/onvif/device_service.
doCameraOperation.php, CMD 3 (add camera / check credentials)
- Camera from the DB: the port may also come from onvif_ctrl (it was read
from `port` only, so the check went to port 80 and failed).
- Direct address: "ip:port" or the dialog's Port field (PO) is the ONVIF
port. Discovery stores ip, port and the device service path separately.
Without discovery, onvif_ctrl was the full MEDIA service URL and ip
was "ip:port"; now it is /onvif/device_service, ip and port.
- count() of a string (PHP 8 TypeError, not caught) killed the request
when the snapshot URI was read.
getCameraEditor.php
- The address field shows "ip:port" when the camera has a port.
Tested with PHP 8.3, a SQLite cameras table and a fake ONVIF camera on a
custom port. The old code dropped the port, built ip:8080:8080, stored
"ip:port" + the media URL, and crashed. Now the record and the
credential check are correct.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16