我只是尝试编辑位于服务器(BIND)上的名为named.conf.local的文件。 当我运行网页时,它显示了File written!,但是当我检查文件(named.conf.local)时,没有更新。
这是我的控制器:
function index() {
$this->load->helper(array('form', 'url', 'file'));
$this->load->library('form_validation');
$this->form_validation->set_rules('domain_name','Domain Name','required');
$this->form_validation->set_rules('mail', 'Mail', 'required');
$this->form_validation->set_rules('localhost', 'Localhost', 'required');
if ($this->form_validation->run() == FALSE) {
$this->load->view('dns_form');
} else {
$domain_name = $this->input->post('domain_name');
$mail = $this->input->post('mail');
$localhost = $this->input->post('localhost');
$data = $domain_name . "\n" . $mail . "\n" . $localhost;
if (!write_file('/etc/bind/named.conf.local' . $domain_name, $data, 'a+')) {
echo 'Unable to write this file';
} else {
echo 'File written!';
}
}
我已获得地点sudo chmod -R 777 /etc/bind/named.conf.local
的许可。我的计划出了什么问题?
感谢您帮助我..
答案 0 :(得分:0)
您确定文件的路径是否正确?从此行中删除$ domain_name变量时是否有效,如下所示?
if (!write_file('/etc/bind/named.conf.local', $data, 'a+')) {