Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once('auth.php');
- $hostname = $_POST['HOSTNAME'];
- echo $hostname;
- $file = "#This file was created by arX box configuration script
- 127.0.0.1 localhost $hostname
- ::1 localhost ip6-localhost ip6-loopback
- fe00::0 ip6-localnet
- ff00::0 ip6-mcastprefix
- ff02::1 ip6-allnodes
- ff02::2 ip6-allrouters";
- $file_hostname = "/tmp/hostname";
- $filename = "/tmp/hosts";
- echo exec('sudo cp /etc/hostname /etc/hostname.backup-`date +%m-%d-%Y_%T`');
- echo exec('sudo cp /etc/hosts /etc/hosts.backup-`date +%m-%d-%Y_%T`');
- $fp = fopen ($filename, "w");
- if ($fp) {
- fwrite ($fp, $file);
- fclose ($fp);
- echo ("New hosts file written");
- }
- else {
- echo ("File was not written");
- }
- $fp = fopen ($file_hostname, "w");
- if ($fp) {
- fwrite ($fp, $hostname);
- fclose ($fp);
- echo ("New hosts file written");
- }
- else {
- echo ("File was not written");
- }
- echo exec('sudo mv /tmp/hostname /etc/hostname');
- echo exec('sudo mv /tmp/hosts /etc/hosts');
- echo ("hostname has been updated<br />");
- shell_exec("sleep 10");
- echo $hostname;
- echo exec('sudo /bin/hostname <?php echo $hostname; ?>');
- print ("<script>window.opener.location.reload();
- //self.close();</script>");
- echo '<input type="submit" value="Close" onclick="window.close()" />';
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement