SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Apr 2013
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    program to remove contact information from message like email and phone

    hi


    In my project users comminicate with each other by sending messages to each.

    I have developed this feature.

    I want to remove contact information from message like name or number more than 4 character in length.

    users can comminicate with each other by sending n receiving message but can not send contact information.

    i want solution in any php or any other technology.

    any idea?



    Thanks
    shahab

  2. #2
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,069
    Mentioned
    153 Post(s)
    Tagged
    2 Thread(s)
    You can't. There is no technology advanced enough in any language to do this. What you can do is remove the obvious, like email addresses, phone numbers, and URLs because they have a specific format. But names cannot be seen because there is nothing that makes them stand out from any other word.

    Still, with URLs it's quite hard to stop everything. What if users type stuff like me [at] example [dot] com, moc.elpmaxe@em (but reversed) me-example-com, etc.

    If you want 100% certainty no contact details come through ever, you need somebody to moderate all the messages by hand.
    Rémon - Hosting Advisor

    SitePoint forums will switch to Discourse soon! Make sure you're ready for it!

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  3. #3
    SitePoint Zealot
    Join Date
    Apr 2013
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Thanks for support and information.

    Could you please provide program to remove email,phone and urls.

    It is okay if user write example dot com in message.

    I need to remove emails,phone numbers more than 4 and urls.

    -Thanks

  4. #4
    SitePoint Zealot
    Join Date
    Apr 2013
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I have following solution and want to share.

    Code:
    <?php
    
    function sanitize_message( $message , $email = true, $numbers = true, $url = true )
    {
    
    	//$message = strip_tags( $message );
    	
    	if($email)
    	{
    		//strip email address
    		$email_regexp = "[_A-Za-z0-9-]+(\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*(\.[A-Za-z]{2,3})";
    		$message = ereg_replace($email_regexp, '', $message);
    	}
    	
    	if($numbers)
    	{
    		//echo count($numbers);	
    		//strip all numerical values
    		$number_regexp = "[0-9]";
    		$message = ereg_replace($number_regexp, '', $message);
    	}
    	
    	//eliminate url from message
    	if($url)
    	{
    		$url_regexp = "(https?://)?(www\.)?([a-zA-z0-9\.])*[a-zA-Z0-9]*\.[a-z]{2,3}";
    		$message = ereg_replace($url_regexp, '', $message);
    	}
    	
    	//eliminate all the bad words
    	$bad_words = array("f**k", "son of a b***h");
    	$message = str_ireplace($bad_words, '', $message);
    	
    	//eliminate all the email words
    	$email_words = array("skype", ".net", ".com", "org", "biz", "@", "yahoo.com", "gmail", "hotmail", "mail", "e-mail", "msn", "dot","net","com",".org",
    						 "at",".org","Gmail.com","Ymail.com", "Hotmail.com", "AOL.com ","Easy.com","Sky.com", "AEmail4u.com", "Caramail", "Care2.com", 
    						 "Catholic Online", "CentralPets", "Computermail", "DC Email", "Ecology Fund", "E-Mail Anywhere", "EasyPeasy", "Eboxmail.net", 
    						 "EmailAccount", "EmailAccounts4Free", "EmailChoice", "Emailyou", "EmailX.net", "Eudora Web Mail","Everyone.net","Execs2K", 
    						 "FastMail", "FasterMail", "FirstName.com","FlashMail","Fresno Mail","Garfield","Gawab","Glay.org", "GMail", "GMX", "Go.com", 
    						 "Go2Now", "GotGeekMail", "Graffiti.net", "Hello Kitty","HushMail","InBox.com", "JoinMe","JoyMail","JungleMate","Killer","KittyMail",
    						 "KuKaMail","Lycos.com", "Mail.com", "Mail2World", "MailCity", "Maktoob","MeowMail", "MyOwnEmail", "MyPersonalEmail", "MyPlace",
    						 "MyRealBox", "MyWay","Netscape Mail","NoPeddlers.com","NZ11.com", "OperaMail","OutGun","ParsMail","Rediff Mail", "SiteWarp",
    						 "Snowboard","Surfy.net","SwissMail","UltimateEmail", "Unlimited Mail","Yahoo",".net");
    	$message = str_ireplace($email_words, '', $message);
    
    	return $message;
    
    }
    
    $MyMessage="
    Hi Test,
    <br/><br/>
    Good Morning.
    <br/><br/>
    How are you? I am good.
    <br/><br/>
    Mobile number => 1234567890
    <br/><br/>
    Email address => test@gmail.com and example@email.com
    <br/><br/>
    Website address => http://www.example.com
    <br/><br/>
    Email address => test at yahoo dot org
    <br/><br/>
    Email address => test at gmail dot com
    <br/><br/>
    See you soon.Bye.
    <br/><br/>
    -Thanks
    
    ";
    
    echo"<br>".$MyMessage."<br>";
    echo"<br>------------------------------------------<br>";
    echo"<br>".$Test2 = sanitize_message($MyMessage)."<br>";
    
    ?>
    I am removing all numbers from message but I want to remove only numbers more than 4 in length.


    Any idea?

    -Thanks


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •