Просмотр исходного кода

Merge branch 'master' of https://github.com/boonex/dolphin

AntonLV 12 лет назад
Родитель
Сommit
e92e109f04

+ 1 - 1
inc/classes/BxDolIO.php

@@ -24,7 +24,7 @@ class BxDolIO extends BxDol
         return (is_file($sFile) && is_executable($sFile));
     }
 
-    public static function isWritable($sFile, $sPrePath = '/../../')
+    public static function isWritable($sFile)
     {
         clearstatcache();
 

+ 0 - 2
inc/classes/BxDolXmlParser.php

@@ -7,8 +7,6 @@
  * @{
  */
 
-defined('BX_DOL') or die('hack attempt');
-
 bx_import('BxDol');
 
 class BxDolXmlParser extends BxDol implements iBxDolSingleton {

+ 4 - 2
inc/js/jquery.dolPopup.js

@@ -273,8 +273,10 @@
 						pointer: oPointerOptions
 					});
                 };
-                
-                $('#' + sPopupId).find(options.container).load(sUrlRoot + options.url, function () {
+
+                var sUrl = (options.url.indexOf('http://') == 0 || options.url.indexOf('https://') == 0 || options.url.indexOf('/') == 0 ? '' : sUrlRoot) + options.url;
+
+                $('#' + sPopupId).find(options.container).load(sUrl, function () {
                 	if($('#' + sPopupId).find('img').length > 0)
                 		$('#' + sPopupId).find('img').load(fOnLoad);
                 	else

+ 22 - 2
install/classes/BxDolInstallController.php

@@ -42,14 +42,34 @@ class BxDolInstallController
     {
         $this->_oView->pageStart();
 
+        $aLangs = BxDolInstallLang::getInstance()->getAvailableLanguages();
+
         $oAudit = new BxDolStudioToolsAudit();
         $aErrors = $oAudit->checkRequirements(BX_DOL_AUDIT_FAIL);
         $aWarnings = $oAudit->checkRequirements(BX_DOL_AUDIT_WARN);
+
         $oAudit->generateStyles();
+
         if (empty($aErrors))
-            $this->_oView->out('initial.php', compact('aWarnings'));
+            $this->_oView->out('initial.php', compact('aLangs', 'aWarnings'));
         else
-            $this->_oView->out('initial_fail.php', compact('aErrors'));
+            $this->_oView->out('initial_fail.php', compact('aLangs', 'aErrors'));
+
+        $this->_oView->pageEnd('Dolphin 8.0.0 Installation');
+    }
+    function actionPermissions () 
+    {
+        $this->_oView->pageStart();
+
+        $oAdmTools = new BxDolStudioTools();
+        
+        $sPermissionsStyles = $oAdmTools->generateStyles();
+
+        ob_start();
+        $bPermissionsOk = $oAdmTools->checkPermissions();
+        $sPermissionsTable = ob_get_clean();
+
+        $this->_oView->out('permissions.php', compact('sPermissionsStyles', 'sPermissionsTable', 'bPermissionsOk'));
 
         $this->_oView->pageEnd('Dolphin 8.0.0 Installation');
     }

+ 143 - 0
install/classes/BxDolInstallLang.php

@@ -0,0 +1,143 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    DolphinInstall Dolphin Install
+ * @{
+ */
+
+class BxDolInstallLang
+{
+    protected $_aLang;
+    protected $_sLang;
+
+    public function __construct($sLang) 
+    {
+        if (!$sLang)
+            $sLang = BX_INSTALL_DEFAULT_LANGUAGE;
+        $aModules = $this->getModules('language');
+        $aModuleConfig = $this->getModuleConfigByLang ($sLang, $aModules);
+        if (!$aModuleConfig && BX_INSTALL_DEFAULT_LANGUAGE != $sLang) {
+            $sLang = BX_INSTALL_DEFAULT_LANGUAGE;
+            $aModuleConfig = $this->getModuleConfigByLang ($sLang, $aModules);
+        }
+
+        $this->_sLang = $sLang;
+        $this->_aLang = $this->readLanguage($aModuleConfig);
+    }
+
+    static function getInstance($sLang = '') {
+        if (!isset($GLOBALS['bxDolClasses'][__CLASS__]))
+            $GLOBALS['bxDolClasses'][__CLASS__] = new BxDolInstallLang($sLang);
+
+        return $GLOBALS['bxDolClasses'][__CLASS__];
+    }
+
+    public function _t ($sKey) 
+    {
+        $sKey = func_get_arg(0);
+        if (isset($this->_aLang[$sKey])) {
+            $s = $this->_aLang[$sKey];
+
+            if (($iNumArgs = func_num_args()) > 1)
+                for ($i = 1; $i < $iNumArgs; $i++)
+                    $s = str_replace('{' . ($i - 1) . '}', func_get_arg($i), $s);
+
+            return $s;
+        }
+
+        return $sKey;
+    }
+   
+    public function getAvailableLanguages () {
+        $aRet = array();
+        $aModules = $this->getModules('language');
+        foreach ($aModules as $aModuleConfig)
+            $aRet[$aModuleConfig['home_uri']] = array(
+                'code' => $aModuleConfig['home_uri'],
+                'title' => $aModuleConfig['title'],
+                'icon' => BX_INSTALL_URL_MODULES . $aModuleConfig['home_dir'] . 'template/images/icons/std-pi.png',
+            );
+        return $aRet;
+    }
+
+    public function getModules ($sType = null) {
+    	$aModules = array();
+
+        $sPath = BX_INSTALL_DIR_MODULES;
+        if (($rHandleVendor = opendir($sPath)) !== false) {
+            while (($sVendor = readdir($rHandleVendor)) !== false) {
+                if (substr($sVendor, 0, 1) == '.' || !is_dir($sPath . $sVendor)) 
+                    continue;
+
+                if (($rHandleModule = opendir($sPath . $sVendor)) !== false) {
+                    while(($sModule = readdir($rHandleModule)) !== false) {
+                        if(!is_dir($sPath . $sVendor . '/' . $sModule) || substr($sModule, 0, 1) == '.')
+                            continue;
+
+						$sConfigPath = $sPath . $sVendor . '/' . $sModule . '/install/config.php';
+						$aModuleConfig = $this->getModuleConfigByConfigPath($sConfigPath);
+						if (empty($aModuleConfig) || ($sType && $sType != $aModuleConfig['type']))
+							continue;
+
+						$aModules[$aModuleConfig['name']] = $aModuleConfig;
+                    }
+                    closedir($rHandleModule);
+                }
+            }
+            closedir($rHandleVendor);
+        }
+
+        ksort($aModules);
+        return $aModules;
+    }
+
+    protected function getModuleConfigByConfigPath ($sConfigPath) {
+		if (!file_exists($sConfigPath))
+			return array();
+
+		include($sConfigPath);
+
+        return $aConfig;
+    }
+
+    protected function getModuleConfigByLang ($sLang, $aModules) {
+        foreach ($aModules as $aModuleConfig)
+            if ($sLang == $aModuleConfig['home_uri'])
+                return $aModuleConfig;
+        return null;
+    }
+
+    protected function readLanguage ($aModuleConfig) {
+        $sPath = BX_INSTALL_DIR_MODULES . $aModuleConfig['home_dir'] . 'data/langs/system.xml';
+
+    	if(!file_exists($sPath))
+    		return array();
+
+    	$oXmlParser = BxDolXmlParser::getInstance();
+    	$sXmlContent = file_get_contents($sPath);
+
+        return $oXmlParser->getValues($sXmlContent, 'string');
+    }
+    
+}
+
+if (!function_exists('_t')) {
+    $sLang = 'en';
+    if (isset($_GET['lang'])) {
+        $sLang = $_GET['lang'];
+        setcookie( 'lang', '', time() - 60*60*24);
+        setcookie( 'lang', $sLang, time() + 60*60*24*365);
+    } elseif (isset($_COOKIE['lang'])) {
+        $sLang = $_COOKIE['lang'];
+    }
+
+    BxDolInstallLang::getInstance($sLang);
+
+    function _t() {
+        return call_user_func_array(array(BxDolInstallLang::getInstance(), '_t'), func_get_args());
+    }
+}
+
+/** @} */

+ 1 - 0
install/classes/BxDolInstallView.php

@@ -30,6 +30,7 @@ class BxDolInstallView
 
     protected $_aFilesJs = array (
         'plugins/jquery/jquery.js',
+        'inc/js/jquery.dolPopup.js',
     );
 
     function __construct()

+ 20 - 5
install/css/styles.css

@@ -4,6 +4,14 @@ html, body {
     margin: 0;
 	height: 100%;
 }
+
+.bx-install-permissions .bx-btn,
+.bx-install-initial .bx-btn {
+    display:inline;
+    display:inline-block;
+    float:none;
+}
+
 .bx-install-page {
 	min-height: 100%;
 	height: auto !important;
@@ -28,7 +36,7 @@ html, body {
     text-align:center;
 }
 
-.bx-install-initial img {
+.bx-install-initial img.bx-install-dolphin {
     display:block;
     margin-left:auto;
     margin-right:auto;
@@ -36,8 +44,15 @@ html, body {
     max-width:90%;
 }
 
-.bx-install-initial .bx-btn {
-    display:inline;
-    display:inline-block;
-    float:none;
+.bx-install-initial-langs {
+    text-align:center;
+}
+
+.bx-install-initial-langs img {
+    width:32px;
+    height:32px;
+}
+
+.bx-install-permissions-buttons {
+    text-align:center;
 }

+ 17 - 0
install/index.php

@@ -8,19 +8,36 @@
  */
 
 define('BX_DOL', 1);
+define('BX_DOL_INSTALL', 1);
 
+define ('BX_INSTALL_DEFAULT_LANGUAGE', 'en');
+
+define ('BX_INSTALL_URL_ROOT', '../');
+define ('BX_INSTALL_URL_MODULES', '../modules/');
+
+define ('BX_INSTALL_DIR_ROOT', '../');
+define ('BX_INSTALL_DIR_MODULES', '../modules/');
 define ('BX_INSTALL_DIR_PLUGINS', '../plugins/');
 define ('BX_INSTALL_DIR_TEMPLATES', './templates/');
 define ('BX_INSTALL_DIR_CLASSES', './classes/');
 
+if (!defined('BX_DOL_MODULE_TYPE_MODULE')) {
+    define('BX_DOL_MODULE_TYPE_MODULE', 'module');
+    define('BX_DOL_MODULE_TYPE_LANGUAGE', 'language');
+    define('BX_DOL_MODULE_TYPE_TEMPLATE', 'template');
+}
+
 require_once('../inc/utils.inc.php');
 require_once('../inc/classes/BxDol.php');
+require_once('../inc/classes/BxDolIO.php');
+require_once('../inc/classes/BxDolXmlParser.php');
 require_once('../template/scripts/BxBaseConfig.php');
 require_once('../studio/classes/BxDolStudioTools.php');
 require_once('../studio/classes/BxDolStudioToolsAudit.php');
 
 require_once(BX_INSTALL_DIR_CLASSES . 'BxDolInstallController.php');
 require_once(BX_INSTALL_DIR_CLASSES . 'BxDolInstallView.php');
+require_once(BX_INSTALL_DIR_CLASSES . 'BxDolInstallLang.php');
 
 $oController = new BxDolInstallController ();
 $oController->run(isset($_REQUEST['action']) ? $_REQUEST['action'] : '');

+ 10 - 4
install/templates/initial.php

@@ -1,10 +1,16 @@
 <div class="bx-install-initial">
-    <img class="bx-def-margin-bottom" src="img/dolphin.png" />
-    <a href="javascript:void(0);" class="bx-btn bx-btn-primary">Start installation</a>
-    <a href="?action=audit" class="bx-btn">Server audit</a>
+
+    <img class="bx-def-margin-bottom bx-install-dolphin" src="img/dolphin.png" alt="Dolphin 8" />
+
+    <?php include('lang_swither.php'); ?>
+
+    <a href="?action=permissions" class="bx-btn bx-btn-primary"><? echo _t('_sys_inst_start_installation'); ?></a>
+    <a href="?action=audit" class="bx-btn"><? echo _t('_sys_inst_server_audit'); ?></a>
+
     <?php if ($aWarnings): ?>
     <div class="bx-install-initial-waring bx-def-margin-top">
-        Your hosting setup has some warnings, for the complete report go to <a href="?action=audit">server audit page</a>.
+        <?php echo _t('_sys_inst_hosting_warnings'); ?>
     </div>
     <?php endif; ?>
+
 </div>

+ 7 - 2
install/templates/initial_fail.php

@@ -1,9 +1,14 @@
 <div class="bx-install-initial-fail">
-    Your hosting doesn't meet minimal requirements:
+
+    <?php include('lang_swither.php'); ?>
+
+    <?php echo _t('_sys_inst_hosting_fails'); ?>
     <ul>
     <?php foreach ($aErrors as $sMsg): ?>
         <li><?=$sMsg; ?></li>
     <?php endforeach; ?>
     </ul>
-    <a href="?action=audit" class="bx-btn">Server audit</a>
+
+    <a href="?action=audit" class="bx-btn"><? echo _t('_sys_inst_server_audit'); ?></a>
+
 </div>

+ 8 - 0
install/templates/lang_swither.php

@@ -0,0 +1,8 @@
+
+    <div class="bx-install-initial-langs bx-def-margin-bottom">
+    <?php foreach ($aLangs as $aLang): ?>
+        <a title="<?php echo bx_html_attribute($aLang['title']); ?>" href="?lang=<?=$aLang['code']; ?>">
+            <img src="<?php echo bx_html_attribute($aLang['icon']); ?>" alt="<?php echo bx_html_attribute($aLang['title']); ?>" />
+        </a>
+    <?php endforeach; ?>
+    </div>

+ 22 - 0
install/templates/permissions.php

@@ -0,0 +1,22 @@
+<div class="bx-install-permissions">
+
+    <h1><?php echo _t('_adm_admtools_Permissions'); ?></h1>
+
+   <?=$sPermissionsStyles; ?>
+   <?=$sPermissionsTable; ?>
+
+    <div class="bx-install-permissions-buttons bx-def-margin-top">
+
+        <?php if (!$bPermissionsOk): ?>
+            <div class="bx-def-margin-bottom">
+                <?php echo _t('_sys_inst_msg_permissions_wrong'); ?>
+            </div>
+            <a href="javascript:void(0);" class="bx-btn bx-btn-primary bx-btn-disabled"><? echo _t('_sys_inst_continue'); ?></a>
+        <?php endif; if ($bPermissionsOk): ?>
+            <a href="?action=info" class="bx-btn bx-btn-primary"><? echo _t('_sys_inst_continue'); ?></a>
+        <?php endif; ?>
+
+        <a href="javascript:void(0);" onclick="location.reload(false);" class="bx-btn"><? echo _t('_sys_inst_refresh'); ?></a>
+    </div>
+
+</div>

+ 67 - 5
modules/boonex/english/data/langs/system.xml

@@ -3026,22 +3026,23 @@ Please click "Continue" below to navigate to the home page of the site.]]></stri
 	<string name="_adm_ambuilder_Small_Icon"><![CDATA[Small Icon]]></string>
 	<string name="_adm_ambuilder_Big_Icon"><![CDATA[Big Icon]]></string>
 	<string name="_adm_mbuilder_All_Items"><![CDATA[All Items]]></string>
+	<string name="_adm_admtools_Path"><![CDATA[Path]]></string>
 	<string name="_adm_admtools_title"><![CDATA[Admin Tools]]></string>
 	<string name="_adm_admtools_Directories"><![CDATA[Directories]]></string>
 	<string name="_adm_admtools_Files"><![CDATA[Files]]></string>
 	<string name="_adm_admtools_Elements"><![CDATA[Elements]]></string>
 	<string name="_adm_admtools_Flash"><![CDATA[Flash]]></string>
-	<string name="_adm_admtools_Current_level"><![CDATA[Current level]]></string>
-	<string name="_adm_admtools_Desired_level"><![CDATA[Desired level]]></string>
+	<string name="_adm_admtools_Current_level"><![CDATA[Current status]]></string>
+	<string name="_adm_admtools_Desired_level"><![CDATA[Desired status]]></string>
 	<string name="_adm_admtools_Bad_files"><![CDATA[Next files and directories have inappropriate permissions]]></string>
 	<string name="_adm_admtools_Only_bad_files"><![CDATA[Show only troubled files and directories with inappropriate permissions]]></string>
 	<string name="_adm_admtools_Show_all_files"><![CDATA[Show all files and directories]]></string>
 	<string name="_adm_admtools_Perm_description"><![CDATA[Dolphin needs special access for certain files and directories. Please, change permissions as specified in the chart below. Helpful info about permissions is <a href="http://www.boonex.com/trac/dolphin/wiki/DetailedInstall#Permissions" target="_blank">available here</a>.]]></string>
 	<string name="_adm_admtools_Writable"><![CDATA[Writable]]></string>
-	<string name="_adm_admtools_Non_Writable"><![CDATA[Non-Writable]]></string>
-	<string name="_adm_admtools_Not_Exists"><![CDATA[Not Exists]]></string>
+	<string name="_adm_admtools_Non_Writable"><![CDATA[Not writable]]></string>
+	<string name="_adm_admtools_Not_Exists"><![CDATA[Not exists]]></string>
 	<string name="_adm_admtools_Executable"><![CDATA[Executable]]></string>
-	<string name="_adm_admtools_Non_Executable"><![CDATA[Non-Executable]]></string>
+	<string name="_adm_admtools_Non_Executable"><![CDATA[Not executable]]></string>
 	<string name="_adm_admtools_Permissions"><![CDATA[Permissions]]></string>
 	<string name="_sys_invitation_no_users_selected"><![CDATA[Please check at least one user or write at least one email]]></string>
 	<string name="_sys_invitation_step_select_users"><![CDATA[Select Users]]></string>
@@ -3626,6 +3627,67 @@ More info about URI DNSBL: <br />
 
     <string name="_sys_access_denied_to_private_content"><![CDATA[Access denied. This is private content.]]></string>
 
+    <string name="_sys_audit_version"><![CDATA[version]]></string>
+    <string name="_sys_audit_version_dolphin"><![CDATA[Dolphin version]]></string>
+    <string name="_sys_audit_permissions"><![CDATA[Files and folders permissions]]></string>
+    <string name="_sys_audit_mail_sending"><![CDATA[Mail sending]]></string>
+    <string name="_sys_audit_cron_jobs"><![CDATA[Cron jobs]]></string>
+    <string name="_sys_audit_php_accelerator"><![CDATA[PHP accelerator]]></string>
+    <string name="_sys_audit_php_setup"><![CDATA[PHP setup]]></string>
+    <string name="_sys_audit_userside_caching"><![CDATA[User-side caching for static content]]></string>
+    <string name="_sys_audit_serverside_compression"><![CDATA[Server-side content compression]]></string>
+    <string name="_sys_audit_title_fail"><![CDATA[FAIL]]></string>
+    <string name="_sys_audit_title_warn"><![CDATA[WARNING]]></string>
+    <string name="_sys_audit_title_undef"><![CDATA[UNDEFINED]]></string>
+    <string name="_sys_audit_title_ok"><![CDATA[OK]]></string>
+    <string name="_sys_audit_header_requirements"><![CDATA[Requirements]]></string>
+    <string name="_sys_audit_header_site_setup"><![CDATA[Site setup]]></string>
+    <string name="_sys_audit_header_site_optimization"><![CDATA[Site optimization]]></string>
+    <string name="_sys_audit_header_manual_audit"><![CDATA[Manual Server Audit]]></string>
+    <string name="_sys_audit_section_webserver"><![CDATA[Web-server]]></string>
+    <string name="_sys_audit_section_os"><![CDATA[OS]]></string>
+    <string name="_sys_audit_section_hardware"><![CDATA[Hardware]]></string>
+    <string name="_sys_audit_msg_should_be"><![CDATA[should be {0} {1}]]></string>
+    <string name="_sys_audit_msg_must_be"><![CDATA[must be {0} {1}]]></string>
+    <string name="_sys_audit_msg_value_checking_failed"><![CDATA[value checking failed]]></string>
+    <string name="_sys_audit_msg_version_is_incompatible"><![CDATA[your version is incompatible with Dolphin, must be at least {0}]]></string>
+    <string name="_sys_audit_msg_version_is_outdated"><![CDATA[your version is probably outdated, upgrade to the latest {0} maybe required]]></string>
+    <string name="_sys_audit_msg_hardware_requirements"><![CDATA[Hardware requirements can not be determined automatically - <a href="#manual_audit">manual server audit</a> may be required.]]></string>
+    <string name="_sys_audit_msg_permissions"><![CDATA[please <a href="javascript:void(0);" onclick="switchAdmPage($('#main_menu1'));">click here</a> to find out if dolphin permissions are correct.]]></string>
+    <string name="_sys_audit_msg_ffmpeg"><![CDATA[<pre class="code">{0}</pre>if you don't know if output is correct then <a href="#manual_audit">manual server audit</a> may be required.]]></string>
+    <string name="_sys_audit_msg_mail_sending"><![CDATA[<span id="bx-sys-adm-audit-test-email"><a href="javascript:void(0);" onclick="bx_sys_adm_audit_test_email()">click here</a> to send test email</span>]]></string>
+    <string name="_sys_audit_msg_cron_jobs"><![CDATA[<pre class="code">{0}</pre> if you are unsure if output is correct then <a href="#manual_audit">manual server audit</a> may be required]]></string>
+    <string name="_sys_audit_msg_php_accelerator_missing"><![CDATA[Dolphin can be much faster if you install some PHP accelerator]]></string>
+    <string name="_sys_audit_msg_php_setup_inefficient"><![CDATA[your PHP setup maybe very inefficient, <a href="javascript:void(0)" onclick="bx_sys_adm_audit_phpinfo()">please check it for sure</a> and try to switch to mod_php, apache dso module or FastCGI]]></string>
+    <string name="_sys_audit_msg_userside_caching"><![CDATA[
+<a href="{0}">click here to check it in Google Page Speed</a><br />
+If it is not enabled then please consider implement this optimization, since it improve perceived site speed and save the bandwidth, refer to <a target="_blank" href="http://www.boonex.com/trac/dolphin/wiki/HostingServerSetupRecommendations#Usersidecachingforstaticcontent">this tutorial</a> on how to do this.<br />{1}]]></string>
+    <string name="_sys_audit_msg_serverside_compression"><![CDATA[
+can be checked <a href="#manual_audit">manually</a> or in "Page Speed" tool build-in into browser.<br />
+If it is not enabled then please consider implement this optimization, since it improve perceived site speed and save the bandwidth, refer to <a href="http://www.boonex.com/trac/dolphin/wiki/HostingServerSetupRecommendations#Serversidecontentcompression">this tutorial</a> on how to do this.<br />{0}]]></string>
+    <string name="_sys_audit_msg_optimization_apache_module"><![CDATA[To apply this optimization you need to have <b>{0}</b> - {1}]]></string>
+    <string name="_sys_audit_msg_apache_module_undef"><![CDATA[try to check manually: apachectl -M 2>&1 | grep {0}]]></string>
+    <string name="_sys_audit_msg_apache_module_fail"><![CDATA[you will need to install {0} for Apache]]></string>
+
+    <string name="_sys_audit_msg_dolphin_optimization_fail"><![CDATA[please enable this cache in Dolphin Admin Panel -> Settings -> Advanced Settings]]></string>
+    <string name="_sys_audit_msg_dolphin_optimization_warn"><![CDATA[installing PHP accelerator will speed-up file cache]]></string>
+    <string name="_sys_audit_msg_dolphin_x_based_cache_engine"><![CDATA[ ({0} based cache engine)]]></string>
+    <string name="_sys_audit_msg_manual_audit"><![CDATA[<p>
+Some things can not be determined automatically, manual server audit is required to check it. 
+If you don't know how to do it by yourself you can submit <a target="_blank" href="http://www.boonex.com/help/tickets">BoonEx Server Audit Request</a>.
+</p>]]></string>
+    <string name="_sys_audit_msg_mail_send_failed"><![CDATA[mail send failed]]></string>
+    <string name="_sys_audit_msg_mail_sent"><![CDATA[test mail was send, please check {0} mailbox]]></string>
+
+    <string name="_sys_inst_msg_permissions_wrong"><![CDATA[Some files or folders rights aren't correct, please set necessary permissions then click "Continue".]]></string>
+
+    <string name="_sys_inst_start_installation"><![CDATA[Start installation]]></string>
+    <string name="_sys_inst_server_audit"><![CDATA[Server audit]]></string>
+    <string name="_sys_inst_hosting_warnings"><![CDATA[Your hosting setup has some warnings, for the complete report go to <a href="?action=audit">server audit page</a>.]]></string>
+    <string name="_sys_inst_hosting_fails"><![CDATA[Your hosting doesn't meet minimal requirements:]]></string>
+    <string name="_sys_inst_refresh"><![CDATA[Refresh]]></string>
+    <string name="_sys_inst_continue"><![CDATA[Continue]]></string>
+
     <!-- ********************** -->
     <!-- Auto Installed Modules -->
     <!-- ********************** -->

+ 14 - 1
modules/boonex/russian/data/langs/system.xml

@@ -2910,6 +2910,7 @@ Without doing that you won't be submitted to our database.</p>
 	<string name="_adm_ambuilder_Small_Icon"><![CDATA[Small Icon]]></string>
 	<string name="_adm_ambuilder_Big_Icon"><![CDATA[Big Icon]]></string>
 	<string name="_adm_mbuilder_All_Items"><![CDATA[All Items]]></string>
+	<string name="_adm_admtools_Path"><![CDATA[Путь]]></string>
 	<string name="_adm_admtools_title"><![CDATA[Admin Tools]]></string>
 	<string name="_adm_admtools_Directories"><![CDATA[Directories]]></string>
 	<string name="_adm_admtools_Files"><![CDATA[Files]]></string>
@@ -2918,7 +2919,7 @@ Without doing that you won't be submitted to our database.</p>
 	<string name="_adm_admtools_Current_level"><![CDATA[Current level]]></string>
 	<string name="_adm_admtools_Desired_level"><![CDATA[Desired level]]></string>
 	<string name="_adm_admtools_Bad_files"><![CDATA[Next files and directories have inappropriate permissions]]></string>
-	<string name="_adm_admtools_Only_bad_files"><![CDATA[Show only troubled files and directories with inappropriate permissions]]></string>
+	<string name="_adm_admtools_Only_bad_files"><![CDATA[Показывать только файлы и папки с неправильными правами]]></string>
 	<string name="_adm_admtools_Show_all_files"><![CDATA[Show all files and directories]]></string>
 	<string name="_adm_admtools_Perm_description"><![CDATA[Dolphin needs special access for certain files and directories. Please, change permissions as specified in the chart below. Helpful info about permissions is <a href="http://www.boonex.com/trac/dolphin/wiki/DetailedInstall#Permissions" target="_blank">available here</a>.]]></string>
 	<string name="_adm_admtools_Writable"><![CDATA[Writable]]></string>
@@ -3427,4 +3428,16 @@ More info about URI DNSBL: <br />
 
     <string name="_sys_profile_system"><![CDATA[Account]]></string>
 
+    <string name="_sys_audit_version"><![CDATA[версия]]></string>
+    <string name="_sys_audit_title_fail"><![CDATA[ПРОВАЛ]]></string>
+    <string name="_sys_audit_title_warn"><![CDATA[ПРЕДУПРЕЖДЕНИЕ]]></string>
+    <string name="_sys_audit_title_undef"><![CDATA[НЕ ОПРЕДЕЛЕНО]]></string>
+    <string name="_sys_audit_title_ok"><![CDATA[ПОРЯДОК]]></string>
+    <string name="_sys_audit_msg_should_be"><![CDATA[хорошо бы {0} {1}]]></string>
+    <string name="_sys_audit_msg_must_be"><![CDATA[нужно {0} {1}]]></string>
+
+    <string name="_sys_inst_start_installation"><![CDATA[Начать инсталляцию]]></string>
+    <string name="_sys_inst_server_audit"><![CDATA[Аудит сервера]]></string>
+    <string name="_sys_inst_hosting_warnings"><![CDATA[Есть некоторые замечания к настройкам сервера, можно перейти к <a href="?action=audit">аудиту сервера</a> для более подробной информации.]]></string>
+
 </resources>

+ 1 - 1
studio/classes/BxDolStudioInstallerUtils.php

@@ -17,7 +17,7 @@ class BxDolStudioInstallerUtils extends BxDolInstallerUtils implements iBxDolSin
         parent::__construct();
     }
 
-	/**
+    /**
      * Prevent cloning the instance
      */
     public function __clone() {

+ 128 - 374
studio/classes/BxDolStudioTools.php

@@ -7,398 +7,112 @@
  * @{
  */
 
-require_once('./../inc/classes/BxDolIO.php');
+bx_import('BxDolIO');
 
-// TODO: consider rewriting installer
+define('BX_DOL_PERM_FILE', 'file');
+define('BX_DOL_PERM_DIR', 'dir');
+define('BX_DOL_PERM_EXE', 'exe');
+
+define('BX_DOL_PERM_FAIL', false);
+define('BX_DOL_PERM_OK', true);
 
 class BxDolStudioTools extends BxDolIO
 {
+    protected $bInstallScript;
+    protected $sRootPath;
+    
+    public $aInstallPermissions;
+    public $aPostInstallPermissions;
 
-    protected $sTroubledElements;
-
-    public $aInstallDirs;
-    public $aInstallFiles;
-    public $aPostInstallPermDirs;
-    public $aPostInstallPermFiles;
-
-    function __construct()
+    public function __construct()
     {
         parent::__construct();
 
-        $this->sTroubledElements = '';
-
-        $this->aInstallDirs = array(
+        $this->aInstallPermissions = array(
             'cache',
             'cache_public',
             'tmp',
+//            'plugins/ffmpeg/ffmpeg.exe',
             'plugins/htmlpurifier/standalone/HTMLPurifier/DefinitionCache/Serializer',
         );
 
-        $this->aInstallFiles = array(
-        );
-
-        $this->aPostInstallPermDirs = array(
-        );
-
-        $this->aPostInstallPermFiles = array(
+        $this->aPostInstallPermissions = array(
         );
+                
+        if (defined('BX_DOL_INSTALL') && BX_DOL_INSTALL) {
+            $this->bInstallScript = true;
+            $this->sRootPath = BX_INSTALL_URL_ROOT;
+        } else {
+            $this->bInstallScript = false;
+            $this->sRootPath = BX_DOL_URL_ROOT;
+        }
     }
 
-    function GenCommonCode()
+    public function generateStyles()
     {
-        $sAdditionDir = (isAdmin()==true) ? BX_DOL_URL_ROOT : '../';
-        $sMasterSwPic = $sAdditionDir . 'media/images/master_nav.gif';
-
         $sRet = <<<EOF
 <style type="text/css">
 
-    div.hidden {
+    .hidden {
         display:none;
     }
 
-    .left_side_sw_caption {
-        float:left;
-        text-align:justify;
-        width:515px;
-    }
-
-    .right_side_sw_caption {
-        float:right;
-        font-weight:normal;
+    .bx-permissions-table {
+        border-collapse:collapse;
     }
 
-    tr.head td {
-        background-color:#FFFFFF;
+    .bx-permissions-table thead td {
         font-weight:bold;
-        height:17px;
-        padding:5px;
-        text-align:center;
-        font-size:13px;
-        border-color:silver;
-    }
-    tr.cont td {
-        height:15px;
-        padding:2px 5px;
-        font-size:13px;
-        border-color:silver;
     }
 
-    .install_table {
-        background-color: silver;
-        border-width:0px;
+    .bx-permissions-table td:not(:first-child) {
+        text-align:center;
     }
 
-    span.unwritable {
+    .bx-permissions-wrong {
         color:red;
         font-weight:bold;
-        margin-right:5px;
     }
 
-    span.writable {
+    .bx-permissions-ok {
         color:green;
         font-weight:bold;
-        margin-right:5px;
-    }
-
-    span.desired {
-        font-weight:bold;
-        margin-right:5px;
-    }
-
-    .install_table tr.even {
-        background-color:#EDE9E9;
-    }
-
-    .install_table tr.odd {
-        background-color:#FFF;
-    }
-
-    .install_table tr:hover{
-        background-color:#DDD;
     }
 
-    #btn-alls-on {
-        background:transparent url({$sMasterSwPic}) no-repeat scroll -0px -0px;
-        width:25px;
-        height:21px;
-    }
-    #btn-alls-off {
-        background:transparent url({$sMasterSwPic}) no-repeat scroll -0px -20px;
-        width:25px;
-        height:21px;
-    }
-    #btn-troubled-on {
-        background:transparent url({$sMasterSwPic}) no-repeat scroll -24px -20px;
-        width:25px;
-        height:21px;
-    }
-
-    #btn-troubled-off {
-        background:transparent url({$sMasterSwPic}) no-repeat scroll -24px -0px;
-        width:25px;
-        height:21px;
-    }
-
-    tr.head td.left_aligned {
-        text-align:left;
-        font-weight:bold;
-    }
 </style>
 EOF;
         return $sRet;
     }
 
-    /**
-     * Generate permissions table for modules
-     * @param $iType - 1: folder, 2: file
-     * @return HTML 
-     */ 
-    function GenPermTableForModules($iType) 
+    public function checkPermissions($isShowModules = false, $bEcho = true, &$aOutputMessages = null)
     {
-        $aList = array ();
-        bx_import('BxDolModuleDb');
-        $oDbModules = new BxDolModuleDb();
-        $aModules = $oDbModules->getModules();
-        foreach ($aModules as $a) {
-            if (empty($a['path']) || !include(BX_DIRECTORY_PATH_MODULES . $a['path'] . 'install/config.php'))
-                continue;
-            if (empty($aConfig['install_permissions']) || !is_array($aConfig['install_permissions']['writable']))
-                continue;
-            foreach ($aConfig['install_permissions']['writable'] as $sPath) {
-                if (1 == $iType && is_dir(BX_DIRECTORY_PATH_MODULES . $a['path'] . $sPath))
-                    $aList[] = basename(BX_DIRECTORY_PATH_MODULES) . '/' . $a['path'] . $sPath;
-                elseif (2 == $iType && is_file(BX_DIRECTORY_PATH_MODULES . $a['path'] . $sPath))
-                    $aList[] = basename(BX_DIRECTORY_PATH_MODULES) . '/' . $a['path'] . $sPath;
-            }
-        }
-        return $this->GenArrElemPerm($aList, $iType);
-    }
+        $bRet = true;
+        $aMessages = array ();
+        foreach ($this->aInstallPermissions as $s) {
+            $sType = $this->_getFileType($s);
 
-    function GenPermTable($isShowModules = false)
-    {
-        $sModulesDirsC = function_exists('_t') ? _t('_adm_admtools_modules_dirs') : 'Modules Directories';
-        $sModulesFilesC = function_exists('_t') ? _t('_adm_admtools_modules_files') : 'Modules Files';
-        $sDirsC = function_exists('_t') ? _t('_adm_admtools_Directories') : 'Directories';
-        $sFilesC = function_exists('_t') ? _t('_adm_admtools_Files') : 'Files';
-        $sElementsC = function_exists('_t') ? _t('_adm_admtools_Elements') : 'Elements';
-        $sCurrentLevelC = function_exists('_t') ? _t('_adm_admtools_Current_level') : 'Current level';
-        $sDesiredLevelC = function_exists('_t') ? _t('_adm_admtools_Desired_level') : 'Desired level';
-        $sBadFilesC = function_exists('_t') ? _t('_adm_admtools_Bad_files') : 'The following files and directories have inappropriate permissions';
-        $sShowOnlyBadC = function_exists('_t') ? _t('_adm_admtools_Only_bad_files') : 'Show only files and directories with inappropriate permissions';
-        $sDescriptionC = function_exists('_t') ? _t('_adm_admtools_Perm_description') : 'Dolphin needs special access for certain files and directories. Please, change permissions as specified in the chart below. Helpful info about permissions is <a href="http://www.boonex.com/trac/dolphin/wiki/DetailedInstall#Permissions" target="_blank">available here</a>.';
-
-        $this->sTroubledElements = '';
-
-        $sInstallDirs = $this->GenArrElemPerm($this->aInstallDirs, 1);
-        $sInstallFiles = $this->GenArrElemPerm($this->aInstallFiles, 2);
-        if ($isShowModules) {
-            $sModulesDirs = $this->GenPermTableForModules(1);
-            $sModulesFiles = $this->GenPermTableForModules(2);
-            if ($sModulesDirs)
-                $sModulesDirs = "
-                    <tr class='head'>
-                        <td>{$sModulesDirsC}</td>
-                        <td>{$sCurrentLevelC}</td>
-                        <td>{$sDesiredLevelC}</td>
-                    </tr>" . $sModulesDirs;
-            if ($sModulesFiles)
-                $sModulesFiles = "
-                    <tr class='head'>
-                        <td>{$sModulesFilesC}</td>
-                        <td>{$sCurrentLevelC}</td>
-                        <td>{$sDesiredLevelC}</td>
-                    </tr>" . $sModulesFiles;
-        }
-        $sAdditionDir = (isAdmin()==true) ? BX_DOL_URL_ROOT : '../';
-        $sLeftAddEl = (isAdmin()==true) ? '<div class="left_side_sw_caption">'.$sDescriptionC.'</div>' : '';
+            $isOk = BX_DOL_PERM_EXE == $sType ? $this->isExecutable($s) : $this->isWritable($s);
 
-        $sSpacerPic = $sAdditionDir . 'media/images/spacer.gif';
-
-        $sRet = <<<EOF
-<script type="text/javascript">
-    <!--
-    function callSwitcher()
-    {
-        $('table.install_table tr:not(.troubled)').toggle();
-    }
-
-    function switchToTroubled(e)
-    {
-        if (!e.checked) {
-            $("#btn-alls-off").attr("id", "btn-alls-on");
-            $("#btn-troubled-on").attr("id", "btn-troubled-off");
-            $('table.install_table tr:not(.troubled)').show();
-        } else  {
-            $("#btn-alls-on").attr("id", "btn-alls-off");
-            $("#btn-troubled-off").attr("id", "btn-troubled-on");
-            $('table.install_table tr:not(.troubled)').hide();
+            $aMessages[$s] = array ('res' => $isOk ? BX_DOL_PERM_OK : BX_DOL_PERM_FAIL, 'type' => $sType);
+            if (!$isOk && $bRet)
+                $bRet = false;
         }
-        return false;
-    }
-    -->
-</script>
-
-<table width="100%" cellspacing="1" cellpadding="0" class="install_table">
-    <tr class="head troubled">
-        <td colspan="3" style="text-align:center;">
-        {$sLeftAddEl}
-        <div class="right_side_sw_caption">
-            <input type="checkbox" id="bx-install-permissions-show-erros-only" onclick="switchToTroubled(this)" /> <label for="bx-install-permissions-show-erros-only">$sShowOnlyBadC</label>
-        </div>
-        <div class="clear_both"></div>
-        </td>
-    </tr>
-    <tr class="head">
-        <td colspan="3" style="text-align:center;" class="normal_td">{$sDirsC}</td>
-    </tr>
-    <tr class="head">
-        <td>{$sDirsC}</td>
-        <td>{$sCurrentLevelC}</td>
-        <td>{$sDesiredLevelC}</td>
-    </tr>
-    {$sInstallDirs}
-    {$sModulesDirs}
-    <tr class="head">
-        <td colspan="3" style="text-align:center;">{$sFilesC}</td>
-    </tr>
-    <tr class="head">
-        <td>{$sFilesC}</td>
-        <td>{$sCurrentLevelC}</td>
-        <td>{$sDesiredLevelC}</td>
-    </tr>
-    {$sInstallFiles}
-    {$sModulesFiles}
-    <tr class="head troubled">
-        <td colspan="3" style="text-align:center;">{$sBadFilesC}</td>
-    </tr>
-    <tr class="head troubled">
-        <td>{$sElementsC}</td>
-        <td>{$sCurrentLevelC}</td>
-        <td>{$sDesiredLevelC}</td>
-    </tr>
-    {$this->sTroubledElements}
-</table>
-EOF;
-        return $sRet;
-    }
-
-    //$iType: 1 - folder, 2 - file
-    function GenArrElemPerm($aElements, $iType)
-    { 
-        if (!is_array($aElements) || empty($aElements))
-            return '';
-        $sWritableC = function_exists('_t') ? _t('_adm_admtools_Writable') : 'Writable';
-        $sNonWritableC = function_exists('_t') ? _t('_adm_admtools_Non_Writable') : 'Non-Writable';
-        $sNotExistsC = function_exists('_t') ? _t('_adm_admtools_Not_Exists') : 'Not Exists';
-        $sExecutableC = function_exists('_t') ? _t('_adm_admtools_Executable') : 'Executable';
-        $sNonExecutableC = function_exists('_t') ? _t('_adm_admtools_Non_Executable') : 'Non-Executable';
 
-        $iType = ($iType==1) ? 1 : 2;
-
-        $sElements = '';
-        $i = 0;
-        foreach ($aElements as $sCurElement) {
-            $iCurType = $iType;
-
-            $sAwaitedPerm = ($iCurType==1) ? $sWritableC : $sWritableC;
-
-            $sElemCntStyle = ($i%2==0) ? 'even' : 'odd' ;
-            $bAccessible = ($iCurType==1) ? $this->isWritable($sCurElement) : $this->isWritable($sCurElement);
-
-            if ($sCurElement == 'flash/modules/global/app/ffmpeg.exe') {
-                $sAwaitedPerm = $sExecutableC;
-                $bAccessible = $this->isExecutable($sCurElement);
-            }
-
-            if ($bAccessible) {
-                $sResultPerm = ($iCurType==1) ? $sWritableC : $sWritableC;
-
-                if ($sCurElement == 'flash/modules/global/app/ffmpeg.exe') {
-                    $sResultPerm = $sExecutableC;
-                }
-
-                $sElements .= <<<EOF
-<tr class="cont {$sElemCntStyle}">
-    <td>{$sCurElement}</td>
-    <td class="span">
-        <span class="writable">{$sResultPerm}</span>
-    </td>
-    <td class="span">
-        <span class="desired">{$sAwaitedPerm}</span>
-    </td>
-</tr>
-EOF;
-            } else {
-                $sPerm = $this->getPermissions($sCurElement);
-                $sResultPerm = '';
-                if ($sPerm==false) {
-                    $sResultPerm = $sNotExistsC;
-                } else {
-                    $sResultPerm = ($iCurType==1) ? $sNonWritableC : $sNonWritableC;
-                }
-
-                if ($sCurElement == 'flash/modules/global/app/ffmpeg.exe') {
-                    $sResultPerm = $sNonExecutableC;
-                }
-
-                $sPerm = '';
-
-                $sElements .= <<<EOF
-<tr class="cont {$sElemCntStyle}">
-    <td>{$sCurElement}</td>
-    <td class="span">
-        <span class="unwritable">{$sPerm} {$sResultPerm}</span>
-    </td>
-    <td class="span">
-        <span class="desired">{$sAwaitedPerm}</span>
-    </td>
-</tr>
-EOF;
+        if ($isShowModules && !$this->_checkPermissionsModules($aMessages) && $bRet)
+            $bRet = false;
 
-                $this->sTroubledElements .= <<<EOF
-<tr class="cont {$sElemCntStyle} troubled">
-    <td>{$sCurElement}</td>
-    <td class="span">
-        <span class="unwritable">{$sPerm} {$sResultPerm}</span>
-    </td>
-    <td class="span">
-        <span class="desired">{$sAwaitedPerm}</span>
-    </td>
-</tr>
-EOF;
+        if (null !== $aOutputMessages)
+            $aOutputMessages = $aMessages;
 
-            }
-            $i++;
+        if ($bEcho) {
+            $sHtml = '';
+            foreach ($aMessages as $s => $r)
+                $sHtml .= $this->_getHtmlPermissionRow($s, $r);
+            echo $this->_getHtmlPermissionTable($sHtml);
         }
-        return $sElements;
-    }
+        
 
-    //check requirements
-    function performInstalCheck()
-    {
-        $aErrors = array();
-
-        $aErrors[] = (ini_get('register_globals') == 0) ? '' : '<font color="red">register_globals is On (warning, you should have this param in Off state, or your site will unsafe)</font>';
-        $aErrors[] = (ini_get('safe_mode') == 0) ? '' : '<font color="red">safe_mode is On, disable it</font>';
-        $aErrors[] = (((int)phpversion()) < 4) ? '<font color="red">PHP version too old, update server please</font>' : '';
-        $aErrors[] = (!extension_loaded( 'mbstring')) ? '<font color="red">mbstring extension not installed. <b>Warning!</b> Dolphin cannot work without <b>mbstring</b> extension.</font>' : '';
-        $aErrors[] = (ini_get('short_open_tag') == 0 && version_compare(phpversion(), "5.4", "<") == 1) ? '<font color="red">short_open_tag is Off (must be On!)<b>Warning!</b> Dolphin cannot work without <b>short_open_tag</b>.</font>' : '';
-
-        if (version_compare(phpversion(), "5.2", ">") == 1) {
-            $aErrors[] = (ini_get('allow_url_include') == 0) ? '' : '<font color="red">allow_url_include is On (warning, you should have this param in Off state, or your site will unsafe)</font>';
-        };
-
-        $aErrors = array_diff($aErrors, array('')); //delete empty
-        if (count($aErrors)) {
-            $sErrors = implode(" <br /> ", $aErrors);
-            echo <<<EOF
-{$sErrors} <br />
-Please go to the <br />
-<a href="http://www.boonex.com/trac/dolphin/wiki/GenDolTShooter">Dolphin Troubleshooter</a> <br />
-and solve the problem.
-EOF;
-            exit;
-        }
+        return $bRet;
     }
 
     function GenCacheEnginesTable()
@@ -474,56 +188,96 @@ EOF;
         return DesignBoxAdmin($sTitleC, $sBoxContent, $aTopItems, '', 11);
     }
 
-    //************
-    function isFolderReadWrite($filename)
+    function GenAuditPage()
     {
-        clearstatcache();
-
-        $aPathInfo = pathinfo(__FILE__);
-        $filename = $aPathInfo['dirname'] . '/../../' . $filename;
+        if (!class_exists('BxDolStudioToolsAudit'))
+            bx_import('BxDolStudioToolsAudit');
 
-        return (@file_exists($filename . '/.') && is_readable( $filename ) && is_writable( $filename ) ) ? true : false;
+        $oAudit = new BxDolStudioToolsAudit();
+        return $oAudit->generate();
     }
 
-    function isFileReadWrite($filename)
+    protected function _getHtmlPermissionRow($s, $r) 
     {
-        clearstatcache();
-
-        $aPathInfo = pathinfo(__FILE__);
-        $filename = $aPathInfo['dirname'] . '/../../' . $filename;
-
-        return (is_file($filename) && is_readable( $filename ) && is_writable( $filename ) ) ? true : false;
+        $sAwaitedPerm = BX_DOL_PERM_EXE == $r['type'] ? _t('_adm_admtools_Executable') : _t('_adm_admtools_Writable');
+        $sResultPerm = $sAwaitedPerm;
+        $sPerm = $this->getPermissions($s);
+        $sClass = 'bx-permissions-ok';
+        if (BX_DOL_PERM_FAIL == $r['res']) {
+            $sClass = 'bx-permissions-wrong';
+            if (false === $sPerm)
+                $sResultPerm = _t('_adm_admtools_Not_Exists');
+            else
+                $sResultPerm = BX_DOL_PERM_EXE == $r['type'] ? _t('_adm_admtools_Non_Executable') : _t('_adm_admtools_Non_Writable');
+        }     
+        
+        return <<<EOF
+<tr class="bx-def-color-bg-hl-even">
+    <td class="bx-def-padding-thd">{$s}</td>
+    <td class="bx-def-padding-thd {$sClass}">{$sResultPerm}</td>
+    <td class="bx-def-padding-thd">{$sAwaitedPerm}</td>
+</tr>
+EOF;
     }
 
-    function isFileExecutable($filename)
+    protected function _getHtmlPermissionTable($sRows) 
     {
-        clearstatcache();
-
-        $aPathInfo = pathinfo(__FILE__);
-        $filename = $aPathInfo['dirname'] . '/../../' . $filename;
-
-        return (is_file($filename) && is_executable( $filename ) ) ? true : false;
+        $sDirsC = _t('_adm_admtools_Path');
+        $sCurrentLevelC = _t('_adm_admtools_Current_level');
+        $sDesiredLevelC = _t('_adm_admtools_Desired_level');
+
+        return <<<EOF
+<table width="100%" class="bx-permissions-table">
+<thead class="bx-def-border-bottom bx-def-border-top">
+    <tr>
+        <td class="bx-def-padding-thd bx-def-font-h3">{$sDirsC}</td>
+        <td class="bx-def-padding-thd bx-def-font-h3">{$sCurrentLevelC}</td>
+        <td class="bx-def-padding-thd bx-def-font-h3">{$sDesiredLevelC}</td>
+    </tr>
+</thead>
+<tbody>
+    {$sRows}
+</tbody>
+</table>
+EOF;
     }
 
-    //************
-
-    function isAllowUrlInclude()
+    protected function _getFileType($s) 
     {
-        if (version_compare(phpversion(), "5.2", ">") == 1) {
-            $sAllowUrlInclude = ini_get('allow_url_include');
-            return !($sAllowUrlInclude == 0);
-        };
-        return false;
+        $sType = BX_DOL_PERM_FILE;
+        if (is_dir($this->sRootPath . $s))
+            $sType = BX_DOL_PERM_DIR;
+        elseif (substr($s, -4) === '.exe')
+            $sType = BX_DOL_PERM_EXE;
+        return $sType;
     }
 
-    function GenAuditPage()
+    protected function _checkPermissionsModules(&$aMessages) 
     {
-        if (!class_exists('BxDolStudioToolsAudit'))
-            bx_import('BxDolStudioToolsAudit');
+        $bRet = true;
+        bx_import('BxDolModuleDb');
+        $oDbModules = new BxDolModuleDb();
+        $aModules = $oDbModules->getModules();
+        foreach ($aModules as $a) {
+            if (empty($a['path']) || !include(BX_DIRECTORY_PATH_MODULES . $a['path'] . 'install/config.php'))
+                continue;
+            if (empty($aConfig['install_permissions']) || !is_array($aConfig['install_permissions']['writable']))
+                continue;
+            foreach ($aConfig['install_permissions']['writable'] as $sPath) {
+                $s = basename(BX_DIRECTORY_PATH_MODULES) . '/' . $a['path'] . $sPath;
 
-        $oAudit = new BxDolStudioToolsAudit();
-        return $oAudit->generate();
-    }
+                $sType = $this->_getFileType($s);
+
+                $isOk = BX_DOL_PERM_EXE ? $this->isExecutable($s) : $this->isWritable($s);
 
+                $aMessages[$s] = array ('res' => $isOk ? BX_DOL_PERM_OK : BX_DOL_PERM_FAIL, 'type' => $sType);
+
+                if (!$isOk && $bRet)
+                    $bRet = false;
+            }
+        }
+
+        return $bRet;
+    }
 }
 /** @} */

+ 180 - 182
studio/classes/BxDolStudioToolsAudit.php

@@ -41,10 +41,10 @@ class BxDolStudioToolsAudit extends BxDol
         );
 
         $this->aType2Title = array (
-            BX_DOL_AUDIT_FAIL => 'FAIL',
-            BX_DOL_AUDIT_WARN => 'WARNING',
-            BX_DOL_AUDIT_UNDEF => 'UNDEFINED',
-            BX_DOL_AUDIT_OK => 'OK',
+            BX_DOL_AUDIT_FAIL => _t('_sys_audit_title_fail'),
+            BX_DOL_AUDIT_WARN => _t('_sys_audit_title_warn'),
+            BX_DOL_AUDIT_UNDEF => _t('_sys_audit_title_undef'),
+            BX_DOL_AUDIT_OK => _t('_sys_audit_title_ok'),
         );
 
         $this->sLatestPhp53Version = '5.3.28';
@@ -68,6 +68,7 @@ class BxDolStudioToolsAudit extends BxDol
             'php module: openssl' => array('op' => 'module', 'val' => 'openssl', 'warn' => 1),
             'php module: zip' => array('op' => 'module', 'val' => 'zip', 'warn' => 1),
             'php module: ftp' => array('op' => 'module', 'val' => 'ftp', 'warn' => 1),
+            'php module: oauth' => array('op' => 'module', 'val' => 'oauth', 'warn' => 1),
         );
 
         $this->sMinMysqlVer = '4.1.2';
@@ -94,6 +95,30 @@ class BxDolStudioToolsAudit extends BxDol
         $this->aRequiredApacheModules = array (
             'rewrite_module' => 'mod_rewrite',
         );
+
+        if (isset($_GET['action'])) {
+            $sOutput = null;
+            switch ($_GET['action']) {
+                case 'audit_send_test_email':
+                    $sOutput = $this->sendTestEmail();
+                    break;
+                case 'phpinfo':
+                    ob_start();
+                    phpinfo();
+                    $sOutput = ob_get_clean();
+                    break;
+                case 'phpinfo_popup':
+                    $sUrlSelf = bx_js_string($_SERVER['PHP_SELF'], BX_ESCAPE_STR_APOS);
+                    $sUrlSelf = bx_append_url_params($sUrlSelf, array('action' => 'phpinfo'));
+                    $sOutput = '<iframe width="640" height="480" src="' . $sUrlSelf . '"></iframe>';
+                    break;
+            }
+            if ($sOutput) {
+                header('Content-type: text/html; charset=utf-8');
+                echo $sOutput;
+                exit;
+            }
+        }
     }
 
     public function generate()
@@ -103,7 +128,8 @@ class BxDolStudioToolsAudit extends BxDol
         $this->setErrorReporting();
 
         $this->generateStyles();
-        
+        $this->generateJs();
+
         $this->requirements();
 
         if (defined('BX_DOL_VERSION'))
@@ -138,6 +164,31 @@ class BxDolStudioToolsAudit extends BxDol
         <?php
     }
 
+    public function generateJs() 
+    {
+        $sUrlSelf = bx_js_string($_SERVER['PHP_SELF'], BX_ESCAPE_STR_APOS);
+        ?>
+        <script language="javascript">
+            function bx_sys_adm_audit_test_email()
+            {
+                var sEmail = prompt('<?php echo _t('_Email'); ?>', '<?php echo function_exists('getParam') ? getParam('site_email') : ''; ?>');
+                if (null == sEmail || ('string' == (typeof sEmail) && !sEmail.length))
+                    return;
+
+                $('#bx-sys-adm-audit-test-email').html('Sending...');
+                $.post('<?php echo bx_append_url_params($sUrlSelf, array('action' => 'audit_send_test_email')); ?>&email=' + sEmail, function(data) {
+                    $('#bx-sys-adm-audit-test-email').html(data);
+                });
+            }
+
+            function bx_sys_adm_audit_phpinfo()
+            {
+                $(window).dolPopupAjax({url: '<?php echo bx_append_url_params($sUrlSelf, array('action' => 'phpinfo_popup')); ?>'});
+            }
+        </script>
+        <?php
+    }
+
     public function checkRequirements($sType = BX_DOL_AUDIT_FAIL)
     {
         $this->setErrorReporting();
@@ -156,7 +207,7 @@ class BxDolStudioToolsAudit extends BxDol
 
     protected function requirements()
     {
-        echo '<h1>Requirements</h1>';
+        echo '<h1>' . _t('_sys_audit_header_requirements') . '</h1>';
         $this->requirementsPHP();
         if (class_exists('BxDolDb'))
             $this->requirementsMySQL();
@@ -177,38 +228,36 @@ class BxDolStudioToolsAudit extends BxDol
 
         $sPhpVer = PHP_VERSION;        
         if (empty($sLatestPhpVersion))
-            $aMessages['version'] = array('type' => BX_DOL_AUDIT_UNDEF, 'msg' => 'value checking failed', 'params' => array ('real_val' => $sPhpVer));
+            $aVer = array('type' => BX_DOL_AUDIT_UNDEF, 'msg' => _t('_sys_audit_msg_value_checking_failed'), 'params' => array ('real_val' => $sPhpVer));
         elseif (version_compare($sPhpVer, $this->sMinPhpVer, '<'))
-            $aMessages['version'] = array('type' => BX_DOL_AUDIT_FAIL, 'msg' => 'your version is incompatible with Dolphin, must be at least ' . $this->sMinPhpVer, 'params' => array ('real_val' => $sPhpVer));
+            $aVer = array('type' => BX_DOL_AUDIT_FAIL, 'msg' => _t('_sys_audit_msg_version_is_incompatible', $this->sMinPhpVer), 'params' => array ('real_val' => $sPhpVer));
         elseif (version_compare($sPhpVer, '5.4.0', '>=') && version_compare($sPhpVer, '6.0.0', '<') && !version_compare($sPhpVer, $sLatestPhpVersion, '>='))
-            $aMessages['version'] = array('type' => BX_DOL_AUDIT_WARN, 'msg' => 'your PHP version is probably outdated, upgrade to the latest ' . $sLatestPhpVersion . ' maybe required', 'params' => array ('real_val' => $sPhpVer));
+            $aVer = array('type' => BX_DOL_AUDIT_WARN, 'msg' => _t('_sys_audit_msg_version_is_outdated', $sLatestPhpVersion), 'params' => array ('real_val' => $sPhpVer));
         elseif (version_compare($sPhpVer, '5.2.0', '>=') && version_compare($sPhpVer, '5.4.0', '<') && !version_compare($sPhpVer, $this->sLatestPhp53Version, '>='))
-            $aMessages['version'] = array('type' => BX_DOL_AUDIT_WARN, 'msg' => 'your PHP version is probably outdated, upgrade to the latest ' . $this->sLatestPhp53Version . ' maybe required', 'params' => array ('real_val' => $sPhpVer));
+            $aVer = array('type' => BX_DOL_AUDIT_WARN, 'msg' => _t('_sys_audit_msg_version_is_outdated', $this->sLatestPhp53Version), 'params' => array ('real_val' => $sPhpVer));
         else
-            $aMessages['version'] = array('type' => BX_DOL_AUDIT_OK, 'params' => array ('real_val' => $sPhpVer));
+            $aVer = array('type' => BX_DOL_AUDIT_OK, 'params' => array ('real_val' => $sPhpVer));
+        $aMessages[_t('_sys_audit_version')] = $aVer;
 
         foreach ($this->aPhpSettings as $sName => $r) {
             $a = $this->checkPhpSetting($sName, $r);
             if ($a['res'])
                 $aMessages[$sName] = array('type' => BX_DOL_AUDIT_OK, 'params' => $a);
             elseif (isset($r['warn']) && $r['warn'])
-                $aMessages[$sName] = array('type' => BX_DOL_AUDIT_WARN, 'msg' => "should be {$r['op']} " . $this->format_output($r['val'], $r), 'params' => $a);
+                $aMessages[$sName] = array('type' => BX_DOL_AUDIT_WARN, 'msg' => _t('_sys_audit_msg_should_be', $r['op'], $this->format_output($r['val'], $r)), 'params' => $a);
             else
-                $aMessages[$sName] = array('type' => BX_DOL_AUDIT_FAIL, 'msg' => "must be {$r['op']} " . $this->format_output($r['val'], $r), 'params' => $a);
+                $aMessages[$sName] = array('type' => BX_DOL_AUDIT_FAIL, 'msg' => _t('_sys_audit_msg_must_be', $r['op'], $this->format_output($r['val'], $r)), 'params' => $a);
         }
 
         if (null !== $aOutputMessages)
             $aOutputMessages = $aMessages;
 
         if ($bEcho) {
-            echo '<b>PHP</b>: ';
-            echo '<ul>';
+            $s = '';
             foreach ($aMessages as $sName => $r) {
-                echo "<li>$sName = " . $this->format_output($r['params']['real_val'], isset($this->aPhpSettings[$sName]) ? $this->aPhpSettings[$sName] : '') . " - ";
-                echo $this->getMsgHTML($sName, $r);
-                echo "</li>\n";
+                $s .= $this->getBlock($sName, $this->format_output($r['params']['real_val'], isset($this->aPhpSettings[$sName]) ? $this->aPhpSettings[$sName] : ''), $this->getMsgHTML($sName, $r));
             }
-            echo '</ul>';
+            echo $this->getSection('PHP', '', $s);
         }
     }
 
@@ -218,42 +267,41 @@ class BxDolStudioToolsAudit extends BxDol
         if (preg_match ('/^(\d+)\.(\d+)\.(\d+)/', $sMysqlVer, $m)) {
             $sMysqlVer = "{$m[1]}.{$m[2]}.{$m[3]}";
             if (version_compare($sMysqlVer, $this->sMinMysqlVer, '<'))
-                $aMessage = array('type' => BX_DOL_AUDIT_FAIL, 'msg' => 'your version is incompatible with Dolphin, must be at least ' . $this->sMinMysqlVer);
+                $aMessage = array('type' => BX_DOL_AUDIT_FAIL, 'msg' => _t('_sys_audit_msg_version_is_incompatible', $this->sMinMysqlVer));
             else
                 $aMessage = array('type' => BX_DOL_AUDIT_OK);
         } else {
-            $aMessage = array('type' => BX_DOL_AUDIT_UNDEF, 'msg' => 'value checking failed');
+            $aMessage = array('type' => BX_DOL_AUDIT_UNDEF, 'msg' => _t('_sys_audit_msg_value_checking_failed'));
         }
 
-        echo '<b>MySQL</b>: ' . $sMysqlVer . ' - ';
-        echo $this->getMsgHTML('version', $aMessage);
+        $s = $this->getBlock(_t('_sys_audit_version'), $sMysqlVer, $this->getMsgHTML(_t('_sys_audit_version'), $aMessage));
+        echo $this->getSection('MySQL', '', $s);
     }
 
     protected function requirementsWebServer()
     {
-        echo '<b>Web-server</b>: ';
-        echo $_SERVER['SERVER_SOFTWARE'];
-        echo '<ul>';
+        $s = '';
         foreach ($this->aRequiredApacheModules as $sName => $sNameCompiledName)
-            echo '<li>' . $sName . ' - ' . $this->checkApacheModule($sName, $sNameCompiledName) . '</li>';
-        echo '</ul>';
+            $s .= $this->getBlock($sName, '', $this->checkApacheModule($sName, $sNameCompiledName));
+
+        echo $this->getSection(_t('_sys_audit_section_webserver'), $_SERVER['SERVER_SOFTWARE'], $s);
     }
 
     protected function requirementsOS() 
     {
-        echo '<b>OS</b>: <ul><li>' . php_uname() . '</li></ul>';
+        $s = $this->getBlock(php_uname());
+        echo $this->getSection(_t('_sys_audit_section_os'), '', $s);
     }
 
     protected function requirementsHardware()
     {
-        ?>
-        <b>Hardware</b>: <ul><li>Hardware requirements can not be determined automatically - <a href="#manual_audit">manual server audit</a> may be required.</li></ul>
-        <?php
+        $s = $this->getBlock(_t('_sys_audit_msg_hardware_requirements'));
+        echo $this->getSection(_t('_sys_audit_section_hardware'), '', $s);
     }
 
     protected function siteSetup()
     {
-        $sDolphinPath = defined('BX_DIRECTORY_PATH_ROOT') ? BX_DIRECTORY_PATH_ROOT : './../';
+        $sDolphinPath = defined('BX_DIRECTORY_PATH_ROOT') ? BX_DIRECTORY_PATH_ROOT : BX_INSTALL_DIR_ROOT;
 
         $sEmailToCkeckMailSending = function_exists('getParam') ? getParam('site_email') : '';
 
@@ -262,56 +310,26 @@ class BxDolStudioToolsAudit extends BxDol
             $sLatestDolphinVer = $m[1];
         else
             $sLatestDolphinVer = 'undefined';
+       
+        $sDolphinVer = BX_DOL_VERSION . '.' . BX_DOL_BUILD;
+        $aMessage = array('type' => BX_DOL_AUDIT_OK);
+        if (!version_compare($sDolphinVer, $sLatestDolphinVer, '>='))
+            $aMessage = array('type' => BX_DOL_AUDIT_WARN, 'msg' => _t('_sys_audit_msg_version_is_outdated', $sLatestDolphinVer));
 
-        ?>
-<h1>Site setup</h1>
-<ul>
-    <li>
-        <b>Dolphin version</b> = 
-        <?php
-            $sDolphinVer = BX_DOL_VERSION . '.' . BX_DOL_BUILD;
-            echo $sDolphinVer . ' - ';
-            if (!version_compare($sDolphinVer, $sLatestDolphinVer, '>='))
-                echo '<b class="warn">WARNING</b> (your Dolphin version is outdated please upgrade to the latest ' . $sLatestDolphinVer . ' version)';
-            else
-                echo '<b class="ok">OK</b>';
-        ?>
-    </li>
-    <li>
-        <b>files and folders permissions</b>
-        <br />
-        Please <a href="javascript:void(0);" onclick="switchAdmPage($('#main_menu1'));">click here</a> to find out if dolphin permissions are correct.
-    </li>
-    <li>
-        <b>ffmpeg</b>
-        <pre class="code"><?php echo `{$sDolphinPath}flash/modules/global/app/ffmpeg.exe 2>&1`;?></pre>
-        if you don't know if output is correct then <a href="#manual_audit">manual server audit</a> may be required.
-    </li>
-    <li>
-        <script language="javascript">
-            function bx_sys_adm_audit_test_email()
-            {
-                $('#bx-sys-adm-audit-test-email').html('Sending...');
-                $.post('<?php echo BX_DOL_URL_STUDIO; ?>host_tools.php?action=audit_send_test_email', function(data) {
-                    $('#bx-sys-adm-audit-test-email').html(data);
-                });
-            }
-        </script>
-        <b>mail sending - </b>
-        <span id="bx-sys-adm-audit-test-email"><a href="javascript:void(0);" onclick="bx_sys_adm_audit_test_email()">click here</a> to send test email to <?php echo $sEmailToCkeckMailSending; ?></span>
-    </li>
-    <li>
-        <b>cronjobs</b>
-        <pre class="code"><?php echo `crontab -l 2>&1`;?></pre>
-        if you are unsure if output is correct then <a href="#manual_audit">manual server audit</a> may be required.
-    </li>
-</ul>
-        <?php
+        $s = '';
+        $s .= $this->getBlock(_t('_sys_audit_version_dolphin'), $sDolphinVer, $this->getMsgHTML(_t('_sys_audit_version_dolphin'), $aMessage));
+        $s .= $this->getBlock(_t('_sys_audit_permissions'), '', _t('_sys_audit_msg_permissions'));
+        $s .= $this->getBlock('ffmpeg', '', _t('_sys_audit_msg_ffmpeg', `{$sDolphinPath}flash/modules/global/app/ffmpeg.exe 2>&1`));
+        $s .= $this->getBlock(_t('_sys_audit_mail_sending'), '', _t('_sys_audit_msg_mail_sending'));
+        $s .= $this->getBlock(_t('_sys_audit_cron_jobs'), '', _t('_sys_audit_msg_cron_jobs', `crontab -l 2>&1`));
+
+        echo '<h1>' . _t('_sys_audit_header_site_setup') . '</h1>';
+        echo "<ul>$s</ul>";
     }
 
     protected function optimization()
     {
-        echo '<h1>Site optimization</h1>';
+        echo '<h1>' . _t('_sys_audit_header_site_optimization') . '</h1>';
 
         $this->optimizationPhp();
 
@@ -326,130 +344,84 @@ class BxDolStudioToolsAudit extends BxDol
 
     protected function optimizationPhp()
     {
-        ?>
-        <b>PHP</b>:
-        <ul>
-            <li>
-                <?php echo $this->optimizationPhpAccelerator(); ?>
-            </li>
-            <li>
-                <?php echo $this->optimizationPhpSetup(); ?>
-            </li>
-        </ul>
-        <?php
-    }
+        $s = '';
+        $aMessage = array();
 
-    protected function optimizationPhpAccelerator()
-    {            
-        echo "<b>PHP accelerator</b> = ";
         $sAccel = $this->getPhpAccelerator();
         if (!$sAccel)
-            echo 'NO - <b class="warn">WARNING</b> (Dolphin can be much faster if you install some PHP accelerator))';
+            $aMessage = array('type' => BX_DOL_AUDIT_WARN, 'msg' => _t('_sys_audit_msg_php_accelerator_missing'));
         else
-            echo $sAccel . ' - <b class="ok">OK</b>';
-    }
+            $aMessage = array('type' => BX_DOL_AUDIT_OK);
+        $s .= $this->getBlock(_t('_sys_audit_php_accelerator'), $sAccel, $this->getMsgHTML(_t('_sys_audit_php_accelerator'), $aMessage));
 
-    protected function optimizationPhpSetup()
-    {
-        echo "<b>PHP setup</b> = ";
         $sSapi = php_sapi_name();
-        echo $sSapi . ' - ';
         if (0 == strcasecmp('cgi', $sSapi))
-            echo '<b class="warn">WARNING</b> (your PHP setup maybe very inefficient, <a href="?action=phpinfo">please check it for sure</a> and try to switch to mod_php, apache dso module or FastCGI)';
+            $aMessage = array('type' => BX_DOL_AUDIT_WARN, 'msg' => _t('_sys_audit_msg_php_setup_inefficient'));
         else
-            echo '<b class="ok">OK</b>';
+            $aMessage = array('type' => BX_DOL_AUDIT_OK);
+        $s .= $this->getBlock(_t('_sys_audit_php_setup'), $sSapi, $this->getMsgHTML(_t('_sys_audit_php_setup'), $aMessage));
+
+        echo $this->getSection('PHP', '', $s);
     }
 
     protected function optimizationMySQL()
     {
+        $s = '';
         $oDb = BxDolDb::getInstance();
 
-        ?>
-        <b>MySQL</b>:
-        <ul>
-            <?php
-                foreach ($this->aMysqlOptimizationSettings as $sName => $r) {
-                    $a = $this->checkMysqlSetting($sName, $r, $oDb);
-                    echo "<li><b>$sName</b> = " . $this->format_output($a['real_val'], $r) ." - " . ($a['res'] ? '<b class="ok">OK</b>' : "<b class='fail'>FAIL</b> (must be {$r['op']} " . $this->format_output($r['val'], $r) . ")") . "</li>\n";
-                }
-            ?>
-        </ul>
-        <?php
-    }
+        foreach ($this->aMysqlOptimizationSettings as $sName => $r) {
+            $a = $this->checkMysqlSetting($sName, $r, $oDb);
+            $aMessage = array('type' => BX_DOL_AUDIT_OK);
+            if (!$a['res'])
+                $aMessage = array('type' => BX_DOL_AUDIT_FAIL, 'msg' => _t('_sys_audit_msg_must_be', $r['op'], $this->format_output($r['val'], $r)));
+            $s .= $this->getBlock($sName, $this->format_output($a['real_val'], $r), $this->getMsgHTML($sName, $aMessage));
+        }
 
-    protected function optimizationWebServer()
-    {
-        ?>
-        <b>Web-server</b>:
-        <ul>
-            <li>
-                <b>User-side caching for static content</b> =
-                <a href="<?php echo $this->getUrlForGooglePageSpeed('LeverageBrowserCaching'); ?>">click here to check it in Google Page Speed</a>
-                <br />
-                If it is not enabled then please consider implement this optimization, since it improve perceived site speed and save the bandwidth, refer to <a target="_blank" href="http://www.boonex.com/trac/dolphin/wiki/HostingServerSetupRecommendations#Usersidecachingforstaticcontent">this tutorial</a> on how to do this.
-                <br />
-                <?php
-                    $sName = 'expires_module';
-                    echo 'To apply this optimization you need to have <b>' . $sName . '</b> Apache module - ' . $this->checkApacheModule($sName);
-                ?>
-            </li>
-            <li>
-                <b>Server-side content compression</b> = can be checked <a href="#manual_audit">manually</a> or in "Page Speed" tool build-in into browser.
-                <br />
-                If it is not enabled then please consider implement this optimization, since it improve perceived site speed and save the bandwidth, refer to <a href="http://www.boonex.com/trac/dolphin/wiki/HostingServerSetupRecommendations#Serversidecontentcompression">this tutorial</a> on how to do this.
-                </textarea>
-                <br />
-                <?php
-                    $sName = 'deflate_module';
-                    echo 'To apply this optimization you need to have <b>' . $sName . '</b> Apache module - ' . $this->checkApacheModule($sName);
-                ?>
-            </li>
-        </ul>
-        <?php
+        echo $this->getSection('MySQL', '', $s);
     }
 
-    protected function optimizationDolphin()
+    protected function optimizationWebServer()
     {
-        ?>
-        <b>Dolphin</b>:
-        <ul>
-            <?php
+        $s = '';
 
-                foreach ($this->aDolphinOptimizationSettings as $sName => $a) {
+        $sName = 'expires_module';
+        $sApacheModuleChack = _t('_sys_audit_msg_optimization_apache_module', $sName, $this->checkApacheModule($sName));
+        $s .= $this->getBlock(_t('_sys_audit_userside_caching'), '', _t('_sys_audit_msg_userside_caching', $this->getUrlForGooglePageSpeed('LeverageBrowserCaching'), $sApacheModuleChack));
 
-                    echo "<li><b>$sName</b> = ";
+        $sName = 'deflate_module';
+        $sApacheModuleChack = _t('_sys_audit_msg_optimization_apache_module', $sName, $this->checkApacheModule($sName));
+        $s .= $this->getBlock(_t('_sys_audit_serverside_compression'), '', _t('_sys_audit_msg_serverside_compression', $sApacheModuleChack));
 
-                    echo ('always_on' == $a['enabled'] || getParam($a['enabled'])) ? 'On' : 'Off';
+        echo $this->getSection(_t('_sys_audit_section_webserver'), '', $s);
+    }
 
-                    if ($a['cache_engine'])
-                        echo " (" . getParam($a['cache_engine']) . ' based cache engine)';
+    protected function optimizationDolphin()
+    {
+        $s = '';      
+        foreach ($this->aDolphinOptimizationSettings as $sName => $a) {
 
-                    echo ' - ';
+            $sVal = ('always_on' == $a['enabled'] || getParam($a['enabled'])) ? 'On' : 'Off';
+            if ($a['cache_engine'])
+                $sVal .= _t('_sys_audit_msg_dolphin_x_based_cache_engine', getParam($a['cache_engine']));
 
-                    if ('always_on' != $a['enabled'] && !getParam($a['enabled']))
-                        echo '<b class="fail">FAIL</b> (please enable this cache in Dolphin Admin Panel -> Settings -> Advanced Settings)';
-                    elseif ($a['check_accel'] && !$this->getPhpAccelerator() && 'File' == getParam($a['cache_engine']))
-                        echo '<b class="warn">WARNING</b> (installing PHP accelerator will speed-up file cache)';
-                    else
-                        echo '<b class="ok">OK</b>';
+            if ('always_on' != $a['enabled'] && !getParam($a['enabled']))
+                $aMessage = array('type' => BX_DOL_AUDIT_FAIL, 'msg' => _t('_sys_audit_msg_dolphin_optimization_fail'));
+            elseif ($a['check_accel'] && !$this->getPhpAccelerator() && 'File' == getParam($a['cache_engine']))
+                $aMessage = array('type' => BX_DOL_AUDIT_WARN, 'msg' => _t('_sys_audit_msg_dolphin_optimization_warn'));
+            else
+                $aMessage = array('type' => BX_DOL_AUDIT_OK);
 
-                    echo "</li>\n";
-                }
+            $s .= $this->getBlock($sName, $sVal, $this->getMsgHTML($sName, $aMessage));
+        }
 
-            ?>
-        </ul>
-        <?php
+        echo $this->getSection('Dolphin', '', $s);
     }
 
     protected function manualCheck()
     {
-        ?>
-<a name="manual_audit"></a>
-<h1>Manual Server Audit</h1>
-<p>
-    Some things can not be determined automatically, manual server audit is required to check it. If you don't know how to do it by yourself you can submit <a target="_blank" href="http://www.boonex.com/help/tickets">BoonEx Server Audit Request</a>.
-</p>
-        <?php
+        echo '<a name="manual_audit"></a>';
+        echo '<h1>' . _t('_sys_audit_header_manual_audit') . '</h1>';
+        echo _t('_sys_audit_msg_manual_audit');
     }
 
     protected function checkPhpSetting($sName, $a)
@@ -541,15 +513,20 @@ class BxDolStudioToolsAudit extends BxDol
                 $sApachectlPath = trim(`which /usr/local/apache/bin/apachectl`);
             if (!$sApachectlPath)
                 $sApachectlPath = trim(`which /usr/local/apache/bin/apache2ctl`);
-            if (!$sApachectlPath)
-                return '<b class="undef">UNDEFINED</b> (try to check manually: apachectl -M 2>&1 | grep ' . $sModule . ')';
-
+            if (!$sApachectlPath) {
+                $aMessage = array('type' => BX_DOL_AUDIT_UNDEF, 'msg' => _t('_sys_audit_msg_apache_module_undef', $sModule));
+                return $this->getBlock($sModule, '', $this->getMsgHTML($sModule, $aMessage));
+            }
             $ret = (boolean)`$sApachectlPath -M 2>&1 | grep $sModule`;
             if (!$ret)
                 $ret = (boolean)`$sApachectlPath -l 2>&1 | grep $sNameCompiledName`;
         }
 
-        return $ret ? '<b class="ok">OK</b>' : '<b class="fail">FAIL</b> (You will need to install ' . $sModule . ' for Apache)';
+        $aMessage = array('type' => BX_DOL_AUDIT_OK);
+        if (!$ret)
+            $aMessage = array('type' => BX_DOL_AUDIT_FAIL, 'msg' => _t('_sys_audit_msg_apache_module_fail', $sModule));
+
+        return $this->getBlock('', '', $this->getMsgHTML($sModule, $aMessage), false);
     }
 
 
@@ -576,16 +553,18 @@ class BxDolStudioToolsAudit extends BxDol
 
     protected function sendTestEmail ()
     {
-        $sEmailToCkeckMailSending = getParam('site_email');
+        $sEmailToCkeckMailSending = isset($_GET['email']) ? $_GET['email'] : getParam('site_email');
         $mixedRet = sendMail($sEmailToCkeckMailSending, 'Audit Test Email', 'Sample text for testing<br /><u><b>Sample text for testing</b></u>', '', array(), BX_EMAIL_SYSTEM);
-        if (!$mixedRet)
-            return '<b class="fail">FAIL</b> (mail send failed)';
-        else
-            return 'test mail was send, please check ' . $sEmailToCkeckMailSending . ' mailbox';
+        if (!$mixedRet) {
+            $aMessage = array('type' => BX_DOL_AUDIT_FAIL, 'msg' => _t('_sys_audit_msg_mail_send_failed'));
+            return $this->getBlock('', '', $this->getMsgHTML(_t('_sys_audit_mail_sending'), $aMessage), false);
+        } else {
+            return _t('_sys_audit_msg_mail_sent', $sEmailToCkeckMailSending);
+        }
     }
 
     protected function setErrorReporting () 
-    {   
+    {
         if (version_compare(phpversion(), "5.3.0", ">=") == 1)
             $this->iPhpErrorReporting = error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING & ~E_DEPRECATED & ~E_STRICT);
         else
@@ -597,6 +576,25 @@ class BxDolStudioToolsAudit extends BxDol
         error_reporting($this->iPhpErrorReporting);
     }
     
+    protected function getSection($sTitle, $sTitleAddon, $sContent) {
+        $s = '<b>' . $sTitle . '</b>: ' . $sTitleAddon;
+        $s .= '<ul>';
+        $s .= $sContent;
+        $s .= '</ul>';
+        return $s;
+    }
+
+    protected function getBlock($sName, $sValue = '', $sMsg = '', $bWrapAsListItem = true) {
+        $s = $bWrapAsListItem ? '<li>'  : '';
+        if ($sName !== '')
+            $s .= "$sName ";
+        if ($sValue !== '')
+            $s .= " = $sValue ";
+        if ($sMsg)
+                $s .= ($s ? " - " : '') . $sMsg;
+        return $s . ($bWrapAsListItem ? '</li>' : '') . "\n";
+    }
+
     protected function getMsgHTML($sName, $a) 
     {
         $s = '';

+ 1 - 0
template/css/default.less

@@ -238,6 +238,7 @@
 }
 
 .bx-def-color-bg-hl,
+.bx-def-color-bg-hl-even:nth-child(even),
 .bx-def-color-bg-hl-hover:hover {
     .background-color (@bx-color-hl);
 }