一个PHP的检验码工具Securimage

xiaoxiao2024-04-22  38

什么是Securimage? Securimage是一个开源/免费的phpCAPTCHA脚本,它可以用来生成复杂的验证码图片,帮助您的网站防止spam。它可以轻松嵌入网站已存的表单中,为您的网站提供spam机器人的防护。它可以运行于大部分支持php(GD)的webserver上。 *点击这里查看快速指南 *Securimage实例 *下载最新版本 Securimage的特性: * 仅用三行代码即可显示验证码 * 仅用六行代码即可对验证码的输入进行验证 * 自定义验证码长度 * 自定义字符集 * 支持TTF * 使用自定义的GD字体(若TTF不支持) * 轻松添加自定义背景图片 * 丰富的文本支持,包括颜色/角度/透明度选项 * 文字淆乱Arched lines through text * 生成wav格式的CAPTCHA音频文件 * 自定义CAPTCHA的验证码列表 下面给大家一个简单的例子: 1. <html> 2. <head> 3. <title>Securimage Test Form</title> 4. </head> 5. <body> 6. <?php 7. if (empty($_POST)){?> 8. <form method="POST"> 9. Username:<br /> 10. <input type="text" name="username" /><br /> 11. Password:<br /> 12. <input type="text" name="password" /><br /> 13. 14. <!-- 调用securimage,显示验证码图片,sid是用来防止被cache住的 --> 15. <img src="securimage_show.php?sid=<?php echomd5(uniqid(time()));?>"><br /> 16. <input type="text" name="code" /><br /> 17. <input type="submit" value="Submit Form" /> 18. </form> 19. 20. <?php 21. } else{//form is posted 22. include("securimage.php"); 23. $img=new Securimage(); 24. $valid=$img->check($_POST['code']);//检查用户的输入是否正确 25. 26. if($valid==true) { 27. echo "<center>Thanks, you entered the correct code.</center>"; 28. } else{ 29. echo "<center>Sorry, the code you entered was invalid. <a href=\"javascript:history.go(-1)\">Go back</a> to try again.</center>"; 30. } 31. } 32. 33. ?> 34. 35. </body> 36. </html> securimage_show.php的代码: 1. <?php 2. include 'securimage.php';//下载包里面的核心类库代码 3. $img=new securimage(); 4. $img->show();// alternate use: $img->show('/path/to/background.jpg'); 5. ?> 相关资源:敏捷开发V1.0.pptx
转载请注明原文地址: https://www.6miu.com/read-5015160.html

最新回复(0)