Example #1
0
 /**
  * add
  * 添加投票
  * @access public
  * @return void
  */
 function add()
 {
     $data['title'] = t(h($_POST['title']));
     if (t(h($_POST['date'])) == 'custom') {
         $data['deadline'] = mktime($_POST['deadline']['hour'], 0, 0, $_POST['deadline']['month'], $_POST['deadline']['day'], $_POST['deadline']['year']);
     } else {
         $data['deadline'] = time() + $_POST['date'] * 86400;
     }
     $data['uid'] = $this->mid;
     $data['explain'] = h($_POST['explain']);
     $data['type'] = intval($_POST['type']);
     $data['onlyfriend'] = intval($_POST['onlyfriend']);
     $data['cTime'] = time();
     $opt = $_POST['opt'];
     //投票表
     $voteDao = D("Vote");
     try {
         $result = $voteDao->addVote($data, $opt);
     } catch (ThinkException $e) {
         $this->error($e->getMessage());
     }
     if ($result) {
         //$_SESSION['MyNewVote'] = 1;
         model('Credit')->setUserCredit($this->mid, 'add_vote');
         $this->assign('jumpUrl', U('vote/Index/pollDetail', array('id' => $result)));
         $this->ajaxData['url'] = U('vote/Index/pollDetail', array('id' => $result));
         $this->ajaxData['id'] = $result;
         $this->ajaxData['title'] = keyWordFilter($data['title']);
         $this->ajaxData['opt'] = array_filter(keyWordFilter($opt));
         $this->ajaxData['deadline'] = $data['deadline'];
         // $this->success('添加投票成功');
         $this->ajaxReturn($this->ajaxData, '添加投票成功', 1);
     } else {
         $this->ajaxReturn($this->ajaxData, '添加投票成功', 1);
         // $this->error('添加失败');
     }
 }
Example #2
0
 /**
  * 执行图片修改操作
  * @return josn 返回修改后的JSON数据
  */
 public function do_update_photo()
 {
     $id = intval($_REQUEST['id']);
     $map['albumId'] = intval($_REQUEST['albumId']);
     $map['name'] = h(t($_REQUEST['name']));
     $nextId = intval($_REQUEST['nextId']);
     $photoDao = D('Photo', 'photo');
     $albumDao = D('Album', 'photo');
     // 图片原信息
     $oldInfo = $photoDao->where("id={$id} AND userId={$this->mid}")->field('albumId')->find();
     // 更新信息
     $result = $photoDao->where("id={$id} AND userId={$this->mid}")->save($map);
     // 移动图片则重置相册图片数
     if ($map['albumId'] != $oldInfo['albumId']) {
         $albumDao->updateAlbumPhotoCount($map['albumId']);
         $albumDao->updateAlbumPhotoCount($oldInfo['albumId']);
     }
     // 返回
     if ($result) {
         $data['result'] = 1;
         $data['message'] = keyWordFilter($map['name']);
         exit(json_encode($data));
     } else {
         $data['result'] = 0;
         exit(json_encode($data));
     }
 }
Example #3
0
/**
 * 格式化评论, 替换表情和@用户
 *
 * @param string  $content 待格式化的内容
 * @param boolean $url     是否替换URL
 * @return string
 */
