HEY YOU!!!, Our records indicate that you have never posted to our site before! Why not make your first post today by saying hello to our community in our new people forums. To access all the good good stuff you need to post, post, and post more.


Support Webrats Forum with your Subscription. Only $5.95 per month!
Adult lounge Access • Private Messaging • GAMES •
Please click here for more details • Please click here to subscribe
Go Back   WR > Community > Computers and Programming
User Name
Password
Register Help Desk Music Uploads Live Cams Arcade Upgrade Account Mark Forums Read
Reply
 
Thread Tools
Old 05-25-2004, 06:36 AM   #1
jacktheripper
whore
 
 
Join Date: Jan 2004
Location: 2nd biggest state
Posts: 27/0.02
Threads: 0
Icon05 Question PHP help

click on one of our sponsors! OR REMOVE ADS
I'm look for a way to stip down IP's and hostnames to display them on a web page. I can display them no problem, but I looking to replace some of the octets with *, instead of numbers. Ie 10.1.3.x. For the hostname part, I'm looking to only display the network they are from, not dialupuser.23.level4.net, I would only like to display level4.net. I have figured out of most of this, but I am running into issues with people that come from au.com or co.nz or com.my networks because of the why the code works it only displays the last two segments of the hostname, not sure if I can make it "smart" or not.

PHP Code:
<?php
$Host 
gethostbyaddr($_SERVER['REMOTE_ADDR']);
print 
$Host;
print 
"<br>";
preg_match("/[^\.\/]+\.[^\.\/]+$/"$Host$matches);
echo 
"domain name is: {$matches[0]}\n";
?>


Any thoughts?
Submit to Clesto Submit to Digg Submit to Reddit Submit to Furl Submit to Del.icio.us Submit to Spurl | quote |
Sponsored Links
REMOVE ADS
Old 05-25-2004, 02:24 PM   #2
jacktheripper
whore
 
 
Join Date: Jan 2004
Location: 2nd biggest state
Posts: 27/0.02
Threads: 0
Re: PHP help

In case anybody wanteds the IP code..here it is...just change the $octs[x] to x out the octet you want to hide.

PHP Code:
<?php 
// 0 is 1st, 1 is 2nd, 2 is 3rd, and 3 is 4th
$ip $_SERVER['REMOTE_ADDR']; 
$octs split('\.'$ip); 
$octs[3] = ereg_replace("[0-9]""x"$octs[3]); 
//$octs[2] = ereg_replace("[0-9]", "x", $octs[2]); 
$hideemjoin("."$octs); 
print 
$hideem
?>
Submit to Clesto Submit to Digg Submit to Reddit Submit to Furl Submit to Del.icio.us Submit to Spurl | quote |
Old 06-01-2004, 10:35 AM   #3
jessicaq
whore
 
 
Join Date: Jun 2004
Location: SoCal
Posts: 364/0.23
Threads: 0
FEMALE
Re: PHP help

You'd almost be better off splitting it up into an array and then checking the length of the last element.
<?php
$Host = gethostbyaddr($_SERVER['REMOTE_ADDR']);
print $Host;
print "<br>";
$ArHost = split("\.",$Host);
$iSizeArr = count($ArHost);
If (strlen(end($ArHost)) < 3) {
#HOST HAS A 2-CHAR TOP LEVEL - IE: COUNTRY CODE
echo "domain name is: " . $ArHost[$iSizeArr-3] . "." . $ArHost[$iSizeArr-2] . "." . $ArHost[$iSizeArr-1] . "\n";
} else {
#HOST IS TYPICAL 3-CHAR TOP LEVEL
echo "domain name is: " . $ArHost[$iSizeArr-2] . "." . $ArHost[$iSizeArr-1] . "\n";
}
?>

Hope this helps.
Jessica.
Submit to Clesto Submit to Digg Submit to Reddit Submit to Furl Submit to Del.icio.us Submit to Spurl | quote |
Old 06-01-2004, 07:29 PM   #4
MythX
Guest
 
Posts: n/a/0
Threads:
Re: PHP help

dividing it into an array as Jessicaq says above is definitely your best bet.
Submit to Clesto Submit to Digg Submit to Reddit Submit to Furl Submit to Del.icio.us Submit to Spurl | quote |
Old 06-09-2004, 04:17 PM   #5
jacktheripper
whore
 
 
Join Date: Jan 2004
Location: 2nd biggest state
Posts: 27/0.02
Threads: 0
Re: PHP help

I'll give it a shot..been away from the computer a while..errr
Submit to Clesto Submit to Digg Submit to Reddit Submit to Furl Submit to Del.icio.us Submit to Spurl | quote |
Sponsored Links
REMOVE ADS
Old 06-09-2004, 08:42 PM   #6
jessicaq
whore
 
 
Join Date: Jun 2004
Location: SoCal
Posts: 364/0.23
Threads: 0
FEMALE
Re: PHP help

Cool. Let me know if you need more advice.
Jessica.
Submit to Clesto Submit to Digg Submit to Reddit Submit to Furl Submit to Del.icio.us Submit to Spurl | quote |
Reply

WR > Community > Computers and Programming
Reload this Page PHP help
Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:

Powered by Waldo 12345678910 1213 14 15 Copyright © 2000-2005 Jelsoft Enterprises Limited.
Page generated in 3.90958500 seconds (98.04% PHP - 1.96% MySQL) with 11 queries
206.212.255.30 Message Boards and Forums Directory