Closed (fixed)
Project:
Comment API
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
2 Jun 2010 at 12:50 UTC
Updated:
16 Dec 2010 at 16:16 UTC
Hi
Can any one help me hoe can we filter email & phone number in comments i have given
this code in _validate()
$s1 = $form_state['values']['comment'];
$Phone_Pattern = "/(\d)?(\s|-)?(\()?(\d){3}(\))?(\s|-){1}(\d){3}(\s|-){1}(\d){4}/";
$Email_Pattern = "|^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\.[a-zA-Z.]{2,5}$|";
$tendigit = "/([\d]{10})/";
$lines = spliti("\n", $s1);
$email_stripped_content = '';
$phone_stripped_content1 = '';
$phone_stripped_content2 = '';
$email_flag = '';
$phone_flag1 = '';
$phone_flag2 = '';
$str_content = '';
$set_error = '';
//srtip email addresses
$cont = '';
foreach($lines as $line)
{
$str_content = '';
$words = spliti(" ",$line);
if($words){
foreach($words as $word){
$email_flag = "";
$phone_flag = "";
$phone_flag2 = "";
if (!preg_match_all($Email_Pattern, $word, $matches)) {
//$email_stripped_content = " ".$word;
}
else
{
$email_flag = "yes";
$set_error = "yes";
}
if (!preg_match_all($Phone_Pattern, $word, $matches) && $email_flag != 'yes') {
//$email_stripped_content = " ".$word;
}
else
{
$phone_flag = "yes";
$set_error = "yes";
}
if (!preg_match_all($tendigit, $word, $matches) && $email_flag != 'yes') {
//$email_stripped_content = " ".$word;
}
else
{
$phone_flag2 = "yes";
$set_error = "yes";
}
if($email_flag == '' && $phone_flag == '' && $phone_flag2 == '')
{
$str_content .= " ".$word;
}
}
//end - for each
}
// end - if
$cont .= $str_content;
}
drupal_set_message($cont);
//end - main - for - each
$form_state['values']['comment'] = $cont;
no use
Please any one help
is there any function or module for comment filter
Comments
Comment #1
dragonwize commentedYou are probably better off asking this support in the help forums or in IRC. It seems you need some basic walk through help on the formapi.
Comment #2
Andrew Gorokhovets commentedsubscribe
Comment #3
Andrew Gorokhovets commented+1