X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fsystem_tests.inc;h=798ef6776539c8251e9bb4a6fd704b972edb2e75;hb=b11418d0e2c2691abcb5330e6b62bc1d45b741f1;hp=2e227bc48ddf36a374dd73c601d9fc58f64b613a;hpb=79ad571f44f329428c5af41b41d9a61aa90e4be1;p=fa-stable.git diff --git a/includes/system_tests.inc b/includes/system_tests.inc index 2e227bc4..798ef677 100644 --- a/includes/system_tests.inc +++ b/includes/system_tests.inc @@ -14,7 +14,7 @@ $test_level = array( 0 => _('Info'), 1 => _('Optional'), - 2 => _('Recomended'), + 2 => _('Recommended'), 3 => _('Required ') ); @@ -34,7 +34,7 @@ function tst_phpmysql() { $test['descr'] = _('PHP MySQL extension'); $test['type'] = 3; - $test['result'] = function_exists('gettext'); + $test['result'] = function_exists('mysql_connect'); $test['test'] = $test['result'] ? _('Yes'): _('No'); $test['comments'] = _('Your PHP has to have MySQL extension enabled.'); @@ -113,7 +113,7 @@ 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; } @@ -226,7 +226,7 @@ function tst_tmpdir() return $test; } -function tst_langs() +function tst_langs($install) { global $installed_languages, $path_to_root; @@ -236,25 +236,30 @@ function tst_langs() $test['comments'] = array(); $fname = $path_to_root.'/lang'; - $test['test'][] = $fname; + $test['test'] = $fname; if (!(is_dir($fname) && is_writable($fname))) { $test['result'] = false; $test['comments'][] = _("Languages folder should be writeable."); + 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."); + 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(); foreach ($installed_languages as $lang) { + + if ($lang['code'] == 'C') continue; // no translation (English) $langs[] = $lang['code']; - if ($lang['code'] == 'en_GB') continue; // native FA language - + $file = $path_to_root.'/lang/'.$lang['code'].'/LC_MESSAGES/'.$lang['code']; if (@$lang['version']) $file .= '-'.$lang['version']; @@ -297,16 +302,25 @@ function tst_config($install) return $test; } -function tst_dbconfig() +function tst_dbconfig($install) { global $path_to_root; $test['descr'] = _('Database auth file'); - $test['type'] = 2; $test['test'] = $path_to_root.'/config_db.php'; - $test['result'] = is_file($test['test']) && !is_writable($test['test']); - $test['comments'][] = sprintf(_("'%s' file should be read-only if you do not plan to add or change companies"), $test['test']); + if ($install) { + $test['type'] = 3; + $writable = check_write($test['test']); + $test['result'] = $writable==1; + $test['comments'][] = $writable == 0 ? + sprintf(_("Can't write '%s' file. Check FA directory write permissions."), $test['test']) + : sprintf(_("'%s' file exists."), $test['test']); + } else { + $test['type'] = 2; + $test['result'] = is_file($test['test']) && !is_writable($test['test']); + $test['comments'][] = sprintf(_("'%s' file should be read-only if you do not plan to add or change companies"), $test['test']); + } return $test; } @@ -320,35 +334,30 @@ 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); - - $fname = $path_to_root.'/sql'; - $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; + } if(!$test['result']) $test['comments'][] = _("Extensions configuration files and directories should be writeable"); @@ -386,7 +395,8 @@ function display_system_tests($install = false) global $test_level; if ($install) - $system_tests = array('tst_php', 'tst_phpmysql', 'tst_system', 'tst_config', + $system_tests = array('tst_php', 'tst_phpmysql', 'tst_system', 'tst_dbconfig', + 'tst_config', 'tst_subdirs', 'tst_langs', 'tst_tmpdir', 'tst_sessionpath', 'tst_extconfig' ); else