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

echo "<h2>Local Host Lookup File Configuration</h2>";
$master = $_POST['master'];
$slave = $_POST['slave'];

if ($action==modnet) {
			echo "<p>The local hosts file has now been changed.</p>";
			SCOP_log("Config : local hosts fille changed.");

			# open a new file
			exec ("sudo chmod 777 /etc/hosts");

			if ($file=fopen("/etc/hosts","w")) {

				fputs($file,"#Auto generated by SCOP.org appliance\n");
				fputs($file,"  localhost\n");
				fputs($file,"$master  master\n");
				fputs($file,"$slave  slave\n");


			} else {
				draw_no_access ("/etc/hosts");

} else {

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

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

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

	#$tok = strtok(" \n\t");

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

	#$tok = strtok(" \n\t");

	$slave = $tok;

	echo "<table><FORM method=\"post\" action=\"changehosts.php?action=modnet\">";
	echo "<tr><td><b>master :</b></td><td><INPUT type=\"text\" size=20 name=\"master\" value=\"$master\"></td></tr>";
	echo "<tr><td><b>slave :</b></td><td><INPUT type=\"text\" size=20 name=\"slave\" value=\"$slave\"></td></tr>";
	echo "<tr><td><INPUT type=\"submit\" value=\"Change local hosts config\" name=\"go\" ></td></tr>";
	echo "</FORM></table>";


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