Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 01-19-2003, 09:15 AM
webhost's Avatar
webhost webhost is offline
 
Join Date: Oct 2001
Location: St. Louis
Posts: 577
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default PHP / HTML Trace

Small problem we need help with go to this url http://realwebhost.net/trace.php you will see a header and footer.php file that is used as a php include in the file below. All looks right on page now try the program. You will see the results come back but they will be put underneath the footer. We have tried taking the footer.php include file and moving it to the end of the file. When we do this the normal page will not show the footer but when you run the program the results will come back and then the footer comes in showing on the bottom underneath the results like it should. Any ideas?

PHP Code:
<?

include("./header.php");
#######################################################################
#nqt.php last revised    11/15/02 ([url]http://www.shat.net/php/nqt/[/url])      #
#        Initial release 03/11/01                                     # 
#                                                                     #
#Version 1.5                                                          #
#11/15: Adjusted the domain name regex to support 4-letter TLDs such  #
#as .info, and added WWWhois support for the .info, .name, .cc, .ws,  #
#.us, and .biz TLDs. Thanks to Andre from reload.de for the great     #
#suggestion!                                                          #
#                                                                     #
#Version 1.4                                                          #
#08/31: Added support for HTTP GET variables. You can now access your #
#copy of NQT and pass some variables within the URL, e.g.             #
#[url]http://your.host/nqt.php?target=shat.net&queryType=wwwhois[/url]           #
#[url]http://your.host/nqt.php?target=shat.net&queryType=all&portNum=80[/url]    #
#Credit to hypersven.com for this suggestion!                         #
#                                                                     #
#Version 1.3                                                          #
#06/28: PHP 4.20+ sets register_globals to "off" by default. This     #
#script expects them to be "on." Added a workaround.                  #
#                                                                     #
#Version 1.2                                                          #
#03/01: The behavior of the gethostbyaddr() function appears to have  #
#changed in PHP 4.12, it no longer accepts hostnames in fqdn format.  #
#(This is how it really should work anyway, I think the old behavior  #
#was a bug.) Previous versions of NQT relied upon the fact that the   #
#gethostbyaddr() function would accept a hostname. If you're getting  #
#errors about addresses not being in a.b.c.d format, please download  #
#and install this version of the script.                              #
#                                                                     #
#Version 1.1                                                          #
#10/30: Security update, thanks Dmitry Frolov, Mathijs Futselaar.     #
#Previous versions of script allowed possible execution of arbitrary  #
#commands on the host system. Updated lines marked with #bugfix, code #
#courtesy Dmitry Frolov.                                              #
#                                                                     #
#COPYRIGHT [email]shaun@shat.net[/email] - If you use this script, the copyright     #
#notice appended to query results MUST remain INTACT and UNALTERED,   #
#including the link to the distribution site [url]http://shat.net/php/nqt/[/url] #
#This script is free, but you may NOT claim it as your own.           #
#                                                                     #
#Requires: PHP3+, unix server preferred                               #
#                                                                     #
#This script takes a given hostname or IP address and attempts to     #
#look up all sorts of information about that address. Basically       #
#it does what network-tools.com does, without all the ads and ASP :)  #
#                                                                     #
#The following steps can be performed separately or all at once:      #
#                                                                     #
# reverse DNS lookup, DNS query (dig), WWW whois, ARIN whois,         #
# open-port check, ping, traceroute                                   #
#                                                                     #
#As you can probably guess this script is intended for unix machines. #
#If you use this script under win32, DNS query (dig) will not work.   #
#                                                                     #
#NO INITIAL CONFIGURATION IS REQUIRED. THERE ARE NO VARIABLES TO SET. #
#                                                                     #
#If you encounter problems with traceroute, replace the default path  #
#/usr/sbin/traceroute with the correct path in the tr() function.     #
######################################################################$

#Until I rewrite my scripts, this will suffice for compatibility
if(phpversion() >= "4.2.0"){
   extract($_POST);
   extract($_GET);
   extract($_SERVER);
   extract($_ENV);
}
?>
<html>
<head>
<title>Real Web Host Network Query Tool</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script>
function m(el) {
  if (el.defaultValue==el.value) el.value = ""
}
</script>
</head>

