php-general Digest 22 Nov 2005 17:02:57 -0000 Issue 3809

Topics (messages 226251 through 226286):

Re: PHP 5.0.5
        226251 by: Curt Zirzow
        226252 by: Ashley M. Kirchner

Re: security question... "man in the middle attacks"
        226253 by: bruce

Re: Including classes
        226254 by: Marco Kaiser

Re: Cookie problem with IE
        226255 by: n.g.
        226270 by: Kristen G. Thorson
        226277 by: Kristen G. Thorson
        226279 by: Jay Blanchard
        226281 by: Richard Davey

cms type session - how to ?
        226256 by: Gregory Machin

GLOB sort order
        226257 by: Mark Lucas
        226258 by: Georgi Ivanov
        226259 by: Jochem Maas

Re: Decision table/business rule parser?
        226260 by: Jochem Maas
        226262 by: Geoff - Creative Living
        226263 by: Jay Blanchard
        226266 by: Jochem Maas
        226268 by: James Kaufman

calling static methods of variable class names
        226261 by: Ahmed Saad
        226264 by: Oliver Grätz
        226265 by: David Grant
        226267 by: Jochem Maas

readdir and mime types
        226269 by: Graham Cossey
        226271 by: Jay Blanchard
        226272 by: Graham Cossey
        226273 by: Jay Blanchard
        226274 by: Graham Cossey
        226275 by: David Grant
        226276 by: Jay Blanchard
        226278 by: Graham Cossey

can bind but cannot search?
        226280 by: Bing Du
        226282 by: Bing Du

Re: better way to mix html and php code?
        226283 by: Dan Baker

Re: Zend + Eclipse + Standized Framework
        226284 by: Jochem Maas

Re: Regex for balanced brackets?
        226285 by: Al

Re: Problems with PHP5 & phpMyAdmin
        226286 by: Russ F

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:
        php-general@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
On Mon, Nov 21, 2005 at 09:41:40PM -0700, Ashley M. Kirchner wrote:
> 
>    Trying to compile APXS version of PHP5.05 and towards the end, when 
> it tries to compile the CLI version, it bombs with the following:
> 
> ext/ftp/ftp.lo(.text+0x76): In function `data_close':
> /usr/local/src/apache/php-5.0.5/ext/ftp/ftp.c:1566: undefined reference 
> to `SSL_shutdown'

This means basically that the header files (*.h) where found but
none of the libraries were found.

You're compile path looks awkward to me.

> 
>    libphp5.so compiles just fine just before this bomb.  Any sugestions 
> anyone?

what does your ./configure line look like?


Curt.
-- 
cat .signature: No such file or directory

--- End Message ---
--- Begin Message ---
Curt Zirzow wrote:

You're compile path looks awkward to me.

How so? /usr/local/src/apache is simply a folder where I have all apache related sources dumped and compiled prior to installation. So naturally PHP's source becomes /usr/local/src/apache/php-5.0.5

what does your ./configure line look like?
   This same configure line compiles PHP4.4.1 just fine.  It's long:

./configure --sysconfdir=/etc/httpd/conf --mandir=/usr/share/man --with-apxs --enable-force-cgi-redirect --enable-discard-path --enable-fastcgi --with-config-file-path=/etc/httpd/conf/ --enable-safe-mode --with-exec-dir=/etc/httpd/php --enable-magic-quotes --with-zlib=shared --enable-bcmath --with-bz2=shared --enable-calendar --with-bcmath=shared --with-calendar=shared --with-jpeg=shared --with-tiff=shared --enable-dba --with-dba=shared --with-gdbm=shared --with-db4=shared --with-dom=shared --with-dom-xslt=shared --with-dom-exslt=shared --enable-ftp --with-gd=shared --with-png=shared --with-freetype-dir --enable-gd-native-ttf --with-gettext=shared --with-gmp=shared --with-imap=shared --with-kerberos --with-imap-ssl --with-mcrypt=shared --with-mime-magic=/etc/httpd/conf/magic --with-mysql=/usr --with-ncurses=shared --with-zlib=shared --enable-sockets --with-tsrm-pthreads --with-ldap=shared --with-openssl=shared --with-mcal=shared

--
R | I haven't lost my mind; it's backed up on tape somewhere.
 +--------------------------------------------------------------------
 Ashley M. Kirchner <mailto:[EMAIL PROTECTED]>   .   303.442.6410 x130
 IT Director / SysAdmin / WebSmith             .     800.441.3873 x130
 Photo Craft Laboratories, Inc.            .     3550 Arapahoe Ave. #6
 http://www.pcraft.com ..... .  .    .       Boulder, CO 80303, U.S.A.

--- End Message ---
--- Begin Message ---
your questions are on point...

