| Advertisement |
Unlock your Iphone
Unlocking and Jailbreaking your iPhone isn't easy. We recommend Unlock iPhone 3G Software!
|
| |
|
Send spam to:
website@xeonlive.com
nick@xeonlive.com
georgiapeach1241@aol.com
Making a Dynamic Text Sig How showing your IP on an image is done. By Red Squirrel
You must have the GD library installed on your server for this to work. What we want to do is set up text strings and place them on top of the graphic. Basically, we generate a graphic on the fly. For the main image, we grab the data off a normal image, and we "insert" the text data into it, and then display it.
Here is a sample dynamic sig and below is it's code.
The code:
1:<?php
2:
3:header("Content-type: image/png");
4:
5:
6:$number = rand(1,9);
7:
8:if($number==1)$string2 = "all your base r belong 2 us";
9:if($number==2)$string2 = "somebody set up us the bomb";
10:if($number==3)$string2 = "Resistance is futile";
11:if($number==4)$string2 = "R0D3NTS are cute";
12:if($number==5)$string2 = "H4X0R in thE yur PC1?!";
13:if($number==6)$string2 = "Dude w3re's my c4r?";
14:if($number==7)$string2 = "s0m3on3 st0l3 my mega hurtz!!";
15:if($number==8)$string2 = "move zig for great justice";
16:if($number==9)$string2 = "Rodents make the world cool";
17:
18:
19:$im = imagecreatefrompng("http://www.iceteks.com/articles/textsig/redsquirrelsig12.png");
20:$color = imagecolorallocate($im, 255, 255, 255);
21:
22:
23:$px=167;
24:$py=70;
25:
26:imagestring($im, 3, $px, $py, $string, $color);
27:imagestring($im, 2, $px, $py+12, $string2, $color);
28:
29:imagepng($im);
30:imagedestroy($im);
31:?>
|
On line 3 we give the browser a header that this is not a php file but is an image file. Basically we are reversing what we tell the server to do, run it as php. But what the server is doing is good, because it's running as php which we want, but we don't want the browser to know it's php, so we indicate that it's an image. You do not even need to use an image extension for this to work, but it causes less problems when posting on forums and such, since some won't let you use .php as image.
On line 6 through 16 we simply establish what text we want to display. The first part chooses a random number from 1 to 9 and depending on that number, a string is chosen. We store it in the $string2 variable.
line 19 picks the image that we will use. Notice that it's actually on a different host. You can pretty much do what you want, even hotlink of another site, but as a courtesy, I would at least put the image on your own host.
Line 20 decides what the color of the text will be, using RBG color scale. Notice the $im variable used on line 19 is used as a parameter.
Line 24 and 25 are simply variables for the position of the text, these numbers can be written directly in the function but this makes changing easier. If you wanted the text to appear at a different location depending on what the chosen string is, you could easily modify these in each if statement shown at the start.
Line 26 and 27 set up the strings on the image. The first one is to show the IP address, and the second is the random string.
Line 29 and 30 display and finish the png image and we're all set!
The possibilities with this are endless. You can make it so the image changes, and the text changes, and make quite a sophisticated sig! If you have questions feel free to ask below and check the rest of the forum thread.
Also, this particular sig does not show much info,but a really scarry sig could be made to show any other php variable such as the user's host name, and I've never researched it, but it's most likely possible to get the user's resolution and other information. Simply plug it in the same spot as the text and you're all set. Also note that if text is too long for the image, it simply gets cut off and does not wrap. Something to keep in mind.
| 12192 Hits |
Pages: [1] [2] |
33 Comments |
|
Latest comments (newest first) |
Posted by Onykage on January 01st 2006 (15:37)
There is a way to add the random factor without the read/write perms. Just use the rand() syntax. IE if you have 5 images then set something like the following:
| CODE | $someStringName = rand( 1, 5 ); if( $someStringName == 1 ) .. pick some image.. if( $someStringName == 2 ) .. pick some image.. if( $someStringName == 3 ) .. pick some image.. if( $someStringName == 4 ) .. pick some image.. if( $someStringName == 5 ) .. pick some image.. |
in the php docs on php.net will explain the rest rand( min, max );Also you can use the imagettftext syntaxt. This allows for a slightly more presice text insertion. PS. if you dont know already, to use a ttf font that font must be in the same dir as the php source file.
Posted by Cold Drink on July 07th 2005 (22:22)
As a side note, that random text code is quite nasty. You could do this:
| CODE | $text = Array('ichi', 'ni', 'san', 'shi'); $random_index = rand(0, count($text) - 1); $random_text = $text[$random_index]; |
It is much easier to maintain this way, too.
Posted by Streety on July 07th 2005 (16:27)
Are both the arial.ttf file and omfghax.png in the same directory?
I really don't know what to suggest. If your host is configured with the GD library I can see no reason why it wouldn't work.

