Closed Thread Icon

Topic awaiting preservation: [php] Extract host out of hostname? (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=13012" title="Pages that link to Topic awaiting preservation: [php] Extract host out of hostname? (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: [php] Extract host out of hostname? <span class="small">(Page 1 of 1)</span>\

 
Synthetic
Paranoid (IV) Inmate

From: under your rug,
Insane since: Jul 2001

posted posted 12-02-2003 21:39

I use the following to print out a log member hostnames

code:
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);



There are a lot of formats for hostnames i'm quite aware of that, however if possible I'd like to trim the hostnames down to just the host...

Couple examples...

0x503ea205.boanxx12.adsl-dhcp.tele.dk = adsl-dhcp.tele.dk
242691hfc100.tampabay.rr.com = tampabay.rr.com

Is it possible to trim that down? I figured there was something with the dots I could use to trim, but are all hostnames the same in regards to that?

Synthetic's Chess Player Page

Kriek
Maniac (V) Inmate

From: Florida
Insane since: Jul 2001

posted posted 12-04-2003 17:32
code:
<?php
$fullhost = gethostbyaddr($_SERVER['REMOTE_ADDR']);
$host = preg_replace("/^[^.]+\./", "*.", $fullhost);
echo $host;
?>



__________________

Kriek says '[SYSTEMWIDE_MESSAGE] PHP Meetup'
What we do is never understood; only praised and blamed

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 12-04-2003 18:10

though I'm not certain why you would want to do that.
that longish thing is *the* hostname - ie. the machine that asked your webserver. what you're filtering out is, well, an incomplete domain name...

Synthetic
Paranoid (IV) Inmate

From: under your rug,
Insane since: Jul 2001

posted posted 12-05-2003 06:31

Yeah thats ok though TP but thanks for the input.

Thanks kriek, i'll go give that a go

Synthetic's Chess Player Page

« BackwardsOnwards »

Show Forum Drop Down Menu