Example #1
0
 public function __construct($method, $path, $callback)
 {
     $reqMethod = $method;
     $this->Method = $reqMethod;
     $this->Path = $path;
     $this->Callback = $callback;
     $this->data = Arguments::Request();
     $this->Referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null;
     $this->IsSecureConnection = isset($_SERVER['HTTPS']) ? (bool) $_SERVER['HTTPS'] : false;
     $this->RemoteAddr = $_SERVER['REMOTE_ADDR'];
     $this->RemoteHost = isset($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : null;
     $this->RemotePort = $_SERVER['REMOTE_PORT'];
     $this->MyAddr = $_SERVER['SERVER_ADDR'];
     $this->MyPort = $_SERVER['SERVER_PORT'];
     $this->MyProtocol = $_SERVER['SERVER_PROTOCOL'];
     if ($this->Method == "ALL") {
         $this->Method = "GET";
         Application::GetInstance()->Requests[$this->Method][] = clone $this;
         $this->Method = "POST";
         Application::GetInstance()->Requests[$this->Method][] = clone $this;
         $this->Method = "PUT";
         Application::GetInstance()->Requests[$this->Method][] = clone $this;
         $this->Method = "DELETE";
         Application::GetInstance()->Requests[$this->Method][] = clone $this;
         $this->Method = "AJAX";
         Application::GetInstance()->Requests[$this->Method][] = clone $this;
     } else {
         $this->Method = $reqMethod;
         Application::GetInstance()->Requests[$this->Method][] = $this;
     }
 }
Example #2
0
 public function Run($args = null)
 {
     // Выполняем обработку УРЛов и возвращаем ответ в браузер
     echo Application::GetInstance()->doRequests();
 }
Example #3
0
File: init.php Project: nolka/k5
}
function getAccount($req, $hash, $apiId, $sign)
{
    $af = new AccountManager();
    $db = SystemConfig::GetDatabaseInstance();
    $db->Query("SELECT `AccountId` FROM `Authorized` WHERE `Hash`=?", $hash);
    $accountId = $db->Assoc('AccountId');
    $acc = $af->GetAccountById($accountId);
    if ($acc) {
        $db->Query("SELECT `Secret` FROM `Apps` WHERE `Id`=?d", $api);
        $key = $db->Assoc('Secret');
        $acc = encrypt(toXml($acc), $key);
        return api_response(array('Account' => $acc));
    }
}
function logout($req, $hash, $apiId, $sign)
{
    $af = new AccountManager();
    $result = $af->Logout($hash);
    if ($result) {
        return api_response(array('LoggedOut' => $result));
    } else {
        return api_error(ApiErrorCode::AuthAlreadyLoggedOut, 'Account already logged out!');
    }
}
$app = Application::GetInstance();
$app->Get('login/{login:str}/{password:str}', 'login');
$app->Get('getObject/account/{hash:str}', 'getAccount');
$app->Get('logout/{hash:str}', 'logout');
$app->AppendPath('/{apiId:int}/{hash}', 3);
#dump($app->Requests["GET"]);