Misc Links
Forum Archive
News Archive
File DB
 

Ads
 

Advertisement
 

Latest Forum Topics
wow 56 k modems are
Posted by Red Squirrel
on Oct 14 2013, 11:52:23 pm

I Need A Program
Posted by rovingcowboy
on Sep 23 2013, 5:37:59 pm

having trouble witn lan
Posted by rovingcowboy
on Sep 23 2013, 5:40:56 pm

new problem for me
Posted by rovingcowboy
on Sep 23 2013, 5:54:09 pm

RBC Royal Bank
Posted by Red Squirrel
on Aug 13 2013, 6:48:08 pm

 

Making a Dynamic Text Sig
How showing your IP on an image is done.
By Red Squirrel


Most of you probably have seen those forum signatures that show your IP and other information. You might be wondering how in the world is it done. Well this article will attempt to explain this to you. If you read our other article on making a sig with an image that changes, you have learned how you can actually make a fake image file that is really php but to the browser, is an image. The dynamic text/ip sig uses the same concept, but different code.

If you have read the other sig article and already understand the concept, you can skip to the next page. Otherwise, read on.

First, what we want to do is setup a folder where .jpg files will run as php. So make a folder called phpsigs and put this in your .htaccess file:

ForceType application/x-httpd-php

That will simply force all files to run in the php parser. You can go into more htaccess stuff to only make certain files be affected and what not, but to keep things simple, we'll just do it to all files. You just have to make sure not to put anything else in this folder. Only the .htaccess file and the fake image file.

Secondly, we need to create a fake image file. By fake I simply mean that it's not a real image, but code. Let's call it siggy.jpg and put it in the phpsigs. The actual image that will be displayed as the sig can be stored anywhere, on, or outside of the server. The image has to be png, for the code we will use.

On the next page, we'll take a look at the code for this sig.





Next Page
spacer
23536 Hits Pages: [1] [2] 33 Comments
spacer


Latest comments (newest first)
Posted by Onykage on January 01st 2006 (16: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.

spacer
Posted by Cold Drink on July 07th 2005 (23: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.

spacer
Posted by Streety on July 07th 2005 (17: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.

spacer
Posted by Streety on July 07th 2005 (16: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.

spacer
Posted by Streety on July 07th 2005 (14: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. laugh.gif

The function imagestring only has the one preset but imagettftext is specifically for use with true type fonts. wink.gif

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 . . .

user posted image

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. wink.gif

spacer
View all comments
Post comment


Top Articles Latest Articles
- What are .bin files for? (669062 reads)
- Text searching in linux with grep (161180 reads)
- Big Brother and Ndisuio.sys (150471 reads)
- PSP User's Guide (139547 reads)
- SPFDisk (Special Fdisk) Partition Manager (117240 reads)
- How to Use MDADM Linux Raid (188 reads)
- What is Cloud Computing? (1225 reads)
- Dynamic Forum Signatures (version 2) (8769 reads)
- Successfully Hacking your iPhone or iTouch (18714 reads)
- Ultima Online Newbie Guide (35906 reads)
corner image

This site best viewed in a W3C standard browser at 800*600 or higher
Site design by Red Squirrel | Contact
© Copyright 2017 Ryan Auclair/IceTeks, All rights reserved