|
Page 1 of 1
|
fucile
Joined: October 2006
Posts: 56
|
Analisys For Luca
Thanks in advance
I'm creating a user info block and I'm putting the functions computed by $ _SERVER
function GetIp()
{
$ip = array(
'127.0.0.1' => 'Local Host',
'151' => 'Libero Infostrada',
'87' => 'Telecom Italia',
'93' => 'Tele2 Adsl',
);
foreach($ip as $ip_string => $get_ip_string)
{
if(strpos($_SERVER['REMOTE_ADDR'], $ip_string ))
{
return $get_ip_string;
}
}
return 'Sconosciuto';
}
On my Machine when call explorer or other browser returned " Sconosciuto " instead " Local Host ".
Can you help me understand?
Hi Fabrizio
|
#1 Sat 24 Oct, 2009 08:13 |
|
Sponsors
|
Icy Phoenix is an open source project, you can show your appreciation and support future development by donating to the project.
|
|
Informpro
Joined: October 2008
Posts: 1110
Location:
|
Re: Analisys For Luca
use this function instead (for get IP address):
-
function get_ip()
-
{
-
if($_SERVER)
-
{
-
if($_SERVER['HTTP_X_FORWARDED_FOR'])
-
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
-
elseif($_SERVER['HTTP_CLIENT_IP'])
-
$ip = $_SERVER['HTTP_CLIENT_IP'];
-
else
-
$ip = $_SERVER['REMOTE_ADDR'];
-
}
-
else
-
{
-
if(getenv('HTTP_X_FORWARDED_FOR'))
-
$ip = getenv('HTTP_X_FORWARDED_FOR');
-
elseif(getenv('HTTP_CLIENT_IP'))
-
$ip = getenv('HTTP_CLIENT_IP');
-
else
-
$ip = getenv('REMOTE_ADDR');
-
}
-
-
return $ip;
-
}
and for the foreach, use this instead: -
$ip_user = get_ip();
-
$key_ip_user = explode('.', $ip_user);
-
foreach($ip as $ip_string => $get_ip_string)
-
{
-
if(in_array($ip_string, $key_ip_user))
-
{
-
return $get_ip_string;
-
break;
-
}
-
}
|
#2 Sat 24 Oct, 2009 09:15 |
|
fucile
Joined: October 2006
Posts: 56
|
Re: Analisys For Luca
I want this script that works in this way
An array take the first three digits of IP and try to associate the name
Example
151.XXX => Libero Infostrada echo in tpl: Libero Infostrada
If I wanted just the ip only associate the variable
$ _SERVER [REMOTE_ADDR]
|
#3 Sat 24 Oct, 2009 17:32 |
|
Mighty Gorgon
Luca Libralato
Joined: August 2006
Posts: 7191
Location: Borgo San Michele
|
Re: Analisys For Luca
You need to use the explode function to be able to match only the first triplet.
$ip_parts = explode('.', $ip_address);
In this way you can match any part of the IP with a condition like this:
if ($ip_parts[0] == '151')
{
$provider = 'Libero';
}
____________ Luca
SEARCH is the quickest way to get support.
Icy Phoenix ColorizeIt - CustomIcy - HON
|
#4 Mon 26 Oct, 2009 15:48 |
|
fucile
Joined: October 2006
Posts: 56
|
Re: Analisys For Luca
Thanks Luca
I knew that I'd been of assistance
Hello Fucile
|
#5 Mon 26 Oct, 2009 21:53 |
|
fucile
Joined: October 2006
Posts: 56
|
Re: Analisys For Luca
This is the last script for the info_block User
Who is error ?
blocks_imp_info.php
<?php
/**
*
* @package Icy Phoenix
* @version $Id: blocks_imp_info.php 61 2008-10-30 09:25:26Z Mighty Gorgon $
* @copyright (c) 2008 Icy Phoenix
* @license http://opensource.org/licenses/GPL-license.php GNU Public License
*
*/
/**
*
* @Extra credits for this file
* name: fucile - Fabrizio Di Silvestro
* url: http://www.fabriziodisilvestro.org/
*/
if (!defined('IN_ICYPHOENIX'))
{
die('Hacking attempt');
}
$os_system = array(
// Array Windows
'Windows NT 6.1' => array(
'img' => 'images/http_agents/os/winlong.png',
'name' => 'Windows Seven'
),
'Windows NT 6.0' => array(
'img' => 'images/http_agents/os/winlong.png',
'name' => 'Windows Vista'
),
'Windows NT 5.2' => array(
'img' => 'images/http_agents/os/win2003.png',
'name' => 'Windows 2003'
),
'Windows NT 5.1' => array(
'img' => 'images/http_agents/os/winxp.png',
'name' => 'Windows XP'
),
'Windows NT 5.0' => array(
'img' => 'images/http_agents/os/win2000.png',
'name' => 'Windows 2000'
),
'Windows NT 4.9' => array(
'img' => 'images/http_agents/os/winme.png',
'name' => 'Windows Millenium'
),
'Win' => array(
'img' => 'images/http_agents/os/win.png',
'name' => 'Windows'
),
// Array Mac
'Mac' => array(
'img' =>'images/http_agents/os/macosx.png',
'name' => 'Apple I-Mac'
),
'PPC' => array(
'img' => 'images/http_agents/os/mac.png',
'name' => 'Apple Power-Pc'
),
// Array Linux
'Unix' => array(
'img' => 'images/http_agents/os/unix.png',
'name' => 'Unix System'
),
'Linux' => array(
'img' => 'images/http_agents/os/linux.png',
'name' => 'Linux'
),
'SuSE' => array(
'img' => 'images/http_agents/os/suse.png',
'name' => 'SUSE Linux'
),
'Slackware' => array(
'img' => 'images/http_agents/os/slackware.png',
'name' => 'Slackware'
),
'Mandrake' => array(
'img' => 'images/http_agents/os/mandrake.png',
'name' => 'Mandrake'
),
'Fedora' => array(
'img' => 'images/http_agents/os/fedora.png',
'name' => 'Fedora'
),
'Novell' => array(
'img' => 'images/http_agents/os/novell.png',
'name' => 'Novell'
),
'Ubuntu' => array(
'img' => 'images/http_agents/os/ubuntu.png',
'name' => 'Ubuntu'
),
'Kubuntu' => array(
'img' => 'images/http_agents/os/kubuntu.png',
'name' => 'Kubuntu'
),
'Xubuntu' => array(
'img' => 'images/http_agents/os/xubuntu.png',
'name' => 'Xubuntu'
),
'Edubuntu' => array(
'img' => 'images/http_agents/os/edubuntu.png',
'name' => 'Edubuntu'
),
'Debian' => array(
'img' => 'images/http_agents/os/debian.png',
'name' => 'Debian'
),
'Red Hat' => array(
'img' => 'images/http_agents/os/redhat.png',
'name' => 'Red Hat'
),
// Array Other Browser
'Nintendo DS' => array(
'img' => 'images/http_agents/os/unknown.png',
'name' => 'Nintendo DS'
),
'FreeBSD' => array(
'img' => 'images/http_agents/os/unknown.png',
'name' => 'Sconosciuto'
),
'SunOS' => array(
'img' => 'images/http_agents/os/unknown.png',
'name' => 'Sconosciuto'
));
$browser = array(
// Array Browser
'MSIE 8.0' => array(
'img' => 'images/http_agents/browsers/msie.png',
'name' => 'Explorer Versione 8.0',
),
'MSIE 7.0' => array(
'img' => 'images/http_agents/browsers/msie.png',
'name' => 'Explorer Versione 6.0',
),
'MSIE 6.0' => array(
'img' => 'images/http_agents/browsers/msie.png',
'name' => 'Explorer Versione 6.0',
),
'Firefox' => array(
'img' => 'images/http_agents/browsers/firefox.png',
'name' => 'Firefox',
),
'Konqueror' => array(
'img' => 'images/http_agents/browsers/konqueror.png',
'name' => 'Konqueror',
),
'Chrome' => array(
'img' => 'images/http_agents/browsers/chrome.png',
'name' => 'Explorer Versione 8.0',
));
// Array Print Os System
$os_system_values = array();
$os_system_img = array();
$os_system_name = array();
if(strpos($_SERVER['HTTP_USER_AGENT'], $os_system_string))
{
return $os_system_get_string;
}
foreach($os_system as $os_system_string => $os_system_get_string)
{
$os_system_values[] = $os_system_string;
$os_system_img[] = $os_system[$os_system_string]['img'];
$os_system_name[] = $os_system[$os_system_string]['name'];
}
// Array Print Browser
$browser_values = array();
$browser_img = array();
$browser_name = array();
if(strpos($_SERVER['HTTP_USER_AGENT'], $browser_string))
{
return $browser_get_string;
}
foreach($browser as $browser_string => $browser_get_string)
{
$browser_values[] = $browser_string;
$browser_img[] = $browser[$browser_string]['img'];
$browser_name[] = $browser[$browser_string]['name'];
}
$template->assign_vars(array(
'L_USER_IP' => 'IP',
'USER_IP' => $_SERVER['REMOTE_ADDR'],
'L_USER_SYSTEM' => 'Sistema Operativo',
'USER_SYSTEM_NAME' => $os_system[$os_system_string]['name'],
'USER_SYSTEM_IMG' => $os_system[$os_system_string]['img'],
'L_USER_BROWSER' => 'Browser',
'USER_SYSTEM_NAME' => $browser[$browser_string]['name'],
'USER_SYSTEM_IMG' => $browser[$browser_string]['img']
)
);
?>
info_block.tpl
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="row1" width="25%"><span class="forumlink">{L_USER_IP}</span></td>
<td colspan="2" class="row2" width="100%"><span class="forumlink">{USER_IP}</span></td>
</tr>
<tr>
<td class="row1" width="25%"><span class="forumlink">{L_USER_SYSTEM}</span></td>
<td class="row2" width="5%"><img src="{USER_SYSTEM_IMG}" /></td>
<td class="row3" width="70%"><span class="forumlink">{USER_SYSTEM_NAME}</span></td>
</tr>
<tr>
<td class="row1" width="25%"><span class="forumlink">{L_USER_BROWSER}</span></td>
<td class="row2" width="5%"><img src="{USER_BROWSER_IMG}" /></td>
<td class="row3" width="70%"><span class="forumlink">{USER_BROWSER_NAME}</span></td>
</tr>
</table>
Thank in advance
Hi fucile
|
#6 Mon 02 Nov, 2009 06:38 |
|
|
Page 1 of 1
|
Was this topic useful?
Was this topic useful?
Link this topic |
URL |
|
BBCode |
|
HTML |
|
You cannot post new topics You cannot reply to topics You cannot edit your posts You cannot delete your posts You cannot vote in polls You cannot attach files You can download files You cannot post calendar events
|
|
|
|