if you're going to really talk about doing transactions... it appears to me
that you really need to solve this. www.passmarksecurity.com claims to have
solved this.. although i'm not sure i agree with them.. for one, i can't
find a thorough independent analysis, for two, from what i can tell... they
rely on the server app getting information from the browser. their approach
appears to depend on their belief that the intermediary (fake) app can't be
in the middle, therefore they'll only get valid information from the 'real'
browser...

as far as i can tell, their solution is to look at certain information (mac
address/headers/etc...) that they're inclined to believe can't be
altered/spoofed. i'm not buying it!!!!

as far as i can tell... you essentially need multiple information streams on
the client(browser) machine coming from the server... in actuality, i can
envision the following...



                   master server      <----> customer client
                    /          \
                   /            \
              biz server <---> customer browser

    the customer and the biz server talk to each other
    the customer client and master server talk to each other
    the customer client and browser are on the same machine

 the idea would be for the client app to be abel to 'get/see' the url that
the biz server app is sending for return requests. the client app would then
go back to the master server to 'determine' if the url/ip address is corect
for the given site. this can be accomplished fairly quickly by polling
random dns servers at the master level.

if the majority of the polled dns servers return the same address as the one
from the biz server, we can assume that the biz server is giving the correct
url/ip addresses.. this could be done for every request.

this kind of approach would be pretty difficult to corrupt, unless the
client app where somehow mangled/forged. you could determine if the client
was ever screwed with by using an SMS type of system via the cell phone...

-bruce



-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Sent: Monday, November 21, 2005 8:34 PM
To: [EMAIL PROTECTED]
Subject: RE: [PHP] security question... "man in the middle attacks"


'man in the middle' relates to any interception/redirection and I see I was
looking at it more as a hacker posing as the user interacting with a
legitmate site rather than the user interacting with a bogus site.   Two
sides to a similar coin.


real site <----> bogus user - bogus site <-----> real user


the session ID issue I was talking about helps prevent a bogus user from
posing as a legitimate one because only the real-site and the real-user
should know the session ID being used but then again, it could be
intercepted.  I think there's more to it than I'm explaining, but it's not
coming to me right now.  My apologies for not being more specific.

Definitely check out Chris Shiflett's site: http://shiflett.org/ (I got
un-lazy for a moment to look it up).. he might have something in there
somewhere.

I think what you're talking about is going to be kind of tricky because more
so than other security issues, this issue seems more susceptible to
measure/countermeasure type things.   You could use a secure connection, but
what happens if the hacker gets a certificate for their bogus site?  What
happens if they mask the URL so it appears to be coming from the legitmate
site?

I'm wondering how often the scenario you're talking about will come into
play though.  Seems that unless someone hacks your site and puts in some
bogus URLs that drag your legit users away from your legit site, the only
way someone's going to get lured into this situation is if someone is
posting bogus URLs somewhere else.. like on online forums or something
saying "Come see Bruce's website!" and going to a totally different URL
posing as yours.  In which case you can really only rely on your user's
intelligence to NOT fall for it.

Anyway, just some things to ponder while you find a "real" answer. :)  I
have some experience with security issues, but wouldn't necessarily call
myself an 'expert'.  Working on it though.

-TG

= = = Original message = = =

i'm not sure i see how this would affect a man in the middle attack...

a man in the middle attack, for the purpose of this thread is the insertion
of a clone/fake web app between the user's browaser and the original web
site...

i'm looking for ways/solutions that will prevent a fake/clone site from
redirecting the user, or intercepting the user/initial site traffic...

  original              fake                 user
    site   <------->    site   <--------->  browser

in this case a fake site could look like the original site, intercepting the
communication between the original/user. how can it be detected, can it
really be prevented?

as far as i can tell, what ever the original might send to the user's
browser, can simply be intercepted by the fake site, and in turn sent to the
user, where the response from the user can be sent/spoofed to the
original...

so, if you're a security guru, or really understand the nuances here.. let's
here your information.

thanks

-bruce



-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Sent: Monday, November 21, 2005 2:02 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] security question... "man in the middle attacks"


You'll probably get some good responses, especially if Chris Schifflet (sp?)
pipes up.  But one technique I've seen to prevent man in the middle type
attacks is to make copious use of session ID's.  That is, a session, when
it's created, generates a unique ID.  When this ID is created, a lot of
systems will store a copy in a database then periodically query the user to
see what session ID they have and compare the two.   There may be ways to
still intercept this or forge the session ID, but it's a start.   Just
thought I'd mention it in case it helps your web searches at all.

I look forward to hearing the responses your quest generates. Thanks for
posting!

-TG

= = = Original message = = =

hey...

anybody here have a serious background in security, or with 'man in the
middle attacks'???

in particular, i'm trying to get my hands around ways of preventing a
server/browser app to be susceptible to a 'man in the middle attack'

serious pointers would be helpful. searching across google hasn't turned up
any examples of how this can be accomplished...

thanks

-bruce
[EMAIL PROTECTED]


___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

--- End Message ---
--- Begin Message ---
hi,

