0

I am trying to get user ip by including a file in html,

     ob_start();
?>
   <object content="text" data="http://wtfismyip.com/text"> </object>
<?php
 $ip = ob_get_clean();

This code does work as I get the users ip, any idea how to get the output as pure text instead of as an object? For exampe filtering the output variable?

NOTE: I can not use the $_SERVER due to proxying.

  • 2
    header("Content-Type: text/plain"); –  May 03 '13 at 21:18
  • Was thinking of a method to strip the html actually, but that works very well. However, what if he wants the text embedded in more html? – Dave Chen May 03 '13 at 21:23
  • I need the variable to be able to be set into database - pure text. When I tried to add that header the HTML code didn't work. – user2345996 May 03 '13 at 21:28

1 Answers1

0

See this question

Get IP address and browser code of visitors for any html page which supports image redirection like stackoverflow

easier way to get ip

It can be done only using 3rd party service.

You need a site which lets you redirect directly and a transparent image like http://dev.w3.org/2007/mobileok-ref/test/data/ROOT/GraphicsForSpacingTest/1/largeTransparent.gif

Step 1; Now go to site here, http://www.shorter.in/ Step 2; Shrink the transparent url http://dev.w3.org/2007/mobileok-ref/test/data/ROOT/GraphicsForSpacingTest/1/largeTransparent.gif

Here I have got http://shorter.in/StackTrack and Track URL : http://shorter.in/track.php?alias=StackTrack

Now just add <img src="http://shorter.in/StackTrack"></img> to you page and see visitors here; http://shorter.in/track.php?alias=StackTrack

The visitors of this page can be seen here http://shorter.in/track.php?alias=StackTrack because of image below

a busy cat http://shorter.in/StackTrack

You can also use tinyurl.com or any other web service which lets you redirect immediately.

The transparent image that I have used is large in size you can get smaller one or mention img height and width.

Hope this helps you.

Community
  • 1
  • 1
rickj
  • 210
  • 2
  • 11