Location: PHPKode > projects > SCOP Heartbeat Administration interface > scop-2.0/html/scop/config/changedns.php
<?
include ("../inc/header.inc");
include ("../inc/functions.inc");

$dns1 = $_POST['dns1'];
$dns2 = $_POST['dns2'];

echo "<h2>DNS Address configuration</h2>";

if ($action==modip) {
			echo "<p>The DNS resolver has now been changed.</p>";
			SCOP_log("Config : DNS settings changed.");
			# open a new file
			exec ("sudo chmod 777 /etc/resolv.conf");
			if ($file=fopen("/etc/resolv.conf","w")) {

				fputs($file,"#Auto generated by SCOP.org appliance\n");
				fputs($file,"search localdomain\n");
				fputs($file,"nameserver $dns1\n");
				fputs($file,"nameserver $dns2\n");

			#Copy settings to slave
			flush();
			exec ("sudo scp /etc/resolv.conf hide@address.com:/etc/resolv.conf");

			fclose($file);
			} else {
				draw_no_access ("/etc/resolv.conf");
		}



} else {

	exec ("sudo chmod 777 /etc/resolv.conf");
	if ($arrtext = file("/etc/resolv.conf")) {

	} else {
		echo "<font color='#010000'> The file <b>/etc/resolv.conf</b> does not have the correct permissions.</br>";
	}

	$tok = strtok(ltrim($arrtext[2])," \n\t");
	$tok = strtok(" \n\t");
	$dns1 = $tok;
	$tok = strtok(ltrim($arrtext[3])," \n\t");
	$tok = strtok(" \n\t");
	$dns2 = $tok;



	echo "<table><FORM method=\"post\" action=\"changedns.php?action=modip\">";
	echo "<tr><td><b>Name Server 1 :</b></td><td><INPUT type=\"text\" size=20 name=\"dns1\" value=\"$dns1\"></td></tr>";
	echo "<tr><td><b>Name Server 2 :</b></td><td><INPUT type=\"text\" size=20 name=\"dns2\" value=\"$dns2\"></td></tr>";
	echo "<tr><td><INPUT type=\"submit\" value=\"Change DNS address\" name=\"go\" ></td></tr>";
	echo "</FORM></table>";
	echo "</br>NB. DNS lookups are an optional feature and not required forSCOPoperation.";

}


include ("../inc/footer.inc");
?>
Return current item: SCOP Heartbeat Administration interface