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 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);
 }
 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 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);
 }
Example #5
0
 /**
  * 快捷发布保存
  */
 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);
     }
 }