1, 'Name'=>'no path', 'Path'=>''), array('Id'=>2, 'Name'=>'file', 'Path'=>'/var/lib/video.mp4'), array('Id'=>3, 'Name'=>'camera', 'Path'=>'rtsp://10.0.0.5/stream'), ); } $dir = __DIR__.'/../../web/skins/classic/views/'; $mp = file_get_contents($dir.'monitorprobe.php'); if (!preg_match('/^function probeNetwork\(\).*?^\} # end function probeNetwork\(\)/ms', $mp, $m)) { echo "FAIL - probeNetwork() not found\n"; exit(1); } eval($m[0]); $warnings = array(); set_error_handler(function($no, $str) use (&$warnings) { $warnings[] = $str; return true; }); $_REQUEST = array(); $result = probeNetwork(); restore_error_handler(); check('Ffmpeg monitors without a host raise no warnings', $warnings, array()); check('probeNetwork still returns', $result, array()); $op = file_get_contents($dir.'onvifprobe.php'); foreach (array('cameras', 'profiles') as $v) { if (!preg_match('/^ if \(count\(\$'.$v.'\) <= \d\)\n \$'.$v.'\[0\] = [^\n]*;/m', $op, $m)) { echo "FAIL - $v placeholder code not found\n"; $failures++; continue; } $$v = array(0 => 'Choose'); eval($m[0]); check("no detected $v shows the not-detected text", $$v[0], $v == 'cameras' ? 'NoDetectedCameras' : 'NoDetectedProfiles'); $$v = array(0 => 'Choose', 'abc' => 'one'); eval($m[0]); check("one detected entry keeps the choose text for $v", $$v[0], 'Choose'); } exit($failures ? 1 : 0); }