當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Filesystem::createHtAccess方法代碼示例

本文整理匯總了PHP中Piwik\Filesystem::createHtAccess方法的典型用法代碼示例。如果您正苦於以下問題:PHP Filesystem::createHtAccess方法的具體用法?PHP Filesystem::createHtAccess怎麽用?PHP Filesystem::createHtAccess使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Piwik\Filesystem的用法示例。


在下文中一共展示了Filesystem::createHtAccess方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: createHtAccessFiles

 /**
  * Generate Apache .htaccess files to restrict access
  */
 public static function createHtAccessFiles()
 {
     // deny access to these folders
     $directoriesToProtect = array('/config', '/core', '/lang', '/tmp');
     foreach ($directoriesToProtect as $directoryToProtect) {
         Filesystem::createHtAccess(PIWIK_INCLUDE_PATH . $directoryToProtect, $overwrite = true);
     }
     // Allow/Deny lives in different modules depending on the Apache version
     $allow = "<IfModule mod_access.c>\nAllow from all\n</IfModule>\n<IfModule !mod_access_compat>\n<IfModule mod_authz_host.c>\nAllow from all\n</IfModule>\n</IfModule>\n<IfModule mod_access_compat>\nAllow from all\n</IfModule>\n";
     $deny = "<IfModule mod_access.c>\nDeny from all\n</IfModule>\n<IfModule !mod_access_compat>\n<IfModule mod_authz_host.c>\nDeny from all\n</IfModule>\n</IfModule>\n<IfModule mod_access_compat>\nDeny from all\n</IfModule>\n";
     // more selective allow/deny filters
     $allowAny = "<Files \"*\">\n" . $allow . "Satisfy any\n</Files>\n";
     $allowStaticAssets = "<Files ~ \"\\.(test\\.php|gif|ico|jpg|png|svg|js|css|swf)\$\">\n" . $allow . "Satisfy any\n</Files>\n";
     $denyDirectPhp = "<Files ~ \"\\.(php|php4|php5|inc|tpl|in|twig)\$\">\n" . $deny . "</Files>\n";
     $directoriesToProtect = array('/js' => $allowAny, '/libs' => $denyDirectPhp . $allowStaticAssets, '/vendor' => $denyDirectPhp . $allowStaticAssets, '/plugins' => $denyDirectPhp . $allowStaticAssets, '/misc/user' => $denyDirectPhp . $allowStaticAssets);
     foreach ($directoriesToProtect as $directoryToProtect => $content) {
         Filesystem::createHtAccess(PIWIK_INCLUDE_PATH . $directoryToProtect, $overwrite = true, $content);
     }
 }
開發者ID:KiwiJuicer,項目名稱:handball-dachau,代碼行數:22,代碼來源:ServerFilesGenerator.php


注:本文中的Piwik\Filesystem::createHtAccess方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。