php-windows Digest 18 Aug 2004 07:38:56 -0000 Issue 2364
Topics (messages 24425 through 24428):
Re: include_path and relative vs. absolute paths
24425 by: David Hamilton
Newbie working with PHP 5.0, IIS, Win2000
24426 by: Chuck
Re: using the mail function in php
24427 by: Lenny Davila
24428 by: neil
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 ---
I've had some problems with this at well. I thought about implementing
one of the solutions below:
$dir = dirname($_SERVER["PATH_TRANSLATED"])"/../includes/";
But it looks like this might have some problems when used with PHP 5.
http://www.php.net/manual/en/migration5.incompatible.php
Just my 2 cents in the hopes that it helps someone.
David
-----Original Message-----
From: Gryffyn, Trevor [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 17, 2004 9:43 AM
To: [EMAIL PROTECTED]
Cc: neil
Subject: RE: [PHP-WIN] Re: include_path and relative vs. absolute paths
Maybe not the most elegant, but I like to keep my stuff kind of modular
so what I've done is just create an "includes" folder in the root and
them reference it as include("../includes/includename.inc") from the
scripts that are all in their own folders (by project).
This may not be the best as far as security is concerned since it's easy
to guess at "/includes" existence and some include files might contain
information that could be useful to a would-be hacker, but I'm working
on an internal environment anyway so it's not so critical for me.
I have a handful of includes that are universal that I keep in there.
If something is project specific, I put it in that project's folder (or
an includes folder under the project folder). I have all of my database
connect strings in one file, I also have a usage logging include as well
as a date conversation include with a bunch of functions that convert
from one date format to another since I use that a lot.
Ideally you'd set your include_path and put your scripts in one of those
folders presumably so that the sometimes-sensitive include files are
accessible to PHP but not necessarily to the webserver to send out to
someone trying to steal your stuff. But if you can't change the
php.ini, maybe do something like I do.
Although, thinking about it, if you have access to a folder above where
your website lives, you could do something like this:
$dir = dirname($_SERVER["PATH_TRANSLATED"]) . "/../includes/";
include($dir ."includefile.inc");
That'd give you the "c:\foldername\" full path of the currently
executing script, then go up a level (parent folder) then back down to
an includes folder. Add more ".." to go further. As long as
permissions are proper for accessing that folder, that'd probably work.
Play around with it! There are a number of path oriented commands and
global variables that may help you even if you don't have access to
PHP.ini
Just some thoughts and feedback.
-TG
> -----Original Message-----
> From: neil [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, August 17, 2004 8:31 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP-WIN] Re: include_path and relative vs. absolute paths
>
>
> Thanks John
>
> That is a great solution, well at least for my development
> box where I can
> control my php.ini. The jokers who host one of the sites I
> look after have
> the include_path pointing to a non-existent place and won't modify it.
>
> Thanks anyway
> Neil
>
> "John Lim" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > Good question. I had the same problem when i switched from
> .asp to .php
> >
> > Suppose you want to use relative paths, eg. reference
> child1.php from
> > file1.php, where the file locations are:
> >
> > path/file1.php
> > path/child/child1.php
> >
> > The trick is to generate an absolute path for the current
> file, and find
> all
> > relative files based on this absolute path.
> >
> > eg. in file1.php:
> >
> > $file1AbsPath = dirname(__FILE__);
> > include($file1AbsPath ."/child/child1.php");
> >
> >
> >
> > "Neil" <[EMAIL PROTECTED]> wrote in message
> > news:[EMAIL PROTECTED]
> > > I am still getting used to .php after moving from .asp
> and one thing I
> had
> > > trouble getting my head around was the apparent inability to use
> absolute
> > > paths for include files.
> > >
> > > If I change the include_path in php.ini to say -
> > > include_path=".;c:\php\site1\inc" then I can access
> include files either
> > > relatively
> > > eg. require '../includes/somefile.php'; where the
> includes folder is at
> > the
> > > same level as the current folder
> > > or absolutely
> > > eg. require 'somefile.php'; where the file is either in
> the same folder
> or
> > > is c:\php\site1\inc
> > >
> > > Now the second option is fine except if I have multiple
> sites on the one
> > > server.
> > >
> > > With .asp it would just read /inc/somefile.inc either
> from the root of
> the
> > > site or from a virtual folder but the include_path
> setting forces all
> the
> > > sites to use the either the one include folder or at
> least not use the
> > same
> > > file names if there are multiple folders specified.
> > >
> > > Does anyone know another way of dealing with this?
> > >
> > > Thanks
> > >
> > > Neil
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Hello everyone. Hopefully someone can help me with this.
I was able to install PHP successfully. I tried a sample script and it
worked fine through IE. I then tried to create a script that would pass a
value on to another script using the post method. These are called Pass.php
and Pass1.php.
Pass.php contains the following.
<form action="pass1.php" method="post">
Name: <input type="text" name="username" /><br />
Email: <input type="text" name="email" /><br />
<input type="submit" name="submit" value="Submit me!" />
</form>
Pass1.php contains the following.
<?php
// Available since PHP 4.1.0
echo $_POST['username'];
echo $_REQUEST['username'];
import_request_variables('p', 'p_');
echo $p_username;
// Available since PHP 3. As of PHP 5.0.0, these long predefined
// variables can be disabled with the register_long_arrays directive.
echo $HTTP_POST_VARS['username'];
// Available if the PHP directive register_globals = on. As of
// PHP 4.2.0 the default value of register_globals = off.
// Using/relying on this method is not preferred.
echo $username;
?>
This is the output I received from this.
CGI Error
The specified CGI application misbehaved by not returning a complete set of
HTTP headers. The headers it did return are:
PHP Notice: Undefined index: username in C:\Web\Pass1.php on line 4
PHP Notice: Undefined index: username in C:\Web\Pass1.php on line 5
PHP Notice: Undefined variable: p_username in C:\Web\Pass1.php on line 8
PHP Notice: Undefined variable: HTTP_POST_VARS in C:\Web\Pass1.php on line
13
PHP Notice: Undefined variable: username in C:\Web\Pass1.php on line 19
I then replaced Pass1.php with the following code to check for any data that
was being posted.// This will check for posted values
<?php
$empty = $post = array();
foreach ($_POST as $varname => $varvalue) {
if (empty($varvalue)) {
$empty[$varname] = $varvalue;
} else {
$post[$varname] = $varvalue;
}
}
print "<pre>";
if (empty($empty)) {
print "None of the POSTed values are empty, posted:\n";
var_dump($post);
} else {
print "We have " . count($empty) . " empty values\n";
print "Posted:\n"; var_dump($post);
print "Empty:\n"; var_dump($empty);
exit;
}
?>
This supplied the following output.
CGI Error
The specified CGI application misbehaved by not returning a complete set of
HTTP headers. The headers it did return are:
// This will check for posted values
None of the POSTed values are empty, posted:
array(0) {
}
I would really appreciate if someone could help me figure out what is going
on.
--- End Message ---
--- Begin Message ---
Try using the strip slashes http://us3.php.net/stripslashes
stripslashes($messageVariable);
------------------------------------
Eleno Davila - SEO
[EMAIL PROTECTED]
(877)933-6750 Ext�163 (direct line)
http://plasticsurgery.com�
--- End Message ---
--- Begin Message ---
Thanks Lenny
The stripslashes worked. I didn't think to use it as there was no slashes to
strip. But since it puts it in they need to be removed.
Neil
"Lenny Davila" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
Try using the strip slashes http://us3.php.net/stripslashes
stripslashes($messageVariable);
------------------------------------
Eleno Davila - SEO
[EMAIL PROTECTED]
(877)933-6750 Ext 163 (direct line)
http://plasticsurgery.com
--- End Message ---