Re: [PHP] RE: help, weird include problem with functions

2001-08-10 Thread Renze Munnik

On Fri, Aug 10, 2001 at 08:22:57AM -0400, Jaxon wrote:
> Renze,
> 
> I found that it works if I pass only a variable or a path in, not both.
> 
> e.g.  opendir("/path/to/foo") works
>   opendir("$variable") where variable contains "path/to/foo" also works
>   opendir("$somevar/some/path") does NOT work.
> 
> go figure.
> 
> cheers,
> jaxon


Ehhh Weird!

I really start believing that it's either the directory you use in
$somevar that's wrong, or that the permissions are wrong. I have no
troubles wse with the constructions.
It doesn't matter if I only type the path, or that I put the whole
path in one variable or that I use both a variable and a (part of)
the path. The result is exactly the same.  (as it should btw).

-- 

* R&zE:

-- 
-- Renze Munnik
-- DataLink BV
--
-- E: [EMAIL PROTECTED]
-- W: +31 23 5326162
-- F: +31 23 5322144
-- M: +31 6 21811143
-- H: +31 23 5516190
--
-- Stationsplein 82
-- 2011 LM  HAARLEM
--
-- http://www.datalink.nl
-- 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] RE: help, weird include problem with functions

2001-08-10 Thread Jaxon

Renze,

I found that it works if I pass only a variable or a path in, not both.

e.g.opendir("/path/to/foo") works
opendir("$variable") where variable contains "path/to/foo" also works
opendir("$somevar/some/path") does NOT work.

go figure.

cheers,
jaxon

> -Original Message-
> From: Renze Munnik [mailto:[EMAIL PROTECTED]]
> Sent: Friday, August 10, 2001 4:06 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] RE: help, weird include problem with functions
>
>
> On Thu, Aug 09, 2001 at 02:05:24PM -0400, Jaxon wrote:
> > yes, I'm sure the directory exists :)
> >
> > here is the actual code, I suppose this would have been more helpful to
> > start:
> >
> >  > function incl_common()
> > {
> > global $modroot; //modroot is defined as http://localhost/modules in a
> > settings file
> >
> > echo "$modroot from included"; //this echos
> "http://localhost/modules";
> > properly
> >
> >
> > //the below throws the error, OpenDir: No such file or
> directory (error 2)
> > in (this function file name)
> > //but I can replce the $modroot/common with a hard-coded path
> and it works
> > fine.
> >
> > $handle=opendir("$modroot/common");
> > while ($file = readdir($handle))
> > { //load files in $directory into array
> > if  ($file != ".." && $file != ".")
> > {
> > $files_to_include[count($files_to_include)] = $file;
> > }
> > }
> >
> > //clean up and sort
> > closedir($handle);
> > if (is_array($files_to_include))
> > {
> > while (list ($key, $val) = each ($files_to_include))
> > {
> > include "$modroot/common/$val";
> > }
> > }
> > }
> > incl_common();
> > ?>
>
> Well... Actualy I can't find anything about opening URL's with
> opendir(). Is it even possible? I don't think so. But if is it, I'd
> check this:
>
> - Is the directory readable for the webserver?
> - Does your webserver allow this kind of actions? I'd say it's a bit
>   of a security leak if anyone can just directly execute an
>   opendir() (and then ofcourse also a readdir()) on your directories
>   from a remote server.
>
> But anyway, I don't know if it's possible to do an opendir() on an
> URL. I've tried your example on my on server and I can't get it to
> work unless I give the actual directory instead of the URL.
>
> --
>
> * R&zE:
>
> -- 
> -- Renze Munnik
> -- DataLink BV
> --
> -- E: [EMAIL PROTECTED]
> -- W: +31 23 5326162
> -- F: +31 23 5322144
> -- M: +31 6 21811143
> -- H: +31 23 5516190
> --
> -- Stationsplein 82
> -- 2011 LM  HAARLEM
> --
> -- http://www.datalink.nl
> -- 
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] RE: help, weird include problem with functions

2001-08-09 Thread Richard Lynch

>  function incl_common()
> {
> global $modroot; //modroot is defined as http://localhost/modules in a
settings file
>
> echo "$modroot from included"; //this echos
"http://localhost/modules"; properly
>
>
> //the below throws the error, OpenDir: No such file or directory
(error 2) in (this function file name)
> //but I can replce the $modroot/common with a hard-coded path and it
works fine.
>

# Echo out exactly what you are passing to opendir().
# Try tacking on a "/" at the end?


$fullpath = "$modroot/common/";
echo "fullpath is $fullpath\n";

$handle=opendir($fullpath);


> while ($file = readdir($handle))
> {//load files in $directory into array
> if  ($file != ".." && $file != ".")
> {
>  $files_to_include[count($files_to_include)] = $file;
> }
> }
>
> //clean up and sort
> closedir($handle);
> if (is_array($files_to_include))
> {
> while (list ($key, $val) = each ($files_to_include))
> {
> include "$modroot/common/$val";
> }
> }
> }
> incl_common();
> ?>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] RE: help, weird include problem with functions

2001-08-09 Thread Jaxon

