├── .gitignore ├── tests ├── code │ ├── testcode │ │ ├── emptyFile │ │ ├── short1 │ │ ├── short2 │ │ ├── short3 │ │ ├── dbal │ │ │ ├── db2 │ │ │ ├── oci │ │ │ ├── pg │ │ │ ├── ibase │ │ │ ├── mssql │ │ │ ├── mysql │ │ │ ├── mysqli │ │ │ ├── odbc │ │ │ ├── sqlite │ │ │ └── sqlsrv │ │ ├── functions │ │ │ ├── die │ │ │ ├── eval │ │ │ ├── exec │ │ │ ├── md5 │ │ │ ├── sha1 │ │ │ ├── backticks │ │ │ ├── getenv │ │ │ ├── system │ │ │ ├── addslashes │ │ │ ├── passthru │ │ │ ├── include_once │ │ │ ├── require_once │ │ │ ├── stripslashes │ │ │ ├── include_once2 │ │ │ ├── require_once2 │ │ │ ├── htmlspecialchars │ │ │ ├── md52 │ │ │ └── umilfile.php │ │ ├── short4 │ │ ├── noShort │ │ ├── noBinary │ │ ├── noinphpbb.php │ │ ├── noExtension │ │ ├── include │ │ │ ├── include6 │ │ │ ├── include1 │ │ │ ├── require1 │ │ │ ├── include7 │ │ │ ├── includeonce1 │ │ │ ├── requireonce1 │ │ │ ├── include2 │ │ │ ├── require2 │ │ │ ├── include3 │ │ │ ├── includeonce2 │ │ │ ├── requireonce2 │ │ │ ├── include4 │ │ │ └── include5 │ │ ├── inphpbb.php │ │ ├── inphpbb3.php │ │ ├── phpbb.php │ │ ├── requestVar1 │ │ ├── requestVar2 │ │ ├── requestVar3 │ │ ├── unixFile │ │ └── windowsFile │ ├── empty_test.php │ ├── unix_test.php │ ├── binary_test.php │ ├── request_var_test.php │ ├── short_test.php │ ├── in_phpbb_test.php │ ├── db_test.php │ ├── include_test.php │ ├── function_test.php │ ├── print_test.php │ ├── modx_test.php │ └── globals_test.php ├── mock │ ├── modx_license.php │ ├── modx_version.php │ └── modx_object.php ├── bootstrap.php └── test_framework │ ├── phpbb_test_case_helpers.php │ ├── mpv_mock.php │ └── phpbb_test_case.php ├── mpv ├── docs ├── AUTHORS └── COPYING ├── test-file.zip ├── includes ├── functions_compress.php ├── lib │ ├── cortex_base.php │ └── cortex_xml.php ├── tests │ ├── tests_lang.php │ ├── tests_html.php │ ├── tests_execution.php │ ├── test_base.php │ ├── tests_packaging.php │ ├── tests_modx.php │ └── tests_code.php ├── languages │ ├── en │ │ └── lang.php │ └── fr │ │ └── lang.php └── functions_mpv.php ├── .travis.yml ├── phpunit.xml.all ├── README.md ├── phpunit.xml.dist ├── cli.php ├── test.php ├── mpv_config.php ├── stats.php ├── style.css └── store └── data └── modx-1.2.6.xsd /.gitignore: -------------------------------------------------------------------------------- 1 | store/* 2 | -------------------------------------------------------------------------------- /tests/code/testcode/emptyFile: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/code/testcode/short1: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /tests/code/testcode/short2: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /tests/code/testcode/short3: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /tests/code/testcode/dbal/db2: -------------------------------------------------------------------------------- 1 | db2_connect(); 2 | -------------------------------------------------------------------------------- /tests/code/testcode/dbal/oci: -------------------------------------------------------------------------------- 1 | oci_connect(); 2 | -------------------------------------------------------------------------------- /tests/code/testcode/dbal/pg: -------------------------------------------------------------------------------- 1 | pg_connect(); 2 | -------------------------------------------------------------------------------- /tests/code/testcode/functions/die: -------------------------------------------------------------------------------- 1 | die(); 2 | -------------------------------------------------------------------------------- /tests/code/testcode/functions/eval: -------------------------------------------------------------------------------- 1 | eval(); 2 | -------------------------------------------------------------------------------- /tests/code/testcode/functions/exec: -------------------------------------------------------------------------------- 1 | exec(); 2 | -------------------------------------------------------------------------------- /tests/code/testcode/functions/md5: -------------------------------------------------------------------------------- 1 | md5(); 2 | -------------------------------------------------------------------------------- /tests/code/testcode/functions/sha1: -------------------------------------------------------------------------------- 1 | sha1(); 2 | -------------------------------------------------------------------------------- /tests/code/testcode/short4: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /tests/code/testcode/dbal/ibase: -------------------------------------------------------------------------------- 1 | ibase_connect(); 2 | -------------------------------------------------------------------------------- /tests/code/testcode/dbal/mssql: -------------------------------------------------------------------------------- 1 | mssql_connect(); 2 | -------------------------------------------------------------------------------- /tests/code/testcode/dbal/mysql: -------------------------------------------------------------------------------- 1 | mysql_connect(); 2 | -------------------------------------------------------------------------------- /tests/code/testcode/dbal/mysqli: -------------------------------------------------------------------------------- 1 | mysqli_connect(); 2 | -------------------------------------------------------------------------------- /tests/code/testcode/dbal/odbc: -------------------------------------------------------------------------------- 1 | odbc_connect(); 2 | -------------------------------------------------------------------------------- /tests/code/testcode/dbal/sqlite: -------------------------------------------------------------------------------- 1 | sqlite_connect(); 2 | -------------------------------------------------------------------------------- /tests/code/testcode/dbal/sqlsrv: -------------------------------------------------------------------------------- 1 | sqlsrv_connect(); 2 | -------------------------------------------------------------------------------- /tests/code/testcode/functions/backticks: -------------------------------------------------------------------------------- 1 | `test` 2 | -------------------------------------------------------------------------------- /tests/code/testcode/functions/getenv: -------------------------------------------------------------------------------- 1 | getenv(); 2 | -------------------------------------------------------------------------------- /tests/code/testcode/functions/system: -------------------------------------------------------------------------------- 1 | system(); 2 | -------------------------------------------------------------------------------- /tests/code/testcode/noShort: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /mpv: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | php "$(dirname $0)/cli.php" "$@" -------------------------------------------------------------------------------- /tests/code/testcode/functions/addslashes: -------------------------------------------------------------------------------- 1 | addslashes(); 2 | -------------------------------------------------------------------------------- /tests/code/testcode/functions/passthru: -------------------------------------------------------------------------------- 1 | passthru(); 2 | -------------------------------------------------------------------------------- /tests/code/testcode/noBinary: -------------------------------------------------------------------------------- 1 | This is only a textfile 2 | -------------------------------------------------------------------------------- /tests/code/testcode/noinphpbb.php: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /tests/code/testcode/functions/include_once: -------------------------------------------------------------------------------- 1 | include_once(); 2 | -------------------------------------------------------------------------------- /tests/code/testcode/functions/require_once: -------------------------------------------------------------------------------- 1 | require_once(); 2 | -------------------------------------------------------------------------------- /tests/code/testcode/functions/stripslashes: -------------------------------------------------------------------------------- 1 | stripslashes(); 2 | -------------------------------------------------------------------------------- /tests/code/testcode/functions/include_once2: -------------------------------------------------------------------------------- 1 | include_once ''; 2 | -------------------------------------------------------------------------------- /tests/code/testcode/functions/require_once2: -------------------------------------------------------------------------------- 1 | require_once 'file'; 2 | -------------------------------------------------------------------------------- /tests/code/testcode/noExtension: -------------------------------------------------------------------------------- 1 | This is a binary file. 2 | � 3 | -------------------------------------------------------------------------------- /docs/AUTHORS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpBB/mpv/master/docs/AUTHORS -------------------------------------------------------------------------------- /test-file.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpBB/mpv/master/test-file.zip -------------------------------------------------------------------------------- /tests/code/testcode/functions/htmlspecialchars: -------------------------------------------------------------------------------- 1 | htmlspecialchars(); 2 | -------------------------------------------------------------------------------- /tests/code/testcode/include/include6: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /tests/code/testcode/inphpbb.php: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /tests/code/testcode/inphpbb3.php: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /tests/code/testcode/include/include1: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /tests/code/testcode/include/require1: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /tests/code/testcode/include/include7: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /tests/code/testcode/include/includeonce1: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /tests/code/testcode/include/requireonce1: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /tests/code/testcode/phpbb.php: -------------------------------------------------------------------------------- 1 | 7 | -------------------------------------------------------------------------------- /tests/code/testcode/include/include2: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /tests/code/testcode/include/require2: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /tests/code/testcode/requestVar1: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /tests/code/testcode/requestVar2: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /tests/code/testcode/requestVar3: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /tests/code/testcode/include/include3: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /tests/code/testcode/include/includeonce2: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /tests/code/testcode/include/requireonce2: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /includes/functions_compress.php: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpBB/mpv/master/includes/functions_compress.php -------------------------------------------------------------------------------- /tests/code/testcode/include/include4: -------------------------------------------------------------------------------- 1 | 7 | -------------------------------------------------------------------------------- /tests/code/testcode/include/include5: -------------------------------------------------------------------------------- 1 | 7 | -------------------------------------------------------------------------------- /tests/code/testcode/unixFile: -------------------------------------------------------------------------------- 1 | This is a file with UNIX line ends 2 | This is a file with UNIX line ends 3 | This is a file with UNIX line ends 4 | This is a file with UNIX line ends 5 | This is a file with UNIX line ends 6 | -------------------------------------------------------------------------------- /tests/code/testcode/windowsFile: -------------------------------------------------------------------------------- 1 | This is a file with windows line ends 2 | This is a file with windows line ends 3 | This is a file with windows line ends 4 | This is a file with windows line ends 5 | This is a file with windows line ends 6 | -------------------------------------------------------------------------------- /tests/mock/modx_license.php: -------------------------------------------------------------------------------- 1 | test_case = $test_case; 19 | } 20 | 21 | public function setExpectedTriggerError($errno, $message = '') 22 | { 23 | phpbb_test_case::$expected_error = $message; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /tests/test_framework/mpv_mock.php: -------------------------------------------------------------------------------- 1 | assertEquals(phpbb_test_case::$expected_error, $message); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /tests/mock/modx_object.php: -------------------------------------------------------------------------------- 1 | xpath; 19 | } 20 | 21 | public function set_xpath($foo) 22 | { 23 | $this->xpath = $foo; 24 | } 25 | 26 | public function get_by_name($name, $return = true) 27 | { 28 | return (isset($this->data_ary[$name])) ? $this->data_ary[$name] : false; 29 | } 30 | 31 | public function set_by_name($name, $value) 32 | { 33 | $this->data_ary[$name] = $value; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /phpunit.xml.all: -------------------------------------------------------------------------------- 1 | 2 | 3 | 14 | 15 | 16 | ./tests/ 17 | 18 | 19 | 20 | 21 | 22 | ./tests/ 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MOD Pre-Validator 2 | 3 | MPV is a tool that performs basic checks on phpBB MODs. It gives hints about things that could be wrong, and rates them as NOTICE, WARNING or FAIL. 4 | 5 | It is written and maintained by the phpBB Modifications Team. 6 | 7 | http://www.phpbb.com/mods/mpv/ 8 | 9 | [![Build Status](https://secure.travis-ci.org/phpbb/mpv.png?branch=master)](http://travis-ci.org/phpbb/mpv) 10 | 11 | ## Contributions 12 | 13 | Do you have an improvement? Did you made a translation? Did you fix a bug? Fork our GitHub repo, make your changes in a separate branch, and send a pull request. 14 | Please read our guidelines first [here](http://wiki.phpbb.com/display/DEV/Sub-Project+Contribution+Guidelines) 15 | 16 | ## Bug Tracker 17 | 18 | If you find a bug, and you are unable to fix it yourself, please submit it to the [MOD Team Tools](http://www.phpbb.com/bugs/modteamtools/) bug tracker on phpBB.com. 19 | -------------------------------------------------------------------------------- /phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 14 | 15 | 16 | ./tests/ 17 | 18 | 19 | 20 | 21 | 22 | slow 23 | 24 | 25 | 26 | 27 | 28 | ./tests/ 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /cli.php: -------------------------------------------------------------------------------- 1 | #!/usr/bin/php 2 | output_type = (mpv::OUTPUT_TEXT); 47 | mpv::$exec_php = mpv::EXEC_PHP; 48 | $mpv->validate($argv[1]); 49 | 50 | print $lang['VALIDATION_RESULTS'] . "\n\n" . $mpv; 51 | -------------------------------------------------------------------------------- /tests/code/empty_test.php: -------------------------------------------------------------------------------- 1 | redirect(), expected triggered error (else false), expected returned result url (else false)) 18 | return array( 19 | array('testcode/emptyFile', 'FILE_EMPTY', false), 20 | array('testcode/noExtension', false, true), 21 | ); 22 | } 23 | 24 | protected function setUp() 25 | { 26 | parent::setUp(); 27 | 28 | $this->test = new mpv_tests_code(new mpv); 29 | } 30 | 31 | /** 32 | * @dataProvider provider 33 | */ 34 | public function test_empty($test, $expected_error, $expected_result) 35 | { 36 | global $user; 37 | $this->test->setFilename('tests/code/' . $test); 38 | 39 | if ($expected_error !== false) 40 | { 41 | $this->setExpectedTriggerError(E_USER_ERROR, $expected_error); 42 | } 43 | 44 | $result = $this->test->unittest('test_empty', array()); 45 | 46 | $this->assertEquals($expected_result, $result); 47 | } 48 | } 49 | 50 | -------------------------------------------------------------------------------- /tests/code/unix_test.php: -------------------------------------------------------------------------------- 1 | redirect(), expected triggered error (else false), expected returned result url (else false)) 18 | return array( 19 | array('testcode/windowsFile', 'NO_UNIX_ENDINGS', false), 20 | array('testcode/unixFile', false, true), 21 | ); 22 | } 23 | 24 | protected function setUp() 25 | { 26 | parent::setUp(); 27 | 28 | $this->test = new mpv_tests_code(new mpv); 29 | } 30 | 31 | /** 32 | * @dataProvider provider 33 | */ 34 | public function test_unix($test, $expected_error, $expected_result) 35 | { 36 | global $user; 37 | $this->test->setFilename('tests/code/' . $test); 38 | 39 | if ($expected_error !== false) 40 | { 41 | $this->setExpectedTriggerError(E_USER_ERROR, $expected_error); 42 | } 43 | 44 | $result = $this->test->unittest('test_unix_endings', array()); 45 | 46 | $this->assertEquals($expected_result, $result); 47 | } 48 | } 49 | 50 | -------------------------------------------------------------------------------- /tests/code/binary_test.php: -------------------------------------------------------------------------------- 1 | redirect(), expected triggered error (else false), expected returned result url (else false)) 18 | return array( 19 | array('testcode/noExtension', false, true), 20 | array('testcode/ignoreFile.php', false, false), 21 | array('testcode/noBinary', 'FILE_NON_BINARY', false), 22 | ); 23 | } 24 | 25 | protected function setUp() 26 | { 27 | parent::setUp(); 28 | 29 | $this->test = new mpv_tests_code(new mpv); 30 | } 31 | 32 | /** 33 | * @dataProvider provider 34 | */ 35 | public function test_binary($test, $expected_error, $expected_result) 36 | { 37 | global $user; 38 | 39 | if ($expected_error !== false) 40 | { 41 | $this->setExpectedTriggerError(E_USER_ERROR, $expected_error); 42 | } 43 | 44 | $result = $this->test->unittest('check_binary', array(('tests/code/' . $test))); 45 | 46 | $this->assertEquals($expected_result, $result); 47 | 48 | } 49 | } 50 | 51 | -------------------------------------------------------------------------------- /tests/test_framework/phpbb_test_case.php: -------------------------------------------------------------------------------- 1 | backupStaticAttributesBlacklist += array( 20 | 'PHP_CodeCoverage' => array('instance'), 21 | 'PHP_CodeCoverage_Filter' => array('instance'), 22 | 'PHP_CodeCoverage_Util' => array('ignoredLines', 'templateMethods'), 23 | 'PHP_Timer' => array('startTimes',), 24 | 'PHP_Token_Stream' => array('customTokens'), 25 | 'PHP_Token_Stream_CachingFactory' => array('cache'), 26 | 27 | 'phpbb_database_test_case' => array('already_connected'), 28 | ); 29 | } 30 | 31 | public function get_test_case_helpers() 32 | { 33 | if (!$this->test_case_helpers) 34 | { 35 | $this->test_case_helpers = new phpbb_test_case_helpers($this); 36 | } 37 | 38 | return $this->test_case_helpers; 39 | } 40 | 41 | public function setExpectedTriggerError($errno, $message = '') 42 | { 43 | self::$expected_error = $message; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /tests/code/request_var_test.php: -------------------------------------------------------------------------------- 1 | redirect(), expected triggered error (else false), expected returned result url (else false)) 18 | return array( 19 | array('testcode/requestVar1', false, true), 20 | array('testcode/requestVar2', 'USAGE_REQUEST_VAR_INT', false), 21 | array('testcode/requestVar3', false, true), 22 | array('testcode/short2', false, true), 23 | ); 24 | } 25 | 26 | protected function setUp() 27 | { 28 | parent::setUp(); 29 | 30 | $this->test = new mpv_tests_code(new mpv); 31 | } 32 | 33 | /** 34 | * @dataProvider provider 35 | */ 36 | public function test_request_var($test, $expected_error, $expected_result) 37 | { 38 | global $user; 39 | $this->test->setFilename('tests/code/' . $test); 40 | 41 | if ($expected_error !== false) 42 | { 43 | $this->setExpectedTriggerError(E_USER_ERROR, $expected_error); 44 | } 45 | 46 | $result = $this->test->unittest('test_request_var', array()); 47 | 48 | $this->assertEquals($expected_result, $result); 49 | } 50 | } 51 | 52 | -------------------------------------------------------------------------------- /tests/code/short_test.php: -------------------------------------------------------------------------------- 1 | redirect(), expected triggered error (else false), expected returned result url (else false)) 18 | return array( 19 | array('testcode/short1', 'SHORT_TAGS', true), 20 | array('testcode/short2', 'SHORT_TAGS', true), 21 | array('testcode/short3', 'SHORT_TAGS', true), 22 | array('testcode/short4', 'SHORT_TAGS', true), 23 | array('testcode/noShort', false, true), 24 | ); 25 | } 26 | 27 | protected function setUp() 28 | { 29 | parent::setUp(); 30 | 31 | $this->test = new mpv_tests_code(new mpv); 32 | } 33 | 34 | /** 35 | * @dataProvider provider 36 | */ 37 | public function test_short($test, $expected_error, $expected_result) 38 | { 39 | global $user; 40 | $this->test->setFilename('tests/code/' . $test); 41 | 42 | if ($expected_error !== false) 43 | { 44 | $this->setExpectedTriggerError(E_USER_ERROR, $expected_error); 45 | } 46 | 47 | $result = $this->test->unittest('test_short_tags', array()); 48 | 49 | $this->assertEquals($expected_result, $result); 50 | } 51 | } 52 | 53 | -------------------------------------------------------------------------------- /test.php: -------------------------------------------------------------------------------- 1 | output_type = ((HTML_FORMAT) ? mpv::OUTPUT_HTML : mpv::OUTPUT_BBCODE); 34 | mpv::$exec_php = mpv::EXEC_PHP; 35 | $mpv->validate('./test-file.zip'); 36 | 37 | if (HTML_HEADERS) 38 | { 39 | print ''; 40 | print ' 41 | 42 | ' . $lang['TITLE'] . ' 43 | 44 | 45 | '; 46 | } 47 | print '
'; 48 | print '
'; 49 | print '

' . $lang['VALIDATION_RESULTS'] . "


