Alex Trofimov преди 12 години
родител
ревизия
da13fad531

+ 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();
 

+ 16 - 0
install/classes/BxDolInstallController.php

@@ -55,6 +55,22 @@ class BxDolInstallController
         else
             $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');
     }
 }

+ 12 - 6
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;
@@ -36,12 +44,6 @@ html, body {
     max-width:90%;
 }
 
-.bx-install-initial .bx-btn {
-    display:inline;
-    display:inline-block;
-    float:none;
-}
-
 .bx-install-initial-langs {
     text-align:center;
 }
@@ -50,3 +52,7 @@ html, body {
     width:32px;
     height:32px;
 }
+
+.bx-install-permissions-buttons {
+    text-align:center;
+}

+ 2 - 0
install/index.php

@@ -8,6 +8,7 @@
  */
 
 define('BX_DOL', 1);
+define('BX_DOL_INSTALL', 1);
 
 define ('BX_INSTALL_DEFAULT_LANGUAGE', 'en');
 
@@ -28,6 +29,7 @@ if (!defined('BX_DOL_MODULE_TYPE_MODULE')) {
 
 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');

+ 1 - 1
install/templates/initial.php

@@ -4,7 +4,7 @@
 
     <?php include('lang_swither.php'); ?>
 
-    <a href="javascript:void(0);" class="bx-btn bx-btn-primary"><? echo _t('_sys_inst_start_installation'); ?></a>
+    <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): ?>

+ 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>

+ 10 - 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>
@@ -3678,10 +3679,14 @@ If you don't know how to do it by yourself you can submit <a target="_blank" hre
     <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 -->

+ 2 - 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>

+ 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;
+    }
 }
 /** @} */

+ 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);
 }