public function checkServerPermissions($sPath = null, $iMinPerm = 777)
    {
        clearstatcache();
        $sPath = $sPath ? $sPath : getShopBasePath();

        // special config file check
        $sFullPath = $sPath . "config.inc.php";
        if (!is_readable($sFullPath) ||
            ($this->isAdmin() && is_writable($sFullPath)) ||
            (!$this->isAdmin() && !is_writable($sFullPath))
        ) {
            return 0;
        }

        $sTmp = "$sPath/tmp/";
        $config = new \OxidEsales\Eshop\Core\ConfigFile(getShopBasePath() . "/config.inc.php");
        $sCfgTmp = $config->getVar('sCompileDir');
        if ($sCfgTmp && strpos($sCfgTmp, '<sCompileDir') === false) {
            $sTmp = $sCfgTmp;
        }

        $aPathsToCheck = [
            $sPath . 'out/pictures/promo/',
            $sPath . 'out/pictures/master/',
            $sPath . 'out/pictures/generated/',
            $sPath . 'out/pictures/media/', // @deprecated, use out/media instead
            $sPath . 'out/media/',
            $sPath . 'log/',
            $sTmp
        ];
        $iModStat = 2;
        $sPathToCheck = reset($aPathsToCheck);
        while ($sPathToCheck) {
            // missing file/folder?
            if (!file_exists($sPathToCheck)) {
                $iModStat = 0;
                break;
            }

            if (is_dir($sPathToCheck)) {
                // adding subfolders
                $aSubF = glob($sPathToCheck . "*", GLOB_ONLYDIR);
                if (is_array($aSubF)) {
                    foreach ($aSubF as $sNewFolder) {
                        $aPathsToCheck[] = $sNewFolder . "/";
                    }
                }
            }

            // testing if file permissions >= $iMinPerm
            if (!is_readable($sPathToCheck) || !is_writable($sPathToCheck)) {
                $iModStat = 0;
                break;
            }

            $sPathToCheck = next($aPathsToCheck);
        }

        return $iModStat;
    }