putty Posted February 25, 2009 Share Posted February 25, 2009 In an attempt to automatically hide my email from spam bots, I have been working on a script that turns all email on a page into ASCII, however I am having trouble with one little bit of code. Douse anyone have a script that can return all emails within a string as an array? Cheers. Quote Link to comment https://forums.phpfreaks.com/topic/146940-hide-email/ Share on other sites More sharing options...
premiso Posted February 25, 2009 Share Posted February 25, 2009 If they are separated by an item explode would split them into an array. EDIT: Not sure if you wanted the "email" to be returned as an array (like a single email) if so I believe str_split is what you would be after. Quote Link to comment https://forums.phpfreaks.com/topic/146940-hide-email/#findComment-771425 Share on other sites More sharing options...
Q695 Posted February 26, 2009 Share Posted February 26, 2009 I like to give each user that can receive e-mail a unique id that pertains to the user e-mail address, then on the back end I run the mail algorythim. Quote Link to comment https://forums.phpfreaks.com/topic/146940-hide-email/#findComment-771579 Share on other sites More sharing options...
putty Posted February 26, 2009 Author Share Posted February 26, 2009 The problem is that the code is coming out of the CMS as plain text with the emails within the text Example: $content = " Some test text with email1@domain.com two email address email2@domain2.com, there could be many many email addresses. "; $content = new SpiderTrap($content); class SpiderTrap{ public function __construct($content){ return $this->emailFilter($content); } public function emailFilter($content){ $search = "~[\s]+([^\s]+@[^\s]+)[\s]+~iUs"; // Find the tags preg_match_all($search, $content, $matches); // Loop through each tag for ($i=0; $i < count($matches['0']); $i++) { $value = $matches['1'][$i]; $email = $this->email2ascii($value); $content = str_replace($value, $email, $content); } return $content; } function email2ascii($email){ $asciiEmail = ''; $lenght = strlen($email); for($i = 0; $i < $lenght; $i++){ $asciiEmail .= '&#' . ord($email[$i]) . ';'; } return $asciiEmail; } } The problem is with the regular expression, it only ever finds the first email. Is there anyone who has some skill with regular expression who can help me out? Quote Link to comment https://forums.phpfreaks.com/topic/146940-hide-email/#findComment-771718 Share on other sites More sharing options...
Q695 Posted February 26, 2009 Share Posted February 26, 2009 There is a built in option for mail to be sent as html, not other things. Quote Link to comment https://forums.phpfreaks.com/topic/146940-hide-email/#findComment-772080 Share on other sites More sharing options...
The Little Guy Posted February 26, 2009 Share Posted February 26, 2009 You could load the users email into flash, I don't know of any bots that can read flash. Quote Link to comment https://forums.phpfreaks.com/topic/146940-hide-email/#findComment-772085 Share on other sites More sharing options...
Q695 Posted February 27, 2009 Share Posted February 27, 2009 Are you talking about having a captcha that is required before sending the e-mail to someone, otherwise it runs a loop? Quote Link to comment https://forums.phpfreaks.com/topic/146940-hide-email/#findComment-772370 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.