php-general Digest 14 Jun 2010 11:21:07 -0000 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 ----------------------------------------------------------------------
--- Begin Message ---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 ---
--- Begin Message ---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.phpHow 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 ---
--- Begin Message ---On Sun, Jun 13, 2010 at 9:29 PM, Robert Cummings <rob...@interjinn.com>wrote: > 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. > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > Clean and lean, Robert ;) Nice! Adam -- Nephtali: PHP web framework that functions beautifully http://nephtaliproject.com
--- End Message ---
--- Begin Message ---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
--- End Message ---
--- Begin Message ---On Mon, Jun 14, 2010 at 4:36 AM, 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 > > I don't know about MLs, but you can look for some user groups on google and yahoo. -- Nilesh Govindarajan Facebook: nilesh.gr Twitter: nileshgr Website: www.itech7.com Cheap and Reliable VPS Hosting: http://j.mp/arHk5e
--- End Message ---
--- Begin Message ---Hello, I've got what is probably a simple question. I've got a site with a footer include file. I want to have a section that displays the last time the page was modified. So for example say the index.php was last modified today and another page was modified two days ago. When the include is run on the other page it says something like this page was last modified and it would be two days ago, but for the index file I get this page was last modified and today's date. Thanks. Dave.
--- End Message ---
--- Begin Message ---On 14/06/2010, at 4:11 PM, David Mehler wrote: > Hello, > I've got what is probably a simple question. I've got a site with a > footer include file. I want to have a section that displays the last > time the page was modified. So for example say the index.php was last > modified today and another page was modified two days ago. When the > include is run on the other page it says something like this page was > last modified and it would be two days ago, but for the index file I > get this page was last modified and today's date. > Thanks. > Dave. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > Try using filemtime() and $_SERVER['SCRIPT_FILENAME'] --- Simon Welsh Admin of http://simon.geek.nz/ Who said Microsoft never created a bug-free program? The blue screen never, ever crashes! http://www.thinkgeek.com/brain/gimme.cgi?wid=81d520e5e
--- End Message ---
--- Begin Message ---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 8513251lstat("/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, 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 stat("/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 open("/usr/local/sitipersonali/disco4_ml/NSP/la/av/lavoro/webspace/httpdocs/wp-includes/feed-rss2.php", O_RDONLY) = 308 fstat(308, {st_mode=S_IFREG|0644, st_size=2513, ...}) = 0 open("/usr/local/sitipersonali/disco4_ml/NSP/la/av/lavoro/webspace/httpdocs/wp-includes/feed-rss2.php", O_RDONLY) = 309 fstat(309, {st_mode=S_IFREG|0644, st_size=2513, ...}) = 0 mmap(NULL, 2513, PROT_READ, MAP_SHARED, 309, 0) = 0x2b352037e000 munmap(0x2b352037e000, 2513) = 0 close(309) = 0 read(308, "<?php\n/**\n * RSS2 Feed Template "..., 8192) = 2513 read(308, "", 8192) = 0 read(308, "", 8192) = 0 close(308) = 0
--- End Message ---
--- Begin Message ---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=ZEND002498&r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling
--- End Message ---