> Here's what's going on. I have a page which calls itself in a <form>.
> On this page, I include two classes from other file I've created. On
> load, the page reads the class stuff just fine. If I submit the form
> (call the page again), then the class doesn't like to show any results.

can you post a working example that can show me the problem?

--
Marco Kaiser

--- End Message ---
--- Begin Message ---
save below as testcookie.php, request it from your browser twice, what
do you get at 2nd time?
  <?php
   setcookie('sessioncookie', 1);
   setcookie('storedcookie',1,time()+3600);

   var_dump($_COOKIE);
  ?>

On 11/22/05, Kristen G. Thorson <[EMAIL PROTECTED]> wrote:
> Anyone have any suggestions?  I'm still stuck.
>
>
> thanks,
> kgt
>
>
>
> Kristen G. Thorson wrote:
>
> > I'm having problems with a customer who can't login to a wholesaler
> > application.  To ensure the problem was that the cookie was not being
> > set, I sent him to this script:
> >
> > if( !isset( $_REQUEST['page'] ) ) {
> >  setcookie('VATtest','Cookie has been set.',time()+50000, "/");
> >  echo '<a href="'.$_SERVER['PHP_SELF'].'?page=1">Test cookie.</a>';
> > } else if( $_REQUEST['page'] == '1' ) {
> >  if( isset( $_COOKIE['VATtest'] ) ) {
> >    echo $_COOKIE['VATtest'];
> >  } else {
> >    echo 'Cookie NOT set.';
> >  }
> > }
> > ?>
> >
> >
> > He got "Cookie NOT set." which means exactly what it says.  He's using
> > IE 6.0, and swears up and down that he's set it to always allow
> > cookies from this domain.  I can't verify that he's set it correctly,
> > but he has been told twice how to do it.  I also know his browser must
> > be saving some cookies, as he is able to login to other sites.  Has
> > anyone run into other sources of cookie-blockage in the past?  I
> > cannot manage to duplicate this when I have IE set to always allow
> > cookies from this domain.
> >
> > Thanks for any tips,
> >
> > kgt
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--
Tomorrow will be a good day :-)

--- End Message ---
--- Begin Message ---
n.g. wrote:

save below as testcookie.php, request it from your browser twice, what
do you get at 2nd time?
 <?php
  setcookie('sessioncookie', 1);
  setcookie('storedcookie',1,time()+3600);

  var_dump($_COOKIE);
 ?>

On 11/22/05, Kristen G. Thorson <[EMAIL PROTECTED]> wrote:
Anyone have any suggestions?  I'm still stuck.


thanks,
kgt



Kristen G. Thorson wrote:

I'm having problems with a customer who can't login to a wholesaler
application.  To ensure the problem was that the cookie was not being
set, I sent him to this script:

if( !isset( $_REQUEST['page'] ) ) {
setcookie('VATtest','Cookie has been set.',time()+50000, "/");
echo '<a href="'.$_SERVER['PHP_SELF'].'?page=1">Test cookie.</a>';
} else if( $_REQUEST['page'] == '1' ) {
if( isset( $_COOKIE['VATtest'] ) ) {
  echo $_COOKIE['VATtest'];
} else {
  echo 'Cookie NOT set.';
}
}
?>


He got "Cookie NOT set." which means exactly what it says.  He's using
IE 6.0, and swears up and down that he's set it to always allow
cookies from this domain.  I can't verify that he's set it correctly,
but he has been told twice how to do it.  I also know his browser must
be saving some cookies, as he is able to login to other sites.  Has
anyone run into other sources of cookie-blockage in the past?  I
cannot manage to duplicate this when I have IE set to always allow
cookies from this domain.

Thanks for any tips,

kgt


Request from MY browser?  I get

array(2) { ["sessioncookie"]=> string(1) "1" ["storedcookie"]=> string(1) "1" }

This isn't a problem in my browser, however. I don't want to keep sending this customer to random scripts, so can you explain the point of this script? I mean, in what way might this help me figure out why his browser is not setting a cookie?


thanks,

kgt

--- End Message ---
--- Begin Message ---
Jay Blanchard wrote:

But I sure would like to see the URL once he has clicked it. Have you tried
changing to $_GET['page']? Again, all of this is just for giggles....but
there is likely to be a clue.

On privacy policies in IE (can he try another browser?) what is his setting?



I'm still waiting on definitive word as to what exactly his privacy settings are. In my experiments, manually setting IE to "Always Allow" or "Always Block" cookies for a domain will completely override privacy settings. I've had IE privacy set to allow no cookies, and manually added the domain to "Always Allow" and this overrode the no cookies setting.

For kicks and giggles, I changed $_REQUEST to $_GET, but he reported no difference. Again, I don't see this as being the problem, since if it were so, he'd get no output at all instead of "Cookie NOT set." I'm quite convinced this is a matter of his cookie simply not being set. He is not able to ever see a cookie for this domain in his temp internet files folder, though he tells us there are other cookies there.

