PDA

View Full Version : Apache File/Directory Access Modes?


gorilla1
09-10-2002, 05:29 PM
Another basic question... Are the methods for accessing Apache file directories documented somewhere? For instance, I have seen links of the following formats:

<a href="user/?mode=review&index=21">

and:

<a href="user/?M=D">


Does "?M" equal "?mode"? What are the available modes and how do they work? I looked on the apache site, but did not find anything that described these. Thanks.

G

Ökii
09-10-2002, 05:46 PM
unless they are manipulating the parse engine with mod rewrite or such, those urls would simply attribute values to variables passed through the url.

Generally (though not in all cases) your Apache server would be set up so that if it was only directed to a folder (<a href="folda/">) it would first look for index.html, then maybe index.htm and then index.php. So user/?..... would effectively tell the server to access index.php (because no .htm or .html index pages exist in that folder) and attribute values to the variables declared after the ?

user/?mode=review&index=21 ---- would look in folder /user/ and then tell index.php that $mode="review" and $index="21";

user/?M=D ---- would again tell index.php that $M = "D";

gorilla1
09-10-2002, 07:10 PM
Okii,

Ok, interesting, thanks I will try that.

G

gorilla1
09-11-2002, 01:52 AM
So I set up an index.php3 script in the directory user. I then clicked on the link that looks like this:
<a href="user/?mode=review&index=21">

In the index.php3 I then set up to find the file in the directory based on the index value that was passed, and display the file by doing $test=readfile($thisfile);
However, when I clicked the link the user all that happens is that I am passed to the user directory - index.php3 never seems to gain control and execute.

G

firepages
09-11-2002, 02:38 AM
the 'M=A' is part of mod_autoindex ? and tells apache to show a directory listing ordering by last Modifiied
same goes for S=A (Size) N=A (Name) and D=A (Directory)

for your last example Gorilla1 - try adding a .htaccess file to the folder containing ...

DirectoryIndex index.php3

gorilla1
09-11-2002, 02:39 AM
OK, it looks like it picks up index.html if it exists on the directory, but if index.html does not exist, index.php or index.php3 do not get picked up This is running on the phpdev from firepages on my local drive.


OK.. just saw firepages' post about htaccess... I will see if I can find what belongs in it.
G

gorilla1
09-11-2002, 03:01 AM
OK, thanks firepages, got it to work. I created the .htaccess with the following line in it:
DirectoryIndex index.php3

I had to go into dos in order to get the file renamed without an extension. But it worked.

G

gorilla1
09-11-2002, 04:24 AM
One more problem. The index.php3 executes and the index passed by variable to select the file works out but when I try to display the file I am referencing (which is in the same subdirectory as index.php3), I get the folllowing message:

Warning: Failed opening '$thisfile[0]' for inclusion (include_path='')

The line of code where the error is generated looks like this:
include'$thisfile[0]';

In the line before I issued:
echo $thisFile[0];

and it displays "mail.txt" which is the file the contents of which I want to display in the browser. What am I missing here?

UPDATE: I also tried adding the following statment to the .htaccess file:
php_value include_path .

but still got the following error message:

Warning: Failed opening '$thisFile[0]' for inclusion (include_path='.')

G

firepages
09-11-2002, 05:38 AM
use ...
include "$thisfile[0]";
or
include ($thisfile[0]);

anything inside single quotes are not parsed.

gorilla1
09-11-2002, 02:20 PM
Ah, yes, that does it, thanks very much. I dumbly followed the example in the manual. I wonder why they use single quotes in the example (first example at link below where it shows include 'vars.php').
http://www.php.net/manual/en/function.include.php

G

firepages
09-12-2002, 01:25 AM
Hi, the example in the manual is correct,
but I was not very clear by just saying 'not parsed' in my answer above though.....

include 'vars.php';
will include vars.php
include '$vars.php';
will atttempt to include the file $vars.php ($ and all)

so anything in single quotes is considered by PHP to be 'as is' and plain text, no variables or codeis parsed within single quotes... i.e.

$var="yaks";
echo $var;//outputs yaks
echo "$var";//ouputs yaks
echo '$var';//outputs $var

gorilla1
09-15-2002, 01:26 AM
Another question on this... I set up my index.php3 file on the subdirectory. This is excellent since when a viewer links into the subdirectory from the page on the web site, index.php3 can then find the appropriate file and display it. Great. But I also want some folks to driectly link to this diectory from out side the web page, by just keying the url in on their browser, say like so:

www.xyz.com/user/?M=D">

When they do so, I want them to see the directory listing the way the apache server normally serves it up. When they do link this way, I believe index.php3 gets control. I can spot that they have reached the page this way (outside of using thee link on the web page) from inside index.php3, but is there any way I can just gracefully exit index.php3 and let apache show the directory, or am I stuck having to list out the directory myself (come to think of it, if I let apache show the directory, then both index.php3 and .htaaccess will be visible, which I don't want)?

G