|
Posted by Streety on July 07th 2005 (15:00)
Directory structure:
| CODE | + | +---arial.ttf | +---dynamic_pic_help_on_code.php | +---wtf.jpg.png
|
dynamic_pic_help_on_code.php:
| CODE | <?php
header("Content-type: image/png");
$number = rand(1,28);
if($number==1)$string2 = "ALL THE WAY TO 3000"; if($number==2)$string2 = "127.0.0.1"; if($number==3)$string2 = "GB2OMFGHAX?"; if($number==4)$string2 = "ALL YOUR MOMS ARE BELONG TO ME"; if($number==5)$string2 = "ROFLMAOBBQ"; if($number==6)$string2 = "HTTP://WWW.OMFGHAX.COM"; if($number==7)$string2 = "I STOLE UR MEGAHURTZ!!11!"; if($number==8)$string2 = "KING OF THE INTERNETS"; if($number==9)$string2 = "IF IT AIN'T HERE IT AIN'T TRUE"; if($number==10)$string2 = "WHAT!"; if($number==11)$string2 = "1+3+3=7"; if($number==12)$string2 = "WE LOVE TO SEE YOU SMILE"; if($number==13)$string2 = "I'D BUY THAT FOR A DOLLAR"; if($number==14)$string2 = "YOU MAY ALREADY BE A WINNER"; if($number==15)$string2 = "TEACHING YOU NEW MEANING OF WORD VIOLATION"; if($number==16)$string2 = "NOW WITH 100% LESS SPYWARE"; if($number==17)$string2 = "OH IT'S BEEN BROUGHT"; if($number==18)$string2 = "IT'S MAGIC"; if($number==19)$string2 = "TOUCH IT!"; if($number==20)$string2 = "EVERYTHING BUT THE RABBI"; if($number==21)$string2 = "WHY, THANK YOU"; if($number==22)$string2 = "9 INCHES OF LIMP DICK FOR YA butt"; if($number==23)$string2 = "SPAM!"; if($number==24)$string2 = "MARDI GRAS WITHOUT THE TITS AND BOOZE"; if($number==25)$string2 = "HMMMMMMM..."; if($number==26)$string2 = "DIE IN A FIRE!"; if($number==27)$string2 = "THIS SPACE FOR RENT"; if($number==28)$string2 = "1-(900)-OMFG-HAX";
$im = imagecreatefrompng("wtf.jpg.png");
$color = imagecolorallocate($im, 178, 187, 201); $font = 'arial.ttf';
$px=150; $py=40;
imagettftext($im, 20, 2, $px, $py, $color, $font, $string2);
imagepng($im); imagedestroy($im); ?> |
Hope that helps.
Posted by Streety on July 07th 2005 (13:56)
| QUOTE (Red Squirrel @ Jul 17 2005, 07:21 PM) | Actually arn't you limited to non true type fonts when using dynamic image text? I may be wrong though, never tried anything but default.  |
The function imagestring only has the one preset but image ttftext is specifically for use with true type fonts. There are a couple of things with your code. When I tried to use it I got the following error | QUOTE | | Parse error: parse error, unexpected T_STRING, expecting T_VARIABLE or '$' in /home/jmstre/public_html/images/help/dynamic_pic_help_on_code.php on line 46 |
Looking at line 46 we have
| CODE | | imagettftext($im, 0, 2, &px, $py+13, $string2, $color, $font); |
For the variable px you used & rather than $.
So if we fix that we get
| QUOTE | | The image “http://www.jmstreet.info/images/help/dynamic_pic_help_on_code.php” cannot be displayed, because it contains errors. |
After checking various things I came back to the same line. Alot of the variables are in the wrong places. It should be set out as below:
| CODE | | imagettftext ( resource image, float size, float angle, int x, int y, int color, string fontfile, string text ) |
After you do all that you get this . . .  I've changed the x and y values so it doesn't totally overlap your image (I couldn't be bothered making my own) but if you fix that one line it should work. One other thing to note though is that your random number isn't going to be very random. You need to seed the random number generator before you use it. The best way to do it is to include this code before you call the random number function; | CODE | | srand((double)microtime()*1000000); |
I'm not sure why exactly this is the best way but I'm informed that it is. It certainly works though.
View all comments Post comment | | | | |
|
|