| | |
| | | if (is_readable($file)) { |
| | | include $file; |
| | | |
| | | // read comments from config file |
| | | if (function_exists('token_get_all')) { |
| | | $tokens = token_get_all(file_get_contents($file)); |
| | | $in_config = false; |
| | | $buffer = ''; |
| | | for ($i=0; $i < count($tokens); $i++) { |
| | | $token = $tokens[$i]; |
| | | if ($token[0] == T_VARIABLE && $token[1] == '$config' || $token[1] == '$rcmail_config') { |
| | | $in_config = true; |
| | | if ($buffer && $tokens[$i+1] == '[' && $tokens[$i+2][0] == T_CONSTANT_ENCAPSED_STRING) { |
| | | $propname = trim($tokens[$i+2][1], "'\""); |
| | | $this->comments[$propname] = $buffer; |
| | | $buffer = ''; |
| | | $i += 3; |
| | | } |
| | | } |
| | | else if ($in_config && $token[0] == T_COMMENT) { |
| | | $buffer .= strtr($token[1], array('\n' => "\n")); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // deprecated name of config variable |
| | | if (is_array($rcmail_config)) { |
| | | return $rcmail_config; |
| | |
| | | $config[$prop] = $value; |
| | | } |
| | | |
| | | // sort by option name |
| | | ksort($config); |
| | | |
| | | $out = "<?php\n\n"; |
| | | $out .= "/* Local configuration for Roundcube Webmail */\n\n"; |
| | | foreach ($config as $prop => $value) { |
| | | // @TODO: copy option descriptions from defaults.inc.php file? |
| | | $out .= "\$config['$prop'] = " . rcube_install::_dump_var($value, $prop) . ";\n"; |
| | | // copy option descriptions from existing config or defaults.inc.php |
| | | $out .= $this->comments[$prop]; |
| | | $out .= "\$config['$prop'] = " . rcube_install::_dump_var($value, $prop) . ";\n\n"; |
| | | } |
| | | $out .= "\n?>"; |
| | | |
| | | return $out; |
| | | } |
| | |
| | | return $schema; |
| | | } |
| | | |
| | | /** |
| | | * Try to detect some file's mimetypes to test the correct behavior of fileinfo |
| | | */ |
| | | function check_mime_detection() |
| | | { |
| | | $files = array( |
| | | 'installer/images/roundcube_logo.png' => 'image/png', |
| | | 'program/resources/blank.tif' => 'image/tiff', |
| | | 'skins/larry/templates/login.html' => 'text/html', |
| | | ); |
| | | |
| | | $errors = array(); |
| | | foreach ($files as $path => $expected) { |
| | | $mimetype = rcube_mime::file_content_type(INSTALL_PATH . $path, basename($path)); |
| | | if ($mimetype != $expected) { |
| | | $errors[] = array($path, $mimetype, $expected); |
| | | } |
| | | } |
| | | |
| | | return $errors; |
| | | } |
| | | |
| | | /** |
| | | * Check the correct configuration of the 'mime_types' mapping option |
| | | */ |
| | | function check_mime_extensions() |
| | | { |
| | | $types = array( |
| | | 'application/zip' => 'zip', |
| | | 'application/x-tar' => 'tar', |
| | | 'application/java-archive' => 'jar', |
| | | 'image/bmp' => 'bmp', |
| | | 'image/svg+xml' => 'svg', |
| | | ); |
| | | |
| | | $errors = array(); |
| | | foreach ($types as $mimetype => $expected) { |
| | | $ext = rcube_mime::get_mime_extensions($mimetype); |
| | | if ($ext[0] != $expected) { |
| | | $errors[] = array($mimetype, $ext, $expected); |
| | | } |
| | | } |
| | | |
| | | return $errors; |
| | | } |
| | | |
| | | /** |
| | | * Getter for the last error message |
| | |
| | | * @param string Test name |
| | | * @param string Error message |
| | | * @param string URL for details |
| | | * @param bool Do not count this failure |
| | | */ |
| | | function fail($name, $message = '', $url = '') |
| | | function fail($name, $message = '', $url = '', $optional=false) |
| | | { |
| | | $this->failures++; |
| | | if (!$optional) { |
| | | $this->failures++; |
| | | } |
| | | |
| | | echo Q($name) . ': <span class="fail">NOT OK</span>'; |
| | | $this->_showhint($message, $url); |