PDA

View Full Version : Trouble with a piece of code.


eon
12-19-2005, 02:34 PM
I'm trying to read the code to learn the code and on row 83 of index.php I found a piece of code. And I don't have a clue what the purpose is of this code.

if(isset($mod_rewrite)&&$mod_rewrite == "1"){

$showprefix = "";

} else {

$showprefix = "./index.php?showimage=";

}

This code was already in Pixelpost 1.4.2. My comment next to the code was: ??WTF??

Please help me out my suffering and tell what it is!

tinyblob
12-19-2005, 02:41 PM
heh.
well.
do you know what mod_rewrite is?

eon
12-19-2005, 02:54 PM
heh.
well.
do you know what mod_rewrite is?

I find out that it has to do something with Apache. Is that right?
But actually, no, it is something new for me.

http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html
Welcome to mod_rewrite, the Swiss Army Knife of URL manipulation!

Aaah, so is the url is like this: "www.foo.com" it wil redirect to "www.foo.com/index.php?showimage="

Is that right? :D

tinyblob
12-19-2005, 03:41 PM
there's a really long thread elsewhere on this forum that discusses mod_rewrite with pixelpost, worth reading!
the basic principal is that a standard url like:

http://touchnothing.net/index.php?showimage=27
can be turned into
hxxp://touchnothing.net/images/27

Joe[y]
12-19-2005, 03:44 PM
there are even more possiblities:

http://photos.jlspurling.com/feeds/rss.xml
http://photos.jlspurling.com/archive/page/1/category/6
http://photos.jlspurling.com/browse
http://photos.jlspurling.com/photo/58
http://photos.jlspurling.com/photo/file/20051217183856_2081.jpg

etc etc

tinyblob
12-19-2005, 03:46 PM
joeys links actually work :D
i've never bothered to set up url rewriting.

eon
12-19-2005, 04:18 PM
if(isset($mod_rewrite)&&$mod_rewrite == "1"){

$showprefix = "";

} else {

$showprefix = "./index.php?showimage=";

}

So the code means:
$mod_rewrite will be filled by Apache (.htaccess).
IF:
there is a var with the name mod_rewrite AND the value of the var is "1"
THEN:
$showprefix will be empty
ELSE:
$showprefix will be a "start" of the url (./index.php?showimage=)

The image ID will filled later in the code. This is correct?

Thanks for you explanation! and I will read the thread.

eon
12-19-2005, 04:42 PM
I have read http://forum.pixelpost.org/showthread.php?t=2317
and I understand the code now for 100%. Thanks!