matty Posted March 23, 2007 Share Posted March 23, 2007 Hi, I put together a quick and SIMPLE bit of code that will stop macro bots, the uncleaver ones anyway. Heres my code. if($action == crimes){ $checknumber = rand(1,; $session[check] = $checknumber; if(!$vn){ echo" <font color=#CCCC00 size=5>Macro Check</font><br><hr color=#000000 width=80%> <font color=#33CC33>Please click the corresponding number.<br> Click number - <font color = red>$session[check]</font><br><br> <center> <img src=image/macrocheck.jpg alt=Macro check border=0 usemap=#Map /> <map name=Map id=Map> <area shape=rect coords=119,78,142,130 href=macrocheck.php?action=crimes&vn=8 alt=8 /> <area shape=rect coords=82,77,105,129 href=macrocheck.php?action=crimes&vn=7 alt=7 /> <area shape=rect coords=47,77,70,129 href=macrocheck.php?action=crimes&vn=6 alt=6 /> <area shape=rect coords=8,76,31,128 href=macrocheck.php?action=crimes&vn=5 alt=5 /> <area shape=rect coords=117,17,140,69 href=macrocheck.php?action=crimes&vn=4 alt=4 /> <area shape=rect coords=80,17,103,69 href=macrocheck.php?action=crimes&vn=3 alt=3 /> <area shape=rect coords=42,16,65,68 href=macrocheck.php?action=crimes&vn=2 alt=2 /> <area shape=rect coords=7,16,30,68 href=macrocheck.php?action=crimes&vn=1 alt=1 /> </map> <hr color=#000000 width=80%> </center> "; exit; } if($vn == $session[check] & $action == crimes){ $addmacro = mysql_query("update userdb set macrocheck = 'Y' where id='$playerinfo[id]'"); header( 'Location: crimes.php' ) ; exit; } if($vn != $session[check] & $action == crimes){ echo "hi"; exit; } } what happens is when the user goes to a page, a function will check the database to see if they have passed the test within the last 5mins if they havnt it will redirect them to the file holding the code above. No its semi works, but im having a problem. When i click the number $session[check] is giving me it outputs 'hi' which means it was incorrect (it does it weather the number is correct or incorrect) i just cant figure out why. Thanks, Matt Link to comment https://forums.phpfreaks.com/topic/44013-solved-need-help-with-bot-checking-script/ Share on other sites More sharing options...
matty Posted March 23, 2007 Author Share Posted March 23, 2007 Anyone? Link to comment https://forums.phpfreaks.com/topic/44013-solved-need-help-with-bot-checking-script/#findComment-213699 Share on other sites More sharing options...
matty Posted March 23, 2007 Author Share Posted March 23, 2007 Didnt I explian it enough. Someone must know something about this, its not like its hard. Link to comment https://forums.phpfreaks.com/topic/44013-solved-need-help-with-bot-checking-script/#findComment-213875 Share on other sites More sharing options...
Hell Toupee Posted March 23, 2007 Share Posted March 23, 2007 Rather than saying if($vn== try if($_REQUEST[vn== so instead of: if($vn == $session[check] & $action == crimes){ $addmacro = mysql_query("update userdb set macrocheck = 'Y' where id='$playerinfo[id]'"); header( 'Location: crimes.php' ) ; exit; } if($vn !== $session[check] & $action == crimes){ echo "hi"; exit; } } Try: f($_REQUEST['vn'] == $session[check] & $action == crimes){ $addmacro = mysql_query("update userdb set macrocheck = 'Y' where id='$playerinfo[id]'"); header( 'Location: crimes.php' ) ; exit; } if($_REQUEST['vn'] !== $session[check] & $action == crimes){ echo "hi"; exit; } } Make any difference? Link to comment https://forums.phpfreaks.com/topic/44013-solved-need-help-with-bot-checking-script/#findComment-213884 Share on other sites More sharing options...
matty Posted March 24, 2007 Author Share Posted March 24, 2007 No, im afriad that didnt make any difference =( Link to comment https://forums.phpfreaks.com/topic/44013-solved-need-help-with-bot-checking-script/#findComment-214257 Share on other sites More sharing options...
shaunrigby Posted March 24, 2007 Share Posted March 24, 2007 What are you trying to block from bots? directorys? or what? Link to comment https://forums.phpfreaks.com/topic/44013-solved-need-help-with-bot-checking-script/#findComment-214259 Share on other sites More sharing options...
matty Posted March 24, 2007 Author Share Posted March 24, 2007 Its not that im trying to block access im trying to prevent bots. The page allows users to click on radio buttons for results. A macro could be set up to gain advantage of this. To stop this I have to set up a 'check' so that I know its not a bot (A bot couldnt guess a random number) So basically the page checks the database to see if the user has been 'human verified' within the last 5 minutes if they have the get passed onto the page, if not then they get sent the file containing the code above. Which then outputs a random number, they then have to click the number on the imagemap, if the numbers match, a value is sent to the database saying they have been checked and then they get passed to the page. Currently all it is doing is sending me to the part of that code which says its not correct, in this case 'hi'. I cant figure out why because its the right numbers. The checkcode is displayed and then the link on the image map is clicked... What could go wrong there? Matt Link to comment https://forums.phpfreaks.com/topic/44013-solved-need-help-with-bot-checking-script/#findComment-214267 Share on other sites More sharing options...
shaunrigby Posted March 24, 2007 Share Posted March 24, 2007 When you redirect back to yourself, you are re-generating another random number... Link to comment https://forums.phpfreaks.com/topic/44013-solved-need-help-with-bot-checking-script/#findComment-214269 Share on other sites More sharing options...
matty Posted March 24, 2007 Author Share Posted March 24, 2007 I have no modified it so that it wont do that. if(!$vn){ $checknumber = rand(1,; $session[check] = $checknumber; echo" <font color=#CCCC00 size=5>Macro Check</font><br><hr color=#000000 width=80%> <font color=#33CC33>Please click the corresponding number.<br> Click number - <font color = red>$session[check]</font><br><br> <center> <img src=image/macrocheck.jpg alt=Macro check border=0 usemap=#Map /> <map name=Map id=Map> <area shape=rect coords=119,78,142,130 href=macrocheck.php?action=crimes&vn=8 alt=8 /> <area shape=rect coords=82,77,105,129 href=macrocheck.php?action=crimes&vn=7 alt=7 /> <area shape=rect coords=47,77,70,129 href=macrocheck.php?action=crimes&vn=6 alt=6 /> <area shape=rect coords=8,76,31,128 href=macrocheck.php?action=crimes&vn=5 alt=5 /> <area shape=rect coords=117,17,140,69 href=macrocheck.php?action=crimes&vn=4 alt=4 /> <area shape=rect coords=80,17,103,69 href=macrocheck.php?action=crimes&vn=3 alt=3 /> <area shape=rect coords=42,16,65,68 href=macrocheck.php?action=crimes&vn=2 alt=2 /> <area shape=rect coords=7,16,30,68 href=macrocheck.php?action=crimes&vn=1 alt=1 /> </map> <hr color=#000000 width=80%> </center> "; exit; } if($vn == $session[check] & $action == crimes){ $addmacro = mysql_query("update userdb set macrocheck = 'Y' where id='$playerinfo[id]'"); header( 'Location: crimes.php' ) ; exit; } if($_REQUEST['vn'] !== $session[check] & $action == crimes){ echo "hi"; exit; } } Now even though i click the correct number its send me back to the macrocheck page, kinda like its working but its not adding the value Y to the database and therefore is doing it all over again EDIT, i have removed the redirect, and its now producing whats in that if statement, the the top is correct Link to comment https://forums.phpfreaks.com/topic/44013-solved-need-help-with-bot-checking-script/#findComment-214273 Share on other sites More sharing options...
matty Posted March 24, 2007 Author Share Posted March 24, 2007 All is sorted now, its was a problem with my redirection. Thanks guys.. Link to comment https://forums.phpfreaks.com/topic/44013-solved-need-help-with-bot-checking-script/#findComment-214279 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.