php-general Digest 15 Jun 2010 03:00:29 -0000 Issue 6799

Topics (messages 306120 through 306146):

Re: Cookie access with CLI
        306120 by: Richard Quadling

protecting email addresses on a web site
        306121 by: David Mehler
        306122 by: Ashley Sheridan
        306123 by: HallMarc Websites
        306124 by: Ashley Sheridan
        306127 by: tedd
        306133 by: Dotan Cohen
        306134 by: Jonesy
        306135 by: Ashley Sheridan
        306142 by: Paul M Foster
        306143 by: Ashley Sheridan
        306144 by: Adam Richardson
        306145 by: Ashley Sheridan

Re: String Parse Help for novice
        306125 by: tedd
        306130 by: Robert Cummings

Another parse problem
        306126 by: tedd
        306128 by: Ashley Sheridan
        306129 by: tedd
        306131 by: Robert Cummings
        306132 by: Daniel P. Brown

PHP on command line -- mysql_connect error
        306136 by: Ferdi
        306137 by: Ashley Sheridan

Seeking developer for short term project
        306138 by: Dev Job

Re: is <?= good?
        306139 by: Daevid Vincent

Re: Quick Question
        306140 by: Karl DeSaulniers
        306141 by: Karl DeSaulniers

Re: Multiple Login in a single PC should not be possible
        306146 by: Karl DeSaulniers

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
On 13 June 2010 17:34, Shawn McKenzie <nos...@mckenzies.net> wrote:
> On 06/13/2010 09:58 AM, David Česal wrote:
>> Hello,
>>
>> I'm trying to access (from CLI) some website, where login is required.
>> Please, is it possible to set/save some cookies first (login session
>> information) and then access the website as logged user? All through CLI.
>>
>>
>>
>> Thank you very much for any information.
>>
>>
>>
>> David Cesal
>>
>>
>
> I'm almost positive you can do this with cURL and it should be fairly
> simple.  Check it out.
>
> http://php.net/manual/en/book.curl.php
>
> --
> Thanks!
> -Shawn
> http://www.spidean.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



-- 
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

--- End Message ---
--- Begin Message ---
Hello,
I've got a site that is needing to have two email addresses on it, one
for general contact and information and the other for webmaster for
site problems. I do not want these addresses to become harvested by
spammers yet i want to make it possible for people to email if needed.
I can not use javascript for this solution.
Suggestions appreciated.
Thanks.
Dave.

--- End Message ---
--- Begin Message ---
On Mon, 2010-06-14 at 08:02 -0400, David Mehler wrote:

> Hello,
> I've got a site that is needing to have two email addresses on it, one
> for general contact and information and the other for webmaster for
> site problems. I do not want these addresses to become harvested by
> spammers yet i want to make it possible for people to email if needed.
> I can not use javascript for this solution.
> Suggestions appreciated.
> Thanks.
> Dave.
> 


If Javascript isn't a solution (which I can understand for accessibility
reasons) then the only method I've seen that seems to work is to have
the email as an image in the same font style as it would be on the page
if it were just text. Facebook uses this to display contact email
addresses for people, and I've seen it used elsewhere also. The only
other method I've seen is to add in extra characters with a small note
to humans to remove them, but I find this quite a messy solution.

Unfortunately, you can't get away with just a contact form these days if
you're a business, as it's a legal requirement in some countries to have
a contact details available, and not just a contact form.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---

-----Original Message-----
From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
Sent: Monday, June 14, 2010 8:06 AM
To: David Mehler
Cc: php-general
Subject: Re: [PHP] protecting email addresses on a web site

On Mon, 2010-06-14 at 08:02 -0400, David Mehler wrote:

> Hello,
> I've got a site that is needing to have two email addresses on it, one
> for general contact and information and the other for webmaster for
> site problems. I do not want these addresses to become harvested by
> spammers yet i want to make it possible for people to email if needed.
> I can not use javascript for this solution.
> Suggestions appreciated.
> Thanks.
> Dave.
> 


If Javascript isn't a solution (which I can understand for accessibility
reasons) then the only method I've seen that seems to work is to have
the email as an image in the same font style as it would be on the page
if it were just text. Facebook uses this to display contact email
addresses for people, and I've seen it used elsewhere also. The only
other method I've seen is to add in extra characters with a small note
to humans to remove them, but I find this quite a messy solution.

Unfortunately, you can't get away with just a contact form these days if
you're a business, as it's a legal requirement in some countries to have
a contact details available, and not just a contact form.

Thanks,
Ash
http://www.ashleysheridan.co.uk


Another is a CSS solution where you type the email address backwards and
then use the CSS style declaration:
style="direction: rtl; unicode-bidi: bidi-override;"

Marc Hall
HallMarc Websites
 

__________ Information from ESET Smart Security, version of virus signature
database 5194 (20100614) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 


--- End Message ---
--- Begin Message ---
On Mon, 2010-06-14 at 08:26 -0400, David Mehler wrote:

> Hi,
> Thanks. How does putting the email address as the same font as the
> text stop crawlers from getting it?
> Thanks.
> Dave.
> 
> 
> On 6/14/10, Ashley Sheridan <a...@ashleysheridan.co.uk> wrote:
> > On Mon, 2010-06-14 at 08:02 -0400, David Mehler wrote:
> >
> >> Hello,
> >> I've got a site that is needing to have two email addresses on it, one
> >> for general contact and information and the other for webmaster for
> >> site problems. I do not want these addresses to become harvested by
> >> spammers yet i want to make it possible for people to email if needed.
> >> I can not use javascript for this solution.
> >> Suggestions appreciated.
> >> Thanks.
> >> Dave.
> >>
> >
> >
> > If Javascript isn't a solution (which I can understand for accessibility
> > reasons) then the only method I've seen that seems to work is to have
> > the email as an image in the same font style as it would be on the page
> > if it were just text. Facebook uses this to display contact email
> > addresses for people, and I've seen it used elsewhere also. The only
> > other method I've seen is to add in extra characters with a small note
> > to humans to remove them, but I find this quite a messy solution.
> >
> > Unfortunately, you can't get away with just a contact form these days if
> > you're a business, as it's a legal requirement in some countries to have
> > a contact details available, and not just a contact form.
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> >
> >


Hope you don't mind, I've copied the list back on in this reply.

What Facebook used to do (it doesn't seem to any more for some reason)
is have a small image with the email address on, and the filename is a
random string of letters and numbers. Presumably the thought is that the
spiders that spammers use to harvest email addresses won't be using OCR
on every image it comes across to detect an email address as that would
be too time-consuming for them.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
At 8:36 AM -0400 6/14/10, HallMarc Websites wrote:
Another is a CSS solution where you type the email address backwards and
then use the CSS style declaration:
style="direction: rtl; unicode-bidi: bidi-override;"

Marc Hall
HallMarc Websites

Marc:

That's clever. I never saw that before.

I guess that you could also span portions of it to reverse and other portions not to. Interesting.

Thanks,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
On 14 June 2010 15:36, HallMarc Websites <sa...@hallmarcwebsites.com> wrote:
> Another is a CSS solution where you type the email address backwards and
> then use the CSS style declaration:
> style="direction: rtl; unicode-bidi: bidi-override;"
>

How does that work with screen readers? How about copy-paste?

-- 
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com

--- End Message ---
--- Begin Message ---
On Mon, 14 Jun 2010 08:02:02 -0400, David Mehler wrote:
> 
> I've got a site that is needing to have two email addresses on it, one
> for general contact and information and the other for webmaster for
> site problems. I do not want these addresses to become harvested by
> spammers yet i want to make it possible for people to email if needed.
> I can not use javascript for this solution.

One way I do it at times is v-a-v what is seen in my .sig below.
It usually requires a fixed pitch font -- depending on how it's laid out.

I also use the image technique as described by others.

I also use the obfuscator technique with acceptable success.  
One reference
at:
        http://www.healyourchurchwebsite.com/obfuscator/

I would not use _all three_ on the same email addy....          :-)

