Esempio n. 1
0
 /**
  * Constructor
  *
  * @param $context Context The current context
  */
 public function __construct(Context $context)
 {
     $this->context = $context;
     if (file_exists($context->rootPath . '/config/admin.php')) {
         $this->config = (include $context->rootPath . '/config/admin.php');
     } else {
         if (file_exists($context->rootPath . '/config/admin.json')) {
             $this->config = JSONParser::parse(file_get_contents($context->rootPath . '/config/admin.json'));
         } else {
             return;
         }
     }
     $this->setup();
 }
Esempio n. 2
0
if (isset($argv[1]) && $argv[1]) {
    $jsonString = $argv[1];
    $_SERVER['REMOTE_ADDR'] = "127.0.0.1";
    Config::$debug = true;
} elseif ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $jsonString = trim(file_get_contents('php://input'));
    /**
     * JSON Logger
     */
    $jsonLogger = new JSONLogger();
    $jsonLogger->setJson($jsonString);
    $jsonLogger->setIpAddress($_SERVER['REMOTE_ADDR']);
    $jsonLogger->insert();
    $jsonParser = new JSONParser();
    try {
        $jsonParser->parse($jsonString);
    } catch (Exception $e) {
        die("Exception: " . $e->getMessage());
    }
} else {
    function send401()
    {
        $realm = "Frogmod Database";
        header('WWW-Authenticate: Basic realm="' . $realm . '"');
        header('HTTP/1.1 401 Unauthorized');
        die;
    }
    function verify_credentials($user, $password)
    {
        //check user and password here. Return true or false
        return $user == Config::$auth['user'] && $password == Config::$auth['pass'];