iPodHacking Community
Home Forum Wiki Themes Register Members List Mark Forums Read
 

Go Back   iPodHacking Community > General > Graphics > Graphics Tutorials

Sponsored Links

Notices

Graphics Tutorials Post tutorials here.

Reply
 
LinkBack Thread Tools
Old 08-16-2008   #1
H3X
Super Mod
 
H3X's Avatar
 

Join Date: Dec 2007
Posts: 216
H3X is on a distinguished road
Default Dynamic IP Signature

Hello, a few of you have been wondering how I made my signature like this:



Before you start, let me tell you that this is not the person viewing the image's IP, but the person who previously viewed the image's IP.

Well, first let me tell you that this is not infact a .png, .jpg or any other format of image, but it is a .php file, titled index.php.

So to start, make 2 files. 1 titled index.php and the other titled store.txt. Make sure both of these files are blank (0 bytes) and that they are in the same directory/folder. Open up index.php notepad, or any other editor.

I'm going to split up the index.php file into 3 parts for you. The first part is this:

Code:
<?
header("Content-type: image/png");

$store = "store.txt";
$fh = fopen($store, 'r');
$fs=filesize($store);
$output = fread($fh, $fs);
fclose($fh);
The first line with a <? in it just tells the server that it's a php file it's reading, and not an html file or something. This is required in all php documents.
The second line is telling the server it's an image and not just plain text.
The next few lines tells the server to open up the store.txt file and read it's contents. It then puts the data in the store.txt (in this case an IP) file into a variable, in this case $output. After it has done that, it closes the file. You don't have to close the file, but you should do it because it will decrease the load on the server quite a bit.

Our next step is to take the information stored in $output.php and make it into an image. This is the fun part.
Now, moving on to the next part of the index.php file:

Code:
$number = strlen($output);
$number = ($number*7)+9;
$im = imagecreate($number, 24);
$color1 = imagecolorallocate($im, 245, 245, 255);
$color2 = imagecolorallocate($im, 0, 0, 0);
imagestring($im, 3, 5, 5,  $output, $color2);
imagepng($im);
imagedestroy($im);
This is where we are actually creating the image. Basically we are taking whatever $output contains, and putting it onto a simple image. You can control what the background and text color of the image are by modifying $color1 and $color2.
$color1 is the background, in RGB (Red, Green, Blue) format. In this case, I just made it the color of the iPH background, which is 245, 245, 255 (if you want different colors, you can get them in Photoshop). $color2 is the font color, in this case black, or 0, 0, 0.
So all in all, it is taking the contents of the store.txt file, and putting them on an image. If that's all you wanted it to do, you could just make 1 more line at the end just containing ?> (but don't do that), to end the php. But let's take it 1 step further.

The third and final piece of code in index.php is going to get the IP of the user and put it into the store.txt file along with some other text.
Code:
$ip = $_SERVER['REMOTE_ADDR'];
$text = "Last IP that saw this image: " . $ip . " --H3X";
$store = "store.txt";
$fh = fopen($store, 'w');
fwrite($fh, $text);
fclose($fh);
?>
The first line is getting the ip with $_SERVER['REMOTE_ADDR'] and setting it to the variable $ip.
The next line is the text that is going to be on our image. Basically we are just taking the text "Last IP that saw this image: " and " --H3X" and putting the IP that we got on the line above and storing it into the variable $text.
Then, it writes the data stored in $text to store.txt, overwriting everything in there.
We then close up index.php with ?> to tell the server that the script is done.

So heres all the code above put together for the cheaters who don't read the tutorial and just want the code .

Code:
<?
header("Content-type: image/png");

$store = "store.txt";
$fh = fopen($store, 'r');
$fs=filesize($store);
$output = fread($fh, $fs);
fclose($fh);

$text = $output;
$number = strlen($text);
$number = ($number*7)+9;
$im = imagecreate($number, 24);
$colour1 = imagecolorallocate($im, 245, 245, 255);
$colour2 = imagecolorallocate($im, 0, 0, 0);
imagestring($im, 3, 5, 5,  $text, $colour2);
imagepng($im);
imagedestroy($im);

$ip = $_SERVER['REMOTE_ADDR'];
$text = "Last IP that saw this image: " . $ip . " --H3X";
$store = "store.txt";
$fh = fopen($store, 'w');
fwrite($fh, $text);
fclose($fh);
?>
The store.txt file we created earlier we don't need to edit.

