php-general Digest 5 May 2011 09:41:21 -0000 Issue 7298

Topics (messages 312667 through 312673):

Re: filter_var using regex
        312667 by: Ashley Sheridan
        312668 by: Jason Gerfen
        312670 by: Ashley Sheridan

Re: using XHTML FRAMESET with Zend Layout on Zend_App (MVC)
        312669 by: Bjoern Bartels

Installing on a Mac: include_path issues
        312671 by: Ken Kixmoeller
        312672 by: David Robley
        312673 by: Richard Quadling

Administrivia:

To subscribe to the digest, e-mail:
        [email protected]

To unsubscribe from the digest, e-mail:
        [email protected]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
On Wed, 2011-05-04 at 13:20 -0600, Jason Gerfen wrote:

> I am running into a problem using the REGEXP option with filter_var().
> 
> The string I am using: 09VolunteerApplication.doc
> The PCRE regex I am using:
> /^[a-z0-9]\.[doc|pdf|txt|jpg|jpeg|png|docx|csv|xls]{1,4}$/Di
> 
> The function in it's entirety:
> return (!filter_var('09VolunteerApplication.doc',
> FILTER_VALIDATE_REGEXP,
> array('options'=>array('regexp'=>'/^[a-z0-9]\.[doc|pdf|txt|jpg|jpeg|png|docx|csv|xls]{1,4}$/Di'))))
> ? false : true;
> 
> Anyone have any insight into this?
> 


You missed a + in your regex, at the moment you're only checking to see
if a file starts with a single a-z or number and then is followed by the
period. Then you're checking for oddly for one to four extensions in the
list, are you sure you want to do that? And the square brackets are used
to match characters, not strings, use the standard brackets to allow
from a choice of strings

Try this:

'/^[a-z0-9]+\.(doc|pdf|txt|jpg|jpeg|png|docx|csv|xls)$/Di'

One other thing you should be aware of maybe, filenames won't always
consist of just the letters a-z and numbers 0-9, they may contain
accented or foreign letters, hyphens, spaces and a number of other
characters depending on the client machines OS. Windows allows very few
characters for example compared to the Unix-like OS's like MacOS and
Linux.

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



--- End Message ---
--- Begin Message ---
On 05/04/2011 01:27 PM, Ashley Sheridan wrote:
> On Wed, 2011-05-04 at 13:20 -0600, Jason Gerfen wrote:
> 
>> I am running into a problem using the REGEXP option with filter_var().
>>
>> The string I am using: 09VolunteerApplication.doc
>> The PCRE regex I am using:
>> /^[a-z0-9]\.[doc|pdf|txt|jpg|jpeg|png|docx|csv|xls]{1,4}$/Di
>>
>> The function in it's entirety:
>> return (!filter_var('09VolunteerApplication.doc',
>> FILTER_VALIDATE_REGEXP,
>> array('options'=>array('regexp'=>'/^[a-z0-9]\.[doc|pdf|txt|jpg|jpeg|png|docx|csv|xls]{1,4}$/Di'))))
>> ? false : true;
>>
>> Anyone have any insight into this?
>>
> 
> 
> You missed a + in your regex, at the moment you're only checking to see
> if a file starts with a single a-z or number and then is followed by the
> period. Then you're checking for oddly for one to four extensions in the
> list, are you sure you want to do that? And the square brackets are used
> to match characters, not strings, use the standard brackets to allow
> from a choice of strings
> 
> Try this:
> 
> '/^[a-z0-9]+\.(doc|pdf|txt|jpg|jpeg|png|docx|csv|xls)$/Di'
> 
> One other thing you should be aware of maybe, filenames won't always
> consist of just the letters a-z and numbers 0-9, they may contain
> accented or foreign letters, hyphens, spaces and a number of other
> characters depending on the client machines OS. Windows allows very few
> characters for example compared to the Unix-like OS's like MacOS and
> Linux.
> 

Both are valid PCRE regex's. However the rules regarding usage of
parenthesis for an XOR string does not explain a similar regex being
used with the filter_var() like so:

