$file_original = $options['file']; // decrypt if required if (SNAP_WI_CRYPT) { $file = snap_decrypt($file, SNAP_WI_CRYPT); } // ensure file path matches test path prefix $file = str_replace(array('..', '//'), array('.', '/'), $file); if (!is_file($file)) { echo ''; exit; } if (strpos($file, SNAP_WI_TEST_PATH) !== 0 || !preg_match('#' . SNAP_WI_TEST_MATCH . '#', $file)) { echo ''; exit; } $analyzer = new Snap_FileAnalyzer(); $results = $analyzer->analyzeFile($file); $output = array(); foreach ($results as $klassname => $classes) { if (!is_array($classes)) { $out = array(); $out['file'] = $file_original; $out['error'] = $classes; $output[] = $out; continue; } foreach ($classes as $klass => $test) { $out = array(); $out['file'] = $file_original; $out['klass'] = $klassname; $out['test'] = $test;
$help = $options['help']; $test = $options['test']; $analyze = $options['analyze']; define('SNAPTEST_VERBOSE_MODE', $options['verbose']); writelog('Initialized'); // help output if no path is specified if ((!$path || $help) && !$test) { echo SNAP_usage(); exit; } // okay, there is some sort of path, get a realpath for it $path = realpath($path); // analyze subprocess if ($analyze) { writelog('Doing analyze substep'); $analyzer = new Snap_FileAnalyzer(); $results = $analyzer->analyzeFile($path); echo SNAPTEST_TOKEN_START; echo serialize($results); echo SNAPTEST_TOKEN_END; echo SNAP_STREAM_ENDING_TOKEN; exit; } // test subprocess if ($test) { // new reporter in phpserializer mode $snap = new Snap_Tester('phpserializer'); // unencode $test = Snap_Request::decodeTestKey($test); // include the file, so that all base components are there require_once $test['file'];