Connecting Tech Pros Worldwide Forums | Help | Site Map

require("common/latest.php") across multiple websites

Jim Carlock
Guest
 
Posts: n/a
#1: Jan 20 '06
I've set up the following using an Alias in Apache...

Alias /phpdocs/ "C:/Apache/htdocs/common/docs/php/"
<Directory "C:/Apache/htdocs/common/docs/php">
Options Indexes FollowSymlinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

It works well for HTML, all sites have access to the information.
I want to extend that to PHP require() and include() functions,
however the following maps out to an incorrect folder. Okay,
that's fine. My questions include, does PHP provide something
that maps out to the Apache Alias directive?

The common folder currently sits up two folders (../..) to the
VirtualHost folders. I realize that possibly a PHP "include_path"
directive could work. So the next question, anyone know of
another way to accomplish this?

Thanks.

Jim Carlock
Post replies to the newsgroup.



Jerry Stuckle
Guest
 
Posts: n/a
#2: Jan 20 '06

re: require("common/latest.php") across multiple websites


Jim Carlock wrote:[color=blue]
> I've set up the following using an Alias in Apache...
>
> Alias /phpdocs/ "C:/Apache/htdocs/common/docs/php/"
> <Directory "C:/Apache/htdocs/common/docs/php">
> Options Indexes FollowSymlinks MultiViews
> AllowOverride None
> Order allow,deny
> Allow from all
> </Directory>
>
> It works well for HTML, all sites have access to the information.
> I want to extend that to PHP require() and include() functions,
> however the following maps out to an incorrect folder. Okay,
> that's fine. My questions include, does PHP provide something
> that maps out to the Apache Alias directive?
>
> The common folder currently sits up two folders (../..) to the
> VirtualHost folders. I realize that possibly a PHP "include_path"
> directive could work. So the next question, anyone know of
> another way to accomplish this?
>
> Thanks.
>
> Jim Carlock
> Post replies to the newsgroup.
>
>[/color]

Sorry, Jim, you can't. PHP doesn't go through Apache to access files;
rather it goes straight to the file system itself. include_path is the
only way to handle it.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Chung Leong
Guest
 
Posts: n/a
#3: Jan 20 '06

re: require("common/latest.php") across multiple websites


Jim Carlock wrote:[color=blue]
> I've set up the following using an Alias in Apache...
>
> Alias /phpdocs/ "C:/Apache/htdocs/common/docs/php/"
> <Directory "C:/Apache/htdocs/common/docs/php">
> Options Indexes FollowSymlinks MultiViews
> AllowOverride None
> Order allow,deny
> Allow from all
> </Directory>
>
> It works well for HTML, all sites have access to the information.
> I want to extend that to PHP require() and include() functions,
> however the following maps out to an incorrect folder. Okay,
> that's fine. My questions include, does PHP provide something
> that maps out to the Apache Alias directive?[/color]

http://fi.php.net/apache-lookup-uri/

Jim Carlock
Guest
 
Posts: n/a
#4: Jan 21 '06

re: require("common/latest.php") across multiple websites


Jim Carlock asked:[color=blue]
> Does PHP provide something that maps out to the Apache
> Alias directive?[/color]

"Chung Leong" <chernyshevsky@hotmail.com> answered:[color=blue]
> http://fi.php.net/apache-lookup-uri/[/color]

Thank you, Chung Leong. Excellent.

The apache_lookup_uri() works quite well. It even works when
a filename is supplied and appends the filename to the mapping.

Alias /news/ "C:/Apache/htdocs/common/news/"
<Directory "C:/Apache/htdocs/common/news">
Options Indexes FollowSymlinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

<?php
// -- START THIS WORKS
// The topic.htm is not part of the Apache Alias above,
// but apache_lookup_uri() works nicely and accepts it
// and returns it as part of the fully qualified pathname to
// the file.
//
$info = apache_lookup_uri('/news/latest.php');
// print_r($info);
$latesttopic = $info->filename;
require($latesttopic);
//
// -- END THIS WORKS
?>

What's it good for? It offers a great way to provide a common
source of news on multiple websites. I like it. Only one place
to change the news and all sites that display the content get the
update. Look out cbsnews and msnbc! <g>

Now... time to figure a way to provide a way for a subdomain
to access the parent domains include files... without using a php
include in httpd.conf... hmmm. I'm going to get back to figuring
out how to do this with Apache.

Thank you very much, Chung Leong.

Thanks to Jerry Stuckle as well for your time and attempt.

Hope this helps.

Jim Carlock
Post replies to the newsgroup.


Jim Carlock
Guest
 
Posts: n/a
#5: Jan 26 '06

re: require("common/latest.php") across multiple websites


Another question...

Using the following code,

<?php require("/common/latest.php"); ?>

Is there a way to detect which page "required" latest.php ?

For instance...

Domain1, homepage (domain1.com/index.php) and
(domain1.com/talks/php/index.php) both employ ...
<?php require("/common/latest.php"); ?>

Domain2, provides similar multiple pages accessing the same
content by requiring...
<?php require("/common/latest.php"); ?>

Is there a php function that detections the name of the calling
page? And is there another way to do this? I'm working with
something along the lines of...

<?php require("/common/latest.php?rp=domain1.com/index.php"); ?>

Any other suggestions or a PHP server variable to detect the
name of the caller (calling page)?

Thanks.

Jim Carlock
Post replies to the newsgroup.


Chung Leong
Guest
 
Posts: n/a
#6: Jan 26 '06

re: require("common/latest.php") across multiple websites


Jim Carlock wrote:[color=blue]
> Another question...
>
> Using the following code,
>
> <?php require("/common/latest.php"); ?>
>
> Is there a way to detect which page "required" latest.php ?
>
> For instance...
>
> Domain1, homepage (domain1.com/index.php) and
> (domain1.com/talks/php/index.php) both employ ...
> <?php require("/common/latest.php"); ?>
>
> Domain2, provides similar multiple pages accessing the same
> content by requiring...
> <?php require("/common/latest.php"); ?>
>
> Is there a php function that detections the name of the calling
> page? And is there another way to do this? I'm working with
> something along the lines of...
>
> <?php require("/common/latest.php?rp=domain1.com/index.php"); ?>
>
> Any other suggestions or a PHP server variable to detect the
> name of the caller (calling page)?
>
> Thanks.
>
> Jim Carlock
> Post replies to the newsgroup.[/color]

Yes. See http://fi.php.net/debug-back-trace/ for details.

Closed Thread