function formatComment($content, $url = false)
{
    if ($url) {
        $content = preg_replace('/((?:https?|ftp):\\/\\/(?:www\\.)?(?:[a-zA-Z0-9][a-zA-Z0-9\\-]*\\.)?[a-zA-Z0-9][a-zA-Z0-9\\-]*(?:\\.[a-zA-Z0-9]+)+(?:\\:[0-9]*)?(?:\\/[^\\x{4e00}-\\x{9fa5}\\s<\'\\"“”‘’]*)?)/u', '<a href="\\1" target="_blank">\\1</a>\\2', $content);
    }
    $content = preg_replace_callback("/(\\[.+?\\])/is", replaceEmot, $content);
    $content = preg_replace_callback("/@([\\w\\x{4e00}-\\x{9fa5}\\-]+)/u", getUserId, $content);
    $content = keyWordFilter($content);
    return $content;
}
 public function getOneApi($id, $value, $uid = 0)
 {
     if (!$value && is_numeric($id)) {
         if (($value = object_cache_get("weibo_{$id}")) === false) {
             $value = $this->where('weibo_id="' . $id . '" AND isdel=0')->find();
         }
     }
     if (!$value) {
         return false;
     }
     $value['uname'] = getUserName($value['uid']);
     $value['face'] = getUserFace($value['uid']);
     if ($value['type'] == 1 && $value['transpond_id'] == 0) {
         $value['type_data'] = unserialize($value['type_data']);
         $value['type_data']['picurl'] = SITE_URL . '/data/uploads/' . $value['type_data']['picurl'];
         $value['type_data']['thumbmiddleurl'] = SITE_URL . '/data/uploads/' . $value['type_data']['thumbmiddleurl'];
         $value['type_data']['thumburl'] = SITE_URL . '/data/uploads/' . $value['type_data']['thumburl'];
     }
     $value['transpond_data'] = $value['transpond_id'] > 0 ? $this->getOneApi($value['transpond_id']) : '';
     $value['timestamp'] = $value['ctime'];
     $value['ctime'] = date('Y-m-d H:i', $value['ctime']);
     $value['from_data'] = unserialize($value['from_data']);
     $value['content'] = keyWordFilter($value['content']);
     if (isset($value['favorited'])) {
         $value['favorited'] = intval($value['favorited']);
     } else {
         $value['favorited'] = (int) D('Favorite', 'weibo')->isFavorited($id, $uid);
     }
     return $value;
 }
Example #5
0
 /**
  * doAddEvent
  * 添加活动
  * @access public
  * @return void
  */
 public function doAddEvent()
 {
     $this->_createLimit($this->mid);
     $map['title'] = t($_POST['title']);
     $map['address'] = t($_POST['address']);
     $map['limitCount'] = intval(t($_POST['limitCount'])) ? intval(t($_POST['limitCount'])) : 0;
     $map['type'] = ',' . trim($_POST['type'], ',') . ',';
     $map['explain'] = preg_replace('/class="[0-9a-zA-Z_\\-]+"/', '', h($_POST['content']));
     $map['contact'] = t($_POST['contact']);
     $map['deadline'] = $this->_paramDate($_POST['deadline']);
     $map['sTime'] = $this->_paramDate($_POST['sTime']);
     $map['eTime'] = $this->_paramDate($_POST['eTime']);
     $map['uid'] = $this->mid;
     $map['evob'] = intval(t($_POST['evob']));
     $map['implement_type'] = intval(t($_POST['implement_type'])) ? intval(t($_POST['implement_type'])) : 1;
     //$map['name']       = getUserName($this->mid);
     if (!t($_POST['title'])) {
         $this->error("活动标题不能为空");
     }
     if ($map['implement_type'] == 2 && !t($_POST['address'])) {
         $this->error("活动地址不能为空");
     }
     if ($map['sTime'] > $map['eTime']) {
         $this->error("结束时间不得早于开始时间");
     }
     /*
     if(intval($_POST['type']) == 0){
         $this->error("请选择活动分类");
     }
     		if( $map['sTime'] < mktime(0, 0, 0, date('M'), date('D'), date('Y')) ) {
         $this->error( "开始时间不得早于当前时间" );
     }
     if( $map['deadline'] < time() ) {
         $this->error( "报名截止时间不得早于当前时间" );
     }
     if( $map['deadline'] > $map['eTime'] ) {
     	$this->error('报名截止时间不能晚于结束时间');
     }
     */
     //$string=iconv("UTF-8","GBK", t($map['explain']));
     $length = strlen(t($map['explain']));
     if ($length < 20) {
         $this->error('介绍不得小于20个字符');
     }
     //处理省份,市,区
     //list( $opts['province'],$opts['city'],$opts['area'] ) = explode(" ",safe($_POST['city']));
     //得到上传的图片
     $data['attach_type'] = 'event';
     $data['upload_type'] = 'image';
     $cover = model('attach')->upload($data);
     //处理选项
     $opts['cost'] = intval($_POST['cost']) ? intval($_POST['cost']) : 0;
     $opts['costExplain'] = t($_POST['costExplain']);
     $opts['costExplain'] = keyWordFilter(t($_POST['costExplain']));
     $friend = isset($_POST['friend']) ? 1 : 0;
     $allow = isset($_POST['allow']) ? 1 : 0;
     $opts['opts'] = array('friend' => $friend, 'allow' => $allow);
     if ($addId = $this->event->doAddEvent($map, $opts, $cover)) {
         $cover['status'] && ($attachid = $cover['info'][0]['attach_id']);
         model('Feed')->syncToFeed('我发布了一个新活动“' . t($_POST['title']) . '”,详情请点击' . U('event/Index/eventDetail', array('id' => $addId, 'uid' => $this->mid)), $this->mid, $attachid, $from);
         model('Credit')->setUserCredit($this->mid, 'add_event');
         // $this->assign('jumpUrl',U('/Index/eventDetail',array('id'=>$addId,'uid'=>$this->mid)));
         // $this->success($this->appName.'添加成功');
         $res['id'] = $addId;
         $res['uid'] = $this->mid;
         exit($this->ajaxReturn($res, $this->appName . '发布成功', 1));
     } else {
         $this->error($this->appName . '添加失败');
     }
 }
