File: 1.01.2a/server/web/admin.dns.php (View as Code)

1: 2: /* ------------------------------------------------------------- 3: This file is part of FreeNATS 4: 5: FreeNATS is (C) Copyright 2008 PurplePixie Systems 6: 7: FreeNATS is free software: you can redistribute it and/or modify 8: it under the terms of the GNU General Public License as published by 9: the Free Software Foundation, either version 3 of the License, or 10: (at your option) any later version. 11: 12: FreeNATS is distributed in the hope that it will be useful, 13: but WITHOUT ANY WARRANTY; without even the implied warranty of 14: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15: GNU General Public License for more details. 16: 17: You should have received a copy of the GNU General Public License 18: along with FreeNATS. If not, see www.gnu.org/licenses 19: 20: For more information see www.purplepixie.org/freenats 21: -------------------------------------------------------------- */ 22: 23: ob_start(); 24: require("include.php"); 25: $NATS->Start(); 26: if (!$NATS_Session->Check($NATS->DB)) 27: { 28: header("Location: ./?login_msg=Invalid+Or+Expired+Session"); 29: exit(); 30: } 31: if ($NATS_Session->userlevel<9) UL_Error("Admin DNS Console"); 32: 33: Screen_Header("DNS Console",1,1); 34: 35: echo "
Simple DNS Query

";
36: 37: echo ""; 38: 39: if (isset($_REQUEST['question'])) $hostname=$_REQUEST['question']; 40: else $hostname=""; 41: 42: echo ""; 43: echo "
";
44: echo ""; 45: echo ""; 46: echo ""; 49: 50: echo ""; 51: echo "
";
52: echo ""; 53: echo ""; 54: echo ""; 57: 58: echo "
Get host by name : "; 47: echo ""; 48: echo "
Get host by address : "; 55: echo ""; 56: echo "
";
59: 60: if (isset($_REQUEST['gethostbyname'])) 61: { 62: $result=gethostbyname($hostname); 63: echo "
".$hostname." => ".$result;
64: if ($result==$hostname) echo " -- Lookup Failed"; 65: } 66: 67: if (isset($_REQUEST['gethostbyaddr'])) 68: { 69: $result=gethostbyaddr($hostname); 70: echo "
".$hostname." => ".$result;
71: if ($result=="") echo " -- Lookup Failed"; 72: } 73: 74: 75: echo "

Complex DNS Query

";
76: // ** IGNORE THIS - It's just the web form ** // 77: if (isset($_REQUEST['server'])) $server=$_REQUEST['server']; 78: else $server="127.0.0.1"; 79: if (isset($_REQUEST['port'])) $port=$_REQUEST['port']; 80: else $port=53; 81: if (isset($_REQUEST['timeout'])) $timeout=$_REQUEST['timeout']; 82: else $timeout=60; 83: if (isset($_REQUEST['tcp'])) $udp=false; 84: else $udp=true; 85: if (isset($_REQUEST['debug'])) $debug=true; 86: else $debug=false; 87: if (isset($_REQUEST['binarydebug'])) $binarydebug=true; 88: else $binarydebug=false; 89: if (isset($_REQUEST['extendanswer'])) $extendanswer=true; 90: else $extendanswer=false; 91: if (isset($_REQUEST['type'])) $type=$_REQUEST['type']; 92: else $type="A"; 93: if (isset($_REQUEST['question'])) $question=$_REQUEST['question']; 94: else $question="www.purplepixie.org"; 95: 96: echo ""; 97: echo "
";
98: echo ""; 99: echo ""; 119: echo "
"; 100: echo "Query :"; 101: echo ""; 102: echo " "; 103: echo ""; 113: echo "
"; 114: echo "Nameserver :"; 115: echo ""; 116: echo " "; 117: echo "port "; 118: echo "
Options :"; 120: 121: if (!$udp) $s=" checked"; 122: else $s=""; 123: echo " Use TCP
";
124: 125: if ($debug) $s=" checked"; 126: else $s=""; 127: echo " Debug Data
";
128: 129: if ($binarydebug) $s=" checked"; 130: else $s=""; 131: echo " Binary Debug
";
132: 133: if ($extendanswer) $s=" checked"; 134: else $s=""; 135: echo " Show Detail
";
136: echo "
 "; 137: echo "
";
138: echo "
";
139: 140: // ** HERE IS THE QUERY SECTION ** // 141: 142: if (isset($_REQUEST['doquery'])) 143: { 144: echo "
";
145: $query=new DNSQuery($server,$port,$timeout,$udp,$debug);
146: if ($binarydebug) $query->binarydebug=true;
147: 
148: if ($type=="SMARTA")
149: 	{
150: 	echo "Smart A Lookup for ".$question."\n\n";
151: 	$hostname=$query->SmartALookup($question);
152: 	echo "Result: ".$hostname."\n\n";
153: 	echo "
";
154: Screen_Footer(); 155: exit(); 156: } 157: 158: echo "Querying: ".$question." -t ".$type." @".$server."\n"; 159: 160: $result=$query->Query($question,$type); 161: 162: if ($query->error) 163: { 164: echo "\nQuery Error: ".$query->lasterror."\n\n"; 165: exit(); 166: } 167: echo "Returned ".$result->count." Answers\n\n"; 168: 169: function ShowSection($result) 170: { 171: global $extendanswer; 172: for ($i=0; $i<$result->count; $i++) 173: { 174: echo $i.". "; 175: if ($result->results[$i]->string=="") 176: echo $result->results[$i]->typeid."(".$result->results[$i]->type.") => ".$result->results[$i]->data; 177: else echo $result->results[$i]->string; 178: echo "\n"; 179: if ($extendanswer) 180: { 181: echo " - record type = ".$result->results[$i]->typeid." (# ".$result->results[$i]->type.")\n"; 182: echo " - record data = ".$result->results[$i]->data."\n"; 183: echo " - record ttl = ".$result->results[$i]->ttl."\n"; 184: if (count($result->results[$i]->extras)>0) // additional data 185: { 186: foreach($result->results[$i]->extras as $key => $val) 187: { 188: echo " + ".$key." = ".$val."\n"; 189: } 190: } 191: } 192: echo "\n"; 193: } 194: } 195: ShowSection($result); 196: 197: if ($extendanswer) 198: { 199: echo "\nNameserver Records: ".$query->lastnameservers->count."\n"; 200: ShowSection($query->lastnameservers); 201: 202: echo "\nAdditional Records: ".$query->lastadditional->count."\n"; 203: ShowSection($query->lastadditional); 204: } 205: 206: echo ""; 207: } 208: 209: 210: Screen_Footer(); 211: ?> 212: