Page 1 of 1

Need help with codes

Posted: Fri Mar 19, 2004 2:29 am
by pweeapw
Hi,

I'm a php as well as a forum newbie... I recently downloaded SPAW from Sourgeforge.net and am encountering problems with this part...

Code: Select all

if (!ereg('/$', $HTTP_SERVER_VARSї'DOCUMENT_ROOT']))
  $_root = $HTTP_SERVER_VARSї'DOCUMENT_ROOT'].'/';
else
  $_root = $HTTP_SERVER_VARSї'DOCUMENT_ROOT'];

It seems to work fine when i upload it to a server (running UNIX, Apache)... but when i try it on my local server, the DOCUMENT_ROOT fails to produce anything... I'm running WindowsXP with IIS5...

Thanx

Posted: Fri Mar 19, 2004 2:44 am
by markl999
the DOCUMENT_ROOT fails to produce anything
Not sure what you mean by that, but what does echo $_root; show after the code you pasted above?

(by the way, if the rest of the SPAW code is like that, i'd try to find something else to use, using an ereg for that is way over the top)

Posted: Fri Mar 19, 2004 3:20 am
by pweeapw
nothing...

but on the other server it produces the root structure e.g. /var/www/htm

Posted: Fri Mar 19, 2004 3:28 am
by markl999
ok, looking back at previous posts, it look like IIS doesn't set the DOCUMENT_ROOT variable, so you're going to have to set it yourself. So the code works on both servers you could do something like,
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$_SERVER['DOCUMENT_ROOT'] = 'whatever/the/docroot/is';
}

Posted: Fri Mar 19, 2004 3:35 am
by pweeapw
i see...

so i'll have to manually insert the root directory right?
if that's so then wouldn't it be easier to have it like this:

if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'
{
$_root = 'whatever/the/docroot/is';
}

just asking to know the difference bewteen putting it into
$_SERVER["DOCUMENT_ROOT"] instead if putting it straight into the $_root variable

oh yeah... and what do you mean by way over the top?
is there any other rich text editor that you would recommend instead?

Posted: Fri Mar 19, 2004 6:17 am
by markl999
Sure, putting it straight into $_root works too. Using an ereg to check the last char of a string is over the to as it has to invoke the regular expression engine which is too expensive for something a simple as that. A substr($_SERVER['DOCUMENT_ROOT'], -1) will get you the last character. I've not used any rtf editors myself, but there's a few threads on this site that discuss the merits of them, try a search for 'htmlarea' as that's one that's discussed...i think ;)

Posted: Sun Mar 21, 2004 7:36 pm
by pweeapw
i'll do just that...

and thanx for all the help...