<?php

//Author:@DGideas
//2016-02-07
require "../../include.php";
$requestHandle = new DGrst();
$sqlHandle = new DGsql();
$sqlHandle->session_clean();
$key = $requestHandle->token();
$requestHandle->add_param("token", $key);
if (!$sqlHandle->session_add($key)) {
    $requestHandle->code("403", "Request too freqently");
    $requestHandle->add_param("token", null);
}
print json_encode($requestHandle->response());
<?php

//Author:@DGideas
//2016-02-06
require "../../include.php";
$requestHandle = new DGrst();
$sqlHandle = new DGsql();
var_dump($sqlHandle->status());
<?php

//Author:@DGideas
//2016-02-11
require "../../include.php";
$queryHandle = new DGrst();
$sqlHandle = new DGsql();
$sqlHandle->session_clean();
if (!isset($_POST["username"]) || !isset($_POST["password"]) || !isset($_POST["token"])) {
    $queryHandle->code('400', 'Bad arguments');
} else {
    $verified = $sqlHandle->session_verified($_POST["token"]);
    if ($verified) {
        if (!isset($_SERVER["REMOTE_ADDR"])) {
            $localIP = "127.0.0.1";
        } else {
            $localIP = $_SERVER["REMOTE_ADDR"];
        }
    } else {
        $queryHandle->code('403', 'Bad token');
    }
}
// Next step, verified username and password
if ($queryHandle->get_code() == "200") {
    $userId = $sqlHandle->user_get_id($_POST["username"]);
    if ($userId == null) {
        $queryHandle->code("403", "Authentication failed");
    } else {
        if ($sqlHandle->user_login($userId, $_POST["password"], $_POST["token"])) {
            $queryHandle->code("200", "Success");
        } else {
<?php

require "../RESTful/include.php";
$dbHandle = new DGsql();
$config_params = array("dgrca_version" => "1.0", "site_status" => "OK", "site_addr" => "localhost", "site_name" => "Another DGSite", "site_lang" => "zh-CN", "site_charset" => "utf-8", "api_version" => "1.0", "api_status" => "OK", "api_query_freq" => "unlimited", "api_query_times" => "1");
// Insert sone data to `config`
foreach ($config_params as $configName => $configValue) {
    $dbHandle->config_add($configName, $configValue);
}
<?php

//Author:@DGideas
//2016-02-07
require "../../include.php";
$requestHandle = new DGrst();
$sqlHandle = new DGsql();
$requestHandle->add_param("api_version", $sqlHandle->config_query("api_version"));
print json_encode($requestHandle->response());