|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
php-general Digest 28 Aug 2006 03:29:10 -0000 Issue 4316
php-general-digest-help
lists.php.net
Date: Sun Aug 27 2006 - 22:29:10 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 28 Aug 2006 03:29:10 -0000 Issue 4316
Topics (messages 241142 through 241151):
Re: Email with pregmatch
241142 by: Dave Goodchild
241143 by: Peter Lauri
241144 by: Michael B Allen
S: function to remove & break URLs
241145 by: RalfGesellensetter
241150 by: Jon Anderson
display a single thumb per gallery
241146 by: Ross
241147 by: Dave Goodchild
241148 by: Ross
241149 by: Alex Turner
Comparing strings... need advice. :)
241151 by: Micky Hulse
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
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
attached mail follows:
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:buddhamagnet
gmail.com]
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
attached mail follows:
On Sun, 27 Aug 2006 20:35:47 +0700
"Peter Lauri" <lists
dwsasia.com> 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("^[A-Z0-9._%-]+
[A-Z0-9._%-]+\.[A-Z]{2,6}$", $email)
Mike
--
Michael B Allen
PHP Active Directory SSO
http://www.ioplex.com/
attached mail follows:
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.
attached mail follows:
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
attached mail follows:
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
attached mail follows:
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
attached mail follows:
$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 etc....something 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
attached mail follows:
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
attached mail follows:
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
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]