public function index() { $root = array(); $email = addslashes($GLOBALS['request']['email']); //用户名或邮箱 $pwd = addslashes($GLOBALS['request']['pwd']); //密码 //检查用户,用户密码 $user = user_check($email, $pwd); $user_id = intval($user['id']); if ($user_id == 0) { $root['user_login_status'] = 0; //用户登陆状态:1:成功登陆;0:未成功登陆 output($root); } else { $root['user_login_status'] = 1; } $yh_id = intval($GLOBALS['request']['yh_id']); $content = addslashes($GLOBALS['request']['content']); //$merchant_id = intval($GLOBALS['db']->getOne("select supplier_location_id from ".DB_PREFIX."youhui where id='".$yh_id."'")); $merchant_youhui_comment = array('user_id' => $user_id, 'rel_id' => $yh_id, 'rel_table' => 'youhui', 'title' => $content, 'content' => $content, 'is_effect' => 1, 'create_time' => get_gmtime()); $GLOBALS['db']->autoExecute(DB_PREFIX . "message", $merchant_youhui_comment, 'INSERT'); $id = $GLOBALS['db']->insert_id(); $root['id'] = $id; if ($id > 0) { increase_user_active($user_id, "点评了一个优惠券"); $root['status'] = 1; $root['info'] = "添加成功"; } else { $root['status'] = 0; $root['info'] = "添加失败"; } output($root); }
public function index() { require_once APP_ROOT_PATH . "system/libs/user.php"; $root = array(); $share_id = intval($GLOBALS['request']['share_id']); //没有分享ID直接退出 if ($share_id == 0) { $root['status'] = -2; output($root); } $content = strim($GLOBALS['request']['content']); $source = strim($GLOBALS['request']['source']); $source = str_replace("来自", "", $source); $email = strim($GLOBALS['request']['email']); $pwd = strim($GLOBALS['request']['pwd']); $is_relay = intval($GLOBALS['request']['is_relay']); $parent_id = intval($GLOBALS['request']['parent_id']); if ($parent_id > 0) { $parent_reply = $GLOBALS['db']->getRow("select id,user_id,user_name from " . DB_PREFIX . "topic_reply where id = " . $parent_id); } $result = do_login_user($email, $pwd); $GLOBALS['user_info'] = $user_data = es_session::get('user_info'); $user_data['id'] = intval($user_data['id']); if (intval($user_data['id']) == 0) { $root['return'] = 0; $root['user_login_status'] = 0; $root['info'] = "请先登录"; output($root); } $root['user_login_status'] = 1; $topic = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "topic where is_effect = 1 and is_delete = 0 and id = " . $share_id); if (empty($topic)) { $root['status'] = -3; output($root); } $reply_data = array(); $reply_data['topic_id'] = $share_id; $reply_data['user_id'] = intval($user_data['id']); $reply_data['user_name'] = $user_data['user_name']; $reply_data['reply_id'] = intval($parent_reply['id']); $reply_data['reply_user_id'] = intval($parent_reply['user_id']); $reply_data['reply_user_name'] = strim($parent_reply['user_name']); $reply_data['create_time'] = get_gmtime(); $reply_data['is_effect'] = 1; $reply_data['is_delete'] = 0; $reply_data['content'] = valid_str($content); $GLOBALS['db']->autoExecute(DB_PREFIX . "topic_reply", $reply_data); $GLOBALS['db']->query("update " . DB_PREFIX . "topic set reply_count = reply_count + 1,last_time = " . get_gmtime() . ",last_user_id=" . $user_data['id'] . " where id = " . $share_id); increase_user_active($user_data['id'], "转发了一则分享"); if ($is_relay == 1) { $cnt = $topic['content'] . "@" . $user_data['user_name'] . " 评论:" . valid_str($content); $id = insert_topic($cnt, $title = "", $type = "", $group = "", $relay_id = $share_id, $fav_id = 0); if ($id) { $GLOBALS['db']->query("update " . DB_PREFIX . "topic set source_name = '" . $source . "' where id = " . intval($id)); } } $root['return'] = 1; $root['status'] = 1; output($root); }
public function index() { require_once APP_ROOT_PATH . "system/libs/user.php"; $root = array(); $event_id = intval($GLOBALS['request']['event_id']); //没有分享ID直接退出 if ($event_id == 0) { $root['status'] = 0; $root['info'] = "不存在的活动ID"; output($root); } $content = strim($GLOBALS['request']['content']); $source = strim($GLOBALS['request']['source']); $source = str_replace("来自", "", $source); $email = strim($GLOBALS['request']['email']); $pwd = strim($GLOBALS['request']['pwd']); $result = do_login_user($email, $pwd); $GLOBALS['user_info'] = $user_data = es_session::get('user_info'); $user_data['id'] = intval($user_data['id']); if (intval($user_data['id']) == 0) { $root['status'] = 0; $root['user_login_status'] = 0; $root['info'] = "请先登录"; output($root); } $root['user_login_status'] = 1; $event_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "event where is_effect = 1 and id = " . $event_id); if (empty($event_info)) { $root['status'] = 0; $root['info'] = "不存在的活动ID"; output($root); } $reply_data = array(); $reply_data['rel_table'] = "event"; $reply_data['rel_id'] = intval($event_id); $reply_data['content'] = valid_str($content); if (app_conf("USER_MESSAGE_AUTO_EFFECT") == 0) { $message_effect = 0; } else { $message_effect = 1; //$message_type['is_effect']; } $reply_data['is_effect'] = $message_effect; $reply_data['create_time'] = get_gmtime(); $reply_data['user_id'] = intval($user_data['id']); $GLOBALS['db']->autoExecute(DB_PREFIX . "message", $reply_data); increase_user_active($user_data['id'], "点评了一个活动"); $title = "对" . $event_info['name'] . "发表了点评"; $url_route = array('rel_app_index' => 'youhui', 'rel_route' => 'edetail', 'rel_param' => 'id=' . $event_info['id']); $tid = insert_topic($reply_data['content'], $title, "eventcomment", $group = "", $relay_id = 0, $fav_id = 0, $group_data = "", $attach_list = array(), $url_route); if ($tid) { $GLOBALS['db']->query("update " . DB_PREFIX . "topic set source_name = '" . $source . "' where id = " . intval($tid)); } $GLOBALS['db']->query("update " . DB_PREFIX . "event set reply_count = reply_count+1 where id =" . $event_id); $root['status'] = 1; $root['info'] = "感谢您的点评"; output($root); }
public function add() { global $user_info; $ajax = intval($_REQUEST['ajax']); if (!$user_info) { showErr($GLOBALS['lang']['PLEASE_LOGIN_FIRST'], $ajax); } if ($_REQUEST['content'] == '') { showErr($GLOBALS['lang']['MESSAGE_CONTENT_EMPTY'], $ajax); } if (!check_ipop_limit(get_client_ip(), "message", intval(app_conf("SUBMIT_DELAY")), 0)) { showErr($GLOBALS['lang']['MESSAGE_SUBMIT_FAST'], $ajax); } $rel_table = addslashes(trim($_REQUEST['rel_table'])); $message_type = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "message_type where type_name='" . $rel_table . "' and type_name <> 'supplier'"); if (!$message_type) { showErr($GLOBALS['lang']['INVALID_MESSAGE_TYPE'], $ajax); } $message_group = addslashes(trim($_REQUEST['message_group'])); //添加留言 $message['title'] = $_REQUEST['title'] ? htmlspecialchars(addslashes(valid_str($_REQUEST['title']))) : htmlspecialchars(addslashes(valid_str($_REQUEST['content']))); $message['content'] = htmlspecialchars(addslashes(valid_str($_REQUEST['content']))); $message['title'] = valid_str($message['title']); if ($message_group) { $message['title'] = "[" . $message_group . "]:" . $message['title']; $message['content'] = "[" . $message_group . "]:" . $message['content']; } $message['create_time'] = get_gmtime(); $message['rel_table'] = $rel_table; $rel_id = $message['rel_id'] = addslashes(trim($_REQUEST['rel_id'])); $message['user_id'] = intval($GLOBALS['user_info']['id']); if (intval($_REQUEST['city_id']) == 0) { $message['city_id'] = $GLOBALS['deal_city']['id']; } else { $message['city_id'] = intval($_REQUEST['city_id']); } if (app_conf("USER_MESSAGE_AUTO_EFFECT") == 0) { $message_effect = 0; } else { $message_effect = $message_type['is_effect']; } $message['is_effect'] = $message_effect; $message['is_buy'] = intval($_REQUEST['is_buy']); $message['contact'] = $_REQUEST['contact'] ? htmlspecialchars(addslashes($_REQUEST['contact'])) : ''; $message['contact_name'] = $_REQUEST['contact_name'] ? htmlspecialchars(addslashes($_REQUEST['contact_name'])) : ''; if ($message['is_buy'] == 1) { if ($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_order_item as doi left join " . DB_PREFIX . "deal_order as do on doi.order_id = do.id where doi.deal_id = " . intval($message['rel_id']) . " and do.user_id = " . intval($message['user_id']) . " and do.pay_status = 2") == 0) { showErr($GLOBALS['lang']['AFTER_BUY_MESSAGE_TIP'], $ajax); } } $message['point'] = intval($_REQUEST['point']); $GLOBALS['db']->autoExecute(DB_PREFIX . "message", $message); $message_id = intval($GLOBALS['db']->insert_id()); if ($message['is_buy'] == 1) { $message_id = $GLOBALS['db']->insert_id(); $attach_list = get_topic_attach_list(); $deal_info = $GLOBALS['db']->getRow("select id,is_shop,name,sub_name from " . DB_PREFIX . "deal where id = " . $rel_id); if ($deal_info['is_shop'] == 0) { $url_route = array('rel_app_index' => 'tuan', 'rel_route' => 'deal', 'rel_param' => 'id=' . $deal_info['id']); $type = "tuancomment"; $locations = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_location_link where deal_id = " . $deal_info['id']); $dp_title = "对" . $deal_info['sub_name'] . "的消费点评"; foreach ($locations as $location) { insert_dp($dp_title, $message['content'], $location['location_id'], $message['point'], $is_buy = 1, $from = "tuan", $url_route, $message_id); } } if ($deal_info['is_shop'] == 1) { $url_route = array('rel_app_index' => 'shop', 'rel_route' => 'goods', 'rel_param' => 'id=' . $deal_info['id']); $type = "shopcomment"; } if ($deal_info['is_shop'] == 2) { $url_route = array('rel_app_index' => 'youhui', 'rel_route' => 'ydetail', 'rel_param' => 'id=' . $deal_info['id']); $type = "youhuicomment"; } increase_user_active(intval($GLOBALS['user_info']['id']), "点评了一个团购"); $title = "对" . $deal_info['sub_name'] . "发表了点评"; $tid = insert_topic($message['content'], $title, $type, "share", $relay_id = 0, $fav_id = 0, $group_data = "", $attach_list = array(), $url_route); if ($tid) { $GLOBALS['db']->query("update " . DB_PREFIX . "topic set source_name = '网站' where id = " . intval($tid)); } } showSuccess($GLOBALS['lang']['MESSAGE_POST_SUCCESS'], $ajax); }
public function do_fav_topic() { if (intval($GLOBALS['user_info']['id']) == 0) { $result['status'] = 0; $result['info'] = $GLOBALS['lang']['PLEASE_LOGIN_FIRST']; } else { $id = intval($_REQUEST['id']); $topic = $GLOBALS['db']->getRow("select id,user_id from " . DB_PREFIX . "topic where id = " . $id); if (!$topic) { $result['status'] = 0; $result['info'] = $GLOBALS['lang']['TOPIC_NOT_EXIST']; } else { if ($topic['user_id'] == intval($GLOBALS['user_info']['id'])) { $result['status'] = 0; $result['info'] = $GLOBALS['lang']['TOPIC_SELF']; } else { $count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "topic where (fav_id = " . $id . " or (origin_id = " . $id . " and fav_id <> 0)) and user_id = " . intval($GLOBALS['user_info']['id'])); if ($count > 0) { $result['status'] = 0; $result['info'] = $GLOBALS['lang']['TOPIC_FAVED']; } else { $result['status'] = 1; $tid = insert_topic($content, $title = "", $type = "", $group = "", $relay_id = 0, $id); if ($tid) { increase_user_active(intval($GLOBALS['user_info']['id']), "喜欢了一则分享"); $GLOBALS['db']->query("update " . DB_PREFIX . "topic set source_name = '网站' where id = " . intval($tid)); } $result['info'] = $GLOBALS['lang']['FAV_SUCCESS']; } } } } ajax_return($result); }
public function add() { $ajax = intval($_REQUEST['ajax']); if (!$GLOBALS['user_info']) { showErr($GLOBALS['lang']['PLEASE_LOGIN_FIRST'], $ajax); } if ($_REQUEST['content'] == '') { showErr($GLOBALS['lang']['MESSAGE_CONTENT_EMPTY'], $ajax); } //验证码 if (app_conf("VERIFY_IMAGE") == 1) { $verify = md5(trim($_REQUEST['verify'])); $session_verify = es_session::get('verify'); if ($verify != $session_verify) { showErr($GLOBALS['lang']['VERIFY_CODE_ERROR'], $ajax); } } es_session::delete("verify"); if (!check_ipop_limit(get_client_ip(), "message", intval(app_conf("SUBMIT_DELAY")), 0)) { showErr($GLOBALS['lang']['MESSAGE_SUBMIT_FAST'], $ajax); } $rel_table = $_REQUEST['rel_table']; // $message_type = $GLOBALS['db']->getRow("select * from ".DB_PREFIX."message_type where type_name='".$rel_table."' and type_name <> 'supplier'"); // if(!$message_type) // { // showErr($GLOBALS['lang']['INVALID_MESSAGE_TYPE'],$ajax); // } $message_group = $_REQUEST['message_group']; //添加留言 $message['title'] = $_REQUEST['title'] ? htmlspecialchars(addslashes(valid_str($_REQUEST['title']))) : htmlspecialchars(addslashes(valid_str($_REQUEST['content']))); $message['content'] = htmlspecialchars(addslashes(valid_str($_REQUEST['content']))); $message['title'] = valid_str($message['title']); if ($message_group) { $message['title'] = "[" . $message_group . "]:" . $message['title']; $message['content'] = "[" . $message_group . "]:" . $message['content']; } $message['create_time'] = get_gmtime(); $message['rel_table'] = $rel_table; $rel_id = $message['rel_id'] = intval($_REQUEST['rel_id']); $message['user_id'] = intval($GLOBALS['user_info']['id']); if (isset($_REQUEST['is_effect'])) { $message_effect = intval($_REQUEST['is_effect']); } else { if (app_conf("USER_MESSAGE_AUTO_EFFECT") == 0) { $message_effect = 0; } else { $message_effect = $message_type['is_effect']; } } $message['is_effect'] = $message_effect; $message['is_buy'] = intval($_REQUEST['is_buy']); $message['contact'] = $_REQUEST['contact'] ? htmlspecialchars(addslashes($_REQUEST['contact'])) : ''; $message['contact_name'] = $_REQUEST['contact_name'] ? htmlspecialchars(addslashes($_REQUEST['contact_name'])) : ''; if ($message['is_buy'] == 1) { if ($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_order_item as doi left join " . DB_PREFIX . "deal_order as do on doi.order_id = do.id where doi.deal_id = " . intval($message['rel_id']) . " and do.user_id = " . intval($message['user_id']) . " and do.pay_status = 2") == 0) { showErr($GLOBALS['lang']['AFTER_BUY_MESSAGE_TIP'], $ajax); } } $message['point'] = intval($_REQUEST['point']); $GLOBALS['db']->autoExecute(DB_PREFIX . "message", $message); $message_id = $GLOBALS['db']->insert_id(); if ($message['is_buy'] == 1) { $deal_info = $GLOBALS['db']->getRow("select id,is_shop,name,sub_name from " . DB_PREFIX . "deal where id = " . $rel_id); if ($deal_info) { $attach_list = get_topic_attach_list(); if ($deal_info['is_shop'] == 0) { $url_route = array('rel_app_index' => 'tuan', 'rel_route' => 'deal', 'rel_param' => 'id=' . $deal_info['id']); $type = "tuancomment"; $locations = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_location_link where deal_id = " . intval($deal_info['id'])); $dp_title = "对" . $deal_info['sub_name'] . "的消费点评"; foreach ($locations as $location) { insert_dp($dp_title, $message['content'], $location['location_id'], $message['point'], $is_buy = 1, $from = "tuan", $url_route, $message_id); } } if ($deal_info['is_shop'] == 1) { $url_route = array('rel_app_index' => 'shop', 'rel_route' => 'goods', 'rel_param' => 'id=' . $deal_info['id']); $type = "shopcomment"; $locations = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_location_link where deal_id = " . intval($deal_info['id'])); $dp_title = "对" . $deal_info['sub_name'] . "的消费点评"; foreach ($locations as $location) { insert_dp($dp_title, $message['content'], $location['location_id'], $message['point'], $is_buy = 1, $from = "shop", $url_route, $message_id); } } if ($deal_info['is_shop'] == 2) { $url_route = array('rel_app_index' => 'youhui', 'rel_route' => 'ydetail', 'rel_param' => 'id=' . $deal_info['id']); $type = "youhuicomment"; $locations = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_location_link where deal_id = " . intval($deal_info['id'])); $dp_title = "对" . $deal_info['sub_name'] . "的消费点评"; foreach ($locations as $location) { insert_dp($dp_title, $message['content'], $location['location_id'], $message['point'], $is_buy = 1, $from = "daijin", $url_route, $message_id); } } increase_user_active(intval($GLOBALS['user_info']['id']), "点评了一个商品"); $title = "对" . $deal_info['sub_name'] . "发表了点评"; $tid = insert_topic($message['content'], $title, $type, $group = "", $relay_id = 0, $fav_id = 0, $group_data = "", $attach_list = array(), $url_route); if ($tid) { $GLOBALS['db']->query("update " . DB_PREFIX . "topic set source_name = '网站' where id = " . intval($tid)); } } } if ($message['rel_table'] == 'youhui') { $youhui_info = $GLOBALS['db']->getRow("select name,id from " . DB_PREFIX . "youhui where id = " . $rel_id); if ($youhui_info) { increase_user_active(intval($GLOBALS['user_info']['id']), "点评了一个优惠券"); $title = "对" . $youhui_info['name'] . "发表了点评"; $url_route = array('rel_app_index' => 'youhui', 'rel_route' => 'fdetail', 'rel_param' => 'id=' . $youhui_info['id']); $tid = insert_topic($message['content'], $title, "fyouhuicomment", $group = "", $relay_id = 0, $fav_id = 0, $group_data = "", $attach_list = array(), $url_route); if ($tid) { $GLOBALS['db']->query("update " . DB_PREFIX . "topic set source_name = '网站' where id = " . intval($tid)); } $locations = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "youhui_location_link where youhui_id = " . intval($youhui_info['id'])); $dp_title = "对" . $youhui_info['name'] . "的点评"; foreach ($locations as $location) { insert_dp($dp_title, $message['content'], $location['location_id'], 3, $is_buy = 0, $from = "youhui", $url_route, $message_id); } } } if ($message['rel_table'] == 'event') { $event_info = $GLOBALS['db']->getRow("select name,id from " . DB_PREFIX . "event where id = " . $rel_id); if ($event_info) { increase_user_active(intval($GLOBALS['user_info']['id']), "点评了一个活动"); $title = "对" . $event_info['name'] . "发表了点评"; $url_route = array('rel_app_index' => 'youhui', 'rel_route' => 'edetail', 'rel_param' => 'id=' . $event_info['id']); $tid = insert_topic($message['content'], $title, "eventcomment", $group = "", $relay_id = 0, $fav_id = 0, $group_data = "", $attach_list = array(), $url_route); if ($tid) { $GLOBALS['db']->query("update " . DB_PREFIX . "topic set source_name = '网站' where id = " . intval($tid)); } $GLOBALS['db']->query("update " . DB_PREFIX . "event set reply_count = reply_count+1 where id =" . $rel_id); $locations = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "event_location_link where event_id = " . intval($event_info['id'])); $dp_title = "对" . $event_info['name'] . "的点评"; foreach ($locations as $location) { insert_dp($dp_title, $message['content'], $location['location_id'], 3, $is_buy = 0, $from = "event", $url_route, $message_id); } } } if ($message['rel_table'] == 'supplier_location') { $supplier_info = $GLOBALS['db']->getRow("select name,id from " . DB_PREFIX . "supplier_location where id = " . $rel_id); if ($supplier_info) { increase_user_active(intval($GLOBALS['user_info']['id']), "点评了一家商户"); $title = "对" . $supplier_info['name'] . "发表了点评"; $url_route = array('rel_app_index' => 'youhui', 'rel_route' => 'store#view', 'rel_param' => 'id=' . $supplier_info['id']); $tid = insert_topic($message['content'], $title, "slocationcomment", $group = "", $relay_id = 0, $fav_id = 0, $group_data = "", $attach_list = array(), $url_route); if ($tid) { $GLOBALS['db']->query("update " . DB_PREFIX . "topic set source_name = '网站' where id = " . intval($tid)); } } } //开始处理为deal时的计分 if ($rel_table == 'deal') { $total_point = $GLOBALS['db']->getOne("select sum(point) from " . DB_PREFIX . "message where rel_table = 'deal' and rel_id = " . intval($_REQUEST['rel_id'])); $total_comment = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "message where rel_table = 'deal' and rel_id = " . intval($_REQUEST['rel_id'])); $avg_point = round($total_point / $total_comment); $GLOBALS['db']->query("update " . DB_PREFIX . "deal set total_point = " . $total_point . ",avg_point = " . $avg_point . " where id =" . intval($_REQUEST['rel_id'])); } showSuccess($GLOBALS['lang']['MESSAGE_POST_SUCCESS'], $ajax); }
/** * 提交保存点评 * @param unknown_type $user_id 提交点评的会员 * @param unknown_type $param 参数 详细规则见 check_dp_status函数说明 * @param unknown_type $content 点评文字内容 * @param unknown_type $dp_point 总评分 * @param unknown_type $dp_image 点评的图片数组 array("./public/...","./public/....."); * @param unknown_type $tag_group 点评标签(二维数组),格式如下 * array( * "group_id" = array("tag","tag") * ); 其中group_id为分组的ID,第二维为每个分组中的tag * @param unknown_type $point_group 点评评分分组数据,格式如下 * array( * "group_id" => "point" * ); 其中group_id为分组的ID,point为对应分组的评分 * * 返回 array("status"=>bool, "info"=>"消息","location_id"=>"门店的ID","deal_id"=>"","youhui_id"=>"","event_id"=>""); */ function save_review($user_id, $param = array("deal_id" => 0, "youhui_id" => 0, "event_id" => 0, "location_id" => 0, "order_item_id" => 0, "youhui_log_id" => 0, "event_submit_id" => 0), $content, $dp_point, $dp_image = array(), $tag_group = array(), $point_group = array()) { //获取参数 $order_item_id = intval($param['order_item_id']); //订单商品ID $youhui_log_id = intval($param['youhui_log_id']); //优惠券领取日志ID $event_submit_id = intval($param['event_submit_id']); //活动报名日志ID if ($order_item_id > 0) { $deal_id = intval($GLOBALS['db']->getOne("select deal_id from " . DB_PREFIX . "deal_order_item where id = " . $order_item_id)); } else { $deal_id = intval($param['deal_id']); } if ($youhui_log_id > 0) { $youhui_id = intval($GLOBALS['db']->getOne("select youhui_id from " . DB_PREFIX . "youhui_log where id = " . $youhui_log_id)); } else { $youhui_id = intval($param['youhui_id']); } if ($event_submit_id > 0) { $event_id = intval($GLOBALS['db']->getOne("select event_id from " . DB_PREFIX . "event_submit where id = " . $event_submit_id)); } else { $event_id = intval($param['event_id']); } $location_id = intval($param['location_id']); //部份初始化的变量 $is_buy = 0; //默认的点评为非购物点评 $avg_price = 0; //均价为0 if ($deal_id > 0) { require_once APP_ROOT_PATH . "system/model/deal.php"; $deal_info = get_deal($deal_id); if ($deal_info) { //验证是否可以点评 $checker = check_dp_status($GLOBALS['user_info']['id'], array("deal_id" => $deal_id, "order_item_id" => $order_item_id)); if (!$checker['status']) { return array("status" => false, "info" => $checker['info']); } else { $supplier_location_id = $checker['supplier_location_id']; } $is_buy = 1; $avg_price = $checker['avg_price']; } else { return array("status" => false, "info" => "你要点评的商品不存在"); } } elseif ($youhui_id > 0) { require_once APP_ROOT_PATH . "system/model/youhui.php"; $youhui_info = get_youhui($youhui_id); if ($youhui_info) { //验证是否可以点评 $checker = check_dp_status($GLOBALS['user_info']['id'], array("youhui_id" => $youhui_id, "youhui_log_id" => $youhui_log_id)); if (!$checker['status']) { return array("status" => false, "info" => $checker['info']); } else { $supplier_location_id = $checker['supplier_location_id']; } } else { return array("status" => false, "info" => "你要点评的优惠券不存在"); } } elseif ($event_id > 0) { require_once APP_ROOT_PATH . "system/model/event.php"; $event_info = get_event($event_id); if ($event_info) { //验证是否可以点评 $checker = check_dp_status($GLOBALS['user_info']['id'], array("event_id" => $event_id, "event_submit_id" => $event_submit_id)); if (!$checker['status']) { return array("status" => false, "info" => $checker['info']); } else { $supplier_location_id = $checker['supplier_location_id']; } } else { return array("status" => false, "info" => "你要点评的活动不存在"); } } elseif ($location_id > 0) { require_once APP_ROOT_PATH . "system/model/supplier.php"; $location_info = get_location($location_id); if ($location_info) { //验证是否可以点评 $checker = check_dp_status($GLOBALS['user_info']['id'], array("location_id" => $location_id)); if (!$checker['status']) { return array("status" => false, "info" => $checker['info']); } else { $supplier_location_id = $checker['supplier_location_id']; } } else { return array("status" => false, "info" => "你要点评的商家不存在"); } } if ($deal_id == 0 && $youhui_id == 0 && $event_id == 0 && $location_id == 0) { return array("status" => false, "info" => "非法的数据"); } //点评入库 $supplier_info = $GLOBALS['db']->getRow("select name,id,new_dp_count_time,supplier_id from " . DB_PREFIX . "supplier_location where id = " . intval($supplier_location_id)); $supplier_id = $supplier_info['supplier_id']; $dp_data = array(); if ($content != "") { $dp_data['is_content'] = 1; $dp_data['content'] = $content; } $dp_data['create_time'] = NOW_TIME; $dp_data['point'] = $dp_point; $dp_data['user_id'] = $user_id; $dp_data['supplier_location_id'] = $supplier_location_id; $dp_data['youhui_id'] = $youhui_id; $dp_data['event_id'] = $event_id; $dp_data['deal_id'] = $deal_id; $dp_data['images_cache'] = serialize($dp_image); $dp_data['supplier_id'] = $supplier_id; $dp_data['status'] = 1; if (count($dp_image) > 0) { $dp_data['is_img'] = 1; } $dp_data['avg_price'] = floatval($avg_price); $GLOBALS['db']->autoExecute(DB_PREFIX . "supplier_location_dp", $dp_data, "INSERT"); $dp_id = $GLOBALS['db']->insert_id(); if ($dp_id > 0) { if ($checker['order_item_id']) { $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order_item set dp_id = " . $dp_id . " where id = '" . $checker['order_item_id'] . "'"); $order_id = intval($GLOBALS['db']->getOne("select order_id from " . DB_PREFIX . "deal_order_item where id = " . $checker['order_item_id'])); update_order_cache($order_id); require_once APP_ROOT_PATH . "system/model/deal_order.php"; distribute_order($order_id); } if ($checker['youhui_log_id']) { $GLOBALS['db']->query("update " . DB_PREFIX . "youhui_log set dp_id = " . $dp_id . " where id = '" . $checker['youhui_log_id'] . "'"); } if ($checker['event_submit_id']) { $GLOBALS['db']->query("update " . DB_PREFIX . "event_submit set dp_id = " . $dp_id . " where id = '" . $checker['event_submit_id'] . "'"); } increase_user_active($user_id, "发表了一则点评"); $GLOBALS['db']->query("update " . DB_PREFIX . "user set dp_count = dp_count + 1 where id = " . $user_id); //创建点评图库 if (count($dp_image) > 0) { foreach ($dp_image as $pkey => $photo) { //点评图片不入商户图片库 // $c_data = array(); // $c_data['image'] = $photo; // $c_data['sort'] = 10; // $c_data['create_time'] = NOW_TIME; // $c_data['user_id'] = $user_id; // $c_data['supplier_location_id'] = $supplier_location_id; // $c_data['dp_id'] = $dp_id; // $c_data['status'] = 0; // $GLOBALS['db']->autoExecute(DB_PREFIX."supplier_location_images", $c_data,"INSERT"); $c_data = array(); $c_data['image'] = $photo; $c_data['dp_id'] = $dp_id; $c_data['create_time'] = NOW_TIME; $c_data['location_id'] = $supplier_location_id; $c_data['supplier_id'] = $supplier_id; $GLOBALS['db']->autoExecute(DB_PREFIX . "supplier_location_dp_images", $c_data, "INSERT"); } } //创建点评评分 foreach ($point_group as $group_id => $point) { $point_data = array(); $point_data['group_id'] = $group_id; $point_data['dp_id'] = $dp_id; $point_data['supplier_location_id'] = $supplier_location_id; $point_data['point'] = $point; $GLOBALS['db']->autoExecute(DB_PREFIX . "supplier_location_dp_point_result", $point_data, "INSERT"); //创建商品点评数据 if ($dp_data['deal_id'] > 0) { $point_data = array(); $point_data['group_id'] = $group_id; $point_data['dp_id'] = $dp_id; $point_data['deal_id'] = $dp_data['deal_id']; $point_data['point'] = $point; $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_dp_point_result", $point_data, "INSERT"); } //创建优惠券点评数据 if ($dp_data['youhui_id'] > 0) { $point_data = array(); $point_data['group_id'] = $group_id; $point_data['dp_id'] = $dp_id; $point_data['youhui_id'] = $dp_data['youhui_id']; $point_data['point'] = $point; $GLOBALS['db']->autoExecute(DB_PREFIX . "youhui_dp_point_result", $point_data, "INSERT"); } //创建活动点评数据 if ($dp_data['event_id'] > 0) { $point_data = array(); $point_data['group_id'] = $group_id; $point_data['dp_id'] = $dp_id; $point_data['event_id'] = $dp_data['event_id']; $point_data['point'] = $point; $GLOBALS['db']->autoExecute(DB_PREFIX . "event_dp_point_result", $point_data, "INSERT"); } } //创建点评分组的标签 foreach ($tag_group as $group_id => $tag_row_arr) { foreach ($tag_row_arr as $tag_row) { $tag_row_data = array(); $tag_row_data['tags'] = $tag_row; $tag_row_data['dp_id'] = $dp_id; $tag_row_data['supplier_location_id'] = $supplier_location_id; $tag_row_data['group_id'] = $group_id; $GLOBALS['db']->autoExecute(DB_PREFIX . "supplier_location_dp_tag_result", $tag_row_data, "INSERT"); insert_match_item($tag_row, "supplier_location_dp", $dp_id, "tags_match"); //更新点评的索引 review_supplier_location_match($supplier_location_id, $tag_row, $group_id); //创建商品点评数据 if ($dp_data['deal_id'] > 0) { $tag_row_data = array(); $tag_row_data['tags'] = $tag_row; $tag_row_data['dp_id'] = $dp_id; $tag_row_data['deal_id'] = $dp_data['deal_id']; $tag_row_data['group_id'] = $group_id; $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_dp_tag_result", $tag_row_data, "INSERT"); } //创建优惠券点评数据 if ($dp_data['youhui_id'] > 0) { $tag_row_data = array(); $tag_row_data['tags'] = $tag_row; $tag_row_data['dp_id'] = $dp_id; $tag_row_data['youhui_id'] = $dp_data['youhui_id']; $tag_row_data['group_id'] = $group_id; $GLOBALS['db']->autoExecute(DB_PREFIX . "youhui_dp_tag_result", $tag_row_data, "INSERT"); } //创建活动点评数据 if ($dp_data['event_id'] > 0) { $tag_row_data = array(); $tag_row_data['tags'] = $tag_row; $tag_row_data['dp_id'] = $dp_id; $tag_row_data['event_id'] = $dp_data['event_id']; $tag_row_data['group_id'] = $group_id; $GLOBALS['db']->autoExecute(DB_PREFIX . "event_dp_tag_result", $tag_row_data, "INSERT"); } } } //更新统计 syn_supplier_locationcount($supplier_info); cache_store_point($supplier_info['id']); //统计商品点评数据 if ($dp_data['deal_id'] > 0) { //计算总点评1-5星人数 $item_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where id = " . $dp_data['deal_id']); $sql = "select count(*) as total,point from " . DB_PREFIX . "supplier_location_dp where deal_id = " . $item_data['id'] . " group by point "; $data_result = $GLOBALS['db']->getAll($sql); foreach ($data_result as $k => $v) { $item_data['dp_count_' . $v['point']] = $v['total']; } $GLOBALS['db']->autoExecute(DB_PREFIX . "deal", $item_data, "UPDATE", " id = " . $item_data['id'] . " "); syn_deal_review_count($item_data['id']); } //创建优惠券点评数据 if ($dp_data['youhui_id'] > 0) { //计算总点评1-5星人数 $item_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "youhui where id = " . $dp_data['youhui_id']); $sql = "select count(*) as total,point from " . DB_PREFIX . "supplier_location_dp where youhui_id = " . $item_data['id'] . " group by point "; $data_result = $GLOBALS['db']->getAll($sql); foreach ($data_result as $k => $v) { $item_data['dp_count_' . $v['point']] = $v['total']; } $GLOBALS['db']->autoExecute(DB_PREFIX . "youhui", $item_data, "UPDATE", " id = " . $item_data['id'] . " "); syn_youhui_review_count($item_data['id']); } //创建活动点评数据 if ($dp_data['event_id'] > 0) { //计算总点评1-5星人数 $item_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "event where id = " . $dp_data['event_id']); $sql = "select count(*) as total,point from " . DB_PREFIX . "supplier_location_dp where event_id = " . $item_data['id'] . " group by point "; $data_result = $GLOBALS['db']->getAll($sql); foreach ($data_result as $k => $v) { $item_data['dp_count_' . $v['point']] = $v['total']; } $GLOBALS['db']->autoExecute(DB_PREFIX . "event", $item_data, "UPDATE", " id = " . $item_data['id'] . " "); syn_event_review_count($item_data['id']); } $return['location_id'] = $supplier_location_id; $return['deal_id'] = $dp_data['deal_id']; $return['youhui_id'] = $dp_data['youhui_id']; $return['event_id'] = $dp_data['event_id']; $return['status'] = 1; $return['info'] = "发表成功"; return $return; } else { $return['status'] = 0; $return['info'] = "数据库异常,提交失败"; return $return; } }
public function index() { require_once APP_ROOT_PATH . "system/libs/user.php"; $root = array(); $content = strim($GLOBALS['request']['content']); $source = strim($GLOBALS['request']['source']); $source = str_replace("来自", "", $source); $email = strim($GLOBALS['request']['email']); $pwd = strim($GLOBALS['request']['pwd']); $result = do_login_user($email, $pwd); $GLOBALS['user_info'] = $user_data = es_session::get('user_info'); $user_data['id'] = intval($user_data['id']); if (intval($user_data['id']) == 0) { $root['return'] = 0; $root['info'] = "请先登录"; output($root); } if (isset($_FILES['image_1'])) { //开始上传 //上传处理 //创建comment目录 if (!is_dir(APP_ROOT_PATH . "public/comment")) { @mkdir(APP_ROOT_PATH . "public/comment"); @chmod(APP_ROOT_PATH . "public/comment", 0777); } $dir = to_date(get_gmtime(), "Ym"); if (!is_dir(APP_ROOT_PATH . "public/comment/" . $dir)) { @mkdir(APP_ROOT_PATH . "public/comment/" . $dir); @chmod(APP_ROOT_PATH . "public/comment/" . $dir, 0777); } $dir = $dir . "/" . to_date(get_gmtime(), "d"); if (!is_dir(APP_ROOT_PATH . "public/comment/" . $dir)) { @mkdir(APP_ROOT_PATH . "public/comment/" . $dir); @chmod(APP_ROOT_PATH . "public/comment/" . $dir, 0777); } $dir = $dir . "/" . to_date(get_gmtime(), "H"); if (!is_dir(APP_ROOT_PATH . "public/comment/" . $dir)) { @mkdir(APP_ROOT_PATH . "public/comment/" . $dir); @chmod(APP_ROOT_PATH . "public/comment/" . $dir, 0777); } if (app_conf("IS_WATER_MARK") == 1) { $img_result = save_image_upload($_FILES, "image_1", "comment/" . $dir, $whs = array('thumb' => array(100, 100, 1, 0)), 1, 1); } else { $img_result = save_image_upload($_FILES, "image_1", "comment/" . $dir, $whs = array('thumb' => array(100, 100, 1, 0)), 0, 1); } if (app_conf("PUBLIC_DOMAIN_ROOT") != '') { $paths = pathinfo($img_result['topic_image']['url']); $path = str_replace("./", "", $paths['dirname']); $filename = $paths['basename']; $pathwithoupublic = str_replace("public/", "", $path); $syn_url = app_conf("PUBLIC_DOMAIN_ROOT") . "/es_file.php?username="******"IMAGE_USERNAME") . "&password="******"IMAGE_PASSWORD") . "&file=" . get_domain() . APP_ROOT . "/" . $path . "/" . $filename . "&path=" . $pathwithoupublic . "/&name=" . $filename . "&act=0"; @file_get_contents($syn_url); } require_once APP_ROOT_PATH . "system/utils/es_imagecls.php"; $image = new es_imagecls(); $info = $image->getImageInfo($img_result['image_1']['path']); $image_data['width'] = intval($info[0]); $image_data['height'] = intval($info[1]); $image_data['name'] = valid_str($_FILES['image_1']['name']); $image_data['filesize'] = filesize($img_result['image_1']['path']); $image_data['create_time'] = get_gmtime(); $image_data['user_id'] = intval($GLOBALS['user_info']['id']); $image_data['user_name'] = addslashes($GLOBALS['user_info']['user_name']); $image_data['path'] = $img_result['image_1']['thumb']['thumb']['url']; $image_data['o_path'] = $img_result['image_1']['url']; $GLOBALS['db']->autoExecute(DB_PREFIX . "topic_image", $image_data); $image_id = intval($GLOBALS['db']->insert_id()); //end 上传 } if ($image_id > 0) { $attach_list = array(array("id" => $image_id, "type" => "image")); } else { $attach_list = array(); } $id = insert_topic(valid_str($content), $title = "", $type = "", $group = "", $relay_id = 0, $fav_id = 0, $group_data = array(), $attach_list); if ($id) { increase_user_active($user_data['id'], "发表了一则分享"); $GLOBALS['db']->query("update " . DB_PREFIX . "topic set source_name = '" . $source . "' where id = " . intval($id)); } $syn_data['content'] = $content; //$syn_data['img'] = get_abs_img_root($GLOBALS['db']->getOne("select o_path from ".DB_PREFIX."topic_image where id = ".intval($image_id))); $syn_data['img'] = $GLOBALS['db']->getOne("select o_path from " . DB_PREFIX . "topic_image where id = " . intval($image_id)); if ($syn_data['img']) { $syn_data['img'] = APP_ROOT_PATH . $syn_data['img']; } //开始同步 if (intval($GLOBALS['request']['is_syn_sina'])) { //$GLOBALS['db']->query("update ".DB_PREFIX."user set is_syn_sina = 1 where id = ".intval($user_data['id'])); //$func_name = strim($GLOBALS['request']['type'])."_Sina"; //$result_sina = $func_name($syn_data); $result_sina = Sina($syn_data); $ext_info = ""; if (!$result_sina['status']) { if (intval($result_sina['code']) == 21316 || intval($result_sina['code']) == 21317) { $ext_info .= " 请先绑定新浪微博"; } if (intval($result_sina['code']) == 21314 || intval($result_sina['code']) == 21315) { $ext_info .= " 新浪微博授权过期"; } } } if (intval($GLOBALS['request']['is_syn_tencent'])) { //$GLOBALS['db']->query("update ".DB_PREFIX."user set is_syn_tencent = 1 where id = ".intval($user_data['id'])); // $func_name = strim($GLOBALS['request']['type'])."_Tencent"; // $result_tencent = $func_name($syn_data); $result_tencent = Tencent($syn_data); if (!$result_tencent['status']) { if (intval($result_tencent['code']) == 0) { $ext_info .= " 请先绑定腾讯微博"; } if (intval($result_tencent['code']) == 14) { $ext_info .= " 腾讯微博未实名认证"; } if (intval($result_tencent['code']) == 10017 || intval($result_tencent['code']) == 10018 || intval($result_tencent['code']) == 10019 || intval($result_tencent['code']) == 36 || intval($result_tencent['code']) == 37 || intval($result_tencent['code']) == 38) { $ext_info .= " 腾讯微博授权过期"; } } } $root['return'] = 1; $root['status'] = 1; $root['info'] = "发布成功" . $ext_info; output($root); }
/** * 插入主题评论数据 * @param array $reply_data * array( * 'topic_id'=>'', * 'user_id'=>'', * 'user_name'=>'', * 'reply_id'=>'', //可选 * 'create_time'=>'', (int) * 'is_effect'=>'', * 'is_delete'=>'', * 'content'=>'' * ) * @return int insert_id */ function insert_topic_reply($reply_data) { if ($reply_data['reply_id'] > 0) { $reply_reply_data = $GLOBALS['db']->getRow("select id,user_id,user_name from " . DB_PREFIX . "topic_reply where id = " . $reply_data['reply_id']); $reply_data['reply_user_id'] = $reply_reply_data['user_id']; $reply_data['reply_user_name'] = $reply_reply_data['user_name']; } $GLOBALS['db']->autoExecute(DB_PREFIX . "topic_reply", $reply_data); $id = $GLOBALS['db']->insert_id(); if ($id > 0) { increase_user_active(intval($GLOBALS['user_info']['id']), "回应了一则分享"); } $GLOBALS['db']->query("update " . DB_PREFIX . "topic set reply_count = reply_count + 1,last_time = " . get_gmtime() . ",last_user_id = " . intval($GLOBALS['user_info']['id']) . " where id = " . $reply_data['topic_id']); return $id; }
public function reply() { $return["status"] = 0; if (!$GLOBALS['user_info']) { $return["status"] = 2; $return["message"] = $GLOBALS['LANG']["PLEASE_LOGIN_FIRST"]; ajax_return($return); exit; } //验证码 if (app_conf("VERIFY_IMAGE") == 1) { $verify = md5(trim($_REQUEST['verify'])); $session_verify = es_session::get('verify'); if ($verify != $session_verify) { $return["message"] = $GLOBALS['lang']['VERIFY_CODE_ERROR']; ajax_return($return); exit; } } $content = htmlspecialchars(addslashes(valid_str($_REQUEST['content']))); $uid = intval($GLOBALS["user_info"]['id']); $pid = intval($_REQUEST['pid']); $dp_id = intval($_REQUEST['dp_id']); $page = intval($_REQUEST['page']); if (!check_ipop_limit(get_client_ip(), "dpsign", 10, $dp_id)) { $return['message'] = '请勿频繁回应'; ajax_return($return); exit; } es_session::delete("verify"); $dp_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "supplier_location_dp where id = " . $dp_id); $merchant_info = $GLOBALS['db']->getRow("select name,id from " . DB_PREFIX . "supplier_location where id = " . $dp_info['supplier_location_id']); $reply_data = array(); $reply_data['dp_id'] = $dp_id; $reply_data['content'] = $content; $reply_data['user_id'] = $uid; $reply_data['parent_id'] = $pid; $reply_data['create_time'] = get_gmtime(); $GLOBALS['db']->autoExecute(DB_PREFIX . "supplier_location_dp_reply", $reply_data, "INSERT"); $rid = $GLOBALS['db']->insert_id(); if ($rid > 0) { $syn_reply = intval($_REQUEST['syn_reply']); if ($syn_reply == 1) { $s_account_info = es_session::get("account_info"); if (in_array($dp_info['supplier_location_id'], $s_account_info['location_ids']) && $dp_info['from_data'] != "") { //验证通过 $message_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "message where id = " . intval($dp_info['message_id'])); if ($message_info) { $message_info['admin_reply'] = $content; $message_info['update_time'] = get_gmtime(); $GLOBALS['db']->autoExecute(DB_PREFIX . "message", $message_info, "UPDATE", "id=" . $message_info['id']); send_user_msg("商户回复了你的点评", "商户回复了你的点评 [<a href='" . url("youhui", "review#detail", array("id" => $dp_info['id'])) . "' target='_blank'>" . $dp_info['title'] . "</a>]", 0, $dp_info['user_id'], get_gmtime(), 0, 1, 1); } } } increase_user_active(intval($GLOBALS['user_info']['id']), "回应了一则商户点评"); $GLOBALS['db']->query("update " . DB_PREFIX . "supplier_location_dp set reply_count = reply_count + 1 where id = " . $dp_id); } //输出回应列表 $sql_count = "select count(*) from " . DB_PREFIX . "supplier_location_dp_reply where dp_id = " . $dp_id; $count = $GLOBALS['db']->getOne($sql_count); $page_size = app_conf("PAGE_SIZE"); if ($page == 0) { $page = 1; } $limit = ($page - 1) * app_conf("PAGE_SIZE") . "," . app_conf("PAGE_SIZE"); $sql = "select * from " . DB_PREFIX . "supplier_location_dp_reply where dp_id = " . $dp_id . " order by create_time desc limit " . $limit; $reply_list = $GLOBALS['db']->getAll($sql); foreach ($reply_list as $k => $v) { $reply_list[$k]['user_name'] = $GLOBALS['db']->getOne("select user_name from " . DB_PREFIX . "user where id = " . $v['user_id']); $reply_list[$k]['create_time_format'] = pass_date($v['create_time']); } $GLOBALS['current_url'] = $_SERVER['REQUEST_URI'] = url("youhui", "review#detail", array("id" => $dp_id)); $page = new Page($count, $page_size); //初始化分页对象 $p = $page->show(); $GLOBALS['tmpl']->assign('pages', $p); $GLOBALS['tmpl']->assign("reply_list", $reply_list); $GLOBALS['tmpl']->assign('user_auth', get_user_auth()); $html = decode_topic($GLOBALS['tmpl']->fetch("inc/review/reply_list.html")); $return = array("status" => 1, "message" => $html); ajax_return($return); exit; }
public function reply() { $no_verify = intval($_REQUEST['no_verify']); $ajax = intval($_REQUEST['ajax']); if (!$GLOBALS['user_info']) { showErr($GLOBALS['lang']['PLEASE_LOGIN_FIRST'], $ajax); } if ($_REQUEST['content'] == '') { showErr($GLOBALS['lang']['MESSAGE_CONTENT_EMPTY'], $ajax); } //验证码 if (app_conf("VERIFY_IMAGE") == 1 && $no_verify == 0) { $verify = md5(trim($_REQUEST['verify'])); $session_verify = es_session::get('verify'); if ($verify != $session_verify) { showErr($GLOBALS['lang']['VERIFY_CODE_ERROR'], $ajax); } } if (!check_ipop_limit(get_client_ip(), "message", intval(app_conf("SUBMIT_DELAY")), 0)) { showErr($GLOBALS['lang']['MESSAGE_SUBMIT_FAST'], $ajax); } $topic_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "topic where id = " . intval($_REQUEST['topic_id'])); if (!$topic_info) { showErr("主题不存在", $ajax); } $reply_data = array(); $reply_data['topic_id'] = intval($_REQUEST['topic_id']); $reply_data['user_id'] = intval($GLOBALS['user_info']['id']); $reply_data['user_name'] = $GLOBALS['user_info']['user_name']; $reply_data['reply_id'] = intval($_REQUEST['reply_id']); if ($reply_data['reply_id'] > 0) { $reply_reply_data = $GLOBALS['db']->getRow("select id,user_id,user_name from " . DB_PREFIX . "topic_reply where id = " . $reply_data['reply_id']); $reply_data['reply_user_id'] = $reply_reply_data['user_id']; $reply_data['reply_user_name'] = $reply_reply_data['user_name']; } $reply_data['create_time'] = get_gmtime(); $reply_data['is_effect'] = 1; $reply_data['is_delete'] = 0; $reply_data['content'] = htmlspecialchars(valid_str(addslashes($_REQUEST['content']))); $GLOBALS['db']->autoExecute(DB_PREFIX . "topic_reply", $reply_data); $id = $GLOBALS['db']->insert_id(); if ($id > 0) { increase_user_active(intval($GLOBALS['user_info']['id']), "回应了一则分享"); $attach_list = get_topic_attach_list(); foreach ($attach_list as $attach) { if ($attach['type'] == 'image') { //插入图片 $GLOBALS['db']->query("update " . DB_PREFIX . "topic_image set topic_id = " . $id . ",topic_table='topic_reply' where id = " . $attach['id']); } } } //删除所有创建超过一小时,且未被使用过的图片 $del_list = $GLOBALS['db']->getAll("select id,path from " . DB_PREFIX . "topic_image where topic_id = 0 and " . get_gmtime() . " - create_time > 3600"); $GLOBALS['db']->query("delete from " . DB_PREFIX . "topic_image where topic_id = 0 and " . get_gmtime() . " - create_time > 3600"); foreach ($del_list as $k => $v) { @unlink(APP_ROOT_PATH . $v['path']); @unlink(APP_ROOT_PATH . $v['o_path']); } $GLOBALS['db']->query("update " . DB_PREFIX . "topic set reply_count = reply_count + 1,last_time = " . get_gmtime() . ",last_user_id = " . intval($GLOBALS['user_info']['id']) . " where id = " . $reply_data['topic_id']); showSuccess($GLOBALS['lang']['MESSAGE_POST_SUCCESS'], $ajax); }
public function add() { $ajax = intval($_REQUEST['ajax']); if (!$GLOBALS['user_info']) { showErr($GLOBALS['lang']['PLEASE_LOGIN_FIRST'], $ajax); } if ($_REQUEST['content'] == '') { showErr($GLOBALS['lang']['MESSAGE_CONTENT_EMPTY'], $ajax); } //验证码 if (app_conf("VERIFY_IMAGE") == 1) { $verify = md5(trim($_REQUEST['verify'])); $session_verify = es_session::get('verify'); if ($verify != $session_verify) { showErr($GLOBALS['lang']['VERIFY_CODE_ERROR'], $ajax); } } if (!check_ipop_limit(get_client_ip(), "message", intval(app_conf("SUBMIT_DELAY")), 0)) { showErr($GLOBALS['lang']['MESSAGE_SUBMIT_FAST'], $ajax); } $forum_title = htmlspecialchars(addslashes(trim(valid_str($_REQUEST['forum_title'])))); $group_id = intval($_REQUEST['group_id']); if ($group_id > 0) { if ($forum_title == '') { showErr("请输出发表的主题", $ajax); } $user_id = intval($GLOBALS['user_info']['id']); $group_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "topic_group where id = " . $group_id); if ($group_info['user_id'] != $user_id) { if ($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "user_topic_group where group_id=" . $group_id . " and user_id = " . $user_id) == 0) { showErr("不是本组会员, 不能发表主题", $ajax); } } } $title = htmlspecialchars(addslashes(trim(valid_str($_REQUEST['title'])))); $content = htmlspecialchars(addslashes(trim(valid_str($_REQUEST['content'])))); $group = htmlspecialchars(addslashes(trim($_REQUEST['group']))); $group_data = addslashes(trim($_REQUEST['group_data'])); $type = addslashes(trim($_REQUEST['type'])); $tags_data = $_REQUEST['tag']; $tags = array(); foreach ($tags_data as $tag_row) { $tag_row_arr = explode(" ", $tag_row); foreach ($tag_row_arr as $tag_item) { $tag_item = trim($tag_item); if (!in_array($tag_item, $tags)) { $tags[] = addslashes(htmlspecialchars(trim($tag_item))); } } } $attach_list = get_topic_attach_list(); $id = insert_topic($content, $title, $type, $group, $relay_id = 0, $fav_id = 0, $group_data, $attach_list, $url_route = array(), $tags, '', '', $forum_title, $group_id); if ($id) { $GLOBALS['db']->query("update " . DB_PREFIX . "topic set source_name = '网站' where id = " . intval($id)); increase_user_active(intval($GLOBALS['user_info']['id']), "发表了一则分享"); } //验证码 if (app_conf("VERIFY_IMAGE") == 1) { es_session::delete('verify'); } if ($ajax == 1) { $result['info'] = $GLOBALS['lang']['MESSAGE_POST_SUCCESS']; $result['data'] = intval($id); $result['status'] = 1; ajax_return($result); } else { if ($group_id > 0) { $url = url("shop", "group#forum", array("id" => $group_id)); } showSuccess($GLOBALS['lang']['MESSAGE_POST_SUCCESS'], $ajax, $url); } // showSuccess($GLOBALS['lang']['MESSAGE_POST_SUCCESS'],$ajax); }
/** * 快捷发布保存 */ public function publish_save() { global_run(); $ajax = intval($_REQUEST['ajax']); if (check_save_login() == LOGIN_STATUS_NOLOGIN) { showErr($GLOBALS['lang']['PLEASE_LOGIN_FIRST'], $ajax); } if ($_REQUEST['content'] == '') { showErr($GLOBALS['lang']['MESSAGE_CONTENT_EMPTY'], $ajax); } if (!check_ipop_limit(get_client_ip(), "message", intval(app_conf("SUBMIT_DELAY")), 0)) { showErr($GLOBALS['lang']['MESSAGE_SUBMIT_FAST'], $ajax); } $forum_title = strim(valid_str($_REQUEST['forum_title'])); $group_id = intval($_REQUEST['group_id']); $syn_weibo = intval($_REQUEST['syn_weibo']); if ($group_id > 0) { if ($forum_title == '') { showErr("请输出发表的主题", $ajax); } $user_id = intval($GLOBALS['user_info']['id']); $group_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "topic_group where id = " . $group_id); if ($group_info['user_id'] != $user_id) { if ($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "user_topic_group where group_id=" . $group_id . " and user_id = " . $user_id) == 0) { //不是会员自动加入小组 $ins_user_topic = array('group_id' => $group_id, 'user_id' => $user_id, 'create_time' => NOW_TIME, 'type' => 0); $GLOBALS['db']->autoExecute(DB_PREFIX . "user_topic_group", $ins_user_topic); $id = $GLOBALS['db']->insert_id(); if ($id) { $GLOBALS['db']->query("update " . DB_PREFIX . "topic_group set user_count = user_count + 1 where id=" . $group_id); } } } } $title = strim(valid_str($_REQUEST['title'])); $content = strim(valid_str($_REQUEST['content'])); $group = strim($_REQUEST['group']); $group_data = strim($_REQUEST['group_data']); $type = strim($_REQUEST['type']); $tags_data = $_REQUEST['tags']; $tags = array(); if ($tags_data) { $tag_row_arr = explode(" ", $tags_data); foreach ($tag_row_arr as $tag_item) { $tag_item = strim($tag_item); if (!in_array($tag_item, $tags)) { $tags[] = strim($tag_item); } } } elseif ($forum_title) { $tags = div_str($forum_title); if (count($tags) > 5) { $tags = array_slice($tags, 0, 4); } } $ungroup_date = unserialize(base64_decode($group_data)); $url_route = array('rel_app_index' => $ungroup_date['url']['app_index'], 'rel_route' => $ungroup_date['url']['route'], 'rel_param' => ''); $attach_list = get_topic_attach_list(); require_once APP_ROOT_PATH . '/system/model/topic.php'; $id = insert_topic($content, $title, $type, $group, $relay_id = 0, $fav_id = 0, $group_data, $attach_list, $url_route, $tags, '', '', $forum_title, $group_id, $syn_weibo); if ($id) { $GLOBALS['db']->query("update " . DB_PREFIX . "topic set source_name = '网站' where id = " . intval($id)); increase_user_active(intval($GLOBALS['user_info']['id']), "发表了一则分享"); } if ($ajax == 1) { $result['info'] = $GLOBALS['lang']['MESSAGE_POST_SUCCESS']; $result['data'] = intval($id); $result['status'] = 1; ajax_return($result); } else { if ($group_id > 0) { $url = url("index", "group#forum", array("id" => $group_id)); } showSuccess($GLOBALS['lang']['MESSAGE_POST_SUCCESS'], $ajax, $url); } }