Esempio n. 1
0
 public function init()
 {
     $allow_visitor = htmlspecialchars($_GET['allow_visitor']);
     $auth = sys_auth($allow_visitor, 'DECODE');
     if (strpos($auth, '|') === false) {
         showmessage(L('illegal_operation'));
     }
     $auth_str = explode('|', $auth);
     $flag = $auth_str[0];
     if (!preg_match('/^([0-9]+)|([0-9]+)/', $flag)) {
         showmessage(L('illegal_operation'));
     }
     $readpoint = intval($auth_str[1]);
     $paytype = intval($auth_str[2]);
     $http_referer = urldecode($_GET['http_referer']);
     if (!$readpoint) {
         showmessage(L('illegal_operation'));
     }
     pc_base::load_app_class('spend', 'pay', 0);
     $flag_arr = explode('_', $flag);
     $catid = $flag_arr[0];
     $siteids = getcache('category_content', 'commons');
     $siteid = $siteids[$catid];
     $CATEGORYS = getcache('category_content_' . $siteid, 'commons');
     if (isset($CATEGORYS[$catid])) {
         $setting = string2array($CATEGORYS[$catid]['setting']);
         $repeatchargedays = intval($setting['repeatchargedays']);
         if ($repeatchargedays) {
             $fromtime = SYS_TIME - 86400 * $repeatchargedays;
             $r = spend::spend_time($this->userid, $fromtime, $flag);
             if ($r) {
                 showmessage(L('have_pay'), $http_referer, 1000);
             }
         }
     }
     if ($paytype) {
         if (spend::amount($readpoint, L('msg_readpoint'), $this->userid, $this->username, '', '', $flag) == false) {
             $msg = spend::get_msg();
             $http_referer = APP_PATH . 'index.php?m=pay&c=deposit&a=pay';
         } else {
             $msg = L('readpoint_pay', array('readpoint' => $readpoint));
         }
     } else {
         if (spend::point($readpoint, L('msg_readpoint'), $this->userid, $this->username, '', '', $flag) == false) {
             $msg = spend::get_msg();
             $http_referer = APP_PATH . 'index.php?m=pay&c=deposit&a=pay';
         } else {
             $msg = L('readpoint_pay_point', array('readpoint' => $readpoint));
         }
     }
     showmessage($msg, $http_referer, 3000);
 }
