Jump to content

unRAID wrapper to populate globals like $_GET


Recommended Posts

The 'document root' is /usr/local/emhttp so for your 'caution.png' file, it would need to exist in

/usr/local/emhttp/bubba/caution.png

or better,

/usr/local/emhttp/plugins/bubba/caution.png

(and url is http://192.168.0.51/plugins/bubba/caution.png).

 

Something else to be aware of... at present, if the first component of a pathname starts with a capital letter, emhttp will treat as a "page" and will invoke 'template.php', passing the path in a querystring.

See /usr/local/plugins/webGui/template.php.

 

Speaking of wrappers... I will be creating a 'wrapper' PHP file that fills in certain globals such as _GET[].  Code would look something like this:

 

<?php
// for http://tower/filename.php?querystring
// wrapper.php invoked like this:
// /usr/bin/php wrapper.php filename.php querystring
parse_str(str_replace("+","%2B",$argv[2]), $_GET);
include $argv[1];
?>

 

Link to comment

There is a bug in using:

 

parse_str(str_replace("+","%2B",$argv[2]), $_GET);

 

php's parse_str() function hoses up periods in the string... converts them the underscores.

 

I'm using this now:

 

    $_GET = array();
    foreach (explode("&", str_replace("+","%2B",$argv[1])) as $item) {
        list($k, $v) = array_map("urldecode", explode("=", $item));
        $_GET[$k] = $v;
    } 

 

If someone is also using php_cgi, they can test for unRAID's php+cli using:

 

if (php_sapi_name() =="cli") {
  // unRAID php_cli is in use
} else {
  // real php_cgi is in use
}

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...