"; 50 | print '
'; 51 | print ((HTML_FORMAT) ? nl2br($mpv) : $mpv); 52 | print '
'; 53 | print '
'; 54 | print ' '; 55 | 56 | 57 | ?> 58 | -------------------------------------------------------------------------------- /includes/lib/cortex_base.php: -------------------------------------------------------------------------------- 1 | __get_() 30 | * 31 | * @access public 32 | * @param string Property name 33 | * @return mixed Property value 34 | */ 35 | public function __get($property_name) 36 | { 37 | $method_name = '__get_' . $property_name; 38 | if (method_exists($this, $method_name)) 39 | { 40 | return $this->$method_name(); 41 | } 42 | 43 | if (!property_exists($this, $property_name)) 44 | { 45 | throw new exception('Trying to get non-existing property ' . htmlspecialchar(get_class($this)) . '->' . htmlspecialchar($property_name)); 46 | } 47 | 48 | return $this->$property_name; 49 | } 50 | 51 | /** 52 | * Setter, will attempt to call $this->__set_() 53 | * 54 | * @access public 55 | * @param string Property name 56 | * @param mixed Property value 57 | * @return void 58 | */ 59 | public function __set($property_name, $property_value) 60 | { 61 | $method_name = '__set_' . $property_name; 62 | if (method_exists($this, $method_name)) 63 | { 64 | $this->$method_name($property_value); 65 | } 66 | else 67 | { 68 | $this->$property_name = $property_value; 69 | } 70 | } 71 | } 72 | ?> 73 | -------------------------------------------------------------------------------- /tests/code/in_phpbb_test.php: -------------------------------------------------------------------------------- 1 | redirect(), expected triggered error (else false), expected returned result url (else false)) 18 | return array(/* 19 | array('testcode/short1', 'SHORT_TAGS', false), 20 | array('testcode/short2', 'SHORT_TAGS', false), 21 | array('testcode/short3', 'SHORT_TAGS', false), 22 | array('testcode/short4', 'SHORT_TAGS', false),*/ 23 | array('mcp/info/mcp_test.php', false, true), 24 | array('acp/info/acp_test.php', false, true), 25 | array('ucp/info/ucp_test.php', false, true), 26 | array('testcode/inphpbb.php', false, true), 27 | array('testcode/inphpbb3.php', false, true), 28 | array('testcode/phpbb.php', false, true), 29 | array('testcode/noinphpbb.php', 'NO_IN_PHPBB', false), 30 | ); 31 | } 32 | 33 | protected function setUp() 34 | { 35 | parent::setUp(); 36 | 37 | $this->test = new mpv_tests_code(new mpv); 38 | } 39 | 40 | /** 41 | * @dataProvider provider 42 | */ 43 | public function test_in_phpbb($test, $expected_error, $expected_result) 44 | { 45 | global $user; 46 | $this->test->setFilename('tests/code/' . $test); 47 | 48 | if ($expected_error !== false) 49 | { 50 | $this->setExpectedTriggerError(E_USER_ERROR, $expected_error); 51 | } 52 | 53 | $result = $this->test->unittest('test_in_phpbb', array()); 54 | 55 | $this->assertEquals($expected_result, $result); 56 | } 57 | } 58 | 59 | -------------------------------------------------------------------------------- /tests/code/db_test.php: -------------------------------------------------------------------------------- 1 | redirect(), expected triggered error (else false), expected returned result url (else false)) 18 | return array( 19 | array('testcode/dbal/mysql', 'USAGE_MYSQL', false), 20 | array('testcode/dbal/mysqli', 'USAGE_MYSQLI', false), 21 | array('testcode/dbal/oci', 'USAGE_OCI', false), 22 | array('testcode/dbal/sqlite', 'USAGE_SQLITE', false), 23 | array('testcode/dbal/pg', 'USAGE_PG', false), 24 | array('testcode/dbal/mssql', 'USAGE_MSSQL', false), 25 | array('testcode/dbal/odbc', 'USAGE_ODBC', false), 26 | array('testcode/dbal/sqlsrv', 'USAGE_SQLSRV', false), 27 | array('testcode/dbal/ibase', 'USAGE_IBASE', false), 28 | array('testcode/dbal/db2', 'USAGE_DB2', false), 29 | array('testcode/short2', false, true), 30 | ); 31 | } 32 | 33 | protected function setUp() 34 | { 35 | parent::setUp(); 36 | 37 | $this->test = new mpv_tests_code(new mpv); 38 | } 39 | 40 | /** 41 | * @dataProvider provider 42 | */ 43 | public function test_mysql($test, $expected_error, $expected_result) 44 | { 45 | global $user; 46 | $this->test->setFilename('tests/code/' . $test); 47 | 48 | if ($expected_error !== false) 49 | { 50 | $this->setExpectedTriggerError(E_USER_ERROR, $expected_error); 51 | } 52 | 53 | $result = $this->test->unittest('test_dbal', array()); 54 | 55 | $this->assertEquals($expected_result, $result); 56 | 57 | } 58 | } 59 | 60 | -------------------------------------------------------------------------------- /mpv_config.php: -------------------------------------------------------------------------------- 1 | array('properties') 53 | $statistics = array( 54 | 'meta' => array('name', 'content'), 55 | ); 56 | 57 | ?> 58 | -------------------------------------------------------------------------------- /tests/code/testcode/functions/umilfile.php: -------------------------------------------------------------------------------- 1 | session_begin(); 23 | $auth->acl($user->data); 24 | $user->setup('viewtopic'); 25 | 26 | $file = request_var('file', ''); 27 | $filename = $phpbb_root_path . 'umil/error_files/' . $file . '.txt'; 28 | 29 | if ($user->data['user_type'] != USER_FOUNDER || // Only founders can access this. 30 | !$file || // Do we have a file name? 31 | strpos($file, '/') || strpos($file, '.')) // Make sure they are not attempting to grab files outside of the umil/error_files/ directory 32 | { 33 | header('HTTP/1.0 403 Forbidden'); 34 | trigger_error($user->lang['LINKAGE_FORBIDDEN']); 35 | } 36 | 37 | // Check if headers already sent or not able to get the file contents. 38 | if (headers_sent() || !@file_exists($filename) || !@is_readable($filename)) 39 | { 40 | // PHP track_errors setting On? 41 | if (!empty($php_errormsg)) 42 | { 43 | trigger_error($user->lang['UNABLE_TO_DELIVER_FILE'] . '
' . sprintf($user->lang['TRACKED_PHP_ERROR'], $php_errormsg)); 44 | } 45 | 46 | trigger_error('UNABLE_TO_DELIVER_FILE'); 47 | } 48 | 49 | header('Content-type: text/plain'); 50 | header('Content-Disposition: filename="' . $file . '.txt"'); 51 | 52 | $size = @filesize($filename); 53 | if ($size) 54 | { 55 | header("Content-Length: $size"); 56 | } 57 | 58 | $fp = @fopen($filename, 'rb'); 59 | if ($fp !== false) 60 | { 61 | while (!feof($fp)) 62 | { 63 | echo fread($fp, 8192); 64 | } 65 | fclose($fp); 66 | } 67 | 68 | garbage_collection(); 69 | exit_handler(); 70 | ?> 71 | -------------------------------------------------------------------------------- /tests/code/include_test.php: -------------------------------------------------------------------------------- 1 | redirect(), expected triggered error (else false), expected returned result url (else false)) 18 | return array( 19 | array('testcode/include/include1', 'INCLUDE_NO_ROOT', false), 20 | array('testcode/include/includeonce1', 'INCLUDE_NO_ROOT', false), 21 | array('testcode/include/require1', 'INCLUDE_NO_ROOT', false), 22 | array('testcode/include/requireonce1', 'INCLUDE_NO_ROOT', false), 23 | 24 | array('testcode/include/include2', 'INCLUDE_NO_PHP', false), 25 | array('testcode/include/includeonce2', 'INCLUDE_NO_PHP', false), 26 | array('testcode/include/require2', 'INCLUDE_NO_PHP', false), 27 | array('testcode/include/requireonce2', 'INCLUDE_NO_PHP', false), 28 | 29 | array('testcode/include/include3', false, true), 30 | array('testcode/include/include4', 'INCLUDE_NO_ROOT', false), 31 | array('testcode/include/include5', 'INCLUDE_NO_PHP', false), 32 | array('testcode/include/include6', false, true), 33 | array('testcode/include/include7', false, true), 34 | 35 | array('testcode/short2', false, true), 36 | ); 37 | } 38 | 39 | protected function setUp() 40 | { 41 | parent::setUp(); 42 | 43 | $this->test = new mpv_tests_code(new mpv); 44 | } 45 | 46 | /** 47 | * @dataProvider provider 48 | */ 49 | public function test_include($test, $expected_error, $expected_result) 50 | { 51 | global $user; 52 | $this->test->setFilename('tests/code/' . $test); 53 | 54 | if ($expected_error !== false) 55 | { 56 | $this->setExpectedTriggerError(E_USER_ERROR, $expected_error); 57 | } 58 | 59 | $result = $this->test->unittest('test_include', array()); 60 | 61 | $this->assertEquals($expected_result, $result); 62 | } 63 | } 64 | 65 | -------------------------------------------------------------------------------- /tests/code/function_test.php: -------------------------------------------------------------------------------- 1 | redirect(), expected triggered error (else false), expected returned result url (else false)) 18 | return array( 19 | array('testcode/dbal/mysql', false, true), 20 | array('testcode/functions/eval', 'USAGE_EVAL', false), 21 | array('testcode/functions/exec', 'USAGE_EXEC', false), 22 | array('testcode/functions/system', 'USAGE_SYSTEM', false), 23 | array('testcode/functions/passthru', 'USAGE_PASSTHRU', false), 24 | array('testcode/functions/getenv', 'USAGE_GETENV', false), 25 | array('testcode/functions/die', 'USAGE_DIE', false), 26 | array('testcode/functions/sha1', 'USAGE_SHA1', false), 27 | array('testcode/functions/addslashes', 'USAGE_ADDSLASHES', false), 28 | array('testcode/functions/htmlspecialchars', 'USAGE_HTMLSPECIALCHARS', false), 29 | array('testcode/functions/stripslashes', 'USAGE_STRIPSLASHES', false), 30 | 31 | array('testcode/functions/backticks', 'USAGE_`', false), 32 | 33 | array('testcode/functions/include_once', 'USAGE_INCLUDEONCE', false), 34 | array('testcode/functions/include_once2', 'USAGE_INCLUDEONCE', false), 35 | array('testcode/functions/require_once', 'USAGE_REQUIREONCE', false), 36 | array('testcode/functions/require_once2', 'USAGE_REQUIREONCE', false), 37 | array('testcode/functions/md5', 'USAGE_MD5', false), 38 | array('testcode/functions/md52', false, true), 39 | array('testcode/short2', false, true), 40 | ); 41 | } 42 | 43 | protected function setUp() 44 | { 45 | parent::setUp(); 46 | 47 | $this->test = new mpv_tests_code(new mpv); 48 | } 49 | 50 | /** 51 | * @dataProvider provider 52 | */ 53 | public function test_function($test, $expected_error, $expected_result) 54 | { 55 | global $user; 56 | $this->test->setFilename('tests/code/' . $test); 57 | 58 | if ($expected_error !== false) 59 | { 60 | $this->setExpectedTriggerError(E_USER_ERROR, $expected_error); 61 | } 62 | 63 | $result = $this->test->unittest('test_code', array()); 64 | 65 | if ($expected_error === false) 66 | $this->assertEquals($expected_result, $result); 67 | } 68 | } 69 | 70 | -------------------------------------------------------------------------------- /includes/tests/tests_lang.php: -------------------------------------------------------------------------------- 1 | validator->package_files) || !sizeof($this->validator->package_files)) 39 | { 40 | return; 41 | } 42 | 43 | foreach ($this->validator->package_files as $package_file) 44 | { 45 | // only test language files 46 | /*if (!preg_match($package_file, '#language/.+\.php#')) 47 | { 48 | continue; 49 | }*/ 50 | 51 | if (mpv::check_unwanted($package_file)) 52 | { 53 | continue; 54 | } 55 | 56 | $this->failed_tests = array(); 57 | 58 | $this->file_name = $package_file; 59 | $this->file_contents = file_get_contents($this->validator->temp_dir . $package_file); 60 | $this->file_contents_file = file($this->validator->temp_dir . $package_file); 61 | 62 | foreach ($test_methods as $method) 63 | { 64 | if (substr($method, 0, 5) == 'test_') 65 | { 66 | if (!$this->$method() || $this->terminate) 67 | { 68 | $this->failed_tests[] = substr($method, 5); 69 | } 70 | 71 | if ($this->terminate) 72 | { 73 | unset($this->file_contents, $this->file_contents_file); 74 | 75 | return; 76 | } 77 | } 78 | } 79 | 80 | unset($this->file_contents, $this->file_contents_file); 81 | } 82 | } 83 | 84 | /** 85 | * Test for the use of an UTF-8 byte-order-mark (BOM) 86 | * 87 | * @access private 88 | * @return bool 89 | */ 90 | protected function test_bom() 91 | { 92 | if (substr($this->file_contents, 0, 3) === $this->bom_char) 93 | { 94 | $this->push_error(mpv::ERROR_WARNING, 'USAGE_BOM'); 95 | return false; 96 | } 97 | 98 | return true; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /tests/code/print_test.php: -------------------------------------------------------------------------------- 1 | redirect(), expected triggered error (else false), expected returned result url (else false)) 18 | return array( 19 | 20 | 21 | array("", 'USAGE_PRINTR', false), 22 | array("", false, true), 23 | array("", false, true), 24 | 25 | array("", 'USAGE_VARDUMP', false), 26 | array("", 'USAGE_VARDUMP', false), 27 | array("", false, true), 28 | array("", false, true), 29 | 30 | array("", 'USAGE_PRINTF', false), 31 | array("", false, true), 32 | array("", false, true), 33 | 34 | 35 | array("", 'USAGE_ECHO', false), 36 | array("", false, true), 37 | array("", false, true), 38 | array("", 'USAGE_ECHO', false), 39 | array("", false, true), 40 | array("", false, true), 41 | 42 | array("", 'USAGE_PRINT', false), 43 | array("", false, true), 44 | array("", false, true), 45 | array("", 'USAGE_PRINT', false), 46 | array("", false, true), 47 | array("", false, true), 48 | ); 49 | } 50 | 51 | protected function setUp() 52 | { 53 | parent::setUp(); 54 | 55 | $this->test = new mpv_tests_code(new mpv); 56 | } 57 | 58 | /** 59 | * @dataProvider provider 60 | */ 61 | public function test_global($test, $expected_error, $expected_result) 62 | { 63 | global $user; 64 | $this->test->setCode('tests/code/' . $test); 65 | 66 | if ($expected_error !== false) 67 | { 68 | $this->setExpectedTriggerError(E_USER_ERROR, $expected_error); 69 | } 70 | 71 | $result = $this->test->unittest('test_echo', array()); 72 | 73 | if ($expected_error === false) 74 | $this->assertEquals($expected_result, $result); 75 | } 76 | } 77 | 78 | 79 | -------------------------------------------------------------------------------- /includes/tests/tests_html.php: -------------------------------------------------------------------------------- 1 | validator->package_files)) 33 | { 34 | $files = array_merge($files, $this->validator->package_files); 35 | } 36 | 37 | if (is_array($this->validator->modx_files)) 38 | { 39 | $files = array_merge($files, $this->validator->modx_files); 40 | } 41 | 42 | foreach ($files as $package_file) 43 | { 44 | if (mpv::check_unwanted($package_file)) 45 | { 46 | continue; 47 | } 48 | 49 | // Only test html, php, xml files 50 | if (!in_array(strrchr($package_file, '.'), array('.php', '.xml', '.html'))) 51 | { 52 | continue; 53 | } 54 | 55 | $this->failed_tests = array(); 56 | 57 | $this->file_name = $package_file; 58 | $this->file_contents = file_get_contents($this->validator->temp_dir . $package_file); 59 | 60 | $this->file_contents_file = file($this->validator->temp_dir . $package_file); 61 | 62 | foreach ($test_methods as $method) 63 | { 64 | if (substr($method, 0, 5) == 'test_') 65 | { 66 | if (!$this->$method() || $this->terminate) 67 | { 68 | $this->failed_tests[] = substr($method, 5); 69 | } 70 | 71 | if ($this->terminate) 72 | { 73 | unset($this->file_contents, $this->file_contents_file); 74 | 75 | return; 76 | } 77 | } 78 | } 79 | 80 | unset($this->file_contents, $this->file_contents_file); 81 | } 82 | } 83 | 84 | /** 85 | * Test for non closed BR tags 86 | * 87 | * @return bool 88 | */ 89 | protected function test_br() 90 | { 91 | $return = true; 92 | 93 | if (preg_match('##', $this->file_contents)) 94 | { 95 | $return = $this->display_line_code(mpv::ERROR_FAIL, 'USAGE_BR_NON_CLOSED', false, '##'); 96 | } 97 | 98 | return $return; 99 | } 100 | /** 101 | * Test for non closed IMG tags 102 | * 103 | * @return bool 104 | */ 105 | protected function test_img() 106 | { 107 | $return = true; 108 | /* 109 | * Disable this check for now, it doesnt detect it correctly atm. 110 | if (preg_match('##', $this->file_contents)) 111 | { 112 | $return = $this->display_line_code(mpv::ERROR_FAIL, 'USAGE_IMG_NON_CLOSED', false, '##'); 113 | } 114 | */ 115 | 116 | return $return; 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /tests/code/modx_test.php: -------------------------------------------------------------------------------- 1 | test = new mpv_tests_modx(new mpv()); 41 | $this->test->modx_object = new phpbb_mock_modx_object(); 42 | $this->version = new phpbb_mock_modx_version(); 43 | } 44 | 45 | /** 46 | * @dataProvider provider 47 | */ 48 | public function test_version($test, $expected_error, $expected_result) 49 | { 50 | global $user; 51 | 52 | if ($expected_error !== false) 53 | { 54 | $this->setExpectedTriggerError(E_USER_ERROR, $expected_error); 55 | } 56 | 57 | $this->version->value = $test; 58 | $this->test->modx_object->set_xpath($this->version); 59 | $result = $this->test->unittest('test_version', array()); 60 | 61 | $this->assertEquals($expected_result, $result); 62 | } 63 | 64 | public function test_version_no_object() 65 | { 66 | $this->setExpectedTriggerError(E_USER_ERROR, 'VERSION_FIELD_MISSING'); 67 | $this->version = '1.0.0'; 68 | $this->test->modx_object->set_xpath($this->version); 69 | $result = $this->test->unittest('test_version', array()); 70 | $this->assertEquals(false, $result); 71 | } 72 | 73 | public static function data_modx_license() 74 | { 75 | return array( 76 | array('http://opensource.org/licenses/gpl-license.php GNU General Public License v2', false, true), 77 | array('http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2', false, true), 78 | array('http://opensource.org/licenses/MIT', 'LICENSE_NOT_GPL2', false), 79 | array(null, 'LICENSE_FIELD_MISSING', false), 80 | ); 81 | } 82 | 83 | /** 84 | * @dataProvider data_modx_license 85 | */ 86 | public function test_modx_license($test, $expected_error, $expected_result) 87 | { 88 | global $user; 89 | 90 | if ($expected_error !== false) 91 | { 92 | $this->setExpectedTriggerError(E_USER_ERROR, $expected_error); 93 | } 94 | 95 | if (isset($test)) 96 | { 97 | $this->license = new phpbb_mock_modx_license(); 98 | $this->license->value = $test; 99 | } 100 | else 101 | { 102 | $this->license = $test; 103 | } 104 | $this->test->modx_object->set_by_name('license', $this->license); 105 | $result = $this->test->unittest('test_license', array()); 106 | 107 | $this->assertEquals($expected_result, $result); 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /includes/tests/tests_execution.php: -------------------------------------------------------------------------------- 1 | validator->package_files) || !sizeof($this->validator->package_files)) 45 | { 46 | return; 47 | } 48 | 49 | foreach ($this->validator->package_files as $package_file) 50 | { 51 | if (mpv::check_unwanted($package_file)) 52 | { 53 | continue; 54 | } 55 | 56 | $this->file_name = $package_file; 57 | 58 | // Only test PHP files 59 | if (substr($package_file, -3) !== 'php') 60 | 61 | { 62 | continue; 63 | } 64 | 65 | $this->failed_tests = array(); 66 | 67 | $this->file_contents = file_get_contents($this->validator->temp_dir . $package_file); 68 | 69 | $this->file_contents_file = file($this->validator->temp_dir . $package_file); 70 | 71 | unset($content); 72 | 73 | foreach ($test_methods as $method) 74 | { 75 | if (substr($method, 0, 5) == 'test_') 76 | { 77 | if (!$this->$method() || $this->terminate) 78 | { 79 | $this->failed_tests[] = substr($method, 5); 80 | } 81 | 82 | if ($this->terminate) 83 | { 84 | unset($this->file_contents, $this->file_contents_file); 85 | 86 | return; 87 | } 88 | } 89 | } 90 | 91 | unset($this->file_contents, $this->file_contents_file); 92 | } 93 | } 94 | 95 | /** 96 | * Tests if there are any syntax errors by default. 97 | */ 98 | protected function test_php() 99 | { 100 | 101 | $file = tempnam(sys_get_temp_dir(), 'mpv'); 102 | $file2 = tempnam(sys_get_temp_dir(), 'mpv'); 103 | $open = @fopen($file, 'wb'); 104 | 105 | if (!$open) 106 | { 107 | $this->push_error(mpv::ERROR_NOTICE, 'UNABLE_OPEN', $file); 108 | return false; 109 | } 110 | foreach(file($this->validator->temp_dir . $this->file_name) as $line) 111 | { 112 | $result = @fwrite($open, "$line\n"); 113 | 114 | if (!$result) 115 | { 116 | fclose($open); 117 | $this->push_error(mpv::ERROR_NOTICE, 'UNABLE_WRITE', $file); 118 | 119 | return; 120 | } 121 | } 122 | @fclose($file); 123 | $result = array(); 124 | $data = @exec('php -l ' . escapeshellarg($file) . " 2>&1 >/dev/null", $result); 125 | @unlink($file); 126 | 127 | if (sizeof($result)) 128 | { 129 | // looks like we have a problem. 130 | $ct = sizeof($result) ; 131 | for ($i = 0; $i < $ct; $i++) 132 | { 133 | $error = str_replace($file, $this->file_name, $result[$i]); 134 | $this->push_error(mpv::ERROR_WARNING, 'PHP_ERROR', htmlspecialchars($error)); 135 | } 136 | } 137 | 138 | return true; 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /stats.php: -------------------------------------------------------------------------------- 1 | 24 | 25 | 26 | 27 | 52 | <?php print $lang['TITLE_STATS']; ?> 53 | 54 | 55 |

56 | 57 | $properties) 64 | { 65 | $data_file = './store/data/' . $tag . '_data.txt'; 66 | 67 | if (file_exists($data_file)) 68 | { 69 | $contents = file_get_contents($data_file); 70 | $entries = explode("\r\n", $contents); 71 | 72 | foreach ($entries as $entry) 73 | { 74 | $mod_name = ''; 75 | $split_entry = explode("||", $entry); 76 | 77 | foreach ($split_entry as $entry_value) 78 | { 79 | //Check for the MOD name and assign counts as needed 80 | if (empty($mod_name)) 81 | { 82 | $mod_name = $entry_value; 83 | $mod_name_id = str_replace(' ', '_', $mod_name); 84 | if (isset($mod_count[$mod_name_id])) 85 | { 86 | $mod_count[$mod_name_id] += 1; 87 | } 88 | else 89 | { 90 | $mod_count = array_merge($mod_count, array($mod_name_id => 1)); 91 | } 92 | $entries_values[] = $entry_value; 93 | continue; 94 | } 95 | $entries_values[] = $entry_value; 96 | $entry_value_id = str_replace(' ', '_', $entry_value); 97 | if (isset($property_count[$entry_value_id])) 98 | { 99 | $property_count[$entry_value_id] += 1; 100 | } 101 | else 102 | { 103 | $property_count = array_merge($property_count, array($entry_value_id => 1)); 104 | } 105 | } 106 | } 107 | } 108 | } 109 | 110 | //Remove the duplicates 111 | $entries_values = array_unique($entries_values); 112 | sort($entries_values); 113 | $row = " %s%s\n"; 114 | 115 | print ' 116 | 117 | 118 | \n"; 119 | 120 | //Print out each row for the properties 121 | foreach ($entries_values as $entry) 122 | { 123 | $entry_id = str_replace(' ', '_', $entry); 124 | 125 | if (isset($property_count[$entry_id])) 126 | { 127 | print sprintf($row, $entry, $property_count[$entry_id]); 128 | } 129 | } 130 | print '
' . $lang['TAG_DATA'] . '' . $lang['DATA_COUNT'] . "
131 |

132 | 133 | 134 | 135 | \n"; 136 | 137 | //Print out each row for the MOD names 138 | foreach ($entries_values as $entry) 139 | { 140 | if (!empty($entry)) 141 | { 142 | $entry_id = str_replace(' ', '_', $entry); 143 | 144 | if (isset($mod_count[$entry_id])) 145 | { 146 | print sprintf($row, $entry, $mod_count[$entry_id]); 147 | } 148 | } 149 | } 150 | print '
' . $lang['MOD_NAME'] . '' . $lang['SUBMIT_COUNT'] . "
'; 151 | } 152 | 153 | ?> 154 | 155 | 156 | -------------------------------------------------------------------------------- /tests/code/globals_test.php: -------------------------------------------------------------------------------- 1 | redirect(), expected triggered error (else false), expected returned result url (else false)) 18 | return array( 19 | array("", 'USAGE_GLOBALS', false), 20 | array("", 'USAGE_HTTPPOSTVARS', false), 21 | array("", 'USAGE_HTTPPOSTVARS', false), 22 | 23 | array("", 'USAGE_HTTPGETVARS', false), 24 | array("", 'USAGE_HTTPGETVARS', false), 25 | 26 | array("", 'USAGE_HTTPSERVERVARS', false), 27 | array("", 'USAGE_HTTPSERVERVARS', false), 28 | 29 | array("", 'USAGE_HTTPENVVARS', false), 30 | array("", 'USAGE_HTTPENVVARS', false), 31 | 32 | array("", 'USAGE_HTTPCOOKIEVARS', false), 33 | array("", 'USAGE_HTTPCOOKIEVARS', false), 34 | 35 | array("", 'USAGE_HTTPPOSTFILES', false), 36 | array("", 'USAGE_HTTPPOSTFILES', false), 37 | 38 | array("", 'USAGE_HTTPSESSIONVARS', false), 39 | array("", 'USAGE_HTTPSESSIONVARS', false), 40 | 41 | array("", 'USAGE_FILES', false), 42 | array("", 'USAGE_FILES', false), 43 | 44 | array("", 'USAGE_SESSION', false), 45 | array("", false, true), 46 | 47 | array("", 'USAGE_SERVER', false), 48 | array("", false, true), 49 | 50 | array("", 'USAGE_ENV', false), 51 | array("", false, true), 52 | 53 | array("", 'USAGE_REQUEST', false), 54 | array("", false, true), 55 | 56 | array("", 'USAGE_POST', false), 57 | array("", false, true), 58 | 59 | array("", 'USAGE_GET', false), 60 | array("", false, true), 61 | 62 | array("", 'USAGE_COOKIE', false), 63 | array("", false, true), 64 | array("", false, true), 65 | 66 | array("", false, true), 67 | array("", false, true), 68 | 69 | ); 70 | } 71 | 72 | protected function setUp() 73 | { 74 | parent::setUp(); 75 | 76 | $this->test = new mpv_tests_code(new mpv); 77 | } 78 | 79 | /** 80 | * @dataProvider provider 81 | */ 82 | public function test_global($test, $expected_error, $expected_result) 83 | { 84 | global $user; 85 | $this->test->setCode('tests/code/' . $test); 86 | 87 | if ($expected_error !== false) 88 | { 89 | $this->setExpectedTriggerError(E_USER_ERROR, $expected_error); 90 | } 91 | 92 | $result = $this->test->unittest('test_globals', array()); 93 | 94 | if ($expected_error === false) 95 | $this->assertEquals($expected_result, $result); 96 | } 97 | } 98 | 99 | -------------------------------------------------------------------------------- /includes/tests/test_base.php: -------------------------------------------------------------------------------- 1 | validator = $validator; 79 | $this->terminate = false; 80 | $this->failed_tests = array(); 81 | } 82 | public abstract function run(); 83 | 84 | /** 85 | * Wrapper around $this->validator->push_error 86 | * 87 | * @access protected 88 | * @param int Error type 89 | * @param string Message 90 | * @param mixed Optional array of sprintf() values, or a non-array for passing one single value 91 | * @return void 92 | */ 93 | protected function push_error($type, $message, $sprintf_args = null) 94 | { 95 | $this->validator->push_error($type, $message, $this->file_name, $sprintf_args); 96 | } 97 | 98 | /** 99 | * Displays a inline code block with the line of wrong code. 100 | * 101 | * @access protected 102 | * @param int Error type 103 | * @param string Message 104 | * @param string String to use in strpos 105 | * @param string String to use in preg_match 106 | * @param array array that contains words that should not be in the line 107 | * @return bool 108 | */ 109 | protected function display_line_code($type, $message, $strpos, $preg_match = false, $ignore_in_line = array()) 110 | { 111 | $found = false; 112 | 113 | $in_comment = false; 114 | 115 | if (!is_array($ignore_in_line)) 116 | { 117 | if (is_string($ignore_in_line)) 118 | { 119 | $ignore_in_line = array(0 => $ignore_in_line); 120 | } 121 | else 122 | { 123 | $ignore_in_line = array(); 124 | } 125 | } 126 | 127 | foreach ($this->file_contents_file as $line => $content) 128 | { 129 | $content_new = $content; 130 | $loc = strpos($content, '*/'); 131 | 132 | if ($in_comment && $loc === false) 133 | { 134 | $content_new = ''; 135 | } 136 | else if ($in_comment && $loc !== false) 137 | { 138 | // Need to replace everything till */ 139 | $total = strlen($content_new); 140 | $negative = $total - $loc; 141 | $total = $total - $negative; 142 | 143 | $content_new = substr($content_new, ($loc + 2)); 144 | $in_comment = false; 145 | } 146 | else if(!$in_comment && strpos($content, '/*') !== false) 147 | { 148 | if ($loc !== false) // Used as inline 149 | { 150 | $content_new = preg_replace('#/\*(.*)\*/#si', '', $content_new); 151 | } 152 | else 153 | { 154 | $in_comment = true; 155 | 156 | $content_new = substr($content_new, 0, strpos($content, '/*')); 157 | } 158 | } 159 | $loc = strpos($content_new, '//'); 160 | 161 | if ($loc !== false) 162 | { 163 | $content_new = substr($content_new, 0, $loc + 2); 164 | } 165 | 166 | foreach ($ignore_in_line as $value) 167 | { 168 | if (strpos($content_new, $value) !== false) 169 | { 170 | $content_new = ''; 171 | } 172 | } 173 | 174 | 175 | if (empty($content_new)) 176 | { 177 | continue; 178 | } 179 | 180 | // Yes, $content_new in if, and $content in code. 181 | // This is because we want comments still being displayed ;) 182 | if (!$preg_match && strpos($content_new, $strpos) !== false) 183 | { 184 | $this->push_error($type, $message, array((string) ($line + 1) , '[code]' . trim($content) . '[/code]')); 185 | $found = true; 186 | } 187 | else if ($preg_match && preg_match($preg_match, $content_new)) 188 | { 189 | $this->push_error($type, $message, array((string) ($line + 1) , '[code]' . trim($content) . '[/code]')); 190 | $found = true; 191 | } 192 | } 193 | 194 | return $found; 195 | } 196 | 197 | /** 198 | * Terminate all further testing; used if failing one test could result in other tests malfunctioning 199 | * 200 | * @access protected 201 | * @return bool 202 | */ 203 | protected function terminate() 204 | { 205 | $this->terminate = true; 206 | $this->push_error(mpv::ERROR_WARNING, 'TESTING_TERMINATED'); 207 | 208 | return false; 209 | } 210 | 211 | /** 212 | * Check whether a given test failed 213 | * 214 | * @access protected 215 | * @param string Test name 216 | * @return bool 217 | */ 218 | protected function failed_test($test_name) 219 | { 220 | return in_array($test_name, $this->failed_tests); 221 | } 222 | 223 | /** 224 | * Returns a array with failed tests 225 | * 226 | * @access public 227 | * @return array 228 | */ 229 | public function return_failed_tests() 230 | { 231 | return $this->failed_tests; 232 | } 233 | 234 | /** 235 | * Extracs a dir from a filename 236 | * 237 | * @param string $file Filename 238 | * @return string 239 | */ 240 | protected function extract_dir($file) 241 | { 242 | return substr($file, 0, -strlen(basename($file))); 243 | } 244 | 245 | /** 246 | * Test a function from phpunit that is private. 247 | * @param string $function Functioname 248 | * @param array $parameters Function parameters 249 | **/ 250 | public function unittest($function, $parameters) 251 | { 252 | return call_user_func_array(array($this, $function), $parameters); 253 | } 254 | 255 | public function setFilename($file) 256 | { 257 | $this->file_name = $file; 258 | $this->file_contents = @file_get_contents($file); 259 | $this->file_contents_file = @file($file); 260 | } 261 | 262 | public function setCode($file) 263 | { 264 | $this->file_name = ""; 265 | $this->file_contents = $file; 266 | $this->file_contents_file = explode("\n", $file); 267 | } 268 | } 269 | ?> 270 | -------------------------------------------------------------------------------- /includes/tests/tests_packaging.php: -------------------------------------------------------------------------------- 1 | 'db40dbe549fcbbb5a790f7e81ce8e4db', 48 | '1.0.3' => 'e0999771662ee6eada0425ff076c3062', 49 | '1.0.4' => 'ada48057d56ebd22298648a8130fe573', 50 | '1.0.5' => '29c5b8a1c881b0b5b249dbfd29bb6f29', 51 | ); 52 | 53 | /** 54 | * Run the tests in this collection 55 | * 56 | * @access public 57 | * @return void 58 | */ 59 | public function run() 60 | { 61 | $test_methods = get_class_methods($this); 62 | foreach ($test_methods as $method) 63 | { 64 | if (substr($method, 0, 5) == 'test_') 65 | { 66 | if (!$this->$method() || $this->terminate) 67 | { 68 | $this->failed_tests[] = substr($method, 5); 69 | } 70 | 71 | if ($this->terminate) 72 | { 73 | return; 74 | } 75 | } 76 | } 77 | } 78 | 79 | /** 80 | * Test if the there is more as 1 xsl file 81 | * 82 | * @access private 83 | * @return bool 84 | */ 85 | protected function test_xsl() 86 | { 87 | if (sizeof($this->validator->xsl_files) == 0) 88 | { 89 | $this->push_error(mpv::ERROR_FAIL, 'NO_XSL_FILE'); 90 | return false; 91 | } 92 | 93 | return true; 94 | } 95 | 96 | 97 | /** 98 | * Test the MD5 for certian files like UMIL and xsl 99 | * 100 | * @access private 101 | * @return bool 102 | */ 103 | protected function test_files() 104 | { 105 | $error = false; 106 | $found_umil = false; 107 | if (sizeof($this->validator->xsl_files) > 0) 108 | { 109 | foreach ($this->validator->xsl_files as $file) 110 | { 111 | $md5 = md5_file($this->validator->temp_dir . $file); 112 | 113 | if (!in_array($md5, $this->valid_md5_xsl)) 114 | { 115 | $error = true; 116 | $this->push_error(mpv::ERROR_WARNING, 'MODIFIED_XSL', $file, array($md5, $this->valid_md5_xsl[0])); 117 | } 118 | else if ($md5 != $this->valid_md5_xsl[0]) // Note, newest MD5 for xsl should be the first! 119 | { 120 | $error = true; 121 | $this->push_error(mpv::ERROR_FAIL, 'OLD_XSL', $file, array($md5)); 122 | } 123 | } 124 | 125 | foreach ($this->validator->package_files as $file) 126 | { 127 | if (strpos($file, 'license.txt') !== false) 128 | { 129 | $md5 = md5_file($this->validator->temp_dir . $file); 130 | 131 | if (!in_array($md5, $this->license_md5)) 132 | { 133 | $this->push_error(mpv::ERROR_FAIL, 'LICENSE_MD5', $file, array($md5, implode(', ',$this->license_md5))); 134 | } 135 | } 136 | 137 | $tmp = explode('/', $file); 138 | 139 | if (isset($tmp[sizeof($tmp) - 2]) && isset($tmp[sizeof($tmp) - 1]) && $tmp[sizeof($tmp) - 2] == 'umil' && $tmp[sizeof($tmp) - 1] == 'umil.php') 140 | { 141 | $md5 = md5_file($this->validator->temp_dir . $file); 142 | 143 | if ($found_umil) 144 | { 145 | $this->push_error(mpv::ERROR_WARNING, 'POSSIBLE_TWO_UMIL', null, array($file, $found_umil)); 146 | continue; 147 | } 148 | 149 | if (!defined('IN_PHPBB')) 150 | { 151 | define('IN_PHPBB', true); 152 | } 153 | include ($this->validator->temp_dir . $file); 154 | 155 | if (!defined('UMIL_VERSION')) 156 | { 157 | $this->push_error(mpv::ERROR_FAIL, 'NO_UMIL_VERSION', $file); 158 | 159 | continue; 160 | } 161 | else if (version_compare(UMIL_VERSION, mpv::get_current_version('umil'), '<')) 162 | { 163 | $this->push_error(mpv::ERROR_FAIL, 'UMIL_OUTDATED', $file); 164 | 165 | // Check to see if the md5 still exists 166 | if (isset($this->valid_md5_umil[UMIL_VERSION]) && $this->valid_md5_umil[UMIL_VERSION] != $md5) 167 | { 168 | // Invalid MD5 for version as well :) 169 | $this->push_error(mpv::ERROR_WARNING, 'INCORRECT_UMIL_MD5', $file); 170 | } 171 | } 172 | else if (!isset($this->valid_md5_umil[UMIL_VERSION])) 173 | { 174 | $this->push_error(mpv::ERROR_FAIL, 'UNKNOWN_VERSION_UMIL', $file); 175 | } 176 | else if ($this->valid_md5_umil[UMIL_VERSION] != $md5) 177 | { 178 | $this->push_error(mpv::ERROR_WARNING, 'INCORRECT_UMIL_MD5', $file); 179 | } 180 | $found_umil = $file; 181 | } 182 | } 183 | } 184 | } 185 | 186 | /** 187 | * Checks to see if the required license.txt exists 188 | * 189 | * @access private 190 | * @return bool 191 | */ 192 | protected function test_license() 193 | { 194 | foreach ($this->validator->package_files as $filename) 195 | { 196 | if (mpv::check_unwanted($filename)) 197 | { 198 | continue; 199 | } 200 | 201 | if (strtolower(basename($filename)) == 'license.txt') 202 | { 203 | return true; 204 | } 205 | } 206 | $this->push_error(mpv::ERROR_FAIL, 'NO_LICENSE'); 207 | return false; 208 | } 209 | 210 | /** 211 | * Test to see if prosilver.xml or english.xml exisits. 212 | * 213 | * @return bool 214 | * @access private 215 | */ 216 | protected function test_prosilver_english() 217 | { 218 | $return = true; 219 | foreach ($this->validator->package_files as $filename) 220 | { 221 | if (mpv::check_unwanted($filename)) 222 | { 223 | continue; 224 | } 225 | 226 | $file = strtolower(basename($filename)); 227 | 228 | if ($file == 'prosilver.xml' || (strpos($file, 'prosilver') !== false && strpos($file, '.xml') !== false)) 229 | { 230 | $this->push_error(mpv::ERROR_FAIL, 'PROSILVER_NO_MAIN_MODX', null, array($filename)); 231 | $return = false; 232 | } 233 | 234 | if ($file == 'en.xml' || (strpos($file, 'english') !== false && strpos($file, '.xml') !== false)) 235 | { 236 | $this->push_error(mpv::ERROR_FAIL, 'ENGLISH_NO_MAIN_MODX', null, array($filename)); 237 | $return = false; 238 | } 239 | } 240 | 241 | return $return; 242 | } 243 | 244 | /** 245 | * Checks to see if there are bad files from svn or the OS 246 | * 247 | * @access private 248 | * @return bool 249 | */ 250 | protected function test_unwanted() 251 | { 252 | // precache regexp for efficiency 253 | $regexp = '#(^|.*/)(' . implode('|', array_map('preg_quote', mpv::$unwanted_files)) . ')(?:/|$)#i'; 254 | 255 | $unwanted_files = array(); 256 | foreach (mpv::$package_directories as $filename) 257 | { 258 | if (preg_match($regexp, $filename, $matches)) 259 | { 260 | // don't add files multiple times 261 | if (isset($unwanted_files[$matches[1] . $matches[2]])) 262 | { 263 | continue; 264 | } 265 | 266 | // add unwanted file, use array keys for efficiency 267 | $unwanted_files[$matches[1] . $matches[2]] = true; 268 | 269 | // if there is no dir, it's the root 270 | if ($matches[1] === '') 271 | { 272 | $matches[1] = './'; 273 | } 274 | 275 | // push notice 276 | $this->push_error(mpv::ERROR_FAIL, 'UNWANTED_FILE', null, array($matches[1], $matches[2])); 277 | } 278 | } 279 | 280 | return sizeof($unwanted_files); 281 | } 282 | 283 | /** 284 | * Wrapper around $this->validator->push_error 285 | * 286 | * @access private 287 | * @param int Error type 288 | * @param string Message 289 | * @param string Filename of the file causing the error 290 | * @param mixed Optional array of sprintf() values, or a non-array for passing one single value 291 | * @return void 292 | */ 293 | protected function push_error($type, $message, $filename = null, $sprintf_args = null) 294 | { 295 | $this->validator->push_error($type, $message, $filename, $sprintf_args); 296 | } 297 | } 298 | -------------------------------------------------------------------------------- /style.css: -------------------------------------------------------------------------------- 1 | 2 | html { 3 | background: #6C7989; 4 | background: #6c7989 -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #6c7989), color-stop(100%, #434b55)) fixed; 5 | background: #6c7989 -webkit-linear-gradient(#6c7989, #434b55) fixed; 6 | background: #6c7989 -moz-linear-gradient(#6c7989, #434b55) fixed; 7 | background: #6c7989 -o-linear-gradient(#6c7989, #434b55) fixed; 8 | background: #6c7989 -ms-linear-gradient(#6c7989, #434b55) fixed; 9 | background: #6c7989 linear-gradient(#6c7989, #434b55) fixed; 10 | } 11 | 12 | body { 13 | padding: 50px 0; 14 | margin: 0; 15 | font: 14px/1.5 "Helvetica Neue", Helvetica, Arial, sans-serif; 16 | color: #555; 17 | font-weight: 300; 18 | background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAeCAYAAABNChwpAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAABx0RVh0U29mdHdhcmUAQWRvYmUgRmlyZXdvcmtzIENTNXG14zYAAAAUdEVYdENyZWF0aW9uIFRpbWUAMy82LzEygrTcTAAAAFRJREFUSIljfPDggZRf5RIGGNjUHsNATz6jXmSL1Kb2GLiAX+USBnrymRgGGDCORgFmoNAXjEbBaBSMRsFoFIxGwWgUjEbBaBSMRsFoFIxGwWgUAABYNujumib3wAAAAABJRU5ErkJggg==") repeat fixed 0 0 transparent; 19 | } 20 | 21 | .wrapper { 22 | width: 640px; 23 | margin: 0 auto; 24 | background: #DEDEDE; 25 | -webkit-border-radius: 8px; 26 | -moz-border-radius: 8px; 27 | -ms-border-radius: 8px; 28 | -o-border-radius: 8px; 29 | border-radius: 8px; 30 | -webkit-box-shadow: rgba(0, 0, 0, 0.2) 0 0 0 1px, rgba(0, 0, 0, 0.45) 0 3px 10px; 31 | -moz-box-shadow: rgba(0, 0, 0, 0.2) 0 0 0 1px, rgba(0, 0, 0, 0.45) 0 3px 10px; 32 | box-shadow: rgba(0, 0, 0, 0.2) 0 0 0 1px, rgba(0, 0, 0, 0.45) 0 3px 10px; 33 | } 34 | 35 | header, section, footer { 36 | display: block; 37 | } 38 | 39 | header { 40 | -webkit-border-radius: 8px 8px 0 0; 41 | -moz-border-radius: 8px 8px 0 0; 42 | -ms-border-radius: 8px 8px 0 0; 43 | -o-border-radius: 8px 8px 0 0; 44 | border-radius: 8px 8px 0 0; 45 | background: #C6EAFA; 46 | background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #ddfbfc), color-stop(100%, #c6eafa)); 47 | background: -webkit-linear-gradient(#ddfbfc, #c6eafa); 48 | background: -moz-linear-gradient(#ddfbfc, #c6eafa); 49 | background: -o-linear-gradient(#ddfbfc, #c6eafa); 50 | background: -ms-linear-gradient(#ddfbfc, #c6eafa); 51 | background: linear-gradient(#ddfbfc, #c6eafa); 52 | position: relative; 53 | padding: 15px 20px; 54 | border-bottom: 1px solid #B2D2E1; 55 | } 56 | 57 | 58 | a { 59 | color: #069; 60 | text-decoration: none; 61 | } 62 | 63 | p { 64 | margin: 0 0 20px; 65 | padding: 0; 66 | } 67 | 68 | strong { 69 | color: #222; 70 | font-weight: 700; 71 | } 72 | 73 | header h1 { 74 | margin: 0; 75 | padding: 0; 76 | font-size: 24px; 77 | line-height: 1.2; 78 | color: #069; 79 | text-shadow: rgba(255, 255, 255, 0.9) 0 1px 0; 80 | } 81 | header.without-description h1 { 82 | margin: 10px 0; 83 | } 84 | header p { 85 | margin: 0; 86 | color: #61778B; 87 | width: 300px; 88 | font-size: 13px; 89 | } 90 | header p.view { 91 | display: none; 92 | font-weight: 700; 93 | text-shadow: rgba(255, 255, 255, 0.9) 0 1px 0; 94 | -webkit-font-smoothing: antialiased; 95 | } 96 | header p.view a { 97 | color: #06c; 98 | } 99 | header p.view small { 100 | font-weight: 400; 101 | } 102 | header ul { 103 | margin: 0; 104 | padding: 0; 105 | list-style: none; 106 | position: absolute; 107 | z-index: 1; 108 | right: 20px; 109 | top: 20px; 110 | height: 38px; 111 | padding: 1px 0; 112 | background: #5198DF; 113 | background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #77b9fb), color-stop(100%, #3782cd)); 114 | background: -webkit-linear-gradient(#77b9fb, #3782cd); 115 | background: -moz-linear-gradient(#77b9fb, #3782cd); 116 | background: -o-linear-gradient(#77b9fb, #3782cd); 117 | background: -ms-linear-gradient(#77b9fb, #3782cd); 118 | background: linear-gradient(#77b9fb, #3782cd); 119 | border-radius: 5px; 120 | -webkit-box-shadow: inset rgba(255, 255, 255, 0.45) 0 1px 0, inset rgba(0, 0, 0, 0.2) 0 -1px 0; 121 | -moz-box-shadow: inset rgba(255, 255, 255, 0.45) 0 1px 0, inset rgba(0, 0, 0, 0.2) 0 -1px 0; 122 | box-shadow: inset rgba(255, 255, 255, 0.45) 0 1px 0, inset rgba(0, 0, 0, 0.2) 0 -1px 0; 123 | width: auto; 124 | } 125 | header ul:before { 126 | content: ''; 127 | position: absolute; 128 | z-index: -1; 129 | left: -5px; 130 | top: -4px; 131 | right: -5px; 132 | bottom: -6px; 133 | background: rgba(0, 0, 0, 0.1); 134 | -webkit-border-radius: 8px; 135 | -moz-border-radius: 8px; 136 | -ms-border-radius: 8px; 137 | -o-border-radius: 8px; 138 | border-radius: 8px; 139 | -webkit-box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 0, inset rgba(255, 255, 255, 0.7) 0 -1px 0; 140 | -moz-box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 0, inset rgba(255, 255, 255, 0.7) 0 -1px 0; 141 | box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 0, inset rgba(255, 255, 255, 0.7) 0 -1px 0; 142 | } 143 | header ul li { 144 | width: 79px; 145 | float: left; 146 | border-right: 1px solid #3A7CBE; 147 | height: 38px; 148 | } 149 | header ul li.single { 150 | border: none; 151 | } 152 | header ul li + li { 153 | width: 78px; 154 | border-left: 1px solid #8BBEF3; 155 | } 156 | header ul li + li + li { 157 | border-right: none; 158 | width: 79px; 159 | } 160 | header ul a { 161 | line-height: 1; 162 | font-size: 11px; 163 | color: #fff; 164 | color: rgba(255, 255, 255, 0.8); 165 | display: block; 166 | text-align: center; 167 | font-weight: 400; 168 | padding-top: 6px; 169 | height: 40px; 170 | text-shadow: rgba(0, 0, 0, 0.4) 0 -1px 0; 171 | } 172 | header ul a strong { 173 | font-size: 14px; 174 | display: block; 175 | color: #fff; 176 | -webkit-font-smoothing: antialiased; 177 | } 178 | 179 | section { 180 | padding: 15px 20px; 181 | font-size: 15px; 182 | border-top: 1px solid #fff; 183 | background: -webkit-gradient(linear, 50% 0%, 50% 700, color-stop(0%, #fafafa), color-stop(100%, #dedede)); 184 | background: -webkit-linear-gradient(#fafafa, #dedede 700px); 185 | background: -moz-linear-gradient(#fafafa, #dedede 700px); 186 | background: -o-linear-gradient(#fafafa, #dedede 700px); 187 | background: -ms-linear-gradient(#fafafa, #dedede 700px); 188 | background: linear-gradient(#fafafa, #dedede 700px); 189 | -webkit-border-radius: 0 0 8px 8px; 190 | -moz-border-radius: 0 0 8px 8px; 191 | -ms-border-radius: 0 0 8px 8px; 192 | -o-border-radius: 0 0 8px 8px; 193 | border-radius: 0 0 8px 8px; 194 | position: relative; 195 | } 196 | 197 | h1, h2, h3, h4, h5, h6 { 198 | color: #222; 199 | padding: 0; 200 | margin: 0 0 20px; 201 | line-height: 1.2; 202 | } 203 | 204 | p, ul, ol, table, pre, dl { 205 | margin: 0 0 20px; 206 | } 207 | 208 | h1, h2, h3 { 209 | line-height: 1.1; 210 | } 211 | 212 | h1 { 213 | font-size: 28px; 214 | } 215 | 216 | h2 { 217 | color: #393939; 218 | } 219 | 220 | h3, h4, h5, h6 { 221 | color: #494949; 222 | } 223 | 224 | blockquote { 225 | margin: 0 -20px 20px; 226 | padding: 15px 20px 1px 40px; 227 | font-style: italic; 228 | background: #ccc; 229 | background: rgba(0, 0, 0, 0.06); 230 | color: #222; 231 | } 232 | 233 | img { 234 | max-width: 100%; 235 | } 236 | 237 | code, pre { 238 | font-family: Monaco, Bitstream Vera Sans Mono, Lucida Console, Terminal; 239 | color: #333; 240 | font-size: 12px; 241 | overflow-x: auto; 242 | } 243 | 244 | pre { 245 | padding: 20px; 246 | background: #6C7989; 247 | color: #f8f8f2; 248 | margin: 0 -20px 20px; 249 | } 250 | pre code { 251 | color: #6C7989; 252 | } 253 | li pre { 254 | margin-left: -60px; 255 | padding-left: 60px; 256 | } 257 | 258 | table { 259 | width: 100%; 260 | border-collapse: collapse; 261 | } 262 | 263 | th, td { 264 | text-align: left; 265 | padding: 5px 10px; 266 | border-bottom: 1px solid #aaa; 267 | } 268 | 269 | dt { 270 | color: #222; 271 | font-weight: 700; 272 | } 273 | 274 | th { 275 | color: #222; 276 | } 277 | 278 | small { 279 | font-size: 11px; 280 | } 281 | 282 | hr { 283 | border: 0; 284 | background: #aaa; 285 | height: 1px; 286 | margin: 0 0 20px; 287 | } 288 | 289 | footer { 290 | width: 640px; 291 | margin: 0 auto; 292 | padding: 20px 0 0; 293 | color: #ccc; 294 | overflow: hidden; 295 | } 296 | footer a { 297 | color: #fff; 298 | font-weight: bold; 299 | } 300 | footer p { 301 | float: left; 302 | } 303 | footer p + p { 304 | float: right; 305 | } 306 | 307 | @media print, screen and (max-width: 740px) { 308 | body { 309 | padding: 0; 310 | } 311 | 312 | .wrapper { 313 | -webkit-border-radius: 0; 314 | -moz-border-radius: 0; 315 | -ms-border-radius: 0; 316 | -o-border-radius: 0; 317 | border-radius: 0; 318 | -webkit-box-shadow: none; 319 | -moz-box-shadow: none; 320 | box-shadow: none; 321 | width: 100%; 322 | } 323 | 324 | footer { 325 | -webkit-border-radius: 0; 326 | -moz-border-radius: 0; 327 | -ms-border-radius: 0; 328 | -o-border-radius: 0; 329 | border-radius: 0; 330 | padding: 20px; 331 | width: auto; 332 | } 333 | footer p { 334 | float: none; 335 | margin: 0; 336 | } 337 | footer p + p { 338 | float: none; 339 | } 340 | } 341 | @media print, screen and (max-width:580px) { 342 | header ul { 343 | display: none; 344 | } 345 | 346 | header p.view { 347 | display: block; 348 | } 349 | 350 | header p { 351 | width: 100%; 352 | } 353 | } 354 | 355 | @media print { 356 | header p.view a small:before { 357 | content: 'at http://github.com/'; 358 | } 359 | } 360 | 361 | -------------------------------------------------------------------------------- /includes/languages/en/lang.php: -------------------------------------------------------------------------------- 1 | 'Using %s as zip method', 33 | 'TYPE_PHP' => 'php', 34 | 'TYPE_PHPBB' => 'phpBB', 35 | 'TYPE_EXEC' => 'exec', 36 | 'INVALID_ZIP_METHOD' => 'Invalid zip method %s', 37 | 38 | 'TITLE' => 'phpBB MOD Pre-Validator Results', 39 | 'TITLE_STATS' => 'MPV Stats', 40 | 'MIN_PHP' => 'PHP 5.2.0 is required', 41 | 'INVALID_ID' => 'Invalid ID', 42 | 'NO_DATA' => 'No data found', 43 | 'INVALID_MODE' => 'Invalid server mode', 44 | 'VALIDATION_RESULTS' => 'Validation results:', 45 | 'MEM_USE' => 'Memory Usage:', 46 | 'TOTAL_TIME' => 'Time : %.3fs', 47 | 'GB' => 'GB', 48 | 'GIB' => 'GiB', 49 | 'MB' => 'MB', 50 | 'MIB' => 'MiB', 51 | 'BYTES' => 'Bytes', 52 | 'KB' => 'KB', 53 | 'KIB' => 'KiB', 54 | 'NO_MODX_FILES' => 'No MODX files found in package', 55 | 'MODX_SCHEMA_INVALID' => 'Invalid XML/MODX [code]%s[/code]', 56 | 57 | 'FSOCK_DISABLED' => 'The operation could not be completed because the fsockopen function has been disabled or the server being queried could not be found.', 58 | 'FILE_NOT_FOUND' => 'The requested file could not be found', 59 | 'VERSION_FIELD_MISSING' => 'The version element is missing from the MODX file.', 60 | 'LICENSE_FIELD_MISSING' => 'The license element is missing from the MODX file.', 61 | 'TARGET_VERSION_NOT_FOUND' => 'The target-version element is missing from the MODX file', 62 | 'INVALID_VERSION_FORMAT' => 'The supplied version (%s) is invalid. The format should be: 1.0.0.', 63 | 64 | 'VALIDATING_ZIP' => '(Validating %s)', 65 | 'MAJOR_VERSION_UNSTABLE' => 'Your MOD version (%s) is unstable. It should be higher starting at 1.0.0. 66 | Example: 67 | [b]0.0.1[/b] is unstable 68 | [b]0.1.0[/b] is unstable 69 | [b]1.0.1[/b] is stable', 70 | 'VERSION_SHOULD_BE_VERSION' => 'The supplied version (%s) should just be a version like 1.0.0, and not be %s.', 71 | 72 | 'NOT_LATEST_PHPBB' => 'Target revision in the MODX file says the MOD is for %s while the latest phpBB version is %s', 73 | 74 | 'INVALID_INLINE_ACTION' => 'An inline action contains new lines [code]%s[/code]', 75 | 'INVALID_INLINE_FIND' => 'An inline find contains new lines [code]%s[/code]', 76 | 'SHORT_TAGS' => 'This file is using short open tags ( 'The license specified in the MODX file may not be the GPLv2.', 79 | 80 | 'MODIFIED_XSL' => 'The MD5 signature of the XSL file is unknown, file might be modified. Found signature %s, expected newest %s', 81 | 'OLD_XSL' => 'You are using a old version of the MODX xsl. You should update the XSL prior to submitting', 82 | 'LICENSE_MD5' => 'Found a wrong md5 signature. Found %s while expected %s', 83 | 84 | 'MANY_EDIT_CHILDREN' => 'The MOD uses many edit children. This could indicate incorrect usage of the edit tag.', 85 | 'MULTIPLE_XSL' => 'You have multiple XSL files. It is preferred to have only one XSL file so as to not confuse the user.', 86 | 87 | 'NO_XSL_FOUND_IN_DIR' => 'There is no XSL found in directory %s. Starting from July 27, 2008 it is required/preferred to have an XSL file in all directories where a MODX file is located at due to a FireFox 3 limitation.', 88 | 'NO_XSL_FOUND_IN_DIR2' => 'IMPORTANT: MPV cannot detect if there is an XSL at a higher directory. Please test with FireFox 3 to verify it displays correctly. If the MOD displays correctly you can ignore above warning! See our policy for more information.', 89 | 90 | 'NO_LICENSE' => 'You are missing the required license.txt file.', 91 | 'NO_UNIX_ENDINGS' => 'This file doesn\'t use UNIX line endings.', 92 | 'NO_XSL_FILE' => 'You are missing the required XSL file for displaying the XML file in the browser.', 93 | 94 | 'USAGE_MYSQL' => 'You are using a hardcoded MySQL function at line %s: %sphpBB MODs are required to use the Database Abstraction Layer (DBAL).', 95 | 'USAGE_MYSQLI' => 'You are using a hardcoded MySQLi function at line %s: %sphpBB MODs are required to use the Database Abstraction Layer (DBAL).', 96 | 'USAGE_OCI' => 'You are using a hardcoded oci (oracle) function at line %s: %sphpBB MODs are required to use the Database Abstraction Layer (DBAL).', 97 | 'USAGE_SQLITE' => 'You are using a hardcoded SQLite function at line %s: %sphpBB MODs are required to use the Database Abstraction Layer (DBAL).', 98 | 'USAGE_PG' => 'You are using a hardcoded PostgreSQL function at line %s: %sphpBB MODs are required to use the Database Abstraction Layer (DBAL).', 99 | 'USAGE_MSSQL' => 'You are using a hardcoded MSSQL function at line %s: %sphpBB MODs are required to use the Database Abstraction Layer (DBAL).', 100 | 'USAGE_ODBC' => 'You are using a hardcoded ODBC function at line %s: %sphpBB MODs are required to use the Database Abstraction Layer (DBAL).', 101 | 'USAGE_SQLSRV' => 'You are using a hardcoded SQLSRV (MSSQL) function at line %s: %sphpBB MODs are required to use the Database Abstraction Layer (DBAL).', 102 | 'USAGE_IBASE' => 'You are using a hardcoded ibase (Interbase/Firebird) function at line %s: %sphpBB MODs are required to use the Database Abstraction Layer (DBAL).', 103 | 'USAGE_DB2' => 'You are using a hardcoded DB2 function at line %s: %sphpBB MODs are required to use the Database Abstraction Layer (DBAL).', 104 | 105 | 'USAGE_GET' => 'Using $_GET at line %s: %srequest_var() should be used instead.', 106 | 'USAGE_POST' => 'Using $_POST at line %s: %srequest_var() should be used instead.', 107 | 'USAGE_COOKIE' => 'Using $_COOKIE at line %s: %srequest_var() should be used with the fourth parameter.', 108 | 'USAGE_SERVER' => 'Using $_SERVER at line %s: %s[b]$_SERVER [u]IS[/u] user input![/b]', 109 | 'USAGE_SESSION' => 'Using $_SESSION at line %s: %sThe phpBB session system should be used instead.', 110 | 'USAGE_REQUEST' => 'Using $_REQUEST at line %s: %srequest_var should be used instead.', 111 | 'USAGE_ENV' => 'Using $_ENV at line %s: %s', 112 | 'USAGE_FILES' => 'Using $_FILES at line %s: %sThe upload functions included in phpBB should be used instead.', 113 | 'USAGE_GLOBALS' => 'Using $GLOBALS at line %s: %s', 114 | 115 | 'USAGE_PRINT' => 'Using print() at line %s: %s The phpBB template system should be used instead.', 116 | 'USAGE_PRINTF' => 'Using printf() at line %s: %s The phpBB template system should be used instead.', 117 | 'USAGE_ECHO' => 'Using echo() at line %s: %s The phpBB template system should be used instead.', 118 | 'USAGE_PRINTR' => 'Using printr() at line %s: %s The phpBB template system should be used instead.', 119 | 120 | 'USAGE_`' => 'Using backticks at line %s: %s', 121 | 'USAGE_EVAL' => 'Using eval() at line %s: %s', 122 | 'USAGE_EXEC' => 'Using exec() at line %s: %s', 123 | 'USAGE_SYSTEM' => 'Using system() at line %s: %s', 124 | 'USAGE_PASSTHRU' => 'Using passthru() at line %s: %s', 125 | 'USAGE_GETENV' => 'Using getenv() at line %s: %s', 126 | 'USAGE_DIE' => 'Using die() at line %s: %s', 127 | 'USAGE_MD5' => 'Using md5() at line %s: %sMD5 should not be used for anything related to passwords. Other usage of MD5 is probably valid.', 128 | 'USAGE_SHA1' => 'Using sha1() at line %s: %s', 129 | 'USAGE_ADDSLASHES' => 'Using addslashes() at line %s: %s', 130 | 'USAGE_STRIPSLASHES' => 'Using stripslashes() at line %s: %s', 131 | 'USAGE_HTMLSPECIALCHARS'=> 'Using htmlspecialchars() at line %s: %s', 132 | 'USAGE_INCLUDEONCE' => 'Using include_once() at line %s: %sUsing include with a function/class_exists check is preferred over include/require _once', 133 | 'USAGE_REQUIREONCE' => 'Using require_once() at line %s: %sUsing include with a function/class_exists check is preferred over include/require _once', 134 | 'USAGE_VARDUMP' => 'Using var_dump at line %s: %s', 135 | 136 | 'USAGE_BOM' => 'Your file is using a UTF-8 byte-order-mark (BOM)', 137 | 138 | 'USAGE_REQUEST_VAR_INT' => 'A call to request_var() is casting an integer to a string at line %s: %s', 139 | 140 | 'UNWANTED_FILE' => 'Your package contains an unwanted file "%2$s" in %1$s', 141 | 142 | 'INCLUDE_NO_ROOT' => 'A call to include or require is missing $phpbb_root_path in call at line %s: %s', 143 | 'INCLUDE_NO_PHP' => 'A call to include or require is missing $phpEx in call at line %s: %s', 144 | 145 | 'PACKAGE_NOT_EXISTS' => 'Choosen file (%s) does not exist', 146 | 'UNABLE_EXTRACT_PHP' => 'Unable to extract %s using php.', 147 | 'UNABLE_OPEN_PHP' => 'Unable to open %s using php.', 148 | 149 | 'LINK_NOT_EXISTS' => 'The file for link %s does not exist in the zip file.', 150 | 151 | 'NO_IN_PHPBB' => 'A define for IN_PHPBB is missing or there is no check for if IN_PHPBB is set.', 152 | 'FILE_EMPTY' => 'This PHP file has been detected as being empty.', 153 | 154 | 'COPY_BASENAME_DIFFER' => 'Basenames of the copy command differ: From %s to %s. Both should be the same', 155 | 156 | 'USING_MODX_OUTDATED' => 'You are using MODX version %s while the latest release of MODX is %s. Please update your MODX file to the latest version.', 157 | 'USING_MODX_UNKNOWN' => 'Found a invalid MODX version for XML file. Cannot continue pre-validating this file.', 158 | 159 | 'PROSILVER_NO_MAIN_MODX' => 'ProSilver style changes should be placed in the main MODX file and not in %s.', 160 | 'ENGLISH_NO_MAIN_MODX' => 'English language changes should be placed in the main MODX file and not in %s.', 161 | 162 | 'MPV_XML_ERROR' => 'XML error in MODX file %s', 163 | 164 | 'USAGE_BR_NON_CLOSED' => 'A BR is not closed correctly which causes invalid XHTML at line %s: %s', 165 | 'USAGE_IMG_NON_CLOSED' => 'An IMG is not closed correctly which causes invalid XHTML at line %s: %s', 166 | 167 | 'FILE_NON_BINARY' => 'File has been detected as non-binary while the extension IS binary. Checking for PHP code for security reasons. ', 168 | 169 | 'GENERAL_NOTICE' => 'Please note that all checks are done by an automated tool. In [u]some[/u] cases a FAIL/WARNING can be valid/allowed usage of a function.', 170 | 171 | 'UNABLE_OPEN' => 'Unable to open %s.', 172 | 'UNABLE_WRITE'=> 'Unable to write to %s.', 173 | 'PHP_ERROR' => 'A PHP error was found: [code]%s[/code]', 174 | 'NO_PRE_VAL_ERRORS' => 'No pre-validation problems found', 175 | 'REPORT_BY' => 'Report made by MPV', 176 | 'MPV_SERVER' => 'MPV server', 177 | 'UNKNOWN_OUTPUT' => 'Unknown output type', 178 | 'MPV_NOTICE' => 'MPV notice found at %1$s line %2$s: %3$s', 179 | 'MPV_WARNING' => 'MPV warning found at %1$s line %2$s: %3$s', 180 | 'MPV_NOTICE' => 'MPV notice found at %1$s line %2$s: %3$s', 181 | 'MPV_USER_NOTICE' => 'MPV user notice found at %1$s line %2$s: %3$s', 182 | 'MPV_GENERAL_ERROR' => 'MPV encountered an error at %1$s line %2$s: %3$s', 183 | 'MPV_FAIL_RESULT' => 'FAIL', 184 | 'MPV_NOTICE_RESULT' => 'NOTICE', 185 | 'MPV_WARNING_RESULT' => 'WARNING', 186 | 'MPV_INFO_RESULT' => 'INFO', 187 | 'INVALID_TYPE' => 'Invalid $type for this function!', 188 | 'MOD_NAME' => 'MOD Name', 189 | 'SUBMIT_COUNT' => 'Submission Count', 190 | 'TAG_DATA' => 'Tag Data', 191 | 'DATA_COUNT' => 'Data Count', 192 | 193 | 'NO_UMIL_VERSION' => 'Could not find UMIL_VERSION in umil.php', 194 | 'UMIL_OUTDATED' => 'The included UMIL is outdated.', 195 | 'INCORRECT_UMIL_MD5' => 'The included UMIL is modified.', 196 | 'UNKNOWN_VERSION_UMIL' => 'The included UMIL version is unknown. The can mean the version is outdated.', 197 | 'POSSIBLE_TWO_UMIL' => 'Possible 2 UMIL files included: %s and %s.', 198 | 199 | )); 200 | -------------------------------------------------------------------------------- /includes/tests/tests_modx.php: -------------------------------------------------------------------------------- 1 | validator->modx_files) || !sizeof($this->validator->modx_files)) 57 | { 58 | $this->validator->push_error(mpv::ERROR_FAIL, 'NO_MODX_FILES'); 59 | return; 60 | } 61 | 62 | foreach ($this->validator->modx_files as $modx_filename => $modx_object) 63 | { 64 | $this->modx_filename = $this->file_name = $modx_filename; 65 | 66 | if (mpv::check_unwanted($modx_filename)) 67 | { 68 | continue; 69 | } 70 | 71 | if (preg_match('#modx-(.*?)\.xsd#s', (string) $modx_object, $matches)) 72 | { 73 | $current_modx_version = mpv::get_current_version('modx'); 74 | if ($matches[1] != $current_modx_version) 75 | { 76 | $this->push_error(mpv::ERROR_FAIL, 'USING_MODX_OUTDATED', array($matches[1], $current_modx_version)); 77 | //continue; 78 | } 79 | //Let's see if we can download the file from phpbb.compact 80 | if (!LOCAL_ONLY && !@file_exists($this->validator->dir . 'store/data/' . $matches[0])) 81 | { 82 | $data = @file_get_contents("http://www.phpbb.com/mods/xml/{$matches[0]}"); 83 | 84 | //Now we write out the .xsd 85 | if (isset($data) && $data !== false) 86 | { 87 | $cache = @fopen($this->validator->dir . 'store/data/' . $matches[0], 'wb'); 88 | @fwrite($cache, $data); 89 | @fclose($cache); 90 | } 91 | else 92 | { 93 | $this->push_error(mpv::ERROR_FAIL, sprintf('UNABLE_OPEN', "http://www.phpbb.com/mods/xml/{$matches[0]}")); 94 | continue; 95 | } 96 | } 97 | $errors = $modx_object->validate($this->validator->dir . 'store/data/' . $matches[0]); 98 | } 99 | else 100 | { 101 | $this->push_error(mpv::ERROR_FAIL, 'USING_MODX_UNKNOWN'); 102 | continue; 103 | } 104 | 105 | if ($errors !== true) 106 | { 107 | foreach ($errors as $error) 108 | { 109 | $this->push_error(mpv::ERROR_FAIL, 'MODX_SCHEMA_INVALID', $error); 110 | } 111 | continue; 112 | } 113 | 114 | $this->failed_tests = array(); 115 | 116 | $this->modx_object = $modx_object; 117 | $this->modx_dir = $this->extract_dir($modx_filename); 118 | $mod_title = $this->modx_object->get_xpath('//header/title', true); 119 | 120 | //Do we need to store some statistics? 121 | if (sizeof($statistics)) 122 | { 123 | foreach ($statistics as $tag => $properties) 124 | { 125 | $line_to_write = ''; 126 | 127 | //First we need to get the tag's existing nodes 128 | $tag_node = $this->modx_object->get_by_name($tag, false); 129 | //Now we go through each node to get the properties 130 | foreach ($tag_node as $node) 131 | { 132 | foreach ($properties as $property) 133 | { 134 | if (empty($line_to_write)) 135 | { 136 | //Let's start with the MOD's title 137 | $line_to_write = $mod_title->value; 138 | } 139 | //Let's build the string we're going to save 140 | $line_to_write .= "||" . $property . ": " . $node->attributes[$property]; 141 | } 142 | } 143 | if (!empty($line_to_write)) 144 | { 145 | //Open text file and write to it 146 | $file_handle = @fopen($this->validator->dir . 'store/data/' . $tag . '_data.txt', 'a'); 147 | if ($file_handle !== false) 148 | { 149 | @fwrite($file_handle, $line_to_write . "\r\n"); 150 | @fclose($fh); 151 | } 152 | } 153 | } 154 | 155 | } 156 | 157 | foreach ($test_methods as $method) 158 | { 159 | if (substr($method, 0, 5) == 'test_') 160 | { 161 | if (!$this->$method() || $this->terminate) 162 | { 163 | $this->failed_tests[] = substr($method, 5); 164 | } 165 | 166 | if ($this->terminate) 167 | { 168 | return; 169 | } 170 | } 171 | } 172 | } 173 | } 174 | 175 | /** 176 | * Test the MOD's version 177 | * 178 | * @access public 179 | * @return bool 180 | */ 181 | protected function test_version() 182 | { 183 | $version = $this->modx_object->get_xpath('//header/mod-version', true); 184 | 185 | if (!is_object($version)) 186 | { 187 | $this->push_error(mpv::ERROR_FAIL, 'VERSION_FIELD_MISSING'); 188 | 189 | return false; 190 | } 191 | $version = strtolower($version->value); 192 | 193 | $unstable = array( 194 | 'rc', 195 | 'alpha', 196 | 'beta', 197 | 'dev', 198 | 'a', 199 | 'b', 200 | ); 201 | 202 | $option = implode('|', $unstable); 203 | 204 | // Check the version format and numbering 205 | if (preg_match('#((\d+)\.)+(\d+)[a-z]?#', $version, $matches)) 206 | { 207 | if (preg_match('#((\d+)\.)+(\d+)-(' . $option . '+)(\d+{0,)?#i', $version, $matches)) 208 | { 209 | $this->push_error(mpv::ERROR_FAIL, 'MAJOR_VERSION_UNSTABLE', array($version)); 210 | return false; 211 | } 212 | 213 | if (version_compare('1.0.0', $version) > 0) 214 | { 215 | $this->push_error(mpv::ERROR_FAIL, 'MAJOR_VERSION_UNSTABLE', array($version)); 216 | return false; 217 | } 218 | } 219 | else 220 | { 221 | // Not a valid version 222 | $this->push_error(mpv::ERROR_FAIL, 'INVALID_VERSION_FORMAT', array($version)); 223 | return false; 224 | } 225 | 226 | return true; 227 | } 228 | 229 | protected function test_xsl_exists() 230 | { 231 | $found = false; 232 | foreach ($this->validator->xsl_files as $xsl_file) 233 | { 234 | if ($this->modx_dir == $this->extract_dir($xsl_file)) 235 | { 236 | $found = true; 237 | 238 | break; 239 | } 240 | } 241 | 242 | if (!$found) 243 | { 244 | $this->push_error(mpv::ERROR_NOTICE, 'NO_XSL_FOUND_IN_DIR', $this->modx_dir); 245 | $this->push_error(mpv::ERROR_NOTICE, 'NO_XSL_FOUND_IN_DIR2', $this->modx_dir); 246 | } 247 | return $found; 248 | } 249 | 250 | /** 251 | * Check whether files to open exist in the phpBB package 252 | * @return bool 253 | * @access private 254 | */ 255 | protected function test_open() 256 | { 257 | $return = true; 258 | $open_ary = $this->modx_object->get_by_name('open', false); 259 | 260 | foreach ($open_ary as $open_src) 261 | { 262 | $filename_ary[] = $open_src->attributes['src']; 263 | } 264 | unset($open_ary); 265 | 266 | $files_array = file($this->validator->dir . 'includes/tests/filelist.txt'); 267 | 268 | // Simulation of in_array. Might be able to switch back to the actual 269 | // function. 270 | /** 271 | * @TODO: Does this actually work? 272 | */ 273 | foreach ($files_array as $filename) 274 | { 275 | $match = false; 276 | foreach ($files_array as $test_filename) 277 | { 278 | if (trim($filename) == trim($test_filename)) 279 | { 280 | $match = true; 281 | break; 282 | } 283 | } 284 | 285 | if (!$match) 286 | { 287 | $return = false; 288 | 289 | if (strpos($filename, '/') === 0) 290 | { 291 | $this->push_error(mpv::ERROR_FAIL, 'OPEN_FAIL_LEADING_SLASH'); 292 | } 293 | else if (strpos($filename, '\\') !== false) 294 | { 295 | $this->push_error(mpv::ERROR_FAIL, 'OPEN_FAIL_BACKSLASH'); 296 | } 297 | else if (preg_match('#language/[a-z_.]+/(.*)\.php#', $filename)) 298 | { 299 | $this->push_error(mpv::ERROR_NOTICE, 'OPEN_FAIL_TRANSLATION'); 300 | } 301 | else if (preg_match('#styles/[a-z_.]+/(.*)/#', $filename)) 302 | { 303 | $this->push_error(mpv::ERROR_NOTICE, 'OPEN_FAIL_STYLE'); 304 | } 305 | else 306 | { 307 | $this->push_error(mpv::ERROR_FAIL, 'OPEN_FAIL_NOT_EXISTS'); 308 | } 309 | } 310 | } 311 | 312 | return $return; 313 | } 314 | 315 | /** 316 | * Check if the opens are the same. 317 | * 318 | * @access private 319 | * @return bool 320 | */ 321 | protected function test_copy() 322 | { 323 | $copy_ary = $this->modx_object->get_by_name('//action-group/copy/file', false); 324 | 325 | $return = true; 326 | 327 | foreach ($copy_ary as $copy_tag) 328 | { 329 | $from = str_replace('\\', '/', $copy_tag->attributes['from']); 330 | $to = str_replace('\\', '/', $copy_tag->attributes['to']); 331 | if (isset ($from) && isset($to) && trim(basename($from)) != trim(basename($to))) 332 | { 333 | $this->push_error(mpv::ERROR_FAIL, 'COPY_BASENAME_DIFFER', array(basename($from), basename($to))); 334 | 335 | $return = false; 336 | } 337 | } 338 | 339 | return $return; 340 | } 341 | 342 | /** 343 | * Attempt to detect whether edit tags are well-formed 344 | * @access private 345 | * @return bool 346 | */ 347 | protected function test_edit() 348 | { 349 | // First, grab all of the edit tags 350 | $edit_ary = $this->modx_object->get_by_name('edit', false); 351 | 352 | $return = true; 353 | 354 | // Then grab the children of each edit tag 355 | foreach ($edit_ary as $edit_tag) 356 | { 357 | // This is pretty darn simplistic, but it stands to reason. 358 | // Two children is normal, three will happen occasionally 359 | // Four is very rare unless the author did something wrong :) 360 | // And at five we give a fail by default. 361 | // PAUL: changed from 2 3/5 to 5/7. 362 | if (isset($edit_tag->children[5])) 363 | { 364 | $this->push_error(mpv::ERROR_NOTICE, 'MANY_EDIT_CHILDREN'); 365 | 366 | $return = false; 367 | } 368 | else if (isset($edit_tag->children[7])) // Changed from 3 to 5, no idea why this one was the same as above? 369 | { 370 | $this->push_error(mpv::ERROR_FAIL, 'MANY_EDIT_CHILDREN'); 371 | 372 | $return = false; 373 | } 374 | } 375 | return $return; 376 | } 377 | 378 | /** 379 | * Check if license matches "boilerplate" GPLv2 notice 380 | * @access private 381 | * @return bool 382 | */ 383 | protected function test_license() 384 | { 385 | $license = $this->modx_object->get_by_name('license', true); 386 | 387 | if (!is_object($license)) 388 | { 389 | $this->push_error(mpv::ERROR_FAIL, 'LICENSE_FIELD_MISSING'); 390 | 391 | return false; 392 | } 393 | $license = $license->value; 394 | 395 | $allowed_licenses = array( 396 | 'http://opensource.org/licenses/gpl-license.php GNU General Public License v2', 397 | 'http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2', 398 | ); 399 | 400 | if (!in_array($license, $allowed_licenses)) 401 | { 402 | $this->push_error(mpv::ERROR_WARNING, 'LICENSE_NOT_GPL2'); 403 | 404 | return false; 405 | } 406 | 407 | return true; 408 | } 409 | 410 | /** 411 | * Test whether in-line find tags contain new lines 412 | * @access private 413 | * @return bool 414 | */ 415 | protected function test_inline_find() 416 | { 417 | $return = true; 418 | $inline_find_ary = $this->modx_object->get_by_name('inline-find', false); 419 | 420 | foreach ($inline_find_ary as $inline_find_tag) 421 | { 422 | $contents = $inline_find_tag->value; 423 | if (strpos($contents, "\n") !== false) 424 | { 425 | $return = false; 426 | $this->push_error(mpv::ERROR_FAIL, 'INVALID_INLINE_FIND', $contents); 427 | } 428 | } 429 | 430 | return $return; 431 | } 432 | 433 | /** 434 | * Test whether in-line action tags contain new lines 435 | * @access private 436 | * @return bool 437 | */ 438 | protected function test_inline_action() 439 | { 440 | $return = true; 441 | $inline_action_ary = $this->modx_object->get_by_name('inline-action', false); 442 | 443 | foreach ($inline_action_ary as $inline_action_tag) 444 | { 445 | $contents = $inline_action_tag->value; 446 | if (strpos($contents, "\n") !== false) 447 | { 448 | $return = false; 449 | $this->push_error(mpv::ERROR_FAIL, 'INVALID_INLINE_ACTION', $contents); 450 | } 451 | } 452 | 453 | return $return; 454 | } 455 | 456 | /** 457 | * Test whether links exist 458 | * Note: links can be external, and we can't very well check those. They are 459 | * exempt from the check 460 | * @return bool 461 | * @access private 462 | */ 463 | protected function test_links() 464 | { 465 | $return = true; 466 | $link_ary = $this->modx_object->get_by_name('link', false); 467 | 468 | foreach ($link_ary as $link_tag) 469 | { 470 | $link_href = $link_tag->attributes['href']; 471 | 472 | if (!file_exists($this->validator->temp_dir . $this->modx_dir . $link_href) && strpos($link_href, '://') === false) 473 | { 474 | $return = false; 475 | $this->push_error(mpv::ERROR_FAIL, 'LINK_NOT_EXISTS', $link_href); 476 | } 477 | } 478 | 479 | return $return; 480 | } 481 | 482 | /** 483 | * Test the phpBB version 484 | */ 485 | protected function test_phpbb_version() 486 | { 487 | $return = true; 488 | 489 | $phpbb_version = $this->modx_object->get_by_name('target-version', true); 490 | //If we're only going to be local then we get the version from the config file 491 | $current_phpbb_version = mpv::get_current_version('phpbb'); 492 | 493 | if (!is_object($phpbb_version)) 494 | { 495 | $this->push_error(mpv::ERROR_FAIL, 'TARGET_VERSION_NOT_FOUND'); 496 | 497 | $return = false; 498 | } 499 | else if (version_compare(strtolower(trim($phpbb_version->value)), strtolower($current_phpbb_version), '<')) 500 | { 501 | if (mpv::$mod_dir . '/' . basename($this->modx_filename) == $this->modx_filename) 502 | { 503 | $this->push_error(mpv::ERROR_FAIL , 'NOT_LATEST_PHPBB', array($phpbb_version->value, $current_phpbb_version)); 504 | } 505 | else 506 | { 507 | $this->push_error(mpv::ERROR_WARNING , 'NOT_LATEST_PHPBB', array($phpbb_version->value, $current_phpbb_version)); 508 | } 509 | 510 | $return = false; 511 | } 512 | 513 | return $return; 514 | } 515 | } 516 | -------------------------------------------------------------------------------- /includes/tests/tests_code.php: -------------------------------------------------------------------------------- 1 | validator->package_files) || !sizeof($this->validator->package_files)) 31 | { 32 | return; 33 | } 34 | 35 | foreach ($this->validator->package_files as $package_file) 36 | { 37 | $this->file_name = $package_file; 38 | 39 | if (mpv::check_unwanted($package_file)) 40 | { 41 | continue; 42 | } 43 | 44 | // Only test PHP files 45 | // We also check files that should be binary, but arent. 46 | // Maybe there is php in that? 47 | 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)) 48 | 49 | { 50 | continue; 51 | } 52 | 53 | $this->failed_tests = array(); 54 | 55 | $this->file_contents = file_get_contents($this->validator->temp_dir . $package_file); 56 | 57 | $this->file_contents_file = file($this->validator->temp_dir . $package_file); 58 | 59 | unset($content); 60 | 61 | foreach ($test_methods as $method) 62 | { 63 | if (substr($method, 0, 5) == 'test_') 64 | { 65 | if (!$this->$method() || $this->terminate) 66 | { 67 | $this->failed_tests[] = substr($method, 5); 68 | } 69 | 70 | if ($this->terminate) 71 | { 72 | unset($this->file_contents, $this->file_contents_file); 73 | 74 | return; 75 | } 76 | } 77 | } 78 | 79 | unset($this->file_contents, $this->file_contents_file); 80 | } 81 | } 82 | 83 | /** 84 | * Add a note if a file isnt a binary, but extension is binary. 85 | * Allowed non binary extension: 86 | * txt, php, html, htm, tpl, xml, xsl, css 87 | */ 88 | protected function check_binary($filename) 89 | { 90 | $base = basename($filename); 91 | $ext = substr($base, -3); 92 | 93 | if (in_array($ext, array('.md', 'txt', 'php', 'tml', 'htm', 'tpl', 'xsl', 'xml', 'css', '.js', 'sql', 'ess'))) 94 | { 95 | return false; 96 | } 97 | /** 98 | * Perl version: 99 | * 100 | # Is this a binary file? Let's look at the first few 101 | # lines to figure it out: 102 | for line in lines[:5]: 103 | for c in line.rstrip(): 104 | if c.isspace(): 105 | continue 106 | if c < ' ' or c > chr(127): 107 | lines = BINARY_EXPLANATION_LINES[:] 108 | break 109 | * 110 | */ 111 | $file = file($filename); 112 | 113 | for ($i = 0, $count = sizeof($file); $i < $count; $i++) 114 | { 115 | if ($i > 5) 116 | { 117 | break; 118 | } 119 | for ($j = 0, $count2 = strlen($file[$i]); $j < $count2; $j++) 120 | { 121 | if ($file[$i][$j] > chr(127)) 122 | { 123 | unset($file); 124 | return true; 125 | } 126 | } 127 | } 128 | unset($file); 129 | 130 | $this->push_error(MPV::ERROR_FAIL, 'FILE_NON_BINARY'); 131 | 132 | return false; 133 | 134 | } 135 | 136 | /** 137 | * Enter description here... 138 | * 139 | * @access private 140 | * @return bool 141 | */ 142 | protected function test_empty() 143 | { 144 | if (strlen(trim($this->file_contents)) == 0) 145 | { 146 | $this->push_error(MPV::ERROR_WARNING, 'FILE_EMPTY'); 147 | 148 | $this->terminate = true; 149 | return false; 150 | } 151 | return true; 152 | } 153 | 154 | /** 155 | * Test for the use of improper line endings 156 | * 157 | * @access private 158 | * @return bool 159 | */ 160 | protected function test_unix_endings() 161 | { 162 | if (strpos($this->file_contents, "\r") !== false) 163 | { 164 | $this->push_error(mpv::ERROR_WARNING, 'NO_UNIX_ENDINGS'); 165 | return false; 166 | } 167 | 168 | return true; 169 | } 170 | 171 | /** 172 | * Test for the use of short tags (file_contents, "file_contents, 'file_contents, "file_contents, "display_line_code(mpv::ERROR_FAIL, 'SHORT_TAGS', $strpos); 200 | } 201 | 202 | return true; 203 | } 204 | /** 205 | * Tests to see if IN_PHPBB is defined. 206 | * 207 | * @access private 208 | * @return bool 209 | */ 210 | protected function test_in_phpbb() 211 | { 212 | if (preg_match("#(a|u|m)cp/info/(a|u|m)cp_(.?)#i", $this->file_name)) 213 | { 214 | // Ignore info files 215 | return true; 216 | } 217 | if (preg_match("#define([ ]+){0,1}\(([ ]+){0,1}'IN_PHPBB'#", $this->file_contents)) 218 | { 219 | return true; 220 | } 221 | else if (preg_match("#defined([ ]+){0,1}\(([ ]+){0,1}'IN_PHPBB'#", $this->file_contents)) 222 | { 223 | return true; 224 | } 225 | $this->push_error(MPV::ERROR_FAIL, 'NO_IN_PHPBB'); 226 | return false; 227 | } 228 | 229 | /** 230 | * Test for mysql_* (DBAL) functions 231 | * 232 | * @access private 233 | * @return bool 234 | */ 235 | protected function test_dbal() 236 | { 237 | $return = true; 238 | 239 | $functions = array( 240 | 'mysql_', 241 | 'mysqli_', 242 | 'oci_', 243 | 'sqlite_', 244 | 'pg_', 245 | 'mssql_', 246 | 'odbc_', 247 | 'sqlsrv_', 248 | 'ibase_', 249 | 'db2_', 250 | ); 251 | 252 | foreach ($functions as $function) 253 | { 254 | 255 | if (preg_match("#(^\s*|[^a-z0-9_])" . preg_quote($function, '#') . "{1}([a-zA-Z0-9_]+){1,}\s*\({1}#si", $this->file_contents)) 256 | { 257 | if ($this->display_line_code(mpv::ERROR_FAIL, 'USAGE_' . strtoupper(str_replace(array('_', '$', '('), '', $function)), false, "#(^\s*|[^a-z0-9_])" . preg_quote($function, '#') . "{1}([a-zA-Z0-9_]+){1,}\s*\({1}#si", array('new', 'function'))) 258 | { 259 | $return = false; 260 | } 261 | } 262 | } 263 | return $return; 264 | } 265 | 266 | /** 267 | * Test for some basic disallowed functions 268 | * 269 | * @access private 270 | * @return bool 271 | */ 272 | protected function test_code() 273 | { 274 | $return = true; 275 | 276 | $functions = array( 277 | 'eval' => mpv::ERROR_FAIL, 278 | 'exec' => mpv::ERROR_FAIL, 279 | 'system' => mpv::ERROR_FAIL, 280 | 'passthru' => mpv::ERROR_FAIL, 281 | 'getenv' => mpv::ERROR_FAIL, 282 | 'die' => mpv::ERROR_FAIL, 283 | 'addslashes' => mpv::ERROR_FAIL, 284 | 'stripslashes' => mpv::ERROR_FAIL, 285 | 'htmlspecialchars' => mpv::ERROR_FAIL, 286 | 'include_once' => mpv::ERROR_NOTICE, 287 | 'require_once' => mpv::ERROR_NOTICE, 288 | 'md5' => mpv::ERROR_WARNING, 289 | 'sha1' => mpv::ERROR_WARNING, 290 | ); 291 | 292 | $functions_none = array( 293 | '`' 294 | ); 295 | 296 | $functions_without = array( 297 | 'include_once' => mpv::ERROR_NOTICE, 298 | 'require_once' => mpv::ERROR_NOTICE, 299 | ); 300 | 301 | foreach ($functions as $function => $code) 302 | { 303 | if (preg_match("#(^\s*|[^a-z0-9_])" . preg_quote($function, '#') . "{1}\s*\({1}#si", $this->file_contents)) 304 | { 305 | if ($this->display_line_code($code, 'USAGE_' . strtoupper(str_replace(array('_', '$', '('), '', $function)), false, "#(^\s*|[^a-z0-9_])" . preg_quote($function) . "([ \(|\(| ]+)#si")) 306 | { 307 | $return = false; 308 | } 309 | } 310 | } 311 | 312 | foreach ($functions_without as $function => $code) 313 | { 314 | if (preg_match("#(^\s*|[^a-z0-9_])" . preg_quote($function, '#') . "{1}\s*\({0}#si", $this->file_contents)) 315 | { 316 | if ($this->display_line_code($code, 'USAGE_' . strtoupper(str_replace(array('_', '$', '('), '', $function)), false, "#(^\s*|[^a-z0-9_])" . preg_quote($function) . "([ \(|\(| ]+)#si")) 317 | { 318 | $return = false; 319 | } 320 | } 321 | } 322 | 323 | foreach ($functions_none as $function) 324 | { 325 | if (preg_match("#" . preg_quote($function, '#') . "#si", $this->file_contents) && strpos($this->file_name, '/language/') == 0) 326 | { 327 | if ($this->display_line_code(mpv::ERROR_FAIL, 'USAGE_' . strtoupper(str_replace(array('_', '$', '('), '', $function)), false, "#" . preg_quote($function) . "#si")) 328 | { 329 | $return = false; 330 | } 331 | } 332 | } 333 | 334 | return $return; 335 | } 336 | 337 | /** 338 | * Test for print/echo functions 339 | * 340 | * @access private 341 | * @return bool 342 | */ 343 | protected function test_echo() 344 | { 345 | $return = true; 346 | 347 | $functions = array( 348 | 'print_r', 349 | 'var_dump', 350 | 'printf', 351 | ); 352 | 353 | $functions_none = array( 354 | 'print', 355 | 'echo', 356 | ); 357 | 358 | foreach ($functions as $function) 359 | { 360 | if (preg_match("#(^\s*|[^a-z0-9_])" . preg_quote($function, '#') . "{1}\s*\({1}#si", $this->file_contents)) 361 | { 362 | if ($this->display_line_code(mpv::ERROR_FAIL, 'USAGE_' . strtoupper(str_replace(array('_', '$', '('), '', $function)), false, "#(^\s*|[^a-z0-9_])" . preg_quote($function) . "([ \(|\(| ]+)#si")) 363 | { 364 | $return = false; 365 | } 366 | } 367 | } 368 | 369 | foreach ($functions_none as $function) 370 | { 371 | if (preg_match("#(^\s*|[^a-z0-9_])" . preg_quote($function, '#') . "{1}\s*\({0,1}#si", $this->file_contents)) 372 | { 373 | if ($this->display_line_code(mpv::ERROR_FAIL, 'USAGE_' . strtoupper(str_replace(array('_', '$', '('), '', $function)), false, "#(^\s*|[^a-z0-9_])" . preg_quote($function) . "([ \(|\(| ]+)#si", array('fread'))) 374 | { 375 | $return = false; 376 | } 377 | } 378 | } 379 | return $return; 380 | } 381 | 382 | /** 383 | * Test for $_*[] 384 | * 385 | * @access private 386 | * @return bool 387 | */ 388 | protected function test_globals() 389 | { 390 | $return = true; 391 | 392 | $fail_functions = array( 393 | '$GLOBALS', 394 | '$HTTP_POST_VARS', 395 | '$HTTP_GET_VARS', 396 | '$HTTP_SERVER_VARS', 397 | '$HTTP_ENV_VARS', 398 | '$HTTP_COOKIE_VARS', 399 | '$HTTP_POST_FILES', 400 | '$HTTP_SESSION_VARS', 401 | '$_FILES', 402 | ); 403 | 404 | $warning_functions = array( 405 | '$_SESSION', 406 | '$_SERVER', 407 | '$_ENV', 408 | '$_REQUEST', 409 | ); 410 | 411 | $isset_functions = array( 412 | '$_POST', 413 | '$_GET', 414 | '$_COOKIE', 415 | ); 416 | 417 | foreach ($warning_functions as $function) 418 | { 419 | if (strpos($this->file_contents, $function) !== false) 420 | { 421 | if ($this->display_line_code(mpv::ERROR_WARNING, 'USAGE_' . strtoupper(str_replace(array('_' , '$'), '', $function)), $function, false, array('isset', 'empty'))) 422 | { 423 | $return = false; 424 | } 425 | } 426 | } 427 | 428 | foreach ($fail_functions as $function) 429 | { 430 | if (strpos($this->file_contents, $function) !== false) 431 | { 432 | $lower = strtoupper(str_replace(array('_' , '$'), '', $function)); 433 | if ($this->display_line_code(mpv::ERROR_FAIL, 'USAGE_' . $lower, $function, false)) 434 | { 435 | $return = false; 436 | } 437 | } 438 | } 439 | 440 | foreach ($isset_functions as $function) 441 | { 442 | if (strpos($this->file_contents, $function) !== false) 443 | { 444 | $lower = strtoupper(str_replace(array('_' , '$'), '', $function)); 445 | if ($this->display_line_code(mpv::ERROR_FAIL, 'USAGE_' . $lower, $function, false, array('isset', 'empty'))) 446 | { 447 | $return = false; 448 | } 449 | } 450 | } 451 | 452 | return $return; 453 | } 454 | 455 | /** 456 | * Checks for the request_var usage with integers. Should match on "0" and '0' 457 | * 458 | * @access private 459 | * @return bool 460 | */ 461 | protected function test_request_var() 462 | { 463 | // 464 | if (preg_match("#request_var\((['|\"]+)(.*)(['|\"]+), (['|\"]+)([0-9]+)(['|\"]+)#si", $this->file_contents)) 465 | { 466 | $this->display_line_code(mpv::ERROR_FAIL, 'USAGE_REQUEST_VAR_INT', false, "#request_var\((['|\"]+)(.*)(['|\"]+), (['|\"]+)([0-9]+)(['|\"]+)#si"); 467 | return false; 468 | } 469 | 470 | return true; 471 | } 472 | 473 | /** 474 | * 475 | */ 476 | protected function test_include() 477 | { 478 | $return = true; 479 | 480 | $in_comment = false; 481 | foreach ($this->file_contents_file as $line => $content) 482 | { 483 | $content_new = $content; 484 | $loc = strpos($content, '*/'); 485 | 486 | if ($in_comment && $loc === false) 487 | { 488 | $content_new = ''; 489 | } 490 | else if ($in_comment && $loc !== false) 491 | { 492 | // Need to replace everything till */ 493 | $total = strlen($content_new); 494 | $negative = $total - $loc; 495 | $total = $total - $negative; 496 | 497 | $content_new = substr($content_new, ($loc + 2)); 498 | $in_comment = false; 499 | } 500 | else if(!$in_comment && strpos($content, '/*') !== false) 501 | { 502 | if ($loc !== false) // Used as inline 503 | { 504 | $content_new = preg_replace('#/\*(.*)\*/#si', '', $content_new); 505 | } 506 | else 507 | { 508 | $in_comment = true; 509 | 510 | $content_new = substr($content_new, 0, strpos($content, '/*')); 511 | } 512 | } 513 | $loc = strpos($content_new, '//'); 514 | if ($loc !== false) 515 | { 516 | $content_new = substr($content_new, 0, $loc + 2); 517 | } 518 | 519 | if (preg_match("#^(include_once|require_once|include|require)(\s'|\s\"|\s\$|\s\(|\()#", trim($content_new))) 520 | { 521 | if (strpos($content_new, '$phpbb_root_path') === false && strpos($content_new, '$phpbb_admin_path') === false) 522 | { 523 | $return = false; 524 | 525 | $this->push_error(mpv::ERROR_WARNING, 'INCLUDE_NO_ROOT', array((string)($line + 1), '[code]' . trim($content) . '[/code]')); 526 | } 527 | if (strpos($content_new, '.php') !== false && strpos($content_new, '$phpEx') === false) 528 | { 529 | $return = false; 530 | 531 | $this->push_error(mpv::ERROR_WARNING, 'INCLUDE_NO_PHP', array((string)($line + 1), '[code]' . trim($content) . '[/code]')); 532 | } 533 | } 534 | } 535 | return $return; 536 | } 537 | } 538 | -------------------------------------------------------------------------------- /includes/languages/fr/lang.php: -------------------------------------------------------------------------------- 1 | (Maël Soucaze) http://mael.soucaze.com/ 24 | * @copyright (c) 2010 phpBB Group 25 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License 26 | * @version $Id$ 27 | * 28 | */ 29 | 30 | if (empty($lang) || !is_array($lang)) 31 | { 32 | $lang = array(); 33 | } 34 | 35 | // DEVELOPERS PLEASE NOTE 36 | // 37 | // All language files should use UTF-8 as their encoding and the files must not contain a BOM. 38 | // 39 | // Placeholders can now contain order information, e.g. instead of 40 | // 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows 41 | // translators to re-order the output of data while ensuring it remains correct 42 | // 43 | // You do not need this where single placeholders are used, e.g. 'Message %d' is fine 44 | // equally where a string contains only two placeholders which are used to wrap text 45 | // in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine 46 | 47 | $lang = array_merge($lang, array( 48 | // Only used for debug purposes. 49 | 'ZIP_METHOD' => 'Utilisant %s comme une méthode ZIP', 50 | 'TYPE_PHP' => 'PHP', 51 | 'TYPE_PHPBB' => 'phpBB', 52 | 'TYPE_EXEC' => 'Exécutable', 53 | 'INVALID_ZIP_METHOD' => '%s est une méthode ZIP invalide', 54 | 55 | 'TITLE' => 'Résultats du MOD Pre-Validator de phpBB', 56 | 'TITLE_STATS' => 'Statistiques de MPV', 57 | 'MIN_PHP' => 'PHP 5.2.0 est obligatoire', 58 | 'INVALID_ID' => 'ID invalide', 59 | 'NO_DATA' => 'Aucune donnée n’a été trouvée', 60 | 'VALIDATION_RESULTS' => 'Résultats de la validation :', 61 | 'MEM_USE' => 'Utilisation de la mémoire :', 62 | 'TOTAL_TIME' => 'Durée : %.3fs', 63 | 'GB' => 'Go', 64 | 'GIB' => 'Gio', 65 | 'MB' => 'Mo', 66 | 'MIB' => 'Mio', 67 | 'BYTES' => 'Octets', 68 | 'KB' => 'Ko', 69 | 'KIB' => 'Kio', 70 | 'NO_MODX_FILES' => 'Aucun fichier MODX n’a été trouvé dans cette archive', 71 | 'MODX_SCHEMA_INVALID' => 'XML/MODX invalide [code]%s[/code]', 72 | 73 | 'FSOCK_DISABLED' => 'L’opération n’a pas pu se terminer car la fonction fsockopen a été désactivée ou le serveur demandé est introuvable.', 74 | 'FILE_NOT_FOUND' => 'Le fichier demandé est introuvable', 75 | 'VERSION_FIELD_MISSING' => 'L’élément “version” n’a pas été spécifié dans le fichier MODX.', 76 | 'LICENSE_FIELD_MISSING' => 'L’élément “license” n’a pas été spécifié dans le fichier MODX.', 77 | 'TARGET_VERSION_NOT_FOUND' => 'L’élément “target-version” n’a pas été spécifié dans le fichier MODX', 78 | 'INVALID_VERSION_FORMAT' => 'La version que vous avez fourni (%s) est invalide. Le format doit être : 1.0.0.', 79 | 80 | 'VALIDATING_ZIP' => '(En train de valider %s)', 81 | 'MAJOR_VERSION_UNSTABLE' => 'La version de votre MOD (%s) est instable. Elle doit être obligatoirement plus élevée que la version initiale 1.0.0. 82 | Par exemple : 83 | [b]0.0.1[/b] est instable 84 | [b]0.1.0[/b] est instable 85 | [b]1.0.1[/b] est stable', 86 | 87 | 'NOT_LATEST_PHPBB' => 'La révision cible, située dans le fichier MODX, indique que le MOD est compatible avec la version %s alors que la dernière version de phpBB est la %s', 88 | 89 | 'INVALID_INLINE_ACTION' => 'Une action “dans la ligne” contient de nouvelles lignes [code]%s[/code]', 90 | 'INVALID_INLINE_FIND' => 'Une action “dans la ligne, rechercher” contient de nouvelles lignes [code]%s[/code]', 91 | 'SHORT_TAGS' => 'Ce fichier utilise des balises d’ouvertures raccourcies ( 'La licence spécifiée dans le fichier MODX ne peut pas être la GPLv2.', 94 | 95 | 'MODIFIED_XSL' => 'La signature MD5 du fichier XSL est inconnue, le fichier doit être modifié. Signature trouvée : %s. Signature souhaitée : %s', 96 | 'OLD_XSL' => 'Vous utilisez une version obsolète du fichier XSL de MODX. Vous devriez mettre à jour le XSL avant tout transfert', 97 | 'LICENSE_MD5' => 'Une signature MD5 invalide a été trouvée. Signature trouvée : %s. Signature souhaitée : %s', 98 | 99 | 'MANY_EDIT_CHILDREN' => 'Le MOD utilise de nombreuses requêtes d’éditions. Cela peut indiquer un usage incorrect de la balise d’édition.', 100 | 'MULTIPLE_XSL' => 'Vous bénéficiez de nombreux fichiers XSL. Il est recommandé de n’avoir qu’un seul et unique fichier XSL afin de ne pas déstabiliser les utilisateurs.', 101 | 102 | 'NO_XSL_FOUND_IN_DIR' => 'Aucun fichier XSL n’a été trouvé dans le répertoire %s. Depuis le 27 juillet 2008, il est obligatoire d’avoir un fichier XSL dans tous les répertoires contenant un fichier MODX à cause d’une limitation du navigateur Mozilla Firefox 3.', 103 | 'NO_XSL_FOUND_IN_DIR2' => 'IMPORTANT : MPV ne peut pas détecter s’il y a bien un fichier XSL dans un répertoire supérieur. Veuillez tester l’affichage avec le navigateur Mozilla Firefox 3 afin de vous assurer que tout fonctionne correctement. Si le MOD s’affiche correctement, vous pouvez alors ignorer l’avertissement affiché ci-dessus ! Pour plus d’informations, veuillez consulter notre politique de fonctionnement.', 104 | 105 | 'NO_LICENSE' => 'Le fichier license.txt est introuvable alors que celui-ci est obligatoire.', 106 | 'NO_UNIX_ENDINGS' => 'Ce fichier n’utilise aucune ligne de fin UNIX.', 107 | 'NO_XSL_FILE' => 'Le fichier XSL est introuvable alors que celui-ci est obligatoire afin d’afficher le fichier XML dans un navigateur.', 108 | 109 | 'USAGE_MYSQL' => 'Vous utilisez une fonction MySQL modifiée à la ligne %s : %sLes MODs de phpBB sont obligatoires afin d’utiliser le “Database Abstraction Layer” (DBAL).', 110 | 'USAGE_MYSQLI' => 'Vous utilisez une fonction MySQLi modifiée à la ligne %s : %sLes MODs de phpBB sont obligatoires afin d’utiliser le “Database Abstraction Layer” (DBAL).', 111 | 'USAGE_OCI' => 'Vous utilisez une fonction OCI (Oracle) modifiée à la ligne %s : %sLes MODs de phpBB sont obligatoires afin d’utiliser le “Database Abstraction Layer” (DBAL).', 112 | 'USAGE_SQLITE' => 'Vous utilisez une fonction SQLite modifiée à la ligne %s : %sLes MODs de phpBB sont obligatoires afin d’utiliser le “Database Abstraction Layer” (DBAL).', 113 | 'USAGE_PG' => 'Vous utilisez une fonction PostgreSQL modifiée à la ligne %s : %sLes MODs de phpBB sont obligatoires afin d’utiliser le “Database Abstraction Layer” (DBAL).', 114 | 'USAGE_MSSQL' => 'Vous utilisez une fonction MSSQL modifiée à la ligne %s : %sLes MODs de phpBB sont obligatoires afin d’utiliser le “Database Abstraction Layer” (DBAL).', 115 | 'USAGE_ODBC' => 'Vous utilisez une fonction ODBC modifiée à la ligne %s : %sLes MODs de phpBB sont obligatoires afin d’utiliser le “Database Abstraction Layer” (DBAL).', 116 | 'USAGE_SQLSRV' => 'Vous utilisez une fonction SQLSRV (MSSQL) modifiée à la ligne %s : %sLes MODs de phpBB sont obligatoires afin d’utiliser le “Database Abstraction Layer” (DBAL).', 117 | 'USAGE_IBASE' => 'Vous utilisez une fonction iBase (Interbase/Firebird) modifiée à la ligne %s : %sLes MODs de phpBB sont obligatoires afin d’utiliser le “Database Abstraction Layer” (DBAL).', 118 | 'USAGE_DB2' => 'Vous utilisez une fonction DB2 modifiée à la ligne %s : %sLes MODs de phpBB sont obligatoires afin d’utiliser le “Database Abstraction Layer” (DBAL).', 119 | 120 | 'USAGE_GET' => 'Vous utilisez $_GET à la ligne %s : %srequest_var() devrait être utilisé à la place.', 121 | 'USAGE_POST' => 'Vous utilisez $_POST à la ligne %s : %srequest_var() devrait être utilisé à la place.', 122 | 'USAGE_COOKIE' => 'Vous utilisez $_COOKIE à la ligne %s : %srequest_var() devrait être utilisé en utilisant le quatrième paramètre.', 123 | 'USAGE_SERVER' => 'Vous utilisez $_SERVER à la ligne %s : %s[b]$_SERVER [u]EST[/u] une saisie qui doit être réalisée par l’utilisateur ![/b]', 124 | 'USAGE_SESSION' => 'Vous utilisez $_SESSION à la ligne %s : %sLe système de session de phpBB devrait être utilisé à la place.', 125 | 'USAGE_REQUEST' => 'Vous utilisez $_REQUEST à la ligne %s : %srequest_var devrait être utilisé à la place.', 126 | 'USAGE_ENV' => 'Vous utilisez $_ENV à la ligne %s : %s', 127 | 'USAGE_FILES' => 'Vous utilisez $_FILES à la ligne %s : %sLes fonctions de transfert inclues dans phpBB devraient être utilisées à la place.', 128 | 'USAGE_GLOBALS' => 'Vous utilisez $GLOBALS à la ligne %s : %s', 129 | 130 | 'USAGE_PRINT' => 'Vous utilisez print() à la ligne %s : %s Le système de template de phpBB devrait être utilisé à la place.', 131 | 'USAGE_PRINTF' => 'Vous utilisez printf() à la ligne %s : %s Le système de template de phpBB devrait être utilisé à la place.', 132 | 'USAGE_ECHO' => 'Vous utilisez echo() à la ligne %s : %s Le système de template de phpBB devrait être utilisé à la place.', 133 | 'USAGE_PRINTR' => 'Vous utilisez printr() à la ligne %s : %s Le système de template de phpBB devrait être utilisé à la place.', 134 | 135 | 'USAGE_`' => 'Vous utilisez backticks à la ligne %s : %s', 136 | 'USAGE_EVAL' => 'Vous utilisez eval() à la ligne %s : %s', 137 | 'USAGE_EXEC' => 'Vous utilisez exec() à la ligne %s : %s', 138 | 'USAGE_SYSTEM' => 'Vous utilisez system() à la ligne %s : %s', 139 | 'USAGE_PASSTHRU' => 'Vous utilisez passthru() à la ligne %s : %s', 140 | 'USAGE_GETENV' => 'Vous utilisez getenv() à la ligne %s : %s', 141 | 'USAGE_DIE' => 'Vous utilisez die() à la ligne %s : %s', 142 | 'USAGE_MD5' => 'Vous utilisez md5() à la ligne %s : %sMD5 ne devrait pas être utilisé pour tout ce qui concerne les mots de passe. Les autres utilisations de MD5 seront probablement valides.', 143 | 'USAGE_SHA1' => 'Vous utilisez sha1() à la ligne %s : %s', 144 | 'USAGE_ADDSLASHES' => 'Vous utilisez addslashes() à la ligne %s : %s', 145 | 'USAGE_STRIPSLASHES' => 'Vous utilisez stripslashes() à la ligne %s : %s', 146 | 'USAGE_INCLUDEONCE' => 'Vous utilisez include_once() à la ligne %s : %sIl est préférable que vous utilisiez include avec function/class_exists check plutôt qu’avec include/require _once', 147 | 'USAGE_REQUIREONCE' => 'Vous utilisez require_once() à la ligne %s : %sIl est préférable que vous utilisiez include avec function/class_exists check plutôt qu’avec include/require _once', 148 | 'USAGE_VARDUMP' => 'Vous utilisez var_dump à la ligne %s : %s', 149 | 150 | 'USAGE_BOM' => 'Votre fichier est encodé en UTF-8 avec BOM', 151 | 152 | 'USAGE_REQUEST_VAR_INT' => 'Une liaison à request_var() incante un entier à une chaîne à la ligne %s : %s', 153 | 154 | 'UNWANTED_FILE' => 'Votre archive contient un fichier indésirable nommé "%2$s" et situé dans %1$s', 155 | 156 | 'INCLUDE_NO_ROOT' => 'Une liaison à “include” ou à “require” est manquante à $phpbb_root_path à la ligne %s : %s', 157 | 'INCLUDE_NO_PHP' => 'Une liaison à “include” ou à “require” est manquante à $phpEx à la ligne %s : %s', 158 | 159 | 'PACKAGE_NOT_EXISTS' => 'Le fichier sélectionné (%s) n’existe pas', 160 | 'UNABLE_EXTRACT_PHP' => 'Impossible d’extraire %s en utilisant la méthode PHP.', 161 | 'UNABLE_OPEN_PHP' => 'Impossible d’ouvrir %s en utilisant la méthode PHP.', 162 | 163 | 'LINK_NOT_EXISTS' => 'Le(s) fichier(s) pour lier %s n’existe(nt) pas dans le fichier compressé.', 164 | 165 | 'NO_IN_PHPBB' => 'Une définition pour IN_PHPBB est manquante ou il n’y a aucune vérification pour savoir si IN_PHPBB est paramétré.', 166 | 'FILE_EMPTY' => 'Ce fichier PHP a été détecté comme étant vide.', 167 | 168 | 'COPY_BASENAME_DIFFER' => 'Les noms de base de la commande de copie diffèrent : de %s à %s. Les deux apparaissent comme étant identiques', 169 | 170 | 'USING_MODX_OUTDATED' => 'Vous utilisez la version %s de MODX alors que la dernière version de MODX est la %s. Veuillez mettre à jour votre fichier MODX vers la dernière version.', 171 | 'USING_MODX_UNKNOWN' => 'Une version incorrecte de MODX a été trouvée concernant le fichier XML. Il est impossible de continuer la prévalidation de ce fichier.', 172 | 173 | 'PROSILVER_NO_MAIN_MODX' => 'Les modifications du style prosilver devraient être inclues dans le fichier principal de MODX et non dans %s.', 174 | 'ENGLISH_NO_MAIN_MODX' => 'Les modifications des fichiers de langue anglais devraient être inclues dans le fichier principal de MODX et non dans %s.', 175 | 176 | 'MPV_XML_ERROR' => 'Une erreur XML est survenue dans le fichier MODX %s', 177 | 178 | 'USAGE_BR_NON_CLOSED' => 'Une balise BR n’a pas été fermée correctement et rend invalide le fichier au niveau XHTML. L’erreur est localisée à la ligne %s : %s', 179 | 'USAGE_IMG_NON_CLOSED' => 'Une balise IMG n’a pas été fermée correctement et rend invalide le fichier au niveau XHTML. L’erreur est localisée à la ligne %s : %s', 180 | 181 | 'FILE_NON_BINARY' => 'Le fichier a été détecté comme étant non binaire alors que l’extension est quant à elle binaire. Veuillez vérifier le code PHP par mesure de sécurité.', 182 | 183 | 'GENERAL_NOTICE' => 'Veuillez noter que toutes les vérifications ont été réalisées par un outil automatique. Dans [u]certains[/u] cas, un échec ou un avertissement peut être considéré comme étant correct et fonctionnel.', 184 | 185 | 'UNABLE_OPEN' => 'Impossible d’ouvrir %s.', 186 | 'UNABLE_WRITE'=> 'Impossible d’écrire sur %s.', 187 | 'PHP_ERROR' => 'Une erreur PHP a été trouvée : [code]%s[/code]', 188 | 'NO_PRE_VAL_ERRORS' => 'Aucun problème de prévalidation n’a été trouvé', 189 | 'REPORT_BY' => 'Rapport réalisé par MPV', 190 | 'MPV_SERVER' => 'Serveur MPV', 191 | 'UNKNOWN_OUTPUT' => 'Type de sortie inconnu', 192 | 'MPV_NOTICE' => 'Avis MPV trouvé sur %1$s à la ligne %2$s : %3$s', 193 | 'MPV_WARNING' => 'Avertissement MPV trouvé sur %1$s à la ligne %2$s : %3$s', 194 | 'MPV_NOTICE' => 'Avis MPV trouvé sur %1$s à la ligne %2$s : %3$s', 195 | 'MPV_USER_NOTICE' => 'Avis utilisateur MPV trouvé sur %1$s à la ligne %2$s : %3$s', 196 | 'MPV_GENERAL_ERROR' => 'MPV a rencontré une erreur sur %1$s à la ligne %2$s : %3$s', 197 | 'MPV_FAIL_RESULT' => 'ÉCHEC', 198 | 'MPV_NOTICE_RESULT' => 'AVIS', 199 | 'MPV_WARNING_RESULT' => 'AVERTISSEMENT', 200 | 'MPV_INFO_RESULT' => 'INFORMATION', 201 | 'INVALID_TYPE' => '$type invalide concernant cette fonction !', 202 | 'MOD_NAME' => 'Nom du MOD', 203 | 'SUBMIT_COUNT' => 'Compteur d’envois', 204 | 'TAG_DATA' => 'Tag de données', 205 | 'DATA_COUNT' => 'Compteur de données', 206 | 207 | 'NO_UMIL_VERSION' => 'Impossible de trouver UMIL_VERSION dans umil.php', 208 | 'UMIL_OUTDATED' => 'L’UMIL fourni est obsolète.', 209 | 'INCORRECT_UMIL_MD5' => 'L’UMIL fourni est modifié.', 210 | 'UNKNOWN_VERSION_UMIL' => 'La version d’UMIL que vous avez renseigné est inconnue. Cela peut signifier que la version est obsolète.', 211 | 212 | )); -------------------------------------------------------------------------------- /docs/COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc. 5 | 675 Mass Ave, Cambridge, MA 02139, USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Library General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | -------------------------------------------------------------------------------- /includes/lib/cortex_xml.php: -------------------------------------------------------------------------------- 1 | formatOutput = true; 55 | $document->preserveWhiteSpace = false; 56 | 57 | // Attempt to load the document 58 | if (!$document->load($filename)) 59 | { 60 | return false; 61 | } 62 | 63 | return self::load_element($document->documentElement); 64 | } 65 | 66 | /** 67 | * Create a cortex_xml object based on a given DOMElement 68 | * 69 | * @access public 70 | * @param object DOMElement 71 | * @return object 72 | */ 73 | private static function load_element(DOMElement $element) 74 | { 75 | $object = new cortex_xml(); 76 | $object->element = $element; 77 | 78 | return $object; 79 | } 80 | 81 | /** 82 | * Constructor 83 | * 84 | * @access public 85 | * @param string Name 86 | * @param string Namespace URI 87 | * @param mixed Initial value 88 | * @return void 89 | */ 90 | public function __construct($name = null, $namespace_uri = null, $value = null) 91 | { 92 | if (is_null($name)) 93 | { 94 | return; 95 | } 96 | 97 | $document = new DOMDocument('1.0', 'utf-8'); 98 | $document->formatOutput = true; 99 | $document->preserveWhiteSpace = false; 100 | 101 | $this->element = (!is_null($namespace_uri)) ? $document->createElementNS($namespace_uri, $name) : $document->createElement($name); 102 | 103 | if (!is_null($namespace_uri)) 104 | { 105 | $this->element->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); 106 | } 107 | 108 | if (!is_null($value)) 109 | { 110 | $this->element->value = $value; 111 | } 112 | 113 | $document->appendChild($this->element); 114 | } 115 | 116 | /** 117 | * Add an attribute to this node 118 | * 119 | * @access public 120 | * @param string Name 121 | * @param mixed Value 122 | * @return bool True on success, otherwise false 123 | */ 124 | public function add_attribute($name, $value) 125 | { 126 | return $this->set_attribute($name, $value); 127 | } 128 | 129 | /** 130 | * Set the value of an existing attribute of this node 131 | * 132 | * @access public 133 | * @param string Name 134 | * @param mixed Value 135 | * @return bool True on success, otherwise false 136 | */ 137 | public function set_attribute($name, $value) 138 | { 139 | return $this->element->setAttribute($name, $value); 140 | } 141 | 142 | /** 143 | * Remove an attribute from this node 144 | * 145 | * @access public 146 | * @param string Name 147 | * @return bool True on success, otherwise false 148 | */ 149 | public function remove_attribute($name) 150 | { 151 | return $this->element->removeAttribute($name); 152 | } 153 | 154 | /** 155 | * Add a child node to the current node 156 | * 157 | * @access public 158 | * @param string Name 159 | * @param mixed Initial value 160 | * @return object cortex_xml object 161 | */ 162 | public function add_node($name, $value = null) 163 | { 164 | $node = new cortex_xml(); 165 | $node->element = $this->document->createElement($name); 166 | 167 | if (!is_null($value)) 168 | { 169 | $node->value = $value; 170 | } 171 | 172 | $this->element->appendChild($node->element); 173 | return $node; 174 | } 175 | 176 | /** 177 | * Append a child to the current document/node 178 | * 179 | * @access public 180 | * @param object cortex_xml object 181 | * @return void 182 | */ 183 | public function append_child(cortex_xml $node) 184 | { 185 | $child = $this->document->importNode($node->element, true); 186 | $this->element->appendChild($child); 187 | } 188 | 189 | /** 190 | * Remove this node from the document 191 | * 192 | * @access public 193 | * @return void 194 | */ 195 | public function remove() 196 | { 197 | $this->element->parentNode->removeChild($this->element); 198 | } 199 | 200 | /** 201 | * Execute an XPath query and return the resulting elements 202 | * 203 | * @access public 204 | * @param string XPath 205 | * @param bool Return only the first result 206 | * @return mixed Array if !$return_first, cortex_xml object or null 207 | */ 208 | public function get_xpath($path, $return_first = false) 209 | { 210 | $xpath = new DOMXpath($this->document); 211 | 212 | // Take care of the default namespace, DOMXpath doesn't support this 213 | if (!is_null($this->default_ns)) 214 | { 215 | $path = preg_replace('#/([^:/]+?)#', '/doc-ns:$1', $path); 216 | $xpath->registerNameSpace('doc-ns', $this->default_ns); 217 | } 218 | 219 | $nodes = $this->parse_children($xpath->query($path)); 220 | if ($return_first) 221 | { 222 | return (sizeof($nodes) > 0) ? $nodes[0] : null; 223 | } 224 | 225 | return $nodes; 226 | } 227 | 228 | /** 229 | * Get all child nodes with a given name 230 | * 231 | * @access public 232 | * @param string Name 233 | * @param bool Return only the first node 234 | * @return mixed Array if !$return_first, cortex_xml object or null 235 | */ 236 | public function get_by_name($name, $return_first = true) 237 | { 238 | return $this->get_xpath('//' . $name, $return_first); 239 | } 240 | 241 | /** 242 | * Get all child nodes of which a given attribute has a certain value 243 | * 244 | * @access public 245 | * @param string Name 246 | * @param mixed Value 247 | * @return mixed Array if !$return_first, cortex_xml object or null 248 | */ 249 | public function get_by_attribute($name, $value, $return_first = true) 250 | { 251 | return $this->get_xpath('//*[attribute::' . $name . '=\'' . $value . '\']', $return_first); 252 | } 253 | 254 | /** 255 | * Validate the document against its schema. Will attempt to download the schema using its URI 256 | * if $schema == null 257 | * 258 | * @access public 259 | * @param string Path to XSD, XSD data or null to automatically download the XSD 260 | * @return mixed TRUE or an array describing the errors 261 | */ 262 | public function validate($schema = null) 263 | { 264 | if ((is_null($schema) && !is_null($this->schema_location)) || strpos($schema, 'http://') !== false) 265 | { 266 | $schema = @file_get_contents((strpos($schema, 'http://') !== false) ? $schema : $this->schema_location); 267 | if ($schema === false) 268 | { 269 | return true; 270 | } 271 | } 272 | else if (@file_exists($schema)) 273 | { 274 | set_error_handler(array($this, 'error_handler')); 275 | 276 | $valid = $this->document->schemaValidate($schema); 277 | restore_error_handler(); 278 | 279 | return ($valid === false) ? $this->error_stack : true; 280 | } 281 | 282 | set_error_handler(array($this, 'error_handler')); 283 | 284 | $valid = $this->document->schemaValidateSource($schema); 285 | restore_error_handler(); 286 | 287 | return ($valid === false) ? $this->error_stack : true; 288 | } 289 | 290 | /** 291 | * Internal error handler for filling the error stack. Should not be called 292 | * from outside of this class. 293 | * 294 | * @access public 295 | * @return void 296 | */ 297 | public function error_handler($error_no, $msg_text, $error_file, $error_line) 298 | { 299 | $this->error_stack[] = substr($msg_text, strpos($msg_text, ']: Element') + 3); 300 | } 301 | 302 | /** 303 | * Directly output the data to the client 304 | * 305 | * @access public 306 | * @param bool Set to TRUE to send the 'no-cache' header. Should be done in order 307 | * to prevent headaches and other mental disorders when using AJAX 308 | * @param bool exit() after having sent the data 309 | * @return void 310 | */ 311 | public function output_xml($no_cache = false, $exit = false) 312 | { 313 | $ob_contents = ob_get_contents(); 314 | if ($ob_contents !== false) 315 | { 316 | ob_clean(); 317 | } 318 | 319 | header('Content-type: application/xml'); 320 | 321 | if ($no_cache) 322 | { 323 | header('Pragma: no-cache'); 324 | header('Cache-Control: no-cache'); 325 | header('Expires: ' . date('r', 0)); 326 | } 327 | 328 | print $this; 329 | 330 | if ($exit) 331 | { 332 | exit(); 333 | } 334 | } 335 | 336 | /** 337 | * Write XML to a file 338 | * 339 | * @access public 340 | * @param string Filename to write to 341 | * @return void 342 | */ 343 | public function save_file($filename) 344 | { 345 | if (!@file_put_contents($filename, (string) $this)) 346 | { 347 | throw new cortex_exception('cortex_xml: Could not store XML data', 'Could not write to "' . $filename . '"'); 348 | } 349 | } 350 | 351 | #region // Getters 352 | 353 | /** 354 | * Getter for this element's DOMDocument 355 | * 356 | * @access protected 357 | * @return object 358 | */ 359 | protected function __get_document() 360 | { 361 | return $this->element->ownerDocument; 362 | } 363 | 364 | /** 365 | * Getter for the default namespace URI 366 | * 367 | * @access protected 368 | * @return mixed String or null 369 | */ 370 | protected function __get_default_ns() 371 | { 372 | return $this->document->documentElement->namespaceURI; 373 | } 374 | 375 | /** 376 | * Getter for the default namespace's prefix 377 | * 378 | * @access protected 379 | * @return mixed String or null 380 | */ 381 | protected function __get_default_ns_prefix() 382 | { 383 | return $this->document->documentElement->lookupPrefix($this->default_ns); 384 | } 385 | 386 | /** 387 | * Getter for the URI from which we should be able to get this document's schema 388 | * 389 | * @access protected 390 | * @return mixed String or null 391 | */ 392 | protected function __get_schema_location() 393 | { 394 | if (is_null($this->default_ns) && isset($this->attributes['noNamespaceSchemaLocation'])) 395 | { 396 | return $this->attributes['noNamespaceSchemaLocation']; 397 | } 398 | else if (is_null($this->default_ns) || !isset($this->attributes['schemaLocation'])) 399 | { 400 | return null; 401 | } 402 | 403 | $url_start = strpos($this->attributes['schemaLocation'], $this->default_ns . ' '); 404 | if ($url_start === false) 405 | { 406 | return null; 407 | } 408 | 409 | $schema_url = substr($this->attributes['schemaLocation'], $url_start + strlen($this->default_ns . ' ')); 410 | if (strpos($schema_url, ' ') !== false) 411 | { 412 | $schema_url = substr($schema_url, 0, strpos($schema_url, ' ')); 413 | } 414 | 415 | return $schema_url; 416 | } 417 | 418 | /** 419 | * Getter for the name of this node 420 | * 421 | * @access protected 422 | * @return string 423 | */ 424 | protected function __get_name() 425 | { 426 | return $this->element->tagName; 427 | } 428 | 429 | /** 430 | * Getter for this node's children 431 | * 432 | * @access protected 433 | * @return array 434 | */ 435 | protected function __get_children() 436 | { 437 | return $this->parse_children($this->element->childNodes); 438 | } 439 | 440 | /** 441 | * Getter for this node's attributes 442 | * 443 | * @access protected 444 | * @return array 445 | */ 446 | protected function __get_attributes() 447 | { 448 | $attributes = array(); 449 | $dom_attributes = $this->element->attributes; 450 | 451 | $i = 0; 452 | while ($dom_attribute = $dom_attributes->item($i)) 453 | { 454 | $attributes[$dom_attribute->name] = $dom_attribute->value; 455 | $i++; 456 | } 457 | 458 | return $attributes; 459 | } 460 | 461 | /** 462 | * Getter vor this node's value 463 | * 464 | * @access protected 465 | * @return string 466 | */ 467 | protected function __get_value() 468 | { 469 | return $this->element->nodeValue; 470 | } 471 | 472 | /** 473 | * Getter for the document's raw XML (without the XML declaration) 474 | * 475 | * @access public 476 | * @return void 477 | */ 478 | protected function __get_raw_xml() 479 | { 480 | $raw_xml = (string) $this; 481 | $raw_xml = trim(substr($raw_xml, strpos($raw_xml, "\n"))); 482 | 483 | return $raw_xml; 484 | } 485 | 486 | /** 487 | * Getter for this node's *inner* XML 488 | * 489 | * @access public 490 | * @return string 491 | */ 492 | protected function __get_inner_xml() 493 | { 494 | $raw_xml = $this->raw_xml; 495 | $raw_xml = substr($raw_xml, strpos($raw_xml, '<' . $this->name) + 1); 496 | $raw_xml = substr($raw_xml, strpos($raw_xml, '>') + 1); 497 | $raw_xml = substr($raw_xml, 0, strrpos($raw_xml, 'name . '>')); 498 | 499 | return trim($raw_xml); 500 | } 501 | 502 | #endregion 503 | 504 | #region // Setters 505 | 506 | /** 507 | * Setter for the document's schema location 508 | * 509 | * @access protected 510 | * @param string URI 511 | * @return void 512 | */ 513 | protected function __set_schema_location($value) 514 | { 515 | if (is_null($this->default_ns)) 516 | { 517 | $this->set_attribute('xsi:noNamespaceSchemaLocation', $value); 518 | } 519 | else 520 | { 521 | $this->set_attribute('xsi:schemaLocation', $this->default_ns . ' ' . $value); 522 | } 523 | } 524 | 525 | /** 526 | * Setter for the node's value. Automatically uses CDATA when needed 527 | * 528 | * @access protected 529 | * @param mixed Value 530 | * @return void 531 | */ 532 | protected function __set_value($value) 533 | { 534 | foreach ($this->element->childNodes as $child) 535 | { 536 | $this->element->removeChild($child); 537 | } 538 | 539 | // It could be that the passed value is an array 540 | if (is_array($value)) 541 | { 542 | foreach ($value as $node_name => $node_value) 543 | { 544 | $this->add_node($node_name, $node_value); 545 | } 546 | 547 | return; 548 | } 549 | 550 | // Figure out whether to use CDATA or not 551 | if (strpos($value, '<') !== false || strpos($value, '>') !== false || strpos($value, '&') !== false) 552 | { 553 | $text_node = $this->document->createCDATASection($value); 554 | } 555 | else 556 | { 557 | $text_node = $this->document->createTextNode($value); 558 | } 559 | 560 | $this->element->appendChild($text_node); 561 | } 562 | 563 | /** 564 | * Setter for the node's attributes 565 | * 566 | * @access public 567 | * @param array Value 568 | * @return void 569 | */ 570 | protected function __set_attributes($value) 571 | { 572 | while (list($attribute, ) = each($value)) 573 | { 574 | $this->remove_attribute($attribute); 575 | } 576 | 577 | foreach ($value as $attr_name => $attr_value) 578 | { 579 | $this->add_attribute($attr_name, $attr_value); 580 | } 581 | } 582 | 583 | #endregion 584 | 585 | /** 586 | * Return the document's raw XML 587 | * 588 | * @access public 589 | * @return string 590 | */ 591 | public function __toString() 592 | { 593 | $this->document->normalizeDocument(); 594 | 595 | $raw_xml = explode("\n", $this->document->saveXML()); 596 | for ($i = 0, $_i = sizeof($raw_xml); $i < $_i; $i++) 597 | { 598 | $raw_xml[$i] = str_repeat("\t", strspn($raw_xml[$i], ' ') / 2) . trim($raw_xml[$i]); 599 | } 600 | 601 | return implode("\n", $raw_xml); 602 | } 603 | 604 | /** 605 | * Get an array of cortex_xml objects based on an array of DOM* objects 606 | * 607 | * @access private 608 | * @param array DOM* objects 609 | * @return array 610 | */ 611 | private function parse_children($elements) 612 | { 613 | $children = array(); 614 | foreach ($elements as $element) 615 | { 616 | if (get_class($element) == 'DOMElement') 617 | { 618 | $children[] = self::load_element($element); 619 | } 620 | } 621 | 622 | return $children; 623 | } 624 | } 625 | ?> 626 | -------------------------------------------------------------------------------- /store/data/modx-1.2.6.xsd: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | -------------------------------------------------------------------------------- /includes/functions_mpv.php: -------------------------------------------------------------------------------- 1 | " : ""); 42 | } 43 | 44 | /** 45 | * Return formatted string for filesizes - "Borrowed" from phpBB3 46 | * 47 | * @param int $value filesize in bytes 48 | * @param bool $string_only true if language string should be returned 49 | * @param array $allowed_units only allow these units (data array indexes) 50 | * 51 | * @return mixed data array if $string_only is false 52 | * @author bantu 53 | */ 54 | function get_formatted_filesize($value, $string_only = true, $allowed_units = false) 55 | { 56 | global $lang; 57 | 58 | $available_units = array( 59 | 'gb' => array( 60 | 'min' => 1073741824, // pow(2, 30) 61 | 'index' => 3, 62 | 'si_unit' => $lang['GB'], 63 | 'iec_unit' => $lang['GIB'], 64 | ), 65 | 'mb' => array( 66 | 'min' => 1048576, // pow(2, 20) 67 | 'index' => 2, 68 | 'si_unit' => $lang['MB'], 69 | 'iec_unit' => $lang['MIB'], 70 | ), 71 | 'kb' => array( 72 | 'min' => 1024, // pow(2, 10) 73 | 'index' => 1, 74 | 'si_unit' => $lang['KB'], 75 | 'iec_unit' => $lang['KIB'], 76 | ), 77 | 'b' => array( 78 | 'min' => 0, 79 | 'index' => 0, 80 | 'si_unit' => $lang['BYTES'], // Language index 81 | 'iec_unit' => $lang['BYTES'], // Language index 82 | ), 83 | ); 84 | 85 | foreach ($available_units as $si_identifier => $unit_info) 86 | { 87 | if (!empty($allowed_units) && $si_identifier != 'b' && !in_array($si_identifier, $allowed_units)) 88 | { 89 | continue; 90 | } 91 | 92 | if ($value >= $unit_info['min']) 93 | { 94 | $unit_info['si_identifier'] = $si_identifier; 95 | 96 | break; 97 | } 98 | } 99 | unset($available_units); 100 | 101 | for ($i = 0; $i < $unit_info['index']; $i++) 102 | { 103 | $value /= 1024; 104 | } 105 | $value = round($value, 2); 106 | 107 | // Default to IEC 108 | $unit_info['unit'] = $unit_info['iec_unit']; 109 | 110 | if (!$string_only) 111 | { 112 | $unit_info['value'] = $value; 113 | 114 | return $unit_info; 115 | } 116 | 117 | return $value . ' ' . $unit_info['unit']; 118 | } 119 | 120 | /** 121 | * Return unique id - Based on phpBB3 function 122 | * @param string $extra additional entropy 123 | */ 124 | function unique_id($extra = 'c') 125 | { 126 | $rand_seed = md5(md5(rand(1000000, 9999999) . microtime()) . $extra); 127 | 128 | return substr($rand_seed, 4, 16); 129 | } 130 | 131 | /** 132 | * @author Chris Smith 133 | * @copyright 2006 Project Minerva Team 134 | * @param string $path The path which we should attempt to resolve. 135 | * @return mixed 136 | */ 137 | function phpbb_own_realpath($path) 138 | { 139 | // Now to perform funky shizzle 140 | 141 | // Switch to use UNIX slashes 142 | $path = str_replace(DIRECTORY_SEPARATOR, '/', $path); 143 | $path_prefix = ''; 144 | 145 | // Determine what sort of path we have 146 | if (is_absolute($path)) 147 | { 148 | $absolute = true; 149 | 150 | if ($path[0] == '/') 151 | { 152 | // Absolute path, *NIX style 153 | $path_prefix = ''; 154 | } 155 | else 156 | { 157 | // Absolute path, Windows style 158 | // Remove the drive letter and colon 159 | $path_prefix = $path[0] . ':'; 160 | $path = substr($path, 2); 161 | } 162 | } 163 | else 164 | { 165 | // Relative Path 166 | // Prepend the current working directory 167 | if (function_exists('getcwd')) 168 | { 169 | // This is the best method, hopefully it is enabled! 170 | $path = str_replace(DIRECTORY_SEPARATOR, '/', getcwd()) . '/' . $path; 171 | $absolute = true; 172 | if (preg_match('#^[a-z]:#i', $path)) 173 | { 174 | $path_prefix = $path[0] . ':'; 175 | $path = substr($path, 2); 176 | } 177 | else 178 | { 179 | $path_prefix = ''; 180 | } 181 | } 182 | else if (isset($_SERVER['SCRIPT_FILENAME']) && !empty($_SERVER['SCRIPT_FILENAME'])) 183 | { 184 | // Warning: If chdir() has been used this will lie! 185 | // Warning: This has some problems sometime (CLI can create them easily) 186 | $path = str_replace(DIRECTORY_SEPARATOR, '/', dirname($_SERVER['SCRIPT_FILENAME'])) . '/' . $path; 187 | $absolute = true; 188 | $path_prefix = ''; 189 | } 190 | else 191 | { 192 | // We have no way of getting the absolute path, just run on using relative ones. 193 | $absolute = false; 194 | $path_prefix = '.'; 195 | } 196 | } 197 | 198 | // Remove any repeated slashes 199 | $path = preg_replace('#/{2,}#', '/', $path); 200 | 201 | // Remove the slashes from the start and end of the path 202 | $path = trim($path, '/'); 203 | 204 | // Break the string into little bits for us to nibble on 205 | $bits = explode('/', $path); 206 | 207 | // Remove any . in the path, renumber array for the loop below 208 | $bits = array_values(array_diff($bits, array('.'))); 209 | 210 | // Lets get looping, run over and resolve any .. (up directory) 211 | for ($i = 0, $max = sizeof($bits); $i < $max; $i++) 212 | { 213 | // @todo Optimise 214 | if ($bits[$i] == '..' ) 215 | { 216 | if (isset($bits[$i - 1])) 217 | { 218 | if ($bits[$i - 1] != '..') 219 | { 220 | // We found a .. and we are able to traverse upwards, lets do it! 221 | unset($bits[$i]); 222 | unset($bits[$i - 1]); 223 | $i -= 2; 224 | $max -= 2; 225 | $bits = array_values($bits); 226 | } 227 | } 228 | else if ($absolute) // ie. !isset($bits[$i - 1]) && $absolute 229 | { 230 | // We have an absolute path trying to descend above the root of the filesystem 231 | // ... Error! 232 | return false; 233 | } 234 | } 235 | } 236 | 237 | // Prepend the path prefix 238 | array_unshift($bits, $path_prefix); 239 | 240 | $resolved = ''; 241 | 242 | $max = sizeof($bits) - 1; 243 | 244 | // Check if we are able to resolve symlinks, Windows cannot. 245 | $symlink_resolve = (function_exists('readlink')) ? true : false; 246 | 247 | foreach ($bits as $i => $bit) 248 | { 249 | if (@is_dir("$resolved/$bit") || ($i == $max && @is_file("$resolved/$bit"))) 250 | { 251 | // Path Exists 252 | if ($symlink_resolve && is_link("$resolved/$bit") && ($link = readlink("$resolved/$bit"))) 253 | { 254 | // Resolved a symlink. 255 | $resolved = $link . (($i == $max) ? '' : '/'); 256 | continue; 257 | } 258 | } 259 | else 260 | { 261 | // Something doesn't exist here! 262 | // This is correct realpath() behaviour but sadly open_basedir and safe_mode make this problematic 263 | // return false; 264 | } 265 | $resolved .= $bit . (($i == $max) ? '' : '/'); 266 | } 267 | 268 | // @todo If the file exists fine and open_basedir only has one path we should be able to prepend it 269 | // because we must be inside that basedir, the question is where... 270 | // @internal The slash in is_dir() gets around an open_basedir restriction 271 | if (!@file_exists($resolved) || (!is_dir($resolved . '/') && !is_file($resolved))) 272 | { 273 | return false; 274 | } 275 | 276 | // Put the slashes back to the native operating systems slashes 277 | $resolved = str_replace('/', DIRECTORY_SEPARATOR, $resolved); 278 | 279 | // Check for DIRECTORY_SEPARATOR at the end (and remove it!) 280 | if (substr($resolved, -1) == DIRECTORY_SEPARATOR) 281 | { 282 | return substr($resolved, 0, -1); 283 | } 284 | 285 | return $resolved; // We got here, in the end! 286 | } 287 | 288 | if (!function_exists('realpath')) 289 | { 290 | /** 291 | * A wrapper for realpath 292 | * @ignore 293 | */ 294 | function phpbb_realpath($path) 295 | { 296 | return phpbb_own_realpath($path); 297 | } 298 | } 299 | else 300 | { 301 | /** 302 | * A wrapper for realpath 303 | */ 304 | function phpbb_realpath($path) 305 | { 306 | $realpath = realpath($path); 307 | 308 | // Strangely there are provider not disabling realpath but returning strange values. :o 309 | // We at least try to cope with them. 310 | if ($realpath === $path || $realpath === false) 311 | { 312 | return phpbb_own_realpath($path); 313 | } 314 | 315 | // Check for DIRECTORY_SEPARATOR at the end (and remove it!) 316 | if (substr($realpath, -1) == DIRECTORY_SEPARATOR) 317 | { 318 | $realpath = substr($realpath, 0, -1); 319 | } 320 | 321 | return $realpath; 322 | } 323 | } 324 | 325 | /** 326 | * Display validation results as HTML 327 | */ 328 | function generate_text_for_html_display($text) 329 | { 330 | //Replace new 331 | $text = str_replace("\n", "
\n", $text); 332 | 333 | //BBCode replacement array 334 | $bbcode = array( 335 | "/\[b\](.*?)\[\/b\]/is" => '$1', 336 | "/\[u\](.*?)\[\/u\]/is" => '$1', 337 | "/\[color\=(.*?)\](.*?)\[\/color\]/is" => '$2', 338 | "/\[code\](.*?)\[\/code\]/is" => '
$1
', 339 | ); 340 | 341 | //Replace BBCode 342 | $text = preg_replace(array_keys($bbcode), array_values($bbcode), $text); 343 | $text = preg_replace_callback('#\[url(=(.*))?\](.*)\[/url\]#iU', function ($ary) { return(validate_url($ary[2], $ary[3])); }, $text); 344 | 345 | return $text; 346 | } 347 | 348 | /** 349 | * Validate url 350 | * 351 | * @param string $var1 optional url parameter for url bbcode: [url(=$var1)]$var2[/url] 352 | * @param string $var2 url bbcode content: [url(=$var1)]$var2[/url] 353 | */ 354 | function validate_url($var1, $var2) 355 | { 356 | global $config; 357 | 358 | $var1 = str_replace("\r\n", "\n", str_replace('\"', '"', trim($var1))); 359 | $var2 = str_replace("\r\n", "\n", str_replace('\"', '"', trim($var2))); 360 | 361 | $url = ($var1) ? $var1 : $var2; 362 | 363 | if ($var1 && !$var2) 364 | { 365 | $var2 = $var1; 366 | } 367 | 368 | if (!$url) 369 | { 370 | return '[url' . (($var1) ? '=' . $var1 : '') . ']' . $var2 . '[/url]'; 371 | } 372 | 373 | $valid = false; 374 | 375 | $url = str_replace(' ', '%20', $url); 376 | 377 | // Checking urls 378 | if (preg_match('#^' . get_preg_expression('url') . '$#i', $url) || 379 | preg_match('#^' . get_preg_expression('www_url') . '$#i', $url)) 380 | { 381 | $valid = true; 382 | } 383 | 384 | if ($valid) 385 | { 386 | // if there is no scheme, then add http schema 387 | if (!preg_match('#^[a-z][a-z\d+\-.]*:/{2}#i', $url)) 388 | { 389 | $url = 'http://' . $url; 390 | } 391 | 392 | return ($var1) ? '' . $var2 . '' : ''; 393 | } 394 | 395 | return '[url' . (($var1) ? '=' . $var1 : '') . ']' . $var2 . '[/url]'; 396 | } 397 | 398 | /** 399 | * This function returns a regular expression pattern for commonly used expressions 400 | * Use with / as delimiter for email mode and # for url modes 401 | * mode can be: email|bbcode_htm|url|url_inline|www_url|www_url_inline|relative_url|relative_url_inline|ipv4|ipv6 402 | */ 403 | function get_preg_expression($mode) 404 | { 405 | switch ($mode) 406 | { 407 | case 'url': 408 | case 'url_inline': 409 | $inline = ($mode == 'url') ? ')' : ''; 410 | $scheme = ($mode == 'url') ? '[a-z\d+\-.]' : '[a-z\d+]'; // avoid automatic parsing of "word" in "last word.http://..." 411 | // generated with regex generation file in the develop folder 412 | return "[a-z]$scheme*:/{2}(?:(?:[a-z0-9\-._~!$&'($inline*+,;=:@|]+|%[\dA-F]{2})+|[0-9.]+|\[[a-z0-9.]+:[a-z0-9.]+:[a-z0-9.:]+\])(?::\d*)?(?:/(?:[a-z0-9\-._~!$&'($inline*+,;=:@|]+|%[\dA-F]{2})*)*(?:\?(?:[a-z0-9\-._~!$&'($inline*+,;=:@/?|]+|%[\dA-F]{2})*)?(?:\#(?:[a-z0-9\-._~!$&'($inline*+,;=:@/?|]+|%[\dA-F]{2})*)?"; 413 | break; 414 | 415 | case 'www_url': 416 | case 'www_url_inline': 417 | $inline = ($mode == 'www_url') ? ')' : ''; 418 | return "www\.(?:[a-z0-9\-._~!$&'($inline*+,;=:@|]+|%[\dA-F]{2})+(?::\d*)?(?:/(?:[a-z0-9\-._~!$&'($inline*+,;=:@|]+|%[\dA-F]{2})*)*(?:\?(?:[a-z0-9\-._~!$&'($inline*+,;=:@/?|]+|%[\dA-F]{2})*)?(?:\#(?:[a-z0-9\-._~!$&'($inline*+,;=:@/?|]+|%[\dA-F]{2})*)?"; 419 | break; 420 | 421 | case 'relative_url': 422 | case 'relative_url_inline': 423 | $inline = ($mode == 'relative_url') ? ')' : ''; 424 | return "(?:[a-z0-9\-._~!$&'($inline*+,;=:@|]+|%[\dA-F]{2})*(?:/(?:[a-z0-9\-._~!$&'($inline*+,;=:@|]+|%[\dA-F]{2})*)*(?:\?(?:[a-z0-9\-._~!$&'($inline*+,;=:@/?|]+|%[\dA-F]{2})*)?(?:\#(?:[a-z0-9\-._~!$&'($inline*+,;=:@/?|]+|%[\dA-F]{2})*)?"; 425 | break; 426 | } 427 | 428 | return ''; 429 | } 430 | 431 | 432 | 433 | // phpbb_chmod() permissions 434 | @define('CHMOD_ALL', 7); 435 | @define('CHMOD_READ', 4); 436 | @define('CHMOD_WRITE', 2); 437 | @define('CHMOD_EXECUTE', 1); 438 | 439 | /** 440 | * Global function for chmodding directories and files for internal use 441 | * 442 | * This function determines owner and group whom the file belongs to and user and group of PHP and then set safest possible file permissions. 443 | * The function determines owner and group from common.php file and sets the same to the provided file. 444 | * The function uses bit fields to build the permissions. 445 | * The function sets the appropiate execute bit on directories. 446 | * 447 | * Supported constants representing bit fields are: 448 | * 449 | * CHMOD_ALL - all permissions (7) 450 | * CHMOD_READ - read permission (4) 451 | * CHMOD_WRITE - write permission (2) 452 | * CHMOD_EXECUTE - execute permission (1) 453 | * 454 | * NOTE: The function uses POSIX extension and fileowner()/filegroup() functions. If any of them is disabled, this function tries to build proper permissions, by calling is_readable() and is_writable() functions. 455 | * 456 | * @param string $filename The file/directory to be chmodded 457 | * @param int $perms Permissions to set 458 | * 459 | * @return bool true on success, otherwise false 460 | * @author faw, phpBB Group 461 | */ 462 | function phpbb_chmod($filename, $perms = CHMOD_READ) 463 | { 464 | static $_chmod_info; 465 | 466 | // Return if the file no longer exists. 467 | if (!file_exists($filename)) 468 | { 469 | return false; 470 | } 471 | 472 | // Determine some common vars 473 | if (empty($_chmod_info)) 474 | { 475 | if (!function_exists('fileowner') || !function_exists('filegroup')) 476 | { 477 | // No need to further determine owner/group - it is unknown 478 | $_chmod_info['process'] = false; 479 | } 480 | else 481 | { 482 | global $root_path, $phpEx; 483 | 484 | // Determine owner/group of common.php file and the filename we want to change here 485 | $common_php_owner = @fileowner($phpbb_root_path . 'index.' . $phpEx); 486 | $common_php_group = @filegroup($phpbb_root_path . 'index.' . $phpEx); 487 | 488 | // And the owner and the groups PHP is running under. 489 | $php_uid = (function_exists('posix_getuid')) ? @posix_getuid() : false; 490 | $php_gids = (function_exists('posix_getgroups')) ? @posix_getgroups() : false; 491 | 492 | // If we are unable to get owner/group, then do not try to set them by guessing 493 | if (!$php_uid || empty($php_gids) || !$common_php_owner || !$common_php_group) 494 | { 495 | $_chmod_info['process'] = false; 496 | } 497 | else 498 | { 499 | $_chmod_info = array( 500 | 'process' => true, 501 | 'common_owner' => $common_php_owner, 502 | 'common_group' => $common_php_group, 503 | 'php_uid' => $php_uid, 504 | 'php_gids' => $php_gids, 505 | ); 506 | } 507 | } 508 | } 509 | 510 | if ($_chmod_info['process']) 511 | { 512 | $file_uid = @fileowner($filename); 513 | $file_gid = @filegroup($filename); 514 | 515 | // Change owner 516 | if (@chown($filename, $_chmod_info['common_owner'])) 517 | { 518 | clearstatcache(); 519 | $file_uid = @fileowner($filename); 520 | } 521 | 522 | // Change group 523 | if (@chgrp($filename, $_chmod_info['common_group'])) 524 | { 525 | clearstatcache(); 526 | $file_gid = @filegroup($filename); 527 | } 528 | 529 | // If the file_uid/gid now match the one from common.php we can process further, else we are not able to change something 530 | if ($file_uid != $_chmod_info['common_owner'] || $file_gid != $_chmod_info['common_group']) 531 | { 532 | $_chmod_info['process'] = false; 533 | } 534 | } 535 | 536 | // Still able to process? 537 | if ($_chmod_info['process']) 538 | { 539 | if ($file_uid == $_chmod_info['php_uid']) 540 | { 541 | $php = 'owner'; 542 | } 543 | else if (in_array($file_gid, $_chmod_info['php_gids'])) 544 | { 545 | $php = 'group'; 546 | } 547 | else 548 | { 549 | // Since we are setting the everyone bit anyway, no need to do expensive operations 550 | $_chmod_info['process'] = false; 551 | } 552 | } 553 | 554 | // We are not able to determine or change something 555 | if (!$_chmod_info['process']) 556 | { 557 | $php = 'other'; 558 | } 559 | 560 | // Owner always has read/write permission 561 | $owner = CHMOD_READ | CHMOD_WRITE; 562 | if (is_dir($filename)) 563 | { 564 | $owner |= CHMOD_EXECUTE; 565 | 566 | // Only add execute bit to the permission if the dir needs to be readable 567 | if ($perms & CHMOD_READ) 568 | { 569 | $perms |= CHMOD_EXECUTE; 570 | } 571 | } 572 | 573 | switch ($php) 574 | { 575 | case 'owner': 576 | $result = @chmod($filename, ($owner << 6) + (0 << 3) + (0 << 0)); 577 | 578 | clearstatcache(); 579 | 580 | if (is_readable($filename) && is_writable($filename)) 581 | { 582 | break; 583 | } 584 | 585 | case 'group': 586 | $result = @chmod($filename, ($owner << 6) + ($perms << 3) + (0 << 0)); 587 | 588 | clearstatcache(); 589 | 590 | if ((!($perms & CHMOD_READ) || is_readable($filename)) && (!($perms & CHMOD_WRITE) || is_writable($filename))) 591 | { 592 | break; 593 | } 594 | 595 | case 'other': 596 | $result = @chmod($filename, ($owner << 6) + ($perms << 3) + ($perms << 0)); 597 | 598 | clearstatcache(); 599 | 600 | if ((!($perms & CHMOD_READ) || is_readable($filename)) && (!($perms & CHMOD_WRITE) || is_writable($filename))) 601 | { 602 | break; 603 | } 604 | 605 | default: 606 | return false; 607 | break; 608 | } 609 | 610 | return $result; 611 | } 612 | 613 | ?> 614 | --------------------------------------------------------------------------------