Viewing File server/web/admin.dns.php of 0.04.21a
|
1: <?php 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"); 34: 35: echo "<br><b class=\"subtitle\">Simple DNS Query</b><br><br>"; 36: 37: echo "<table class=\"nicetable\">"; 38: 39: if (isset($_REQUEST['question'])) $hostname=$_REQUEST['question']; 40: else $hostname=""; 41: 42: echo "<tr>"; 43: echo "<form action=admin.dns.php method=get>"; 44: echo "<input type=hidden name=gethostbyname value=1>"; 45: echo "<td>Get host by <b>name</b> :</td>"; 46: echo "<td><input type=text name=question size=30 value=\"".$hostname."\"> "; 47: echo "<input type=submit value=\"Go\">"; 48: echo "</td></tr></form>"; 49: 50: echo "<tr>"; 51: echo "<form action=admin.dns.php method=get>"; 52: echo "<input type=hidden name=gethostbyaddr value=1>"; 53: echo "<td>Get host by <b>address</b> :</td>"; 54: echo "<td><input type=text name=question size=30 value=\"".$hostname."\"> "; 55: echo "<input type=submit value=\"Go\">"; 56: echo "</td></tr></form>"; 57: 58: echo "</table>"; 59: 60: if (isset($_REQUEST['gethostbyname'])) 61: { 62: $result=gethostbyname($hostname); 63: echo "<br>".$hostname." => ".$result; 64: if ($result==$hostname) echo " -- Lookup Failed"; 65: } 66: 67: if (isset($_REQUEST['gethostbyaddr'])) 68: { 69: $result=gethostbyaddr($hostname); 70: echo "<br>".$hostname." => ".$result; 71: if ($result=="") echo " -- Lookup Failed"; 72: } 73: 74: 75: echo "<br><br><b class=\"subtitle\">Complex DNS Query</b><br><br>"; 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 "<table class=\"nicetable\">"; 97: echo "<form action=admin.dns.php method=get>"; 98: echo "<input type=hidden name=doquery value=1>"; 99: echo "<tr><td>"; 100: echo "Query :"; 101: echo "</td><td>"; 102: echo "<input type=text name=question size=50 value=\"".$question."\"> "; 103: echo "<select name=type>"; 104: echo "<option value=".$type.">".$type."</option>"; 105: echo "<option value=A>A</option>"; 106: echo "<option value=MX>MX</option>"; 107: echo "<option value=PTR>PTR</option>"; 108: echo "<option value=SOA>SOA</option>"; 109: echo "<option value=NS>NS</option>"; 110: echo "<option value=ANY>ANY</option>"; 111: echo "<option value=SMARTA>SmartA</option>"; 112: echo "</select>"; 113: echo "</td></tr><tr><td>"; 114: echo "Nameserver :"; 115: echo "</td><td>"; 116: echo "<input type=text name=server size=30 value=\"".$server."\"> "; 117: echo "port <input type=text name=port size=4 value=\"".$port."\">"; 118: echo "</td></tr><tr><td align=left valign=top>Options :</td>"; 119: echo "<td valign=top>"; 120: 121: if (!$udp) $s=" checked"; 122: else $s=""; 123: echo "<input type=checkbox name=tcp value=1".$s."> Use TCP<br>"; 124: 125: if ($debug) $s=" checked"; 126: else $s=""; 127: echo "<input type=checkbox name=debug value=1".$s."> Debug Data<br>"; 128: 129: if ($binarydebug) $s=" checked"; 130: else $s=""; 131: echo "<input type=checkbox name=binarydebug value=1".$s."> Binary Debug<br>"; 132: 133: if ($extendanswer) $s=" checked"; 134: else $s=""; 135: echo "<input type=checkbox name=extendanswer value=1".$s."> Show Detail<br>"; 136: echo "</td></tr><tr><td> </td><td>"; 137: echo "<input type=submit value=\"Perform DNS Query\"><br>"; 138: echo "</td></tr></table>"; 139: 140: // ** HERE IS THE QUERY SECTION ** // 141: 142: if (isset($_REQUEST['doquery'])) 143: { 144: echo "<pre>"; 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 "</pre>"; 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 "</pre>"; 207: } 208: 209: 210: Screen_Footer(); 211: ?> 212: