Re: [PHP-DB] How can I solve this?

2006-01-19 Thread Jeremy Peterson
A friend of mine updated your regular expression...  Check it out if your 
interested.


Jeremy




Dear Jeremy,

Thanks for writing!

 I saw this regular expression and thought you might like it... :)

 preg_replace(/^\/?(.*)\/[\w]+\.php$/,$1,$PHP_SELF)
 
 that strips that leading forward slash too ;-)

  \w is a PCRE (Perl-Compatible Regular Expression) that matches any
word character: a-z, A-Z, 0-9 and the underscore _. sed and awk do
not support \w, although ssed (super-sed) supports \w if an -R switch
is added on the command line.

   Back to PHP and \w : Putting \w by itself inside a character class
[...] does absolutely nothing, just as [a] and [9] does nothing
special. It could be more efficiently written as:

/^\/?(.*)\/\w+\.php$/

   One additional problem is that the characters defined by \w does
not include the hyphen, the pound sign, or other punctuation marks
that sometimes find their way into filenames, like:

four-to-go.php
page#10.php
convert$toDM.php

so in this case, a character set should be used:

/^\/?(.*)\/[EMAIL PROTECTED]*+=-]+\.php$/

Keep 'em coming!

--
Eric Pement - [EMAIL PROTECTED]
Educational Technical Services, MBI




Jeremy Peterson, MACS
Automation Systems Administrator
Crowell Library
Moody Bible Institute
820 N. LaSalle Drive
Chicago, IL, 60610

Email:  [EMAIL PROTECTED]
Phone:  312.329.8081
Fax:312.329.8959


Re: [PHP-DB] How can I solve this?

2006-01-19 Thread Julien Bonastre

Thank you,


In fact, its called busy-ness, and I tend to believe I have quite a 
prowess in the was of Regular Expressions.



Reason I have the character class? You betchya! So I could do exactly 
what your friend did.



Reason I completely forgot? I'm an idiot and was too busy replying to 3 
emails at once whilst on a phone call.


My fault? Completely ;-)



Yes, see its called impulsive reasoning, hence the reason I added the 
character class without needing it, embedding a character class 
predicate such as \w inside a character class enclosure alone is well.. 
Stupid and reduntant at best..


Therefore there was some sub-concious reasoning to my madness I can 
presume. And yes, I also know that that \w class wouldn't cover all the 
characters I needed in a possible filename, again, I was careless and 
quick



As for the compatibility of the \w character class within sed and awk:

I am well aware that this implementation works on Perl-Compatible 
Regular Expression patterns, and is not a necessarily supported by all 
regular expression standards


BUT WHO GIVES A FLYING FUCK?


But this is a PHP-DB list, he is asking a PHP related question and I 
even specifically stated in my response:


preg_replace() which is a PCRE function using the PCRE pattern 
modifiers.




And finally this is a mailing list, not a kindergarten room. We're here 
to help, assist, and suggest advice. Not to wipe their bottoms.



I posted a suggestive solution to a problem. Thats all

SURE theres going to be different methods of approaching it, SURE it 
could not be the most perfect pattern, but its a suggestion where to 
head for the correct solution. HELL it wouldn't work with .asp files 
either. Or if your files were named .php4 or .phtml


Do I give a damn about that?

No. Are you a tech support officer Jeremy? Do you need to help them 
digest their baby jelly food?



Actually, enough of the hostility, I am honoured actually to think you 
went to the effort of sending off my 10 second quick drafted suggestive 
PCRE pattern off to Eric Pement of MBI..



Wow, touched. Imagine if I gave you guys some REAL PCRE patterns that I 
use!!!


Now that you'd honour me for wouldn't you! I can just picture you two 
drooling at the mouth now.




So is this Eric friend of yours some RegEx guru? I respect him if so, no 
harm intended, but I do think my suggestive help posting to this list 
was 'fit for purpose'


He never asked anyone to spoon feed him, and if you want to be a real 
world developer you better learn to use your resources and reference 
manuals.



I've had enough now.



Adios and cya later mate!


P.S. You (Jeremy) and Eric are Americans right?? :-) Just curious.





---oOo--- Allowing users to execute CGI scripts in any directory should 
only be considered if: ... a.. You have no users, and nobody ever visits 
your server. ... Extracted Quote: Security Tips - Apache HTTP 
Server ---oOo--- --oOo---oOo-- Julien Bonastre 
[The_RadiX] The-Spectrum Network CEO ABN: 64 235 749 494 
[EMAIL PROTECTED] 
www.the-spectrum.org --oOo---oOo-- 
- Original Message - 
From: Jeremy Peterson [EMAIL PROTECTED]

To: php-db@lists.php.net
Sent: Friday, January 20, 2006 8:09 AM
Subject: Re: [PHP-DB] How can I solve this?


A friend of mine updated your regular expression...  Check it out if 
your

interested.

Jeremy




Dear Jeremy,

