* @copyright 2007-2011 PrestaShop SA * @version Release: $Revision: 7456 $ * @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/', 'tools_dir' => PS_ADMIN_DIR.'/../tools/smarty/compile', 'cache_dir' => PS_ADMIN_DIR.'/../tools/smarty/cache/', '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'), 'tools_dir' => $this->l('Set write permissions for tools 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)').'

'; } $html .= '

'.$this->l('Optional parameters').':'; if (!in_array('fail', $paramsOptionalResults)) $html .= ' OK

'; else { $html .= ' '.$this->l('Please consult the following error(s)').'

'; } return $html; } public function display() { global $currentIndex; echo '

'.$this->l('Information').'

'.$this->l('Help').'

'.$this->l('This information must be indicated when you report a bug on our bug tracker or if you report a problem on our forum.').'


'.$this->l('Information about your configuration').'

'.$this->l('Server information').'

'.$this->l('Prestashop Version').': '._PS_VERSION_.'

'; if (function_exists('php_uname')) echo '

'.$this->l('Server information').': '.php_uname('s').' '.php_uname('v').' '.php_uname('m').'

'; echo '

'.$this->l('Server software Version').': '.$_SERVER['SERVER_SOFTWARE'].'

'.$this->l('PHP Version').': '.phpversion().'

'.$this->l('MySQL Version').': '.mysql_get_server_info().'

'; if (function_exists('apache_get_modules') AND in_array('mod_instaweb', apache_get_modules())) echo '

'.$this->l('PageSpeed module for Apache installed (mod_instaweb)').'

'; echo '

'.$this->l('Store information').'

'.$this->l('URL of your website').': '.Tools::getHttpHost(true).__PS_BASE_URI__.'

'.$this->l('Theme name used').': '._THEME_NAME_.'


'.$this->l('Mail information').'

'.$this->l('Mail method').': '; if (Configuration::get('PS_MAIL_METHOD') == 1) echo $this->l('You use PHP mail() function.').'

'; else { echo $this->l('You use your own SMTP parameters').'

'; echo '

'.$this->l('SMTP server').': '.Configuration::get('PS_MAIL_SERVER').'

'.$this->l('SMTP user').': '.(Configuration::get('PS_MAIL_USER') ? $this->l('Defined') : ''.$this->l('Not defined').'').'

'.$this->l('SMTP password').': '.(Configuration::get('PS_MAIL_PASSWD') ? $this->l('Defined') : ''.$this->l('Not defined').'').'

'.$this->l('Encryption').': '.Configuration::get('PS_MAIL_SMTP_ENCRYPTION').'

'.$this->l('Port').': '.Configuration::get('PS_MAIL_SMTP_PORT').'

'; } echo '

'.$this->l('Your information').'

'.$this->l('Information from you').': '.$_SERVER["HTTP_USER_AGENT"].'


'.$this->l('Check your configuration').' '.self::_getTestResultHtml().'
'; } 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 (@filetype($dir.$file) == 'dir' 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 private function test_tools_dir($dir) { return self::test_dir($dir); } 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); } }