本文整理汇总了PHP中AIOWPSecurity_Utility_Htaccess::delete_from_htaccess方法的典型用法代码示例。如果您正苦于以下问题:PHP AIOWPSecurity_Utility_Htaccess::delete_from_htaccess方法的具体用法?PHP AIOWPSecurity_Utility_Htaccess::delete_from_htaccess怎么用?PHP AIOWPSecurity_Utility_Htaccess::delete_from_htaccess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AIOWPSecurity_Utility_Htaccess
的用法示例。
在下文中一共展示了AIOWPSecurity_Utility_Htaccess::delete_from_htaccess方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: write_to_htaccess
/**
* Write all active rules to .htaccess file.
*
* @return boolean True on success, false on failure.
*/
static function write_to_htaccess()
{
global $aio_wp_security;
//figure out what server is being used
if (AIOWPSecurity_Utility::get_server_type() == -1) {
$aio_wp_security->debug_logger->log_debug("Unable to write to .htaccess - server type not supported!", 4);
return false;
//unable to write to the file
}
//clean up old rules first
if (AIOWPSecurity_Utility_Htaccess::delete_from_htaccess() == -1) {
$aio_wp_security->debug_logger->log_debug("Delete operation of .htaccess file failed!", 4);
return false;
//unable to write to the file
}
$htaccess = ABSPATH . '.htaccess';
if (!($f = @fopen($htaccess, 'a+'))) {
@chmod($htaccess, 0644);
if (!($f = @fopen($htaccess, 'a+'))) {
$aio_wp_security->debug_logger->log_debug("chmod operation on .htaccess failed!", 4);
return false;
}
}
AIOWPSecurity_Utility_File::backup_and_rename_htaccess($htaccess);
//TODO - we dont want to continually be backing up the htaccess file
@ini_set('auto_detect_line_endings', true);
$ht = explode(PHP_EOL, implode('', file($htaccess)));
//parse each line of file into array
$rules = AIOWPSecurity_Utility_Htaccess::getrules();
$rulesarray = explode(PHP_EOL, $rules);
$rulesarray = apply_filters('aiowps_htaccess_rules_before_writing', $rulesarray);
$contents = array_merge($rulesarray, $ht);
if (!($f = @fopen($htaccess, 'w+'))) {
$aio_wp_security->debug_logger->log_debug("Write operation on .htaccess failed!", 4);
return false;
//we can't write to the file
}
$blank = false;
//write each line to file
foreach ($contents as $insertline) {
if (trim($insertline) == '') {
if ($blank == false) {
fwrite($f, PHP_EOL . trim($insertline));
}
$blank = true;
} else {
$blank = false;
fwrite($f, PHP_EOL . trim($insertline));
}
}
@fclose($f);
return true;
//success
}