diff --git a/admin-dev/tabs/AdminInformation.php b/admin-dev/tabs/AdminInformation.php
deleted file mode 100644
index 7f5ca57b2..000000000
--- a/admin-dev/tabs/AdminInformation.php
+++ /dev/null
@@ -1,372 +0,0 @@
-
-* @copyright 2007-2011 PrestaShop SA
-* @version Release: $Revision: 6844 $
-* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
-* International Registered Trademark & Property of PrestaShop SA
-*/
-
-class AdminInformation extends AdminTab
-{
- private function _getTestResultHtml()
- {
- $html = '';
- // Functions list to test with 'test_system'
- $funcs = array('fopen', 'fclose', 'fread', 'fwrite', 'rename', 'file_exists', 'unlink', 'rmdir', 'mkdir', 'getcwd', 'chdir', 'chmod');
-
- // Test list to execute (function/args)
- $tests = array(
- 'phpversion' => false,
- 'upload' => false,
- 'system' => $funcs,
- 'gd' => false,
- 'mysql_support' => false,
- 'config_dir' => _PS_ADMIN_DIR_.'/../config/',
- 'cache_dir' => _PS_CACHE_DIR_,
- 'sitemap' => _PS_ADMIN_DIR_.'/../sitemap.xml',
- 'img_dir' => _PS_ADMIN_DIR_.'/../img/',
- 'mails_dir' => _PS_ADMIN_DIR_.'/../mails/',
- 'module_dir' => _PS_ADMIN_DIR_.'/../modules/',
- 'theme_lang_dir' => _PS_ADMIN_DIR_.'/../themes/'._THEME_NAME_.'/lang/',
- 'translations_dir' => _PS_ADMIN_DIR_.'/../translations/',
- 'customizable_products_dir' => _PS_ADMIN_DIR_.'/../upload/',
- 'virtual_products_dir' => _PS_ADMIN_DIR_.'/../download/'
- );
-
- $tests_op = array(
- 'fopen' => false,
- 'register_globals' => false,
- 'gz' => false
- );
-
- $testsErrors = array(
- 'phpversion' => $this->l('Update your PHP version'),
- 'upload' => $this->l('Configure your server to allow the upload file'),
- 'system' => $this->l('Configure your server to allow the creation of directories and write to files'),
- 'gd' => $this->l('Enable the GD library on your server'),
- 'mysql_support' => $this->l('Enable the MySQL support on your server'),
- 'config_dir' => $this->l('Set write permissions for config folder'),
- 'cache_dir' => $this->l('Set write permissions for cache folder'),
- 'sitemap' => $this->l('Set write permissions for sitemap.xml file'),
- 'img_dir' => $this->l('Set write permissions for img folder and subfolders/recursively'),
- 'mails_dir' => $this->l('Set write permissions for mails folder and subfolders/recursively'),
- 'module_dir' => $this->l('Set write permissions for modules folder and subfolders/recursively'),
- 'theme_lang_dir' => $this->l('Set write permissions for themes/')._THEME_NAME_.$this->l('/lang/ folder and subfolders/recursively'),
- 'translations_dir' => $this->l('Set write permissions for translations folder and subfolders/recursively'),
- 'customizable_products_dir' => $this->l('Set write permissions for upload folder and subfolders/recursively'),
- 'virtual_products_dir' => $this->l('Set write permissions for download folder and subfolders/recursively'),
- 'fopen' => $this->l('Enable fopen on your server'),
- 'register_globals' => $this->l('Set PHP register global option to off'),
- 'gz' => $this->l('Enable GZIP compression on your server')
- );
-
- $paramsRequiredResults = self::check($tests);
- $paramsOptionalResults = self::check($tests_op);
-
- $html .= '
-
- '.$this->l('Required parameters').':';
- if (!in_array('fail', $paramsRequiredResults))
- $html .= ' OK
-
- ';
- else
- {
- $html .= ' '.$this->l('Please consult the following error(s)').'
-
-
- ';
- foreach ($paramsRequiredResults AS $key => $value)
- if ($value == 'fail')
- $html .= '- '.$testsErrors[$key].'
';
- $html .= '
';
- }
-
- $html .= '
-
- '.$this->l('Optional parameters').':';
- if (!in_array('fail', $paramsOptionalResults))
- $html .= ' OK
-
- ';
- else
- {
- $html .= ' '.$this->l('Please consult the following error(s)').'
-
-
- ';
- foreach ($paramsOptionalResults AS $key => $value)
- if ($value == 'fail')
- $html .= '- '.$testsErrors[$key].'
';
- $html .= '
';
- }
-
- return $html;
- }
-
- public function display()
- {
- echo '
- '.$this->l('Information').'
-
-
-
-
-
- ';
- }
-
- static private function check($tests)
- {
- $res = array();
- foreach ($tests AS $key => $test)
- $res[$key] = self::run($key, $test);
- return $res;
- }
-
- static private function run($ptr, $arg = 0)
- {
- if (call_user_func(array('self', 'test_'.$ptr), $arg))
- return ('ok');
- return ('fail');
- }
-
- // Misc functions
- static private function test_phpversion()
- {
- return PHP_VERSION_ID >= 50000; /* PHP version > 5.0 */
- }
-
- static private function test_mysql_support()
- {
- return function_exists('mysql_connect');
- }
-
- static private function test_upload()
- {
- return ini_get('file_uploads');
- }
-
- static private function test_fopen()
- {
- return ini_get('allow_url_fopen');
- }
-
- static private function test_system($funcs)
- {
- foreach ($funcs AS $func)
- if (!function_exists($func))
- return false;
- return true;
- }
-
- static private function test_gd()
- {
- return function_exists('imagecreatetruecolor');
- }
-
- static private function test_register_globals()
- {
- return !ini_get('register_globals');
- }
-
- static private function test_gz()
- {
- if (function_exists('gzencode'))
- return !(@gzencode('dd') === false);
- return false;
- }
-
- // is_writable dirs
- static private function test_dir($dir, $recursive = false)
- {
- if (!is_writable($dir) OR !$dh = opendir($dir))
- return false;
- if ($recursive)
- {
- while (($file = readdir($dh)) !== false)
- if (is_dir($dir.$file) AND $file != '.' AND $file != '..')
- if (!self::test_dir($dir.$file, true))
- return false;
- }
- closedir($dh);
- return true;
- }
-
- // is_writable files
- static private function test_file($file)
- {
- return (file_exists($file) AND is_writable($file));
- }
-
- static private function test_config_dir($dir)
- {
- return self::test_dir($dir);
- }
-
- static private function test_sitemap($dir)
- {
- return self::test_file($dir);
- }
-
- static private function test_root_dir($dir)
- {
- return self::test_dir($dir);
- }
-
- static private function test_admin_dir($dir)
- {
- return self::test_dir($dir);
- }
-
- static private function test_img_dir($dir)
- {
- return self::test_dir($dir, true);
- }
-
- static private function test_module_dir($dir)
- {
- return self::test_dir($dir, true);
- }
-
- static function test_cache_dir($dir)
- {
- return self::test_dir($dir);
- }
-
- static private function test_download_dir($dir)
- {
- return self::test_dir($dir);
- }
-
- static private function test_mails_dir($dir)
- {
- return self::test_dir($dir, true);
- }
-
- static private function test_translations_dir($dir)
- {
- return self::test_dir($dir, true);
- }
-
- static private function test_theme_lang_dir($dir)
- {
- return self::test_dir($dir, true);
- }
-
- static private function test_customizable_products_dir($dir)
- {
- return self::test_dir($dir);
- }
-
- static private function test_virtual_products_dir($dir)
- {
- return self::test_dir($dir);
- }
-}
diff --git a/admin-dev/themes/template/information/content.tpl b/admin-dev/themes/template/information/content.tpl
new file mode 100755
index 000000000..946b652e6
--- /dev/null
+++ b/admin-dev/themes/template/information/content.tpl
@@ -0,0 +1,119 @@
+{l s='Information'}
+
+
+
+
+
diff --git a/classes/ConfigurationTest.php b/classes/ConfigurationTest.php
index ea3343811..8db378aef 100644
--- a/classes/ConfigurationTest.php
+++ b/classes/ConfigurationTest.php
@@ -27,6 +27,62 @@
class ConfigurationTestCore
{
+
+ /**
+ * getDefaultTests return an array of tests to executes.
+ * key are method name, value are parameters (false for no parameter)
+ * all path are _PS_ROOT_DIR_ related
+ *
+ * @return array
+ */
+ public static function getDefaultTests()
+ {
+ return array(
+ 'system' => array(
+ 'fopen', 'fclose', 'fread', 'fwrite',
+ 'rename', 'file_exists', 'unlink', 'rmdir', 'mkdir',
+ 'getcwd', 'chdir', 'chmod'
+ ),
+
+ 'phpversion' => false,
+ 'upload' => false,
+ 'gd' => false,
+ 'mysql_support' => false,
+ 'config_dir' => 'config',
+ 'cache_dir' => 'cache',
+ 'sitemap' => 'sitemap.xml',
+ 'img_dir' => 'img',
+ 'mails_dir' => 'mails',
+ 'module_dir' => 'modules',
+ 'theme_lang_dir' => 'themes/'._THEME_NAME_.'/lang/',
+ 'translations_dir' => 'translations',
+ 'customizable_products_dir' => 'upload',
+ 'virtual_products_dir' => 'download'
+ );
+ }
+
+ /**
+ * getDefaultTestsOp return an array of tests to executes.
+ * key are method name, value are parameters (false for no parameter)
+ *
+ * @return array
+ */
+ public static function getDefaultTestsOp()
+ {
+
+ return array(
+ 'fopen' => false,
+ 'register_globals' => false,
+ 'gz' => false
+ );
+ }
+
+ /**
+ * run all test defined in $tests
+ *
+ * @param array $tests
+ * @return array results of tests
+ */
public static function check($tests)
{
$res = array();
@@ -38,8 +94,8 @@ class ConfigurationTestCore
public static function run($ptr, $arg = 0)
{
if (call_user_func(array('ConfigurationTest', 'test_'.$ptr), $arg))
- return ('ok');
- return ('fail');
+ return 'ok';
+ return 'fail';
}
public static function test_phpversion()
@@ -97,8 +153,9 @@ class ConfigurationTestCore
return false;
}
- public static function test_dir($dir, $recursive = false)
+ public static function test_dir($relative_dir, $recursive = false)
{
+ $dir = _PS_ROOT_DIR_.DIRECTORY_SEPARATOR.ltrim($relative_dir, '/');
if (!file_exists($dir) OR !$dh = opendir($dir))
return false;
$dummy = rtrim($dir, '/').'/'.uniqid();
@@ -113,16 +170,17 @@ class ConfigurationTestCore
if ($recursive)
{
while (($file = readdir($dh)) !== false)
- if (is_dir($dir.$file) && $file != '.' && $file != '..')
- if (!self::test_dir($dir.$file, true))
+ if (is_dir($dir.DIRECTORY_SEPARATOR.$file) && $file != '.' && $file != '..' && $file != '.svn')
+ if (!self::test_dir($relative_dir.DIRECTORY_SEPARATOR.$file, true))
return false;
}
closedir($dh);
return true;
}
- public static function test_file($file)
+ public static function test_file($file_relative)
{
+ $file = _PS_ROOT_DIR_.DIRECTORY_SEPARATOR.$file_relative;
return (file_exists($file) AND is_writable($file));
}
@@ -163,7 +221,7 @@ class ConfigurationTestCore
public static function test_cache_dir($dir)
{
- return self::test_dir($dir);
+ return self::test_dir($dir, true);
}
public static function test_tools_v2_dir($dir)
diff --git a/controllers/admin/AdminInformationController.php b/controllers/admin/AdminInformationController.php
new file mode 100644
index 000000000..685727e11
--- /dev/null
+++ b/controllers/admin/AdminInformationController.php
@@ -0,0 +1,107 @@
+
+* @copyright 2007-2011 PrestaShop SA
+* @version Release: $Revision: 6844 $
+* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
+* International Registered Trademark & Property of PrestaShop SA
+*/
+
+class AdminInformationControllerCore extends AdminController
+{
+
+
+ public function initContent()
+ {
+ parent::initContent();
+
+ $this->context->smarty->assign(array(
+ 'version' => array(
+ 'mysql' => Db::getInstance()->getVersion(),
+ 'php' => phpversion(),
+ 'ps' => _PS_VERSION_,
+ 'server' => $_SERVER['SERVER_SOFTWARE'],
+ ),
+ 'uname' => function_exists('php_uname') ? php_uname('s').' '.php_uname('v').' '.php_uname('m') : '',
+ 'apache_instaweb' => Tools::apacheModExists('mod_instaweb'),
+ 'shop' => array(
+ 'url' => Tools::getHttpHost(true).__PS_BASE_URI__,
+ 'theme' => _THEME_NAME_,
+ ),
+ 'mail' => Configuration::get('PS_MAIL_METHOD') == 1,
+ 'smtp' => array(
+ 'server' => Configuration::get('PS_MAIL_SERVER'),
+ 'user' => Configuration::get('PS_MAIL_USER'),
+ 'password' => Configuration::get('PS_MAIL_PASSWD'),
+ 'encryption' => Configuration::get('PS_MAIL_SMTP_ENCRYPTION'),
+ 'port' => Configuration::get('PS_MAIL_SMTP_PORT'),
+ ),
+ 'user_agent' => $_SERVER["HTTP_USER_AGENT"],
+ ));
+
+ $this->context->smarty->assign($this->getTestResult());
+ }
+
+ /**
+ * get all tests
+ *
+ * @return array of test results
+ */
+ public function getTestResult()
+ {
+ // Functions list to test with 'test_system'
+ // Test to execute (function/args) : lets uses the default test
+ $tests = ConfigurationTest::getDefaultTests();
+ $tests_op = ConfigurationTest::getDefaultTestsOp();
+
+ $testsErrors = array(
+ 'phpversion' => $this->l('Update your PHP version'),
+ 'upload' => $this->l('Configure your server to allow the upload file'),
+ 'system' => $this->l('Configure your server to allow the creation of directories and write to files'),
+ 'gd' => $this->l('Enable the GD library on your server'),
+ 'mysql_support' => $this->l('Enable the MySQL support on your server'),
+ 'config_dir' => $this->l('Set write permissions for config folder'),
+ 'cache_dir' => $this->l('Set write permissions for cache folder'),
+ 'sitemap' => $this->l('Set write permissions for sitemap.xml file'),
+ 'img_dir' => $this->l('Set write permissions for img folder and subfolders/recursively'),
+ 'mails_dir' => $this->l('Set write permissions for mails folder and subfolders/recursively'),
+ 'module_dir' => $this->l('Set write permissions for modules folder and subfolders/recursively'),
+ 'theme_lang_dir' => $this->l('Set write permissions for themes/')._THEME_NAME_.$this->l('/lang/ folder and subfolders/recursively'),
+ 'translations_dir' => $this->l('Set write permissions for translations folder and subfolders/recursively'),
+ 'customizable_products_dir' => $this->l('Set write permissions for upload folder and subfolders/recursively'),
+ 'virtual_products_dir' => $this->l('Set write permissions for download folder and subfolders/recursively'),
+ 'fopen' => $this->l('Enable fopen on your server'),
+ 'register_globals' => $this->l('Set PHP register global option to off'),
+ 'gz' => $this->l('Enable GZIP compression on your server')
+ );
+
+ $paramsRequiredResults = ConfigurationTest::check($tests);
+ $paramsOptionalResults = ConfigurationTest::check($tests_op);
+
+ return array(
+ 'failRequired' => in_array('fail', $paramsRequiredResults),
+ 'failOptional' => in_array('fail', $paramsOptionalResults),
+ 'testsErrors' => $testsErrors,
+ 'testsRequired' => $paramsRequiredResults,
+ 'testsOptional' => $paramsOptionalResults,
+ );
+ }
+}