示例#1
0
    require_once DISCUZ_ROOT . './include/task.func.php';
    task_apply($task);
    showmessage('task_applied', "task.php?action=view&id={$id}");
} elseif ($action == 'draw' && $id) {
    if (!$discuz_uid) {
        showmessage('not_loggedin', NULL, 'NOPERM');
    }
    if (!($task = $db->fetch_first("SELECT t.*, mt.dateline AS applytime, mt.status FROM {$tablepre}tasks t, {$tablepre}mytasks mt WHERE mt.uid='{$discuz_uid}' AND mt.taskid=t.taskid AND t.taskid='{$id}' AND t.available='2'"))) {
        showmessage('task_nonexistence', NULL, 'HALTED');
    } elseif ($task['status'] != 0) {
        showmessage('undefined_action', NULL, 'HALTED');
    } elseif ($task['tasklimits'] && $task['achievers'] >= $task['tasklimits']) {
        showmessage('task_up_to_limit', 'task.php');
    }
    require_once DISCUZ_ROOT . './include/tasks/' . $task['scriptname'] . '.inc.php';
    $result = task_csc($task);
    if ($result === TRUE) {
        if ($task['reward']) {
            require_once DISCUZ_ROOT . './include/task.func.php';
            $rewards = task_reward($task);
            if ($task['reward'] == 'magic') {
                $magicname = $db->result_first("SELECT name FROM {$tablepre}magics WHERE magicid='{$task['prize']}'");
            } elseif ($task['reward'] == 'medal') {
                $medalname = $db->result_first("SELECT name FROM {$tablepre}medals WHERE medalid='{$task['prize']}'");
            } elseif ($task['reward'] == 'group') {
                $grouptitle = $db->result_first("SELECT grouptitle FROM {$tablepre}usergroups WHERE groupid='{$task['prize']}'");
            }
            sendpm($discuz_uid, 'task_reward_subject', 'task_reward_' . $task['reward'] . '_message', 0);
        }
        task_sufprocess();
        $db->query("UPDATE {$tablepre}mytasks SET status='1', csc='100', dateline='{$timestamp}' WHERE uid='{$discuz_uid}' AND taskid='{$id}'");
示例#2
0
function task_newbie_complete()
{
    global $db, $tablepre, $discuz_uid, $timestamp, $task, $newbietasks, $newbietaskid, $currenttaskcsc, $nextnewbietaskid, $magicname, $medalname, $grouptitle, $rewards;
    require_once DISCUZ_ROOT . './include/tasks/newbie_' . $newbietasks[$newbietaskid]['scriptname'] . '.inc.php';
    $task = $db->fetch_first("SELECT * FROM {$tablepre}tasks WHERE taskid='{$newbietaskid}' AND available='2'");
    $currenttaskcsc = 0;
    if (task_csc($task) === TRUE) {
        $currenttaskcsc = 100;
        if ($task['reward']) {
            $rewards = task_reward($task);
            if ($task['reward'] == 'magic') {
                $magicname = $db->result_first("SELECT name FROM {$tablepre}magics WHERE magicid='{$task['prize']}'");
            } elseif ($task['reward'] == 'medal') {
                $medalname = $db->result_first("SELECT name FROM {$tablepre}medals WHERE medalid='{$task['prize']}'");
            } elseif ($task['reward'] == 'group') {
                $grouptitle = $db->result_first("SELECT grouptitle FROM {$tablepre}usergroups WHERE groupid='{$task['prize']}'");
            }
            sendnotice($discuz_uid, 'task_reward_' . $task['reward'], 'systempm');
        }
        $db->query("UPDATE {$tablepre}mytasks SET status='1', csc='100', dateline='{$timestamp}' WHERE uid='{$discuz_uid}' AND taskid='{$newbietaskid}'");
        $db->query("UPDATE {$tablepre}tasks SET achievers=achievers+1 WHERE taskid='{$newbietaskid}'", 'UNBUFFERED');
        $nextnewbietaskid = intval($db->result_first("SELECT t.taskid FROM {$tablepre}tasks t LEFT JOIN {$tablepre}mytasks mt ON mt.taskid=t.taskid AND mt.uid='{$discuz_uid}' WHERE mt.taskid IS NULL AND t.available='2' AND t.newbietask='1' ORDER BY t.newbietask DESC LIMIT 1"));
        if ($nextnewbietaskid) {
            $nexttask = $db->fetch_first("SELECT * FROM {$tablepre}tasks WHERE taskid='{$nextnewbietaskid}' AND available='2'");
            $nexttask['newbie'] = 1;
            task_apply($nexttask);
            $db->query("UPDATE {$tablepre}members SET newbietaskid='{$nextnewbietaskid}' WHERE uid='{$discuz_uid}'", 'UNBUFFERED');
        } else {
            $db->query("UPDATE {$tablepre}members SET prompt=prompt^8, newbietaskid='0' WHERE uid='{$discuz_uid}'", 'UNBUFFERED');
        }
        $taskmsg = $newbietasks['task'][$newbietaskid]['scriptname'];
        if (!$nextnewbietaskid) {
            $taskmsg .= '_complete';
        }
        write_statlog('', 'action=newbie&from=' . $taskmsg, '', '', 'task.php');
    }
}