The next step is to sign upfor free hosting. I used arenaspace.com.
After you have signed up there, go to your setting and create a new subdomain, the name doesn't matter. Now go to the upload page and click on your subbdomain. Finally, just upload the 2 files you made. Now go to your URL bar and type in the subdomain you made, for example mine is h3x.awardspace.com.

You should have an image like mine. Now, to put it in your sig or put it on any webpage, just treat it as a normal image, and enter it's url. The first time you visit it, there will appear to be a fake image. This is because there is no data in store.txt. Just hit refresh, and everything will work. This only happens once, don't worry.

Hope you liked this tutorial.

If you want to show the person viewing the images IP, and not the person who just previously viewed the image's IP, replace the code in index.php with this:

Code:
<?
header("Content-type: image/png");

$ip = $_SERVER['REMOTE_ADDR'];
$output = "Your IP: " . $ip . " --H3X";

$number = strlen($output);
$number = ($number*7)+9;
$im = imagecreate($number, 24);
$colour1 = imagecolorallocate($im, 245, 245, 255);
$colour2 = imagecolorallocate($im, 0, 0, 0);
imagestring($im, 3, 5, 5,  $output, $colour2);
imagepng($im);
imagedestroy($im);
?>
Pretty cool, eh?
Leave feedback please.


__________________

Last edited by H3X; 08-16-2008 at 07:28 PM.
H3X is offline   Reply With Quote
Sponsored Links
Old 08-16-2008   #2
Back, Baby :)
 
psychotic.grape's Avatar
 

Join Date: Mar 2008
Location: croydon, london, england
Posts: 796
psychotic.grape is a jewel in the roughpsychotic.grape is a jewel in the roughpsychotic.grape is a jewel in the roughpsychotic.grape is a jewel in the rough
Send a message via AIM to psychotic.grape Send a message via MSN to psychotic.grape
Default Re: Dynamic IP Signature

wow thanks
im trying this later
__________________

Check Out GFX Central.
Want Warez? Visit WarezVB.
psychotic.grape is offline   Reply With Quote
Old 08-16-2008   #3
STATE CHAMPS
 
SportsGuy's Avatar
 

Join Date: Jan 2008
Posts: 194
SportsGuy is on a distinguished road
Default Re: Dynamic IP Signature

What can you do with an ip address anyway?
__________________
SportsGuy is offline   Reply With Quote
Old 08-16-2008   #4
UltimateiPod Manager
 

Join Date: Jan 2008
Posts: 90
Forgoten Dynasty will become famous soon enough
Default Re: Dynamic IP Signature

wow thanks alot i dont really like the idea of showing ip addresses at all but i really enjoyed the image thing ive been dieing to know how to do that i am going to try to apply the concept to some thing else.

i really need to start learning more advanced php because the little bit i know isnt really a huge help when i go to go code something.
Forgoten Dynasty is offline   Reply With Quote
Old 08-18-2008   #5
QC > US
 
Kedzi's Avatar
 

Join Date: Dec 2007
Location: Québec
Age: 16
Posts: 1,117
Kedzi is a jewel in the roughKedzi is a jewel in the roughKedzi is a jewel in the roughKedzi is a jewel in the rough
Send a message via AIM to Kedzi Send a message via MSN to Kedzi
Default Re: Dynamic IP Signature

Cool I will definitly try this if I can install PHP... H3X, how to you install it ? It gives me an error...
__________________
Kedzi is offline   Reply With Quote
Old 08-18-2008   #6
H3X
Super Mod
 
H3X's Avatar
 

Join Date: Dec 2007
Posts: 216
H3X is on a distinguished road
Default Re: Dynamic IP Signature

I recommend this.
I have used it on both Mac and PC and it works great.

http://www.apachefriends.org/en/xampp.html


__________________
H3X is offline   Reply With Quote
Sponsored Links
Reply

Thread Tools

 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Make Dynamic Icons font white? antonyfl iPod Video Support 0 04-21-2008 07:09 AM
[Request] dynamic icons for evolution? dhack iPod Video Ideas/Requests 0 04-20-2008 03:30 AM
[Request]Dynamic Icons for Showtime ktran iPod Video Ideas/Requests 4 03-31-2008 11:08 PM
Static vs. Dynamic Icons sethoramma4 iPod Video Support 6 03-02-2008 07:35 PM
Dynamic Backgrounds iMav iPod Video Support 3 01-29-2008 07:20 AM


Sponsored Links

New To iPodHacking.com? Need Assistance?

All times are GMT. The time now is 07:43 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
iPodHacking is a Member of the R9V Network

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62