yes, I'm sure the directory exists :)

here is the actual code, I suppose this would have been more helpful to
start:

http://localhost/modules in a
settings file

echo "$modroot from included"; //this echos "http://localhost/modules";
properly


//the below throws the error, OpenDir: No such file or directory (error 2)
in (this function file name)
//but I can replce the $modroot/common with a hard-coded path and it works
fine.

$handle=opendir("$modroot/common");
while ($file = readdir($handle))
{ //load files in $directory into array
if  ($file != ".." && $file != ".")
{
$files_to_include[count($files_to_include)] = $file;
}
}

//clean up and sort
closedir($handle);
if (is_array($files_to_include))
{
while (list ($key, $val) = each ($files_to_include))
{
include "$modroot/common/$val";
}
}
}
incl_common();
?>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] RE: help, weird include problem with functions

2001-08-09 Thread Renze Munnik

On Thu, Aug 09, 2001 at 01:15:41PM -0400, Jaxon wrote:
> hmm...yes, it does work, I jumped the gun on the simple example, cuz I
> thought it was an echo problem..
> my un-simplified example has an opendir() in function foo() file.
> 
> 
> function.php is:
>function foo{
>   global $bar;
>   echo "$bar from foo"; //this is working
>   $handle=opendir("$bar/common/"); // I get a "OpenDir - no such file or
> directory"
>   //some more stuff here to handle directory maniuplaion
>   }
>   foo();
> ?>
> 
> so the simple example does indeed work, but the opendir() is choking trying
> to deal with the variable.
> 
> hmmm...
> 
> jaxon
> 


Are you sure the directory you try to open actualy exists?

Btw... for things like this you better use:

if (!($handle = opendir ("$bar/common/"))) {
  // Some error here, and don't try to use $handle after this!
}

-- 

* R&zE:

-- 
-- Renze Munnik
-- DataLink BV
--
-- E: [EMAIL PROTECTED]
-- W: +31 23 5326162
-- F: +31 23 5322144
-- M: +31 6 21811143
-- H: +31 23 5516190
--
-- Stationsplein 82
-- 2011 LM  HAARLEM
--
-- http://www.datalink.nl
-- 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] RE: help, weird include problem with functions

2001-08-09 Thread Jaxon

hmm...yes, it does work, I jumped the gun on the simple example, cuz I
thought it was an echo problem..
my un-simplified example has an opendir() in function foo() file.


function.php is:


so the simple example does indeed work, but the opendir() is choking trying
to deal with the variable.

hmmm...

jaxon

> -Original Message-
> From: Renze Munnik [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, August 09, 2001 1:06 PM
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: Re: [PHP] RE: help, weird include problem with functions
>
>
> On Thu, Aug 09, 2001 at 12:48:38PM -0400, Jaxon wrote:
> > oh, this still happens when I fix the missing () in the foo
> declaration :)
> >
> > cheers,
> > jaxon
> >
>
>
> Works fine, no problems at all!
>

>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] RE: help, weird include problem with functions

2001-08-09 Thread Renze Munnik

On Thu, Aug 09, 2001 at 12:48:38PM -0400, Jaxon wrote:
> oh, this still happens when I fix the missing () in the foo declaration :)
> 
> cheers,
> jaxon
> 


Works fine, no problems at all!

Are you sure function.php is included at all? Because if the only
problem would be $bar, the output would at least be:

someval from page.php
from foo

Like I said... I don't have any problems with it. The output is:

someval from page.php
someval from foo

(and all this without any errors or warnings!)


Pretty much what you'd expected...

-- 

* R&zE:

-- 
-- Renze Munnik
-- DataLink BV
--
-- E: [EMAIL PROTECTED]
-- W: +31 23 5326162
-- F: +31 23 5322144
-- M: +31 6 21811143
-- H: +31 23 5516190
--
-- Stationsplein 82
-- 2011 LM  HAARLEM
--
-- http://www.datalink.nl
-- 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] RE: help, weird include problem with functions

2001-08-09 Thread Clayton Dukes

You need to include settings.php in functions.php.


- Original Message -
From: "Jaxon" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, August 09, 2001 12:48 PM
Subject: [PHP] RE: help, weird include problem with functions


> oh, this still happens when I fix the missing () in the foo declaration :)
>
> cheers,
> jaxon
>
> > -Original Message-
> > From: Jaxon [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, August 09, 2001 12:34 PM
> > To: [EMAIL PROTECTED]
> > Subject: help, weird include problem with functions
> >
> >
> >
> > can anyone tell me why this doesn't work??
> > assuming I have these three files:
> >
> > settings.php is:
> > 
> >
> > page.php is:
> >  > require("settings.php");
> > echo "$bar from page.php"; //this works!!!
> > include "function.php";
> > ?>
> >
> >
> > function.php is:
> >  > function foo{
> > global $bar;
> > echo "$bar from foo"; //this does not work!!!
> > }
> > foo();
> > ?>
> >
> > for some reason the $bar in function foo() doesn't have a value... :(
> > calling page.php only returns the $bar from page.php
> >
> > thanks in advance!
> > jaxon
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]