Random Javascript and PHP generation
Published: Wed, 15 Aug 2007 08:19:10 GMT
Updated: Sat, 22 Mar 2025 15:38:03 GMT
This code was based on a CAPTCHA I wrote but it could be useful in other areas such as comment spam protection. The idea is that a few random code blocks are generated on the client and server side, so each language (PHP, Javascript) has the same code. For example:-
<pre lang="javascript"> num = 1330; for(i=0;i<2;i++) { num += 25; for(j=0;j<2;j++) { num += 25; } cfapqx = num </pre>The variables and the code are completely randomised so you should never get the same value, PHP will actually have the same code and therefore knows the result of the Javascript code block.
Here's the source, enjoy ;)