|
|
|
|
|
|
| |
OK, I was thinking I'd make a script for recording access to my server when I got this Idea to make a script to display the info abt the users or the server or the running script. Pass the variable depending on the need
info.php
| /*********************************************
** class info
**
** Author.: leapinglangoor
** Date...: 9th April 2005
** version: v1.00
**
** Params.: You'll have to send a parameter $topic
** which can be:
**
** server
** user
** script
** all ( default )
**
** As the name suggests, they give info on the
** particular topics.
**
************************************************/
class info
{
function print_info( $topic = 'all' )
{
$list = array();
// Define the properties to be shown
// Modify it if needed
if( $topic == 'server' )
{
$list = array( 'SERVER_NAME', 'SERVER_SOFTWARE', 'SERVER_PROTOCOL', 'SERVER_PORT', 'SERVER_SIGNATURE' );
}
else if( $topic == 'user' )
{
$list = array( 'REMOTE_ADDR', 'REMOTE_HOST', 'REMOTE_PORT', 'HTTP_USER_AGENT', 'HTTP_REFFERER', 'HTTP_REQUEST', 'PHP_AUTH_USER', 'PHP_AUTH_PW' );
}
else if( $topic == 'script' )
{
$list = array( 'SCRIPT_FILENAME', 'SCRIPT_NAME', 'DOCUMENT_ROOT', 'QUERY_STRING', 'REQUEST_METHOD', 'REQUEST_TIME' );
}
else
{
$list = array( 'SERVER_NAME', 'SERVER_SOFTWARE', 'SERVER_PROTOCOL', 'SERVER_PORT', 'SERVER_SIGNATURE', 'REMOTE_ADDR', 'REMOTE_HOST', 'REMOTE_PORT', 'HTTP_USER_AGENT', 'HTTP_REFFERER', 'HTTP_REQUEST', 'PHP_AUTH_USER', 'PHP_AUTH_PW', 'SCRIPT_FILENAME', 'SCRIPT_NAME', 'DOCUMENT_ROOT', 'QUERY_STRING', 'REQUEST_METHOD', 'REQUEST_TIME' );
}
for( $i = 0; $i < count( $list ); $i++ )
{
echo $i . ' ' . $list[$i] . ' = ' . $_SERVER["$list[$i]"] . '<br />';
}
}
}
?> | |
Example:
| <?php
include( 'info.php' );
$i = new info;
$i->print_info( 'server' ); //You can also send user or script or all instead os server
?> | | |
|
| MySQL Handler Categories : PHP, Databases, MySQL, Classes and Objects, PHP Classes | | | ECHO-PHP Class Real Time Transaction Processor v1.4.4 for Credit Cards and
Checks / ACH Categories : PHP Classes, Cybercash, Classes and Objects, Ecommerce, PHP | | | Online Automatic Class Generator for MySQL Tables Categories : PHP, PHP Classes, Classes and Objects, Databases, MySQL | | | An efficient iterative and buffered text file reader Categories : PHP, Classes and Objects, Filesystem, PHP Classes, Log Files | | | Access_user Class - an easy to use system for protecting pages and register users. Categories : PHP, Classes and Objects, Object Oriented, PHP Classes, Authentication | | | Mssql database Manager Categories : PHP, Databases, MS SQL Server, Classes and Objects, PHP Classes | | | PHP CLASS for ORACLE (database connectivity) Categories : PHP, PHP Classes, Classes and Objects, Databases, Oracle | | | Reflection Examples - Their main goal is show how to use PHP's reflection classes re-implementing some php standard functions using reflection. Categories : PHP, PHP Classes, Classes and Objects | | | ClassFuncDoc - This script is a classes and functions documentation tool. Categories : PHP, Classes and Objects, Documentation, PHP Classes, Complete Programs | | | file class , uploade file , download file already uploaded on another website Categories : PHP, PHP Classes, Filesystem, Web Services | | | Authorize.net AIM Interface Class v1.0.0 Categories : PHP, PHP Classes, Ecommerce, Payment Gateways | | | crop and resize image class using gd library function Categories : PHP, PHP Classes, GD image library, Graphics | | | News management class Categories : PHP, PHP Classes, Beginner Guides | | | 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 | |
| | | | Ariel Filipiak wrote : 1310
Hello from Argentina
Excuse me cause I`m novice. Why the most of developers use classes when just a few funtions are needed?
Someone can answer me, please?
For example, the same process could be more simple and quickly in this way:
<?php
function print_info($topic = `all`) {
switch ($topic) {
case `server`:
$list = array( `SERVER_NAME`, `SERVER_SOFTWARE`, `SERVER_PROTOCOL`, `SERVER_PORT`, `SERVER_SIGNATURE` ); break;
case `user`:
$list = array( `REMOTE_ADDR`, `REMOTE_HOST`, `REMOTE_PORT`, `HTTP_USER_AGENT`, `HTTP_REFFERER`, `HTTP_REQUEST`, `PHP_AUTH_USER`, `PHP_AUTH_PW` ); break;
case `script`:
$list = array( `SCRIPT_FILENAME`, `SCRIPT_NAME`, `DOCUMENT_ROOT`, `QUERY_STRING`, `REQUEST_METHOD`, `REQUEST_TIME` ); break;
default:
$list = array( `SERVER_NAME`, `SERVER_SOFTWARE`, `SERVER_PROTOCOL`, `SERVER_PORT`, `SERVER_SIGNATURE`, `REMOTE_ADDR`, `REMOTE_HOST`, `REMOTE_PORT`, `HTTP_USER_AGENT`, `HTTP_REFFERER`, `HTTP_REQUEST`, `PHP_AUTH_USER`, `PHP_AUTH_PW`, `SCRIPT_FILENAME`, `SCRIPT_NAME`, `DOCUMENT_ROOT`, `QUERY_STRING`, `REQUEST_METHOD`, `REQUEST_TIME` );
}
for($i=0; $i<count($list); $i++ ) {
echo "$i.- $list[$i] = ".$_SERVER[$list[$i]]."<br>\n";
}
}
// Example:
print_info();
?>
Thank you
Ariel Filipiak
| | | | Boaz Yahav wrote :1311
I think that the best place to as this would be http://www.weberforums.com
| |
|
|
|