/** * 处理投票 */ public function post() { $subjectid = intval($_POST['subjectid']); if (!$subjectid) { showmessage(L('vote_novote'), 'blank'); } //当前站点 $siteid = SITEID; //判断是否已投过票,或者尚未到第二次投票期 $return = $this->check($subjectid); switch ($return) { case 0: showmessage(L('vote_voteyes'), "?m=vote&c=index&a=result&subjectid={$subjectid}&siteid={$siteid}"); break; case -1: showmessage(L('vote_voteyes'), "?m=vote&c=index&a=result&subjectid={$subjectid}&siteid={$siteid}"); break; } if (!is_array($_POST['radio'])) { showmessage(L('vote_nooption'), 'blank'); } $time = SYS_TIME; $data_arr = array(); foreach ($_POST['radio'] as $radio) { $data_arr[$radio] = '1'; } $new_data = array2string($data_arr); //转成字符串存入数据库中 //添加到数据库 $this->vote_data->insert(array('userid' => $this->userid, 'username' => $this->username, 'subjectid' => $subjectid, 'time' => $time, 'ip' => $this->ip, 'data' => $new_data)); //查询投票奖励点数,并更新会员点数 $vote_arr = $this->vote->get_one(array('subjectid' => $subjectid)); pc_base::load_app_class('receipts', 'pay', 0); receipts::point($vote_arr['credit'], $this->userid, $this->username, '', 'selfincome', L('vote_post_point')); //更新投票人数 $this->vote->update(array('votenumber' => '+=1'), array('subjectid' => $subjectid)); showmessage(L('vote_votesucceed'), "?m=vote&c=index&a=result&subjectid={$subjectid}&siteid={$siteid}"); }
/** * 更新评论的状态 * @param string $commentid 评论ID * @param integer $id 内容ID * @param integer $status 状态{1:通过 ,0:未审核, -1:不通过,将做删除操作} */ public function status($commentid, $id, $status = -1) { if (!($comment = $this->comment_db->get_one(array('commentid' => $commentid), 'tableid, commentid'))) { $this->msg_code = 6; return false; } //为数据存储数据模型设置 数据表名。 $this->comment_data_db->table_name($comment['tableid']); if (!($comment_data = $this->comment_data_db->get_one(array('id' => $id, 'commentid' => $commentid)))) { $this->msg_code = 6; return false; } //读取评论的站点配置信息 $site = $this->comment_setting_db->get_one(array('siteid' => $comment_data['siteid'])); if ($status == 1) { //通过的时候 $sql['total'] = '+=1'; switch ($comment_data['direction']) { case 1: //正方 $sql['square'] = '+=1'; break; case 2: //反方 $sql['anti'] = '+=1'; break; case 3: //中立方 $sql['neutral'] = '+=1'; break; } //当评论被设置为通过的时候,更新评论总表的数量。 $this->comment_db->update($sql, array('commentid' => $comment['commentid'])); //更新评论内容状态 $this->comment_data_db->update(array('status' => $status), array('id' => $id, 'commentid' => $commentid)); //当评论用户ID不为空,而且站点配置了积分添加项,支付模块也存在的时候,为用户添加积分。 if (!empty($comment_data['userid']) && !empty($site['add_point']) && module_exists('pay')) { pc_base::load_app_class('receipts', 'pay', 0); receipts::point($site['add_point'], $comment_data['userid'], $comment_data['username'], '', 'selfincome', 'Comment'); } } elseif ($status == -1) { //删除数据 //如果数据原有状态为已经通过,需要删除评论总表中的总数 if ($comment_data['status'] == 1) { $sql['total'] = '-=1'; switch ($comment_data['direction']) { case '1': //正方 $sql['square'] = '-=1'; break; case '2': //反方 $sql['anti'] = '-=1'; break; case '3': //中立方 $sql['neutral'] = '-=1'; break; } $this->comment_db->update($sql, array('commentid' => $comment['commentid'])); } //删除存储表的数据 $this->comment_data_db->delete(array('id' => $id, 'commentid' => $commentid)); //删除存储表总数记录 $this->comment_table_db->edit_total($comment['tableid'], '-=1'); //当评论ID不为空,站点配置了删除的点数,支付模块存在的时候,删除用户的点数。 if (!empty($comment_data['userid']) && !empty($site['del_point']) && module_exists('pay')) { pc_base::load_app_class('spend', 'pay', 0); $op_userid = param::get_cookie('userid'); $op_username = param::get_cookie('admin_username'); spend::point($site['del_point'], L('comment_point_del', '', 'comment'), $comment_data['userid'], $comment_data['username'], $op_userid, $op_username); } } //删除审核表中的数据 $this->comment_check_db->delete(array('comment_data_id' => $id)); $this->msg_code = 0; return true; }
public function over() { $M = getcache('ask', 'commons'); $M = $M[1]; $_username = param::get_cookie('_username'); $_userid = param::get_cookie('_userid'); $id = intval($_GET['id']); $this->db->status($id, 6, $_userid); if ($M['return_credit']) { extract($this->db->get_one("askid='{$id}'", "userid,ischeck", $this->table_name)); if ($userid != $_userid) { showmessage(L('no_edit_other_people_info'), HTTP_REFERER); } if ($ischeck) { pc_base::load_app_class('receipts', 'pay', 0); receipts::point($M['return_credit'], $userid, $username, $flag, 'selfincome', L('return_credit'), $username); } } showmessage(L('operation_success'), HTTP_REFERER); }
public function info_publish() { $memberinfo = $this->memberinfo; $grouplist = getcache('grouplist'); $SEO['title'] = L('info_publish', '', 'info'); //判断会员组是否允许投稿 if (!$grouplist[$memberinfo['groupid']]['allowpost']) { showmessage(L('member_group') . L('publish_deny'), HTTP_REFERER); } //判断每日投稿数 $this->content_check_db = pc_base::load_model('content_check_model'); $todaytime = strtotime(date('y-m-d', SYS_TIME)); $_username = $memberinfo['username']; $allowpostnum = $this->content_check_db->count("`inputtime` > {$todaytime} AND `username`='{$_username}'"); if ($grouplist[$memberinfo['groupid']]['allowpostnum'] > 0 && $allowpostnum >= $grouplist[$memberinfo['groupid']]['allowpostnum']) { showmessage(L('allowpostnum_deny') . $grouplist[$memberinfo['groupid']]['allowpostnum'], HTTP_REFERER); } $siteids = getcache('category_content', 'commons'); header("Cache-control: private"); if (isset($_POST['dosubmit'])) { $catid = intval($_POST['info']['catid']); $siteid = $siteids[$catid]; $CATEGORYS = getcache('category_content_' . $siteid, 'commons'); $category = $CATEGORYS[$catid]; $modelid = $category['modelid']; if (!$modelid) { showmessage(L('illegal_parameters'), HTTP_REFERER); } $this->content_db = pc_base::load_model('content_model'); $this->content_db->set_model($modelid); $table_name = $this->content_db->table_name; $fields_sys = $this->content_db->get_fields(); $this->content_db->table_name = $table_name . '_data'; $fields_attr = $this->content_db->get_fields(); $fields = array_merge($fields_sys, $fields_attr); $fields = array_keys($fields); $info = array(); foreach ($_POST['info'] as $_k => $_v) { if (in_array($_k, $fields)) { $info[$_k] = $_v; } } $post_fields = array_keys($_POST['info']); $post_fields = array_intersect_assoc($fields, $post_fields); $setting = string2array($category['setting']); if ($setting['presentpoint'] < 0 && $memberinfo['point'] < abs($setting['presentpoint'])) { showmessage(L('points_less_than', array('point' => $memberinfo['point'], 'need_point' => abs($setting['presentpoint']))), APP_PATH . 'index.php?m=pay&c=deposit&a=pay&exchange=point', 3000); } //判断会员组投稿是否需要审核 if ($grouplist[$memberinfo['groupid']]['allowpostverify'] || !$setting['workflowid']) { $info['status'] = 99; } else { $info['status'] = 1; } $info['username'] = $memberinfo['username']; $this->content_db->siteid = $siteid; $id = $this->content_db->add_content($info); //检查投稿奖励或扣除积分 $flag = $catid . '_' . $id; if ($setting['presentpoint'] > 0) { pc_base::load_app_class('receipts', 'pay', 0); receipts::point($setting['presentpoint'], $memberinfo['userid'], $memberinfo['username'], $flag, 'selfincome', L('contribute_add_point'), $memberinfo['username']); } else { pc_base::load_app_class('spend', 'pay', 0); spend::point($setting['presentpoint'], L('contribute_del_point'), $memberinfo['userid'], $memberinfo['username'], '', '', $flag); } //缓存结果 $model_cache = getcache('model', 'commons'); $infos = array(); foreach ($model_cache as $modelid => $model) { if ($model['siteid'] == $siteid) { $datas = array(); $this->content_db->set_model($modelid); $datas = $this->content_db->select(array('username' => $memberinfo['username'], 'sysadd' => 0), 'id,catid,title,url,username,sysadd,inputtime,status', 100, 'id DESC'); } } setcache('member_' . $memberinfo['userid'] . '_' . $siteid, $infos, 'content'); //缓存结果 END if ($info['status'] == 99) { showmessage(L('contributors_success'), APP_PATH . 'index.php?m=member&c=content&a=info_top&id=' . $id . '&catid=' . $catid . '&msg=1'); } else { showmessage(L('contributors_checked'), APP_PATH . 'index.php?m=member&c=content&a=info_top&id=' . $id . '&catid=' . $catid . '&msg=1'); } } else { $show_header = $show_dialog = $show_validator = ''; $step = $step_1 = $step_2 = $step_3 = $step_4; $temp_language = L('news', '', 'content'); $sitelist = getcache('sitelist', 'commons'); /* if(!isset($_GET['siteid']) && count($sitelist)>1) { include template('member', 'content_publish_select_model'); exit; } */ //设置cookie 在附件添加处调用 param::set_cookie('module', 'content'); $siteid = intval($_GET['siteid']); //获取信息模型类别、区域、城市信息 $info_linkageid = getinfocache('info_linkageid'); $cityid = getcity(trim($_GET['city']), 'linkageid'); $cityname = getcity(trim($_GET['city']), 'name'); $citypinyin = getcity(trim($_GET['city']), 'pinyin'); $zone = intval($_GET['zone']); $zone_name = get_linkage($zone, $info_linkageid, '', 0); if (!$siteid) { $siteid = 1; } $CATEGORYS = getcache('category_content_' . $siteid, 'commons'); $priv_db = pc_base::load_model('category_priv_model'); //加载栏目权限表数据模型 foreach ($CATEGORYS as $catid => $cat) { if ($cat['siteid'] == $siteid && $cat['child'] == 0 && $cat['type'] == 0 && $priv_db->get_one(array('catid' => $catid, 'roleid' => $memberinfo['groupid'], 'is_admin' => 0, 'action' => 'add'))) { break; } } $catid = $_GET['catid'] ? intval($_GET['catid']) : $catid; if (!$catid) { showmessage(L('category') . L('publish_deny'), APP_PATH . 'index.php?m=member'); } //判断本栏目是否允许投稿 if (!$priv_db->get_one(array('catid' => $catid, 'roleid' => $memberinfo['groupid'], 'is_admin' => 0, 'action' => 'add'))) { showmessage(L('category') . L('publish_deny'), APP_PATH . 'index.php?m=member'); } $category = $CATEGORYS[$catid]; if ($category['siteid'] != $siteid) { showmessage(L('site_no_category'), '?m=member&c=content&a=info_publish'); } $setting = string2array($category['setting']); if ($zone == 0 && !isset($_GET['catid'])) { $step = 1; include template('member', 'info_content_publish_select'); exit; } elseif ($zone == 0 && $category['child']) { $step = 2; $step_1 = '<a href="' . APP_PATH . 'index.php?m=member&c=content&a=info_publish&siteid=' . $siteid . '&city=' . $citypinyin . '">' . $category['catname'] . '</a>'; include template('member', 'info_content_publish_select'); exit; } elseif ($zone == 0 && isset($_GET['catid'])) { $step = 3; $step_1 = '<a href="' . APP_PATH . 'index.php?m=member&c=content&a=info_publish&siteid=' . $siteid . '">' . $CATEGORYS[$category['parentid']]['catname'] . '</a>'; $step_2 = '<a href="' . APP_PATH . 'index.php?m=member&c=content&a=info_publish&siteid=' . $siteid . '&city=' . $citypinyin . '&catid=' . $category['parentid'] . '">' . $category['catname'] . '</a>'; $zone_arrchild = show_linkage($info_linkageid, $cityid, $cityid); include template('member', 'info_content_publish_select'); exit; } elseif ($zone !== 0 && get_linkage_level($info_linkageid, $zone, 'child') && !$_GET['jumpstep']) { $step = 4; $step_1 = '<a href="' . APP_PATH . 'index.php?m=member&c=content&a=info_publish&siteid=' . $siteid . '&city=' . $citypinyin . '">' . $CATEGORYS[$category['parentid']]['catname'] . '</a>'; $step_2 = '<a href="' . APP_PATH . 'index.php?m=member&c=content&a=info_publish&siteid=' . $siteid . '&city=' . $citypinyin . '&catid=' . $category['parentid'] . '">' . $category['catname'] . '</a>'; $step_3 = '<a href="' . APP_PATH . 'index.php?m=member&c=content&a=info_publish&siteid=' . $siteid . '&city=' . $citypinyin . '&catid=' . $catid . '">' . $zone_name . '</a>'; $zone_arrchild = get_linkage_level($info_linkageid, $zone, 'arrchildinfo'); include template('member', 'info_content_publish_select'); exit; } if ($setting['presentpoint'] < 0 && $memberinfo['point'] < abs($setting['presentpoint'])) { showmessage(L('points_less_than', array('point' => $memberinfo['point'], 'need_point' => abs($setting['presentpoint']))), APP_PATH . 'index.php?m=pay&c=deposit&a=pay&exchange=point', 3000); } if ($category['type'] != 0) { showmessage(L('illegal_operation')); } $modelid = $category['modelid']; require CACHE_MODEL_PATH . 'content_form.class.php'; $content_form = new content_form($modelid, $catid, $CATEGORYS); $data = array('zone' => $zone, 'city' => $cityid); $forminfos_data = $content_form->get($data); $forminfos = array(); foreach ($forminfos_data as $_fk => $_fv) { if ($_fv['isomnipotent']) { continue; } if ($_fv['formtype'] == 'omnipotent') { foreach ($forminfos_data as $_fm => $_fm_value) { if ($_fm_value['isomnipotent']) { $_fv['form'] = str_replace('{' . $_fm . '}', $_fm_value['form'], $_fv['form']); } } } $forminfos[$_fk] = $_fv; } $formValidator = $content_form->formValidator; //去掉栏目id unset($forminfos['catid']); $workflowid = $setting['workflowid']; header("Cache-control: private"); include template('member', 'info_content_publish'); } }
/** * 更新评论的状态 * @param string $reviewsid 评论ID * @param integer $id 内容ID * @param integer $status 状态{1:通过 ,0:未审核, -1:不通过,将做删除操作} */ public function status($reviewsid, $id, $status = -1) { if (!($reviews = $this->reviews_db->get_one(array('reviewsid' => $reviewsid), 'tableid, reviewsid'))) { $this->msg_code = 6; return false; } //为数据存储数据模型设置 数据表名。 $this->reviews_data_db->table_name($reviews['tableid']); if (!($reviews_data = $this->reviews_data_db->get_one(array('id' => $id, 'reviewsid' => $reviewsid)))) { $this->msg_code = 6; return false; } //读取评论的站点配置信息 $site = $this->reviews_setting_db->get_one(array('siteid' => $reviews_data['siteid'])); if ($status == 1) { //通过的时候 $sql['total'] = '+=1'; $sql['star1'] = '+=' . $reviews_data['star1']; $sql['star2'] = '+=' . $reviews_data['star2']; $sql['star3'] = '+=' . $reviews_data['star3']; $sql['star4'] = '+=' . $reviews_data['star4']; $sql['star5'] = '+=' . $reviews_data['star5']; $sql['star6'] = '+=' . $reviews_data['star6']; $reviews = $this->reviews_db->get_one(array('reviewsid' => $reviewsid)); $sql['allstar'] = $reviews['allstar'] + $reviews_data['star1'] + $reviews_data['star2'] + $reviews_data['star3'] + $reviews_data['star4'] + $reviews_data['star5'] + $reviews_data['star6']; //当评论被设置为通过的时候,更新评论总表的数量。 $this->reviews_db->update($sql, array('reviewsid' => $reviews['reviewsid'])); //更新评论内容状态 $this->reviews_data_db->update(array('status' => $status), array('id' => $id, 'reviewsid' => $reviewsid)); //当评论用户ID不为空,而且站点配置了积分添加项,支付模块也存在的时候,为用户添加积分。 if (!empty($reviews_data['userid']) && !empty($site['add_point']) && module_exists('pay')) { pc_base::load_app_class('receipts', 'pay', 0); receipts::point($site['add_point'], $reviews_data['userid'], $reviews_data['username'], '', 'selfincome', 'reviews'); } } elseif ($status == -1) { //删除数据 //如果数据原有状态为已经通过,需要删除评论总表中的总数 if ($reviews_data['status'] == 1) { $sql['total'] = '-=1'; $sql['star1'] = '-=' . $reviews_data['star1']; $sql['star2'] = '-=' . $reviews_data['star2']; $sql['star3'] = '-=' . $reviews_data['star3']; $sql['star4'] = '-=' . $reviews_data['star4']; $sql['star5'] = '-=' . $reviews_data['star5']; $sql['star6'] = '-=' . $reviews_data['star6']; $reviews = $this->reviews_db->get_one(array('reviewsid' => $reviewsid)); $sql['allstar'] = $reviews['allstar'] - $reviews_data['star1'] - $reviews_data['star2'] - $reviews_data['star3'] - $reviews_data['star4'] - $reviews_data['star5'] - $reviews_data['star6']; $this->reviews_db->update($sql, array('reviewsid' => $reviews['reviewsid'])); } //删除存储表的数据 $this->reviews_data_db->delete(array('id' => $id, 'reviewsid' => $reviewsid)); //删除存储表总数记录 $this->reviews_table_db->edit_total($reviews['tableid'], '-=1'); //当评论ID不为空,站点配置了删除的点数,支付模块存在的时候,删除用户的点数。 if (!empty($reviews_data['userid']) && !empty($site['del_point']) && module_exists('pay')) { pc_base::load_app_class('spend', 'pay', 0); $op_userid = param::get_cookie('userid'); $op_username = param::get_cookie('admin_username'); spend::point($site['del_point'], L('reviews_point_del', '', 'reviews'), $reviews_data['userid'], $reviews_data['username'], $op_userid, $op_username); } } //删除审核表中的数据 $this->reviews_check_db->delete(array('reviews_data_id' => $id)); $this->msg_code = 0; return true; }
/** * 过审内容 */ public function pass() { $memberinfo = $this->memberinfo; if ($memberinfo['status'] != 99 || $memberinfo['groupid'] <= 12) { showmessage('你没有权限操作此项'); } $message_db = pc_base::load_model('message_model'); $content_db = pc_base::load_model('content_model'); $catid = intval($_GET['catid']); if (!$catid) { showmessage(L('missing_part_parameters')); } $this->siteid = get_siteid(); $this->categorys = getcache('category_content_' . $this->siteid, 'commons'); $category = $this->categorys[$catid]; $setting = string2array($category['setting']); $workflowid = $setting['workflowid']; //print_r($category); //只有存在工作流才需要审核 if ($workflowid) { $steps = intval($_GET['steps']); //检查当前用户有没有当前工作流的操作权限 $workflows = getcache('workflow_' . $this->siteid, 'commons'); $workflows = $workflows[$workflowid]; $workflows_setting = string2array($workflows['setting']); //将有权限的级别放到新数组中 $admin_privs = array(); foreach ($workflows_setting as $_k => $_v) { if (empty($_v)) { continue; } foreach ($_v as $_value) { if ($_value == $admin_username) { $admin_privs[$_k] = $_k; } } } //if($_SESSION['roleid']!=1 && $steps && !in_array($steps,$admin_privs)) showmessage(L('permission_to_operate')); //更改内容状态 if (isset($_GET['reject'])) { //退稿 $status = 0; } else { //工作流审核级别 $workflow_steps = $workflows['steps']; if ($workflow_steps > $steps) { $status = $steps + 1; } else { $status = 99; } if ($catid == 9) { $str1 = ""; $str2 = ""; switch ($status) { case 1: $str1 = '您的申报的项目'; $str2 = '正在进一步审核'; break; case 2: $str1 = '您的申报的项目'; $str2 = '通过项目审核'; break; case 99: $str1 = '您的申报的项目'; $str2 = '通过了审核'; break; default: $str1 = '您的申报的项目'; $str2 = '已通过了审核'; } //非退稿,发送审核消息 if (isset($_POST['ids']) && !empty($_POST['ids'])) { foreach ($_POST['ids'] as $id) { $content_info = $this->db->get_content($catid, $id); $memberinfo = $this->db->get_one(array('username' => $content_info['username']), 'userid, username'); $title = $content = $str1 . '"' . $content_info['title'] . '"' . $str2; $message_db->add_message($memberinfo['username'], 'SYSTEM', $title, $content); } } } } //echo $status;die; $memberinfo = $this->db->get_one(array('username' => 'shenhua52'), 'userid, username'); $modelid = $this->categorys[$catid]['modelid']; $content_db->set_model($modelid); $content_db->search_db = pc_base::load_model('search_model'); //审核通过,检查录入奖励或扣除积分 if ($status == 99) { $html = pc_base::load_app_class('html', 'content'); $this->url = pc_base::load_app_class('url', 'content'); if (isset($_POST['ids']) && !empty($_POST['ids'])) { foreach ($_POST['ids'] as $id) { $content_info = $content_db->get_content($catid, $id); $memberinfo = $this->db->get_one(array('username' => $content_info['username']), 'userid, username'); $flag = $catid . '_' . $id; if ($setting['presentpoint'] > 0) { pc_base::load_app_class('receipts', 'pay', 0); receipts::point($setting['presentpoint'], $memberinfo['userid'], $memberinfo['username'], $flag, 'selfincome', L('contribute_add_point'), $memberinfo['username']); } else { pc_base::load_app_class('spend', 'pay', 0); spend::point($setting['presentpoint'], L('contribute_del_point'), $memberinfo['userid'], $memberinfo['username'], '', '', $flag); } if ($setting['content_ishtml'] == '1') { //栏目有静态配置 $urls = $this->url->show($id, 0, $content_info['catid'], $content_info['inputtime'], '', $content_info, 'add'); $html->show($urls[1], $urls['data'], 0); } //更新到全站搜索 $inputinfo = ''; $inputinfo['system'] = $content_info; $content_db->search_api($id, $inputinfo); } } else { if (isset($_GET['id']) && $_GET['id']) { $id = intval($_GET['id']); $content_info = $content_db->get_content($catid, $id); $memberinfo = $this->db->get_one(array('username' => 'shenhua52'), 'userid, username'); //print_r($content_db); // print_r($this->db); //$memberinfo = $this->db->get_one(array('username'=>$content_info['username']), 'userid, username'); $flag = $catid . '_' . $id; if ($setting['presentpoint'] > 0) { pc_base::load_app_class('receipts', 'pay', 0); receipts::point($setting['presentpoint'], $memberinfo['userid'], $memberinfo['username'], $flag, 'selfincome', L('contribute_add_point'), $memberinfo['username']); } else { pc_base::load_app_class('spend', 'pay', 0); spend::point($setting['presentpoint'], L('contribute_del_point'), $memberinfo['userid'], $memberinfo['username'], '', '', $flag); } //单篇审核,生成静态 if ($setting['content_ishtml'] == '1') { //栏目有静态配置 $urls = $this->url->show($id, 0, $content_info['catid'], $content_info['inputtime'], '', $content_info, 'add'); $html->show($urls[1], $urls['data'], 0); } //更新到全站搜索 $inputinfo = ''; $inputinfo['system'] = $content_info; $content_db->search_api($id, $inputinfo); } } } if (isset($_GET['ajax_preview'])) { $_POST['ids'] = $_GET['id']; } $content_db->status($_POST['ids'], $status); } showmessage(L('operation_success'), HTTP_REFERER); }
/** * 过审内容 */ public function pass() { $admin_username = param::get_cookie('admin_username'); $catid = intval($_GET['catid']); if (!$catid) { showmessage(L('missing_part_parameters')); } $category = $this->categorys[$catid]; $setting = string2array($category['setting']); $workflowid = $setting['workflowid']; //只有存在工作流才需要审核 if ($workflowid) { $steps = intval($_GET['steps']); //检查当前用户有没有当前工作流的操作权限 $workflows = getcache('workflow_' . $this->siteid, 'commons'); $workflows = $workflows[$workflowid]; $workflows_setting = string2array($workflows['setting']); //将有权限的级别放到新数组中 $admin_privs = array(); foreach ($workflows_setting as $_k => $_v) { if (empty($_v)) { continue; } foreach ($_v as $_value) { if ($_value == $admin_username) { $admin_privs[$_k] = $_k; } } } if ($_SESSION['roleid'] != 1 && $steps && !in_array($steps, $admin_privs)) { showmessage(L('permission_to_operate')); } //更改内容状态 if (isset($_GET['reject'])) { //退稿 $status = 0; } else { //工作流审核级别 $workflow_steps = $workflows['steps']; if ($workflow_steps > $steps) { $status = $steps + 1; } else { $status = 99; } } $modelid = $this->categorys[$catid]['modelid']; $this->db->set_model($modelid); //审核通过,检查投稿奖励或扣除积分 if ($status == 99) { $html = pc_base::load_app_class('html', 'content'); $this->url = pc_base::load_app_class('url', 'content'); $member_db = pc_base::load_model('member_model'); if (isset($_POST['ids']) && !empty($_POST['ids'])) { foreach ($_POST['ids'] as $id) { $content_info = $this->db->get_content($catid, $id); $memberinfo = $member_db->get_one(array('username' => $content_info['username']), 'userid, username'); $flag = $catid . '_' . $id; if ($setting['presentpoint'] > 0) { pc_base::load_app_class('receipts', 'pay', 0); receipts::point($setting['presentpoint'], $memberinfo['userid'], $memberinfo['username'], $flag, 'selfincome', L('contribute_add_point'), $memberinfo['username']); } else { pc_base::load_app_class('spend', 'pay', 0); spend::point($setting['presentpoint'], L('contribute_del_point'), $memberinfo['userid'], $memberinfo['username'], '', '', $flag); } if ($setting['content_ishtml'] == '1') { //栏目有静态配置 $urls = $this->url->show($id, 0, $content_info['catid'], $content_info['inputtime'], '', $content_info, 'add'); $html->show($urls[1], $urls['data'], 0); } } } else { if (isset($_GET['id']) && $_GET['id']) { $id = intval($_GET['id']); $content_info = $this->db->get_content($catid, $id); $memberinfo = $member_db->get_one(array('username' => $content_info['username']), 'userid, username'); $flag = $catid . '_' . $id; if ($setting['presentpoint'] > 0) { pc_base::load_app_class('receipts', 'pay', 0); receipts::point($setting['presentpoint'], $memberinfo['userid'], $memberinfo['username'], $flag, 'selfincome', L('contribute_add_point'), $memberinfo['username']); } else { pc_base::load_app_class('spend', 'pay', 0); spend::point($setting['presentpoint'], L('contribute_del_point'), $memberinfo['userid'], $memberinfo['username'], '', '', $flag); } //单篇审核,生成静态 if ($setting['content_ishtml'] == '1') { //栏目有静态配置 $urls = $this->url->show($id, 0, $content_info['catid'], $content_info['inputtime'], '', $content_info, 'add'); $html->show($urls[1], $urls['data'], 0); } } } } if (isset($_GET['ajax_preview'])) { $_POST['ids'] = $_GET['id']; } $this->db->status($_POST['ids'], $status); } showmessage(L('operation_success'), HTTP_REFERER); }
function vote($id, $pid) { $M = getcache('ask', 'commons'); $M = $M[1]; $_username = param::get_cookie('_username'); $_userid = param::get_cookie('_userid'); $id = intval($id); $pid = intval($pid); $userid = intval($_userid); if (!$id || !$pid || !$userid) { return false; } $r = $this->db->get_one("count(voteid) AS num", $this->db_tablepre . "ask_vote", "askid={$id} AND userid={$userid}"); if ($r['num'] > 0) { return false; } $a = $this->db->get_one('catid', $this->db_tablepre . "ask", "askid={$id} AND siteid=" . $this->siteid); //检测表 $posts_table_name = $this->posts_table($a['catid']); $this->table_name = $posts_table_name; $this->update(array('votecount' => '+=1'), "pid={$pid}"); if ($M['vote_give_credit']) { $maxnum = floor($M['vote_max_credit'] / $M['vote_give_credit']); if ($r['num'] <= $maxnum) { $this->credit->update_credit($_userid, $_username, $M['vote_give_credit'], 1); pc_base::load_app_class('receipts', 'pay', 0); receipts::point($M['vote_give_credit'], $_userid, $_username, $flag, 'selfincome', L('votes_the_reward_integral'), $_username); } } $posts['askid'] = $id; $posts['pid'] = $pid; $posts['userid'] = $userid; $posts['addtime'] = SYS_TIME; return $this->db->insert($posts, $this->db_tablepre . "ask_vote"); }
function accept_answer($id, $pid) { $M = getcache('ask', 'commons'); $M = $M[1]; $_username = param::get_cookie('_username'); $_userid = param::get_cookie('_userid'); $id = intval($id); $pid = intval($pid); if (!$id || !$pid) { return false; } $a = $this->db->get_one("userid,catid,status,reward", $this->table_name, "askid='{$id}'"); if (!$a) { return false; } if ($a['status'] > 4) { showmessage(L('no_edit'), HTTP_REFERER); } if ($a['userid'] != $_userid) { showmessage(L('no_edit_other_people_info'), HTTP_REFERER); } $posts_table_name = $this->db2->posts_table($a['catid']); $this->db2->table_name = $posts_table_name; $this->status($id, 5); $this->db2->update(array('optimal' => 1, 'solvetime' => SYS_TIME), "pid={$pid} AND askid={$id}"); $r = $this->db2->get_one("pid={$pid}", "userid,username"); $this->db->update(array('acceptcount' => '+=1'), $this->db_tablepre . "member", "userid={$r['userid']}"); if ($M['answer_bounty_credit'] || $M['return_credit']) { pc_base::load_app_class('receipts', 'pay', 0); } if ($M['answer_bounty_credit']) { $this->credit->update_credit($r['userid'], $r['username'], $M['answer_bounty_credit'], 1); receipts::point($M['answer_bounty_credit'], $r['userid'], $r['username'], $flag, 'selfincome', L('answer_bounty_credit'), $r['username']); } if ($M['return_credit']) { @extract($this->db->get_one("userid,username,ischeck", $this->table_name, "askid={$id}")); if ($ischeck) { $this->credit->update_credit($userid, $username, $M['return_credit'], 1); receipts::point($M['return_credit'], $userid, $username, $flag, 'selfincome', L('return_credit'), $username); } } if (intval($a['reward'])) { $this->credit->update_credit($r['userid'], $r['username'], intval($a['reward']), 1); receipts::point($a['reward'], $r['userid'], $r['username'], $flag, 'selfincome', L('reward_score'), $r['username']); } return true; }
/** * 处理投票 */ public function post() { $subjectid = intval($_POST['subjectid']); if (!$subjectid) { showmessage(L('vote_novote'), 'blank'); } // 判断是否已投过票,或者尚未到第二次投票期 $return = $this->check($subjectid); switch ($return) { case 0: showmessage(L('vote_voteyes'), "?app=vote&controller=index&action=result&subjectid={$subjectid}"); break; case -1: showmessage(L('vote_voteyes'), "?app=vote&controller=index&action=result&subjectid={$subjectid}"); break; } if (!is_array($_POST['radio'])) { showmessage(L('vote_nooption'), 'blank'); } $time = TIME; $data_arr = array(); foreach ($_POST['radio'] as $radio) { $data_arr[$radio] = '1'; } $new_data = array2string($data_arr); // 转成字符串存入数据库中 // 添加到数据库 $this->vote_data->insert(array('userid' => $this->userid, 'username' => $this->username, 'subjectid' => $subjectid, 'time' => $time, 'ip' => $this->ip, 'data' => $new_data)); // 查询投票奖励点数,并更新会员点数 $vote_arr = $this->vote->getby_subjectid($subjectid); Loader::lib('pay:receipts', false); receipts::point($vote_arr['credit'], $this->userid, $this->username, '', 'selfincome', L('vote_post_point')); // 更新投票人数 $this->vote->where(array('subjectid' => $subjectid))->update(array('votenumber' => '+=1')); showmessage(L('vote_votesucceed'), "?app=vote&controller=index&action=result&subjectid={$subjectid}"); }
/** * 过审内容 */ public function pass() { $admin_username = cookie('admin_username'); $catid = intval($_GET['catid']); if (!$catid) { showmessage(L('missing_part_parameters')); } $category = $this->categorys[$catid]; $setting = string2array($category['setting']); $workflowid = $setting['workflowid']; // 只有存在工作流才需要审核 if ($workflowid) { $steps = intval($_GET['steps']); // 检查当前用户有没有当前工作流的操作权限 $workflows = S('common/workflow'); $workflows = $workflows[$workflowid]; $workflows_setting = string2array($workflows['setting']); // 将有权限的级别放到新数组中 $admin_privs = array(); foreach ($workflows_setting as $_k => $_v) { if (empty($_v)) { continue; } foreach ($_v as $_value) { if ($_value == $admin_username) { $admin_privs[$_k] = $_k; } } } if ($_SESSION['roleid'] != 1 && $steps && !in_array($steps, $admin_privs)) { showmessage(L('permission_to_operate')); } // 更改内容状态 if (isset($_GET['reject'])) { // 退稿 $status = 0; } else { // 工作流审核级别 $workflow_steps = $workflows['steps']; if ($workflow_steps > $steps) { $status = $steps + 1; } else { $status = 99; } } $modelid = $this->categorys[$catid]['modelid']; $this->db->set_model($modelid); // 审核通过,检查投稿奖励或扣除积分 if ($status == 99) { $member_db = Loader::model('member_model'); foreach ($_POST['ids'] as $id) { $content_info = $this->db->where(array('id' => $id))->field('username')->find(); $memberinfo = $member_db->where(array('username' => $content_info['username']))->field('userid, username')->find(); $flag = $catid . '_' . $id; if ($setting['presentpoint'] > 0) { Loader::lib('pay:receipts', false); receipts::point($setting['presentpoint'], $memberinfo['userid'], $memberinfo['username'], $flag, 'selfincome', L('contribute_add_point'), $memberinfo['username']); } else { Loader::lib('pay:spend', false); spend::point($setting['presentpoint'], L('contribute_del_point'), $memberinfo['userid'], $memberinfo['username'], '', '', $flag); } } } if (isset($_GET['ajax_preview'])) { $_POST['ids'] = $_GET['id']; } $this->db->status($_POST['ids'], $status); } showmessage(L('operation_success'), HTTP_REFERER); }
/** * 更新评论的状态 * * @param string $commentid 评论ID * @param integer $id 内容ID * @param integer $status 状态{1:通过 ,0:未审核, -1:不通过,将做删除操作} */ public function status($commentid, $id, $status = -1) { if (!($comment = $this->comment_db->where(array('commentid' => $commentid))->field('tableid, commentid')->find())) { $this->msg_code = 6; return false; } // 为数据存储数据模型设置 数据表名。 $this->comment_data_db->table_name($comment['tableid']); if (!($comment_data = $this->comment_data_db->where(array('id' => $id, 'commentid' => $commentid))->find())) { $this->msg_code = 6; return false; } // 读取评论的站点配置信息 $site = S('common/comment'); if ($status == 1) { // 通过的时候 $sql['total'] = '+=1'; // 当评论被设置为通过的时候,更新评论总表的数量。 $this->comment_db->where(array('commentid' => $comment['commentid']))->update($sql); // 更新评论内容状态 $this->comment_data_db->where(array('id' => $id, 'commentid' => $commentid))->update(array('status' => $status)); // 当评论用户ID不为空,而且站点配置了积分添加项,支付模块也存在的时候,为用户添加积分。 if (!empty($comment_data['userid']) && !empty($site['add_point']) && app_exists('pay')) { Loader::lib('pay:receipts', false); receipts::point($site['add_point'], $comment_data['userid'], $comment_data['username'], '', 'selfincome', 'Comment'); } } elseif ($status == -1) { // 删除数据 // 如果数据原有状态为已经通过,需要删除评论总表中的总数 if ($comment_data['status'] == 1) { $sql['total'] = '-=1'; $this->comment_db->where(array('commentid' => $comment['commentid']))->update($sql); } // 删除存储表的数据 $this->comment_data_db->where(array('id' => $id, 'commentid' => $commentid))->delete(); // 删除存储表总数记录 $this->comment_table_db->edit_total($comment['tableid'], '-=1'); // 当评论ID不为空,站点配置了删除的点数,支付模块存在的时候,删除用户的点数。 if (!empty($comment_data['userid']) && !empty($site['del_point']) && app_exists('pay')) { Loader::lib('pay:receipts', false); $op_userid = cookie('userid'); $op_username = cookie('admin_username'); spend::point($site['del_point'], L('comment_point_del', '', 'comment'), $comment_data['userid'], $comment_data['username'], $op_userid, $op_username); } } // 删除审核表中的数据 $this->comment_check_db->where(array('comment_data_id' => $id))->delete(); $this->msg_code = 0; return true; }