Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Document Root


I'm just having a little problem, and i'm wondering whats wrong with it. i coded an document shown below:

<? include('$DOCUMENT_ROOT/header.php'); ?>

and it leads me to this problem, i don't know why?

Warning: Failed opening '$DOCUMENT_ROOT/header.php' for inclusion (include_path='') in d:wwwdigitalricesomethingindex.php on line 2




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Document Root Not Website Root
I want to use PHP in my website; but run into a snag, the recommended
method of calling an include is:
<?php include($_SERVER["DOCUMENT_ROOT"]."/inc/css-gateway.inc"); ?>

when I try
<?php ECHO $_SERVER["DOCUMENT_ROOT"]; ?> the document root is shown as
/usr/local/apache/htdocs/

However the website root is at:
/mnt/home/www/canadian-dream.com/www

How do I redirect $_SERVER["DOCUMENT_ROOT"] to the my website root? Is
there a global variable that can be used? I do not wish to rewrite a lot
of pages if I were to change web host in the future.

from the error logs

[Sat Oct 25 06:32:51 2003] [error] PHP Warning:
main(/usr/local/apache/htdocs/inc/css-gateway.inc): failed to open stream:
No such file or directory in
/mnt/home/www/canadian-dream.com/www/de/immobilien/main.php on line 15

[Sat Oct 25 06:32:51 2003] [error] PHP Warning: main(): Failed opening
'/usr/local/apache/htdocs/inc/css-gateway.inc' for inclusion
(include_path='.:/usr/local/lib/php') in
/mnt/home/www/canadian-dream.com/www/de/immobilien/main.php on line 15

What Other Things That Should Not Be Under Document Root?
I would like to know what other things that you do not place under document roots? Besides initialization or configuration files, db name and parameters, all passwords, what else?

PHP Works Only In Document Root
All php files in document root work fine. While php
files in sub-directories of document root shows the
php source like a text file.

I have looked for help and also FAQ. Did I miss anything
during the installation. I have installed both apache and
php on Linux many times before actually figuring out that
all my php files generate html only in document root.

Document Root/include Path Problem
My site is/will be housed on a 3rd party host. I do not have control of the server variables.

Neither $DOCUMENT_ROOT or include_path are pointed anyplace I can use

Does anyone know what I can do do get the server path to my main directory(short of hard coding it).

Server And Document Root Settings In Apache
I'm not sure if I'm even asking the right question, but my website (not hosted by me) used codes like include $_SERVER["DOCUMENT_ROOT"] . "/include/header.php";.  Per a forum member's suggestion, I ran an echo on that command, and it gives a folder tree three folders deep...  So, online, it points to the correct page, but I'm trying to set up Apache (I used WAMP) to get a beta test site on my own computer.  So, the above command doesn't work. 

I ran searches for "document_root" and "php5/pear" (a directory in the error messages I get) to see if I could find a path setting in either Apache or PHP config files with no success. Does anyone know how to set up either my Apache or PHP config so I can define what $_SERVER and DOCUMENT_ROOT are pointing to when they're on my localhost without making them not work when I upload them to my web host?

Document.write(document.referrer)
Anyone know how I can use this java statement:
<Script Language="JavaScript"> document.write(document.referrer)</SCRIPT>

in the following php email message? PHP Code:

Root Access
If I want to add a column in a existing table in a php script, do I have to have root access?

Logging In As Root. Possible With Php Or Not??
I want to log as root from php. I am using Exec() function. I have tried the following code:
===========================
Passthru("whoami");
Exec("su root");
Exec("password");
Passthru("whoami");
===========================

Both the Passthru("whoami") returns apache. Where am I going wrong? Or is it not possible with php??

XML Root Elements?
I am writing some XML code in a php script PHP Code:

Crontab Outside Web Root
I am trying to get a PHP script running on the crontab where the PHP document is located outside of the web root, this presents a problem because PHP is installed as an Apache module and I dont have access to re-install on this server.

I have searched endlessly for ideas about how to get this running but all I am running into is the usual suspects: CGI Install Call Like a Command Line:

Fetch
wget
lynx

The last three all use http:// protocol as far as I have figured out. So does anyone know of any other software I can use to call from the crontab to run this script.

Ask About Root Access
Can anyone tell me how to access root on localhost?

The Root Folder
I've a web site in the address http://mySite.com
in the root, I've a file index.html

I've some subfiolders insid root/sub1/sub2

I like to add an html file (or php) index.html that call the index.html of
the root (in order to protect)
Now I've created 2 different index.html because I use relative path to
design the root (../index.html and ../../index.html)

I like to have the same file in all folders,but I don't know how to call the
root folder.

How Can I Run Root Commands In Php
I need to run a command as root to create users on the system for webmail
server.

What is the best way to do this?

Site Root?
I'm a freelance web designer and I've begun to use PHP extensively for my clients' websites. A problem I run into is the consistent use of "/" for the site root. My server thinks that that refers to public_html/, meaning I can't test a site with "/" used to recognize the site root if I'm, say, one directory deep.

How can I have a specific website recognize its own base folder as the site root? I imagine that in PHP, without touching Apache config files, there's a way to set a new site root, I just don't know how.

Execute As Root
Is there a way to execute commands as root using sudo? If yes, how to use it, if no, how can I get around.

Access To Mp3 Files Below Web Root
I want to place some mp3 files below the web root directory to keep people from accessing these files. however i want certain php scripts to be able to use them (ie for a flash movie that plays mp3 files)whats the best way to accomplish this?

Goto Root Directory
does anyone know how to goto the root dir on a LINUX server. I mean like go to parent directory of public_html. i want store a really secure file there and then use the iinclude function to get it when i need it. is this even possible. are there limitations for using the "../" command in include functions? i've obviously tried something like
include("../../../home/mydir/my_secure_script.php"); //doesnt work

Calling Include Outside Root
so I want to keep my mySQL connection file and my constants file (variables) outside the webroot in '/inetpub/includes/' with the root being '/inetpub/wwwroot/'.

I should be able to call this with. PHP Code:

Opening Docs Outside Of The Www Root
I'm trying to find a way to make links with php that will open up files I have stored outside of my web root (i.e., when someone clicks on the link, php opens up a PDF file that is outside of the public folders).

I've been scouring the PHP manual to find a command that will do this easily but most of them are more in depth than I need.

Finding Nth Root Of X Quickly?
what is a quick way of finding the nth root of a large number? My program checks a bunch of numbers to find their square root, cube root, 4th root etc. but I think I could make it faster.

I've tried using pow($number,(1/2)); but the numbers I'm using are way to big (hundreds of digits) so I tried the same thing with bcpow() but it would only return 1 when I tried to use (1/2) as the exponent. Why is that?

Php-cli No Mysql Module For Non-root
So far I've been unable to find anything that addresses this one...

Basically, if I am logged in as root and issue a "php -m", mysql is in the
list of installed modules. If I log in or su to a normal user and do the
same then mysql is *not* in the list and I cannot use mysql_connect (or any
other mysql function)...

Any ideas on why this is or how to fix it?

Notes:

# php -v
PHP 4.3.3 (cgi-fcgi) (built: Nov 4 2003 14:05:47)
Copyright (c) 1997-2003 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2003 Zend Technologies

Module list as root:
bcmath,bz2,calendar,ctype,dba,dbase,ftp,gd,gmp,ima p,mysql,openssl,overload,pcre,
posix,session,shmop,sockets,standard,sysvsem,sysvs hm,tokenizer,xml,yp,zlib

Module list as non-root:
bcmath,bz2,calendar,ctype,dba,dbase,ftp,gd,gmp,ima p,openssl,overload,pcre,posix,
session,shmop,sockets,standard,sysvsem,sysvshm,tok enizer,xml,yp,zlib

Setting Password For Root
I'm just starting PHP and MySQL - and really like the book by Welling
and Thomsom.

I've installed MySQL on my WinXP desktop, along with Apache and PHP. I
have not figured out how to set a password for the root account. I've
been able to set up a user account for myself, with a password, but not
the root account. I understand this is not ideal.

I've tried setting the password in My.ini but it doesn't seem to work.
I must be doing something wrong.

Accessing Files Outside Of The Web Root
Anyone got any pointers for a script and/or advice for accessing files that are outwith the root directory. I am using Apache on WIN2K Server (a box which is also running IIS on port 81).

I want user to be able to select a file and have a script verify their security clearance level (although I have this part worked out already) and then to supply a relative url from the web page they are on - out of the web root - to the file in question.

I have been toying with the 'realpath' function but to no avail thus far. I have tried using the path:

../../../files/{filename}
where the path to the web root (from the page in question) is
../../../

on my notebook (running WINXP Pro and same version Apache and PHP this works fine) but on the production server it cannot find the path outwith the server root.

Root Of Folder App Files
While I know putting a app into a folder was chiseled out of fine
scottish granite and carried upto the top of ben nevis by php newbies
many years ago - I dont think a folder is the best way to do it .

The fact a script is in a folder means certain instant problems if you
want to do certain things with .

Assuming a script doesnt have index.php and all the script files have a
filename prefix like phpgb_ then theres no chance of them clashing with
anything else and theres no real reason to continue using a folder for
the main script files .

While the script will have a app folder for various things - does it
make any sense not to use the root because of a single solitary file
called index.php .

phpgb_index.php is what I use and the method hasnt brought up a single
problem of any shape or description .

Gas lighting was once what everybody thought was the best way of doing
it until that darn new fangled electricity came along .

Creating Directories After Root
i want to create directories using vaiables my mkdir line is as follows PHP Code:

Smarty Installation In Root
I would like to install Smarty in a directory placed in my root. Could you please give me intructions of how I am going to do it?

Locating Root Directory
I posted earlier about finding a directory path from another directory. I tried to find the root directory of the site using the following variable:

$_SERVER['DOCUMENT_ROOT'];

Which I was then going to search to find the appropriate directory. However doc root is not defined on the server i'm using. So my question is this, is there another way to find the root directory and if not how can I set the document root variable? what do I need to change in the server configuration?

PHP Files Only Run In Root Directory?
I've installed a php forum script under a directory named 'forum', the script ran with no problems untill about a week ago, but now I get the following error: 'You don't have permission to access /forum/index.php on this server.'

Its has nothing to do with CMOD, I've tried that. Worst still it's not just the forum it's any PHP file thats under a directory. The thing is, I can run a PHP file from the root directory, but for some reason can't run the same file under another directory.

eg www.mywebsite/testfile.php --- will work fine www.mywebsite/newdirectory/testfile.php --- causes permission error

Could it be a .htaccess problem? Heres my error log report: Options ExecCGI is off in this directory: /home/mywebsite/public_html/forum/index.php P.S The forum script dosn't use CGI?

Read A File Below Root
How can I include a file from below the Root dir, other than using:
include "../../filename.inc.php";

Php Initializes Extensions As Root
I'm having a problem, i've designed an php extension, that uses shared
memory iteraction.

Altought, Php is initializing the extension as root, leaving the shared
memory with wrong permissions, as is created as root process.

Is there any way to initialize extensions, not as root?

Running Exec As Root?
exec('/sbin/ifdown eth0');

does not work, due to needing to be run as root.
I need to have this work on a closed network environment.

Site Root Directory?
I've posted this onto alt.php earlier and stumped all involved.
I didn't cross post for the usual reasons Anyone here got any ideas?
--------------------------------------

I am simply attempting to find my sites root directory so I can then step up
into a folder
in which I will have my INCLUDE code. This will allow me to easily refer to
my
INCLUDE code without messing about.

Now, This code...

It simply attempts to put a file into the root of my server space, and
recall it. It doesn't work.

The file write doesn't error and the file read fails without error.
Most importantly the file is nowhere to be seen!

<Added when sent to the domain provider>
--------------------------------------
I am worried the file is dropping into a space not allocated to my account
and that
this could cause you/I some problems if it were to overwrite an important
file.

Getting The Document Name In PHP
From inside a PHP program, is there a way I can obtain
the document name (e.g. if the php program is located in /x/y/zzz.php,
I want that whole string returned to me in a PHP program).

Running System() As Root User
Is there a way that I can run the system() command as a root user. Need to
restart network services on a server via php.

Define Root Directory For Images
I want to have a root directory from which the images on different pages shall be displayed. I define it here:

define('image_root', '/web/d2/w/mydomain/mydomain.com/images/');
Then I try to pass this path to the image:
$imageurl = image_root . $myrow['image'];
echo "<div id=left><img src='$imageurl' border=1></div>";But it doesn't work...
Any ideas?

Requiring File From Root While In Sub-domain
I'm trying to include a file from my root directory but I can't figure out how to. The file that is requiring is in sub.domain.com and the file to be required is in domain.com.

How would I go about including it?

Display Image Above Root Directory
Is it possible to display an image that is above the root directory using php?

for example if i have an image in /home/user/uploads/test.jpg and lets say my root directory for my site is /home/user/public_html/

is it possible to display test.jpg on /home/user/public_html/index.html ?

i am trying to create a secure file upload script and i think not having the file be directly accessed by the public is one of the main steps.

Writing A .RTF Document Using PHP
Does anyone know how to use PHP to write a rich text format file - or know of a link to an article that explains it?

I'm getting a bunch of user input from a form, and want to slot the values into a .rtf file so that the document can be printed out for signing (it's a contract).

Document Management In PHP?
Does anybody know about a good open source form manager (document
management) in PHP/MySQL? I have to build online admin pages for couple
of custom form types which are currently on the paper.

Basicaly, it's about seminar event management with teachers, students
and sponsors. I have lots of (paper) documents with details about each
of them and I'm looking for a quick way to build online admin pages that
would have these features:

1) administer forms (documents)
2) building relationships between documents
3) advanced search engine for reports

Document Indexing
I need to build an (databased) index from uploaded documents (.doc, .xls, .ppt, .pdf) for searching purposes, using php, of course. Does anyone know about this issue?

Word Document To XML
I want to convert a word template(.doc) to XML such that its DTD is known to me. I is important that I do it in PHP. IS there any way out.Are there some tools available on the net for the same.

Document Print
i'm trying to make a website for a jewelery so the user can print
warranties for every jewel it sold.

