/** * add_htaccess_deny_from_all * @param string $folder * @return bool */ public static function add_htaccess_deny_from_all($folder = '') { $folder = EEH_File::standardise_and_end_with_directory_separator($folder); if (!EEH_File::exists($folder . '.htaccess')) { if (!EEH_File::write_to_file($folder . '.htaccess', 'deny from all', '.htaccess')) { return FALSE; } } return TRUE; }
public function test_standardise_diirectory_seperators_and_end_with_directory_separator() { $file_path = '/well\\this/isnt\\very/consistent'; $this->assertEquals('/well/this/isnt/very/consistent/', EEH_File::standardise_and_end_with_directory_separator($file_path)); }
/** * Adds an index file to this folder, so folks can't list all the file's contents * @param string $folder * @throws EE_Error if filesystem credentials are required * @return boolean */ public static function add_index_file($folder) { $folder = EEH_File::standardise_and_end_with_directory_separator($folder); if (!EEH_File::exists($folder . 'index.php')) { if (!EEH_File::write_to_file($folder . 'index.php', 'You are not permitted to read from this folder', '.php')) { return false; } } return true; }