From 5038b2421872d5baacc1c1f4bd8b0c503adc656c Mon Sep 17 00:00:00 2001 From: sparc Date: Sun, 30 Apr 2006 15:06:10 +0000 Subject: [PATCH] added template for example.php and proxy support --- example.html | 50 +++++++++++++++++++++ example.php | 124 +++++++++++++++++++++++++-------------------------- 2 files changed, 112 insertions(+), 62 deletions(-) create mode 100755 example.html diff --git a/example.html b/example.html new file mode 100755 index 0000000..10b338a --- /dev/null +++ b/example.html @@ -0,0 +1,50 @@ + + + +whois.php -base classes to do whois queries with php + + + +
+Results for {query} :

+{result} +
+ + +
+ + +
+
+ + + + + + + + + +
+
+Enter any domain name, ip address or AS handle you would like to query whois for +



+ +
+
+ Show me regular output +

+ Show me HTMLized output +

+ Show me the returned PHP object +
+ +

+
+
+
+
+
+ + \ No newline at end of file diff --git a/example.php b/example.php index 9de0f22..b92619c 100644 --- a/example.php +++ b/example.php @@ -24,18 +24,14 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -?> - - - - -whois.php -base classes to do whois queries with php - - -deep_whois = false; @@ -60,77 +59,78 @@ if(isSet($_GET['query'])) // $whois->non_icann = true; $result = $whois->Lookup($query); - echo "
Results for $query :

"; - + + $resout = str_replace('{query}', $query, $resout); + switch ($output) { case 'object': if ($whois->Query['status'] < 0) { - echo implode($whois->Query['errstr'],"\n

"); + $winfo = implode($whois->Query['errstr'],"\n

"); } else { $utils = new utils; - echo $utils->showObject($result); + $winfo = $utils->showObject($result); } break; case 'nice': - if (!empty($result['rawdata'])) { + if (!empty($result['rawdata'])) + { $utils = new utils; - echo $utils->showHTML($result); + $winfo = $utils->showHTML($result); } - else { - echo implode($whois->Query['errstr'],"\n

"); + else + { + $winfo= implode($whois->Query['errstr'],"\n

"); } break; - + + case 'proxy': + if ($allowproxy) + exit(serialize($result)); + default: - if(!empty($result['rawdata'])) { - echo '
'.implode($result['rawdata'],"\n").'
'; + if(!empty($result['rawdata'])) + { + $winfo .= '
'.implode($result['rawdata'],"\n").'
'; } - else { - echo implode($whois->Query['errstr'],"\n

"); + else + { + $winfo = implode($whois->Query['errstr'],"\n

"); } } - echo '
'; + + $resout = str_replace('{result}', $winfo, $resout); } + +echo str_replace('{results}', $resout, $out); + +//------------------------------------------------------------------------- + +function extract_block (&$plantilla,$mark,$retmark='') +{ +$start = strpos($plantilla,''); +$final = strpos($plantilla,''); + +if ($start === false || $final === false) return; + +$ini = $start+7+strlen($mark); + +$ret=substr($plantilla,$ini,$final-$ini); + +$final+=8+strlen($mark); + +if ($retmark===false) + $plantilla=substr($plantilla,0,$start).substr($plantilla,$final); +else + { + if ($retmark=='') $retmark=$mark; + $plantilla=substr($plantilla,0,$start).'{'.$retmark.'}'.substr($plantilla,$final); + } + +return $ret; +} ?> - -
- - -
-
- - - - - - - - - -
-
-Enter any domain name, ip address or AS handle you would like to query whois for -



- -
-
- Show me regular output -

- Show me HTMLized output -

- Show me the returned PHP object -
- -

-
-
-
-
-
- - \ No newline at end of file