HTH
Jonesy
-- 
  Marvin L Jones    | jonz          | W3DHJ  | linux
   38.24N  104.55W  |  @ config.com | Jonesy |  OS/2
    * Killfiling google & XXXXbanter.com: jonz.net/ng.htm 


--- End Message ---
--- Begin Message ---
On Mon, 2010-06-14 at 17:50 +0300, Dotan Cohen wrote:

> On 14 June 2010 15:36, HallMarc Websites <sa...@hallmarcwebsites.com> wrote:
> > Another is a CSS solution where you type the email address backwards and
> > then use the CSS style declaration:
> > style="direction: rtl; unicode-bidi: bidi-override;"
> >
> 
> How does that work with screen readers? How about copy-paste?
> 


I don't think there's an accessible way of doing this. Anything that
allows a screen reader to speak the email address would also be
susceptible to spammers email scrapers.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
On Mon, Jun 14, 2010 at 01:06:29PM +0100, Ashley Sheridan wrote:

> On Mon, 2010-06-14 at 08:02 -0400, David Mehler wrote:
> 
> > Hello,
> > I've got a site that is needing to have two email addresses on it, one
> > for general contact and information and the other for webmaster for
> > site problems. I do not want these addresses to become harvested by
> > spammers yet i want to make it possible for people to email if needed.
> > I can not use javascript for this solution.
> > Suggestions appreciated.
> > Thanks.
> > Dave.
> >
> 
> 
> If Javascript isn't a solution (which I can understand for accessibility
> reasons) then the only method I've seen that seems to work is to have
> the email as an image in the same font style as it would be on the page
> if it were just text. Facebook uses this to display contact email
> addresses for people, and I've seen it used elsewhere also. The only
> other method I've seen is to add in extra characters with a small note
> to humans to remove them, but I find this quite a messy solution.
> 
> Unfortunately, you can't get away with just a contact form these days if
> you're a business, as it's a legal requirement in some countries to have
> a contact details available, and not just a contact form.

Do you have specifics? I've never heard of such a requirement.

Notwithstanding Ash's assertion, I would suggest a contact form. The
email address is effectively hidden, and you can apply CAPTCHA to the
form to cut down on bot spam. It also introduces some discipline on the
user, and potentially allows you to categorize inquiries (making it
easier to pass them on to the proper person). You can also have a pick
list on the form which details which person you'd like the form to be
sent to.

In general, on contact forms or "about us" pages, I include some
physical address and possibly a phone number. This might satisfy Ash's
requirement for "contact details".

Paul

-- 
Paul M. Foster

--- End Message ---
--- Begin Message ---
On Mon, 2010-06-14 at 17:20 -0400, Paul M Foster wrote:

> On Mon, Jun 14, 2010 at 01:06:29PM +0100, Ashley Sheridan wrote:
> 
> > On Mon, 2010-06-14 at 08:02 -0400, David Mehler wrote:
> > 
> > > Hello,
> > > I've got a site that is needing to have two email addresses on it, one
> > > for general contact and information and the other for webmaster for
> > > site problems. I do not want these addresses to become harvested by
> > > spammers yet i want to make it possible for people to email if needed.
> > > I can not use javascript for this solution.
> > > Suggestions appreciated.
> > > Thanks.
> > > Dave.
> > >
> > 
> > 
> > If Javascript isn't a solution (which I can understand for accessibility
> > reasons) then the only method I've seen that seems to work is to have
> > the email as an image in the same font style as it would be on the page
> > if it were just text. Facebook uses this to display contact email
> > addresses for people, and I've seen it used elsewhere also. The only
> > other method I've seen is to add in extra characters with a small note
> > to humans to remove them, but I find this quite a messy solution.
> > 
> > Unfortunately, you can't get away with just a contact form these days if
> > you're a business, as it's a legal requirement in some countries to have
> > a contact details available, and not just a contact form.
> 
> Do you have specifics? I've never heard of such a requirement.
> 
> Notwithstanding Ash's assertion, I would suggest a contact form. The
> email address is effectively hidden, and you can apply CAPTCHA to the
> form to cut down on bot spam. It also introduces some discipline on the
> user, and potentially allows you to categorize inquiries (making it
> easier to pass them on to the proper person). You can also have a pick
> list on the form which details which person you'd like the form to be
> sent to.
> 
> In general, on contact forms or "about us" pages, I include some
> physical address and possibly a phone number. This might satisfy Ash's
> requirement for "contact details".
> 
> Paul
> 
> -- 
> Paul M. Foster
> 


It's not my requirement, it's been a legal requirement in the UK for 3
years now.

http://www.calmdesign.co.uk/articles/Website_legal_requirements/?id=16 

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
On Mon, Jun 14, 2010 at 5:51 PM, Ashley Sheridan
<a...@ashleysheridan.co.uk>wrote:

> On Mon, 2010-06-14 at 17:20 -0400, Paul M Foster wrote:
>
> > On Mon, Jun 14, 2010 at 01:06:29PM +0100, Ashley Sheridan wrote:
> >
> > > On Mon, 2010-06-14 at 08:02 -0400, David Mehler wrote:
> > >
> > > > Hello,
> > > > I've got a site that is needing to have two email addresses on it,
> one
> > > > for general contact and information and the other for webmaster for
> > > > site problems. I do not want these addresses to become harvested by
> > > > spammers yet i want to make it possible for people to email if
> needed.
> > > > I can not use javascript for this solution.
> > > > Suggestions appreciated.
> > > > Thanks.
> > > > Dave.
> > > >
> > >
> > >
> > > If Javascript isn't a solution (which I can understand for
> accessibility
> > > reasons) then the only method I've seen that seems to work is to have
> > > the email as an image in the same font style as it would be on the page
> > > if it were just text. Facebook uses this to display contact email
> > > addresses for people, and I've seen it used elsewhere also. The only
> > > other method I've seen is to add in extra characters with a small note
> > > to humans to remove them, but I find this quite a messy solution.
> > >
> > > Unfortunately, you can't get away with just a contact form these days
> if
> > > you're a business, as it's a legal requirement in some countries to
> have
> > > a contact details available, and not just a contact form.
> >
> > Do you have specifics? I've never heard of such a requirement.
> >
> > Notwithstanding Ash's assertion, I would suggest a contact form. The
> > email address is effectively hidden, and you can apply CAPTCHA to the
> > form to cut down on bot spam. It also introduces some discipline on the
> > user, and potentially allows you to categorize inquiries (making it
> > easier to pass them on to the proper person). You can also have a pick
> > list on the form which details which person you'd like the form to be
> > sent to.
> >
> > In general, on contact forms or "about us" pages, I include some
> > physical address and possibly a phone number. This might satisfy Ash's
> > requirement for "contact details".
> >
> > Paul
> >
> > --
> > Paul M. Foster
> >
>
>
> It's not my requirement, it's been a legal requirement in the UK for 3
> years now.
>
> http://www.calmdesign.co.uk/articles/Website_legal_requirements/?id=16
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
Thanks for the link, Ashley, I'll admit I my ignorance regarding these
requirements in other countries.  Something to consider in future projects.

Adam

-- 
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com

--- End Message ---
--- Begin Message ---
On Mon, 2010-06-14 at 18:48 -0400, Adam Richardson wrote:

> On Mon, Jun 14, 2010 at 5:51 PM, Ashley Sheridan
> <a...@ashleysheridan.co.uk>wrote:
> 
> > On Mon, 2010-06-14 at 17:20 -0400, Paul M Foster wrote:
> >
> > > On Mon, Jun 14, 2010 at 01:06:29PM +0100, Ashley Sheridan wrote:
> > >
> > > > On Mon, 2010-06-14 at 08:02 -0400, David Mehler wrote:
> > > >
> > > > > Hello,
> > > > > I've got a site that is needing to have two email addresses on it,
> > one
> > > > > for general contact and information and the other for webmaster for
> > > > > site problems. I do not want these addresses to become harvested by
> > > > > spammers yet i want to make it possible for people to email if
> > needed.
> > > > > I can not use javascript for this solution.
> > > > > Suggestions appreciated.
> > > > > Thanks.
> > > > > Dave.
> > > > >
> > > >
> > > >
> > > > If Javascript isn't a solution (which I can understand for
> > accessibility
> > > > reasons) then the only method I've seen that seems to work is to have
> > > > the email as an image in the same font style as it would be on the page
> > > > if it were just text. Facebook uses this to display contact email
> > > > addresses for people, and I've seen it used elsewhere also. The only
> > > > other method I've seen is to add in extra characters with a small note
> > > > to humans to remove them, but I find this quite a messy solution.
> > > >
> > > > Unfortunately, you can't get away with just a contact form these days
> > if
> > > > you're a business, as it's a legal requirement in some countries to
> > have
> > > > a contact details available, and not just a contact form.
> > >
> > > Do you have specifics? I've never heard of such a requirement.
> > >
> > > Notwithstanding Ash's assertion, I would suggest a contact form. The
> > > email address is effectively hidden, and you can apply CAPTCHA to the
> > > form to cut down on bot spam. It also introduces some discipline on the
> > > user, and potentially allows you to categorize inquiries (making it
> > > easier to pass them on to the proper person). You can also have a pick
> > > list on the form which details which person you'd like the form to be
> > > sent to.
> > >
> > > In general, on contact forms or "about us" pages, I include some
> > > physical address and possibly a phone number. This might satisfy Ash's
> > > requirement for "contact details".
> > >
> > > Paul
> > >
> > > --
> > > Paul M. Foster
> > >
> >
> >
> > It's not my requirement, it's been a legal requirement in the UK for 3
> > years now.
> >
> > http://www.calmdesign.co.uk/articles/Website_legal_requirements/?id=16
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> >
> >
> Thanks for the link, Ashley, I'll admit I my ignorance regarding these
> requirements in other countries.  Something to consider in future projects.
> 
> Adam
> 


I only know about this one because I live here! I wouldn't have a clue
about laws in other countries really!

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
At 9:29 PM -0400 6/13/10, Robert Cummings wrote:

<?php

function my_parse_url( $url )
{
    $parsed = parse_url( $url );
    $parsed['file'] = basename( $parsed['path'] );
$parsed['pathbits'] = explode( '/', ltrim( dirname( $parsed['path'] ), '/' ) );

    return $parsed;
}

$url = my_parse_url( 'http://foo.fee.com/blah/bleh/bluh/meh.php' );
print_r( $url );

?>

Cheers,
Rob.

Rob:

Very neat.

It also handles url's like this:

<http://mydomain.com/mydirectory/mysubdirectory/anothersubdirectory/mypage.php>

See Demo here:

http://www.webbytedd.com/b4/parse-url/index.php

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
tedd wrote:
At 9:29 PM -0400 6/13/10, Robert Cummings wrote:
<?php

function my_parse_url( $url )
{
    $parsed = parse_url( $url );
    $parsed['file'] = basename( $parsed['path'] );
$parsed['pathbits'] = explode( '/', ltrim( dirname( $parsed['path'] ), '/' ) );

    return $parsed;
}

$url = my_parse_url( 'http://foo.fee.com/blah/bleh/bluh/meh.php' );
print_r( $url );

?>

Cheers,
Rob.

Rob:

Very neat.

It also handles url's like this:

<http://mydomain.com/mydirectory/mysubdirectory/anothersubdirectory/mypage.php>

See Demo here:

http://www.webbytedd.com/b4/parse-url/index.php

It's useful to leverage the work of others. So using parse_url() gets you all the parsing stuff for a url without having to worry about the spec (such as embedded user, password, port, parameters, and fragment. Then we just augment to provide the extra functionality :)

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

--- End Message ---
--- Begin Message ---
Hi gang:

Considering all the recent parsing, here's another problem to consider -- given any text, parse the domain-names out of it.

You may limit the parsing to the most popular TDL's, such as .com, .net, and .org, but the finished result should be an array containing all the domain-names found in a text file.

Cheers,

tedd
--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
On Mon, 2010-06-14 at 09:14 -0400, tedd wrote:

> Hi gang:
> 
> Considering all the recent parsing, here's another problem to 
> consider -- given any text, parse the domain-names out of it.
> 
> You may limit the parsing to the most popular TDL's, such as .com, 
> .net, and .org, but the finished result should be an array containing 
> all the domain-names found in a text file.
> 
> Cheers,
> 
> tedd
> -- 
> -------
> http://sperling.com  http://ancientstones.com  http://earthstones.com
> 


I'm assuming it won't be anything as simple as assuming all the domains
begin with the http:// prefix? :p

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
At 2:18 PM +0100 6/14/10, Ashley Sheridan wrote:
On Mon, 2010-06-14 at 09:14 -0400, tedd wrote:


Hi gang:

Considering all the recent parsing, here's another problem to
consider -- given any text, parse the domain-names out of it.

You may limit the parsing to the most popular TDL's, such as .com,
.net, and .org, but the finished result should be an array containing
all the domain-names found in a text file.

Cheers,

tedd
--
-------
<http://sperling.com>http://sperling.com <http://ancientstones.com>http://ancientstones.com <http://earthstones.com>http://earthstones.com


I'm assuming it won't be anything as simple as assuming all the domains begin with the http:// prefix? :p

Thanks,
Ash

Ash:

Nope, just a text file containing whatever and domain-names. The only domain-name indicator would be the period followed by an approved TDL, such as .com, .net, or .org.

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
tedd wrote:
At 2:18 PM +0100 6/14/10, Ashley Sheridan wrote:
On Mon, 2010-06-14 at 09:14 -0400, tedd wrote:

Hi gang:

Considering all the recent parsing, here's another problem to
consider -- given any text, parse the domain-names out of it.

You may limit the parsing to the most popular TDL's, such as .com,
.net, and .org, but the finished result should be an array containing
all the domain-names found in a text file.

Cheers,

tedd
--
-------
<http://sperling.com>http://sperling.com <http://ancientstones.com>http://ancientstones.com <http://earthstones.com>http://earthstones.com

I'm assuming it won't be anything as simple as assuming all the domains begin with the http:// prefix? :p

Thanks,
Ash

Ash:

Nope, just a text file containing whatever and domain-names. The only domain-name indicator would be the period followed by an approved TDL, such as .com, .net, or .org.

<?php

function rip_domains( $text )
{
    $domains = false;

    $pattern =
        '[^-[:alnum:]]*'
       .'('
       .  '[-[:alnum:]][-.[:alnum:]]*'
       .  '\.(com|net|org)'
       .')'
       .'[^-_[:alnum:]]*';

    if( preg_match_all( "#$pattern#", $text, $matches ) )
    {
        $domains = array();
        foreach( $matches[1] as $domain )
        {
            $domains[$domain] = true;
        }
        $domains = array_keys( $domains );
    }

    return $domains;
}

?>

Naive implementation. I'm sure I've missed edge cases someplace.

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

--- End Message ---
--- Begin Message ---
On Mon, Jun 14, 2010 at 09:14, tedd <t...@sperling.com> wrote:
> Hi gang:
>
> Considering all the recent parsing, here's another problem to consider --
> given any text, parse the domain-names out of it.
>
> You may limit the parsing to the most popular TDL's, such as .com, .net, and
> .org, but the finished result should be an array containing all the
> domain-names found in a text file.

<?php
$text =<<<TXT
        To test example.com and www.php.net and other domain names
such as january.pilotpig.net and ca2.php.parasane.net, we need a
reliable method of checking.  We don't want to match on regular
periods, nor on the 2.2million or 2.2 million or just 2,200,000
other potential matches. And not when we are double-spacing or
single-spacing, just when oidk.net and similar domains are found.
We'll match hyphen domains like l-i-e.com, but not fake_underscored_domain.net.
We also want to match http://-fronted domains like http://php1.net/,
which also contains a number.  If we wanted to match domains plus
paths, but there was no leading http:// to indicate that it should
be a URL, we could extend this to grab things like www.facebook.com/parasane,
so long as we don't ignore the rare one-character SLDs like x.com,
as well as the domains in email addresses like danbr...@php.net
So if everything works as expected, we should see eleven domains
matched here, because ccTLDs like guthr.ie should be matched as well.