I wish I could tell him to just use another friggin browser, but it would be nice to fix it so he can use the one he wants, no matter what words one can say about his choice. ;)

I have not looked into it, but do some internet security apps like Norton try to block certain cookies? I've not come across this, as I don't really use those programs, but right now I'm grasping for straws.

thanks for the help so far,
kgt

--- End Message ---
--- Begin Message ---
[snip]
I have not looked into it, but do some internet security apps like 
Norton try to block certain cookies?  I've not come across this, as I 
don't really use those programs, but right now I'm grasping for straws.
[/snip]

Certain anti-virus/spyware programs can and do block cookies and can be very
specific. Do you know if he is using something loike that? If so, can you
determine the settings?

--- End Message ---
--- Begin Message ---
Hi Kristen,

Tuesday, November 22, 2005, 3:21:31 PM, you wrote:

> I have not looked into it, but do some internet security apps like
> Norton try to block certain cookies? I've not come across this, as I
> don't really use those programs, but right now I'm grasping for
> straws.

Yes they do - I replied to your original message to this mailing list
saying exactly that. I will copy it again:

"What about third party software? Norton for example has cookie
features that will totally over-ride any IE setting with regards to
blocking them, etc. It's not the only one."

Ok, so not much detail - but you get the drift!

Cheers,

Rich
-- 
Zend Certified Engineer
PHP Development Services
http://www.corephp.co.uk

--- End Message ---
--- Begin Message ---
Hi all
I'm looking for a how to , on creating sessions similar to those used my
cms's
that ref only a single page..

--
Gregory Machin
[EMAIL PROTECTED]
[EMAIL PROTECTED]
www.linuxpro.co.za <http://www.linuxpro.co.za>
www.exponent.co.za <http://www.exponent.co.za>
Web Hosting Solutions
Scalable Linux Solutions
www.iberry.info <http://www.iberry.info> (support and admin)

+27 72 524 8096

--- End Message ---
--- Begin Message ---
Can anyone help me please? I'm not an advanced PHP user!

I'm looing for a way to sort the array returned by the GLOB function. I would
like to be able to sort the result by filemtime.

Any good ideas?

Thanks,

    Mark


_____________________________________________________________________________



      St John's Church, Polegate - Making Disciples of Jesus Christ

_____________________________________________________________________________



This email is intended solely for the addressee and is strictly confidential. 

If you are not the addressee please delete the message from your computer.

--- End Message ---
--- Begin Message ---
On Tuesday 22 November 2005 11:41, Mark Lucas wrote:
> Can anyone help me please? I'm not an advanced PHP user!
>
> I'm looing for a way to sort the array returned by the GLOB function. I
> would like to be able to sort the result by filemtime.
>
> Any good ideas?

I think you can walk the array returned by glob and create a hash :
$arr=glob(..);
foreach($arr as $file){
        $stat=stat($file);
        $mtime=$stat[mtime];
        $new[$file]=$mtime;
}

Now you should have array like this :
foo.txt => 19879823
foo1.txt => 1987987998
Now you can use array_sort function to sort the new  array.

Good luck.
>
> Thanks,
>
>     Mark
>
>
> ___________________________________________________________________________
>__
>
>
>
>       St John's Church, Polegate - Making Disciples of Jesus Christ
>
> ___________________________________________________________________________
>__
>
>
>
> This email is intended solely for the addressee and is strictly
> confidential.
>
> If you are not the addressee please delete the message from your computer.

--- End Message ---
--- Begin Message ---
Georgi Ivanov wrote:
On Tuesday 22 November 2005 11:41, Mark Lucas wrote:

Can anyone help me please? I'm not an advanced PHP user!

I'm looing for a way to sort the array returned by the GLOB function. I
would like to be able to sort the result by filemtime.

Any good ideas?


