被领光啦!');die();} $r_red = db_find_one('thread_red',array('tid'=>$tid)); if(empty($r_red)) {message(-1,'ERROR!');die();} $rest_num = $r_red['rest_money']; $set_red = setting_get('tt_redpacket'); if($set_red['allow_cancel']!='1') {message(-1,'管理员禁止撤回红包!');die();} db_update('thread',array('tid'=>$tid),array('red_num'=>0)); db_update('thread_red',array('tid'=>$tid),array('rest'=>0,'rest_money'=>0)); db_update('user',array('uid'=>$__thread['uid']),array(get_credits_name_by_type($set_red['money_type']).'+'=>$rest_num)); db_insert('user_pay',array('uid'=>$__thread['uid'],'status'=>1,'num'=>$rest_num,'type'=>11,'credit_type'=>$set_red['money_type'],'time'=>time(),'code'=>'')); message(0,'撤回成功!'); } // 发表主题帖 | create new thread if($action == 'create') { user_login_check(); if($method == 'GET') { $fid = param(2, 0); $forum = $fid ? forum_read($fid) : array(); $forumlist_allowthread = forum_list_access_filter($forumlist, $gid, 'allowthread'); $forumarr = xn_json_encode(arrlist_key_values($forumlist_allowthread, 'fid', 'name')); if(empty($forumlist_allowthread)) { message(-1, lang('user_group_insufficient_privilege')); } $header['title'] = lang('create_thread'); $header['mobile_title'] = $fid ? $forum['name'] : ''; $header['mobile_linke'] = url("forum-$fid"); $content_num = 0; $content_num_type = 1; if($group['allowsell']=="1") { $input['content_num_status'] = form_radio_yes_no('content_num_status', 0); } $offer_num=0; $input['offer_status'] = form_radio_yes_no('offer_status', 0); $input['red_type'] = form_select('red_type', array('普通红包','拼手气红包','口令红包')); $input['red_num'] = form_text('red_num', '-1'); $input['red_total_money'] = form_text('red_total_money', '0'); $input['red_command'] = form_text('red_command', '0'); $input['post_red'] =form_radio_yes_no('post_red', 0); include _include(APP_PATH.'view/htm/post.htm'); } else { $kv_majia = kv_get('majia'); if (majia_on($kv_majia)) { $majia_nickname = param('majia_nickname'); if($majia_nickname){ $majia_user = majia_create_user($majia_nickname); if ($majia_user[0] === 3) { message(-1, '马甲昵称【'.$majia_nickname.'】与一位真实用户重名,发帖失败,请在后台自行删除此马甲'); } if ($majia_user[0] === 4) { message(-1, '马甲系统错误,发帖失败'); } $uid = $majia_user[1]; $imgsrc = param('imgsrc'); if($imgsrc) { user_update($uid, array('avatar_auto'=>$imgsrc,'avatar'=>0)); }else{ user_update($uid, array('avatar_auto'=>'0')); } } } $set = setting_get('tt_credits'); $credits = $set['thread_exp'];$rmbs = $set['thread_rmb'];$golds = $set['thread_gold']; $golds_op = $golds>0?'+':'';$credits_op = $credits>0?'+':'';$rmbs_op = $rmbs>0?'+':''; if(($credits<0&&($user['credits']+$credits<0))||($golds<0&&($user['golds']+$golds<0))||($rmbs<0&&($user['rmbs']+$rmbs<0))) {message(-1,lang('credit_no_enough'));die();} $c_limit =$set['limit'] ; $add_credit=1; if($c_limit!=0) { $todayTime = strtotime(date('Y-m-d',time()))-1; $todayThread = db_count('post',array('create_date' => array('>'=>$todayTime),'uid'=>$uid,'isfirst'=>'1')); if($c_limit<=$todayThread) $add_credit=0; } $kv_vcode = kv_get('vcode'); if(!empty($kv_vcode['vcode_thread_create_on'])) { $vcode_post = param('vcode'); $vcode_sess = _SESSION('vcode'); strtolower($vcode_post) != strtolower($vcode_sess) AND message('vcode', '验证码不正确'); } // 对 id 进行处理 $is_vote = param('is_vote', 0); if($is_vote==1) { $vote_subject = param('vote_subject');//投票主题 $vote_type = param('vote_type', 0);//投票类型 $vote_days = param('vote_days', 0);//投票天数 $vote_max = param('vote_max', 0);//最大选择数 $vote_content = param('vote_content');//投票选项内容 if($vote_subject=='' || $vote_type== '' || $vote_days=='' || $vote_max=='' || $vote_content==''){ message(-1, '投票信息不完整'); } $vote_days = intval($vote_days); $vote_max = intval($vote_max); $vote_type = intval($vote_type); if($vote_days<=0 || $vote_type<=0 || $vote_max<=0){ message(-1, '投票信息错误'); } $vote_content_arr = explode("\n",$vote_content); //将字符串转为数组 foreach ($vote_content_arr as $k => $v){ $vote_content_arr[$k] = trim($v); //删除多余字符串 } $vote_content_arr = array_filter($vote_content_arr); //过滤数组空值 if($vote_type==1){ $vote_max=1; } if(count($vote_content_arr)<$vote_max){ message(-1, '投票选项数量小于最大选项'); } } $fid = param('fid', 0); $forum = forum_read($fid); empty($forum) AND message('fid', lang('forum_not_exists')); $r = forum_access_user($fid, $gid, 'allowthread'); !$r AND message(-1, lang('user_group_insufficient_privilege')); $subject = htmlspecialchars(param('subject', '', FALSE)); empty($subject) AND message('subject', lang('please_input_subject')); xn_strlen($subject) > 128 AND message('subject', lang('subject_length_over_limit', array('maxlength'=>128))); $message = param('message', '', FALSE); empty($message) AND message('message', lang('please_input_message')); $doctype = param('doctype', 0); $doctype > 10 AND message(-1, lang('doc_type_not_supported')); xn_strlen($message) > 2028000 AND message('message', lang('message_too_long')); $thread = array ( 'fid'=>$fid, 'uid'=>$uid, 'sid'=>$sid, 'subject'=>$subject, 'message'=>$message, 'time'=>$time, 'longip'=>$longip, 'doctype'=>$doctype, ); $set_check = setting_get('tt_check'); if($set_check['user_check']=='1' && $user['OK']!= '1') {message(-1, '您需要等待管理员审核后,才能发表帖子!'); die();} $offer_num = param('offer_num');$offer_status=param('offer_status'); if($offer_num<0){message(-1,'输入数字不合法!不能为负。');die();} if ($offer_status&& $offer_num>0){ $set_offer = setting_get('tt_offer'); if($user[get_credits_name_by_type($set_offer['credits_type'])] - $offer_num <0) { message(-1, '您好,您的余额不足,无法发表该悬赏!点此充值'); die();} } $red_type=param('red_type')+1; $red_num=param('red_num'); $red_total_money=param('red_total_money'); $red_command=param('red_command','0'); if($red_type=='1') $red_total_money*=$red_num; if($red_total_money<0){message(-1,'输入数字不合法!不能为负。');die();} if($red_num>0 && $red_total_money>0){ $set_red = setting_get('tt_redpacket'); if($user[get_credits_name_by_type($set_red['money_type'])] - $red_total_money <0) { message(-1, '您好,您的余额不足,无法发表该红包!点此充值'); die();} if($red_total_money/$red_num < 1.0){ message(-1, '您好,每个红包最低1分,您的输入的金额过少!'); die();} } // todo: $tagids = param('tagid', array(0)); $tagcatemap = $forum['tagcatemap']; foreach($forum['tagcatemap'] as $cate) { $defaulttagid = $cate['defaulttagid']; $isforce = $cate['isforce']; $catetags = array_keys($cate['tagmap']); $intersect = array_intersect($catetags, $tagids); // 比较数组交集 // 判断是否强制 if($isforce) { if(empty($intersect)) { message(-1, '请选择'.$cate['name']); } } } $tid = thread_create($thread, $pid); $pid === FALSE AND message(-1, lang('create_post_failed')); $tid === FALSE AND message(-1, lang('create_thread_failed')); if ($offer_status&& $offer_num>0){ db_update('user',array('uid'=>$uid),array(get_credits_name_by_type($set_offer['credits_type']).'-'=>$offer_num)); db_insert('user_pay',array('uid'=>$uid,'status'=>1,'num'=>$offer_num,'type'=>16,'credit_type'=>$set_offer['credits_type'],'time'=>time(),'code'=>'')); db_update('thread', array('tid' => $tid), array('offerNum' =>$offer_num,'offerStatus'=>0)); } // 引入模型文件 include_once _include(APP_PATH.'plugin/tt_ranklist/model/ranklist.func.php'); // 更新任务进度 $result = ranklist_update($uid,$fid);if($red_num>0 && $red_total_money>0){ db_update('thread',array('tid'=>$tid),array('red_num'=>$red_num)); db_update('user',array('uid'=>$uid),array(get_credits_name_by_type($set_red['money_type']).'-'=>$red_total_money)); db_insert('thread_red',array('tid'=>$tid,'type'=>$red_type,'total'=>$red_num,'rest'=>$red_num,'total_money'=>$red_total_money,'rest_money'=>$red_total_money,'command'=>$red_command)); db_insert('user_pay',array('uid'=>$uid,'status'=>1,'num'=>$red_total_money,'type'=>10,'credit_type'=>$set_red['money_type'],'time'=>time(),'code'=>red_get_type_by_id($red_type))); }$forum_structure_r = $forumlist[$fid]['structure']; $forum_structure= explode('|',$forum_structure_r); $forum_structure_count = count($forum_structure); $update_array = array(); $update_array['tid']= $tid; for($i=0;$i<$forum_structure_count;$i++) $update_array['c'.($i+1)] = param('ini_'.($i+1),'-'); db_insert('thread_structure',$update_array);// 引入任务相关函数 include_once _include(APP_PATH.'plugin/tt_task/model/task.func.php'); // 更新发帖任务进度 $tasklist = task_find(array('available' => 1)); // 先检查是否有未完成的新手任务 $has_unfinished_novice_task = false; foreach($tasklist as $task) { if($task['type'] == 1) { // 新手任务 $condition = json_decode($task['condition'], true); if(!empty($condition) && isset($condition['type']) && $condition['type'] == 'post_thread') { $log = task_log_read($uid, $task['tid']); if(empty($log) || $log['status'] == 0) { $has_unfinished_novice_task = true; if(empty($log)) { task_log_create(array( 'uid' => $uid, 'tid' => $task['tid'], 'status' => 0, 'progress' => 1, 'start_date' => time(), 'complete_date' => 0 )); } else { task_log_update($uid, $task['tid'], array( 'progress+' => 1 )); } // 检查任务是否完成 task_check($uid, $task['tid']); break; } } } } // 如果没有未完成的新手任务,处理日常任务和成就任务 if(!$has_unfinished_novice_task) { foreach($tasklist as $task) { if($task['type'] == 2 || $task['type'] == 3) { // 日常任务或成就任务 $condition = json_decode($task['condition'], true); if(!empty($condition) && isset($condition['type']) && $condition['type'] == 'post_thread') { $log = task_log_read($uid, $task['tid']); // 对于日常任务,检查是否需要重置 if($task['type'] == 2 && !empty($log) && $log['status'] == 1) { // 检查完成时间是否是今天 if(date('Y-m-d', $log['complete_date']) != date('Y-m-d', time())) { // 不是今天完成的,重置任务状态 task_log_update($uid, $task['tid'], array( 'status' => 0, 'progress' => 0, 'complete_date' => 0 )); $log['status'] = 0; $log['progress'] = 0; } } if(empty($log)) { task_log_create(array( 'uid' => $uid, 'tid' => $task['tid'], 'status' => 0, 'progress' => 1, 'start_date' => time(), 'complete_date' => 0 )); } else if($log['status'] == 0 || $task['type'] == 3) { // 成就任务即使完成也继续记录 task_log_update($uid, $task['tid'], array( 'progress+' => 1 )); } // 检查任务是否完成 task_check($uid, $task['tid']); } } } } // todo: /* $tag_cate_id_arr = param('tag_cate_id', array(0)); foreach($tag_cate_id_arr as $tag_cate_id => $tagid) { tag_thread_create($tagid, $tid); } */ $tagids = param('tagid', array(0)); $tagcatemap = $forum['tagcatemap']; foreach($forum['tagcatemap'] as $cate) { $defaulttagid = $cate['defaulttagid']; $isforce = $cate['isforce']; $catetags = array_keys($cate['tagmap']); $intersect = array_intersect($catetags, $tagids); // 比较数组交集 // 判断是否强制 if($isforce) { if(empty($intersect)) { message(-1, '请选择'.$cate['name']); } } // 判断是否默认 if($defaulttagid) { if(empty($intersect)) { array_push($tagids, $defaulttagid); } } } foreach($tagids as $tagid) { $tagid AND tag_thread_create($tagid, $tid); } unset($_SESSION['vcode']); unset($_SESSION['vcode_initpw_ok']); // 对 id 进行处理 if($is_vote==1) { $create_time = $time;//创建时间 $finish_time = $create_time+$vote_days*86400;//结束时间 $arr = array( 'tid'=>$tid, 'uid'=>$uid, 'create_time'=>$create_time, 'finish_time'=>$finish_time, 'type'=> $vote_type, 'max'=>$vote_max, 'subject'=>$vote_subject, ); //投票主题信息 $r = xn_vote_create($arr);//创建抽奖帖 $xn_vote = db_find_one('xn_vote',array('tid'=>$tid)); $vote_id = $xn_vote['vote_id']; foreach($vote_content_arr as $v) { $arr_optoin = array( 'vote_id' => $vote_id, 'tid' => $tid, 'content' => $v, ); xn_vote_info_create($arr_optoin); } //创建投票选项 thread_update($tid, array('is_vote'=>1));//修改帖子状态为投票帖 } if($group['allowsell']=="1") { $content_num_status = param('content_num_status'); $content_num = param('content_num'); if($content_num < 0 ){//判断购买主题货币值小于零 $content_num = 1;//小于零强制写为一 } $content_type = credits_get_content_type_by_name(param('content_type')); if ($content_num_status && $content_num) db_update('thread', array('tid' => $tid), array('content_buy' => $content_num, 'content_buy_type' => $content_type)); } $update_array = array(); if((($add_credit==1)||($add_credit==0&& $credits<0))&&$credits!=0) $update_array['credits+']=$credits; if((($add_credit==1)||($add_credit==0&& $golds<0))&&$golds!=0) $update_array['golds+']=$golds; if((($add_credit==1)||($add_credit==0&& $rmbs<0))&&$rmbs!=0) $update_array['rmbs+']=$rmbs; $uid AND $update_array AND user_update($uid, $update_array); $uid AND $update_array AND $user['gid']>=100 AND user_update_group($uid); $message = ''; isset($update_array['credits+']) AND $message .= lang('credits1').$credits_op.$credits.' ' ; isset($update_array['golds+']) AND $message .= lang('credits2').$golds_op.$golds.' ' ; isset($update_array['rmbs+']) AND $message .= lang('credits3').$rmbs_op.$rmbs ; message(0, lang('create_thread_sucessfully').' '.$message); message(0, lang('create_thread_sucessfully')); } // 帖子详情 | post detail } else { // thread-{tid}-{page}-{keyword}.htm $tid = param(1, 0); $page = param(2, 1); $keyword = param(3); $pagesize = $conf['postlist_pagesize']; //$pagesize = 10; //$page == 1 AND $pagesize++; /** * 定制请加QQ 1218894030 */ function isMobile() { // 如果有HTTP_X_WAP_PROFILE则一定是移动设备 if (isset ($_SERVER['HTTP_X_WAP_PROFILE'])) return true; // 如果via信息含有wap则一定是移动设备,部分服务商会屏