Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Well, I'm (almost) sure that without making use of the <code>$_SERVER</code> superglobal keys, providing a alternative way to figure out <code>PATH_INFO</code> is just impossible, that being said <a href="http://pt.php.net/manual/en/reserved.variables.server.php" rel="nofollow noreferrer">lets first list all of the $_SERVER keys</a> that we may <strong>possibly</strong> use:</p> <ul> <li>'PHP_SELF'</li> <li>'QUERY_STRING'</li> <li>'SCRIPT_FILENAME'</li> <li>'PATH_TRANSLATED'</li> <li>'SCRIPT_NAME'</li> <li>'REQUEST_URI'</li> <li>'PATH_INFO'</li> <li>'ORIG_PATH_INFO'</li> </ul> <p>We obviously need to ignore the last two. Now we should (<strong>I don't know this for a fact, I'm just assuming because you said so</strong>) filter all the keys that exist in the link you provided (<a href="http://209.85.129.132/search?q=cache%3Ahttp%3A//hoohoo.ncsa.illinois.edu/docs/cgi/env.html" rel="nofollow noreferrer">which BTW is offline ATM</a>), that leaves us with the following keys:</p> <ul> <li>'PHP_SELF'</li> <li>'SCRIPT_FILENAME'</li> <li>'REQUEST_URI'</li> </ul> <p>Regarding your comment to <a href="https://stackoverflow.com/questions/1884041/php-cgi-portable-and-safe-way-to-get-pathinfo/1905357#1905357">Anthonys answer</a>:</p> <blockquote> <p>You are just juggling variables now. <code>SCRIPT_FILENAME</code> is a part of the CGI spec. It will not be available if <code>PATH_INFO</code> is unavailable. As for <code>REQUEST_URI</code>, it's apache's mod_rewrite specific. – LiraNuna</p> </blockquote> <p>I'm running <strong>LightTPD/1.4.20-1 (Win32) with PHP 5.3.0 as CGI, <code>cgi.fix_pathinfo = 1</code> and <code>$_SERVER['REQUEST_URI']</code> is very available to me</strong>, I also remember using that same variable back in the days when no one used <code>mod_rewrite</code> so <strong>my honest humble guess is that you're plain wrong in this point</strong>. Regarding the <code>SCRIPT_FILENAME</code> key I'm unable to test that one out ATM. Still, if we close our eyes really hard and believe that you're right that leaves us with only one variable:</p> <ul> <li>'PHP_SELF'</li> </ul> <p>I'm not trying in being harsh here (and I still believe that there are more solutions) but if <code>PHP_SELF</code> is the only key you want us to work with (<strong>assuming there are no impositions on <code>PHP_SELF</code> itself</strong>) there is only one solution left:</p> <pre><code>function PATH_INFO() { if (array_key_exists('PATH_INFO', $_SERVER) === true) { return $_SERVER['PATH_INFO']; } $whatToUse = basename(__FILE__); // see below return substr($_SERVER['PHP_SELF'], strpos($_SERVER['PHP_SELF'], $whatToUse) + strlen($whatToUse)); } </code></pre> <p>This function should work, however there may be some problems using <strong>the <code>__FILE__</code> constant since it returns the path to the file where the <code>__FILE__</code> constant is declared and not the path to the requested PHP script</strong>, so that's why the $whatToUse is there for: sou you can <strong>replace it with <code>'SCRIPT_FILENAME'</code></strong> or if you really believe in what you are saying, <strong>just use <code>'.php'</code></strong>.</p> <p><strong>You should also <a href="http://seancoates.com/xss-woes" rel="nofollow noreferrer">read this regarding why not to use <code>PHP_SELF</code></a>.</strong></p> <p>If this doesn't work for you, I'm sorry but I can think of anything else.</p> <p><strong>EDIT - Some more reading for you:</strong></p> <ul> <li><a href="http://api.drupal.org/api/function/request_uri/7" rel="nofollow noreferrer">Drupal request_uri()</a> (why do they keep saying <code>REQUEST_URI</code> is Apache specific?)</li> <li><a href="https://stackoverflow.com/questions/279966/phpself-vs-pathinfo-vs-scriptname-vs-requesturi"><code>PHP_SELF</code> vs <code>PATH_INFO</code> vs <code>SCRIPT_NAME</code> vs <code>REQUEST_URI</code></a></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload