@@ -40,7 +40,7 @@ function execONVIF($cmd) {
4040 $ html_output
4141 Please run the following command from a command line for more information:
4242 $ shell_command "
43- );
43+ );
4444 } else {
4545 ZM \Debug ('Results from probe: ' .implode ('<br/> ' , $ output ));
4646 }
@@ -58,17 +58,17 @@ function probeCameras($localIp) {
5858 $ device_ep = $ matches [1 ];
5959 $ soapversion = $ matches [2 ];
6060 $ camera = array (
61- 'model ' => 'Unknown ONVIF Camera ' ,
62- 'monitor ' => array (
63- 'Function ' => 'Monitor ' ,
64- 'Type ' => 'Ffmpeg ' ,
65- 'Host ' => $ device_ep ,
66- 'SOAP ' => $ soapversion ,
67- 'ConfigURL ' => $ device_ep ,
68- 'ConfigOptions ' => 'SOAP ' . $ soapversion ,
69- 'Notes ' => '' ,
70- ),
71- );
61+ 'model ' => 'Unknown ONVIF Camera ' ,
62+ 'monitor ' => array (
63+ 'Function ' => 'Monitor ' ,
64+ 'Type ' => 'Ffmpeg ' ,
65+ 'Host ' => $ device_ep ,
66+ 'SOAP ' => $ soapversion ,
67+ 'ConfigURL ' => $ device_ep ,
68+ 'ConfigOptions ' => 'SOAP ' . $ soapversion ,
69+ 'Notes ' => '' ,
70+ ),
71+ );
7272 foreach ( preg_split ('|,\s*| ' , $ matches [3 ]) as $ attr_val ) {
7373 if ( preg_match ('|(.+)= \'(.*) \'| ' , $ attr_val , $ tokens ) ) {
7474 if ( $ tokens [1 ] == 'hardware ' ) {
@@ -117,17 +117,17 @@ function probeProfiles($device_ep, $soapversion, $username, $password) {
117117 ZM \Debug (print_r ($ matches , true ));
118118
119119 $ profile = array ( # 'monitor' part of camera
120- 'Type ' => 'Ffmpeg ' ,
121- 'Width ' => $ matches [4 ],
122- 'Height ' => $ matches [5 ],
123- 'MaxFPS ' => $ matches [6 ],
124- 'Path ' => $ stream_uri ,
125- // local-only:
126- 'Profile ' => $ matches [1 ],
127- 'Name ' => $ matches [2 ],
128- 'Encoding ' => $ matches [3 ],
129- 'Transport ' => $ matches [7 ],
130- );
120+ 'Type ' => 'Ffmpeg ' ,
121+ 'Width ' => $ matches [4 ],
122+ 'Height ' => $ matches [5 ],
123+ 'MaxFPS ' => $ matches [6 ],
124+ 'Path ' => $ stream_uri ,
125+ // local-only:
126+ 'Profile ' => $ matches [1 ],
127+ 'Name ' => $ matches [2 ],
128+ 'Encoding ' => $ matches [3 ],
129+ 'Transport ' => $ matches [7 ],
130+ );
131131 $ profiles [] = $ profile ;
132132 } else {
133133 ZM \Debug ("Line did not match preg: $ line " );
@@ -145,86 +145,86 @@ function probeProfiles($device_ep, $soapversion, $username, $password) {
145145getBodyTopHTML ();
146146echo getNavBarHTML ();
147147?>
148- <div id="page">
149- <?php
150- if (!isset ($ _REQUEST ['step ' ]) || ($ _REQUEST ['step ' ] == '1 ' )) {
151- $ monitors = array ();
152- foreach ( dbFetchAll ("SELECT Id, Name, Host FROM Monitors WHERE Type='Remote' ORDER BY Host " ) as $ monitor ) {
153- if ( preg_match ('/^(.+)@(.+)$/ ' , $ monitor ['Host ' ], $ matches ) ) {
154- //echo "1: ".$matches[2]." = ".gethostbyname($matches[2])."<br/>";
155- $ monitors [gethostbyname ($ matches [2 ])] = $ monitor ;
156- } else {
157- //echo "2: ".$monitor['Host']." = ".gethostbyname($monitor['Host'])."<br/>";
158- $ monitors [gethostbyname ($ monitor ['Host ' ])] = $ monitor ;
148+ <div id="page">
149+ <?php
150+ if (!isset ($ _REQUEST ['step ' ]) || ($ _REQUEST ['step ' ] == '1 ' )) {
151+ $ monitors = array ();
152+ foreach ( dbFetchAll ("SELECT Id, Name, Host FROM Monitors WHERE Type='Remote' ORDER BY Host " ) as $ monitor ) {
153+ if ( preg_match ('/^(.+)@(.+)$/ ' , $ monitor ['Host ' ], $ matches ) ) {
154+ //echo "1: ".$matches[2]." = ".gethostbyname($matches[2])."<br/>";
155+ $ monitors [gethostbyname ($ matches [2 ])] = $ monitor ;
156+ } else {
157+ //echo "2: ".$monitor['Host']." = ".gethostbyname($monitor['Host'])."<br/>";
158+ $ monitors [gethostbyname ($ monitor ['Host ' ])] = $ monitor ;
159+ }
159160 }
160- }
161161
162- $ detcameras = probeCameras ('' );
163- foreach ($ detcameras as $ camera ) {
164- if (preg_match ('|([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)| ' , $ camera ['monitor ' ]['Host ' ], $ matches )) {
165- $ ip = $ matches [1 ];
162+ $ detcameras = probeCameras ('' );
163+ foreach ($ detcameras as $ camera ) {
164+ if (preg_match ('|([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)| ' , $ camera ['monitor ' ]['Host ' ], $ matches )) {
165+ $ ip = $ matches [1 ];
166+ }
167+ $ host = $ ip ;
168+ $ sourceDesc = base64_encode (json_encode ($ camera ['monitor ' ]));
169+ $ sourceString = $ camera ['model ' ].' @ ' .$ host .' using version ' .$ camera ['monitor ' ]['SOAP ' ];
170+ $ cameras [$ sourceDesc ] = $ sourceString ;
166171 }
167- $ host = $ ip ;
168- $ sourceDesc = base64_encode (json_encode ($ camera ['monitor ' ]));
169- $ sourceString = $ camera ['model ' ].' @ ' .$ host .' using version ' .$ camera ['monitor ' ]['SOAP ' ];
170- $ cameras [$ sourceDesc ] = $ sourceString ;
171- }
172172
173- if (count ($ cameras ) <= 0 )
174- $ cameras [0 ] = translate ('NoDetectedCameras ' );
175- ?>
176- <h2><?php echo translate ('MonitorProbe ' ) ?> </h2>
177- <div id="content">
178- <form name="contentForm" id="contentForm" method="post" action="?">
179- <input type="hidden" name="view" value="none"/>
180- <input type="hidden" name="mid" value="<?php echo validNum ($ _REQUEST ['mid ' ]) ?> "/>
181- <input type="hidden" name="step" value=""/>
173+ if (count ($ cameras ) <= 0 )
174+ $ cameras [0 ] = translate ('NoDetectedCameras ' );
175+ ?>
176+ <h2><?php echo translate ('MonitorProbe ' ) ?> </h2>
177+ <div id="content">
178+ <form name="contentForm" id="contentForm" method="post" action="?">
179+ <input type="hidden" name="view" value="none"/>
180+ <input type="hidden" name="mid" value="<?php echo validNum ($ _REQUEST ['mid ' ]) ?> "/>
181+ <input type="hidden" name="step" value=""/>
182+ <p>
183+ <?php echo translate ('OnvifProbeIntro ' ) ?>
184+ </p>
185+ <p><label for="interface"><?php echo translate ('Interface ' ) ?> </label>
186+ <?php
187+ $ interfaces = get_networks ();
188+ $ default_interface = isset ($ interfaces ['default ' ]) ? $ interfaces ['default ' ] : null ;
189+ unset($ interfaces ['default ' ]);
190+
191+ echo htmlSelect ('interface ' , $ interfaces ,
192+ (isset ($ _REQUEST ['interface ' ]) ? $ _REQUEST ['interface ' ] : $ default_interface ),
193+ array ('data-on-change-this ' =>'changeInterface ' ) );
194+ ?>
195+ </p>
196+ <div id="DetectedCameras">
182197 <p>
183- <?php echo translate ('OnvifProbeIntro ' ) ?>
198+ <label for="probe"><?php echo translate ('DetectedCameras ' ) ?> </label>
199+ <?php echo htmlSelect ('probe ' , $ cameras , null , array ('data-on-change-this ' =>'configureButtons ' )); ?>
184200 </p>
185- <p><label for="interface"><?php echo translate ('Interface ' ) ?> </label>
186- <?php
187- $ interfaces = get_networks ();
188- $ default_interface = isset ($ interfaces ['default ' ]) ? $ interfaces ['default ' ] : null ;
189- unset($ interfaces ['default ' ]);
190-
191- echo htmlSelect ('interface ' , $ interfaces ,
192- (isset ($ _REQUEST ['interface ' ]) ? $ _REQUEST ['interface ' ] : $ default_interface ),
193- array ('data-on-change-this ' =>'changeInterface ' ) );
194- ?>
201+ <p>
202+ <?php echo translate ('OnvifCredentialsIntro ' ) ?>
195203 </p>
196- <div id="DetectedCameras">
197- <p>
198- <label for="probe"><?php echo translate ('DetectedCameras ' ) ?> </label>
199- <?php echo htmlSelect ('probe ' , $ cameras , null , array ('data-on-change-this ' =>'configureButtons ' )); ?>
200- </p>
201- <p>
202- <?php echo translate ('OnvifCredentialsIntro ' ) ?>
203- </p>
204- <p>
205- <label for="Username"><?php echo translate ('Username ' ) ?> </label>
206- <input type="text" name="Username" data-on-change-this="configureButtons"/>
207- </p>
208- <p>
209- <label for="Password"><?php echo translate ('Password ' ) ?> </label>
210- <input type="password" name="Password" id="Password" data-on-change-this="configureButtons"/>
211- <span class="material-icons md-18" data-on-click-this="toggle_password_visibility" data-password-input="Password">visibility</span>
212- </p>
213- </div>
214- <div id="contentButtons">
215- <button type="button" data-on-click="backWindow"><?php echo translate ('Cancel ' ) ?> </button>
216- <button type="button" name="nextBtn" data-on-click-this="gotoStep2" disabled="disabled"><?php echo translate ('Next ' ) ?> </button>
217- </div>
218- </form>
219- </div>
204+ <p>
205+ <label for="Username"><?php echo translate ('Username ' ) ?> </label>
206+ <input type="text" name="Username" data-on-change-this="configureButtons"/>
207+ </p>
208+ <p>
209+ <label for="Password"><?php echo translate ('Password ' ) ?> </label>
210+ <input type="password" name="Password" id="Password" data-on-change-this="configureButtons"/>
211+ <span class="material-icons md-18" data-on-click-this="toggle_password_visibility" data-password-input="Password">visibility</span>
212+ </p>
213+ </div>
214+ <div id="contentButtons">
215+ <button type="button" data-on-click="backWindow"><?php echo translate ('Cancel ' ) ?> </button>
216+ <button type="button" name="nextBtn" data-on-click-this="gotoStep2" disabled="disabled"><?php echo translate ('Next ' ) ?> </button>
217+ </div>
218+ </form>
220219 </div>
220+ </div>
221221<?php
222222
223223//==== STEP 2 ============================================================
224224} else if ($ _REQUEST ['step ' ] == '2 ' ) {
225- if (empty ($ _REQUEST ['probe ' ]))
225+ if (empty ($ _REQUEST ['probe ' ]))
226226 ZM \Fatal ('No probe passed in request. Please go back and try again. ' );
227-
227+
228228 $ probe = json_decode (base64_decode ($ _REQUEST ['probe ' ]));
229229 ZM \Debug (print_r ($ probe , true ));
230230 foreach ($ probe as $ name =>$ value ) {
@@ -238,29 +238,21 @@ function probeProfiles($device_ep, $soapversion, $username, $password) {
238238
239239 $ detprofiles = probeProfiles ($ monitor ['Host ' ], $ monitor ['SOAP ' ], $ _REQUEST ['Username ' ], $ _REQUEST ['Password ' ]);
240240 foreach ($ detprofiles as $ profile ) {
241- $ monitor = $ camera ['monitor ' ];
241+ $ monitor = $ camera ['monitor ' ];
242242
243- if (PHP_VERSION_ID >= 80200 ) { // strings ${xxx} are depreated, use {$xxx} instead
244- eval (<<<'PHP'
245- $sourceString = "{$profile['Name']} : {$profile['Encoding']}" .
246- " ({$profile['Width']}x{$profile['Height']} @ {$profile['MaxFPS']}fps {$profile['Transport']})";
247- PHP);
248- } else {
249- eval (<<<'PHP'
250- $sourceString = "${profile['Name']} : ${profile['Encoding']}" .
251- " (${profile['Width']}x${profile['Height']} @ ${profile['MaxFPS']}fps ${profile['Transport']})";
252- PHP);
253- }
243+
244+ $ sourceString = $ profile ['Name ' ] . ' : ' . $ profile ['Encoding ' ] .
245+ ' ( ' . $ profile ['Width ' ] . 'x ' . $ profile ['Height ' ] . ' @ ' . $ profile ['MaxFPS ' ] . 'fps ' . $ profile ['Transport ' ] . ') ' ;
254246
255247 // copy technical details
256248 $ monitor ['Width ' ] = $ profile ['Width ' ];
257249 $ monitor ['Height ' ] = $ profile ['Height ' ];
258250 if ( $ profile ['Transport ' ] == 'RTP-Multicast ' ) {
259- $ monitor ['Method ' ] = 'rtpMulti ' ;
251+ $ monitor ['Method ' ] = 'rtpMulti ' ;
260252 } else if ( $ profile ['Transport ' ] == 'RTP-Unicast ' ) {
261- $ monitor ['Method ' ] = 'rtpUni ' ;
253+ $ monitor ['Method ' ] = 'rtpUni ' ;
262254 } else {
263- $ monitor ['Method ' ] = 'rtpRtsp ' ;
255+ $ monitor ['Method ' ] = 'rtpRtsp ' ;
264256 }
265257 // The maxfps fields do not work for ip streams. Can re-enable if that is fixed.
266258 // $monitor['MaxFPS'] = $profile['MaxFPS'];
@@ -274,29 +266,29 @@ function probeProfiles($device_ep, $soapversion, $username, $password) {
274266 if (count ($ profiles ) <= 0 )
275267 $ profiles [0 ] = translate ('NoDetectedProfiles ' );
276268?>
277- <div id="header">
278- <h2><?php echo translate ('ProfileProbe ' ) ?> </h2>
269+ <div id="header">
270+ <h2><?php echo translate ('ProfileProbe ' ) ?> </h2>
271+ </div>
272+ <div id="content">
273+ <form name="contentForm" id="contentForm" method="post" action="?">
274+ <input type="hidden" name="view" value="none"/>
275+ <input type="hidden" name="mid" value="<?php echo validNum ($ _REQUEST ['mid ' ]) ?> "/>
276+ <input type="hidden" name="step"/>
277+ <p>
278+ <?php echo translate ('ProfileProbeIntro ' ) ?>
279+ </p>
280+ <p>
281+ <label for="probe"><?php echo translate ('DetectedProfiles ' ) ?> </label>
282+ <?php echo htmlSelect ('probe ' , $ profiles , null , array ('data-on-change-this ' =>'configureButtons ' )); ?>
283+ </p>
284+ <div id="contentButtons">
285+ <button type="button" name="prevBtn" data-on-click-this="gotoStep1"><?php echo translate ('Prev ' ) ?> </button>
286+ <button type="button" data-on-click="closeWindow"><?php echo translate ('Cancel ' ) ?> </button>
287+ <button type="button" name="saveBtn" data-on-click-this="submitCamera" disabled="disabled"><?php echo translate ('Save ' ) ?> </button>
279288 </div>
280- <div id="content">
281- <form name="contentForm" id="contentForm" method="post" action="?">
282- <input type="hidden" name="view" value="none"/>
283- <input type="hidden" name="mid" value="<?php echo validNum ($ _REQUEST ['mid ' ]) ?> "/>
284- <input type="hidden" name="step"/>
285- <p>
286- <?php echo translate ('ProfileProbeIntro ' ) ?>
287- </p>
288- <p>
289- <label for="probe"><?php echo translate ('DetectedProfiles ' ) ?> </label>
290- <?php echo htmlSelect ('probe ' , $ profiles , null , array ('data-on-change-this ' =>'configureButtons ' )); ?>
291- </p>
292- <div id="contentButtons">
293- <button type="button" name="prevBtn" data-on-click-this="gotoStep1"><?php echo translate ('Prev ' ) ?> </button>
294- <button type="button" data-on-click="closeWindow"><?php echo translate ('Cancel ' ) ?> </button>
295- <button type="button" name="saveBtn" data-on-click-this="submitCamera" disabled="disabled"><?php echo translate ('Save ' ) ?> </button>
296- </div>
297- </form>
298- </div>
299- </div>
289+ </form>
290+ </div>
291+ </div>
300292<?php
301293} // end if step 1 or 2
302294?>
0 commit comments