PDA

Просмотр полной версии : Антиспам в PHP


Ravshan_R
24.03.2008, 16:51
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 (http://www.white-hat-web-design.co.uk/articles/php-captcha.php)

Vitaliy Fioktistov
25.03.2008, 09:55
Если же взять чуть шире проблему левых постов, то вот неплохой фильтр антимата (требуется напильник, чтоб заработал и некоторое пополнение базы) Censure (http://forum.dklab.ru/php/advises/CensureOpredelenieNalichiyaMataNetsenzurnihSlovVTe ksteMatotest.html)

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',$c haracters='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">