Exemple #1
0
function getProject()
{
    $pc = new projectController();
    $api = new apiController();
    if (isset($_GET)) {
        if (!isset($_GET["api_key"])) {
            return json_encode(["err" => "Specify API_KEY"]);
        } else {
            if (!isset($_GET["project"])) {
                return json_encode(["err" => "Specify PROJECT"]);
            } else {
                $project = $_GET["project"];
                $apikey = $_GET["api_key"];
                if ($api->checkKey($apikey)) {
                    $pr = $pc->getProjectDataFull($project);
                    if (!is_bool($pr)) {
                        return json_encode($pr);
                    } else {
                        return json_encode(["err" => "Project not found!"]);
                    }
                } else {
                    return json_encode(["err" => "Incorrect key."]);
                }
            }
        }
    } else {
        return json_encode(["err" => "No arguments found."]);
    }
}
Exemple #2
0
function api_mycss()
{
    $sql = "SELECT `css` FROM `css` WHERE `uid` = '" . intval(uid()) . "' LIMIT 1";
    $data = get_var($sql);
    if (db_errno() != 0) {
        apiController::send_error(LR_API_DB_ERROR, 'DATABASE ERROR ' . db_error());
    }
    return apiController::send_result($data);
}
 function __construct()
 {
     parent::__construct();
     if (g('c') !== 'get_token') {
         $permit = $this->check_admin_permit();
         if (!permit) {
             $data['code'] = 101;
             $data['message'] = 'not permit';
             render($data, 'rest');
         }
     }
 }
Exemple #4
0
function stoken_api_login($data)
{
    $stoken = z(t(v('stoken')));
    if (!in_array(g('a'), $data) && strlen($stoken) > 0) {
        if ($uid = get_var("SELECT `uid` FROM `stoken` WHERE `token` = '" . s($stoken) . "' AND `on` = '1' LIMIT 1")) {
            $user = get_user_info_by_id($uid);
            if ($user['level'] < 1 || $user['is_closed'] == 1) {
                return apiController::send_error(LR_API_USER_CLOSED, 'USER CLOSED BY ADMIN');
            }
            session_set_cookie_params(c('session_time'));
            @session_start();
            $token = session_id();
            // $_SESSION[ 'token' ] = $stoken; <- 加上这行stoken可以变成token
            $_SESSION['uid'] = $user['id'];
            $_SESSION['uname'] = $user['name'];
            $_SESSION['email'] = $user['email'];
            $_SESSION['level'] = $user['level'];
            $data[] = g('a');
        }
    }
    return $data;
}
Exemple #5
0
function api_checklist_add()
{
    $content = z(t(v('text')));
    if (!not_empty($content)) {
        return apiController::send_error(LR_API_ARGS_ERROR, 'TEXT CAN\'T EMPTY');
    }
    $tid = intval(v('tid'));
    if (intval($tid) < 1) {
        return apiController::send_error(LR_API_ARGS_ERROR, 'TID NOT EXISTS');
    }
    // check user
    $tinfo = get_todo_info_by_id($tid);
    if (intval($tinfo['details']['is_public']) == 0 && uid() != $tinfo['owner_uid']) {
        return apiController::send_error(LR_API_FORBIDDEN, 'ONLY PUBLIC TODO CAN ADD CHECKLIST BY OTHERS');
    }
    $sql = "INSERT INTO `checklist` ( `tid` , `title` , `content` , `timeline` , `uid` ) VALUES ( '" . intval($tid) . "' , '" . s($content) . "' , '" . s($content) . "'  , NOW() , '" . intval(uid()) . "' ) ";
    run_sql($sql);
    if (db_errno() != 0) {
        return apiController::send_error(LR_API_DB_ERROR, 'DATABASE ERROR ' . mysql_error());
    } else {
        return apiController::send_result(get_line("SELECT * FROM `checklist` WHERE `id` = '" . intval(last_id()) . "' LIMIT 1", db()));
    }
}
Exemple #6
0
function plugin_check_mail()
{
    if (intval(kget('mqueue_on')) != 1) {
        return false;
    }
    $sql = "SELECT * FROM `mail_queue` WHERE `timeline` > '" . date("Y-m-d H:i:s", strtotime("-1 hour")) . "' LIMIT 1";
    if ($line = get_line($sql)) {
        session_write_close();
        $info = unserialize($line['data']);
        if (phpmailer_send_mail($info['to'], $info['subject'], $info['body'], kget('mqueue_username'), kget('mqueue_server'), kget('mqueue_port'), kget('mqueue_username'), kget('mqueue_password'))) {
            $sql = "DELETE FROM `mail_queue` WHERE `id` = '" . intval($line['id']) . "' LIMIT 1";
        } else {
            $sql = "UPDATE `mail_queue` SET `timeline` = '" . date("Y-m-d H:i:s", strtotime("-2 hours")) . "' LIMIT 1 ";
        }
        run_sql($sql);
    }
    include_once AROOT . 'controller' . DS . 'api.class.php';
    if (db_errno() != 0) {
        apiController::send_error(LR_API_DB_ERROR, 'DATABASE ERROR ' . db_error());
    }
    return apiController::send_result(array('to_send' => get_var("SELECT COUNT(*) FROM `mail_queue` WHERE `timeline` > '" . date("Y-m-d H:i:s", strtotime("-1 hour")) . "' ")));
}
 /**
  * @return mixed
  */
 public function index()
 {
     $repository = $this->repository->all();
     return $this->apiController->respondWithCollection($repository, new CommentTransformer());
 }
Exemple #8
0
<?php

/**
 * Created by PhpStorm.
 * User: root
 * Date: 1-7-15
 * Time: 15:00
 */
require_once __DIR__ . "/../backend/controllers/apiController.php";
require_once __DIR__ . "/../backend/db/medoo.min.php";
$db = new medoo();
$ac = new apiController();
var_dump(method_exists($db, "asdfasdfasdf"));
$arguments = ["obj" => "string", "func" => "string"];
$objects = [];
$answer = $ac->hasRequiredArguments($arguments);
if (is_bool($answer) && $answer == true) {
    //The get request has the correct arguments.
} else {
    echo json_encode($answer);
}
Exemple #9
0
function note_del_all()
{
    echo run_sql("delete from note where uid='" . uid() . "'") ? apiController::send_result(array()) : apiController::send_error(5003, 'note delete failed');
}
Exemple #10
0
function board_todo_sort()
{
    $list_id = intval(v('list_id'));
    $todos = s(z(t(v('todos'))));
    if (!run_sql("update board_list set todos='{$todos}' where id='{$list_id}'")) {
        return apiController::send_error(6017, 'todo sort failed');
    } else {
        return apiController::send_result('success');
    }
}