Ejemplo n.º 1
0
Archivo: app.php Proyecto: ramo01/1kapp
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);
}
Ejemplo n.º 2
0
Archivo: app.php Proyecto: ramo01/1kapp
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;
}
Ejemplo n.º 3
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()));
    }
}
Ejemplo n.º 4
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")) . "' ")));
}
Ejemplo n.º 5
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');
}
Ejemplo n.º 6
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');
    }
}