public function add() { import("ORG.Util.Input"); $db = new WorldsResponsesModel(); $data['text'] = Input::deleteHtmlTags($_POST['text']); $data['w_id'] = $_POST['w_id']; $data['ip'] = $_SESSION['user_ip']; $data['name'] = $_SESSION['sina_me']['name']; $data['url'] = 'http://t.sina.com/' . $_SESSION['sina_me']['domain']; //将回复同步到新浪微博 $myname = $_SESSION['sina_me']['name']; $the_id = $data['w_id']; $sql = "SELECT * FROM `ty_worlds_responses` WHERE ( `w_id` = '{$the_id}' ) AND ( `name` != '' ) AND(`name`<>'{$myname}') \r\r\n\t\t\t group by name"; $result = $db->query($sql); foreach ($result as $item) { $name .= ' @' . $item['name'] . ' '; } if ($id = $db->add($data)) { $url = "http://t-y.me/index.php/Worlds/view/id/" . $data['w_id']; if ($name != '') { $msg = $this->sina_update($name . ' :TY在t-y.me回复了你!点击查看' . $url . ' ' . date("Y-m-d H:i:s")); } echo $data['text'] . " -<a href='" . $data['url'] . "'>" . $data['name'] . "</a>" . '(' . $name . $msg . ')'; } else { echo "<span style='color:red;'>Error</span>"; echo '(⊙o⊙)…杯具,服务器出现错误!'; } unset($data); $db = new WorldsModel(); $data['last_time'] = date("Y-m-d H:i:s"); $map['id'] = $_POST['w_id']; $db->where($map)->save($data); }
/** * 数据处理 * @param type $data 数据 * @return type */ private function dataHandle($data, $text = '') { if (!$data) { return $data; } import("Input"); $data = addslashes($data); $data = strip_tags($data); $data = str_replace(array(" ", "\r\t"), array(""), $data); $data = Input::forSearch($data); $data = Input::deleteHtmlTags($data); $config = F("Search_config"); if (!$config) { $this->search_cache(); $config = F("Search_config"); } //判断是否启用sphinx全文索引,如果不是,则进行php简易分词处理 if ((int) $config['sphinxenable'] == 0 && $config['segment']) { static $Segment; if (!isset($Segment)) { import("Segment", APP_PATH . C("APP_GROUP_PATH") . '/Search/Class/'); $Segment = new Segment(); } $fulltext_data = $Segment->get_keyword($Segment->split_result($data)); $data = $text . $fulltext_data; } return $data; }
/** * 数据处理 * @param type $data 数据 * @return type */ private function dataHandle($data) { if (!$data) { return $data; } import("Input"); $data = addslashes($data); $data = strip_tags($data); $data = str_replace(array(" ", "\r\t"), array(""), $data); $data = Input::forSearch($data); $data = Input::deleteHtmlTags($data); return $data; }
/** * 评论一个商品 */ public function comment() { foreach ($_POST as $key => $val) { $_POST[$key] = Input::deleteHtmlTags($val); } $data = array(); $data['post_id'] = $this->_post('id', 'intval'); !$data['post_id'] && $this->ajaxReturn(0, L('invalid_item')); $data['info'] = $this->_post('content', 'trim'); !$data['info'] && $this->ajaxReturn(0, L('please_input') . L('comment_content')); //敏感词处理 $check_result = D('badword')->check($data['info']); switch ($check_result['code']) { case 1: //禁用。直接返回 $this->ajaxReturn(0, L('has_badword')); break; case 3: //需要审核 $data['status'] = 0; break; } $data['info'] = $check_result['content']; $data['uid'] = $this->visitor->info['id']; $data['uname'] = $this->visitor->info['username']; $data['add_time'] = time(); $data['pid'] = $this->_post('pid', 'intval'); //验证商品 $item = $this->post_mod->field('id,uid,uname')->where(array('id' => $data['post_id'], 'status' => '1'))->find(); !$item && $this->ajaxReturn(0, L('invalid_item')); //写入评论 if (false === $this->post_comment_mod->create($data)) { $this->ajaxReturn(0, $this->post_comment_mod->getError()); } $comment_id = $this->post_comment_mod->add(filter_data($data)); if ($comment_id) { $tag_arg = array('uid' => $this->visitor->info['id'], 'uname' => $this->visitor->info['username'], 'action' => 'comment'); tag('comment_end', $tag_arg); $to_id = $this->_post('to_id', 'intval'); if ($to_id > 0) { $this->message_mod->add(array('ftid' => $data['uid'], 'from_id' => $data['uid'], 'from_name' => $data['uname'], 'to_id' => $this->_post('to_id', 'intval'), 'to_name' => $this->_post('to_name', 'trim'), 'add_time' => time(), 'info' => $data['info'])); } $this->assign('cmt_list', array(array('id' => $comment_id, 'uid' => $data['uid'], 'uname' => $data['uname'], 'info' => $data['info'], 'add_time' => time(), 'digg' => 0, 'burn' => 0, 'quote' => $this->post_comment_mod->where(array('id' => $data['pid']))->find(), 'user' => $this->user_mod->where(array('id' => $data['uid']))->find()))); $resp['html'] = $this->fetch('ajax_comment_list'); $resp['total'] = $this->post_comment_mod->where(array('post_id' => $data['post_id']))->count('id'); $this->ajaxReturn(1, L('comment_success'), $resp); } else { $this->ajaxReturn(0, L('comment_failed')); } }
public function save() { $db = new MsgsModel(); import("ORG.Util.Input"); $data['text'] = Input::deleteHtmlTags($_POST['text']); $data['time'] = date("Y-m-d H:i:s"); $data['ip'] = $this->getIp(); // if ($db->add($data)) { echo "<div id='sendmsg' class='center'>发送成功!</div>"; //dump($data); } else { echo "<div id='sendmsg' class='center red'>呃,服务器开小差了~~~稍后再试··</div>"; } }
public function addResponse() { import("ORG.Util.Input"); $db = new WorldsResponsesModel(); $data['text'] = Input::deleteHtmlTags($_POST['text']); $data['w_id'] = $_POST['w_id']; $data['ip'] = $_SESSION['user_ip']; $data['name'] = $_SESSION['sina']['name']; $data['url'] = 'http://t.sina.com/' . $_SESSION['sina']['id']; if ($id = $db->add($data)) { //echo $db->getLastSql();exit; $str1 = $data['text'] . "[IP:" . $_SESSION['user_ip'] . "]"; $str2 = $data['text'] . " -<a href='" . $data['url'] . "'>" . $data['name'] . "</a>"; echo $_SESSION['sina']['id'] != '' ? $str2 : $str1; } else { echo "<span style='color:red;'>Error</span>"; echo '(⊙o⊙)…杯具,服务器出现错误!'; } unset($data); $db = new WorldsModel(); $data['last_time'] = date("Y-m-d H:i:s"); $map['id'] = $_POST['w_id']; $db->where($map)->save($data); }
public function publish_item() { $item = unserialize($this->_post('item', 'trim')); !$item['key_id'] && $this->ajaxReturn(0, L('publish_item_failed')); $album_id = $this->_post('album_id', 'intval', 0); $ac_id = $this->_post('ac_id', 'intval', 0); $item['intro'] = $this->_post('intro', 'trim'); $item['info'] = Input::deleteHtmlTags($item['info']); $item['uid'] = $this->visitor->info['id']; $item['uname'] = $this->visitor->info['username']; $item['status'] = C('pin_item_check') ? 0 : 1; //添加商品 $item_mod = D('item'); $result = $item_mod->publish($item, $album_id, $ac_id); if ($result) { //发布商品钩子 $tag_arg = array('uid' => $item['uid'], 'uname' => $item['uname'], 'action' => 'pubitem'); tag('pubitem_end', $tag_arg); $this->ajaxReturn(1, L('publish_item_success')); } else { $this->ajaxReturn(0, $item_mod->getError()); } }
/** * 发布 */ public function publish() { foreach ($_POST as $key => $val) { $_POST[$key] = Input::deleteHtmlTags($val); } $to_id = $this->_post('to_id', 'intval'); $content = $this->_post('content', 'trim'); if (!$content) { $this->ajaxReturn(0, L('message_content_empty')); } $to_name = M('user')->where(array('id' => $to_id))->getField('username'); $ftid = $this->visitor->info['id'] + $to_id; $data = array('ftid' => $ftid, 'from_id' => $this->visitor->info['id'], 'from_name' => $this->visitor->info['username'], 'to_id' => $to_id, 'to_name' => $to_name, 'info' => $content); $message_mod = D('message'); $info = $message_mod->create($data); $info['id'] = $message_mod->add(); if ($info['id']) { //提示接收者 D('user_msgtip')->add_tip($to_id, 3); $this->assign('info', $info); $resp = $this->fetch('list_unit'); $this->ajaxReturn(1, L('send_message_success'), $resp); } else { $this->ajaxReturn(0, L('illegal_parameters')); } }
/** * 基本信息修改 */ public function index() { if (IS_POST) { foreach ($_POST as $key => $val) { $_POST[$key] = Input::deleteHtmlTags($val); } $data['gender'] = $this->_post('gender', 'intval'); $data['province'] = $this->_post('province', 'trim'); $data['city'] = $this->_post('city', 'trim'); $data['intro'] = $this->_post('intro', 'trim'); $data['truename'] = $this->_post('truename', 'trim'); $data['mobile'] = $this->_post('mobile', 'intval'); $data['telephone'] = $this->_post('telephone', 'trim'); $data['address'] = $this->_post('address', 'trim'); $data['qq'] = $this->_post('qq', 'intval'); $data['wangwang'] = $this->_post('wangwang', 'trim'); $birthday = $this->_post('birthday', 'trim'); $birthday = explode('-', $birthday); $data['byear'] = $birthday[0]; $data['bmonth'] = $birthday[1]; $data['bday'] = $birthday[2]; if (false !== M('user')->where(array('id' => $this->visitor->info['id']))->save($data)) { $msg = array('status' => 1, 'info' => L('edit_success')); } else { $msg = array('status' => 0, 'info' => L('edit_failed')); } $this->assign('msg', $msg); } $info = $this->visitor->get(); $notice = M('article')->where(array('cate_id' => '1'))->select(); $this->assign('notice', $notice); $this->assign('info', $info); $this->_config_seo(array('title' => L('base_setting') . ' - ' . C('ftx_site_name'))); $this->display(); }
public function profile() { if (IS_POST) { foreach ($_POST as $key => $val) { $_POST[$key] = Input::deleteHtmlTags($val); } $data['gender'] = $this->_post('gender', 'intval'); $data['province'] = $this->_post('province', 'trim'); $data['city'] = $this->_post('city', 'trim'); $data['tags'] = $this->_post('tags', 'trim'); $data['intro'] = $this->_post('intro', 'trim'); $birthday = $this->_post('birthday', 'trim'); $birthday = explode('-', $birthday); $data['byear'] = $birthday[0]; $data['bmonth'] = $birthday[1]; $data['bday'] = $birthday[2]; if (false !== M('user')->where(array('id' => $this->visitor->info['id']))->save($data)) { $msg = array('status' => 1, 'info' => L('edit_success')); } else { $msg = array('status' => 0, 'info' => L('edit_failed')); } $this->assign('msg', $msg); $this->success($msg['info']); } $info = $this->visitor->get(); $this->assign('info', $info); $this->_config_seo(); $this->display(); }
/** * 评论一个商品 */ public function comment() { foreach ($_POST as $key => $val) { $_POST[$key] = Input::deleteHtmlTags($val); } $data = array(); $data['item_id'] = I('id', '', 'intval'); !$data['item_id'] && $this->ajaxReturn(0, L('invalid_item')); $data['info'] = I('content', '', 'trim'); !$data['info'] && $this->ajaxReturn(0, L('please_input') . L('comment_content')); $data['status'] = 1; $data['uid'] = $this->visitor->info['id']; $data['uname'] = $this->visitor->info['username']; //验证商品 $item = $this->_mod->field('id,uid,nick')->where(array('id' => $data['item_id'], 'pass' => '1'))->find(); !$item && $this->ajaxReturn(0, L('invalid_item')); //写入评论 $item_comment_mod = D('items_comment'); if (false === $item_comment_mod->create($data)) { $this->ajaxReturn(0, $item_comment_mod->getError()); } $comment_id = $item_comment_mod->add(); if ($comment_id) { $this->assign('cmt_list', array(array('uid' => $data['uid'], 'uname' => $data['uname'], 'info' => $data['info'], 'add_time' => time()))); $resp = $this->fetch('comment_list'); $this->ajaxReturn(1, L('comment_success'), $resp); } else { $this->ajaxReturn(0, L('comment_failed')); } }
public function addResponse() { import('ORG.Util.Input'); $db = new WorldsResponsesModel(); $data['text'] = Input::deleteHtmlTags($_POST['text']); $data['w_id'] = $_POST['w_id']; $data['ip'] = $_SESSION['user_ip']; if ($db->add($data)) { unset($data); $db = new WorldsModel(); $data['last_time'] = date("Y-m-d H:i:s"); $map['id'] = $_POST['w_id']; $db->where($map)->save($data); $this->gSuccess("你的评论“" . $_POST['text'] . "“发表成功!", "viewWorlds?id=" . $_POST['w_id']); } else { $this->gError("呃," . $db->getError(), "viewWorlds?id=" . $_POST['w_id']); } }
function deleteHtmlTags($text) { return Input::deleteHtmlTags($text); }
/** * 评论一个商品 */ public function comment() { foreach ($_POST as $key => $val) { $_POST[$key] = Input::deleteHtmlTags($val); } $data = array(); $data['num_iid'] = I('ths_id'); !$data['num_iid'] && $this->ajaxReturn(1, '评论失败', 0); $data['info'] = I('comment', '', 'trim'); !$data['info'] && $this->ajaxReturn(1, '请填写评论', 0); $data['status'] = 1; $data['uid'] = $this->visitor->info['id']; !$data['uid'] && $this->ajaxReturn(1, '请登录之后再评论', 0); $data['uname'] = $this->visitor->info['username']; //验证商品 $item = $this->_mod->field('id,num_iid,uid,nick')->where(array('num_iid' => $data['num_iid'], 'pass' => '1'))->find(); !$item && $this->ajaxReturn(0, "该商品可能已经删除,请联系管理员", 0); //写入评论 $data['item_id'] = $item['num_iid']; $data['add_time'] = time(); D('items_comment')->add($data); $this->ajaxReturn(1, "评论完成", 1); }