My first try was: let the user create an openoffice document with
variable placeholder {tag} that I substitute with the real value of $tag
and then open the document (with mimetype application/vnd. ...) for print.

Now user want to be able to insert formatting and styles to the text so
I can't mantain the same structure if I user FCKeditor or similar
because these products returns a string with HTML code inside that I
have to translate to OO.

I want to use pdf that is more standard in web application but I don't
want to create the document "by hand" because it's a user task!

So if there's some methods to take a pdf template (made by user) and
substitute placeholders inside with an HTML formatted text,

Get Current Document Name?
I would like to retrieve the current document name and store it in a variable.

Example: I am at page http://www.home.com/currentinfo.php.
I would like to take the string 'currentinfo.php' and assign it to a variable.

Is there any PHP function or global variable that can do that?

Add Phrases From 1 Document To Another
I realise this query has a very simple solution, but i just do not know what it is. I want to take File A an information file

Name
Reference
Colour
Shape

or whatever

and then add the answers to File 2 and file 3 and file 4, without ever needing to edit 2,3 or 4

Hello Welcome to (Name)
also known as (Reference) available in (Colour) and (Shape)

<?php include("file1.php"); ?>is not good enough for the job because I want to add sections or snippets to File2.php, not the entire file. I think I may need to use an array but I do not know how to call upon the sections of the Array or really how to setup the array in the first place.

There is no database involved, too advanced for me.

I just want / need to be able to amend file1.php if needed so that it changes File2.php and wherever featured. I know the solution will be very simple but the more I read about php the less obvious the solution seems to be.

.tmp Files Being Placed In The Root Directory By The 100's, Want It To Stop
Hi folks, I have a bit of a problem, perhaps one of you knows what is going on.

According to the sys admin at my ISP, something from my site (which is entirely php) is saving 100's of tiny files with the extension .tmp into the root directory on the server where my site is located.

He doesn't know very much about PHP and neither do I (this is the first site I've ever produced using it) so neither of us knows what could be causing it, there is one other site hosted on that server that is running PHP and it is doing the same thing, although the lion's share of temporary files are coming from my site.

I have a copy of the php.ini file that he emailed to me this morning, if it would help to post it please let me know and I will do so. We are not sure what is going on, but we would like to know if there is some way to make it stop (or at the very least, to get these files to destroy themselves once they're no longer usefull)

Also: I would like to thank SilkySmooth for his mail script, I used it awhile back and it got the job done. Thanks so much!

Access Denied For User: 'root@localhost'
Warning: MySQL Connection Failed: Access denied for user: 'root@localhost' (Using password: NO) in /www/apache/domains/www

usually this error occurs when i've wrong password, i'm sure i haven't.

other strange thing is that it says root@localhost... should it? this crap happened after my webhost company upgraded their servers... the code must be fine!!! i think so at least... before it worked... i checked the password, host, and username are fine...

Problem With Locating Image Directory From Root
All i want to do is change my following method that works fine, so that it checks from the root directory.

This is what i originally have and works fine:

$file_name = 'products/'.$pId.'s.jpg'
if (file_exists($file_name))
$test = true;
else
$file_name = 'template/noimage.gif'

I tried changing the following line but it does not locate the image:
$file_name = '../products/'.$pId.'s.jpg'

The folder 'products' and 'template' are in the root directory.
ie. root/products...

Php Control Panel -setuid/root Permission
I'm currently developing a web based control panel that allows users to change e-mail paswords, create subdomains etc. which is to be expected to run for more than 1000-2000 domains in a short time.

Both versions of php (apache module and cgi versions) that I'm using are used for the panel. (OS RedHat Linux) Everyting seemed ok up to the point where I tried to do things that required root permissions (for ex. "useradd" command)

I've been searching on the web since 3-4 days but it seems that nobody has found a good, working solution for this problem (even on this forum. For ex:

1) I call cgi php from web page with <form action=add_user.php>
2) try to add a user from cgi php like exec("adduser test_user")

the cgi php doesn't work because useradd command needs root permissions ! Most of the time it is indicated that using chmod 4755 or chmod u+s filename will allow cgi php to gain root permissions but it doesn't work. Also posix_setuid() doesn't work as expected because Apache runs as nobody.

The only working solution seems to run cgi php from cron, but that way some features of the control panel i'm coding will not be as dynamic as I wanted.

Root For Including Www Link In A Form With Drop Down
I have everything working except what should be a simple issue I think, but I continue to miss it. My links end up in the root of my website: e.g. http://www.fitzssite.com/

www.devshed.com
instead of simply
www.devshed.com
or
http://www.devshed.com

How do I point to a "blank address area" (don't know what to cal this...) for my links?
Here is my code: PHP Code:


Copyright © 2005-08 www.BigResource.com, All rights reserved