@ -173,10 +173,10 @@ class Ponvif {
" %%PASSWORD%% " ,
" %%PASSWORD%% " ,
" %%NONCE%% " ,
" %%NONCE%% " ,
" %%CREATED%% " ),
" %%CREATED%% " ),
array ( $REQ [ 'USERNAME' ],
$this -> _xescAll ( array ( $REQ [ 'USERNAME' ],
$REQ [ 'PASSDIGEST' ],
$REQ [ 'PASSDIGEST' ],
$REQ [ 'NONCE' ],
$REQ [ 'NONCE' ],
$REQ [ 'TIMESTAMP' ]),
$REQ [ 'TIMESTAMP' ])) ,
$post_string );
$post_string );
if ( $this -> isFault ( $response = $this -> _send_request ( $this -> mediauri , $post_string ))) {
if ( $this -> isFault ( $response = $this -> _send_request ( $this -> mediauri , $post_string ))) {
if ( $this -> intransingent ) throw new Exception ( 'GetCapabilities: Communication error' );
if ( $this -> intransingent ) throw new Exception ( 'GetCapabilities: Communication error' );
@ -192,10 +192,10 @@ class Ponvif {
" %%PASSWORD%% " ,
" %%PASSWORD%% " ,
" %%NONCE%% " ,
" %%NONCE%% " ,
" %%CREATED%% " ),
" %%CREATED%% " ),
array ( $REQ [ 'USERNAME' ],
$this -> _xescAll ( array ( $REQ [ 'USERNAME' ],
$REQ [ 'PASSDIGEST' ],
$REQ [ 'PASSDIGEST' ],
$REQ [ 'NONCE' ],
$REQ [ 'NONCE' ],
$REQ [ 'TIMESTAMP' ]),
$REQ [ 'TIMESTAMP' ])) ,
$post_string );
$post_string );
//echo "POST STRING:" . $post_string . "\n\n";
//echo "POST STRING:" . $post_string . "\n\n";
if ( $this -> isFault ( $response = $this -> _send_request ( $this -> mediauri , $post_string ))) {
if ( $this -> isFault ( $response = $this -> _send_request ( $this -> mediauri , $post_string ))) {
@ -213,10 +213,10 @@ class Ponvif {
" %%PASSWORD%% " ,
" %%PASSWORD%% " ,
" %%NONCE%% " ,
" %%NONCE%% " ,
" %%CREATED%% " ),
" %%CREATED%% " ),
array ( $REQ [ 'USERNAME' ],
$this -> _xescAll ( array ( $REQ [ 'USERNAME' ],
$REQ [ 'PASSDIGEST' ],
$REQ [ 'PASSDIGEST' ],
$REQ [ 'NONCE' ],
$REQ [ 'NONCE' ],
$REQ [ 'TIMESTAMP' ]),
$REQ [ 'TIMESTAMP' ])) ,
$post_string );
$post_string );
if ( $this -> isFault ( $response = $this -> _send_request ( $this -> mediauri , $post_string ))) {
if ( $this -> isFault ( $response = $this -> _send_request ( $this -> mediauri , $post_string ))) {
if ( $this -> intransingent ) throw new Exception ( 'GetProfiles: Communication error' );
if ( $this -> intransingent ) throw new Exception ( 'GetProfiles: Communication error' );
@ -232,10 +232,10 @@ class Ponvif {
" %%PASSWORD%% " ,
" %%PASSWORD%% " ,
" %%NONCE%% " ,
" %%NONCE%% " ,
" %%CREATED%% " ),
" %%CREATED%% " ),
array ( $REQ [ 'USERNAME' ],
$this -> _xescAll ( array ( $REQ [ 'USERNAME' ],
$REQ [ 'PASSDIGEST' ],
$REQ [ 'PASSDIGEST' ],
$REQ [ 'NONCE' ],
$REQ [ 'NONCE' ],
$REQ [ 'TIMESTAMP' ]),
$REQ [ 'TIMESTAMP' ])) ,
$post_string );
$post_string );
if ( $this -> isFault ( $this -> _send_request ( $this -> mediauri , $post_string ))) {
if ( $this -> isFault ( $this -> _send_request ( $this -> mediauri , $post_string ))) {
if ( $this -> intransingent ) throw new Exception ( 'GetServices: Communication error' );
if ( $this -> intransingent ) throw new Exception ( 'GetServices: Communication error' );
@ -249,10 +249,10 @@ class Ponvif {
" %%PASSWORD%% " ,
" %%PASSWORD%% " ,
" %%NONCE%% " ,
" %%NONCE%% " ,
" %%CREATED%% " ),
" %%CREATED%% " ),
array ( $REQ [ 'USERNAME' ],
$this -> _xescAll ( array ( $REQ [ 'USERNAME' ],
$REQ [ 'PASSDIGEST' ],
$REQ [ 'PASSDIGEST' ],
$REQ [ 'NONCE' ],
$REQ [ 'NONCE' ],
$REQ [ 'TIMESTAMP' ]),
$REQ [ 'TIMESTAMP' ])) ,
$post_string );
$post_string );
if ( $this -> isFault ( $response = $this -> _send_request ( $this -> mediauri , $post_string ))) {
if ( $this -> isFault ( $response = $this -> _send_request ( $this -> mediauri , $post_string ))) {
if ( $this -> intransingent ) throw new Exception ( 'GetDeviceInformation: Communication error' );
if ( $this -> intransingent ) throw new Exception ( 'GetDeviceInformation: Communication error' );
@ -272,13 +272,13 @@ class Ponvif {
" %%PROFILETOKEN%% " ,
" %%PROFILETOKEN%% " ,
" %%STREAM%% " ,
" %%STREAM%% " ,
" %%PROTOCOL%% " ),
" %%PROTOCOL%% " ),
array ( $REQ [ 'USERNAME' ],
$this -> _xescAll ( array ( $REQ [ 'USERNAME' ],
$REQ [ 'PASSDIGEST' ],
$REQ [ 'PASSDIGEST' ],
$REQ [ 'NONCE' ],
$REQ [ 'NONCE' ],
$REQ [ 'TIMESTAMP' ],
$REQ [ 'TIMESTAMP' ],
$profileToken ,
$profileToken ,
$stream ,
$stream ,
$protocol ),
$protocol )) ,
$post_string
$post_string
);
);
if ( $this -> isFault ( $response = $this -> _send_request ( $this -> mediauri , $post_string ))) {
if ( $this -> isFault ( $response = $this -> _send_request ( $this -> mediauri , $post_string ))) {
@ -296,11 +296,11 @@ class Ponvif {
" %%NONCE%% " ,
" %%NONCE%% " ,
" %%CREATED%% " ,
" %%CREATED%% " ,
" %%PROFILETOKEN%% " ),
" %%PROFILETOKEN%% " ),
array ( $REQ [ 'USERNAME' ],
$this -> _xescAll ( array ( $REQ [ 'USERNAME' ],
$REQ [ 'PASSDIGEST' ],
$REQ [ 'PASSDIGEST' ],
$REQ [ 'NONCE' ],
$REQ [ 'NONCE' ],
$REQ [ 'TIMESTAMP' ],
$REQ [ 'TIMESTAMP' ],
$profileToken ),
$profileToken )) ,
$post_string );
$post_string );
if ( $this -> isFault ( $response = $this -> _send_request ( $this -> mediauri , $post_string ))) {
if ( $this -> isFault ( $response = $this -> _send_request ( $this -> mediauri , $post_string ))) {
if ( $this -> intransingent ) throw new Exception ( 'GetSnapshotUri: Communication error' );
if ( $this -> intransingent ) throw new Exception ( 'GetSnapshotUri: Communication error' );
@ -319,11 +319,11 @@ class Ponvif {
" %%NONCE%% " ,
" %%NONCE%% " ,
" %%CREATED%% " ,
" %%CREATED%% " ,
" %%PROFILETOKEN%% " ),
" %%PROFILETOKEN%% " ),
array ( $REQ [ 'USERNAME' ],
$this -> _xescAll ( array ( $REQ [ 'USERNAME' ],
$REQ [ 'PASSDIGEST' ],
$REQ [ 'PASSDIGEST' ],
$REQ [ 'NONCE' ],
$REQ [ 'NONCE' ],
$REQ [ 'TIMESTAMP' ],
$REQ [ 'TIMESTAMP' ],
$profileToken ),
$profileToken )) ,
$post_string );
$post_string );
if ( $this -> isFault ( $response = $this -> _send_request ( $this -> ptzuri , $post_string ))) {
if ( $this -> isFault ( $response = $this -> _send_request ( $this -> ptzuri , $post_string ))) {
if ( $this -> intransingent ) throw new Exception ( 'GetPresets: Communication error' );
if ( $this -> intransingent ) throw new Exception ( 'GetPresets: Communication error' );
@ -349,11 +349,11 @@ class Ponvif {
" %%NONCE%% " ,
" %%NONCE%% " ,
" %%CREATED%% " ,
" %%CREATED%% " ,
" %%NODETOKEN%% " ),
" %%NODETOKEN%% " ),
array ( $REQ [ 'USERNAME' ],
$this -> _xescAll ( array ( $REQ [ 'USERNAME' ],
$REQ [ 'PASSDIGEST' ],
$REQ [ 'PASSDIGEST' ],
$REQ [ 'NONCE' ],
$REQ [ 'NONCE' ],
$REQ [ 'TIMESTAMP' ],
$REQ [ 'TIMESTAMP' ],
$ptzNodeToken ),
$ptzNodeToken )) ,
$post_string );
$post_string );
if ( $this -> isFault ( $response = $this -> _send_request ( $this -> ptzuri , $post_string ))) {
if ( $this -> isFault ( $response = $this -> _send_request ( $this -> ptzuri , $post_string ))) {
if ( $this -> intransingent ) throw new Exception ( 'GetNode: Communication error' );
if ( $this -> intransingent ) throw new Exception ( 'GetNode: Communication error' );
@ -375,7 +375,7 @@ class Ponvif {
" %%SPEEDPANTILTX%% " ,
" %%SPEEDPANTILTX%% " ,
" %%SPEEDPANTILTY%% " ,
" %%SPEEDPANTILTY%% " ,
" %%SPEEDZOOMX%% " ),
" %%SPEEDZOOMX%% " ),
array ( $REQ [ 'USERNAME' ],
$this -> _xescAll ( array ( $REQ [ 'USERNAME' ],
$REQ [ 'PASSDIGEST' ],
$REQ [ 'PASSDIGEST' ],
$REQ [ 'NONCE' ],
$REQ [ 'NONCE' ],
$REQ [ 'TIMESTAMP' ],
$REQ [ 'TIMESTAMP' ],
@ -383,7 +383,7 @@ class Ponvif {
$presetToken ,
$presetToken ,
$speed_pantilt_x ,
$speed_pantilt_x ,
$speed_pantilt_y ,
$speed_pantilt_y ,
$speed_zoom_x ),
$speed_zoom_x )) ,
$post_string );
$post_string );
if ( $this -> isFault ( $this -> _send_request ( $this -> ptzuri , $post_string ))) {
if ( $this -> isFault ( $this -> _send_request ( $this -> ptzuri , $post_string ))) {
if ( $this -> intransingent ) throw new Exception ( 'GotoPreset: Communication error' );
if ( $this -> intransingent ) throw new Exception ( 'GotoPreset: Communication error' );
@ -400,12 +400,12 @@ class Ponvif {
" %%CREATED%% " ,
" %%CREATED%% " ,
" %%PROFILETOKEN%% " ,
" %%PROFILETOKEN%% " ,
" %%PRESETTOKEN%% " ),
" %%PRESETTOKEN%% " ),
array ( $REQ [ 'USERNAME' ],
$this -> _xescAll ( array ( $REQ [ 'USERNAME' ],
$REQ [ 'PASSDIGEST' ],
$REQ [ 'PASSDIGEST' ],
$REQ [ 'NONCE' ],
$REQ [ 'NONCE' ],
$REQ [ 'TIMESTAMP' ],
$REQ [ 'TIMESTAMP' ],
$profileToken ,
$profileToken ,
$presetToken ),
$presetToken )) ,
$post_string );
$post_string );
if ( $this -> isFault ( $this -> _send_request ( $this -> ptzuri , $post_string ))) {
if ( $this -> isFault ( $this -> _send_request ( $this -> ptzuri , $post_string ))) {
if ( $this -> intransingent ) throw new Exception ( 'RemovePreset: Communication error' );
if ( $this -> intransingent ) throw new Exception ( 'RemovePreset: Communication error' );
@ -422,12 +422,12 @@ class Ponvif {
" %%CREATED%% " ,
" %%CREATED%% " ,
" %%PROFILETOKEN%% " ,
" %%PROFILETOKEN%% " ,
" %%PRESETNAME%% " ),
" %%PRESETNAME%% " ),
array ( $REQ [ 'USERNAME' ],
$this -> _xescAll ( array ( $REQ [ 'USERNAME' ],
$REQ [ 'PASSDIGEST' ],
$REQ [ 'PASSDIGEST' ],
$REQ [ 'NONCE' ],
$REQ [ 'NONCE' ],
$REQ [ 'TIMESTAMP' ],
$REQ [ 'TIMESTAMP' ],
$profileToken ,
$profileToken ,
$presetName ),
$presetName )) ,
$post_string );
$post_string );
if ( $this -> isFault ( $this -> _send_request ( $this -> ptzuri , $post_string ))) {
if ( $this -> isFault ( $this -> _send_request ( $this -> ptzuri , $post_string ))) {
if ( $this -> intransingent ) throw new Exception ( 'SetPreset: Communication error' );
if ( $this -> intransingent ) throw new Exception ( 'SetPreset: Communication error' );
@ -447,7 +447,7 @@ class Ponvif {
" %%TRANSLATIONPANTILTY%% " ,
" %%TRANSLATIONPANTILTY%% " ,
" %%SPEEDPANTILTX%% " ,
" %%SPEEDPANTILTX%% " ,
" %%SPEEDPANTILTY%% " ),
" %%SPEEDPANTILTY%% " ),
array ( $REQ [ 'USERNAME' ],
$this -> _xescAll ( array ( $REQ [ 'USERNAME' ],
$REQ [ 'PASSDIGEST' ],
$REQ [ 'PASSDIGEST' ],
$REQ [ 'NONCE' ],
$REQ [ 'NONCE' ],
$REQ [ 'TIMESTAMP' ],
$REQ [ 'TIMESTAMP' ],
@ -455,7 +455,7 @@ class Ponvif {
$translation_pantilt_x ,
$translation_pantilt_x ,
$translation_pantilt_y ,
$translation_pantilt_y ,
$speed_pantilt_x ,
$speed_pantilt_x ,
$speed_pantilt_y ),
$speed_pantilt_y )) ,
$post_string );
$post_string );
if ( $this -> isFault ( $this -> _send_request ( $this -> ptzuri , $post_string ))) {
if ( $this -> isFault ( $this -> _send_request ( $this -> ptzuri , $post_string ))) {
if ( $this -> intransingent ) throw new Exception ( 'RelativeMove: Communication error' );
if ( $this -> intransingent ) throw new Exception ( 'RelativeMove: Communication error' );
@ -473,13 +473,13 @@ class Ponvif {
" %%PROFILETOKEN%% " ,
" %%PROFILETOKEN%% " ,
" %%SPEEDZOOM%% " ,
" %%SPEEDZOOM%% " ,
" %%ZOOM%% " ),
" %%ZOOM%% " ),
array ( $REQ [ 'USERNAME' ],
$this -> _xescAll ( array ( $REQ [ 'USERNAME' ],
$REQ [ 'PASSDIGEST' ],
$REQ [ 'PASSDIGEST' ],
$REQ [ 'NONCE' ],
$REQ [ 'NONCE' ],
$REQ [ 'TIMESTAMP' ],
$REQ [ 'TIMESTAMP' ],
$profileToken ,
$profileToken ,
$speedZoom ,
$speedZoom ,
$zoom ),
$zoom )) ,
$post_string );
$post_string );
if ( $this -> isFault ( $this -> _send_request ( $this -> ptzuri , $post_string ))) {
if ( $this -> isFault ( $this -> _send_request ( $this -> ptzuri , $post_string ))) {
if ( $this -> intransingent ) throw new Exception ( 'RelativeMoveZoom: Communication error' );
if ( $this -> intransingent ) throw new Exception ( 'RelativeMoveZoom: Communication error' );
@ -494,11 +494,11 @@ class Ponvif {
" %%NONCE%% " ,
" %%NONCE%% " ,
" %%CREATED%% " ,
" %%CREATED%% " ,
" %%PROFILETOKEN%% " ),
" %%PROFILETOKEN%% " ),
array ( $REQ [ 'USERNAME' ],
$this -> _xescAll ( array ( $REQ [ 'USERNAME' ],
$REQ [ 'PASSDIGEST' ],
$REQ [ 'PASSDIGEST' ],
$REQ [ 'NONCE' ],
$REQ [ 'NONCE' ],
$REQ [ 'TIMESTAMP' ],
$REQ [ 'TIMESTAMP' ],
$profileToken ),
$profileToken )) ,
$post_string );
$post_string );
if ( $this -> isFault ( $response = $this -> _send_request ( $this -> ptzuri , $post_string ))) {
if ( $this -> isFault ( $response = $this -> _send_request ( $this -> ptzuri , $post_string ))) {
if ( $this -> intransingent ) throw new Exception ( 'ptz Get Status: Communication error' );
if ( $this -> intransingent ) throw new Exception ( 'ptz Get Status: Communication error' );
@ -524,7 +524,7 @@ class Ponvif {
" %%SPEEDPANTILTX%% " ,
" %%SPEEDPANTILTX%% " ,
" %%SPEEDPANTILTY%% " ,
" %%SPEEDPANTILTY%% " ,
" %%SPEEDZOOMX%% " ),
" %%SPEEDZOOMX%% " ),
array ( $REQ [ 'USERNAME' ],
$this -> _xescAll ( array ( $REQ [ 'USERNAME' ],
$REQ [ 'PASSDIGEST' ],
$REQ [ 'PASSDIGEST' ],
$REQ [ 'NONCE' ],
$REQ [ 'NONCE' ],
$REQ [ 'TIMESTAMP' ],
$REQ [ 'TIMESTAMP' ],
@ -534,7 +534,7 @@ class Ponvif {
$zoom ,
$zoom ,
$PSpeed ,
$PSpeed ,
$TSpeed ,
$TSpeed ,
$ZSpeed ),
$ZSpeed )) ,
$post_string );
$post_string );
if ( $this -> isFault ( $this -> _send_request ( $this -> ptzuri , $post_string ))) {
if ( $this -> isFault ( $this -> _send_request ( $this -> ptzuri , $post_string ))) {
if ( $this -> intransingent ) throw new Exception ( 'AbsoluteMove: Communication error' );
if ( $this -> intransingent ) throw new Exception ( 'AbsoluteMove: Communication error' );
@ -552,13 +552,13 @@ class Ponvif {
" %%PROFILETOKEN%% " ,
" %%PROFILETOKEN%% " ,
" %%VELOCITYPANTILTX%% " ,
" %%VELOCITYPANTILTX%% " ,
" %%VELOCITYPANTILTY%% " ),
" %%VELOCITYPANTILTY%% " ),
array ( $REQ [ 'USERNAME' ],
$this -> _xescAll ( array ( $REQ [ 'USERNAME' ],
$REQ [ 'PASSDIGEST' ],
$REQ [ 'PASSDIGEST' ],
$REQ [ 'NONCE' ],
$REQ [ 'NONCE' ],
$REQ [ 'TIMESTAMP' ],
$REQ [ 'TIMESTAMP' ],
$profileToken ,
$profileToken ,
$velocity_pantilt_x ,
$velocity_pantilt_x ,
$velocity_pantilt_y ),
$velocity_pantilt_y )) ,
$post_string );
$post_string );
if ( $this -> isFault ( $this -> _send_request ( $this -> ptzuri , $post_string ))) {
if ( $this -> isFault ( $this -> _send_request ( $this -> ptzuri , $post_string ))) {
if ( $this -> intransingent ) throw new Exception ( 'ContinuousMove: Communication error' );
if ( $this -> intransingent ) throw new Exception ( 'ContinuousMove: Communication error' );
@ -575,12 +575,12 @@ class Ponvif {
" %%CREATED%% " ,
" %%CREATED%% " ,
" %%PROFILETOKEN%% " ,
" %%PROFILETOKEN%% " ,
" %%ZOOM%% " ),
" %%ZOOM%% " ),
array ( $REQ [ 'USERNAME' ],
$this -> _xescAll ( array ( $REQ [ 'USERNAME' ],
$REQ [ 'PASSDIGEST' ],
$REQ [ 'PASSDIGEST' ],
$REQ [ 'NONCE' ],
$REQ [ 'NONCE' ],
$REQ [ 'TIMESTAMP' ],
$REQ [ 'TIMESTAMP' ],
$profileToken ,
$profileToken ,
$zoom ),
$zoom )) ,
$post_string );
$post_string );
if ( $this -> isFault ( $this -> _send_request ( $this -> ptzuri , $post_string ))) {
if ( $this -> isFault ( $this -> _send_request ( $this -> ptzuri , $post_string ))) {
if ( $this -> intransingent ) throw new Exception ( 'ContinuousMoveZoom: Communication error' );
if ( $this -> intransingent ) throw new Exception ( 'ContinuousMoveZoom: Communication error' );
@ -598,13 +598,13 @@ class Ponvif {
" %%PROFILETOKEN%% " ,
" %%PROFILETOKEN%% " ,
" %%PANTILT%% " ,
" %%PANTILT%% " ,
" %%ZOOM%% " ),
" %%ZOOM%% " ),
array ( $REQ [ 'USERNAME' ],
$this -> _xescAll ( array ( $REQ [ 'USERNAME' ],
$REQ [ 'PASSDIGEST' ],
$REQ [ 'PASSDIGEST' ],
$REQ [ 'NONCE' ],
$REQ [ 'NONCE' ],
$REQ [ 'TIMESTAMP' ],
$REQ [ 'TIMESTAMP' ],
$profileToken ,
$profileToken ,
$pantilt ,
$pantilt ,
$zoom ),
$zoom )) ,
$post_string );
$post_string );
if ( $this -> isFault ( $this -> _send_request ( $this -> ptzuri , $post_string ))) {
if ( $this -> isFault ( $this -> _send_request ( $this -> ptzuri , $post_string ))) {
if ( $this -> intransingent ) throw new Exception ( 'Stop: Communication error' );
if ( $this -> intransingent ) throw new Exception ( 'Stop: Communication error' );
@ -707,6 +707,20 @@ class Ponvif {
return $data ;
return $data ;
}
}
/*
Values put into the XML of a request ( user name , profile / preset / node tokens , preset name ... )
must be XML - escaped : a user name like " a&b " or a token with " & " or " < " made the request
malformed - the camera rejected it and the UI reported " Credentials are Wrong! " .
Only strings are escaped : numbers and booleans are replaced as before .
*/
protected function _xesc ( $v ) {
return is_string ( $v ) ? htmlspecialchars ( $v , ENT_XML1 | ENT_QUOTES , 'UTF-8' ) : $v ;
}
protected function _xescAll ( $values ) {
return array_map ( array ( $this , '_xesc' ), $values );
}
protected function _passwordDigest ( $username , $password , $timestamp = " default " , $nonce = " default " ) {
protected function _passwordDigest ( $username , $password , $timestamp = " default " , $nonce = " default " ) {
if ( $timestamp == 'default' ) $timestamp = date ( 'Y-m-d\TH:i:s.000\Z' );
if ( $timestamp == 'default' ) $timestamp = date ( 'Y-m-d\TH:i:s.000\Z' );
if ( $nonce == 'default' ) $nonce = mt_rand ();
if ( $nonce == 'default' ) $nonce = mt_rand ();