Esempio n. 2
0
 /**
  * 更新评论的状态
  * @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;
 }
Esempio n. 3
0
 /**
  * 更新评论的状态
  * @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;
 }
Esempio n. 4
0
 function info_top_cost()
 {
     $amount = $msg = '';
     $memberinfo = $this->memberinfo;
     $_username = $this->memberinfo['username'];
     $_userid = $this->memberinfo['userid'];
     $infos = getcache('info_setting', 'commons');
     $toptype_arr = array(1, 2, 3);
     //置顶积分数组
     $toptype_price = array('1' => $infos['top_city'], '2' => $infos['top_zone'], '3' => $infos['top_district']);
     //置顶推荐位数组
     $toptype_posid = array('1' => $infos['top_city_posid'], '2' => $infos['top_zone_posid'], '3' => $infos['top_district_posid']);
     if (isset($_POST['dosubmit'])) {
         $posids = array();
         $push_api = pc_base::load_app_class('push_api', 'admin');
         $pos_data = pc_base::load_model('position_data_model');
         $catid = intval($_POST['catid']);
         $id = intval($_POST['id']);
         $flag = $catid . '_' . $id;
         $toptime = intval($_POST['toptime']);
         if ($toptime == 0 || empty($_POST['toptype'])) {
             showmessage(L('info_top_not_setting_toptime'));
         }
         //计算置顶扣费积分,时间
         if (is_array($_POST['toptype']) && !empty($_POST['toptype'])) {
             foreach ($_POST['toptype'] as $r) {
                 if (is_numeric($r) && in_array($r, $toptype_arr)) {
                     $posids[] = $toptype_posid[$r];
                     $amount += $toptype_price[$r];
                     $msg .= $r . '-';
                 }
             }
         }
         //应付总积分
         $amount = $amount * $toptime;
         //扣除置顶点数
         pc_base::load_app_class('spend', 'pay', 0);
         $pay_status = spend::point($amount, L('info_top') . $msg, $_userid, $_username, '', '', $flag);
         if ($pay_status == false) {
             $msg = spend::get_msg();
             showmessage($msg);
         }
         //置顶过期时间
         //TODO
         $expiration = SYS_TIME + $toptime * 3600;
         //获取置顶文章信息内容
         if (isset($catid) && $catid) {
             $siteids = getcache('category_content', 'commons');
             $siteid = $siteids[$catid];
             $CATEGORYS = getcache('category_content_' . $siteid, 'commons');
             $category = $CATEGORYS[$catid];
             if ($category['type'] == 0) {
                 $modelid = $category['modelid'];
                 $this->model = getcache('model', 'commons');
                 $this->content_db = pc_base::load_model('content_model');
                 $this->content_db->set_model($modelid);
                 $this->content_db->table_name = $this->content_db->db_tablepre . $this->model[$modelid]['tablename'];
                 $r = $this->content_db->get_one(array('id' => $id, 'username' => $_username, 'sysadd' => 0));
             }
         }
         if (!$r) {
             showmessage(L('illegal_operation'));
         }
         $push_api->position_update($id, $modelid, $catid, $posids, $r, $expiration, 1);
         $refer = $_POST['msg'] ? $r['url'] : '';
         if ($_POST['msg']) {
             showmessage(L('ding_success'), $refer);
         } else {
             showmessage(L('ding_success'), '', '', 'top');
         }
     } else {
         $toptype = trim($_POST['toptype']);
         $toptime = trim($_POST['toptime']);
         $types = explode('_', $toptype);
         if (is_array($types) && !empty($types)) {
             foreach ($types as $r) {
                 if (is_numeric($r) && in_array($r, $toptype_arr)) {
                     $amount += $toptype_price[$r];
                 }
             }
         }
         $amount = $amount * $toptime;
         echo $amount;
     }
 }
Esempio n. 5
0
 /**
  * 过审内容
  */
 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);
 }
Esempio n. 6
0
 /**
  * 过审内容
  */
 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);
 }