Thanks for writing!

 I saw this regular expression and thought you might like it... :)

 preg_replace(/^\/?(.*)\/[\w]+\.php$/,$1,$PHP_SELF)
 
 that strips that leading forward slash too ;-)

  \w is a PCRE (Perl-Compatible Regular Expression) that matches any
word character: a-z, A-Z, 0-9 and the underscore _. sed and awk do
not support \w, although ssed (super-sed) supports \w if an -R switch
is added on the command line.

   Back to PHP and \w : Putting \w by itself inside a character class
[...] does absolutely nothing, just as [a] and [9] does nothing
special. It could be more efficiently written as:

/^\/?(.*)\/\w+\.php$/

   One additional problem is that the characters defined by \w does
not include the hyphen, the pound sign, or other punctuation marks
that sometimes find their way into filenames, like:

four-to-go.php
page#10.php
convert$toDM.php

so in this case, a character set should be used:

/^\/?(.*)\/[EMAIL PROTECTED]*+=-]+\.php$/

Keep 'em coming!

--
Eric Pement - [EMAIL PROTECTED]
Educational Technical Services, MBI




Jeremy Peterson, MACS
Automation Systems Administrator
Crowell Library
Moody Bible Institute
820 N. LaSalle Drive
Chicago, IL, 60610

Email:  [EMAIL PROTECTED]
Phone:  312.329.8081
Fax:312.329.8959







No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.1.375 / Virus Database: 267.14.21/235 - Release Date: 
19/01/2006




--
No virus found in this outgoing

Re: [PHP-DB] How can I solve this?

2006-01-18 Thread Cal Evans

try
$x =pathinfo($_SERVER['PHP_SELF']);
echo $x['dirname'];

=C=

|
| Cal Evans
| http://blog.calevans.com
|
|

Chris Payne wrote:

Hi everyone,

 


I am using PHP_SELF in order to get the current path on a dynamically
created webpage.  This gives me the following:

 


/my_website/index.php

 


My problem is, ALL I NEED is the directory name - no / or no index.php, how
can I strip these out to leave JUST the folder name the file is located in?
I need this because the page is dynamically created, and it gets templated
information from a database and needs to use the foldername as the
identifier between the DB entry to use for grabbing the information and the
pages inside the directory.

 


Any help would be really appreciated and I'm certain it's something REALLY
obvious.

 


Chris




--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] How can I solve this?

2006-01-18 Thread Chris Payne
Wonderful thank you, it displays a single / before the dir name but I can
remove that without too much trouble :-)

Thank you.

Chris

try
$x =pathinfo($_SERVER['PHP_SELF']);
echo $x['dirname'];

=C=

|
| Cal Evans
| http://blog.calevans.com
|
|

Chris Payne wrote:
 Hi everyone,
 
  
 
 I am using PHP_SELF in order to get the current path on a dynamically
 created webpage.  This gives me the following:
 
  
 
 /my_website/index.php
 
  
 
 My problem is, ALL I NEED is the directory name - no / or no index.php,
how
 can I strip these out to leave JUST the folder name the file is located
in?
 I need this because the page is dynamically created, and it gets templated
 information from a database and needs to use the foldername as the
 identifier between the DB entry to use for grabbing the information and
the
 pages inside the directory.
 
  
 
 Any help would be really appreciated and I'm certain it's something REALLY
 obvious.
 
  
 
 Chris
 
 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] How can I solve this?

2006-01-18 Thread Julien Bonastre

Two alternatives..

dirname(); returns basically just the path, same string as using 
pathinfo[dirname] but saves that array step..


or back to the love of my life [well, the non-human one]:
preg_replace(/^\/?(.*)\/[\w]+\.php$/,$1,$PHP_SELF)

that strips that leading forward slash too ;-)



by love of my life I mean, Regular Expressions, not that particular one 
:P


ciao

- Original Message - 
From: Chris Payne [EMAIL PROTECTED]

To: php-db@lists.php.net
Sent: Thursday, January 19, 2006 3:58 AM
Subject: RE: [PHP-DB] How can I solve this?


Wonderful thank you, it displays a single / before the dir name but I 
can

remove that without too much trouble :-)

Thank you.

Chris

try
$x =pathinfo($_SERVER['PHP_SELF']);
echo $x['dirname'];

=C=

|
| Cal Evans
| http://blog.calevans.com
|
|

Chris Payne wrote:

Hi everyone,



I am using PHP_SELF in order to get the current path on a dynamically
created webpage.  This gives me the following:



/my_website/index.php



My problem is, ALL I NEED is the directory name - no / or no 
index.php,

how
can I strip these out to leave JUST the folder name the file is 
located

in?
I need this because the page is dynamically created, and it gets 
templated

information from a database and needs to use the foldername as the
identifier between the DB entry to use for grabbing the information 
and

the

pages inside the directory.



Any help would be really appreciated and I'm certain it's something 
REALLY

obvious.



Chris




--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.1.375 / Virus Database: 267.14.20/233 - Release Date: 
18/01/2006







--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.1.375 / Virus Database: 267.14.20/234 - Release Date: 18/01/2006

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php