Location: PHPKode > projects > WeBBind Web Gui to Bind > webbind_0.98/showzone.php
<?
require("htmlcommon.php");
require("parser.php");

//Elabora per ogni file dns trovato e genera html output
//
function ModifyZone($RECORD_SERIAL,$RECORD_NS,$RECORD_DELEGATION,$RECORD_MX,$RECORD_A,$RECORD_CNAME,$RECORD_PTR,$otherinfo,$idserver,$dnsfile,$rdonly,$user)
{
	require("global.php");
	
	$server = $servername[$idserver];
	$zonename = explode("/", $dnsfile);
	$ZONENAME = strtoupper(end($zonename));
	$newserial = ($RECORD_SERIAL + 1);

	HTMLheader();
	StatusBar($zflto);

	Banner("<font face=\"Verdana\" size=2>"."<CENTER>"."Working on "."<MARQUEE BEHAVIOR=ALTERNATE SCROLLDELAY=10 SCROLLAMOUNT=2>".$ZONENAME."</MARQUEE>"."</CENTER>"."</FONT>",$user,$server);

        print("<center><table BORDER COLS=1 WIDTH=\"100%\" >\n");
        print("<tr>\n");
        print("<td BGCOLOR=\"#990000\">\n");
        print("<center>\n");
        print("<font face=\"Verdana\" size=2 font color=\"#FFFFFF\"><B>$ZONENAME</B></font></center>\n");
        print("</td>\n");
        print("</tr>\n");
        print("</table></center>\n");

        print("<center><table BORDER COLS=3 WIDTH=\"100%\" >\n");
        print("<form method=\"post\" action=\"writezone.php\">\n");

        print("<tr BGCOLOR=\"#990000\">\n");
        print("<td>\n");
        print("<center><font face=\"Verdana\" size=2 font color=\"#FFFFFF\"><B>Record Type</B></font></center>\n");
        print("</td>\n");
        print("<td>\n");
        print("<center><font face=\"Verdana\" size=2 font color=\"#FFFFFF\"><B>Current Value</B></font></center>\n");
        print("</td>\n");
        print("<td>\n");
        print("<center><font face=\"Verdana\" size=2 font color=\"#FFFFFF\"><B>New Value</B></font></center>\n");
        print("</td>\n");
	print("</tr>\n");

        print("<tr BGCOLOR=\"#990000\">\n");
        print("<td>\n");
        print("<center><font face=\"Verdana\" size=2 font color=\"#FFFFFF\"><B>       .        </B></font></center>\n");
        print("</td>\n");
        print("<td>\n");
        print("<center><font face=\"Verdana\" size=2 font color=\"#FFFFFF\"><B>       .        </B></font></center>\n");
        print("</td>\n");
        print("<td>\n");
        print("<center><font face=\"Verdana\" size=2 font color=\"#FFFFFF\"><B>       .        </B></font></center>\n");
        print("</td>\n");
        print("</tr>\n");
//SERIAL
	print("<tr BGCOLOR=\"#FFFFFF\">\n");
        print("<td BGCOLOR=\"#990000\">\n");
        print("<center><font face=\"Verdana\" size=1 font color=\"#FFFFFF\"><B>Serial Number</B></font></center>\n");
        print("</td>\n");
        print("<td BGCOLOR=\"#FFFFFF\">\n");
        print("<center><font face=\"Verdana\" size=1 font color=\"#990000\"><B>$RECORD_SERIAL</B></font></center>\n");
        print("</td>\n");
        print("<td>\n");
        print("<CENTER><INPUT type=\"TEXT\" name=\"oserial\" maxlength=\"10\" value=\"$newserial\" size=10></CENTER>\n");
        print("</td>\n");
	print("</tr>\n");
//NAME SERVERS
  for ($i = 0; $i < (count ($RECORD_NS)); $i++) {
	print("<tr BGCOLOR=\"#FFFFFF\">\n");
        print("<td BGCOLOR=\"#990000\">\n");
        print("<center><font face=\"Verdana\" size=1 font color=\"#FFFFFF\"><B>Name Server (NS)</B></font></center>\n");
        print("</td>\n");
        print("<td BGCOLOR=\"#FFFFFF\">\n");
        print("<center><font face=\"Verdana\" size=1 font color=\"#990000\"><B>$RECORD_NS[$i]</B></font></center>\n");
        print("</td>\n");
        print("<td>\n");
        print("<CENTER><INPUT type=\"TEXT\" name=\"nameserver[$i]\" value=\"$RECORD_NS[$i]\" size=30></CENTER>\n");
        print("</td>\n");
        print("</tr>\n");
  }
        print("<tr BGCOLOR=\"#FFFFFF\">\n");
        print("<td BGCOLOR=\"#990000\">\n");
        print("<center><font face=\"Verdana\" size=1 font color=\"#FFFFFF\"><B>Name Server (NS) (Add New)</B></font></center>\n");
        print("</td>\n");
        print("<td BGCOLOR=\"#FFFFFF\">\n");
        print("<center><font face=\"Verdana\" size=1 font color=\"#990000\"><B></B></font></center>\n");
        print("</td>\n");
        print("<td>\n");
        print("<CENTER><INPUT type=\"TEXT\" name=\"nameservernew\" value=\"\" size=30></CENTER>\n");
        print("</td>\n");
        print("</tr>\n");

//IF IN-ADDR.ARPA ZONES DON'T SHOW "A"/"MX"/etc. FIELDS
if (! $RECORD_PTR) {

//MX RECORDS
        print("<tr BGCOLOR=\"#FFFFFF\">\n");
        print("<td BGCOLOR=\"#DCDCDC\">\n");
        print("<font color=\"#DCDCDC\"><B>.</B></font>\n");
        print("</td>\n");
        print("<td BGCOLOR=\"#DCDCDC\">\n");
        print("<font color=\"#DCDCDC\"><B>.</B></font>\n");
        print("</td>\n");
        print("<td BGCOLOR=\"#DCDCDC\">\n");
        print("<font color=\"#DCDCDC\"><B>.</B></font>\n");
        print("</td>\n");
        print("</tr>\n");
//MX RECORDS

  for ($i = 0; $i < (count ($RECORD_MX)); $i++) {
  //$distvalue = split("(	+)|( +)",$RECORD_MX[$i]);
  $distvalue = split("(".chr(32)."+)|(".chr(9)."+)",$RECORD_MX[$i]);

	print("<tr BGCOLOR=\"#FFFFFF\">\n");
        print("<td BGCOLOR=\"#990000\">\n");
        print("<center><font face=\"Verdana\" size=1 font color=\"#FFFFFF\"><B>Mail Exchanger (MX)</B></font></center>\n");
        print("</td>\n");
        print("<td BGCOLOR=\"#FFFFFF\">\n");
        print("<center><font face=\"Verdana\" size=1 font color=\"#990000\"><B>$RECORD_MX[$i]</B></font></center>\n");
        print("</td>\n");
        print("<td>\n");
        print("<CENTER><INPUT type=\"TEXT\" name=\"mailxhost[$i]\" value=\"$distvalue[0]\" size=10>\n");
	print("<INPUT type=\"TEXT\" name=\"mailxvalue[$i]\" value=\"$distvalue[1]\" size=5>\n");
        print("<INPUT type=\"TEXT\" name=\"mailxrecord[$i]\" value=\"$distvalue[2]\" size=20></CENTER>\n");
        print("</td>\n");
        print("</tr>\n");
  }
        print("<tr BGCOLOR=\"#FFFFFF\">\n");
        print("<td BGCOLOR=\"#990000\">\n");
        print("<center><font face=\"Verdana\" size=1 font color=\"#FFFFFF\"><B>Mail Exchanger (MX) (Add New)</B></font></center>\n");
        print("</td>\n");
        print("<td BGCOLOR=\"#FFFFFF\">\n");
        print("<center><font face=\"Verdana\" size=1 font color=\"#990000\"><B></B></font></center>\n");
        print("</td>\n");
        print("<td>\n");
        print("<CENTER><INPUT type=\"TEXT\" name=\"mailxhostnew\" value=\"\" size=10 >\n");
        print("<INPUT type=\"TEXT\" name=\"mailxvaluenew\" value=\"\" size=5 >\n");
        print("<INPUT type=\"TEXT\" name=\"mailxrecordnew\" value=\"\" size=20></CENTER>\n");
        print("</td>\n");
        print("</tr>\n");

//A RECORDS
        print("<tr BGCOLOR=\"#FFFFFF\">\n");
        print("<td BGCOLOR=\"#DCDCDC\">\n");
        print("<font color=\"#DCDCDC\"><B>.</B></font>\n");
        print("</td>\n");
        print("<td BGCOLOR=\"#DCDCDC\">\n");
        print("<font color=\"#DCDCDC\"><B>.</B></font>\n");
        print("</td>\n");
        print("<td BGCOLOR=\"#DCDCDC\">\n");
        print("<font color=\"#DCDCDC\"><B>.</B></font>\n");
        print("</td>\n");
        print("</tr>\n");
//A RECORDS

  for ($i = 0; $i < (count ($RECORD_A)); $i++) {
  $distvalue = explode(" ",$RECORD_A[$i]);

        print("<tr BGCOLOR=\"#FFFFFF\">");
        print("<td BGCOLOR=\"#990000\">");
        print("<center><font face=\"Verdana\" size=1 font color=\"#FFFFFF\"><B>Address Record (A)</B></font></center>\n");
        print("</td>\n");
        print("<td BGCOLOR=\"#FFFFFF\">\n");
        print("<center><font face=\"Verdana\" size=1 font color=\"#990000\"><B>$distvalue[0] &nbsp&nbsp A &nbsp&nbsp $distvalue[1]</B></font></center>\n");
        print("</td>\n");
        print("<td>\n");
        print("<CENTER><INPUT type=\"TEXT\" name=\"ahost[$i]\" value=\"$distvalue[0]\" size=15>\n");
        print("<INPUT type=\"TEXT\" name=\"aip[$i]\" value=\"$distvalue[1]\" size=15></CENTER>\n");
        print("</td>\n");
        print("</tr>\n");
  }
        print("<tr BGCOLOR=\"#FFFFFF\">\n");
        print("<td BGCOLOR=\"#990000\">\n");
        print("<center><font face=\"Verdana\" size=1 font color=\"#FFFFFF\"><B>Address Record (A) (Add New)</B></font></center>\n");
        print("</td>\n");
        print("<td BGCOLOR=\"#FFFFFF\">\n");
        print("<center><font face=\"Verdana\" size=1 font color=\"#990000\"><B></B></font></center>\n");
        print("</td>\n");
        print("<td>\n");
        print("<CENTER><INPUT type=\"TEXT\" name=\"ahostnew\" value=\"\" size=15 >\n");
        print("<INPUT type=\"TEXT\" name=\"aipnew\" value=\"\" size=15></CENTER>\n");
        print("</td>\n");
        print("</tr>\n");

//CNAME RECORDS
        print("<tr BGCOLOR=\"#FFFFFF\">\n");
        print("<td BGCOLOR=\"#DCDCDC\">\n");
        print("<font color=\"#DCDCDC\"><B>.</B></font>\n");
        print("</td>\n");
        print("<td BGCOLOR=\"#DCDCDC\">\n");
        print("<font color=\"#DCDCDC\"><B>.</B></font>\n");
        print("</td>\n");
        print("<td BGCOLOR=\"#DCDCDC\">\n");
        print("<font color=\"#DCDCDC\"><B>.</B></font>\n");
        print("</td>\n");
        print("</tr>\n");
//CNAME RECORDS

  for ($i = 0; $i < (count ($RECORD_CNAME)); $i++) {
  $distvalue = explode(" ",$RECORD_CNAME[$i]);

        print("<tr BGCOLOR=\"#FFFFFF\">\n");
        print("<td BGCOLOR=\"#990000\">\n");
        print("<center><font face=\"Verdana\" size=1 font color=\"#FFFFFF\"><B>Canonical Name (CNAME)</B></font></center>\n");
        print("</td>\n");
        print("<td BGCOLOR=\"#FFFFFF\">\n");
        print("<center><font face=\"Verdana\" size=1 font color=\"#990000\"><B>$distvalue[0] &nbsp&nbsp CNAME &nbsp&nbsp $distvalue[1]</B></font></center>\n");
        print("</td>\n");
        print("<td>\n");
        print("<CENTER><INPUT type=\"TEXT\" name=\"cnamehost[$i]\" value=\"$distvalue[0]\" size=15>\n");
        print("<INPUT type=\"TEXT\" name=\"cnamevalue[$i]\" value=\"$distvalue[1]\" size=20></CENTER>\n");
        print("</td>\n");
        print("</tr>\n");
  }
        print("<tr BGCOLOR=\"#FFFFFF\">\n");
        print("<td BGCOLOR=\"#990000\">\n");
        print("<center><font face=\"Verdana\" size=1 font color=\"#FFFFFF\"><B>Canonical Name (CNAME) (Add New)</B></font></center>\n");
        print("</td>\n");
        print("<td BGCOLOR=\"#FFFFFF\">\n");
        print("<center><font face=\"Verdana\" size=1 font color=\"#990000\"><B></B></font></center>\n");
        print("</td>\n");
        print("<td>\n");
        print("<CENTER><INPUT type=\"TEXT\" name=\"cnamehostnew\" value=\"\" size=15 >\n");
        print("<INPUT type=\"TEXT\" name=\"cnamevaluenew\" value=\"\" size=20></CENTER>\n");
        print("</td>\n");
        print("</tr>\n");
}

if ($RECORD_PTR) {
//PTR RECORDS
        print("<tr BGCOLOR=\"#FFFFFF\">\n");
        print("<td BGCOLOR=\"#DCDCDC\">\n");
        print("<font color=\"#DCDCDC\"><B>.</B></font>\n");
        print("</td>\n");
        print("<td BGCOLOR=\"#DCDCDC\">\n");
        print("<font color=\"#DCDCDC\"><B>.</B></font>\n");
        print("</td>\n");
        print("<td BGCOLOR=\"#DCDCDC\">\n");
        print("<font color=\"#DCDCDC\"><B>.</B></font>\n");
        print("</td>\n");
        print("</tr>\n");
//PTR RECORDS
			
  for ($i = 0; $i < (count ($RECORD_PTR)); $i++) {
  $distvalue = explode(" ",$RECORD_PTR[$i]);

			if ($distvalue[0]) {
				$checkchange = $distvalue[0];
			}


        print("<tr BGCOLOR=\"#FFFFFF\">\n");
        print("<td BGCOLOR=\"#990000\">\n");
        print("<center><font face=\"Verdana\" size=1 font color=\"#FFFFFF\"><B>PTR</B></font></center>\n");
        print("</td>\n");
        print("<td BGCOLOR=\"#FFFFFF\">\n");
        print("<center><font face=\"Verdana\" size=1 font color=\"#990000\"><B>$distvalue[0] &nbsp&nbsp PTR &nbsp&nbsp $distvalue[1]</B></font></center>\n");
        print("</td>\n");
			if ($distvalue[0]) {
        print("<td ALIGN=\"right\">\n");
        print("<INPUT type=\"TEXT\" name=\"ptrip[$i]\" value=\"$distvalue[0]\" size=5>\n");
        print("<INPUT type=\"TEXT\" name=\"ptrhost[$i]\" value=\"$distvalue[1]\" size=30>\n");
        print("</td>\n");
        print("</tr>\n");
			} else {
        print("<td ALIGN=\"right\">\n");
        print("<INPUT type=\"TEXT\" name=\"ptrhost[$i]\" value=\"$distvalue[1]\" size=30>\n");
        print("</td>\n");
        print("</tr>\n");
			}

//ADDNEWEXISTENTIP
			if ($checkchange) {
        print("<tr BGCOLOR=\"#FFFFFF\">\n");
        print("<td BGCOLOR=\"#990000\">\n");
        print("<center><font face=\"Verdana\" size=1 font color=\"#FFFFFF\"><B>PTR</B></font></center>\n");
        print("</td>\n");
        print("<td BGCOLOR=\"#990000\">\n");
        print("<center><font face=\"Verdana\" size=1 font color=\"#FFFFFF\"><B>Add New FQDN at IP $checkchange</B></font></center>\n");
        print("</td>\n");
        print("<td ALIGN=\"right\">\n");
        print("<INPUT type=\"TEXT\" name=\"ptrhostnew[$i]\" value=\"\" size=30>\n");
        print("</td>\n");
        print("</tr>\n");
			$checkchange = "" ;
			}
//ADDNEWEXISTENTIP


  }

//ADDNEW
        print("<tr BGCOLOR=\"#FFFFFF\">\n");
        print("<td BGCOLOR=\"#DCDCDC\">\n");
        print("<font color=\"#DCDCDC\"><B>.</B></font>\n");
        print("</td>\n");
        print("<td BGCOLOR=\"#DCDCDC\">\n");
        print("<font color=\"#DCDCDC\"><B>.</B></font>\n");
        print("</td>\n");
        print("<td BGCOLOR=\"#DCDCDC\">\n");
        print("<font color=\"#DCDCDC\"><B>.</B></font>\n");
        print("</td>\n");
        print("</tr>\n");
//ADDNEW
        print("<tr BGCOLOR=\"#FFFFFF\">\n");
        print("<td BGCOLOR=\"#990000\">\n");
        print("<center><font face=\"Verdana\" size=1 font color=\"#FFFFFF\"><B>PTR (Add New)
</B></font></center>\n");
        print("</td>\n");
        print("<td BGCOLOR=\"#FFFFFF\">\n");
        print("<center><font face=\"Verdana\" size=1 font color=\"#990000\"><B>Add New IP and FQDN</B></font></center>\n");
        print("</td>\n");
        print("<td>\n");
        print("<CENTER><INPUT type=\"TEXT\" name=\"ptripnnew\" value=\"\" size=5 >\n");
        print("<INPUT type=\"TEXT\" name=\"ptrhostnnew\" value=\"\" size=30></CENTER>\n");
        print("</td>\n");
        print("</tr>\n");


}


//DELEGATION RECORDS
        print("<tr BGCOLOR=\"#FFFFFF\">\n");
        print("<td BGCOLOR=\"#DCDCDC\">\n");
        print("<font color=\"#DCDCDC\"><B>.</B></font>\n");
        print("</td>\n");
        print("<td BGCOLOR=\"#DCDCDC\">\n");
        print("<font color=\"#DCDCDC\"><B>.</B></font>\n");
        print("</td>\n");
        print("<td BGCOLOR=\"#DCDCDC\">\n");
        print("<font color=\"#DCDCDC\"><B>.</B></font>\n");
        print("</td>\n");
        print("</tr>\n");
//DELEGATION RECORDS


  for ($i = 0; $i < (count ($RECORD_DELEGATION)); $i++) {
  $distvalue = explode(" ",$RECORD_DELEGATION[$i]);

        print("<tr BGCOLOR=\"#FFFFFF\">\n");
        print("<td BGCOLOR=\"#990000\">\n");
        print("<center><font face=\"Verdana\" size=1 font color=\"#FFFFFF\"><B>Zone Delegation (NS)</B></font></center>\n");
        print("</td>\n");
        print("<td BGCOLOR=\"#FFFFFF\">\n");
        print("<center><font face=\"Verdana\" size=1 font color=\"#990000\"><B>$distvalue[0] &nbsp&nbsp NS &nbsp&nbsp $distvalue[1]</B></font></center>\n");
        print("</td>\n");
        print("<td>\n");
        print("<CENTER><INPUT type=\"TEXT\" name=\"delegationzone[$i]\" value=\"$distvalue[0]\" size=10>\n");
        print("<INPUT type=\"TEXT\" name=\"delegationns[$i]\" value=\"$distvalue[1]\" size=30></CENTER>\n");
        print("</td>\n");
        print("</tr>\n");
  }
        print("<tr BGCOLOR=\"#FFFFFF\">\n");
        print("<td BGCOLOR=\"#990000\">\n");
        print("<center><font face=\"Verdana\" size=1 font color=\"#FFFFFF\"><B>Zone Delegation (NS) (Add New)</B></font></center>\n");
        print("</td>\n");
        print("<td BGCOLOR=\"#FFFFFF\">\n");
        print("<center><font face=\"Verdana\" size=1 font color=\"#990000\"><B></B></font></center>\n");
        print("</td>\n");
        print("<td>\n");
        print("<CENTER><INPUT type=\"TEXT\" name=\"delegationzonenew\" value=\"\" size=10 >\n");
        print("<INPUT type=\"TEXT\" name=\"delegationnsnew\" value=\"\" size=30></CENTER>\n");
        print("</td>\n");
        print("</tr>\n");
	print("</table></center>\n");

        print("<center><table BORDER COLS=1 WIDTH=\"100%\" >\n");
        print("<tr>\n");
        print("<td BGCOLOR=\"#990000\">\n");
        print("<center>\n");
        print("<font face=\"Verdana\" size=2 font color=\"#FFFFFF\"><B>Other Info (Read Only)</B></font></center>\n");
        print("</td>\n");
        print("</tr>\n");
	print("<td BGCOLOR=\"#FFFFFF\">\n");
	print("<center><font face=\"Verdana\" size=1 font color=\"#990000\"><B>$otherinfo</B></font></center>\n");
        print("</td>\n");
	print("</tr>\n");
        print("</table></center>\n");

  if ($rdonly != 1) {
        print("<center><table BORDER=0 COLS=2 WIDTH=\"100%\" >\n");
        print("<tr BGCOLOR=\"#C0C0C0\">\n");

        print("<td>\n");
        print("<center><INPUT type=\"SUBMIT\" value=\"                       Modify                         \"></center>\n");
        print("</td>\n");
        print("<td>\n");
        print("<center><INPUT type=\"RESET\"  value=\"                       Restore                        \"></center>\n");
        print("</td>\n");
        print("</tr>\n");
        print("</table></center>\n");

        print("<center><table BORDER=0 COLS=1 WIDTH=\"100%\" >\n");
        print("<tr BGCOLOR=\"#C0C0C0\">\n");
        print("<td>\n");
        print("<center><font face=\"Verdana\" size=2 font color=\"#FFFFFF\"><A HREF=\"$phpbindurl\">Return to Search Page</A></center>\n");
        print("</td>\n");
        print("</tr>\n");
        print("</table></center>\n");

	print("<INPUT type=\"HIDDEN\" name=\"filelocation\" value=\"$dnsfile\">\n");
	print("<INPUT type=\"HIDDEN\" name=\"idserver\" value=\"$idserver\">\n");
	print("<INPUT TYPE=\"HIDDEN\" NAME=\"username\" VALUE=\"$user\">\n");
        print("</form>\n");
  } else {
	print("<center><table BORDER=0 COLS=1 WIDTH=\"100%\" >\n");
        print("<tr BGCOLOR=\"#C0C0C0\">\n");
	print("<td>\n");
	print("<center><font face=\"Verdana\" size=2 font color=\"#FFFFFF\"><A HREF=\"$phpbindurl\">Return to Search Page</A></center>\n");
	print("</td>\n");
        print("</tr>\n");
        print("</table></center>\n");
	print("</form>\n");
  }
}


/*
	Get request from resultdomain.php form about view|modify zone.
*/


if ( $zonechoose != "" ) {
	if (ereg("Read", $consulta)) {
			$readonly=1 ;
		} else {
			include("global.php");
			$zonelock=(end(explode("/", $zonechoose)));
			if ( file_exists("/tmp/$zonelock".".zonelock") && ( (time() - filemtime("/tmp/$zonelock".".zonelock")) < $zflto) ) {
				HTMLHeader();
				$wxzflto=( $zflto - (time() - filemtime("/tmp/$zonelock".".zonelock")) );
				Banner("Another user already working on requested zone. <BR>Zone will be available in $wxzflto secs.<BR><BR><A HREF=\"$phpbindurl\">Back to Search Page</A>\n",$username,$servername[$serverchoose]);
				print ("<BR><BR><BR><BR><HR>\n");
				exit();
			}
			if ( file_exists("/tmp/$zonelock".".zonelock") ) { unlink ("/tmp/$zonelock".".zonelock"); }
			session_register("zonelock");
			touch("/tmp/$zonelock".".zonelock");
		}
	ParseZone ($username,$idserver,$zonechoose,$readonly) ;
	}
 
?>
Return current item: WeBBind Web Gui to Bind