Mi Captcha

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Hola quisiera saber como puedo implementar es codigo de Captcha en el login (algunos css para el mismo) del xnova 1.8 para lograra la utentificacion del mismo atraevez del captcha.

      PHP Source Code

      1. //Por josevdr95
      2. <?php
      3. $imagen = imageCreate(100, 35);
      4. $fondo = imageColorallocate ($imagen, 126, 220, 153);
      5. $texto1 = imageColorallocate ($imagen, 0, 0, 255);
      6. $aleatorio = rand (100000, 999999);
      7. imagefill($imagen, 50, 0, $fondo);
      8. imagestring($imagen,80,0,0, $aleatorio , $texto1);
      9. header('content-type: image/png');
      10. imagepng($imagen);
    • с этим не чего не сделать вы дали кусок малый кода что бы работать надо владеть полной информацией по коду - к примеру вам нужно написать свой вариант отдельно типа такого..
      к примеру в general инклудим ... (но по сути я показал пример .. дальше на примере думаем сами .. я так тоже переписываю каптчу.. именно свою .. отталкивался от этого варианта... который ниже но переделал по своему)
      include('classes' . DIRECTORY_SEPARATOR . 'Captcha.php');
      include('classes' . DIRECTORY_SEPARATOR . 'Interface.php');




      Source Code

      1. плюс отдельно Interface.php можно не создавать но желательно отдельно вынести проверка на ошибку так же тут будет
      2. include('Interface.php');
      3. interface CaptchaInterface
      4. {
      5. public function session_write($code);
      6. public function generate_code();
      7. }
      8. далее создаем файл
      9. Captcha.php
      10. class CaptchaValue implements Interface
      11. {
      12. private $font_dir = '';
      13. public function __construct()
      14. {
      15. $this->font_dir = $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'fonts' . DIRECTORY_SEPARATOR;
      16. }
      17. public function session_write($code)
      18. {
      19. session_start();
      20. $_SESSION['captcha_value'] = md5(md5($code));
      21. $_SESSION['answer_time'] = strtotime(date('d-m-Y H:i:s'));
      22. }
      23. public function generate_code()
      24. {
      25. $chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
      26. $length = rand(4, 6);
      27. $numChars = strlen($chars);
      28. $str = '';
      29. for ($i = 0; $i < $length; $i++)
      30. {
      31. $str .= substr($chars, rand(1, $numChars) - 1, 1);
      32. }
      33. $array_mix = preg_split('//', $str, -1, PREG_SPLIT_NO_EMPTY);
      34. srand((float) microtime() * 1000000);
      35. shuffle($array_mix);
      36. $result = implode("", $array_mix);
      37. $this->session_write($result);
      38. return $result;
      39. }
      40. public function captcha_image($code)
      41. {
      42. $image = imagecreatetruecolor(150, 70);
      43. imagesetthickness($image, 2);
      44. $background_color = imagecolorallocate($image, rand(220, 255), rand(220, 255), rand(220, 255));
      45. imagefill($image, 0, 0, $background_color);
      46. $linenum = rand(3, 5);
      47. for ($i = 0; $i < $linenum; $i++)
      48. {
      49. $color = imagecolorallocate($image, rand(0, 150), rand(0, 100), rand(0, 150));
      50. imageline($image, rand(0, 150), rand(1, 70), rand(20, 150), rand(1, 70), $color);
      51. }
      52. $font_arr = array_values(array_diff(scandir($this->font_dir), array('.', '..')));
      53. $font_size = rand(20, 30);
      54. $x = rand(0, 10);
      55. for ($i = 0; $i < strlen($code); $i++)
      56. {
      57. $x += 20;
      58. $letter = substr($code, $i, 1);
      59. $color = imagecolorallocate($image, rand(0, 200), 0, rand(0, 200));
      60. $current_font = rand(0, sizeof($font_arr) - 1);
      61. imagettftext($image, $font_size, rand(-10, 10), $x, rand(50, 55), $color, $this->font_dir . $font_arr[$current_font], $letter);
      62. }
      63. $pixels = rand(2000, 4000);
      64. for ($i = 0; $i < $pixels; $i++)
      65. {
      66. $color = imagecolorallocate($image, rand(0, 200), rand(0, 200), rand(0, 200));
      67. imagesetpixel($image, rand(0, 150), rand(0, 150), $color);
      68. }
      69. for ($i = 0; $i < $linenum; $i++)
      70. {
      71. $color = imagecolorallocate($image, rand(0, 255), rand(0, 200), rand(0, 255));
      72. imageline($image, rand(0, 20), rand(1, 50), rand(150, 180), rand(1, 50), $color);
      73. }
      74. header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
      75. header("Last-Modified: " . gmdate("D, d M Y H:i:s", 10000) . " GMT");
      76. header("Cache-Control: no-store, no-cache, must-revalidate");
      77. header("Cache-Control: post-check=0, pre-check=0", false);
      78. header("Pragma: no-cache");
      79. header("Content-type: image/png");
      80. imagepng($image);
      81. imagedestroy($image);
      82. }
      83. }
      Display All

      плюс еще надо написать форму свою скрипт бишь - вот тогда будет работать

      пример формы на основе моей

      <div class="big red Xsmall">
      <img src='/captcha.php' id='captcha-image'>
      <a href="javascript:void(0);" onclick="document.getElementById('captcha-image').src = 'captcha.php';">
      Обновить капчу
      </a>
      </div>
      Делаю качественно в сроки! на любой версии moons, встрою, или напишу любой мод , но дорого! afire-space.com