uForum.uz

uForum.uz (https://uforum.uz/index.php)
-   Веб программирование (https://uforum.uz/forumdisplay.php?f=171)
-   -   Антиспам в PHP (https://uforum.uz/showthread.php?t=4475)

Ravshan_R 24.03.2008 16:51

Антиспам в PHP
 
Privet vsem ya sozdal obichniy gastivoy no u me takay probmlema, ya kazdey den ego ocheshayo ot spama. Narod pomogite mne ego zashitit ot spama. ya slishel est sistema antibot :cray:

Akmal Bafoev 24.03.2008 17:33

самый примитивный способ - добавить captcha (картинка с кодом)

Vitaliy Fioktistov 24.03.2008 18:02

Это только от ботов защитит, если же надо проконтролировать, ЧТО написал человек, то придется поискать готовый или самому написать. Алгоритмы, кстати, у таких фильтров не самые тривиальные.

Ravshan_R 24.03.2008 18:07

Esli u vast esti takiy php skipti (s jashitoy ot avtomaticheskogo zapolneniya). vi mojeti link skajat

shumbola 24.03.2008 21:05

Вот первая попавшая ссылка CAPTCHA

Vitaliy Fioktistov 25.03.2008 09:55

Если же взять чуть шире проблему левых постов, то вот неплохой фильтр антимата (требуется напильник, чтоб заработал и некоторое пополнение базы) Censure

wwwjs 24.02.2009 19:24

Код:

<?php
session_start();

class CaptchaSecurityImages {
 
  var $font = 'fonts/verdana.ttf';
 
  function generateCode($characters) {
      /* list all possible characters, similar looking characters and vowels have been removed */
      $possible = '23456789bcdfhkmnprstvwxz';
      $code = '';
      $i = 0;
      while ($i < $characters) {
        $code .= substr($possible, mt_rand(0, strlen($possible)-1), 1);
        $i++;
      }
      return $code;
  }
 
  function CaptchaSecurityImages($width='120',$height='40',$characters='6') {
      $code = $this->generateCode($characters);
      $_SESSION['security_code'] = $code;
      /* font size will be 75% of the image height */
      $font_size = $height * 0.75;
      $image = imagecreate($width, $height) or die('Cannot initialize new GD image stream');
      /* set the colours */
      $background_color = imagecolorallocate($image, 255, 255, 255);
      $text_color = imagecolorallocate($image, 48, 56, 63);
      $noise_color = imagecolorallocate($image, 160, 169, 214);
      /* generate random dots in background */
      for( $i=0; $i<($width*$height)/3; $i++ ) {
        imagefilledellipse($image, mt_rand(0,$width), mt_rand(0,$height), 1, 1, $noise_color);
      }
      /* generate random lines in background */
      for( $i=0; $i<($width*$height)/150; $i++ ) {
        imageline($image, mt_rand(0,$width), mt_rand(0,$height), mt_rand(0,$width), mt_rand(0,$height), $noise_color);
      }
      /* create textbox and add text */
      $textbox = imagettfbbox($font_size, 0, $this->font, $code) or die('Error in imagettfbbox function');
      $x = ($width - $textbox[4])/2;
      $y = ($height - $textbox[5])/2;
      imagettftext($image, $font_size, 0, $x, $y, $text_color, $this->font , $code) or die('Error in imagettftext function');
      /* output captcha image to browser */
      header('Content-Type: image/jpeg');
      imagejpeg($image);
      imagedestroy($image);
  }
}
 
$captcha = new CaptchaSecurityImages(90,20,5);
 
?>

а в файлах используйте <img src="captcha.php">


Текущее время: 14:05. Часовой пояс GMT +5.

Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd. Перевод: zCarot
OOO «Единый интегратор UZINFOCOM»