TipZ Posted July 11, 2008 Share Posted July 11, 2008 my captcha code doesent work can any one help me ?? my captcha_verify.php <?php function parse_bgcolor() { if(strlen($_GET['bgcolor']) == 6) { $p1=$_GET['bgcolor'][0].$_GET['bgcolor'][1]; $p2=$_GET['bgcolor'][2].$_GET['bgcolor'][3]; $p3=$_GET['bgcolor'][4].$_GET['bgcolor'][5]; } else { $p1=$_GET['bgcolor'][0].$_GET['bgcolor'][0]; $p2=$_GET['bgcolor'][1].$_GET['bgcolor'][1]; $p3=$_GET['bgcolor'][2].$_GET['bgcolor'][2]; } return array(hexdec($p1),hexdec($p2),hexdec($p3)); } session_start(); $bgcolor=($_GET['bgcolor']) ? parse_bgcolor() : array(255,255,255); $text=array(255-$bgcolor[0],255-$bgcolor[1],255-$bgcolor[2]); $distort=rand(80,120)/100; $distort2=rand(80,120)/100; $f_x=round(75*$distort); $f_y=round(25*$distort); $s_x=round(175*$distort2); $s_y=round(70*$distort2); $first=imagecreatetruecolor($f_x, $f_y); $second=imagecreatetruecolor($s_x, $s_y); $white=imagecolorallocate($first, $bgcolor[0], $bgcolor[1], $bgcolor[2]); $black=imagecolorallocate($first, 0, 0, 0); $red=imagecolorallocate($first, 255, 0, 0); $green=imagecolorallocate($first, 0, 128, 0); $blue=imagecolorallocate($first, 0, 0, 255); imagefill($first, 0, 0, $white); $color[0]=$red; $color[1]=$green; $color[2]=$blue; for($i=0; $i<=2; $i++) { $points = array( 0 => array(10, $f_x - 10), 1 => array(5, $f_y - 5), 2 => array(10, $f_x - 10), 3 => array(5, $f_y - 5), 4 => array(10, $f_x - 10), 5 => array(5, $f_y - 5), 6 => array(10, $f_x - 10), 7 => array(5, $f_y - 5), 8 => array(10, $f_x - 10), 9 => array(5, $f_y - 5), ); imagefilledpolygon($first, $points, 5, $red); } imagestring($first, 4, rand(0, $f_x/3), rand(0,$f_y/2.5), $_SESSION['captcha'], $black); imagecopyresized($second, $first, 0, 0, 0, 0, $s_x, $s_y, $f_x, $f_y); imagedestroy($first); $red=imagecolorallocate($second, 255, 0, 0); $green=imagecolorallocate($second, 0, 128, 0); $blue=imagecolorallocate($second, 0, 0, 255); $RandomPixels=ceil($s_x*$s_y/100); for($i=0;$i<$RandomPixels;$i++) { $locx=rand(0,$s_x-1); $locy=rand(0,$s_y-1); imagesetpixel($second, $locx, $locy, $red); } for($i=0;$i<$RandomPixels;$i++) { $locx=rand(0,$s_x-1); $locy=rand(0,$s_y-1); imagesetpixel($second, $locx, $locy, $green); } for($i=0;$i<$RandomPixels;$i++) { $locx=rand(0,$s_x-1); $locy=rand(0,$s_y-1); imagesetpixel($second, $locx, $locy, $blue); } $randcolor=imagecolorallocate($second, rand(100,255), rand(100,255), rand(100,255)); for($i=0; $i<5; $i++) { imageline($second, rand(0, $s_x), rand(0, $s_y), rand(0, $s_x), rand(0, $s_y), $randcolor); $randcolor=imagecolorallocate($second, rand(100,255), rand(100,255), rand(100,255)); } @header("Content-Type: image/png"); $finished=imagerotate($second, rand(0,15)-7.5, $bgcolor[2]*65536+$bgcolor[1]*256+$bgcolor[0]); imagedestroy($second); imagepng($finished); imagedestroy($finished); ?> Quote Link to comment Share on other sites More sharing options...
TipZ Posted July 11, 2008 Author Share Posted July 11, 2008 Re: e need seriously help and my macro1 and 2 macro1.php <?php include "globals.php"; if(!$set['validate_on'] || $ir['verified']) { die("WTF are you doing on this page? Go home losr."); } $ref=$_GET['refer']; unset($_SESSION['captcha']); $chars="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!?\\/%^"; $len=strlen($chars); $_SESSION['captcha']=""; for($i=0;$i<6;$i++) $_SESSION['captcha'].=$chars[rand(0, $len - 1)]; print "<h3>Validation</h3><hr /> Enter the text you see in the image into the box below.<form action='macro2.php' method='post'>"; if($_GET['code']) { print "<font color='red'>[b]Invalid code or blank[/b]</font> "; } print " [img=captcha_verify.php] Text: <input type='text' name='captcha' /> <input type='hidden' name='refer' value='{$_GET['refer']}' /> <input type='submit' value='Verify' /></form>"; $h->endpage(); ?> macro2.php <?php session_start(); if(get_magic_quotes_gpc() == 0) { foreach($_POST as $k => $v) { $_POST[$k]=addslashes($v); } foreach($_GET as $k => $v) { $_GET[$k]=addslashes($v); } } require "global_func.php"; if($_SESSION['loggedin']==0) { header("Location: login.php");exit; } $userid=$_SESSION['userid']; include "config.php"; global $_CONFIG; define("MONO_ON", 1); require "class/class_db_{$_CONFIG['driver']}.php"; $db=new database; $db->configure($_CONFIG['hostname'], $_CONFIG['username'], $_CONFIG['password'], $_CONFIG['database'], $_CONFIG['persistent']); $db->connect(); $c=$db->connection_id; $is=$db->query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid"); $ir=$db->fetch_row($is); $set=array(); $settq=$db->query("SELECT * FROM settings"); while($r=$db->fetch_row($settq)) { $set[$r['conf_name']]=$r['conf_value']; } if(!$set['validate_on'] || $ir['verified']) { die("WTF are you doing on this page? Go home losr."); } if(!isset($_SESSION['captcha'])) { header("Location: macro1.php?code=invalid&refer={$_POST['refer']}"); exit; } if($_SESSION['captcha'] != $_POST['captcha']) { header("Location: macro1.php?code=invalid&refer={$_POST['refer']}"); exit; } $ref=$_POST['refer']; unset($_SESSION['captcha']); $db->query("UPDATE users SET verified=1 WHERE userid={$userid}"); header("Location: $ref"); ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.