action_htaccess_addtotalprotect_file.php
上传用户:feiyaoda
上传日期:2016-11-21
资源大小:9556k
文件大小:2k
源码类别:
WEB邮件程序
开发平台:
PHP
- <?php
- $write_file = false;
- include ('action_htaccess_guess.php');
- include ('./extensions/htaccess.class.php');
- echo "<form action=execute.php method=POST>n";
- echo "<input type=hidden name=action value="".$_POST['action']."">n";
- echo "<input type=hidden name=target_folder value="".$_POST['target_folder']."">n";
- echo "<input type=hidden name=target_type value="".$_POST['target_type']."">n";
- echo "<table border=0>n";
- if ($state != NO_ACCESS)
- {
- // changing state
- if ($_POST['change_state'])
- {
- // setting new rules
- $write_file = true;
- }
- else
- {
- // form to ask to change to new rules
- echo "<tr><td>".$get_string->get('change_rules')."</td><td>";
- echo "<input type=radio name=change_state value=1>".$get_string->get('yes')."n";
- echo "<input type=radio name=change_state value=0>".$get_string->get('no')."n";
- echo "</td></tr>n";
- }
- }
- else
- {
- // the same or no rules adding
- if ($_POST['writefile'])
- $write_file = true;
- else
- $write_file = false;
- }
- if ($state != NO_RULE)
- {
- $userfile = $_POST['userfile'];
- $authname = $_POST['authname'];
- }
- // default values
- if ('' == $userfile) $userfile = translate_path($target_folder.'.htpasswd');
- if ('' == $authname) $authname = 'Restricted Area';
- echo "</table>n";
- if ($write_file)
- {
- $htaccess_str = '# PAT no access'."n";
- $htaccess_str .= 'Deny from All'."n";
- $fp = fopen($target_folder.'.htaccess',"w+");
- if (FALSE == $fp) echo $get_string->get('failed_open_file')."n";
- else
- {
- fputs($fp,$htaccess_str);
- fclose($fp);
- echo "<p><i>".$get_string->get('failed_open_file')."</i></p>n";
- }
- }
- else
- {
- // displaying end of form
- echo "<input type=submit name=submit value="".$get_string->get('protection_success')."">n";
- echo "</form>n";
- }
English
