You are on page 1of 2

Do you want to know who and when is visiting your web pages without having to look thru

complex server logs? Would you like to be informed every time someone someone looks
at your site even if your not at your computer?

Fear not web 2.0 has the solution, and in just a few simple steps you too can have a spy
on your site.

All you need is a web host that allows php (a free account from works
just fine), A mobile phone to send your visitors information to, and a couple of twitter
accounts (for which you will need a couple of different email addresses).

First you will need to set up a primary twitter account and link it to your phone, the
instructions at are quite straightforward and easy to follow. You might
like to subscribe to one or two twitter feeds like or to test it. Then you will need to log out and create a second
account with an easy to remember name and an easy to remember password.

Now we can get started on a little php script that is going to do two things for us, first it will
display a nice little image so we have a reason for people to use the script, the second is
to send the IP of the person using the script to twitter.

The first part of the script looks like this:

1. <?php
2. header ("Content-type: image/png");
3. $im = @ImageCreate (100, 200)
4. or die ("Cannot Initialize new GD image stream");
5. $background_color = ImageColorAllocate ($im, 0, 151, 153);
6. $text_color = ImageColorAllocate ($im, 0, 255, 255);
8. imageline ($im,0,0,100,200,$text_color);
9. imageline ($im,100,0,0,200,$text_color);
11. ImagePng ($im);

And you should feel free to change background colour and text colours in lines 5 and 6.
The second part of the script is what sends the IP to twitter as follows:

13. $username = 'username';
14. $password = 'password';
15. $ip=$_SERVER['REMOTE_ADDR'];
16. $url = '';
17. $curl_handle = curl_init();
18. curl_setopt($curl_handle, CURLOPT_URL, "$url");
19. curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
20. curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
21. curl_setopt($curl_handle, CURLOPT_POST, 1);
22. curl_setopt($curl_handle, CURLOPT_POSTFIELDS, "status=$ip");
23. curl_setopt($curl_handle, CURLOPT_USERPWD, "$username:$password");
24. $buffer = curl_exec($curl_handle);
25. curl_close($curl_handle);
27. ?>

Created by NosDa 0705

You will need to change the username (in line 13) and password (in line 14) to those of
your second twitter account. You should then save the script under a witty name. After
uploading your new php script to your web hosting you should pay a visit to it in your web
browser, all you should see is a square of one colour with or without two diagonal lines of
another colour going across it. After viewing your new image you should go to the twitter
page for your second account and there is everything as gone to plan should be displayed
your IP address, at this point you should log out and log back in with your first account,
and had your second account to your watch list.

By now you should have a working php script that displays an image and sends the IP of
the person it displays the image to via twitter to your phone. The next step is to get the
page you want to spy on the users of to display you image and we do that using CSS

1. <style type="text/css">
2. body {
3. background-image: url(;
4. background-attachment: fixed;
5. background-position: top left;
6. background-repeat: repeat;
7. }
8. </style>

First you will need to change the path in line 3 to the correct path to your php script then all
you need do is paste the CSS into the html of the document you want to spy on the users
of, that could be your myspace profile, your blog, your homepage, the posibilites are
almost endless.

Created by NosDa 0705

You might also like