本文整理汇总了PHP中Piwik_Common::createHtAccess方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik_Common::createHtAccess方法的具体用法?PHP Piwik_Common::createHtAccess怎么用?PHP Piwik_Common::createHtAccess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik_Common
的用法示例。
在下文中一共展示了Piwik_Common::createHtAccess方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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) {
Piwik_Common::createHtAccess(PIWIK_INCLUDE_PATH . $directoryToProtect);
}
// more selective allow/deny filters
$allowAny = "<Files \"*\">\nAllow from all\nSatisfy any\n</Files>\n";
$allowStaticAssets = "<Files ~ \"\\.(test\\.php|gif|ico|jpg|png|js|css|swf)\$\">\nSatisfy any\nAllow from all\n</Files>\n";
$denyDirectPhp = "<Files ~ \"\\.(php|php4|php5|inc|tpl|in)\$\">\nDeny from all\n</Files>\n";
$directoriesToProtect = array('/js' => $allowAny, '/libs' => $denyDirectPhp . $allowStaticAssets, '/plugins' => $denyDirectPhp . $allowStaticAssets, '/themes' => $denyDirectPhp . $allowStaticAssets);
foreach ($directoriesToProtect as $directoryToProtect => $content) {
Piwik_Common::createHtAccess(PIWIK_INCLUDE_PATH . $directoryToProtect, $content);
}
}
示例2: 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) {
Piwik_Common::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|js|css|swf)\$\">\n" . $allow . "Satisfy any\n</Files>\n";
$denyDirectPhp = "<Files ~ \"\\.(php|php4|php5|inc|tpl|in)\$\">\n" . $deny . "</Files>\n";
$directoriesToProtect = array('/js' => $allowAny, '/libs' => $denyDirectPhp . $allowStaticAssets, '/plugins' => $denyDirectPhp . $allowStaticAssets, '/themes' => $denyDirectPhp . $allowStaticAssets);
foreach ($directoriesToProtect as $directoryToProtect => $content) {
Piwik_Common::createHtAccess(PIWIK_INCLUDE_PATH . $directoryToProtect, $overwrite = true, $content);
}
}