TXT;

/**
 * $fromText can be defined via a file_get_contents() or
 * similar function, while $fullLink should be anything
 * but false to enable link-matching, which will return
 * only link-like domains with paths attached.
 */
function extract_domains($fromText,$fullLink=false) {

        // If we only want to match the domain names.
        if ($fullLink === false) {
                
preg_match_all('/\b([a-z0-9\-\.]{1,}\.[a-z]{2,5})\b/',$fromText,$matches);
                return $matches[1];
        }

        // If we want to match just domain names with trailing paths.
        
preg_match_all('/\b([a-z0-9\-\.]{1,}\.[a-z]{2,5}\/.+?)\b/',$fromText,$matches);
        return $matches[1];
}

// Demo
echo "<pre>".PHP_EOL;

echo "Just domains:".PHP_EOL;
var_dump(extract_domains($text));

echo PHP_EOL;

echo "Full links:".PHP_EOL;
var_dump(extract_domains($text,true));

echo "</pre>".PHP_EOL;
?>


-- 
</Daniel P. Brown>
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
We now offer SAME-DAY SETUP on a new line of servers!

--- End Message ---
--- Begin Message ---
Hi list,

My config is XAMPP 1.7.2 with PHP 5.3.0

I'm trying to run a php script as a cron job. The same script works
perfectly from the browser, but fails when I try it from the command line
(not yet set it up as cron).

I get the following error:
PHP Fatal error:  Call to undefined function mysql_connect() in
/opt/lampp/htdocs/CS/weekly_email_report.php on line 3

I tried using dl('mysql.so') before the mysql_connect, but to no avail, I
get:

PHP Warning:  dl(): Unable to load dynamic library
'/usr/lib/php/modules/mysql.so' - /usr/lib/php/modules/mysql.so: cannot open
shared object file: No such file or directory in
/opt/lampp/htdocs/CS/weekly_email_report.php on line 2
PHP Fatal error:  Call to undefined function mysql_connect() in
/opt/lampp/htdocs/CS/weekly_email_report.php on line 3

In general many functions that work when the page is accessed from the
browser, fail on the command line. I tried setting extension=mysql.so in
both the php.ini files (the one used by the web server and the one used by
the command line (/etc/php.ini, correct??), though not simultaneously)

Any pointers??

TIA
Ferdi

--- End Message ---
--- Begin Message ---
On Mon, 2010-06-14 at 21:36 +0530, Ferdi wrote:

> Hi list,
> 
> My config is XAMPP 1.7.2 with PHP 5.3.0
> 
> I'm trying to run a php script as a cron job. The same script works
> perfectly from the browser, but fails when I try it from the command line
> (not yet set it up as cron).
> 
> I get the following error:
> PHP Fatal error:  Call to undefined function mysql_connect() in
> /opt/lampp/htdocs/CS/weekly_email_report.php on line 3
> 
> I tried using dl('mysql.so') before the mysql_connect, but to no avail, I
> get:
> 
> PHP Warning:  dl(): Unable to load dynamic library
> '/usr/lib/php/modules/mysql.so' - /usr/lib/php/modules/mysql.so: cannot open
> shared object file: No such file or directory in
> /opt/lampp/htdocs/CS/weekly_email_report.php on line 2
> PHP Fatal error:  Call to undefined function mysql_connect() in
> /opt/lampp/htdocs/CS/weekly_email_report.php on line 3
> 
> In general many functions that work when the page is accessed from the
> browser, fail on the command line. I tried setting extension=mysql.so in
> both the php.ini files (the one used by the web server and the one used by
> the command line (/etc/php.ini, correct??), though not simultaneously)
> 
> Any pointers??
> 
> TIA
> Ferdi


It sounds that maybe you have two different setups of PHP or that the
CLI isn't using the same php.ini as the server module. What happens if
you run a phpinfo() from the CLI? Do you get the output you expect? You
should see the php.ini location as being the same as the server module.
If not, you can pass the location of the php.ini in with the command
line arguments.

