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
?>
Mssql database Manager Categories : PHP , Databases , MS SQL Server , 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 MySQL Handler Categories : PHP , Databases , MySQL , Classes and Objects , PHP Classes Access_user Class - an easy to use system for protecting pages and register users. Categories : PHP , Classes and Objects , Object Oriented , PHP Classes , Authentication ClassFuncDoc - This script is a classes and functions documentation tool. Categories : PHP , Classes and Objects , Documentation , PHP Classes , Complete Programs 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 Online Automatic Class Generator for MySQL Tables Categories : PHP , PHP Classes , Classes and Objects , Databases , MySQL PHP CLASS for ORACLE (database connectivity) Categories : PHP , PHP Classes , Classes and Objects , Databases , Oracle An efficient iterative and buffered text file reader Categories : PHP , Classes and Objects , Filesystem , PHP Classes , Log Files SPL and ITERATOR : examples Categories : PHP , Object Oriented , PHP Classes , Sessions Three Cool Classes and One Trick Categories : PHP , PHP Classes , Graphics , Email XTemplate, a template class for PHP Categories : PHP Classes , HTML and PHP , PHP call_user_method -- Call a user method on an specific object Categories : PHP , PHP Functions , Classes and Objects AutoRSS Categories : PHP , Rich Site Summary (RSS) , PHP Classes A Timing Class Categories : PHP , PHP Classes , Date Time
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