WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : WHOIS is a class to make your life easier in case you use a lot of APACHE PREDEFINED VARIABLES.
Categories : PHP, PHP Classes Update Picture
Maxim Maletsky
Date : Oct 06th 2000
Grade : Be the 1st to grade this Code Example
Viewed : 3128
File : whois.php
Images : No Images for this code example.
Search : More code by Maxim Maletsky
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

<html><head><title>Whois</title>
<STYLE TYPE="text/css"><!--
.style {font-family:Verdana;color:#A40000;font-size:10px;line-height:12px}
.style A:link { text-decoration: none; color: #990000 }
.style A:visited { text-decoration: none; color: #990000 }
.style A:hover { text-decoration: none; color: #FF3300 }
.head {font-family:Verdana;color: #FF9900;font-size:24px} --></STYLE>
</head>

<span class="head"><B>Whois</B></span><span class="style"><br>by <A
HREF="mailto:maxim@maxim.cx">Maxim Maletsky</A>

<?
/*
* WHOIS
* Whois is just an easier way to use Predefined Variables;
*
* Class tested on Linux running PHP 4.0.1pl2.
* Load Time: approximatly 3 milliseconds.
*
* COPYRIGHT
* Copyright (C) 2000,
* Maxim Maletsky, [maxim.maletsky@lincmedia.co.jp],
* LINC Media Inc., J-Door.com, J@pan Inc.
*
* LICENCE
* This software is FREEWARE. Do with it what you want to, as long as
* the copyright notice remains intact.
*
* DISCLAIMER
* Do not blaim me for anything that my software could do wrong.
* It's a FREE software - respect it!
*
* If you redistribute this code please mention in your script my info (Name & Email) as it's
creator.
* If you are using this code please send me your feedback and your improvements to it.
*/

class whois
{
        function ip()
        {
                if (getenv(HTTP_X_FORWARDED_FOR))
                        return getenv(HTTP_X_FORWARDED_FOR);
                else
                        return getenv(REMOTE_ADDR);
        }

        function whois($who='name', $data='')
        {
                Global $PHP_SELF;
                if($who == 'ip')
                        $is = $this->ip();
                
                elseif($who == 'dns')
                        $is = gethostbyaddr($this->ip());
                
                elseif($who == 'user')
                        $is = getenv('HTTP_USER_AGENT');
                
                elseif($who == 'uri')
                        $is = getenv('REQUEST_URI');
                
                elseif($who == 'ref')
                        $is = getenv('HTTP_REFERER');

                elseif($who == 'query')
                        $is = getenv('QUERY_STRING');

                elseif($who == 'host')
                        $is = getenv('HTTP_HOST');

                elseif($who == 'root')
                        $is = getenv('DOCUMENT_ROOT');

                elseif($who == 'name')
                        $is = getenv('SCRIPT_NAME');

                elseif($who == 'self')
                        $is = $PHP_SELF;

                elseif($who == 'path')
                        $is = getenv('SCRIPT_FILENAME');

                return $is;
        }
}

$whois = new whois;

echo '<HR size="1" color="#000000">';
                        
echo '( <B>ip</B> ) => <B>'.$whois->whois('ip').'</B><BR>';
echo '( <B>dns</B> ) => <B>'.$whois->whois('dns').'</B><BR>';
echo '( <B>user</B> ) => <B>'.$whois->whois('user').'</B><BR>';
echo '( <B>uri</B> ) => <B>'.$whois->whois('uri').'</B><BR>';
echo '( <B>ref</B> ) => <B>'.$whois->whois('ref').'</B><BR>';
echo '( <B>query</B> ) => <B>'.$whois->whois('query').'</B><BR>';
echo '( <B>host</B> ) => <B>'.$whois->whois('host').'</B><BR>';
echo '( <B>root</B> ) => <B>'.$whois->whois('root').'</B><BR>';
echo '( <B>name</B> ) => <B>'.$whois->whois('name').'</B><BR>';
echo '( <B>self</B> ) => <B>'.$whois->whois('self').'</B><BR>';
echo '( <B>path</B> ) => <B>'.$whois->whois('path').'</B><BR>';
                                

/*
* You of course can add more here and there...
* To use this class
* just remove every line that is not needed like this examples,
* then add/remove the Enviroment variables to your own needs,
* include and define Whois everywhere you need it (better in a configuration file)
*
* and go wild: examples of use are above!
*
* mail me at maxim@maxim.cx or webmaster@j-door.com if you have any questions
*/

echo '<HR size="1" color="#000000">';

?>


<p>Basically, there's no particular reason to use this class, since it doesn't do much.<br>
However classes when included work faster then just a function call from a script.

<p>Few reasons to use Whois:

<ol>
<li>It is much easier call a class to get an Apache predefined variable then look manuals each
time and test it.
<li>You can modify the class to do more complicated things while you still writing the same call
to it.<br>
<ul><li>Means: you modify one file and all the pages are using it
</ol>
Dynamic, Simple, Usable...

<br>Cheers!

<BR><HR size="1" color="#000000"><HR size="1" color="#000000"><BR>

<P>Tests Made:
<PRE>

Tests were done on a Linux Box, 133 MHz, 32 MB RAM, PHP4.0.1pl2

Interval Name                ( Lines )                Process Time( Milliseconds )
--------------------------------------------------------------------------------
ip                 Between line 88 and 89                 0.247
--------------------------------------------------------------------------------
dns                 Between line 89 and 90                 1.155
--------------------------------------------------------------------------------
user                 Between line 90 and 91                 0.193
--------------------------------------------------------------------------------
uri                 Between line 91 and 92                 0.182
--------------------------------------------------------------------------------
ref                 Between line 92 and 93                 0.212
--------------------------------------------------------------------------------
query                 Between line 93 and 94                 0.187
--------------------------------------------------------------------------------
host                 Between line 94 and 95                 0.188
--------------------------------------------------------------------------------
name                 Between line 95 and 96                 0.173
--------------------------------------------------------------------------------
self                 Between line 96 and 97                 0.188
--------------------------------------------------------------------------------
path                 Between line 97 and 98                 0.197
--------------------------------------------------------------------------------

                                Total Execution Time : 3.317
</PRE></span>



very simple ftp class
Categories : PHP, PHP Classes, FTP
PHP Paypal IPN Integration Class v1.0.0
Categories : PHP, PHP Classes, Payment Gateways
A Timing Class
Categories : PHP, PHP Classes, Date Time
The class to check load time of your script VERY usefull for relatively slow applications, but not only..
Categories : PHP, PHP Classes, Debugging
Create HTML forms dynamicly using Javascript & PHP
Categories : PHP, PHP Classes, Java Script
usercounter class
Categories : PHP, PHP Classes, Databases, MySQL, Environment Variables
RSS parser. Parses RSS into an array. Quick and nasty but does the job. No checking is done for correct Tags, only correct XML. PHP4 needed to display result (uses print_r).
Categories : PHP, XML, PHP Classes, Rich Site Summary (RSS)
These PHP Classes Check if a host is alive using various methods.
Categories : PHP, PHP Classes, Sockets, CURL
an example of the cyberlib payment class
Categories : PHP, PHP Classes, Ecommerce, Credit Cards
Power Form Validation
Categories : PHP, PHP Classes, Data Validation
MySQL Handler
Categories : PHP, Databases, MySQL, Classes and Objects, PHP Classes
pcCalendar class - Allows for the creation of calendars in HTML pages. All output functions can be easily overridden, refer to article 1471 for an example.
Categories : PHP, Date Time, Calendar, PHP Classes
Class for sending mail with MIME attachments in multipart format using external sendmail, mimencode and zip
Categories : Email, Network, PHP, PHP Classes
A PHP Calendar function with CSS : add a cool calendar to any php page by just adding a calendar class based function.
Categories : PHP, PHP Classes, Calendar, Date Time
Browser Detecor Class
Categories : PHP Classes, PHP, HTML