return (filter_var('kc-1', FILTER_VALIDATE_REGEXP,
array('options'=>array('regexp'=>'/^[kc\-1|kc\-color|gr\-1|fa\-1|un\-1|un\-color|ben\-1|bencolor|sage\-1|sr\-1|st\-1]{1,8}$/Di')))
? true : false;

The above returns string(4) "kc-1"

Another test using the following works similarly:

return (filter_var('u0368839', FILTER_VALIDATE_REGEXP,
array('options'=>array('regexp'=>'/^[gp|u|gx]{1,2}[\d+]{6,15}$/Di'))) ?
true : false;

The above returns string(8) "u0368839"

And
return (filter_var('u0368839', FILTER_VALIDATE_REGEXP,
array('options'=>array('regexp'=>'/^[gp|u|gx]{1,2}[\d+]{6,15}$/Di'))) ?
true : false;

returns string(8) "gp123456"

As you can see these three examples use the start [] as XOR conditionals
for multiple strings as prefixes.



--- End Message ---
--- Begin Message ---
On Wed, 2011-05-04 at 13:46 -0600, Jason Gerfen wrote:

> On 05/04/2011 01:27 PM, Ashley Sheridan wrote:
> > On Wed, 2011-05-04 at 13:20 -0600, Jason Gerfen wrote:
> > 
> >> I am running into a problem using the REGEXP option with filter_var().
> >>
> >> The string I am using: 09VolunteerApplication.doc
> >> The PCRE regex I am using:
> >> /^[a-z0-9]\.[doc|pdf|txt|jpg|jpeg|png|docx|csv|xls]{1,4}$/Di
> >>
> >> The function in it's entirety:
> >> return (!filter_var('09VolunteerApplication.doc',
> >> FILTER_VALIDATE_REGEXP,
> >> array('options'=>array('regexp'=>'/^[a-z0-9]\.[doc|pdf|txt|jpg|jpeg|png|docx|csv|xls]{1,4}$/Di'))))
> >> ? false : true;
> >>
> >> Anyone have any insight into this?
> >>
> > 
> > 
> > You missed a + in your regex, at the moment you're only checking to see
> > if a file starts with a single a-z or number and then is followed by the
> > period. Then you're checking for oddly for one to four extensions in the
> > list, are you sure you want to do that? And the square brackets are used
> > to match characters, not strings, use the standard brackets to allow
> > from a choice of strings
> > 
> > Try this:
> > 
> > '/^[a-z0-9]+\.(doc|pdf|txt|jpg|jpeg|png|docx|csv|xls)$/Di'
> > 
> > One other thing you should be aware of maybe, filenames won't always
> > consist of just the letters a-z and numbers 0-9, they may contain
> > accented or foreign letters, hyphens, spaces and a number of other
> > characters depending on the client machines OS. Windows allows very few
> > characters for example compared to the Unix-like OS's like MacOS and
> > Linux.
> > 
> 
> Both are valid PCRE regex's. However the rules regarding usage of
> parenthesis for an XOR string does not explain a similar regex being
> used with the filter_var() like so:
> 
> return (filter_var('kc-1', FILTER_VALIDATE_REGEXP,
> array('options'=>array('regexp'=>'/^[kc\-1|kc\-color|gr\-1|fa\-1|un\-1|un\-color|ben\-1|bencolor|sage\-1|sr\-1|st\-1]{1,8}$/Di')))
> ? true : false;
> 
> The above returns string(4) "kc-1"
> 
> Another test using the following works similarly:
> 
> return (filter_var('u0368839', FILTER_VALIDATE_REGEXP,
> array('options'=>array('regexp'=>'/^[gp|u|gx]{1,2}[\d+]{6,15}$/Di'))) ?
> true : false;
> 
> The above returns string(8) "u0368839"
> 
> And
> return (filter_var('u0368839', FILTER_VALIDATE_REGEXP,
> array('options'=>array('regexp'=>'/^[gp|u|gx]{1,2}[\d+]{6,15}$/Di'))) ?
> true : false;
> 
> returns string(8) "gp123456"
> 
> As you can see these three examples use the start [] as XOR conditionals
> for multiple strings as prefixes.
> 
> 
> 


Not quite, you think they match correctly because that's all you're
testing for, and you're not looking for anything that might disprove
that. Using your last example, it will also match these strings:

gu0368839
xx0368839
p0368839


I tested your first regex with '09VolunteerApplication.doc' and it
doesn't work at all until you add in that plus after the basename match
part of the regex:

^[a-z0-9]+\.[doc|pdf|txt|jpg|jpeg|png|docx|csv|xls]{1,4}$

However, your regex (with the plus) also matches these strings:

09VolunteerApplication.docp
09VolunteerApplication.docj
09VolunteerApplication.doc|    <-- note it's matching the literal bar
character

Making the changes I suggested (^[a-z0-9]+\.(doc|pdf|txt|jpg|jpeg|png|
docx|csv|xls)$) means the regex works as you expect. Square brackets in
a regex match a range, not a literal string, and without any sort of
modifier, match only a single instance of that range. So in your
example, you're matching a 4 character extension containing any of the
following characters '|cdfgjlnopstx', and a basename containing only 1
character that is either an a-z or a number.

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



--- End Message ---
--- Begin Message ---
hello Dare!

it seems you got something wrong there...
the .phtml files are not meant to be called directly.
for the frames' src-attributes you'll have to provide a full URI calling
another controller's/module's action to output the frame content.


YT
BB



[ Björn Bartels                       ]

[ email :  [email protected] ]
[ home  :   http://dragon-projects.de ]
[ skype :                  bb-drummer ]
[ icq   :                   283827160 ]
[ ----------------------------------- ]
Diese E-Mail könnte vertrauliche und/oder rechtlich geschützte Informationen enthalten. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail sind nicht gestattet.

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden.

[ ----------------------------------- ]


Am 04.05.2011 um 14:04 schrieb Dare Williams:

Dear Developer,
Can anybody help with tips on how to implement a XHTML1_FRAMESET type on a Zend_Layout API in a Zend_Application(MVC). example.in your bootstrap resources plugin (setting.ini).resources.layout.layout = "main"resources.layout.layoutPath = "/path/to/layout" then on main.phtml you have this code<? $this->DocType() ; ?>"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd "><html xmlns="http://www.w3.org/1999/xhtml";><head><? $this- >HeadMeta ; ?><? $this->HeadTitle ; ?><? $this->HeadScript; ?><? $this->HeadLink; ?></head> <frameset rows="80,*" cols="*" frameborder="no" border="0" framespacing="0"> <frame src="top.phtml" name="topFrame" scrolling="No" noresize="noresize" id="topFrame" title="topFrame" / > <frameset cols="80,*" frameborder="no" border="0" framespacing="0"> <frame src="left.phtml" name="leftFrame" scrolling="No" noresize="noresize" id="leftFrame" title="leftFrame" / > <frame src="mainDisplay.phtml" name="mainFrame" id="mainFrame" title="mainFrame" /> </frameset></frameset><noframes><body></body></ noframes></html> While mainDisplay.phtml stands as your main script that should load the Layout Content variable i.e <? $this->layout()->content; ?> My main question is how do you make <? $this->layout()->content; ?> works on the external script(src="mainDisplay.phtml") that is called on main.phtml on mainFrameset .
Thank you.


--- End Message ---
--- Begin Message ---
Hey, folks -- --

I am switching over my development (I hope) to a Mac. Having some
trouble with the configuration. Rudimentary scripts run fine in the
document_root, but beyond that, my scripts in the include_path are not
found.

The include_path has a couple of directories in which I have my
foundation classes and a clients application classes and other
programs. For various reasons, I put them into my "Documents/Clients"
folder. When I create to set the path to these files in PHP, they are:

 /Users/ken/Documents/Clients/comped_php
 /Users/ken/Documents/Clients/jaguar_php

PHP doesn't find them, which has me stumped.

php.ini shows the include_path correctly, as:   
  
/Users/ken/Documents/Clients/comped_php:/Users/ken/Documents/Clients/jaguar_php

the document_root, configured in Apache is: /Users/ken/Sites/

The errors show as:
include_once() [function.include]: Failed opening 'smm_header.php' for
inclusion 
(include_path='/Users/ken/Documents/Clients/comped_php:/Users/ken/Documents/Clients/jaguar_php')
in /Users/ken/Sites/smm_registration/smmcomputereducation.php on line
1

Any ideas or suggestions?

Thanks,

Ken

--- End Message ---
--- Begin Message ---
Ken Kixmoeller wrote:

> Hey, folks -- --
> 
> I am switching over my development (I hope) to a Mac. Having some
> trouble with the configuration. Rudimentary scripts run fine in the
> document_root, but beyond that, my scripts in the include_path are not
> found.
> 
> The include_path has a couple of directories in which I have my
> foundation classes and a clients application classes and other
> programs. For various reasons, I put them into my "Documents/Clients"
> folder. When I create to set the path to these files in PHP, they are:
> 
>  /Users/ken/Documents/Clients/comped_php
>  /Users/ken/Documents/Clients/jaguar_php
> 
> PHP doesn't find them, which has me stumped.
> 
> php.ini shows the include_path correctly, as:
>   
> /Users/ken/Documents/Clients/comped_php:/Users/ken/Documents/Clients/jaguar_php
> 
> the document_root, configured in Apache is: /Users/ken/Sites/
> 
> The errors show as:
> include_once() [function.include]: Failed opening 'smm_header.php' for
> inclusion
>
(include_path='/Users/ken/Documents/Clients/comped_php:/Users/ken/Documents/Clients/jaguar_php')
> in /Users/ken/Sites/smm_registration/smmcomputereducation.php on line 1
> 
> Any ideas or suggestions?
> 
> Thanks,
> 
> Ken

If I remember correctly, include and friends have two parts to the error
message but you've only shown us one. For a guess, is it possible the
apache process doesn't have permissions for those directories and/or the
files within them?



Cheers
-- 
David Robley

I've got Parkinson's disease. And he's got mine.
Today is Setting Orange, the 52nd day of Discord in the YOLD 3177. 


--- End Message ---
--- Begin Message ---
On 5 May 2011 05:51, David Robley <[email protected]> wrote:
> Ken Kixmoeller wrote:
>
>> Hey, folks -- --
>>
>> I am switching over my development (I hope) to a Mac. Having some
>> trouble with the configuration. Rudimentary scripts run fine in the
>> document_root, but beyond that, my scripts in the include_path are not
>> found.
>>
>> The include_path has a couple of directories in which I have my
>> foundation classes and a clients application classes and other
>> programs. For various reasons, I put them into my "Documents/Clients"
>> folder. When I create to set the path to these files in PHP, they are:
>>
>>  /Users/ken/Documents/Clients/comped_php
>>  /Users/ken/Documents/Clients/jaguar_php
>>
>> PHP doesn't find them, which has me stumped.
>>
>> php.ini shows the include_path correctly, as:
>>   
>> /Users/ken/Documents/Clients/comped_php:/Users/ken/Documents/Clients/jaguar_php
>>
>> the document_root, configured in Apache is: /Users/ken/Sites/
>>
>> The errors show as:
>> include_once() [function.include]: Failed opening 'smm_header.php' for
>> inclusion
>>
> (include_path='/Users/ken/Documents/Clients/comped_php:/Users/ken/Documents/Clients/jaguar_php')
>> in /Users/ken/Sites/smm_registration/smmcomputereducation.php on line 1
>>
>> Any ideas or suggestions?
>>
>> Thanks,
>>
>> Ken
>
> If I remember correctly, include and friends have two parts to the error
> message but you've only shown us one. For a guess, is it possible the
> apache process doesn't have permissions for those directories and/or the
> files within them?
>
>
>
> Cheers
> --
> David Robley
>
> I've got Parkinson's disease. And he's got mine.
> Today is Setting Orange, the 52nd day of Discord in the YOLD 3177.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

include_path should only contain directories, not filenames. [1]

Richard.

[1] http://docs.php.net/manual/en/ini.core.php#ini.include-path

-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

--- End Message ---

Reply via email to