PageRenderTime 45ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/concrete/libraries/3rdparty/securimage/example_form.php

https://bitbucket.org/seanom/concrete5
PHP | 71 lines | 49 code | 17 blank | 5 comment | 5 complexity | 6a4c416f549f2037504b04e50725e9c7 MD5 | raw file
  1. <?php
  2. /**
  3. * Project: Securimage: A PHP class for creating and managing form CAPTCHA images<br />
  4. * File: securimage.php<br />
  5. * URL: www.phpcaptcha.org
  6. */
  7. session_start(); // Start the session where the code will be stored.
  8. ?>
  9. <html>
  10. <head>
  11. <title>Securimage Test Form</title>
  12. </head>
  13. <body>
  14. <?php
  15. if (empty($_POST)) { ?>
  16. <form method="POST">
  17. Username:<br />
  18. <input type="text" name="username" /><br />
  19. Password:<br />
  20. <input type="text" name="password" /><br /><br />
  21. <div style="width: 430px; float: left; height: 90px">
  22. <img id="siimage" align="left" style="padding-right: 5px; border: 0" src="securimage_show.php?sid=<?php echo md5(time()) ?>" />
  23. <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="19" height="19" id="SecurImage_as3" align="middle">
  24. <param name="allowScriptAccess" value="sameDomain" />
  25. <param name="allowFullScreen" value="false" />
  26. <param name="movie" value="securimage_play.swf?audio=securimage_play.php&bgColor1=#777&bgColor2=#fff&iconColor=#000&roundedCorner=5" />
  27. <param name="quality" value="high" />
  28. <param name="bgcolor" value="#ffffff" />
  29. <embed src="securimage_play.swf?audio=securimage_play.php&bgColor1=#777&bgColor2=#fff&iconColor=#000&roundedCorner=5" quality="high" bgcolor="#ffffff" width="19" height="19" name="SecurImage_as3" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
  30. </object>
  31. <br />
  32. <!-- pass a session id to the query string of the script to prevent ie caching -->
  33. <a tabindex="-1" style="border-style: none" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = 'securimage_show.php?sid=' + Math.random(); return false"><img src="images/refresh.gif" alt="Reload Image" border="0" onclick="this.blur()" align="bottom" /></a>
  34. </div>
  35. <div style="clear: both"></div>
  36. Code:<br />
  37. <!-- NOTE: the "name" attribute is "code" so that $img->check($_POST['code']) will check the submitted form field -->
  38. <input type="text" name="code" size="12" /><br /><br />
  39. <input type="submit" value="Submit Form" />
  40. </form>
  41. <?php
  42. } else { //form is posted
  43. include("securimage.php");
  44. $img = new Securimage();
  45. $valid = $img->check($_POST['code']);
  46. if($valid == true) {
  47. echo "<center>Thanks, you entered the correct code.<br />Click <a href=\"{$_SERVER['PHP_SELF']}\">here</a> to go back.</center>";
  48. } else {
  49. echo "<center>Sorry, the code you entered was invalid. <a href=\"javascript:history.go(-1)\">Go back</a> to try again.</center>";
  50. }
  51. }
  52. ?>
  53. </body>
  54. </html>