config.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. /*
  3. FusionPBX
  4. Version: MPL 1.1
  5. The contents of this file are subject to the Mozilla Public License Version
  6. 1.1 (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.mozilla.org/MPL/
  9. Software distributed under the License is distributed on an "AS IS" basis,
  10. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11. for the specific language governing rights and limitations under the
  12. License.
  13. The Original Code is FusionPBX
  14. The Initial Developer of the Original Code is
  15. Mark J Crane <[email protected]>
  16. Portions created by the Initial Developer are Copyright (C) 2008-2012
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. Mark J Crane <[email protected]>
  20. */
  21. $pathtofonts = "/captcha/fonts/"; //path from the root of the website
  22. /*
  23. //How to use this Captcha
  24. //Option1: add this to the html form
  25. <table width='100%' border='0' cellpadding="3" cellspacing="0">
  26. <tr>
  27. <td colspan='2'>Please type the code you see from the image into the text box below.</td>
  28. </tr>
  29. <tr>
  30. <td align='right'><img src='/captcha/img.php'></td>
  31. <td align='right'><input type="text" name="captcha" size="15"></td>
  32. </tr>
  33. </table>
  34. //Option2: or add this to the html form
  35. <br>
  36. <script language="JavaScript" type="text/javascript">
  37. function genNewCaptcha(imgObj) {
  38. var randnum = Math.floor((1-1000)*Math.random()+1000);
  39. imgObj.src='/captcha/img.php?x=' + randnum;
  40. }
  41. </script>
  42. <table cellpadding="0" cellspacing="0" border="0" width="100%">
  43. <tr>
  44. <td align="center" colspan="2" style="font-size: 11px;">Please enter the text you see from the image below...</td>
  45. </tr>
  46. <tr>
  47. <td align="center" valign="bottom" width="50%"><img id="captchaimg" src="/captcha/img.php" onclick="genNewCaptcha(this); document.getElementById('captcha').focus();" onmouseover="this.style.cursor='hand';" alt="Click for a new image."></td>
  48. <td align="center" valign="bottom" width="50%"><input type="text" class="txt" style="text-align: center;" name="captcha" id="captcha" size="15" style="margin-top: 15px;"></td>
  49. </tr>
  50. <td align="center" colspan="2" style="font-size: 9px;"><br>Can't read the image text? Click the image for a new one.</td>
  51. </table>
  52. <br>
  53. //add this to the top of the page where the form is submitted to
  54. //--- begin captcha verification ---------------------
  55. //ini_set("session.cookie_httponly", True); session_start(); //make sure sessions are started
  56. if (strtolower($_SESSION["captcha"]) != strtolower($_REQUEST["captcha"]) || empty($_SESSION["captcha"])) {
  57. echo " <span class=\"h2\">Sorry!</span>\n";
  58. //echo " <br><br>\n";
  59. //echo "\n";
  60. //echo " <b>Your e-mail was NOT sent.</b>\n";
  61. echo " <br><br>\n";
  62. echo " <b>Error: <span style=\"color: red;\">Captcha Image Verification Failed</span></b><br>\n";
  63. echo " <img src=\"/images/spacer.gif\" width=\"325\" height=\"1\" border=\"0\">\n";
  64. echo " <br><br>\n";
  65. echo " <a href=\"contact.php\">Try Again?</a>";
  66. exit;
  67. }
  68. else {
  69. //echo "verified";
  70. }
  71. //--- end captcha verification -----------------------
  72. //notes
  73. A diverse collection of unique fonts can improve the captcha.
  74. If bots get past the captcha try changing fonts.
  75. Ideas that may be implemented in the future...
  76. 1. randomize the background with texture, color and/or gradient
  77. 2. distort the image
  78. 3. rotate the characters with different rotations.
  79. 4. use audio, svg, or flash
  80. //additional fonts can be obtained from
  81. http://simplythebest.net/fonts/
  82. http://www.1001freefonts.com/afonts.htm
  83. //Usefull Links
  84. http://sam.zoy.org/pwntcha/
  85. http://en.wikipedia.org/wiki/Captcha
  86. */
  87. ?>