C
C
celen2013-05-08 11:38:45
PHP
celen, 2013-05-08 11:38:45

How can a CMS figure out which page is requested of it without using superglobals?

I have some self-written CMS in PHP, carefully obfuscated by a developer unknown to me. I want to make a CNC for her through my own script. All page requests are processed by the CMS through a single index.php - so I'll just include the script there and reprocess requests with it.
The mechanism of work is conceived as follows: my script, having a CNC conversion rule, first receives the current request url from $_SERVER['REQUEST_URI'], determines if it is a new CNC, and if it is a new CNC, then it gets the old address from the database and feeds it to CMS , replacing in accordance with it the data that the CMS is guided by when generating the page.
But how can a CMS "guess" what URL it is processing? Clearly, through superglobal variables: $_SERVER, $_GET, $_REQUEST and so on. After reviewing the contents of these arrays and replacing the values ​​of all elements that contained a value similar to the current url, I did not achieve anything - when processing the old address understandable by CMS, even if all the url inclusions in the values ​​of superglobal variables are spoiled, the CMS still guesses which page is needed give; when processing a new url, in which the variables are replaced with the ones corresponding to the old one, the CMS indignantly returns 404.
Therefore, the question. How can a CMS figure out which page is requested of it without using data from PHP's environment superglobals?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
E
edogs, 2013-05-08
@celen

php.net/getenv

$_SERVER['REQUEST_URI']='bbb';
echo getenv('REQUEST_URI');

Will display NOT bbb, but the real url.
It used to be very fashionable to use getenv in cms .
And accordingly, read about putenv, carefully (by default, not all variables can be changed).
ps: As well as php.net/apache_getenv and so on in meaning.

A
Andrey Apanasik, 2013-05-08
@Suvitruf

I can't imagine otherwise than through global arrays.
What about in .htaccess?

M
Melkij, 2013-05-08
@melkij

Check what state register_globals is in.

F
fenric, 2015-02-04
@fenric

Change CMS...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question