Fixed get_post() support for numeric fields.
[fa-stable.git] / includes / system_tests.inc
index 34e97e9639d6721fabc9c2c65e34b54118fa22b2..17d89b63b433a26b44a9bcc8fa89b831c070f588 100644 (file)
@@ -14,7 +14,7 @@
 $test_level = array(
        0 => _('Info'),
        1 => _('Optional'),
-       2 => _('Recomended'),
+       2 => _('Recommended'),
        3 => _('Required ')
 );
 
@@ -23,8 +23,11 @@ function tst_mysql()
 {
        $test['descr'] = _('MySQL version'). ' >=4.1';
        $test['type'] = 3;
-       $test['test'] = mysql_get_server_info();
-       $test['result'] = $test['test']>='4.1';
+       $test['test'] = db_get_version();
+       if (!($test['result'] = ($test['test']>='4.1'))) {
+               $db_str = explode('-', $test['test']);
+               $test['result'] = ($db_str[1] == 'MariaDB');
+       }
        $test['comments'] = _('Upgrade MySQL server to version at least 4.1');
 
        return $test;
@@ -34,7 +37,7 @@ function tst_phpmysql()
 {
        $test['descr'] = _('PHP MySQL extension');
        $test['type'] = 3;
-       $test['result'] = function_exists('gettext');
+       $test['result'] = db_extension_exists();
        $test['test'] = $test['result'] ? _('Yes'): _('No');
        
        $test['comments'] = _('Your PHP has to have MySQL extension enabled.');
@@ -43,11 +46,11 @@ function tst_phpmysql()
 
 function tst_php() 
 {
-       $test['descr'] = _('PHP version').' >=4.3.3';
+       $test['descr'] = _('PHP version').' >=5.0.0';
        $test['type'] = 3;
        $test['test'] = phpversion();
-       $test['result'] = $test['test']>='4.3.3';
-       $test['comments'] = _('Upgrade PHP to version at least 4.3.3');
+       $test['result'] = $test['test']>='5.0.0';
+       $test['comments'] = _('Upgrade PHP to version at least 5.0.0');
 
        return $test;
 }
@@ -113,18 +116,18 @@ function tst_gettext()
        $test['test'] = function_exists('gettext') ? _('Yes'): _('No');
        $test['type'] = 1;
        $test['result'] = true;
-       $test['comments'] = _('In case of no getext support, php emulation is used');
+       $test['comments'] = _('In case of no gettext support, php emulation is used');
 
        return $test;
 }
 
 function tst_debug() 
 {
-       global $go_debug;
+       global $SysPrefs;
        $test['descr'] = _('Debugging mode');
        $test['type'] = 0;
-       $test['test'] = $go_debug ? _("Yes") : _("No");
-       $test['result'] = $go_debug != 0;
+       $test['test'] = $SysPrefs->go_debug ? _("Yes") : _("No");
+       $test['result'] = $SysPrefs->go_debug != 0;
        $test['comments'] = _('To switch debugging on set $go_debug>0 in config.php file');
 
        return $test;
@@ -132,8 +135,9 @@ function tst_debug()
 
 function tst_logging() 
 {
-       global $error_logfile;
+       global $SysPrefs;
        
+       $error_logfile = $SysPrefs->error_logfile;
        $test['descr'] = _('Error logging');
        $test['type'] = 2;
        // if error lgging is on, but log file does not exists try write
@@ -220,16 +224,16 @@ function tst_tmpdir()
        
        $test['descr'] = _('Temporary directory');
        $test['type'] = 3;
-       $test['test'] = $path_to_root.'/tmp';
+       $test['test'] = VARLIB_PATH;
        $test['result'] = is_dir($test['test']) && is_writable($test['test']);
        $test['comments'][] = sprintf(_("'%s' is not writeable"), $test['test']);
        return $test;
 }
 
-function tst_langs()
+function tst_langs($install)
 {
-       global $installed_languages, $path_to_root;
-       
+       global $installed_languages, $path_to_root, $GetText;
+
        $test['descr'] = _('Language configuration consistency');
        $test['type'] = 3;
        $test['result'] = true;
@@ -243,12 +247,14 @@ function tst_langs()
                return $test;
        }
        
-       $fname =  $path_to_root.'/lang/installed_languages.inc';
-       $test['test'] = $fname;
-       if (!(is_file($fname) && is_writable($fname))) {
-               $test['result'] = false;
-               $test['comments'][] = _("Languages configuration file should be writeable.");
-               return $test;
+       if (!$install) {
+               $fname =  $path_to_root.'/lang/installed_languages.inc';
+               $test['test'] = $fname;
+               if (!(is_file($fname) && is_writable($fname))) {
+                       $test['result'] = false;
+                       $test['comments'][] = _("Languages configuration file should be writeable.");
+                       return $test;
+               }
        }
 
        $langs = array();
@@ -267,7 +273,7 @@ function tst_langs()
                        $test['result'] = false;
                        $test['comments'][] = sprintf( _('Missing %s translation file.'), $file);
                }
-               if (!$_SESSION['get_text']->check_support($lang['code'], $lang['encoding']))
+               if (!$GetText->check_support($lang['code'], $lang['encoding']))
                {
                        $test['result'] = false;
                        $test['comments'][] = sprintf(_('Missing system locale: %s'), $lang['code'].".".$lang['encoding']);
@@ -332,44 +338,48 @@ function tst_extconfig($install)
        $test['type'] = 3;
        $fname =  $path_to_root.'/installed_extensions.php';
        $test['test'][] = $fname;
-       $test['result'] = is_file($fname) && is_writable($fname);
+       $test['result'] = ($install || is_file($fname)) && check_write($fname);
        $test['test'][] = company_path().'/*/installed_extensions.php';
+       if (!$test['result'])
+               $test['comments'][] = sprintf(_("'%s' is not writeable"), $fname);
 
        foreach ($comps as $n) {
                $path = company_path($n);
                if (!is_dir($path)) continue;
 
                $path .= "/installed_extensions.php";
-               if (!is_file($path) || !is_writable($path) ) {
+               if ((!$install && !is_file($path)) || !check_write($path) ) {
                        $test['result'] = false;
                        $test['comments'][] = sprintf(_("'%s' is not writeable"), $path);
                        continue;
                };
        }
-       $fname =  $path_to_root.'/modules';
-       $test['test'][] = $fname;
-       $test['result'] &= is_dir($fname) && is_writable($fname);
-
-       $fname =  $path_to_root.'/modules/_cache';
-       $test['test'][] = $fname;
-       $test['result'] &= is_dir($fname) && is_writable($fname);
-
-       $fname =  $path_to_root.'/themes';
-       $test['test'][] = $fname;
-       $test['result'] &= is_dir($fname) && is_writable($fname);
+       foreach(array('modules', 'modules/_cache', 'themes', 'sql') as $dir) {
+               $fname =  $path_to_root.'/'.$dir;
+               $test['test'][] = $fname;
+               $t = is_dir($fname) && is_writable($fname);
+               if (!$t)
+                       $test['comments'][] = sprintf(_("'%s' is not writeable"), $fname);
+               $test['result'] &= $t;
+       }
 
-       $fname =  $path_to_root.'/sql';
-       $test['test'][] = $fname;
-       $test['result'] &= is_dir($fname) && is_writable($fname);
+       foreach(array('Release', 'Themes', 'Languages', 'Extensions', 'Charts') as $file) {
+               $fname = $path_to_root."/modules/_cache/".$file.".gz";
+               $t = !file_exists($fname) || is_writable($fname);
+               if (!$t)
+                       $test['comments'][] = sprintf(_("'%s' is not writeable"), $fname);
+               $test['result'] &= $t;
+       }
 
        if(!$test['result'])
                $test['comments'][] = _("Extensions configuration files and directories should be writeable");
 
+       $fname = $path_to_root."/themes";
        $themedir = opendir($fname);
        while (false !== ($fname = readdir($themedir)))
        {
-               if ($fname!='.' && $fname!='..' && $fname!='CVS' && is_dir($path_to_root.'/themes/'.$fname)
-                       && !in_array($fname, array('aqua', 'cool', 'default')))
+               if ($fname!='.' && $fname!='..' && is_dir($path_to_root.'/themes/'.$fname)
+                       && !in_array($fname, array('canvas', 'default', 'dropdown')))
                {
                        $test['test'][] = $fname;
                        $test['result'] = is_writable($path_to_root.'/themes/'.$fname);
@@ -410,7 +420,7 @@ function display_system_tests($install = false)
                );
 
 
-       start_table(TABLESTYLE, "width=80%");
+       start_table(TABLESTYLE, "width='80%'");
        $th = array(_("Test"), _('Test type'), _("Value"), _("Comments"));
        table_header($th);