Main Page - Log in -

PHP CLI GET

From Noah.org

Jump to: navigation, search

Call a PHP script from either the CLI or through a web server via a GET request.

require_once(dirname(__FILE__) . "/../../includes/conf.php");

header("content-type: text/plain");
set_time_limit(0);

// This copies command-line parameters into the $_GET variable.
// This allows the script to be called from http GET or from the command-line.
if ($argv) {
    foreach ($argv as $k=>$v)
    {
        if ($k==0) continue;
        $i = explode("=",$v);
        if (isset($i[1]))
        {
            $_GET[$i[0]] = $i[1];
        }
        else
        {
            $_GET[$i[0]] = True;
        }
    }
}