Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $numbers = array(1,2,3,4,5,6,7,8,9,10,12);
- $letters = array("un","deux","trois","quatre","cinq","six","sept","huit","neuf","dix","onze","douze");
- $rand1 = rand(1,count($numbers));
- $rand2 = rand(1,count($numbers));
- $sign = ($rand1<=$rand2)?'+':(rand(0,3)?'-':'+');
- $sign_display = ($sign=='-')?(rand(0,1)?'-':'moins'):(rand(0,1)?'+':'plus');
- $int = $numbers[$rand1-1]+$numbers[$rand2-1]*(($sign=='-')?-1:1);
- $challenge = (rand(0,1)?$numbers[$rand1-1]:$letters[$rand1-1]).' '.$sign_display.' '.(rand(0,1)?$numbers[$rand2-1]:$letters[$rand2-1]);
- $salt = md5(uniqid());
- $checksum = md5($int.$salt);
- // display $challenge as a question and pass $salt and $checksum in hidden fields, then check that md5(answer.$salt)==$checksum
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement