#!/usr/local/bin/perl # Copyright (c) 2003, James Seng. (http://james.seng.cc/) # This code is released under the Artistic License. my($MT_DIR); BEGIN { if ($0 =~ m!(.*[/\\])!) { $MT_DIR = $1; } else { $MT_DIR = './'; } unshift @INC, $MT_DIR . 'lib'; unshift @INC, $MT_DIR . 'extlib'; } use GD; use CGI; require MT::SCode; $cgi = new CGI; $code = $cgi->param('code'); # Calculate code $scode = MT::SCode::scode_get($code); # lets define the image $im_length = (MT::SCode::scode_len()+1)*10; $im = new GD::Image($im_length,25); # define the color we going to use $c_background = $im->colorAllocate(224,224,224); $c_border = $im->colorAllocate(0,0,0); $c_line = $im->colorAllocate(192,192,192); $c_code = $im->colorAllocate(128,128,128); # Fill in the background $im->fill(50,50,$c_background); # Draw the borders lines for ($i=0;$i<$im_length;$i+=5) { $im->line($i,0,$i,24,$c_line); } for ($i=0;$i<25;$i+=5) { $im->line(0,$i,$im_length-1,$i,$c_line); } $im->rectangle(0,0,$im_length-1,24,$c_border); # Write the code $im->string(gdGiantFont,8,5,$scode,$c_code); # Generate the cookie $cookie = $cgi->cookie(-name=>code,-value=>$code); # Output the image binmode STDOUT; #print $cgi->header(-type=>'image/png',-cookie=>$cookie); print $cgi->header(-type=>'image/png'); print $im->png;