This is a rather simple way to create an image from a string. You can use this for whatever you want to, but my thought would be for posting e-mail addresses or maybe a CAPTCHA of some sort. You could do all sorts of stuff with this, like base64ing it or encrypting it with AES. All you need to do is upload this file in a new folder and name it index.php, then create an .htaccess file and you're done. You can now just link to it like this:
<img src="http://yoursite.com/folder/this is your string">
index.php:
<?php
$fontnum = 5; // 1-5
$max_str_length = 100; // maximum length of one line of text
header("Content-type: image/png"); // tell the browser this is an image
if(@$_SERVER['REQUEST_URI']){
$str = urldecode(str_replace(dirname($_SERVER['PHP_SELF']) . "/", "", $_SERVER['REQUEST_URI'])); // get the string
}
$str = chunk_split($str, $max_str_length); // split up the text into chunks based on max length
$str = substr(str_replace("\r", "", $str),0, -1); // replace \r (fucks things up)
$lines = count(explode("\n", $str)); // find the number of lines
$height = imagefontheight($fontnum)*count(explode("\n", $str)); // determine height
$width = imagefontwidth($fontnum) * ($lines <= 1 ? strlen($str) : $max_str_length); // determine width
$i = imagecreatetruecolor($width, $height); // create the base image
$str = explode("\n", $str); // create the string
for($x=0;$x<$lines;$x++){
imagestring($i,$fontnum,0,(imagefontheight($fontnum)*$x),$str[$x],imagecolorallocate($i, 255, 255, 255)); // add each line to the image
}
imagepng($i); // output the image
?>
.htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>

Enjoy 




February 16th, 2008 at 1:31 am
Nice, son!
February 16th, 2008 at 4:36 am
And then you could add a logging function…
February 16th, 2008 at 11:47 am
Of course