php-general Digest 14 Jun 2010 11:21:07 -0000 Issue 6798
php-general Digest 14 Jun 2010 11:21:07 - Issue 6798 Topics (messages 306111 through 306119): Re: String Parse Help for novice 306111 by: Ashley Sheridan 306113 by: Robert Cummings 306115 by: Adam Richardson Quick Question 306112 by: Karl DeSaulniers 306114 by: Nilesh Govindarajan last modified on a page 306116 by: David Mehler 306117 by: Simon J Welsh php apache module before read a file recursively scan full path 306118 by: Vincenzo D'Amore Re: Cookie access with CLI 306119 by: Richard Quadling 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 -- ---BeginMessage--- On Sun, 2010-06-13 at 18:52 -0400, Rick Dwyer wrote: OK, sorry for any confusion. Here is all my code: $url = http . ((!empty($_SERVER['HTTPS'])) ? s : ) . ://. $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; $thepath = parse_url($url); So, given that the URL can vary as follows: /mydirectory/mysubdirectory/anothersubdirectory/mypage.php vs. /mydirectory/mypage.php How do I get the either of the above url paths broken out so the variables equal the following $dir1 = mydirectory $dir2 = mysubdirectory $dir3 = anothersubdirectory $page = mypage.php ...etc... if there were 5 more subdirectories... they would be dynamically assigned to a variable. --Rick On Jun 13, 2010, at 6:42 PM, Ashley Sheridan wrote: On Sun, 2010-06-13 at 18:35 -0400, Rick Dwyer wrote: OK, I get the following error: Warning: basename() expects parameter 1 to be string, array given in When I use the following: $thepath = parse_url($url); $filename = basename($thepath); Is my variable thepath not automatically string? --Rick On Jun 13, 2010, at 6:23 PM, Ashley Sheridan wrote: On Sun, 2010-06-13 at 18:13 -0400, Rick Dwyer wrote: Hello List. I need to parse the PATH portion of URL. I have assigned the path portion to a variable using the following: $thepath = parse_url($url); Now I need to break each portion of the path down into its own variable. The problem is, the path can vary considerably as follows: /mydirectory/mysubdirectory/anothersubdirectory/mypage.php vs. /mydirectory/mypage.php How do I get the either of the above url paths broken out so the variables equal the following $dir1 = mydirectory $dir2 = mysubdirectory $dir3 = anothersubdirectory $page = mypage.php ...etc... if there were 5 more subdirectories... they would be dynamically assigned to a variable. Thanks for any help. --Rick $filename = basename($path); $parts = explode('/', $path); $directories = array_pop($parts); Now you have your directories in the $directories array and the filename in $filename. Thanks, Ash http://www.ashleysheridan.co.uk Because you've given it an array. Your original question never mentioned you were using parse_url() on the original array string. parse_url() breaks the string into its component parts, much like my explode example. Thanks, Ash http://www.ashleysheridan.co.uk Take out the parse_url line and use the code I gave you, or keep the parse_url line and drop my explode line. Thanks, Ash http://www.ashleysheridan.co.uk ---End Message--- ---BeginMessage--- Rick Dwyer wrote: Hello List. I need to parse the PATH portion of URL. I have assigned the path portion to a variable using the following: $thepath = parse_url($url); Now I need to break each portion of the path down into its own variable. The problem is, the path can vary considerably as follows: /mydirectory/mysubdirectory/anothersubdirectory/mypage.php vs. /mydirectory/mypage.php How do I get the either of the above url paths broken out so the variables equal the following $dir1 = mydirectory $dir2 = mysubdirectory $dir3 = anothersubdirectory $page = mypage.php ...etc... if there were 5 more subdirectories... they would be dynamically assigned to a variable. Thanks for any help. ?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. -- 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---
[PHP] php apache module before read a file recursively scan full path
Hello, I have performance problems during execution of php code. With strace I have recorded system calls which are called by apache httpd and what I have is quite singular. It seems that php apache module before read file recursively scan with lstat all the path (please also see attached file). If you take a look at attached file, it is also odd because there are many tries before read the file. Is there somebody that could help me to understand why I have this behavior? lstat(/usr, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 lstat(/usr/local, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 lstat(/usr/local/sitipersonali, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 lstat(/usr/local/sitipersonali/disco4_ml, {st_mode=S_IFDIR|0755, st_size=3072, ...}) = 0 lstat(/usr/local/sitipersonali/disco4_ml/NSP, {st_mode=S_IFDIR|0755, st_size=2048, ...}) = 0 lstat(/usr/local/sitipersonali/disco4_ml/NSP/la, {st_mode=S_IFDIR|0755, st_size=80, ...}) = 0 lstat(/usr/local/sitipersonali/disco4_ml/NSP/la/av, {st_mode=S_IFDIR|0755, st_size=80, ...}) = 0 lstat(/usr/local/sitipersonali/disco4_ml/NSP/la/av/lavoro, {st_mode=S_IFDIR|0755, st_size=1024, ...}) = 0 lstat(/usr/local/sitipersonali/disco4_ml/NSP/la/av/lavoro/webspace, {st_mode=S_IFDIR|0755, st_size=1024, ...}) = 0 lstat(/usr/local/sitipersonali/disco4_ml/NSP/la/av/lavoro/webspace/httpdocs, {st_mode=S_IFDIR|0750, st_size=2048, ...}) = 0 lstat(/usr/local/sitipersonali/disco4_ml/NSP/la/av/lavoro/webspace/httpdocs/wp-includes, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 lstat(/usr/local/sitipersonali/disco4_ml/NSP/la/av/lavoro/webspace/httpdocs/wp-includes/feed-rss2.php, {st_mode=S_IFREG|0644, st_size=2513, ...}) = 0 Best regards, Vincenzo D'Amore -- Vincenzo D'Amore email: v.dam...@gmail.com msn: free...@hotmail.com skype: free.dev mobile: +39 349 8513251 lstat(/usr, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 lstat(/usr/local, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 lstat(/usr/local/sitipersonali, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 lstat(/usr/local/sitipersonali/disco4_ml, {st_mode=S_IFDIR|0755, st_size=3072, ...}) = 0 lstat(/usr/local/sitipersonali/disco4_ml/NSP, {st_mode=S_IFDIR|0755, st_size=2048, ...}) = 0 lstat(/usr/local/sitipersonali/disco4_ml/NSP/la, {st_mode=S_IFDIR|0755, st_size=80, ...}) = 0 lstat(/usr/local/sitipersonali/disco4_ml/NSP/la/av, {st_mode=S_IFDIR|0755, st_size=80, ...}) = 0 lstat(/usr/local/sitipersonali/disco4_ml/NSP/la/av/lavoro, {st_mode=S_IFDIR|0755, st_size=1024, ...}) = 0 lstat(/usr/local/sitipersonali/disco4_ml/NSP/la/av/lavoro/webspace, {st_mode=S_IFDIR|0755, st_size=1024, ...}) = 0 lstat(/usr/local/sitipersonali/disco4_ml/NSP/la/av/lavoro/webspace/httpdocs, {st_mode=S_IFDIR|0750, st_size=2048, ...}) = 0 lstat(/usr/local/sitipersonali/disco4_ml/NSP/la/av/lavoro/webspace/httpdocs/wp-includes, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 lstat(/usr/local/sitipersonali/disco4_ml/NSP/la/av/lavoro/webspace/httpdocs/wp-includes/feed-rss2.php, {st_mode=S_IFREG|0644, st_size=2513, ...}) = 0 lstat(/usr, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 lstat(/usr/local, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 lstat(/usr/local/sitipersonali, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 lstat(/usr/local/sitipersonali/disco4_ml, {st_mode=S_IFDIR|0755, st_size=3072, ...}) = 0 lstat(/usr/local/sitipersonali/disco4_ml/NSP, {st_mode=S_IFDIR|0755, st_size=2048, ...}) = 0 lstat(/usr/local/sitipersonali/disco4_ml/NSP/la, {st_mode=S_IFDIR|0755, st_size=80, ...}) = 0 lstat(/usr/local/sitipersonali/disco4_ml/NSP/la/av, {st_mode=S_IFDIR|0755, st_size=80, ...}) = 0 lstat(/usr/local/sitipersonali/disco4_ml/NSP/la/av/lavoro, {st_mode=S_IFDIR|0755, st_size=1024, ...}) = 0 lstat(/usr/local/sitipersonali/disco4_ml/NSP/la/av/lavoro/webspace, {st_mode=S_IFDIR|0755, st_size=1024, ...}) = 0 lstat(/usr/local/sitipersonali/disco4_ml/NSP/la/av/lavoro/webspace/httpdocs, {st_mode=S_IFDIR|0750, st_size=2048, ...}) = 0 lstat(/usr/local/sitipersonali/disco4_ml/NSP/la/av/lavoro/webspace/httpdocs/wp-includes, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 lstat(/usr/local/sitipersonali/disco4_ml/NSP/la/av/lavoro/webspace/httpdocs/wp-includes/feed-rss2.php, {st_mode=S_IFREG|0644, st_size=2513, ...}) = 0 lstat(/usr, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 lstat(/usr/local, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 lstat(/usr/local/sitipersonali, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 lstat(/usr/local/sitipersonali/disco4_ml, {st_mode=S_IFDIR|0755, st_size=3072, ...}) = 0 lstat(/usr/local/sitipersonali/disco4_ml/NSP, {st_mode=S_IFDIR|0755, st_size=2048, ...}) = 0 lstat(/usr/local/sitipersonali/disco4_ml/NSP/la, {st_mode=S_IFDIR|0755, st_size=80, ...}) = 0 lstat(/usr/local/sitipersonali/disco4_ml/NSP/la/av, {st_mode=S_IFDIR|0755, st_size=80, ...}) = 0 lstat(/usr/local/sitipersonali/disco4_ml/NSP/la/av/lavoro, {st_mode=S_IFDIR|0755, st_size=1024, ...}) = 0 lstat(/usr, {st_mode=S_IFDIR|0755,
Re: [PHP] Cookie access with CLI
2010/6/13 David Česal da...@cesal.cz: 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 Beside cURL, you can also use stream contexts to get/set the cookie for subsequent requests. http://docs.php.net/stream_context_create http://docs.php.net/stream_get_meta_data http://docs.php.net/manual/en/context.http.php Essentially, you create a context when you send the data (this will allow you to POST data for a file_get_contents() call). Then you get the meta data from the response. Then you put the cookie you received into the context you will use to continue in communication. If you set up the default context in this way, then you don't need to supply the context to every file command. See the user notes on file_get_contents regarding routing calls through an NTLM proxy. By creating a default context, all my code was routed through an NTML proxy. PHP didn't support NTLM authentication when I wrote the note (not sure it does yet, but my requirement changed). By using a default context, I have 1 place to edit any code (in my auto_prepend.php script). Richard. -- - 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=ZEND002498r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Cookie access with CLI
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=ZEND002498r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] protecting email addresses on a web site
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. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
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
RE: [PHP] protecting email addresses on a web site
-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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] protecting email addresses on a web site
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
Re: [PHP] String Parse Help for novice
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Another parse problem
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] protecting email addresses on a web site
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Another parse problem
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
Re: [PHP] Another parse problem
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.comhttp://sperling.com http://ancientstones.comhttp://ancientstones.com http://earthstones.comhttp://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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] String Parse Help for novice
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. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Another parse problem
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.comhttp://sperling.com http://ancientstones.comhttp://ancientstones.com http://earthstones.comhttp://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. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Another parse problem
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! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] protecting email addresses on a web site
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: protecting email addresses on a web site
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 banter.com: jonz.net/ng.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] protecting email addresses on a web site
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
[PHP] PHP on command line -- mysql_connect error
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
Re: [PHP] PHP on command line -- mysql_connect error
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
[PHP] Seeking developer for short term project
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!
RE: [PHP] is ?= good?
-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. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick Question
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick Question
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] protecting email addresses on a web site
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] protecting email addresses on a web site
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
Re: [PHP] protecting email addresses on a web site
On Mon, Jun 14, 2010 at 5:51 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: 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
Re: [PHP] protecting email addresses on a web site
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.ukwrote: 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
Re: [PHP] Multiple Login in a single PC should not be possible
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
[PHP] CFP for Surge Scalability Conference 2010
We're excited to announce Surge, the Scalability and Performance Conference, to be held in Baltimore on Sept 30 and Oct 1, 2010. The event focuses on case studies that demonstrate successes (and failures) in Web applications and Internet architectures. Rasmus Lerdorf will be presenting his PHP Performance Checklist talk at Surge, and our Keynote speakers include John Allspaw and Theo Schlossnagle. We are currently accepting submissions for the Call For Papers through July 9th. You can find more information, including our current list of speakers, online: http://omniti.com/surge/2010 If you've been to Velocity, or wanted to but couldn't afford it, then Surge is just what you've been waiting for. For more information, including CFP, sponsorship of the event, or participating as an exhibitor, please contact us at su...@omniti.com. Thanks, -- Jason Dixon OmniTI Computer Consulting, Inc. jdi...@omniti.com 443.325.1357 x.241 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php