Exemplo n.º 1
0
    }
    if (empty($result['msg']) == TRUE or empty($params['reward']) == TRUE) {
        $data = array('pubuser' => Assign($params['uid'], 0), 'type' => Assign($params['tag'], 0), 'title' => Assign($params['title']), 'content' => Assign($params['context']), 'pubtime' => 'NOW()', 'anonymous' => Assign($params['anonymous'], 0), 'reward' => Assign($params['reward'], 0), 'rewarded' => empty($params['reward']) ? 0 : $rankscore);
        $id = StorageAdd('hh_techforum', $data);
        if (empty($id) == TRUE) {
            $result['msg'] = MESSAGE_ERROR;
        } else {
            for ($index = 0; $index < 6; $index++) {
                $field = 'image' . strval($index + 1);
                if ($_FILES[$field]['error'] <= 0 and empty($_FILES[$field]['tmp_name']) == FALSE) {
                    $buf_data = array('qid' => $id, 'createdat' => 'NOW()', 'filename' => $_FILES[$field]['name'], 'size' => $_FILES[$field]['size']);
                    $buf_id = StorageAdd('hh_techforum_img', $buf_data);
                    $uploadfile = PIC_F_PATH . DIRECTORY_SEPARATOR . "{$buf_id}.png";
                    $uploadfile_s = PIC_F_PATH . DIRECTORY_SEPARATOR . "{$buf_id}_s.png";
                    move_uploaded_file($_FILES[$field]['tmp_name'], $uploadfile);
                    MakeSmallIMG($uploadfile, $uploadfile_s);
                }
            }
            $result = array('code' => '101', 'data' => array());
            $record = StorageFindID('hh_techforum', $id);
            if (is_array($record) and empty($record) == FALSE) {
                $result['data'][] = array('posttime' => $record['pubtime'], 'tid' => $record['id']);
            }
            ## 设置用戶可兌換積分
            if (empty($rankscore) == FALSE) {
                $message = sprintf(RANKSCORE_ASK, $data['title'], $params['reward']);
                Techuser_setRankscore($params['uid'], 0 - $rankscore, $message);
            }
        }
    }
}
Exemplo n.º 2
0
if (CheckOpenID($params['openid'], $params['uid']) == FALSE) {
    $result['msg'] = MESSAGE_WARNING;
} else {
    if ($params['reward'] == 1) {
        $result['msg'] = '该回复已经被采纳!';
    } else {
        $info_tid = StorageFindID('hh_techforum_list', Assign($params['tolistid'], 0));
        $user_uid = StorageFindID('hh_techuser', Assign($params['uid'], 0));
        $user_touid = StorageFindID('hh_techuser', Assign($params['touid'], 0));
        $info_tid = StorageFindID('hh_techforum', Assign($params['tid'], 0));
        if ($info_tid['rewarded'] == 1) {
            die(JsonEncode(array('code' => '100', 'msg' => '该回复已经被采纳!')));
        }
        ## 設置回帖的採納狀態
        $fields_tolist = array('adopt' => 1);
        StorageEditByID('hh_techforum_list', $fields_tolist, Assign($params['tolistid'], 0));
        ## 添加會貼者之可兌換積分
        $message = sprintf(RANKSCORE_ADOPTED, $info_tid['title'], SafeUsername($user_uid), Techuser_viewRankScore($params['reward']));
        //Techuser_setRankscore(Assign($params['touid'], 0), $params['reward'], $message, TRUE);
        Techuser_setRankByScore(Assign($params['touid'], 0), Techuser_viewRankScore($params['reward']), $message);
        ## 設置主題悬赏狀態
        $fields_tid = array('rewarded' => 1);
        StorageEditByID('hh_techforum', $fields_tid, Assign($params['tid'], 0));
        ## 記錄樓主採納日誌
        $message = sprintf(RANKSCORE_ADOPT, SafeUsername($user_touid), Techuser_viewRankScore($params['reward']));
        Techuser_setRankscore(Assign($params['uid'], 0), 0, $message);
        ## 添加回帖者經驗值
        Techuser_setRank($params['touid'], 2);
        $result = array('code' => '101', 'msg' => MESSAGE_SUCCESS);
    }
}