Beispiel #1
0
 public function authApiKey($user, $key)
 {
     global $postgisdb;
     $postgisdb = $user;
     $settings_viewer = new \app\models\Setting();
     $res = $settings_viewer->get();
     $apiKey = $res['data']['api_key'];
     if ($apiKey == $key && $key != false) {
         return true;
     } else {
         return false;
     }
 }
Beispiel #2
0
 public function get_index()
 {
     include_once 'Cache_Lite/Lite.php';
     if (Input::get('base64') === "true") {
         $this->q = base64_decode(Input::get('q'));
     } else {
         $this->q = urldecode(Input::get('q'));
     }
     $settings_viewer = new \app\models\Setting();
     $res = $settings_viewer->get();
     $this->apiKey = $res['data']['api_key'];
     $this->response = $this->transaction($this->q, Input::get('client_encoding'));
     // Check if $this->data is set in SELECT section
     if (!$this->data) {
         $this->data = $this->response;
     }
     return unserialize($this->data);
 }
<?php

use app\inc\Input;
$db = \app\inc\Input::getPath()->part(2);
$dbSplit = explode("@", $db);
include "http_basic_authen_subuser.php";
if (!$_SESSION['auth'] || $_SESSION['screen_name'] != $db) {
    $settings_viewer = new \app\models\Setting();
    $response = $settings_viewer->get();
    \app\inc\Log::write("Auth");
    // mod_php
    if (isset($_SERVER['PHP_AUTH_USER'])) {
        $username = $_SERVER['PHP_AUTH_USER'];
        $password = $_SERVER['PHP_AUTH_PW'];
        // most other servers
    } elseif (isset($_SERVER['HTTP_AUTHENTICATION'])) {
        if (strpos(strtolower($_SERVER['HTTP_AUTHENTICATION']), 'basic') === 0) {
            list($username, $password) = explode(':', base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6)));
        }
    }
    if (is_null($username)) {
        header('WWW-Authenticate: Basic realm="' . Input::getPath()->part(2) . '"');
        header('HTTP/1.0 401 Unauthorized');
        header("Cache-Control: no-cache, must-revalidate");
        // HTTP/1.1
        header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
        // Date in the past
        // Text to send if user hits Cancel button
        die("Could not authenticate you 1");
    } elseif ($username != Input::getPath()->part(2)) {
        header('WWW-Authenticate: Basic realm="' . Input::getPath()->part(2) . '"');