Esempio n. 7
0
 public function show()
 {
     pc_base::load_sys_class('form', '', 0);
     $M = getcache('ask', 'commons');
     $M = $M[1];
     $_username = param::get_cookie('_username', L('phpcms_friends'));
     $_userid = param::get_cookie('_userid');
     $r_m = $this->db_m->get_one(array('userid' => $_userid, 'siteid' => SITEID));
     $_point = $r_m['point'];
     $id = intval($_GET['id']);
     if (!$id) {
         showmessage(L('illegal_parameters'), HTTP_REFERER);
     }
     $array = array();
     $a = $this->db->get_one(array('askid' => $id, 'siteid' => SITEID));
     $posts_table_name = $this->db2->posts_table($a['catid']);
     $this->db2->table_name = $posts_table_name;
     if (!$this->db2->table_exists(str_replace($this->db2->db_tablepre, '', $posts_table_name))) {
         showmessage(L('info_does_not_exists'), HTTP_REFERER);
     }
     $result = $this->db2->select("askid={$id} AND status>2 AND siteid=" . SITEID, '*');
     foreach ($result as $r) {
         if ($r['isask']) {
             $arr = $this->db->get_one(array('askid' => $id, 'siteid' => SITEID));
             $r['title'] = $arr['title'];
             $r['reward'] = $arr['reward'];
             $r['status'] = $arr['status'];
             $r['answercount'] = $arr['answercount'];
             $r['flag'] = $arr['flag'];
             $r['endtime'] = $arr['endtime'];
             $r['catid'] = $arr['catid'];
             $r['hits'] = $arr['hits'];
             $r['anonymity'] = $arr['anonymity'];
             $rs['keywords'] = $arr['keywords'];
             $r['keywords'] = explode(' ', $arr['keywords']);
             if (SYS_TIME > $r['endtime'] && !$arr['ischeck']) {
                 $this->db->update(array('ischeck' => '1'), array('askid' => $id));
                 $this->db->update(array('flag' => '3'), 'askid=' . $id . ' AND answercount>1');
                 $this->db2->update(array('candidate' => '1'), array('askid' => $id));
                 $this->db_credit->update($arr['userid'], $arr['username'], $M['del_day15_credit'], 0);
                 pc_base::load_app_class('spend', 'pay', 0);
                 spend::point($M['del_day15_credit'], L('ask_15days_no_deal_with'), $arr['userid'], $arr['username'], '', '', $flag);
             }
         }
         $userids[] = $r['userid'];
         $array[] = $r;
     }
     if ($userids) {
         $userids = implode(',', $userids);
         $data = $this->db_m->select("userid IN ({$userids}) AND siteid=" . SITEID, '*');
         foreach ($data as $r) {
             $userinfo[$r['userid']]['actortype'] = $r['actortype'];
             $userinfo[$r['userid']]['point'] = $r['point'];
         }
         foreach ($array as $arr) {
             $arr['actortype'] = $userinfo[$arr['userid']]['actortype'];
             $arr['point'] = $userinfo[$arr['userid']]['point'];
             $_array[] = $arr;
         }
         $array = $_array;
     } else {
         $array = $array;
     }
     if ($array) {
         $have_answer = false;
         foreach ($array as $k => $v) {
             if ($v['isask']) {
                 $title = $v['title'];
                 $message = $this->M[1]['use_editor'] ? $v['message'] : trim_textarea($v['message']);
                 $reward = $v['reward'];
                 $userid = $v['userid'];
                 $username = $v['username'];
                 $nickname = get_nickname($v['userid']);
                 $status = $v['status'];
                 $hits = $v['hits'];
                 $flag = $v['flag'];
                 $addtime = $v['addtime'];
                 $actor = actor($v['actortype'], $v['point']);
                 $answercount = $v['answercount'];
                 $result = count_down($v['endtime']);
                 $day = $result[0];
                 $hour = $result[1];
                 $minute = $result[2];
                 $catid = $v['catid'];
                 $anonymity = $v['anonymity'];
                 $keywords = $v['keywords'];
             } elseif ($v['optimal']) {
                 $best_answer_pid = $v['pid'];
                 $best_answer_vote_1 = $v['best_answer_vote_1'];
                 $best_answer_vote_2 = $v['best_answer_vote_2'];
                 $totalnum = $best_answer_vote_1 + $best_answer_vote_2;
                 $best_answer_vote_1_per = round($best_answer_vote_1 / $totalnum * 100, 1) . "%";
                 $best_answer_vote_2_per = round($best_answer_vote_2 / $totalnum * 100, 1) . "%";
                 $solvetime = $v['solvetime'];
                 $answer = $v['message'];
                 $answertime = $v['addtime'];
                 $answer = trim_textarea($v['message']);
                 $optimail_username = $v['username'];
                 $optimail_userid = $v['userid'];
                 $optimail_nickname = get_nickname($v['userid']);
                 $optimal_actor = actor($v['actortype'], $v['point']);
             } else {
                 if ($v['userid'] == $_userid) {
                     $have_answer = true;
                 }
                 $infos[$k]['pid'] = $v['pid'];
                 $infos[$k]['userid'] = $v['userid'];
                 $infos[$k]['username'] = $v['username'];
                 $infos[$k]['nickname'] = get_nickname($v['userid']);
                 $infos[$k]['addtime'] = $v['addtime'];
                 $infos[$k]['candidate'] = $v['candidate'];
                 $infos[$k]['anonymity'] = $v['anonymity'];
                 $infos[$k]['actor'] = actor($v['actortype'], $v['point']);
                 $infos[$k]['message'] = $this->M[1]['use_editor'] ? $v['message'] : trim_textarea($v['message']);
             }
         }
         if ($v['optimal']) {
             $answercount = $answercount - 1;
         }
         if ($userid == $_userid) {
             $isask = 1;
         } else {
             $isask = 0;
         }
         if (isset($action) && $action == 'vote') {
             if ($flag == 1) {
                 exit;
             }
             $tpl = 'vote';
         } else {
             $tpl = 'show';
         }
         if ($status == 1) {
             showmessage(L('info_does_not_exists'), HTTP_REFERER);
         }
         if ($userid != $_userid) {
             $this->db->update(array('hits' => '+=1'), array('askid' => $id));
         }
         $description = $answer ? str_cut($answer, '200') : str_cut($message, '200');
         $SEO = seo(SITEID, $catid, $title, $description, $seo_keywords);
         include template('ask', $tpl);
     } else {
         showmessage(L('info_does_not_exists'), HTTP_REFERER);
     }
 }
Esempio n. 8
0
 function addscore($id, $point = 0)
 {
     $M = getcache('ask', 'commons');
     $M = $M[1];
     $_username = param::get_cookie('_username');
     $_userid = param::get_cookie('_userid');
     $r_m = $this->db->get_one("point", $this->db_tablepre . "member", "userid='{$_userid}'");
     if (!$r_m) {
         return false;
     }
     $_point = $r_m['point'];
     if ($point > $_point) {
         return false;
     }
     $id = intval($id);
     $point = intval($point);
     $r = $this->db->get_one("userid,username", $this->table_name, "askid='{$id}'");
     if ($r['userid'] != $_userid) {
         showmessage(L('no_edit_other_people_info'), HTTP_REFERER);
     }
     $this->db->update("reward=reward+{$point},endtime=endtime+432000", $this->table_name, "askid='{$id}' AND userid={$_userid}");
     $this->db->update("flag=2", $this->table_name, "askid={$id} AND flag=0 AND reward >= {$M['height_score']}");
     $this->credit->update_credit($_userid, $_username, $point, 0);
     pc_base::load_app_class('spend', 'pay', 0);
     spend::point($point, L('enhances_credit'), $_userid, $_username, '', '', $flag);
     return true;
 }
Esempio n. 9
0
	public function del() {
		if (isset($_GET['dosubmit']) && $_GET['dosubmit']) {
			$ids = $_GET['ids'];
			$tableid = isset($_GET['tableid']) ? intval($_GET['tableid']) : 0;
			$r = $this->comment_db->get_one(array(), 'MAX(tableid) AS tableid');
			$max_table = $r['tableid'];
			if (!$tableid || $max_table<$tableid) showmessage(L('illegal_operation'));
			$this->comment_data_db->table_name($tableid);
			$site = $this->comment_setting_db->site($this->siteid);
			if (is_array($ids)) {
				foreach ($ids as $id) {
					$comment_info = $this->comment_data_db->get_one(array('id'=>$id), 'commentid, userid, username');
					$this->comment_db->update(array('total'=>'-=1'), array('commentid'=>$comment_info['commentid']));
					$this->comment_data_db->delete(array('id'=>$id));

					//当评论ID不为空,站点配置了删除的点数,支付模块存在的时候,删除用户的点数。
					if (!empty($comment_info['userid']) && !empty($site['del_point']) && module_exists('pay')) {
						pc_base::load_app_class('receipts', '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_info['userid'], $comment_info['username'], $op_userid, $op_username);
					}
				}
				$ids = implode(',', $ids);
			} elseif (is_numeric($ids)) {
				$id = intval($ids);
				$comment_info = $this->comment_data_db->get_one(array('id'=>$id), 'commentid, userid, username');
				$this->comment_db->update(array('total'=>'-=1'), array('commentid'=>$comment_info['commentid']));
				$this->comment_data_db->delete(array('id'=>$id));

				//当评论ID不为空,站点配置了删除的点数,支付模块存在的时候,删除用户的点数。
				if (!empty($comment_info['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_info['userid'], $comment_info['username'], $op_userid, $op_username);
				}
			} else {
				showmessage(L('illegal_operation'));
			}
			showmessage(L('operation_success'), HTTP_REFERER);
		}
	}
Esempio n. 10
0
 /**
  * 过审内容
  */
 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);
 }
Esempio n. 11
0
 /**
  * 更新评论的状态
  *
  * @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;
 }