If you have two different installations of PHP (which some people tend
to do) then you might need to make sure the right modules are installed
on both.

Try the ini thing first and see if that fixes the issue.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
Our company is looking to hire a PHP Developer for a short term project.
 We're currently in the last couple weeks of the interview phase to narrow
down our options.  We are looking for a developer that is comfortable
working with existing code as well as creating new code.  You must be
skilled in PHP and MySQL in addition to HTML and javascript.  Experience in
jQuery is a plus!

We're looking for candidates from the U.S. and UK only right now.

If you meet the requirements and are intersted, please respond with a resume
and contact information.

We'll be making a decision in the next couple weeks, so please respond soon!

--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Paul M Foster [mailto:pa...@quillandmouse.com] 
> Sent: Saturday, June 12, 2010 10:40 PM
> 
> this in PHP. I can convert from '.' to '+' (as in most 
> languages) in my
> mind, but embedding variables in strings was a harder habit 
> to break. My
> opinion is that the dot operator used this way was a mistake for
> PHP. Not using the dot operator to mean "concatenate" would mean we
> could use it to replace the accursed '->' for class/method selection.
> And the plus operator is obviously a more natural fit for string
> concatenation.
> 
> And yes, if you're going to use the dot operator, surround it with
> spaces for readability.

Ironically, I believe that in the old days of PHP/FI the "+" was used
instead of "." -- to their defense, OOP wasn't even around then and so no
precedent had been set for the "." and I think they wanted to avoid
confusion with actual addition. I just remember having to go through and
re-work a bunch of code that broke b/c of this change.

But yes, I agree with you there. + should have stayed as the concat AND
addition, just like in JavaScript and other languages, and "." should have
been used instead of "->"

All of this I think could have been done AND maintain backwards
compatability with the use of some php.ini directives. Alternatively, I bet
some fancy regex scripts could also have been written that would migrate
"old" code to "new" code styles (I think the python guys did this for
"print")

*sigh*. It is what it is now. Ain't no going back from here. Like it or
lump it as they say.


--- End Message ---
--- Begin Message ---
Thanks Malka,
I was wondering if you had a web page I could go to before I sign up to see some discussions that have taken place. I tried using the lists.evolt.org, but it did not show the javascript section.
TIA,

Karl


On Jun 14, 2010, at 3:20 AM, Malka Cymbalista wrote:

javascr...@lists.evolt.org
--

Malka Cymbalista
Webmaster, Weizmann Institute of Science
malki.cymbali...@weizmann.ac.il
08-934-3036


On 6/14/2010 at  2:06 AM, in message
<26040320-88f0-4cf3-84ca-2ff81891b...@designdrumm.com>, Karl DeSaulniers
<k...@designdrumm.com> wrote:
Hello List,
I may have asked this before, but can not find any emails about it.
Does anyone know of a general-javascript email list like this php list?
Hoping someone here can point me in the right direction.
TIA

Karl DeSaulniers
Design Drumm
http://designdrumm.com


Karl DeSaulniers
Design Drumm
http://designdrumm.com


--- End Message ---
--- Begin Message ---

On Jun 14, 2010, at 3:45 PM, Paul M Foster wrote:

On Sun, Jun 13, 2010 at 06:06:16PM -0500, Karl DeSaulniers wrote:

Hello List,
I may have asked this before, but can not find any emails about it.
Does anyone know of a general-javascript email list like this php list?
Hoping someone here can point me in the right direction.
TIA

Listen, Karl, if you find something like this, let me know. I've been
looking for a javascript list as well.

Thanks,

Paul

--
Paul M. Foster

Hi Paul,
I will post my results here when I find something.


Karl DeSaulniers
Design Drumm
http://designdrumm.com


--- End Message ---
--- Begin Message ---
Hey,
I just found this app that I think will do your single user login. It is a MySQL monitoring app called MySQL Query Analyzer. It has the functionality I think you were looking for. Might be worth a "look-see".

:))

Hth,
Karl

--- End Message ---

Reply via email to