User Name
Password

Go Back   Planetarion Forums > Non Planetarion Discussions > Programming and Discussion
Register FAQ Members List Calendar Arcade Today's Posts

Reply
Thread Tools Display Modes
Unread 2 Nov 2002, 01:20   #1
queball
Ball
 
queball's Avatar
 
Join Date: Oct 2001
Posts: 4,410
queball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so little
protecting against scripts

I remember seeing a site which contained ready to use code to generate, for example, images with obscured numbers like you might see when registering for Yahoo Games or E-Gold. These are used to verify that the account is being registered by a human. Despite much googling I can't find this site again, so I wonder if any of you know where I could find code like this, or any synonyms for these systems.
queball is offline   Reply With Quote
Unread 2 Nov 2002, 10:21   #2
Cocaine
Guest
 
Posts: n/a
i'm sure there was a chanllenge or something on these boards a while back that related to this
  Reply With Quote
Unread 2 Nov 2002, 11:13   #3
MT
/dev/zero
Retired Mod
 
MT's Avatar
 
Join Date: May 2000
Posts: 415
MT is an unknown quantity at this point
Code:
<?php
    function getmicrotime(){ 
        list($usec, $sec) = explode(" ",microtime()); 
        return ((float)$usec + (float)$sec); 
    } 
    $start = getmicrotime();
    Header("Content-type: image/jpeg");
    function makeKey() {
        //32 - 126
        $tArr = array();
        while(sizeof($tArr)<8) {
            $tArr[] = chr(mt_rand(65,90));
        }
        return $tArr;
    }
    //generate 7 letter passkey
    $passkey = makeKey();
    //generate list of available fonts
    $basedir='/usr/fonts';
    $arFonts = array();
    if ($dHandle = opendir($basedir)) {
        while ($tFName = readdir($dHandle)) {
            if (eregi("ttf$",$tFName)) {
                $arFonts[] = $basedir . '/' . $tFName;
            }
        }
    }
    $fonts = sizeof($arFonts);
    if ($fonts==0) {
        die("No fonts found!");
    }
    //choose a font attributes for each character
    $face = array();$fsize = array();$fangle = array();
    while(sizeof($face)<8) {
        $face[] = mt_rand(0,$fonts-1);
        $fsize[] = mt_rand(32,72);
        $fangle[] = mt_rand(0,10);
    }
    //work out dimensions
    $fp = fopen('used.txt','a');
    $dx = 0; $dy = 0;$dpad = 12;
    foreach($passkey as $val => $char) {
        $fnt = $face[$val];
        $size = imagettfbbox($fsize[$val],$fangle[$val],$arFonts[$fnt],$char);
        $dx += abs($size[2]-$size[0]) + $dpad;
        $ddy = abs($size[5]-$size[3]);
        $ddy += abs($dx * tan(deg2rad($fangle[$val])));
        $dy = max($ddy,$dy);
        fwrite($fp,"Character $char in ".$arFonts[$fnt]."\n");
    }
    
    $xpad=90;
    $ypad=90;
    $im = imagecreate($dx+$xpad,$dy+$ypad);
    //$blue = ImageColorAllocate($im, 0x2c,0x6D,0xAF);
    $black = ImageColorAllocate($im, 215,215,215);
    $white = ImageColorAllocate($im, 230,230,230);
    ImageRectangle($im,0,0,$dx+$xpad-1,$dy+$ypad-1,$black);
    ImageRectangle($im,0,0,$dx+$xpad,$dy+$ypad,$white);
    $currx = (int)($xpad/2); $curry = (int)($ypad/2);
    foreach($passkey as $val => $char) {
        $fnt = $face[$val];
        $size = imagettfbbox($fsize[$val],$fangle[$val],$arFonts[$fnt],$char);
        $thisx = abs($size[2]-$size[0]) + $dpad;
        //$thisy = abs($size[5]-$size[3]) + abs($dx * tan(deg2rad($fangle[$val])));
        ImageTTFText(   $im,
                        $fsize[$val],
                        $fangle[$val],
                        $currx+1,
                        (int)($ypad/2)+$dy,
                        $black,
                        $arFonts[$fnt],
                        $char);
        ImageTTFText(   $im,
                        $fsize[$val],
                        $fangle[$val],
                        $currx,
                        (int)($ypad/2)-1+$dy,
                        $white,
                        $arFonts[$fnt],
                        $char);
        $currx += $thisx;
    }
    $x=0;$y=0;$mx=imagesx($im);$my=imagesy($im);$sx=0;
    while($y < $my) {
        while ($x < $mx) {
            imagesetpixel($im,$x,$y,$white);
            $x+=2;
        }
        $y++;
        if ($sx) {
           $x=0;$sx=0;
        }
        else {
           $x=1;$sx=1;
       }
    }    
    imagegammacorrect($im, 20.0, 1.0);
    Imagejpeg($im,'',50);
    ImageDestroy($im);
    $timestr = strftime("%T %D");
    $userinfo = "$HTTP_USER_AGENT @ ".$_SERVER["REMOTE_ADDR"]."\n$timestr";
    $ttime = number_format(getmicrotime() - $start,4);
    fwrite($fp,"$userinfo generated in $ttime seconds\n\n");fclose($fp);
?>
__________________
#linux : Home of Genius

<idimmu> ok i was chained to a desk with this oriental dude
MT is offline   Reply With Quote
Unread 4 Nov 2002, 14:44   #4
queball
Ball
 
queball's Avatar
 
Join Date: Oct 2001
Posts: 4,410
queball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so little
OK, I need one that makes an audio file for blind users, ta.
queball is offline   Reply With Quote
Unread 4 Nov 2002, 14:49   #5
queball
Ball
 
queball's Avatar
 
Join Date: Oct 2001
Posts: 4,410
queball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so littlequeball contributes so much and asks for so little
http://www.captcha.net/

yay
\o/
queball is offline   Reply With Quote
Reply



Forum Jump


All times are GMT +1. The time now is 02:35.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2002 - 2018