Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write to htaccess at wphome and not to abspath #86

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions all-in-one-wp-security/admin/wp-security-settings-menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@ function render_tab2()
$aio_wp_security->debug_logger->log_debug("Nonce check failed on htaccess file save!",4);
die("Nonce check failed on htaccess file save!");
}
$htaccess_path = ABSPATH . '.htaccess';
$home_path = get_home_path();
$htaccess_path = $home_path . '.htaccess';
$result = AIOWPSecurity_Utility_File::backup_and_rename_htaccess($htaccess_path); //Backup the htaccess file

if ($result)
Expand Down Expand Up @@ -289,7 +290,8 @@ function render_tab2()
$is_htaccess = AIOWPSecurity_Utility_Htaccess::check_if_htaccess_contents($new_htaccess_file_path);
if ($is_htaccess == 1)
{
$active_root_htaccess = ABSPATH.'.htaccess';
$home_path = get_home_path();
$active_root_htaccess = $home_path . '.htaccess';
if (!copy($new_htaccess_file_path, $active_root_htaccess))
{
//Failed to make a backup copy
Expand Down Expand Up @@ -363,7 +365,8 @@ function render_tab2()
<!-- <h3 class="hndle"><label for="title">--><?php //_e('View Contents of the currently active .htaccess file', 'all-in-one-wp-security-and-firewall'); ?><!--</label></h3>-->
<!-- <div class="inside">-->
<!-- --><?php
// $ht_file = ABSPATH . '.htaccess';
// $home_path = get_home_path();
// $ht_file = $home_path . '.htaccess';
// $ht_contents = AIOWPSecurity_Utility_File::get_file_contents($ht_file);
// //echo $ht_contents;
// ?>
Expand Down Expand Up @@ -791,4 +794,4 @@ function check_if_valid_aiowps_settings_file($wp_file)

}

} //end class
} //end class
3 changes: 2 additions & 1 deletion all-in-one-wp-security/classes/wp-security-utility-file.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ function __construct(){

//Get wp-config.php file path
$wp_config_path = AIOWPSecurity_Utility_File::get_wp_config_file_path();
$home_path = get_home_path();

$this->files_and_dirs_to_check = array(
array('name'=>'root directory','path'=>ABSPATH,'permissions'=>'0755'),
array('name'=>'wp-includes/','path'=>ABSPATH."wp-includes",'permissions'=>'0755'),
array('name'=>'.htaccess','path'=>ABSPATH.".htaccess",'permissions'=>'0644'),
array('name'=>'.htaccess','path'=> $home_path .".htaccess",'permissions'=>'0644'),
array('name'=>'wp-admin/index.php','path'=>ABSPATH."wp-admin/index.php",'permissions'=>'0644'),
array('name'=>'wp-admin/js/','path'=>ABSPATH."wp-admin/js/",'permissions'=>'0755'),
array('name'=>'wp-content/themes/','path'=>ABSPATH."wp-content/themes",'permissions'=>'0755'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ static function write_to_htaccess()
return false; //unable to write to the file
}

$htaccess = ABSPATH . '.htaccess';
$home_path = get_home_path();
$htaccess = $home_path . '.htaccess';

if (!$f = @fopen($htaccess, 'a+')) {
@chmod($htaccess, 0644);
Expand Down Expand Up @@ -135,7 +136,8 @@ static function write_to_htaccess()
static function delete_from_htaccess($section = 'All In One WP Security')
{
//TODO
$htaccess = ABSPATH . '.htaccess';
$home_path = get_home_path();
$htaccess = $home_path . '.htaccess';

@ini_set('auto_detect_line_endings', true);
if (!file_exists($htaccess)) {
Expand Down Expand Up @@ -1138,4 +1140,4 @@ protected static function add_netmask($ips) {

return $output;
}
}
}