I think you can walk the array returned by glob and create a hash :
$arr=glob(..);
foreach($arr as $file){

// you can also write this like so, sometimes useful for keeping code
compact and minimizing variable usage:
foreach(glob(/* bla bla */) as $file) {

        $stat=stat($file);
        $mtime=$stat[mtime];

// don't forget to use quotes!:

$mtime=$stat['mtime'];

        $new[$file]=$mtime;
}

Now you should have array like this :
foo.txt => 19879823
foo1.txt => 1987987998
Now you can use array_sort function to sort the new  array.

array_multi_sort() is a slightly different way of doing the same thing,
sometimes handy when you need to be able to switch between different
sort orders:

$mFilesFound = glob(/* bla bla */);
foreach ($mFilesFound as $file) {
        $mTimes[] = filemtime($file);
}
array_multisort($mTimes, SORT_DESC, $mFilesFound);



Good luck.

Thanks,

   Mark


___________________________________________________________________________
__



     St John's Church, Polegate - Making Disciples of Jesus Christ

___________________________________________________________________________
__



This email is intended solely for the addressee and is strictly
confidential.

If you are not the addressee please delete the message from your computer.



--- End Message ---
--- Begin Message ---
Geoff - Creative Living wrote:
Hi

Does anyone know of an open source or commercial php library for parsing
decision tables? Or failing that, a more general business rules parser?
I can't find anything on the usual php script sites.

Unless I'm missing something, this seems to be a gap - in the Java world
there is a wide choice of native solutions.

I don't know if this is really what you are looking for, but I have repeatly
read and investigate the code/idea/writing found here:

http://www.tonymarston.net/php-mysql/workflow.html

if nothing else its a really impressive piece of work in terms of
bringing the subject matter within the grasp of us mere mortals


--------------------
Geoff Caplan
Creative Living


--- End Message ---
--- Begin Message ---
Hi Mike

> I'm not aware of any. I am kind of developing my own for my current
> Materials System. 

Sounds as though, like me, you might just get away with a decision table
parser rather than a fully-fledged corporate rules engine. though your
application is a bit more complex than ours. 

It's surprising to me that we are faced with rolling our own or working
with Java - suggests that PHP still has a bit to go as a platform for
serious business systems.

> With jBPM I "hope" I'll be able to change "routing"/approval of
> electronic documents more easily than it is currently.
 
Are you planning to have PHP run as a servelet within JBoss? Does this
work reliably? I much prefer to keep things as simple as possible.

As an alternative, I worked briefly on a native PHP Petri-net workflow
engine with a guy called Tony Marston before we parted ways. He has
written it up here:

http://www.tonymarston.net/php-mysql/workflow.html


--------------------
Geoff Caplan
Creative Living
Direct: 0121 515 1154
General: 01803 840 607

--- End Message ---
--- Begin Message ---
[snip]
It's surprising to me that we are faced with rolling our own or working
with Java - suggests that PHP still has a bit to go as a platform for
serious business systems.
[/snip]

The lack of a decision table/business rule parser does not suggest that PHP
has a way to go as a platform for serious business, as many serious
businesses will attest to. What it does suggest is that no one has had the
need or opportunity to construct one in PHP.

--- End Message ---
--- Begin Message ---
Geoff - Creative Living wrote:
Hi Mike


I'm not aware of any. I am kind of developing my own for my current
Materials System.


Sounds as though, like me, you might just get away with a decision table
parser rather than a fully-fledged corporate rules engine. though your
application is a bit more complex than ours.
It's surprising to me that we are faced with rolling our own or working
with Java - suggests that PHP still has a bit to go as a platform for
serious business systems.


With jBPM I "hope" I'll be able to change "routing"/approval of
electronic documents more easily than it is currently.

Are you planning to have PHP run as a servelet within JBoss? Does this
work reliably? I much prefer to keep things as simple as possible.

As an alternative, I worked briefly on a native PHP Petri-net workflow
engine with a guy called Tony Marston before we parted ways. He has
written it up here:

http://www.tonymarston.net/php-mysql/workflow.html

guess I didn't have to point you at that then ;-)



--------------------
Geoff Caplan
Creative Living
Direct: 0121 515 1154
General: 01803 840 607


--- End Message ---
--- Begin Message ---
On Tue, Nov 22, 2005 at 02:49:41PM +0100, Jochem Maas wrote:
> Geoff - Creative Living wrote:
> >Hi Mike
> >
> >As an alternative, I worked briefly on a native PHP Petri-net workflow
> >engine with a guy called Tony Marston before we parted ways. He has
> >written it up here:
> >
> >http://www.tonymarston.net/php-mysql/workflow.html
> 
> guess I didn't have to point you at that then ;-)
> 
> >
> >--------------------
> >Geoff Caplan
> >Creative Living

I wrote to Tony a couple of months ago and he said that his workflow code might
be available someday, but wasn't available currently. His ideas are published
on his website, but only code snippets.

-- 
Jim Kaufman
Linux Evangelist
public key 0x6D802619
CCNA, CISSP# 65668

--- End Message ---
--- Begin Message ---
hi all,

how can i call static methods of a class whose name is variable.. something like
<? $className::doSomething(); // throws a parser error ?>
I can do this with reflection by creating a ReflectionMethod object
then invoke()ing it, but is there a better way?
Thanks

-ahmed

--- End Message ---
--- Begin Message ---
Ahmed Saad schrieb:
> hi all,
> 
> how can i call static methods of a class whose name is variable.. something 
> like
> <? $className::doSomething(); // throws a parser error ?>
> I can do this with reflection by creating a ReflectionMethod object
> then invoke()ing it, but is there a better way?
> Thanks
> 
> -ahmed

For

$args=array('para1','para2');

use

call_user_func(array($className,'doSomething'),$args[0],$args[1]);

or

call_user_func_array(array($className,'doSomething'),$args);


Have Fun!
OLLi

--- End Message ---
--- Begin Message ---
Ahmed,

call_user_func(array($className, 'doSomething'));

Cheers,

David Grant

Ahmed Saad wrote:
> hi all,
> 
> how can i call static methods of a class whose name is variable.. something 
> like
> <? $className::doSomething(); // throws a parser error ?>
> I can do this with reflection by creating a ReflectionMethod object
> then invoke()ing it, but is there a better way?
> Thanks
> 
> -ahmed

--- End Message ---
--- Begin Message ---
Ahmed Saad wrote:
hi all,

how can i call static methods of a class whose name is variable.. something like
<? $className::doSomething(); // throws a parser error ?>
I can do this with reflection by creating a ReflectionMethod object
then invoke()ing it, but is there a better way?

try call_user_func() and/or call_user_func_array()

e.g.

call_user_func( array($className, 'doSomething') );

the array passed in this case is how one tells php the callback
function you are handing it is a class+method, you can also use this
callback notation to pass in an object+method.

Thanks

-ahmed

--- End Message ---
--- Begin Message ---
I'm attempting to read a list of files in a directory using readdir()
but am having problems with mpeg files not seemingly being read.

Cope snippet:

        $count = 0;
        while (false !== ($file = readdir($open_dir)))
        {
        if ($file != '.' && $file != '..')
        {
            if (file_exists("$VID_DIR/$file"))
            {
                                $count++;

$count counts any 'avi' files but not 'mpg' files.

Any suggestions much apreciated.

--
Graham

--- End Message ---
--- Begin Message ---
[snip]
I'm attempting to read a list of files in a directory using readdir()
but am having problems with mpeg files not seemingly being read.

Cope snippet:

        $count = 0;
        while (false !== ($file = readdir($open_dir)))
        {
        if ($file != '.' && $file != '..')
        {
            if (file_exists("$VID_DIR/$file"))
            {
                                $count++;

$count counts any 'avi' files but not 'mpg' files.
[/snip]

Without seeing the rest of the code I am going to assume that $open_dir is
the handle for the directory the files are in. Given that, why would you
specify a directory in your file_exists function? I am unsure why
file_exists would be necessary at this point. Eliminate that condition and
see what the results are

--- End Message ---
--- Begin Message ---
On 11/22/05, Jay Blanchard <[EMAIL PROTECTED]> wrote:
> [snip]
> I'm attempting to read a list of files in a directory using readdir()
> but am having problems with mpeg files not seemingly being read.
>
> Cope snippet:
>
>         $count = 0;
>         while (false !== ($file = readdir($open_dir)))
>         {
>         if ($file != '.' && $file != '..')
>         {
>             if (file_exists("$VID_DIR/$file"))
>             {
>                                 $count++;
>
> $count counts any 'avi' files but not 'mpg' files.
> [/snip]
>
> Without seeing the rest of the code I am going to assume that $open_dir is
> the handle for the directory the files are in. Given that, why would you
> specify a directory in your file_exists function? I am unsure why
> file_exists would be necessary at this point. Eliminate that condition and
> see what the results are
>
Yes $open_dir is the handle from opendir().

The file_exists is simply checking for an associated file elsewhere as
I'm looking for video files and thumbnails.

As I said, this works fine for avi suffixed files but not mpg or mpeg
suffixed files.

--
Graham

--- End Message ---
--- Begin Message ---
[snip]
Yes $open_dir is the handle from opendir().

The file_exists is simply checking for an associated file elsewhere as
I'm looking for video files and thumbnails.

As I said, this works fine for avi suffixed files but not mpg or mpeg
suffixed files.
[/snip]

Make sure to always hit reply-all, or the e-mail will not go back to the
list.

If file exists is looking for an associated files is it probable that the
.mpg files do not have one associated with it in the other directory?

--- End Message ---
--- Begin Message ---
[snip]
> Make sure to always hit reply-all, or the e-mail will not go back to the
> list.

Yep, realised that after hitting 'send'. :-(

> If file exists is looking for an associated files is it probable that the
> .mpg files do not have one associated with it in the other directory?

It is probable, that's why the check is there, but in this case the
associated file(s) definitely does exist. If I simply change the file
extensions from mpg to avi the script works.


--
Graham

--- End Message ---
--- Begin Message ---
Graham,

Is safe mode enabled in your config file?  If safe mode is on, PHP will
check the file to ensure it is owned by the same user executing the
script.  If this condition fails, file_exists() will not work on the file.

http://php.net/file_exists
http://php.net/manual/en/features.safe-mode.php

Cheers,

David Grant

Graham Cossey wrote:
> [snip]
>> Make sure to always hit reply-all, or the e-mail will not go back to the
>> list.
> 
> Yep, realised that after hitting 'send'. :-(
> 
>> If file exists is looking for an associated files is it probable that the
>> .mpg files do not have one associated with it in the other directory?
> 
> It is probable, that's why the check is there, but in this case the
> associated file(s) definitely does exist. If I simply change the file
> extensions from mpg to avi the script works.
> 
> 
> --
> Graham
> 

--- End Message ---
--- Begin Message ---
[snip]
> If file exists is looking for an associated files is it probable that the
> .mpg files do not have one associated with it in the other directory?

It is probable, that's why the check is there, but in this case the
associated file(s) definitely does exist. If I simply change the file
extensions from mpg to avi the script works.
[/snip]

Try this simple example and see what is output...

if ($handle = opendir('/path/to/files')) {
   while (false !== ($file = readdir($handle))) {
       if ($file != "." && $file != "..") {
           echo "$file\n";
       }
   }
   closedir($handle);
}

--- End Message ---
--- Begin Message ---
[snip all]

OK, of course it's my fault !!  :o

My directory variables are using relative paths and I was trying to
access the parent directory from the sub-directory but not using '..'

Sorry.....

Thanks for your help.

--
Graham

--- End Message ---
--- Begin Message ---
Hello all,

The following script returns 'search failed...' after 'LDAP bind successful...'.

==
<?php

$ldaprdn = "CN=John Smith,OU=Users,DC=Coll,DC=some,DC=edu";
$ldappass = "passwd";

$ds=ldap_connect("ad.coll.some.edu");

if ($ds) {
   echo "Binding ...<br />";
   $r=ldap_bind($ds, $ldaprdn, $ldappass);

   if ($r) {
       echo "LDAP bind successful...<br />";
   } else {
       echo "LDAP bind failed...<br />";
       exit;
   }

   $filter = "(sAMAccountName=jsmith)";
   $base = "DC=Coll,DC=some,DC=edu";

   $sr=ldap_search($ds, $base, $filter);

   if ($sr)
   {
     echo "Search result is " . $sr . "<br />";
   } else {
             echo "search failed...<br />";
          }
}
?>
==

However, the following ldapsearch returns the result fine.

% ldapsearch -h ad.coll.some.edu -s sub -b "dc=coll,dc=some,dc=edu" -x -D 'CN=John Smith,OU=Users,DC=Coll,DC=some,DC=edu' -W "samaccountname=jsmith"

I'm in dark now and don't know where to look for more information on why ldap_search did not work. I'd appreciate any help.

Bing

--- End Message ---
--- Begin Message ---
Bing Du wrote:
Hello all,

The following script returns 'search failed...' after 'LDAP bind successful...'.

==
<?php

$ldaprdn = "CN=John Smith,OU=Users,DC=Coll,DC=some,DC=edu";
$ldappass = "passwd";

$ds=ldap_connect("ad.coll.some.edu");

if ($ds) {
   echo "Binding ...<br />";
   $r=ldap_bind($ds, $ldaprdn, $ldappass);

   if ($r) {
       echo "LDAP bind successful...<br />";
   } else {
       echo "LDAP bind failed...<br />";
       exit;
   }

   $filter = "(sAMAccountName=jsmith)";
   $base = "DC=Coll,DC=some,DC=edu";

   $sr=ldap_search($ds, $base, $filter);

   if ($sr)
   {
     echo "Search result is " . $sr . "<br />";
   } else {
             echo "search failed...<br />";
          }
}
?>
==

However, the following ldapsearch returns the result fine.

% ldapsearch -h ad.coll.some.edu -s sub -b "dc=coll,dc=some,dc=edu" -x -D 'CN=John Smith,OU=Users,DC=Coll,DC=some,DC=edu' -W "samaccountname=jsmith"

I'm in dark now and don't know where to look for more information on why ldap_search did not work. I'd appreciate any help.

Bing

I've figured out. Adding 'ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);' right after ldap_connect fixed the problem.

Bing

--- End Message ---
--- Begin Message ---
"Robert Cummings" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]

>> I am interested in how this works, but am skeptical.
>
> No problem, the "programming in X template" instead of "programming in
> PHP" objection is raised often. I've given previous arguments about the
> merits of templates and concise data retrieval, display logic versus
> business logic, and meta tags versus traditional tags. Everything done
> in TemplateJinn can be done in PHP, absolutely since templates compile
> to PHP pages, but templates provide a layer between the soup of PHP
> necessary to accomplish that, and the designer. Even as a developer I
> don't want to engage in the soup necessary to accomplish everything
> TemplateJinn now does for me -- unfortunately I maintain some sites that
> do employ the soup system.

Thank you for the time and effort of explaining this.  It sounds 
fascinating, and worthy of investigating.
I will spend some time looking into this.

Thanks again.
DanB

--- End Message ---
--- Begin Message ---
Roman Ivanov wrote:
Greg Donald wrote:

Maybe Zend will get it right where all the previous attempts I've seen/used are less than great.


Personally, I would start creation of PHP framework by cleaning up PHP sytax. It's freakin' impossible to make complex OOP clean:

there is plenty wrong with php, but none of your comments are
even vaguely relevant.

btw you can 'clean up the syntax' - just don't expect it
to ever make it into the official build.


$this->output(array('dir', 'template'), &new BlaBla($this->bla));

this is supposed to prove what exactly? apart from the fact that OO in
php is not something you are very familiar with, for starters if you
want to do OO in php these days you should be using php5 (assuming you
don't have a mountain of existing php4 OO code you have to work with -
if you do then moaning about syntax is completely pointless... php4 is
is 'bugfix only')

the '&' sign for passing objects around in php5 is unnecessary because objects
are always passed around as references. and if you really know that you
need a reference to a reference you skill level should at the very least
be such that 'freakin' impossible' is not relevant at all.



--- End Message ---
--- Begin Message ---
Jeffrey Sambells wrote:
I came across this method of matching brackets with regex in .NET

http://puzzleware.net/blogs/archive/2005/08/13/22.aspx

but I am wondering if it is possible to do the same in PHP?

I've tried it a bit but I can't seem to get it to work properly. I'm just wondering if I am doing something wrong or if it is just not possible.

Thanks.

here is the code I was playing with:

<?php

$pattern = <<<PATTERN
\{
    (?>
        [^{}]+
        |
        \{ (?P<DEPTH>)
        |
        \} (?P<-DEPTH>)
    )*
    (?(DEPTH)(?!))

\}
PATTERN;

$subject = <<<SUBJECT
test {
    test2 {
        test3
    }
}

test4
{

}
SUBJECT;


preg_match_all("/$pattern/ix",$subject,$matches);

header("content-type: text/plain; ");

var_dump($matches);

?>


- Jeff



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jeffrey Sambells
Director of Research and Development
Zend Certified Engineer (ZCE)

We-Create Inc.
[EMAIL PROTECTED] email
519.745.7374 office
519.897.2552 mobile

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Get Mozilla Firefox at
http://spreadfirefox.com

If I'm understanding what you want, consider this.  I use it to check matching 
tags.

First get an array of all the start tags:

$pattern= "%<([^/][a-z_\-]*)>%i";               //all start tags used <xxx>

preg_match_all("$pattern", $text_str, $matches);

$start_tags= $matches[1];

$start_tag_nums= array_count_values($start_tags);       //get count for each tag

Then do the same for your end tags, using the same pattern but with the end tag 
slash. </....

Finally, you make a text list of the mismatches:

foreach($start_tag_nums as $tag=> $num){
                
        if($num != $end_tag_nums[$tag]) $end_error_msg .= "&lt;$tag&gt; || ";
        
}//end foreach
        
echo $end_error_msg;

--- End Message ---
--- Begin Message ---
Curt Zirzow wrote:

> On Fri, Nov 18, 2005 at 12:07:00PM -0800, Russ F wrote:
>> I've reinstalled Apache2, PHP5, phpMyAdmin and MYSQl several times. I
>> still get the same error when i try to use phpmyadmin Can not load mysql
>> extensions. I checked the path it is correct, the extensions exist
>> in /etc/php5/extensions but they do not have a .so after them. The
>> php.ini file and config files appear correct from a server setup. I read
>> you need to put a loadmodule statement in httpd but am not sure when. The
>> script says not to modify this file, put mods in /etc/sisconfig. But I'm
>> not sure where as there are no loadmod commands in the scripts. My
>> authorities all appear correct.
>> 
>> Can anyone poiny me to the right configuration file.
> 
> How you install all of apache2, php5, phpMyAdmin and Mysql all
> matters on what file to edit.  With your extension dir existing in
> /etc/php5/extension, i would assume you insalled via some package
> system.
> 
> With out any of the information, it will be hard to help.
> 
I installed all packages with SUSE 10.0 YaST rpms. I installed earlier
versions on SuSE 9.1 from rpms with no problems. After install I changed
mysql to run as user mysql. add root and damon to the group mysql. SuSe has
added stems in the install that (When I start the mysql server) that change
the my sql permisions. 

I recently uninstall php5 and went back to php4. The .so files are now
installed but I get a message now that access is denied when I try using my
browser running as root:  

http://localhost/phpMyAdmin/. 

I've configured php.ini and config.inc.php correctly I think. I can manually
get to mysql from the command line as root with no problem. I'm almost
certain its a permissions problem but I'm not sure where. 

/srv/www/htdocs
drwxr-xr-x   6 root        root  3000 2005-11-21 17:25 phpMyAdmin

/srv/www/htdocs/phpMyAdmin
-rw-rw-r--  1 root root  38826 2005-11-21 17:25 config.inc.php

I can either reinstall php5 or stay with php4 as long as I get this working.
You help will be greatly appreciated.

Thanks

Russ

--- End Message ---

Reply via email to