Example #6
0
 public function filterCategory()
 {
     $category = t($_POST['name']);
     echo keyWordFilter($category);
 }
Example #7
0
 public function sendToWeibo()
 {
     $_REQUEST['with_new_weibo'] = intval($_REQUEST['with_new_weibo']);
     $_REQUEST['type'] = t($_REQUEST['type']);
     $_REQUEST['appid'] = intval($_REQUEST['appid']);
     $_REQUEST['comment'] = $_REQUEST['comment'];
     $_REQUEST['to_id'] = intval($_REQUEST['to_id']);
     $_REQUEST['author_uid'] = intval($_REQUEST['author_uid']);
     $_REQUEST['title'] = t(html_entity_decode($_REQUEST['title'], ENT_QUOTES));
     $_REQUEST['url'] = urldecode($_REQUEST['url']);
     $_REQUEST['table'] = t($_REQUEST['table']);
     $_REQUEST['id_field'] = t($_REQUEST['id_field']);
     $_REQUEST['comment_count_field'] = t($_REQUEST['comment_count_field']);
     $app_alias = getAppAlias($_REQUEST['type']);
     // 被回复内容
     $former_comment = array();
     if ($_REQUEST['to_id'] > 0) {
         $former_comment = M('comment')->where("`id`='{$_REQUEST['to_id']}'")->find();
     }
     // 插入新数据
     $map['type'] = $_REQUEST['type'];
     // 应用名
     $map['appid'] = $_REQUEST['appid'];
     $map['appuid'] = $_REQUEST['author_uid'];
     $map['uid'] = $this->mid;
     $map['comment'] = t(getShort($_REQUEST['comment'], $GLOBALS['ts']['site']['length']));
     $map['cTime'] = time();
     $map['toId'] = $_REQUEST['to_id'];
     $map['status'] = 0;
     // 0: 未读 1:已读
     $map['quietly'] = 0;
     $map['to_uid'] = $former_comment['uid'] ? $former_comment['uid'] : $_REQUEST['author_uid'];
     $map['data'] = serialize(array('title' => keyWordFilter($_REQUEST['title']), 'url' => $_REQUEST['url'], 'table' => $_REQUEST['table'], 'id_field' => $_REQUEST['id_field'], 'comment_count_field' => $_REQUEST['comment_count_field']));
     $res = M('comment')->add($map);
     // 避免命名冲突
     unset($map['data']);
     if ($res) {
         // 发表分享
         if ($_REQUEST['with_new_weibo']) {
             $from_data = array('app_type' => 'local_app', 'app_name' => $_REQUEST['type'], 'title' => $_REQUEST['title'], 'url' => $_REQUEST['url']);
             $from_data = serialize($from_data);
             D('Weibo', 'weibo')->publish($this->mid, array('content' => html_entity_decode($_REQUEST['comment'] . ($_REQUEST['to_id'] > 0 ? ' //@' . getUserName($former_comment['uid']) . ' :' . $former_comment['comment'] : ''), ENT_QUOTES)), 0, 0, '', '', $from_data);
         }
         // 组装结果集
         $result = $map;
         $result['data']['uavatar'] = getUserSpace($this->mid, 'null', '_blank', '{uavatar}');
         $result['data']['uspace'] = getUserSpace($this->mid, 'null', '_blank', '{uname}');
         //$result['data']['comment']        = $_REQUEST['comment'];
         $result['data']['ctime'] = L('just_now');
         $result['data']['uname'] = getUserName($this->mid);
         $result['data']['comment'] = formatComment(t($_REQUEST['comment']));
         $result['data']['id'] = $res;
         $result['data']['userGroupIcon'] = getUserGroupIcon($this->mid);
         $result['data']['del_state'] = 1;
         return json_encode($result);
     } else {
         echo -1;
     }
 }