Web Interface For Lite Argus Control modules
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

842 lines
55 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
toto.php: no PHP Error past try/catch in initialize() 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
5 hours ago
​
​
​
​
​
​
​
​
​
toto.php: no PHP Error past try/catch in initialize() 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
5 hours ago
​
​
​
​
​
toto.php: no PHP Error past try/catch in initialize() 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
5 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
toto.php: no PHP Error past try/catch in initialize() 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
5 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
toto.php: no PHP Error past try/catch in initialize() 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
5 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
toto.php: no PHP Error past try/catch in initialize() 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
5 hours ago
​
​
toto.php: no PHP Error past try/catch in initialize() 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
5 hours ago
​
​
​
​
​
​
​
​
​
​
toto.php: no PHP Error past try/catch in initialize() 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
5 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
toto.php: no PHP Error past try/catch in initialize() 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
5 hours ago
​
​
​
​
​
​
​
​
​
​
​
toto.php: no PHP Error past try/catch in initialize() 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
5 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
toto.php: no PHP Error past try/catch in initialize() 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
5 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
toto.php: no PHP Error past try/catch in initialize() 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
5 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
toto.php: no PHP Error past try/catch in initialize() 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
5 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
toto.php: no PHP Error past try/catch in initialize() 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
5 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
toto.php: no PHP Error past try/catch in initialize() 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
5 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
toto.php: no PHP Error past try/catch in initialize() 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
5 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
toto.php: no PHP Error past try/catch in initialize() 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
5 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
toto.php: no PHP Error past try/catch in initialize() 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
5 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
toto.php: no PHP Error past try/catch in initialize() 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
5 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
toto.php: no PHP Error past try/catch in initialize() 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
5 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
toto.php: no PHP Error past try/catch in initialize() 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
5 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
toto.php: no PHP Error past try/catch in initialize() 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
5 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
toto.php: no PHP Error past try/catch in initialize() 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
5 hours ago
​
​
​
​
​
​
​
​
​
​
​
toto.php: no PHP Error past try/catch in initialize() 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
5 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
toto.php: no PHP Error past try/catch in initialize() 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
5 hours ago
​
​
​
​
​
toto.php: no PHP Error past try/catch in initialize() 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
5 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
toto.php: no PHP Error past try/catch in initialize() 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
5 hours ago
​
​
​
​
​
​
​
toto.php: no PHP Error past try/catch in initialize() 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
5 hours ago
toto.php: no PHP Error past try/catch in initialize() 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
5 hours ago
​
​
​
​
​
​
​
​
​
​
toto.php: no PHP Error past try/catch in initialize() 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
5 hours ago
​
toto.php: no PHP Error past try/catch in initialize() 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
5 hours ago
​
​
toto.php: no PHP Error past try/catch in initialize() 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
5 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
toto.php: no PHP Error past try/catch in initialize() 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
5 hours ago
toto.php: no PHP Error past try/catch in initialize() 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
5 hours ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
toto.php: no PHP Error past try/catch in initialize() 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
5 hours ago
​
​
​
​
​
​
​
​
  1. <?php
  2. class Ponvif {
  3. protected $ipaddress='';
  4. protected $username='';
  5. protected $password='';
  6. protected $mediauri='';
  7. protected $snapshoturi='';
  8. protected $deviceuri='';
  9. protected $ptzuri='';
  10. protected $baseuri='';
  11. protected $onvifversion=array();
  12. protected $deltatime=0;
  13. protected $capabilities=array();
  14. protected $videosources=array();
  15. protected $sources=array();
  16. protected $profiles=array();
  17. protected $proxyhost='';
  18. protected $proxyport='';
  19. protected $proxyusername='';
  20. protected $proxypassword='';
  21. protected $lastresponse='';
  22. protected $intransingent=true;
  23. protected $discoverytimeout=2;
  24. protected $discoverybindip='0.0.0.0';
  25. protected $discoverymcastip='239.255.255.250';
  26. protected $discoverymcastport=3702;
  27. protected $discoveryhideduplicates=true;
  28. protected $AuthMethod = 0;
  29. public function setProxyHost($proxyHost) { $this->proxyhost = $proxyHost; }
  30. public function getProxyHost() { return $this->proxyhost; }
  31. public function setProxyPort($proxyPort) { $this->proxyport = $proxyPort; }
  32. public function getProxyPort() { return $this->proxyport; }
  33. public function setProxyUsername($proxyUsername) { $this->proxyusername = $proxyUsername; }
  34. public function getProxyUsername() { return $this->proxyusername; }
  35. public function setProxyPassword($proxyPassword) { $this->proxypassword = $proxyPassword; }
  36. public function getProxyPassword() { return $this->proxypassword; }
  37. public function setUsername($username) { $this->username = $username; }
  38. public function getUsername() { return $this->username; }
  39. public function setPassword($password) { $this->password = $password; }
  40. public function getPassword() { return $this->password; }
  41. public function getDeviceUri() { return $this->mediauri; }
  42. public function setDeviceUri($deviceUri) { $this->mediauri=$deviceUrl; }
  43. public function getIPAddress($ipAddress) { return $this->ipaddress; }
  44. public function setIPAddress($ipAddress) { $this->ipaddress=$ipAddress; }
  45. public function getSources() { return $this->sources; }
  46. public function getMediaUri() { return $this->mediauri; }
  47. public function getPTZUri() { return $this->ptzuri; }
  48. public function getBaseUrl() { return $this->baseuri; }
  49. public function getSupportedVersion() { return $this->onvifversion; }
  50. public function getCapabilities() { return $this->capabilities; }
  51. public function setBreakOnError($intransingent) { $this->intransingent=$intransingent; }
  52. public function getLastResponse() { return $this->lastresponse; }
  53. public function setDiscoveryTimeout($discoverytimeout) { $this->discoverytimeout = $discoverytimeout; }
  54. public function setDiscoveryBindIp($discoverybindip) { $this->discoverybindip = $discoverybindip; }
  55. public function setDiscoveryMcastIp($discoverymcastip) { $this->discoverymcastip = $discoverymcastip; }
  56. public function setDiscoveryMcastPort($discoverymcastport) { $this->discoverymcastport = $discoverymcastport; }
  57. public function setDiscoveryHideDuplicates($discoveryhideduplicates) { $this->discoveryhideduplicates = $discoveryhideduplicates; }
  58. public function getSnapshotUri() { return $this->snapshoturi; }
  59. public function setAuthMethod( $A ){ $this->AuthMethod = $A; }
  60. /*
  61. Constructor & Destructor
  62. */
  63. public function __construct()
  64. {
  65. // nothing to do
  66. }
  67. public function __destruct()
  68. {
  69. // nothing to do
  70. }
  71. /*
  72. WS-Discovery
  73. */
  74. public function discover(){
  75. $result = array();
  76. $timeout = time() + $this->discoverytimeout;
  77. $post_string = '<?xml version="1.0" encoding="UTF-8"?><e:Envelope xmlns:e="http://www.w3.org/2003/05/soap-envelope" xmlns:w="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:d="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:dn="http://www.onvif.org/ver10/network/wsdl"><e:Header><w:MessageID>uuid:84ede3de-7dec-11d0-c360-f01234567890</w:MessageID><w:To e:mustUnderstand="true">urn:schemas-xmlsoap-org:ws:2005:04:discovery</w:To><w:Action a:mustUnderstand="true">http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe</w:Action></e:Header><e:Body><d:Probe><d:Types>dn:NetworkVideoTransmitter</d:Types></d:Probe></e:Body></e:Envelope>';
  78. try {
  79. if(FALSE == ($sock = @socket_create(AF_INET, SOCK_DGRAM, SOL_UDP))){
  80. echo('Create socket error: ['.socket_last_error().'] '.socket_strerror(socket_last_error()));
  81. }
  82. if(FALSE == @socket_bind($sock, $this->discoverybindip, rand(20000, 40000))){
  83. echo('Bind socket error: ['.socket_last_error().'] '.socket_strerror(socket_last_error()));
  84. }
  85. if( $this->ipaddress == '' ){
  86. socket_set_option($sock, IPPROTO_IP, MCAST_JOIN_GROUP, array('group' => $this->discoverymcastip));
  87. socket_sendto($sock, $post_string, strlen($post_string), 0, $this->discoverymcastip, $this->discoverymcastport);
  88. } else {
  89. socket_sendto($sock, $post_string, strlen($post_string), 0, $this->ipaddress, $this->discoverymcastport );
  90. };
  91. socket_set_nonblock($sock);
  92. while( time() < $timeout ){
  93. if(FALSE !== @socket_recvfrom($sock, $response, 9999, 0, $from, $this->discoverymcastport)){
  94. if($response != NULL && $response != $post_string){
  95. $response = $this->_xml2array($response);
  96. if(!$this->isFault($response)){
  97. $response['Envelope']['Body']['ProbeMatches']['ProbeMatch']['IPAddr'] = $from;
  98. if($this->discoveryhideduplicates){
  99. $result[$from] = $response['Envelope']['Body']['ProbeMatches']['ProbeMatch'];
  100. }else{
  101. $result[] = $response['Envelope']['Body']['ProbeMatches']['ProbeMatch'];
  102. }
  103. }
  104. }
  105. }
  106. }
  107. socket_close($sock);
  108. } catch (Exception $e) {}
  109. sort($result);
  110. return $result;
  111. }
  112. /*
  113. Public functions (basic initialization method and other collaterals)
  114. */
  115. /*
  116. Errors here must be Exceptions: the callers use try { initialize() } catch (Exception $e).
  117. Before, a camera answering GetVideoSources with an HTML page (e.g. HTTP 401) or with no
  118. <VideoSources> made PHP 8 throw an Error / TypeError ($xml->getName() on false, count(null))
  119. that went past catch (Exception) and ended the whole request.
  120. */
  121. public function initialize() {
  122. $this->mediauri='http://'.$this->ipaddress.'/onvif/device_service';
  123. try {
  124. $datetime=$this->core_GetSystemDateAndTime();
  125. if (is_array($datetime) && isset($datetime['Time']) && isset($datetime['Date'])) {
  126. $timestamp=mktime($datetime['Time']['Hour'], $datetime['Time']['Minute'], $datetime['Time']['Second'],
  127. $datetime['Date']['Month'], $datetime['Date']['Day'], $datetime['Date']['Year']);
  128. $this->deltatime=time()-$timestamp-5;
  129. }
  130. } catch (Throwable $e) {}
  131. try {
  132. $this->capabilities=$this->core_GetCapabilities();
  133. if (!is_array($this->capabilities) || !isset($this->capabilities['Media']['XAddr']))
  134. throw new Exception('GetCapabilities: no media service in the reply');
  135. $onvifVersion=$this->_getOnvifVersion($this->capabilities);
  136. $this->mediauri=$onvifVersion['media'];
  137. $this->deviceuri=$onvifVersion['device'];
  138. $this->ptzuri=$onvifVersion['ptz'];
  139. preg_match("/^http(.*)onvif\//",$this->mediauri,$matches);
  140. $this->baseuri=isset($matches[0]) ? $matches[0] : '';
  141. $this->onvifversion=array('major'=>$onvifVersion['major'],'minor'=>$onvifVersion['minor']);
  142. $this->videosources=$this->media_GetVideoSources();
  143. if (!is_array($this->videosources) || count($this->videosources)==0)
  144. throw new Exception('GetVideoSources: no video source in the reply');
  145. $this->profiles=$this->media_GetProfiles();
  146. if (!is_array($this->profiles) || count($this->profiles)==0)
  147. throw new Exception('GetProfiles: no media profile in the reply');
  148. $this->sources=$this->_getActiveSources($this->videosources,$this->profiles);
  149. } catch (Exception $e) {
  150. throw $e;
  151. } catch (Throwable $e) {
  152. throw new Exception('ONVIF initialize: '.$e->getMessage(), 0, $e);
  153. }
  154. }
  155. public function isFault($response) { // Useful to check if response contains a fault
  156. if( is_array( $response ) ){
  157. if( array_key_exists('Fault', $response ) ) return true;
  158. if( array_key_exists('Envelope', $response ) )
  159. if( is_array( $response['Envelope'] ) )
  160. if( array_key_exists('Body', $response['Envelope'] ) )
  161. if( is_array( $response['Envelope']['Body'] ) )
  162. if( array_key_exists('Fault', $response['Envelope']['Body'] ) ) return true;
  163. };
  164. return false;
  165. }
  166. /*
  167. Public wrappers for a subset of ONVIF primitives
  168. */
  169. public function core_GetSystemDateAndTime() {
  170. $post_string='<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><GetSystemDateAndTime xmlns="http://www.onvif.org/ver10/device/wsdl"/></s:Body></s:Envelope>';
  171. if ($this->isFault($response=$this->_send_request($this->mediauri,$post_string))) {
  172. if ($this->intransingent) throw new Exception('GetSystemDateAndTime: Communication error'.$this->_faultText());
  173. } else {
  174. return $response['Envelope']['Body']['GetSystemDateAndTimeResponse']['SystemDateAndTime']['UTCDateTime'];
  175. }
  176. }
  177. public function core_GetCapabilities() {
  178. $REQ=$this->_makeToken();
  179. $post_string='<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Header><Security s:mustUnderstand="1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><UsernameToken><Username>%%USERNAME%%</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">%%PASSWORD%%</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">%%NONCE%%</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">%%CREATED%%</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><GetCapabilities xmlns="http://www.onvif.org/ver10/device/wsdl"><Category>All</Category></GetCapabilities></s:Body></s:Envelope>';
  180. $post_string=str_replace(array("%%USERNAME%%",
  181. "%%PASSWORD%%",
  182. "%%NONCE%%",
  183. "%%CREATED%%"),
  184. $this->_xescAll(array($REQ['USERNAME'],
  185. $REQ['PASSDIGEST'],
  186. $REQ['NONCE'],
  187. $REQ['TIMESTAMP'])),
  188. $post_string);
  189. if ($this->isFault($response=$this->_send_request($this->mediauri,$post_string))) {
  190. if ($this->intransingent) throw new Exception('GetCapabilities: Communication error'.$this->_faultText());
  191. }
  192. else
  193. return $response['Envelope']['Body']['GetCapabilitiesResponse']['Capabilities'];
  194. }
  195. public function media_GetVideoSources() {
  196. $REQ=$this->_makeToken();
  197. $post_string='<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Header><Security s:mustUnderstand="1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><UsernameToken><Username>%%USERNAME%%</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">%%PASSWORD%%</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">%%NONCE%%</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">%%CREATED%%</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><GetVideoSources xmlns="http://www.onvif.org/ver10/media/wsdl"/></s:Body></s:Envelope>';
  198. $post_string=str_replace(array("%%USERNAME%%",
  199. "%%PASSWORD%%",
  200. "%%NONCE%%",
  201. "%%CREATED%%"),
  202. $this->_xescAll(array($REQ['USERNAME'],
  203. $REQ['PASSDIGEST'],
  204. $REQ['NONCE'],
  205. $REQ['TIMESTAMP'])),
  206. $post_string);
  207. //echo "POST STRING:" . $post_string . "\n\n";
  208. if ($this->isFault($response=$this->_send_request($this->mediauri,$post_string))) {
  209. if ($this->intransingent) throw new Exception('GetVideoSources: Communication error'.$this->_faultText());
  210. }
  211. else
  212. // var_dump( $response );
  213. return isset($response['Envelope']['Body']['GetVideoSourcesResponse']['VideoSources']) ? $response['Envelope']['Body']['GetVideoSourcesResponse']['VideoSources'] : null;
  214. }
  215. public function media_GetProfiles() {
  216. $REQ=$this->_makeToken();
  217. $post_string='<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Header><Security s:mustUnderstand="1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><UsernameToken><Username>%%USERNAME%%</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">%%PASSWORD%%</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">%%NONCE%%</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">%%CREATED%%</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><GetProfiles xmlns="http://www.onvif.org/ver10/media/wsdl"/></s:Body></s:Envelope>';
  218. $post_string=str_replace(array("%%USERNAME%%",
  219. "%%PASSWORD%%",
  220. "%%NONCE%%",
  221. "%%CREATED%%"),
  222. $this->_xescAll(array($REQ['USERNAME'],
  223. $REQ['PASSDIGEST'],
  224. $REQ['NONCE'],
  225. $REQ['TIMESTAMP'])),
  226. $post_string);
  227. if ($this->isFault($response=$this->_send_request($this->mediauri,$post_string))) {
  228. if ($this->intransingent) throw new Exception('GetProfiles: Communication error'.$this->_faultText());
  229. }
  230. else
  231. return $response['Envelope']['Body']['GetProfilesResponse']['Profiles'];
  232. }
  233. public function media_GetServices() {
  234. $REQ=$this->_makeToken();
  235. $post_string='<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Header><Security s:mustUnderstand="1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><UsernameToken><Username>%%USERNAME%%</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">%%PASSWORD%%</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">%%NONCE%%</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">%%CREATED%%</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><GetServices xmlns="http://www.onvif.org/ver10/device/wsdl"><IncludeCapability>false</IncludeCapability></GetServices></s:Body></s:Envelope>';
  236. $post_string=str_replace(array("%%USERNAME%%",
  237. "%%PASSWORD%%",
  238. "%%NONCE%%",
  239. "%%CREATED%%"),
  240. $this->_xescAll(array($REQ['USERNAME'],
  241. $REQ['PASSDIGEST'],
  242. $REQ['NONCE'],
  243. $REQ['TIMESTAMP'])),
  244. $post_string);
  245. if ($this->isFault($this->_send_request($this->mediauri,$post_string))) {
  246. if ($this->intransingent) throw new Exception('GetServices: Communication error'.$this->_faultText());
  247. }
  248. }
  249. public function core_GetDeviceInformation() {
  250. $REQ=$this->_makeToken();
  251. $post_string='<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Header><Security s:mustUnderstand="1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><UsernameToken><Username>%%USERNAME%%</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">%%PASSWORD%%</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">%%NONCE%%</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">%%CREATED%%</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><GetDeviceInformation xmlns="http://www.onvif.org/ver10/device/wsdl"/></s:Body></s:Envelope>';
  252. $post_string=str_replace(array("%%USERNAME%%",
  253. "%%PASSWORD%%",
  254. "%%NONCE%%",
  255. "%%CREATED%%"),
  256. $this->_xescAll(array($REQ['USERNAME'],
  257. $REQ['PASSDIGEST'],
  258. $REQ['NONCE'],
  259. $REQ['TIMESTAMP'])),
  260. $post_string);
  261. if ($this->isFault($response=$this->_send_request($this->mediauri,$post_string))) {
  262. if ($this->intransingent) throw new Exception('GetDeviceInformation: Communication error'.$this->_faultText());
  263. }
  264. else
  265. return $response['Envelope']['Body']['GetDeviceInformationResponse'];
  266. }
  267. public function media_GetStreamUri($profileToken,$stream="RTP-Unicast",$protocol="RTSP") {
  268. $REQ=$this->_makeToken();
  269. $post_string='<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Header><Security s:mustUnderstand="1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><UsernameToken><Username>%%USERNAME%%</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">%%PASSWORD%%</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">%%NONCE%%</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">%%CREATED%%</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><GetStreamUri xmlns="http://www.onvif.org/ver10/media/wsdl"><StreamSetup><Stream xmlns="http://www.onvif.org/ver10/schema">%%STREAM%%</Stream><Transport xmlns="http://www.onvif.org/ver10/schema"><Protocol>%%PROTOCOL%%</Protocol></Transport></StreamSetup><ProfileToken>%%PROFILETOKEN%%</ProfileToken></GetStreamUri></s:Body></s:Envelope>';
  270. $post_string=str_replace(
  271. array("%%USERNAME%%",
  272. "%%PASSWORD%%",
  273. "%%NONCE%%",
  274. "%%CREATED%%",
  275. "%%PROFILETOKEN%%",
  276. "%%STREAM%%",
  277. "%%PROTOCOL%%"),
  278. $this->_xescAll(array($REQ['USERNAME'],
  279. $REQ['PASSDIGEST'],
  280. $REQ['NONCE'],
  281. $REQ['TIMESTAMP'],
  282. $profileToken,
  283. $stream,
  284. $protocol)),
  285. $post_string
  286. );
  287. if ($this->isFault($response=$this->_send_request($this->mediauri,$post_string))) {
  288. if ($this->intransingent) throw new Exception('GetStreamUri: Communication error'.$this->_faultText());
  289. }
  290. else
  291. return $response['Envelope']['Body']['GetStreamUriResponse']['MediaUri']['Uri'];
  292. }
  293. public function media_GetSnapshotUri($profileToken) {
  294. $REQ=$this->_makeToken();
  295. $post_string='<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Header><Security s:mustUnderstand="1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><UsernameToken><Username>%%USERNAME%%</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">%%PASSWORD%%</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">%%NONCE%%</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">%%CREATED%%</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><GetSnapshotUri xmlns="http://www.onvif.org/ver10/media/wsdl"><ProfileToken>%%PROFILETOKEN%%</ProfileToken></GetSnapshotUri></s:Body></s:Envelope>';
  296. $post_string=str_replace(array("%%USERNAME%%",
  297. "%%PASSWORD%%",
  298. "%%NONCE%%",
  299. "%%CREATED%%",
  300. "%%PROFILETOKEN%%"),
  301. $this->_xescAll(array($REQ['USERNAME'],
  302. $REQ['PASSDIGEST'],
  303. $REQ['NONCE'],
  304. $REQ['TIMESTAMP'],
  305. $profileToken)),
  306. $post_string);
  307. if ($this->isFault($response=$this->_send_request($this->mediauri,$post_string))) {
  308. if ($this->intransingent) throw new Exception('GetSnapshotUri: Communication error'.$this->_faultText());
  309. var_dump($response);
  310. }
  311. else
  312. return $response['Envelope']['Body']['GetSnapshotUriResponse']['MediaUri']['Uri'];
  313. }
  314. public function ptz_GetPresets($profileToken) {
  315. if ($this->ptzuri=='') return array();
  316. $REQ=$this->_makeToken();
  317. $post_string='<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Header><Security s:mustUnderstand="1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><UsernameToken><Username>%%USERNAME%%</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">%%PASSWORD%%</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">%%NONCE%%</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">%%CREATED%%</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><GetPresets xmlns="http://www.onvif.org/ver20/ptz/wsdl"><ProfileToken>%%PROFILETOKEN%%</ProfileToken></GetPresets></s:Body></s:Envelope>';
  318. $post_string=str_replace(array("%%USERNAME%%",
  319. "%%PASSWORD%%",
  320. "%%NONCE%%",
  321. "%%CREATED%%",
  322. "%%PROFILETOKEN%%"),
  323. $this->_xescAll(array($REQ['USERNAME'],
  324. $REQ['PASSDIGEST'],
  325. $REQ['NONCE'],
  326. $REQ['TIMESTAMP'],
  327. $profileToken)),
  328. $post_string);
  329. if ($this->isFault($response=$this->_send_request($this->ptzuri,$post_string))) {
  330. if ($this->intransingent) throw new Exception('GetPresets: Communication error'.$this->_faultText());
  331. }
  332. else {
  333. $getpresetsresponse=$response['Envelope']['Body']['GetPresetsResponse']['Preset'];
  334. $presets=array();
  335. foreach ($getpresetsresponse as $preset) {
  336. $presets[]=array('Token'=>$preset['@attributes']['token'],
  337. 'Name'=>$preset['Name'],
  338. 'PTZPosition'=>$preset['PTZPosition']);
  339. }
  340. return $presets;
  341. }
  342. }
  343. public function ptz_GetNode($ptzNodeToken) {
  344. if ($this->ptzuri=='') return array();
  345. $REQ=$this->_makeToken();
  346. $post_string='<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Header><Security s:mustUnderstand="1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><UsernameToken><Username>%%USERNAME%%</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">%%PASSWORD%%</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">%%NONCE%%</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">%%CREATED%%</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><GetNode xmlns="http://www.onvif.org/ver20/ptz/wsdl"><NodeToken>%%NODETOKEN%%</NodeToken></GetNode></s:Body></s:Envelope>';
  347. $post_string=str_replace(array("%%USERNAME%%",
  348. "%%PASSWORD%%",
  349. "%%NONCE%%",
  350. "%%CREATED%%",
  351. "%%NODETOKEN%%"),
  352. $this->_xescAll(array($REQ['USERNAME'],
  353. $REQ['PASSDIGEST'],
  354. $REQ['NONCE'],
  355. $REQ['TIMESTAMP'],
  356. $ptzNodeToken)),
  357. $post_string);
  358. if ($this->isFault($response=$this->_send_request($this->ptzuri,$post_string))) {
  359. if ($this->intransingent) throw new Exception('GetNode: Communication error'.$this->_faultText());
  360. }
  361. else
  362. return $response['Envelope']['Body']['GetNodeResponse'];
  363. }
  364. public function ptz_GotoPreset($profileToken,$presetToken,$speed_pantilt_x,$speed_pantilt_y,$speed_zoom_x) {
  365. if ($this->ptzuri=='') return array();
  366. $REQ=$this->_makeToken();
  367. $post_string='<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Header><Security s:mustUnderstand="1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><UsernameToken><Username>%%USERNAME%%</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">%%PASSWORD%%</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">%%NONCE%%</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">%%CREATED%%</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><GotoPreset xmlns="http://www.onvif.org/ver20/ptz/wsdl"><ProfileToken>%%PROFILETOKEN%%</ProfileToken><PresetToken>%%PRESETTOKEN%%</PresetToken><Speed><PanTilt x="%%SPEEDPANTILTX%%" y="%%SPEEDPANTILTY%%" xmlns="http://www.onvif.org/ver10/schema"/><Zoom x="%%SPEEDZOOMX%%" xmlns="http://www.onvif.org/ver10/schema"/></Speed></GotoPreset></s:Body></s:Envelope>';
  368. $post_string=str_replace(array("%%USERNAME%%",
  369. "%%PASSWORD%%",
  370. "%%NONCE%%",
  371. "%%CREATED%%",
  372. "%%PROFILETOKEN%%",
  373. "%%PRESETTOKEN%%",
  374. "%%SPEEDPANTILTX%%",
  375. "%%SPEEDPANTILTY%%",
  376. "%%SPEEDZOOMX%%"),
  377. $this->_xescAll(array($REQ['USERNAME'],
  378. $REQ['PASSDIGEST'],
  379. $REQ['NONCE'],
  380. $REQ['TIMESTAMP'],
  381. $profileToken,
  382. $presetToken,
  383. $speed_pantilt_x,
  384. $speed_pantilt_y,
  385. $speed_zoom_x)),
  386. $post_string);
  387. if ($this->isFault($this->_send_request($this->ptzuri,$post_string))) {
  388. if ($this->intransingent) throw new Exception('GotoPreset: Communication error'.$this->_faultText());
  389. }
  390. }
  391. public function ptz_RemovePreset($profileToken,$presetToken) {
  392. if ($this->ptzuri=='') return array();
  393. $REQ=$this->_makeToken();
  394. $post_string='<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Header><Security s:mustUnderstand="1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><UsernameToken><Username>%%USERNAME%%</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">%%PASSWORD%%</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">%%NONCE%%</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">%%CREATED%%</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><RemovePreset xmlns="http://www.onvif.org/ver20/ptz/wsdl"><ProfileToken>%%PROFILETOKEN%%</ProfileToken><PresetToken>%%PRESETTOKEN%%</PresetToken></RemovePreset></s:Body></s:Envelope>';
  395. $post_string=str_replace(array("%%USERNAME%%",
  396. "%%PASSWORD%%",
  397. "%%NONCE%%",
  398. "%%CREATED%%",
  399. "%%PROFILETOKEN%%",
  400. "%%PRESETTOKEN%%"),
  401. $this->_xescAll(array($REQ['USERNAME'],
  402. $REQ['PASSDIGEST'],
  403. $REQ['NONCE'],
  404. $REQ['TIMESTAMP'],
  405. $profileToken,
  406. $presetToken)),
  407. $post_string);
  408. if ($this->isFault($this->_send_request($this->ptzuri,$post_string))) {
  409. if ($this->intransingent) throw new Exception('RemovePreset: Communication error'.$this->_faultText());
  410. }
  411. }
  412. public function ptz_SetPreset($profileToken,$presetName) {
  413. if ($this->ptzuri=='') return array();
  414. $REQ=$this->_makeToken();
  415. $post_string='<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Header><Security s:mustUnderstand="1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><UsernameToken><Username>%%USERNAME%%</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">%%PASSWORD%%</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">%%NONCE%%</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">%%CREATED%%</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><SetPreset xmlns="http://www.onvif.org/ver20/ptz/wsdl"><ProfileToken>%%PROFILETOKEN%%</ProfileToken><PresetName>%%PRESETNAME%%</PresetName></SetPreset></s:Body></s:Envelope>';
  416. $post_string=str_replace(array("%%USERNAME%%",
  417. "%%PASSWORD%%",
  418. "%%NONCE%%",
  419. "%%CREATED%%",
  420. "%%PROFILETOKEN%%",
  421. "%%PRESETNAME%%"),
  422. $this->_xescAll(array($REQ['USERNAME'],
  423. $REQ['PASSDIGEST'],
  424. $REQ['NONCE'],
  425. $REQ['TIMESTAMP'],
  426. $profileToken,
  427. $presetName)),
  428. $post_string);
  429. if ($this->isFault($this->_send_request($this->ptzuri,$post_string))) {
  430. if ($this->intransingent) throw new Exception('SetPreset: Communication error'.$this->_faultText());
  431. }
  432. }
  433. public function ptz_RelativeMove($profileToken,$translation_pantilt_x,$translation_pantilt_y,$speed_pantilt_x,$speed_pantilt_y) {
  434. if ($this->ptzuri=='') return array();
  435. $REQ=$this->_makeToken();
  436. $post_string='<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Header><Security s:mustUnderstand="1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><UsernameToken><Username>%%USERNAME%%</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">%%PASSWORD%%</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">%%NONCE%%</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">%%CREATED%%</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><RelativeMove xmlns="http://www.onvif.org/ver20/ptz/wsdl"><ProfileToken>%%PROFILETOKEN%%</ProfileToken><Translation><PanTilt x="%%TRANSLATIONPANTILTX%%" y="%%TRANSLATIONPANTILTY%%" space="http://www.onvif.org/ver10/tptz/PanTiltSpaces/TranslationGenericSpace" xmlns="http://www.onvif.org/ver10/schema"/></Translation><Speed><PanTilt x="%%SPEEDPANTILTX%%" y="%%SPEEDPANTILTY%%" space="http://www.onvif.org/ver10/tptz/PanTiltSpaces/GenericSpeedSpace" xmlns="http://www.onvif.org/ver10/schema"/></Speed></RelativeMove></s:Body></s:Envelope>';
  437. $post_string=str_replace(array("%%USERNAME%%",
  438. "%%PASSWORD%%",
  439. "%%NONCE%%",
  440. "%%CREATED%%",
  441. "%%PROFILETOKEN%%",
  442. "%%TRANSLATIONPANTILTX%%",
  443. "%%TRANSLATIONPANTILTY%%",
  444. "%%SPEEDPANTILTX%%",
  445. "%%SPEEDPANTILTY%%"),
  446. $this->_xescAll(array($REQ['USERNAME'],
  447. $REQ['PASSDIGEST'],
  448. $REQ['NONCE'],
  449. $REQ['TIMESTAMP'],
  450. $profileToken,
  451. $translation_pantilt_x,
  452. $translation_pantilt_y,
  453. $speed_pantilt_x,
  454. $speed_pantilt_y)),
  455. $post_string);
  456. if ($this->isFault($this->_send_request($this->ptzuri,$post_string))) {
  457. if ($this->intransingent) throw new Exception('RelativeMove: Communication error'.$this->_faultText());
  458. }
  459. }
  460. public function ptz_RelativeMoveZoom($profileToken,$zoom,$speedZoom) {
  461. if ($this->ptzuri=='') return array();
  462. $REQ=$this->_makeToken();
  463. $post_string='<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Header><Security s:mustUnderstand="1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><UsernameToken><Username>%%USERNAME%%</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">%%PASSWORD%%</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">%%NONCE%%</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">%%CREATED%%</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><RelativeMove xmlns="http://www.onvif.org/ver20/ptz/wsdl"><ProfileToken>%%PROFILETOKEN%%</ProfileToken><Translation><Zoom x="%%ZOOM%%" space="http://www.onvif.org/ver10/tptz/ZoomSpaces/TranslationGenericSpace" xmlns="http://www.onvif.org/ver10/schema"/></Translation><Speed><Zoom x="%%SPEEDZOOM%%" space="http://www.onvif.org/ver10/tptz/ZoomSpaces/ZoomGenericSpeedSpace" xmlns="http://www.onvif.org/ver10/schema"/></Speed></RelativeMove></s:Body></s:Envelope>';
  464. $post_string=str_replace(array("%%USERNAME%%",
  465. "%%PASSWORD%%",
  466. "%%NONCE%%",
  467. "%%CREATED%%",
  468. "%%PROFILETOKEN%%",
  469. "%%SPEEDZOOM%%",
  470. "%%ZOOM%%"),
  471. $this->_xescAll(array($REQ['USERNAME'],
  472. $REQ['PASSDIGEST'],
  473. $REQ['NONCE'],
  474. $REQ['TIMESTAMP'],
  475. $profileToken,
  476. $speedZoom,
  477. $zoom)),
  478. $post_string);
  479. if ($this->isFault($this->_send_request($this->ptzuri,$post_string))) {
  480. if ($this->intransingent) throw new Exception('RelativeMoveZoom: Communication error'.$this->_faultText());
  481. }
  482. }
  483. public function ptz_GetStatus( $profileToken ){
  484. $REQ=$this->_makeToken();
  485. $post_string='<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Header><Security s:mustUnderstand="1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><UsernameToken><Username>%%USERNAME%%</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">%%PASSWORD%%</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">%%NONCE%%</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">%%CREATED%%</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><GetStatus xmlns="http://www.onvif.org/ver20/ptz/wsdl"><ProfileToken>%%PROFILETOKEN%%</ProfileToken></GetStatus></s:Body></s:Envelope>';
  486. $post_string=str_replace(array("%%USERNAME%%",
  487. "%%PASSWORD%%",
  488. "%%NONCE%%",
  489. "%%CREATED%%",
  490. "%%PROFILETOKEN%%"),
  491. $this->_xescAll(array($REQ['USERNAME'],
  492. $REQ['PASSDIGEST'],
  493. $REQ['NONCE'],
  494. $REQ['TIMESTAMP'],
  495. $profileToken)),
  496. $post_string);
  497. if ($this->isFault($response = $this->_send_request($this->ptzuri,$post_string))) {
  498. if ($this->intransingent) throw new Exception('ptz Get Status: Communication error');
  499. } else {
  500. var_dump( $response );
  501. $cpos=$response['Envelope']['Body']['GetStatusResponse']['PTZStatus']['Position'];
  502. return $cpos;
  503. };
  504. }
  505. public function ptz_AbsoluteMove($profileToken,$position_pantilt_x,$position_pantilt_y,$zoom, $PSpeed=1.0, $TSpeed=1.0, $ZSpeed=1.0 ) {
  506. if ($this->ptzuri=='') return array();
  507. $REQ=$this->_makeToken();
  508. $post_string='<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Header><Security s:mustUnderstand="1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><UsernameToken><Username>%%USERNAME%%</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">%%PASSWORD%%</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">%%NONCE%%</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">%%CREATED%%</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><AbsoluteMove xmlns="http://www.onvif.org/ver20/ptz/wsdl"><ProfileToken>%%PROFILETOKEN%%</ProfileToken><Position><PanTilt x="%%POSITIONPANTILTX%%" y="%%POSITIONPANTILTY%%" space="http://www.onvif.org/ver10/tptz/PanTiltSpaces/PositionGenericSpace" xmlns="http://www.onvif.org/ver10/schema"/><Zoom x="%%ZOOM%%" space="http://www.onvif.org/ver10/tptz/ZoomSpaces/PositionGenericSpace" xmlns="http://www.onvif.org/ver10/schema"/></Position><Speed><PanTilt x="%%SPEEDPANTILTX%%" y="%%SPEEDPANTILTY%%" xmlns="http://www.onvif.org/ver10/schema"/><Zoom x="%%SPEEDZOOMX%%" xmlns="http://www.onvif.org/ver10/schema"/></Speed></AbsoluteMove></s:Body></s:Envelope>';
  509. $post_string=str_replace(array("%%USERNAME%%",
  510. "%%PASSWORD%%",
  511. "%%NONCE%%",
  512. "%%CREATED%%",
  513. "%%PROFILETOKEN%%",
  514. "%%POSITIONPANTILTX%%",
  515. "%%POSITIONPANTILTY%%",
  516. "%%ZOOM%%",
  517. "%%SPEEDPANTILTX%%",
  518. "%%SPEEDPANTILTY%%",
  519. "%%SPEEDZOOMX%%"),
  520. $this->_xescAll(array($REQ['USERNAME'],
  521. $REQ['PASSDIGEST'],
  522. $REQ['NONCE'],
  523. $REQ['TIMESTAMP'],
  524. $profileToken,
  525. $position_pantilt_x,
  526. $position_pantilt_y,
  527. $zoom,
  528. $PSpeed,
  529. $TSpeed,
  530. $ZSpeed)),
  531. $post_string);
  532. if ($this->isFault($this->_send_request($this->ptzuri,$post_string))) {
  533. if ($this->intransingent) throw new Exception('AbsoluteMove: Communication error'.$this->_faultText());
  534. }
  535. }
  536. public function ptz_ContinuousMove($profileToken,$velocity_pantilt_x,$velocity_pantilt_y) {
  537. if ($this->ptzuri=='') return array();
  538. $REQ=$this->_makeToken();
  539. $post_string='<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Header><Security s:mustUnderstand="1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><UsernameToken><Username>%%USERNAME%%</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">%%PASSWORD%%</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">%%NONCE%%</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">%%CREATED%%</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><ContinuousMove xmlns="http://www.onvif.org/ver20/ptz/wsdl"><ProfileToken>%%PROFILETOKEN%%</ProfileToken><Velocity><PanTilt x="%%VELOCITYPANTILTX%%" y="%%VELOCITYPANTILTY%%" space="http://www.onvif.org/ver10/tptz/PanTiltSpaces/VelocityGenericSpace" xmlns="http://www.onvif.org/ver10/schema"/></Velocity></ContinuousMove></s:Body></s:Envelope>';
  540. $post_string=str_replace(array("%%USERNAME%%",
  541. "%%PASSWORD%%",
  542. "%%NONCE%%",
  543. "%%CREATED%%",
  544. "%%PROFILETOKEN%%",
  545. "%%VELOCITYPANTILTX%%",
  546. "%%VELOCITYPANTILTY%%"),
  547. $this->_xescAll(array($REQ['USERNAME'],
  548. $REQ['PASSDIGEST'],
  549. $REQ['NONCE'],
  550. $REQ['TIMESTAMP'],
  551. $profileToken,
  552. $velocity_pantilt_x,
  553. $velocity_pantilt_y)),
  554. $post_string);
  555. if ( $this->isFault($this->_send_request($this->ptzuri,$post_string))) {
  556. if( $this->intransingent ) throw new Exception('ContinuousMove: Communication error'.$this->_faultText());
  557. }
  558. }
  559. public function ptz_ContinuousMoveZoom($profileToken,$zoom) {
  560. if ($this->ptzuri=='') return array();
  561. $REQ=$this->_makeToken();
  562. $post_string='<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Header><Security s:mustUnderstand="1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><UsernameToken><Username>%%USERNAME%%</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">%%PASSWORD%%</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">%%NONCE%%</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">%%CREATED%%</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><ContinuousMove xmlns="http://www.onvif.org/ver20/ptz/wsdl"><ProfileToken>%%PROFILETOKEN%%</ProfileToken><Velocity><Zoom x="%%ZOOM%%" space="http://www.onvif.org/ver10/tptz/ZoomSpaces/VelocityGenericSpace" xmlns="http://www.onvif.org/ver10/schema"/></Velocity></ContinuousMove></s:Body></s:Envelope>';
  563. $post_string=str_replace(array("%%USERNAME%%",
  564. "%%PASSWORD%%",
  565. "%%NONCE%%",
  566. "%%CREATED%%",
  567. "%%PROFILETOKEN%%",
  568. "%%ZOOM%%"),
  569. $this->_xescAll(array($REQ['USERNAME'],
  570. $REQ['PASSDIGEST'],
  571. $REQ['NONCE'],
  572. $REQ['TIMESTAMP'],
  573. $profileToken,
  574. $zoom)),
  575. $post_string);
  576. if ($this->isFault($this->_send_request($this->ptzuri,$post_string))) {
  577. if ($this->intransingent) throw new Exception('ContinuousMoveZoom: Communication error'.$this->_faultText());
  578. }
  579. }
  580. public function ptz_Stop($profileToken,$pantilt,$zoom) {
  581. if ($this->ptzuri=='') return array();
  582. $REQ=$this->_makeToken();
  583. $post_string='<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Header><Security s:mustUnderstand="1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><UsernameToken><Username>%%USERNAME%%</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">%%PASSWORD%%</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">%%NONCE%%</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">%%CREATED%%</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><Stop xmlns="http://www.onvif.org/ver20/ptz/wsdl"><ProfileToken>%%PROFILETOKEN%%</ProfileToken><PanTilt>%%PANTILT%%</PanTilt><Zoom>%%ZOOM%%</Zoom></Stop></s:Body></s:Envelope>';
  584. $post_string=str_replace(array("%%USERNAME%%",
  585. "%%PASSWORD%%",
  586. "%%NONCE%%",
  587. "%%CREATED%%",
  588. "%%PROFILETOKEN%%",
  589. "%%PANTILT%%",
  590. "%%ZOOM%%"),
  591. $this->_xescAll(array($REQ['USERNAME'],
  592. $REQ['PASSDIGEST'],
  593. $REQ['NONCE'],
  594. $REQ['TIMESTAMP'],
  595. $profileToken,
  596. $pantilt,
  597. $zoom)),
  598. $post_string);
  599. if ($this->isFault($this->_send_request($this->ptzuri,$post_string))) {
  600. if ($this->intransingent) throw new Exception('Stop: Communication error'.$this->_faultText());
  601. }
  602. }
  603. /*
  604. Internal functions
  605. */
  606. protected function _makeToken() {
  607. $timestamp=time()-$this->deltatime;
  608. return $this->_passwordDigest($this->username,$this->password,date('Y-m-d\TH:i:s.000\Z',$timestamp));
  609. }
  610. protected function _getOnvifVersion($capabilities) {
  611. $version=array('major'=>0,'minor'=>0);
  612. $sv=isset($capabilities['Device']['System']['SupportedVersions']) ? $capabilities['Device']['System']['SupportedVersions'] : null;
  613. if (is_array($sv) && isset($sv['Major'])) {
  614. // NVT supports a specific onvif version
  615. $version['major']=$sv['Major'];
  616. $version['minor']=isset($sv['Minor']) ? $sv['Minor'] : 0;
  617. } elseif (is_array($sv)) {
  618. // NVT supports more onvif versions
  619. foreach ($sv as $cver) {
  620. if (is_array($cver) && isset($cver['Major']) && $cver['Major']>$version['major']) {
  621. $version['major']=$cver['Major'];
  622. $version['minor']=isset($cver['Minor']) ? $cver['Minor'] : 0;
  623. }
  624. }
  625. }
  626. $version['media']=isset($capabilities['Media']['XAddr']) ? $capabilities['Media']['XAddr'] : '';
  627. $version['device']=isset($capabilities['Device']['XAddr']) ? $capabilities['Device']['XAddr'] : '';
  628. $version['event']=isset($capabilities['Events']['XAddr']) ? $capabilities['Events']['XAddr'] : '';
  629. $version['ptz']=isset($capabilities['PTZ']['XAddr']) ? $capabilities['PTZ']['XAddr'] : '';
  630. return $version;
  631. }
  632. // Why the last request failed: " (HTTP 401: reply is not a SOAP envelope)" or the SOAP Fault reason
  633. protected function _faultText() {
  634. $r=$this->lastresponse;
  635. if (is_array($r) && isset($r['Fault']) && is_string($r['Fault'])) return ' ('.$r['Fault'].')';
  636. if (is_array($r) && isset($r['Envelope']['Body']['Fault']['Reason']['Text'])) {
  637. $t=$r['Envelope']['Body']['Fault']['Reason']['Text'];
  638. if (is_string($t)) return ' ('.$t.')';
  639. }
  640. return '';
  641. }
  642. // One XML element decodes to an associative array, several to a list: always return a list
  643. protected function _asList($v) {
  644. if (!is_array($v)) return array();
  645. if (isset($v['@attributes']) || !array_key_exists(0, $v)) return array($v);
  646. return $v;
  647. }
  648. protected function _getActiveSources($videoSources,$profiles) {
  649. $sources=array();
  650. if (!is_array($videoSources)) return $sources;
  651. if (isset($videoSources['@attributes'])) {
  652. // NVT is a camera
  653. $sources[0]['sourcetoken']=$videoSources['@attributes']['token'];
  654. $this->_getProfileData($sources,0,$profiles);
  655. }
  656. else {
  657. // NVT is an encoder
  658. $videoSources=$this->_asList($videoSources);
  659. for ($i=0;$i<count($videoSources);$i++) {
  660. if (isset($videoSources[$i]['@attributes']['SignalActive']) && strtolower($videoSources[$i]['@attributes']['SignalActive'])=='true') {
  661. $sources[$i]['sourcetoken']=$videoSources[$i]['@attributes']['token'];
  662. $this->_getProfileData($sources,$i,$profiles);
  663. }
  664. } // for
  665. }
  666. return $sources;
  667. }
  668. protected function _getProfileData(&$sources,$i,$profiles) {
  669. $inprofile=0;
  670. // A camera with ONE profile: count() counted the fields of that profile, no source was found
  671. $profiles=$this->_asList($profiles);
  672. for ($y=0; $y < count($profiles); $y++) {
  673. if (isset($profiles[$y]['VideoSourceConfiguration']['SourceToken']) && $profiles[$y]['VideoSourceConfiguration']['SourceToken']==$sources[$i]['sourcetoken']) {
  674. $sources[$i][$inprofile]['profilename']=$profiles[$y]['Name'];
  675. $sources[$i][$inprofile]['profiletoken']=$profiles[$y]['@attributes']['token'];
  676. if ( isset($profiles[$y]['VideoEncoderConfiguration'])) {
  677. // RateControl (and in theory Resolution) are optional in ONVIF
  678. $vec=$profiles[$y]['VideoEncoderConfiguration'];
  679. $sources[$i][$inprofile]['encoding']=isset($vec['Encoding']) ? $vec['Encoding'] : '';
  680. $sources[$i][$inprofile]['width']=isset($vec['Resolution']['Width']) ? $vec['Resolution']['Width'] : 0;
  681. $sources[$i][$inprofile]['height']=isset($vec['Resolution']['Height']) ? $vec['Resolution']['Height'] : 0;
  682. $sources[$i][$inprofile]['fps']=isset($vec['RateControl']['FrameRateLimit']) ? $vec['RateControl']['FrameRateLimit'] : 0;
  683. $sources[$i][$inprofile]['bitrate']=isset($vec['RateControl']['BitrateLimit']) ? $vec['RateControl']['BitrateLimit'] : 0;
  684. }
  685. if ( isset($profiles[$y]['PTZConfiguration'])) {
  686. $sources[$i][$inprofile]['ptz']['name']=$profiles[$y]['PTZConfiguration']['Name'];
  687. $sources[$i][$inprofile]['ptz']['nodetoken']=$profiles[$y]['PTZConfiguration']['NodeToken'];
  688. }
  689. $inprofile++;
  690. }
  691. }
  692. }
  693. // Not SOAP XML (empty, HTML error page ...): a Fault instead of a PHP Error / Exception
  694. protected function _xml2array($response) {
  695. try {
  696. if (!is_string($response) || trim($response)=='') return array('Fault'=>'empty reply');
  697. $prev=libxml_use_internal_errors(true);
  698. $sxe = new SimpleXMLElement($response);
  699. $dom_sxe = dom_import_simplexml($sxe);
  700. $dom = new DOMDocument('1.0');
  701. $dom_sxe = $dom->importNode($dom_sxe, true);
  702. $dom_sxe = $dom->appendChild($dom_sxe);
  703. $element = $dom->childNodes->item(0);
  704. foreach ($sxe->getDocNamespaces() as $name => $uri) {
  705. $element->removeAttributeNS($uri, $name);
  706. }
  707. $xmldata=$dom->saveXML();
  708. $b=strpos($xmldata,"<Envelope>");
  709. $e=strpos($xmldata,"</Envelope>");
  710. if ($b===false || $e===false) { libxml_use_internal_errors($prev); return array('Fault'=>'reply is not a SOAP envelope'); }
  711. $xmldata=substr($xmldata,$b,$e+strlen("</Envelope>")-$b);
  712. $xml=simplexml_load_string($xmldata);
  713. libxml_use_internal_errors($prev);
  714. if ($xml===false) return array('Fault'=>'reply is not valid XML');
  715. $data=json_decode(json_encode((array)$xml),1);
  716. $data=array($xml->getName()=>$data);
  717. return $data;
  718. } catch (Throwable $e) {
  719. if (isset($prev)) libxml_use_internal_errors($prev);
  720. return array('Fault'=>'reply is not XML: '.$e->getMessage());
  721. }
  722. }
  723. /*
  724. Values put into the XML of a request (user name, profile / preset / node tokens, preset name ...)
  725. must be XML-escaped: a user name like "a&b" or a token with "&" or "<" made the request
  726. malformed - the camera rejected it and the UI reported "Credentials are Wrong!".
  727. Only strings are escaped: numbers and booleans are replaced as before.
  728. */
  729. protected function _xesc($v) {
  730. return is_string($v) ? htmlspecialchars($v, ENT_XML1 | ENT_QUOTES, 'UTF-8') : $v;
  731. }
  732. protected function _xescAll($values) {
  733. return array_map(array($this, '_xesc'), $values);
  734. }
  735. protected function _passwordDigest( $username, $password, $timestamp = "default", $nonce = "default" ) {
  736. if ($timestamp=='default') $timestamp=date('Y-m-d\TH:i:s.000\Z');
  737. if ($nonce=='default') $nonce=mt_rand();
  738. $REQ=array();
  739. $passdigest = base64_encode(pack('H*', sha1(pack('H*', $nonce) . pack('a*',$timestamp).pack('a*',$password))));
  740. //$passdigest=base64_encode(sha1($nonce.$timestamp.$password,true)); // alternative
  741. $REQ['USERNAME']=$username;
  742. $REQ['PASSDIGEST']=$passdigest;
  743. $REQ['NONCE']=base64_encode(pack('H*', $nonce));
  744. //$REQ['NONCE']=base64_encode($nonce); // alternative
  745. $REQ['TIMESTAMP']=$timestamp;
  746. return $REQ;
  747. }
  748. protected function _send_request($url,$post_string) {
  749. $soap_do = curl_init();
  750. curl_setopt($soap_do, CURLOPT_URL, $url );
  751. if ($this->proxyhost!='' && $this->proxyport!='') {
  752. curl_setopt($soap_do, CURLOPT_PROXY, $this->proxyhost);
  753. curl_setopt($soap_do, CURLOPT_PROXYPORT, $this->proxyport);
  754. if ($this->proxyusername!='' && $this->proxypassword!='')
  755. curl_setopt($soap_do, CURLOPT_PROXYUSERPWD, $this->proxyusername.':'.$this->proxypassword);
  756. }
  757. curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 2 );
  758. curl_setopt($soap_do, CURLOPT_TIMEOUT, 2 );
  759. curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true );
  760. curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false);
  761. //curl_setopt($soap_do, CURLOPT_VERBOSE, true);
  762. //curl_setopt($soap_do, CURLOPT_DEBUG, true);
  763. curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false);
  764. curl_setopt($soap_do, CURLOPT_POST, true );
  765. curl_setopt($soap_do, CURLOPT_POSTFIELDS, $post_string);
  766. curl_setopt($soap_do, CURLOPT_HTTPHEADER, array('Expect:', 'Content-Type: application/soap+xml; charset=utf-8', 'Content-Length: '.strlen($post_string) ));
  767. switch( $this->AuthMethod ){
  768. case 0: curl_setopt($soap_do, CURLOPT_HTTPAUTH, CURLAUTH_BASIC ); break;
  769. case 1: curl_setopt($soap_do, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST ); break;
  770. case 2: curl_setopt($soap_do, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST_IE ); break;
  771. case 3: curl_setopt($soap_do, CURLOPT_HTTPAUTH, CURLAUTH_BEARER ); break;
  772. case 4: curl_setopt($soap_do, CURLOPT_HTTPAUTH, CURLAUTH_NEGOTIATE ); break;
  773. case 5: curl_setopt($soap_do, CURLOPT_HTTPAUTH, CURLAUTH_NTLM ); break;
  774. case 6: curl_setopt($soap_do, CURLOPT_HTTPAUTH, CURLAUTH_NTLM_WB ); break;
  775. case 7: curl_setopt($soap_do, CURLOPT_HTTPAUTH, CURLAUTH_ANY ); break;
  776. case 8: curl_setopt($soap_do, CURLOPT_HTTPAUTH, CURLAUTH_ANYSAFE ); break;
  777. case 9: curl_setopt($soap_do, CURLOPT_HTTPAUTH, CURLAUTH_ONLY ); break;
  778. case 10: curl_setopt($soap_do, CURLOPT_HTTPAUTH, CURLAUTH_AWS_SIGV4 ); break;
  779. };
  780. curl_setopt($soap_do, CURLOPT_USERPWD, $this->username . ":" . $this->password); // HTTP authentication
  781. if ( ($result = curl_exec($soap_do)) === false) {
  782. $err = curl_error($soap_do);
  783. $this->lastresponse=array("Fault"=>$err);
  784. } else {
  785. //echo "QU: {$url}\n";
  786. //echo "\n------------------\n";
  787. //var_dump( $post_string );
  788. //echo "\n~~~~~~~~~~~~~~~~~~\n";
  789. //var_dump( $result );
  790. $this->lastresponse=$this->_xml2array($result);
  791. if (isset($this->lastresponse['Fault']) && is_string($this->lastresponse['Fault'])) {
  792. $code=curl_getinfo($soap_do, CURLINFO_HTTP_CODE);
  793. $this->lastresponse['Fault']='HTTP '.$code.': '.$this->lastresponse['Fault']; // e.g. "HTTP 401: reply is not a SOAP envelope"
  794. }
  795. }
  796. return $this->lastresponse;
  797. }
  798. } // end class
  799. ?>