[PHP] Email with pregmatch
Hi, I am trying to check if an email is an email or not, so I used this that I found on the internet: preg_match("/^([a-zA-Z0-9])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+/", $_POST['email']); BUT, it returns false with the email [EMAIL PROTECTED] And ok for [EMAIL PROTECTED] What is the error here :) /Peter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Email with pregmatch
Try this: preg_match("/^([a-zA-Z0-9.])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+/", $_POST['email']); -- http://www.web-buddha.co.uk http://www.projectkarma.co.uk
RE: [PHP] Email with pregmatch
I found this on google, does this LONG function do anything more then your preg_match? function isEmail($emailstr) { // Make the email address lower case and remove whitespace $emailstr = strtolower(trim($emailstr)); // Split it up into before and after the @ symbol $email_components = explode('@', $emailstr); // Check that there is only one @ symbol if (count($email_components) != 2) return FALSE; // Check that the username is >= 1 char if (strlen($email_components[0]) == 0) return FALSE; // Split the domain part into the dotted parts $domain_components = explode('.', $email_components[1]); // check there are at least 2 if (count($domain_components) < 2) return FALSE; // Check each domain part to ensure it doesn't start or end with a bad char foreach ($domain_components as $domain_component) if ( strlen($domain_component) > 0 ) { if ( preg_match('/[\.-]/', $domain_component[0]) || preg_match('/[\.-]/', $domain_component[strlen($domain_component)-1]) ) return FALSE; } else return FALSE; // Check the last domain component has 2-6 chars (.uk to .museum) $domain_last = array_pop($domain_components); if (strlen($domain_last) < 2 || strlen($domain_last) > 6) return FALSE; // Check for valid chars - Domains can only have A-Z, 0-9, ., and the - chars, // or be in the form [123.123.123.123] if ( preg_match('/^\[(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\]$/', $email_components[1], $ipnum) ) return (ip2long($ipnum[1]) === false ? false : true); if ( preg_match('/^[a-z0-9\.-]+$/', $email_components[1]) ) return TRUE; // If we get here then it didn't pass return FALSE; } /Peter From: Dave Goodchild [mailto:[EMAIL PROTECTED] Sent: Sunday, August 27, 2006 8:47 PM To: Peter Lauri Cc: php-general@lists.php.net Subject: Re: [PHP] Email with pregmatch Try this: preg_match("/^([a-zA-Z0-9.])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+/", $_POST['email']); -- http://www.web-buddha.co.uk http://www.projectkarma.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Email with pregmatch
On Sun, 27 Aug 2006 20:35:47 +0700 "Peter Lauri" <[EMAIL PROTECTED]> wrote: > Hi, > > I am trying to check if an email is an email or not, so I used this that I > found on the internet: > > preg_match("/^([a-zA-Z0-9])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+/", > $_POST['email']); This is what I use: eregi("[EMAIL PROTECTED],6}$", $email) Mike -- Michael B Allen PHP Active Directory SSO http://www.ioplex.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] S: function to remove & break URLs
Dear list, does anybody of you know these spammers filling up your guestbook with URLs? With strip_tags, I managed to remove the html tags. But what I want is this: 1. Detect such entries (to hide them by default) 2. Destroy URLs As for 2. I am thinking of adding spaces after at least every 12 characters (or even after every dot) - what do you recommend? Just removing "http://"; still leaves the domain behind. A good start could be to replace "." by ". " and "/" by " / ". Any code to share? Cheers Ralf. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] display a single thumb per gallery
I have a database of images, http://www.thethistlehouse.com/db.jpg What I want to do is select ONLY ONE image to display as a the image link for that gallery. As you can see galleries are numbered dynamcially but galleries can also be added and deleted so the galleries no's I have now (7, 8) will change. I have the code to display the thubnail but am stuck with the query. I want to use mysql and php to (i) determine how many unique galleries there are. (ii) Retrieve & display a single thumbnail from each gallery to act as the link to that gallery Ross -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] display a single thumb per gallery
To find out how many unique galleries: SELECT DISTINCT gallery FROM table Ross -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- http://www.web-buddha.co.uk http://www.projectkarma.co.uk
Re: [PHP] display a single thumb per gallery
$query = "SELECT distinct gallery FROM thumbnails"; that only returns the numbers 7 & 8. I need the all the info from the rows - id, binary data etcsomething like $query = "SELECT * FROM DISTINCT gallery FROM thumbnails"; any ideas? - Original Message - From: Dave Goodchild To: Ross Cc: php-general@lists.php.net Sent: Sunday, August 27, 2006 8:21 PM Subject: Re: [PHP] display a single thumb per gallery To find out how many unique galleries: SELECT DISTINCT gallery FROM table Ross -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- http://www.web-buddha.co.uk http://www.projectkarma.co.uk
Re: [PHP] display a single thumb per gallery
Here is one way of doing it: Group by gallery and return max for image id. Place the resultant Gallery and Image values in an array of arrays. SELECT Gallery, Max(Image) FROM Thumbnails GROUP BY Gallery Then loop over the outer array returning the entire thumbnail row where gallery and image match the values in the inner array SELECT * FROM Thumbnails WHERE Gallery=XXX AND Image=XXX This all assumes there is a column called Image that uniquely identifies each row - if there is not - errr. Cheers AJ Dave Goodchild wrote: To find out how many unique galleries: SELECT DISTINCT gallery FROM table Ross -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- www.deployview.com www.nerds-central.com www.project-network.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] S: function to remove & break URLs
RalfGesellensetter wrote: Dear list, does anybody of you know these spammers filling up your guestbook with URLs? With strip_tags, I managed to remove the html tags. But what I want is this: 1. Detect such entries (to hide them by default) 2. Destroy URLs As for 2. I am thinking of adding spaces after at least every 12 characters (or even after every dot) - what do you recommend? Just removing "http://"; still leaves the domain behind. A good start could be to replace "." by ". " and "/" by " / ". Guestbook spam (and comment spam) is something I'd like to try to eliminate altogether myself. I don't think there are any one-size-fits all solutions out there yet for detection/elimination. I'd personally like to hear any effective solutions people have found in PHP to combat this stuff. In reference to the detection part; In my case, 95%+ of the spam entries have links that contain one of about 5 words (casino, pharm, drug, stock, or invest), so I could eliminate most spam by automatically trashing all entries that contains a link with one of those key words. I don't know if you're lucky enough to have spammers as predictable as mine, so that may not be an effective solution for anyone but me. In terms of destroying URLs, what happens when a real guest wants to put a URL in their entry? Seems to me that you might be overshooting... You might be better off finding some way of preventing the data from even entering the system, for example, a captcha type system. They have accessibility problems, but I've read about solutions that use simple JavaScript to automatically enter the captcha code into the correct field and hide the captcha and the field so that the whole process is transparent to the user (including users with screen readers), whereas if JS is disabled, the captcha is shown and the code must be entered. This is based on the assumption that current spam robots that don't incorporate a JavaScript execution engine. Not sure how effective it is, but it's an interesting idea. Anyone want to share some spam-fighting success stories? jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Comparing strings... need advice. :)
Hi, I am looking for the most secure/efficient way to compare these two strings: /folder1/folder2/folder3/folder4/ /folder1/folder2/folder3/folder4/file.php Basically I am trying to setup as many security features as possible for a simplistic (home-grown/hand-coded) CMS... This appears to work: $haystack = '/folder1/folder2/folder3/folder4/someFileName.php'; $needle = '/folder1/folder2/folder3/folder4/'; if(substr_count($haystack, $needle) === 1) echo "yea"; Before making changes to "someFileName.php" I want to make sure it is within the allowed path ($needle). I would appreciate any advice. Even RTFM is cool. :D Many TIA, Cheers, Micky -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] S: function to remove & break URLs
On Sun, 2006-08-27 at 20:31 -0400, Jon Anderson wrote: > In reference to the detection part; In my case, 95%+ of the spam entries > have links that contain one of about 5 words (casino, pharm, drug, > stock, or invest), so I could eliminate most spam by automatically > trashing all entries that contains a link with one of those key words. I > don't know if you're lucky enough to have spammers as predictable as > mine, so that may not be an effective solution for anyone but me. > I wrote a mailing list application (GNU Mailman style) in PHP and wrote in an excellent spam filter into that - not one spam mail yet... Basically, I had the users sign up through a web interface, and then fill in their details during registration. The users in my users table are assigned a unique userId, which I then reference through the mailing list module. Basically what happens is: 1. Mail comes in through a POP3 account 2. The messages are downloaded and MIME messages decoded. 3. Message "From" headers are checked for a valid email address 4. The email address is looked up in the users table 5. The userId in the users table is compared to the userId in the mailing list subscribers table 6. If the email addresses from both match, and the userId is the same, the mail is inserted into the mail table, with a ref to the attachment(s) if any 7. A cron picks it up and emails the new mail to all subscribers. Basically, in order to get a mail through, you need to be a valid user, and subscribe to a list, otherwise you are treated as spam and discarded. --Paul All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php