<body bgcolor="#FFFFFF">
<div align="center"> 
  <h2>Real Web Host Network Query Tool</h2>
  <form method="post" action="<? echo $PHP_SELF; ?>">
    <table width="60%" border="0" cellspacing="0" cellpadding="1">
      <tr bgcolor="#ffffff"> 
        <td width="50%" bgcolor="#ffffff"><font size="2" face="Verdana, Arial, Helvetica, sans-serif" color="#616161"><b>Host 
          Information</b></font></td>
        <td bgcolor="#ffffff"><font size="2" face="Verdana, Arial, Helvetica, sans-serif" color="#616161"><b>Host 
          Connectivity</b></font></td>
      </tr>
      <tr valign="top" bgcolor="#ffffff"> 
        <td> 
          <p><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
            <input type="radio" name="queryType" value="lookup" class="white">
            Resolve/Reverse Lookup<br>
            <input type="radio" name="queryType" value="dig" class="white">
            Get DNS Records<br>
            <input type="radio" name="queryType" value="wwwhois" class="white">
            Whois (Web)<br>
            <input type="radio" name="queryType" value="arin" class="white">
            Whois (IP owner)</font></p>
        </td>
        <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
          <input type="radio" name="queryType" value="checkp" class="white">
          Check port: 
          <input type="text" name="portNum" size="5" maxlength="5" value="80">
          <br>
          <input type="radio" name="queryType" value="p" class="white" style="color: #FFFFFF">
          Ping host<br>
          <span style="background-color: #FFFFFF"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">
          <input type="radio" name="queryType" value="all" class="white" name="queryType" value="all" class="white" checked radio" style="color: #FFFFFF">
          </font></span> Do it all</font></td>

      </tr>
      
      </table>
  <table width="60%" border="0" cellspacing="0" cellpadding="1"><tr bgcolor="#ffffff"> 
        <td colspan="2">
          <div align="center">
            <input type="text" name="target" 
value="Enter host or IP" onFocus="m(this)">
            <input type="submit" name="Submit" value="Do It">
          </div>
        </td>
      </tr>
    </table>
  </form>
</div> 
<?php
include("./footer.php");
?>
<?

#Global kludge for new gethostbyaddr() behavior in PHP 4.1x
$ntarget = "";
#Some functions

function message($msg){
echo "<font face=\"verdana,arial\" size=2>$msg</font>";
flush();
}

function lookup($target){
global $ntarget;
$msg = "$target resolved to ";
if( eregi("[a-zA-Z]", $target) )
  $ntarget = gethostbyname($target);
else
  $ntarget = gethostbyaddr($target);
$msg .= $ntarget;
message($msg);
}

function dig($target){
global $ntarget;
message("<p><b>DNS Query Results:</b><blockquote>");
#$target = gethostbyaddr($target);
#if (! eregi("[a-zA-Z]", ($target = gethostbyaddr($target))) )
if( (!eregi("[a-zA-Z]", $target) && (!eregi("[a-zA-Z]", $ntarget))))
  $msg .= "Can't do a DNS query without a hostname.";
else{
  if(!eregi("[a-zA-Z]", $target)) $target = $ntarget;
  if (! $msg .= trim(nl2br(`dig any '$target'`))) #bugfix
    $msg .= "The <i>dig</i> command is not working on your system.";
  }
#TODO: Clean up output, remove ;;'s and DiG headers
$msg .= "</blockquote></p>";
message($msg);
}

function wwwhois($target){
global $ntarget;
$server = "whois.crsnic.net";
message("<p><b>WWWhois Results:</b><blockquote>");
#Determine which WHOIS server to use for the supplied TLD
if((eregi("\.com\$|\.net\$|\.org\$|\.edu\$", $target)) || (eregi("\.com\$|\.net\$|\.org\$|\.edu\$", $ntarget)))
  $server = "whois.crsnic.net";
else if((eregi("\.info\$", $target)) || (eregi("\.info\$", $ntarget)))
  $server = "whois.afilias.net";
else if((eregi("\.name\$", $target)) || (eregi("\.name\$", $ntarget)))
  $server = "whois.nic.name";
else if((eregi("\.biz\$", $target)) || (eregi("\.biz\$", $ntarget)))
  $server = "whois.nic.biz";
else if((eregi("\.us\$", $target)) || (eregi("\.us\$", $ntarget)))
  $server = "whois.nic.us";
else if((eregi("\.cc\$", $target)) || (eregi("\.cc\$", $ntarget)))
  $server = "whois.enicregistrar.com";
else if((eregi("\.ws\$", $target)) || (eregi("\.ws\$", $ntarget)))
  $server = "whois.nic.ws";
else{
  $msg .= "I only support .com, .net, .org, .edu, .info, .name, .us, .cc, .ws, and .biz.</blockquote>";
  message($msg);
  return;
}

message("Connecting to $server...<br><br>");
if (! $sock = fsockopen($server, 43, $num, $error, 10)){
  unset($sock);
  $msg .= "Timed-out connecting to $server (port 43)";
}
else{
  fputs($sock, "$target\n");
  while (!feof($sock))
    $buffer .= fgets($sock, 10240); 
}
 fclose($sock);
 if(! eregi("Whois Server:", $buffer)){
   if(eregi("no match", $buffer))
     message("NOT FOUND: No match for $target<br>");
   else
     message("Ambiguous query, multiple matches for $target:<br>");
 }
 else{
   $buffer = split("\n", $buffer);
   for ($i=0; $i<sizeof($buffer); $i++){
     if (eregi("Whois Server:", $buffer[$i]))
       $buffer = $buffer[$i];
   }
   $nextServer = substr($buffer, 17, (strlen($buffer)-17));
   $buffer = "";
   message("Deferred to specific whois server: $nextServer...<br><br>");
   if(! $sock = fsockopen($nextServer, 43, $num, $error, 10)){
     unset($sock);
     $msg .= "Timed-out connecting to $nextServer (port 43)";
   }
   else{
     fputs($sock, "$target\n");
     while (!feof($sock))
       $buffer .= fgets($sock, 10240);
     fclose($sock);
   }
}
$msg .= nl2br($buffer);
$msg .= "</blockquote></p>";
message($msg);
}

