예제 #1
0
<?php

namespace phpsec\framework;

const whoami = "phpsec framework 1.0";
/**
 * This file is in charge of setting some environment variables prior to running
 * the front controller, it tries to set those properly even in CLI mode using
 * some tricks.
 */
if (\phpsec\HttpRequest::isCLI()) {
    //the request should be provided in CLI as:
    #php front.php "folder/file?a=b&cd="
    if ($argc == 1) {
        \phpsec\HttpRequest::SetBaseURL("http://localhost/");
    } else {
        \phpsec\HttpRequest::SetBaseURL("http://localhost/" . $argv[1]);
        if (strpos($argv[1], "?") !== false) {
            $QueryString = substr($argv[1], strpos($argv[1], "?") + 1);
            $Params = explode("&", $QueryString);
            foreach ($Params as $p) {
                if (strpos($p, "=") === false) {
                    $_GET[urldecode($p)] = "";
                    continue;
                }
                list($k, $v) = explode("=", $p);
                $_GET[urldecode($k)] = urldecode($v);
            }
        }
    }
} else {