Blame view

php/change_dns.php 532 Bytes
cf76164e6   Ting Chan   20190709
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  <?php
   //include('../cfg/file_name.php');
   $open_dns = '/etc/resolv.conf';
   shell_exec("sudo chmod 777 ".$open_dns);
   $fp = fopen($open_dns,'w') or die("Unable to open file!");
  
   if(trim($_POST['dns1'])!=""){
    fwrite($fp, "nameserver ");
    fwrite($fp, $_POST['dns1']."
  ");
   }
   if(trim($_POST['dns2'])!=""){
    fwrite($fp, "nameserver ");
    fwrite($fp, $_POST['dns2']."
  ");
   }
   if(trim($_POST['dns3'])!=""){
    fwrite($fp, "nameserver ");
    fwrite($fp, $_POST['dns3']."
  ");
   }
   
   fclose($fp);
   echo "1";
  
  ?>