function arin($target){
$server = "whois.arin.net";
message("<p><b>IP Whois Results:</b><blockquote>");
if (!$target = gethostbyname($target))
  $msg .= "Can't IP Whois without an IP address.";
else{
  message("Connecting to $server...<br><br>");
  if (! $sock = fsockopen($server, 43, $num, $error, 20)){
    unset($sock);
    $msg .= "Timed-out connecting to $server (port 43)";
    }
  else{
    fputs($sock, "$target\n");
    while (!feof($sock))
      $buffer .= fgets($sock, 10240); 
    fclose($sock);
    }
   if (eregi("RIPE.NET", $buffer))
     $nextServer = "whois.ripe.net";
   else if (eregi("whois.apnic.net", $buffer))
     $nextServer = "whois.apnic.net";
   else if (eregi("nic.ad.jp", $buffer)){
     $nextServer = "whois.nic.ad.jp";
     #/e suppresses Japanese character output from JPNIC
     $extra = "/e";
     }
   else if (eregi("whois.registro.br", $buffer))
     $nextServer = "whois.registro.br";
   if($nextServer){
     $buffer = "";
     message("Deferred to specific whois server: $nextServer...<br><br>");
     if(! $sock = fsockopen($nextServer, 43, $num, $error, 10)){
       unset($sock);
       $msg .= "Timed-out connecting to $nextServer (port 43)";
       }
     else{
       fputs($sock, "$target$extra\n");
       while (!feof($sock))
         $buffer .= fgets($sock, 10240);
       fclose($sock);
       }
     }
  $buffer = str_replace(" ", "&nbsp;", $buffer);
  $msg .= nl2br($buffer);
  }
$msg .= "</blockquote></p>";
message($msg);
}

function checkp($target,$portNum){
message("<p><b>Checking Port $portNum</b>...<blockquote>");
if (! $sock = fsockopen($target, $portNum, $num, $error, 5))
  $msg .= "Port $portNum does not appear to be open.";
else{
  $msg .= "Port $portNum is open and accepting connections.";
  fclose($sock);
  }
$msg .= "</blockquote></p>";
message($msg);
}

function p($target){
message("<p><b>Ping Results:</b><blockquote>");
if (! $msg .= trim(nl2br(`ping -c5 '$target'`))) #bugfix
  $msg .= "Ping failed. Host may not be active.";
$msg .= "</blockquote></p>";
message($msg);
}

function tr($target){
message("<p><b>Traceroute Results:</b><blockquote>");
if (! $msg .= trim(nl2br(`/usr/sbin/traceroute '$target'`))) #bugfix
  $msg .= "Traceroute failed. Host may not be active.";
$msg .= "</blockquote></p>";
message($msg);
}


#If the form has been posted, process the query, otherwise there's 
#nothing to do yet

if(!$queryType)
  exit;

#Make sure the target appears valid

if( (!$target) || (!preg_match("/^[\w\d\.\-]+\.[\w\d]{1,4}$/i",$target)) ){ #bugfix
  message("Error: You did not specify a valid target host or IP.");
  exit;
  }

#Figure out which tasks to perform, and do them

if( ($queryType=="all") || ($queryType=="lookup") )
  lookup($target);
if( ($queryType=="all") || ($queryType=="dig") )
  dig($target);
if( ($queryType=="all") || ($queryType=="wwwhois") )
  wwwhois($target);
if( ($queryType=="all") || ($queryType=="arin") )
  arin($target);
if( ($queryType=="all") || ($queryType=="checkp") )
  checkp($target,$portNum);
if( ($queryType=="all") || ($queryType=="p") )
  p($target);
if( ($queryType=="all") || ($queryType=="tr") )
  tr($target);
?>
Reply With Quote
  #2  
Old 01-19-2003, 04:33 PM
Neo's Avatar
Neo Neo is offline
 
Join Date: Oct 2001
Location: Anywhere
Posts: 1,817
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It could just be me but it seems to work fine on your site now.. but if you notice that footer is in the middle of the page.. which you might guess is why it would apear above the search info.
Reply With Quote
  #3  
Old 01-19-2003, 04:50 PM
webhost's Avatar
webhost webhost is offline
 
Join Date: Oct 2001
Location: St. Louis
Posts: 577
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Real quick here, read my post above please it will explain to you the problem. set it up where footer shows you do results info shows up under footer, code where footer does not show results come up then footer would like it to show footer and when results given be above footer where footer could show all the time. show footer results underneath is code I posted above, no footer results then footer is what i have it coded to at site now
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:52 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04008 seconds
  • Memory Usage 2,278KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (3)post_thanks_box
  • (3)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit_info
  • (3)postbit
  • (3)postbit_onlinestatus
  • (3)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete