Beispiel #1
0
 /**
  * Run the tests in this collection
  *
  * @access 	public
  * @return 	void
  */
 public function run()
 {
     $test_methods = get_class_methods($this);
     if (!is_array($this->validator->package_files) || !sizeof($this->validator->package_files)) {
         return;
     }
     foreach ($this->validator->package_files as $package_file) {
         $this->file_name = $package_file;
         if (mpv::check_unwanted($package_file)) {
             continue;
         }
         // Only test PHP files
         // We also check files that should be binary, but arent.
         // Maybe there is php in that?
         if (in_array(substr($package_file, -3), array('.md', 'txt', 'tml', 'htm', 'tpl', 'xsl', 'xml', 'css', '.js', 'sql', 'ess')) || $this->check_binary($this->validator->temp_dir . $package_file)) {
             continue;
         }
         $this->failed_tests = array();
         $this->file_contents = file_get_contents($this->validator->temp_dir . $package_file);
         $this->file_contents_file = file($this->validator->temp_dir . $package_file);
         unset($content);
         foreach ($test_methods as $method) {
             if (substr($method, 0, 5) == 'test_') {
                 if (!$this->{$method}() || $this->terminate) {
                     $this->failed_tests[] = substr($method, 5);
                 }
                 if ($this->terminate) {
                     unset($this->file_contents, $this->file_contents_file);
                     return;
                 }
             }
         }
         unset($this->file_contents, $this->file_contents_file);
     }
 }
Beispiel #2
0
 /**
  * Run the tests in this collection
  *
  * @access 	public
  * @return 	void
  */
 public function run()
 {
     $test_methods = get_class_methods($this);
     if (!is_array($this->validator->package_files) || !sizeof($this->validator->package_files)) {
         return;
     }
     foreach ($this->validator->package_files as $package_file) {
         // only test language files
         /*if (!preg_match($package_file, '#language/.+\.php#'))
         		{
         			continue;
         		}*/
         if (mpv::check_unwanted($package_file)) {
             continue;
         }
         $this->failed_tests = array();
         $this->file_name = $package_file;
         $this->file_contents = file_get_contents($this->validator->temp_dir . $package_file);
         $this->file_contents_file = file($this->validator->temp_dir . $package_file);
         foreach ($test_methods as $method) {
             if (substr($method, 0, 5) == 'test_') {
                 if (!$this->{$method}() || $this->terminate) {
                     $this->failed_tests[] = substr($method, 5);
                 }
                 if ($this->terminate) {
                     unset($this->file_contents, $this->file_contents_file);
                     return;
                 }
             }
         }
         unset($this->file_contents, $this->file_contents_file);
     }
 }
Beispiel #3
0
 /**
  * Run the tests in this collection
  *
  * @access 	public
  * @return 	void
  */
 public function run()
 {
     // Make sure these tests are enabled in MPV.
     // These tests are for security reasons disabled by default.
     // Only enable these tests if you know what you do and
     // if this MPV install isnt public usable.
     // These tests are NOT enabled at the online MPV at phpBB.com
     // if you want to use these tests you need to install MPV
     // locally.
     // If you use these tests is it at your own risk.
     if (mpv::$exec_php !== mpv::EXEC_PHP) {
         return;
     }
     $test_methods = get_class_methods($this);
     if (!is_array($this->validator->package_files) || !sizeof($this->validator->package_files)) {
         return;
     }
     foreach ($this->validator->package_files as $package_file) {
         if (mpv::check_unwanted($package_file)) {
             continue;
         }
         $this->file_name = $package_file;
         // Only test PHP files
         if (substr($package_file, -3) !== 'php') {
             continue;
         }
         $this->failed_tests = array();
         $this->file_contents = file_get_contents($this->validator->temp_dir . $package_file);
         $this->file_contents_file = file($this->validator->temp_dir . $package_file);
         unset($content);
         foreach ($test_methods as $method) {
             if (substr($method, 0, 5) == 'test_') {
                 if (!$this->{$method}() || $this->terminate) {
                     $this->failed_tests[] = substr($method, 5);
                 }
                 if ($this->terminate) {
                     unset($this->file_contents, $this->file_contents_file);
                     return;
                 }
             }
         }
         unset($this->file_contents, $this->file_contents_file);
     }
 }
Beispiel #4
0
 /**
  * Run the tests in this collection
  *
  * @access 	public
  * @return 	void
  */
 public function run()
 {
     $test_methods = get_class_methods($this);
     $files = array();
     if (is_array($this->validator->package_files)) {
         $files = array_merge($files, $this->validator->package_files);
     }
     if (is_array($this->validator->modx_files)) {
         $files = array_merge($files, $this->validator->modx_files);
     }
     foreach ($files as $package_file) {
         if (mpv::check_unwanted($package_file)) {
             continue;
         }
         // Only test html, php, xml files
         if (!in_array(strrchr($package_file, '.'), array('.php', '.xml', '.html'))) {
             continue;
         }
         $this->failed_tests = array();
         $this->file_name = $package_file;
         $this->file_contents = file_get_contents($this->validator->temp_dir . $package_file);
         $this->file_contents_file = file($this->validator->temp_dir . $package_file);
         foreach ($test_methods as $method) {
             if (substr($method, 0, 5) == 'test_') {
                 if (!$this->{$method}() || $this->terminate) {
                     $this->failed_tests[] = substr($method, 5);
                 }
                 if ($this->terminate) {
                     unset($this->file_contents, $this->file_contents_file);
                     return;
                 }
             }
         }
         unset($this->file_contents, $this->file_contents_file);
     }
 }
Beispiel #5
0
 /**
  * Test to see if prosilver.xml or english.xml exisits.
  *
  * @return bool
  * @access private
  */
 protected function test_prosilver_english()
 {
     $return = true;
     foreach ($this->validator->package_files as $filename) {
         if (mpv::check_unwanted($filename)) {
             continue;
         }
         $file = strtolower(basename($filename));
         if ($file == 'prosilver.xml' || strpos($file, 'prosilver') !== false && strpos($file, '.xml') !== false) {
             $this->push_error(mpv::ERROR_FAIL, 'PROSILVER_NO_MAIN_MODX', null, array($filename));
             $return = false;
         }
         if ($file == 'en.xml' || strpos($file, 'english') !== false && strpos($file, '.xml') !== false) {
             $this->push_error(mpv::ERROR_FAIL, 'ENGLISH_NO_MAIN_MODX', null, array($filename));
             $return = false;
         }
     }
     return $return;
 }
Beispiel #6
0
 /**
  * Run the tests in this collection
  *
  * @access 	public
  * @return 	void
  */
 public function run()
 {
     global $statistics;
     $test_methods = get_class_methods($this);
     if (!is_array($this->validator->modx_files) || !sizeof($this->validator->modx_files)) {
         $this->validator->push_error(mpv::ERROR_FAIL, 'NO_MODX_FILES');
         return;
     }
     foreach ($this->validator->modx_files as $modx_filename => $modx_object) {
         $this->modx_filename = $this->file_name = $modx_filename;
         if (mpv::check_unwanted($modx_filename)) {
             continue;
         }
         if (preg_match('#modx-(.*?)\\.xsd#s', (string) $modx_object, $matches)) {
             $current_modx_version = mpv::get_current_version('modx');
             if ($matches[1] != $current_modx_version) {
                 $this->push_error(mpv::ERROR_FAIL, 'USING_MODX_OUTDATED', array($matches[1], $current_modx_version));
                 //continue;
             }
             //Let's see if we can download the file from phpbb.compact
             if (!LOCAL_ONLY && !@file_exists($this->validator->dir . 'store/data/' . $matches[0])) {
                 $data = @file_get_contents("http://www.phpbb.com/mods/xml/{$matches[0]}");
                 //Now we write out the .xsd
                 if (isset($data) && $data !== false) {
                     $cache = @fopen($this->validator->dir . 'store/data/' . $matches[0], 'wb');
                     @fwrite($cache, $data);
                     @fclose($cache);
                 } else {
                     $this->push_error(mpv::ERROR_FAIL, sprintf('UNABLE_OPEN', "http://www.phpbb.com/mods/xml/{$matches[0]}"));
                     continue;
                 }
             }
             $errors = $modx_object->validate($this->validator->dir . 'store/data/' . $matches[0]);
         } else {
             $this->push_error(mpv::ERROR_FAIL, 'USING_MODX_UNKNOWN');
             continue;
         }
         if ($errors !== true) {
             foreach ($errors as $error) {
                 $this->push_error(mpv::ERROR_FAIL, 'MODX_SCHEMA_INVALID', $error);
             }
             continue;
         }
         $this->failed_tests = array();
         $this->modx_object = $modx_object;
         $this->modx_dir = $this->extract_dir($modx_filename);
         $mod_title = $this->modx_object->get_xpath('//header/title', true);
         //Do we need to store some statistics?
         if (sizeof($statistics)) {
             foreach ($statistics as $tag => $properties) {
                 $line_to_write = '';
                 //First we need to get the tag's existing nodes
                 $tag_node = $this->modx_object->get_by_name($tag, false);
                 //Now we go through each node to get the properties
                 foreach ($tag_node as $node) {
                     foreach ($properties as $property) {
                         if (empty($line_to_write)) {
                             //Let's start with the MOD's title
                             $line_to_write = $mod_title->value;
                         }
                         //Let's build the string we're going to save
                         $line_to_write .= "||" . $property . ": " . $node->attributes[$property];
                     }
                 }
                 if (!empty($line_to_write)) {
                     //Open text file and write to it
                     $file_handle = @fopen($this->validator->dir . 'store/data/' . $tag . '_data.txt', 'a');
                     if ($file_handle !== false) {
                         @fwrite($file_handle, $line_to_write . "\r\n");
                         @fclose($fh);
                     }
                 }
             }
         }
         foreach ($test_methods as $method) {
             if (substr($method, 0, 5) == 'test_') {
                 if (!$this->{$method}() || $this->terminate) {
                     $this->failed_tests[] = substr($method, 5);
                 }
                 if ($this->terminate) {
                     return;
                 }
             }
         }
     }
 }