Location: PHPKode > projects > WeBBind Web Gui to Bind > webbind_0.98/parser.php
<?

function ParseZone($user,$idserver,$dnsfile,$readonly) {

 $fp = fopen ("$dnsfile", "r");

 while (!feof ($fp)) {
        $buffer = fgets($fp, 4096);

        if ( (substr ($buffer, 0, 1) != ";") && (stristr ($buffer, "serial number")) ) {
                $exprow = explode(";", $buffer);
                $RECORD_SERIAL = trim($exprow[0]);

        } elseif ( (substr ($buffer, 0, 1) != ";") && (substr ($buffer, 0, 1) == chr(32) || substr ($buffer, 0, 1) == chr(9)  || substr ($buffer, 0, 1) == "@" ) && (ereg("NS", $buffer)) ) {
                $exprow = explode("NS", $buffer);
                $RECORD_NS[] = trim(end($exprow));

        } elseif ( (substr ($buffer, 0, 1) != ";") && (substr ($buffer, 0, 1) != "@") && (substr ($buffer, 0, 1) != chr(9)) && (ereg("(".chr(32).")(NS{1})|(".chr(9).")(NS{1})", $buffer)) ) {
                $exprow = split("[\"".chr(32)."\"\"".chr(9)."\"]", $buffer);
                $RECORD_DELEGATION[] .= (trim($exprow[0])." ".trim(end($exprow)));

        } elseif ( (substr ($buffer, 0, 1) != ";") && (ereg("MX", $buffer)) ) {
                $exprow = explode("MX", $buffer);
                $RECORD_MX[] = trim($exprow[0])." ".trim($exprow[1]);

        } elseif ( (substr ($buffer, 0, 1) != ";") && (ereg("(".chr(32).")(A{1})|(".chr(9).")(A{1})", $buffer)) ) {
                $exprow = split("[\"".chr(32)."\"\"".chr(9)."\"]", $buffer);
                $RECORD_A[] = (trim($exprow[0])." ".trim(end($exprow)));

        } elseif ( (substr ($buffer, 0, 1) != ";") && (ereg("CNAME", $buffer)) ) {
                $exprow = explode("CNAME", $buffer);
                $RECORD_CNAME[] = (trim($exprow[0])." ".trim($exprow[1]));

        } elseif ( (substr ($buffer, 0, 1) != ";") && (ereg("(".chr(32).")(PTR{1})|(".chr(9).")(PTR{1})", $buffer)) ) {
                $exprow = split("[\"".chr(32)."\"\"".chr(9)."\"]", $buffer);
                $RECORD_PTR[] = (trim($exprow[0])." ".trim(end($exprow)));

        } else {
                if ( (substr ($buffer, 0, 1) != ";") || (ereg("user", $buffer)) ) { $otherinfo .= "$buffer<BR>"; }

        }
 }

 fclose ($fp);

ModifyZone($RECORD_SERIAL,$RECORD_NS,$RECORD_DELEGATION,$RECORD_MX,$RECORD_A,$RECORD_CNAME,$RECORD_PTR,$otherinfo,$idserver,$dnsfile,$readonly,$user) ;

/*
        print "<h4>";
        print ("Serial: ".$RECORD_SERIAL."<BR>");
        print ("NameServer01: ".($RECORD_NS[0]."<BR>"));
        print ("NameServer02: ".($RECORD_NS[1]."<BR>"));
        print ("Glue Record: ".($RECORD_DELEGATION."<BR>"));

        print ("MX Record01: ".($RECORD_MX[0]."<BR>"));
        print ("MX Record02: ".($RECORD_MX[1]."<BR>"));
        print ("MX Record02: ".($RECORD_MX[2]."<BR>"));
        print ("MX Record02: ".($RECORD_MX[3]."<BR>"));
        print ("MX Record02: ".($RECORD_MX[4]."<BR>"));
        print ("MX Record02: ".($RECORD_MX[5]."<BR>"));


$distvalue = split("(   +)|( +)",$RECORD_MX[4]);
print $distvalue[0];
print "<BR>";
print $distvalue[1];
print "<BR>";
print $distvalue[2];


        print ("Record A01: ".($RECORD_A[0]."<BR>"));
        print ("Record A01: ".($RECORD_A[1]."<BR>"));
        print ("Record A01: ".($RECORD_A[2]."<BR>"));
        print ("Record CNAME01: ".($RECORD_CNAME[0]."<BR>"));
        print ("Record CNAME02: ".($RECORD_CNAME[1]."<BR>"));
        print ($dnsfile."<BR>");
        print ("Record PTR01: ".($RECORD_PTR[0]."<BR>"));
        print ("Record PTR01: ".($RECORD_PTR[1]."<BR>"));
        print ("Record PTR01: ".($RECORD_PTR[2]."<BR>"));
        print ($otherinfo);

*/

}

?>
Return current item: WeBBind Web Gui to Bind