Just a quick comment about your replacement:
define('DOC_ROOT',(substr($_SERVER['DOCUMENT_ROOT'],-1,strlen($_SERVER['DOCUMENT_ROOT']))=='/') ? $_SERVER['DOCUMENT_ROOT'] : $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR);
Note that the '/' is still hard-coded in there, despite the code's later use of the DIRECTORY_SEPARATOR constant. So, it's trying to be portable yet still failing to do so everywhere.
Also note that here are some shorter versions that do the same (with the above error/oversight fixed):
define('DOC_ROOT',(substr($_SERVER['DOCUMENT_ROOT'], -1)==DIRECTORY_SEPARATOR) ? $_SERVER['DOCUMENT_ROOT'] : $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR);
or just:
define('DOC_ROOT',rtrim($_SERVER['DOCUMENT_ROOT'], DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR);
And yes, I've normally found that most filesystems (and/or the OS) will filter out null directories, so "C:/test/foo.txt" is the same as "C://test/foo.txt" which is the same as "C://///////test/////////foo.txt" which is the same as... etc.
EDIT: Woops, forgot PHP isn't as smart as I'd like it to be (e.g. negative character offsets don't work).