当前位置: 首页>>代码示例>>PHP>>正文


PHP get_str_length函数代码示例

本文整理汇总了PHP中get_str_length函数的典型用法代码示例。如果您正苦于以下问题:PHP get_str_length函数的具体用法?PHP get_str_length怎么用?PHP get_str_length使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_str_length函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: index

 public function index()
 {
     if (isset($_POST['editsubmit'])) {
         $group['name'] = h(t($_POST['name']));
         $group['intro'] = h(t($_POST['intro']));
         $group['cid0'] = intval($_POST['cid0']);
         // intval($_POST['cid1']) > 0	&& $group['cid1']  = intval($_POST['cid1']);
         $cid1 = D('Category')->_digCateNew($_POST);
         intval($cid1) > 0 && ($group['cid1'] = intval($cid1));
         if (!$group['name']) {
             $this->error('群组名称不能为空');
         } else {
             if (get_str_length($group['name']) > 30) {
                 $this->error('群组名称不能超过30个字');
             }
         }
         if (D('Category')->getField('id', 'name=' . $group['name'])) {
             $this->error('请选择群分类');
         }
         if (get_str_length($group['intro']) > 200) {
             $this->error('群组简介请不要超过200个字');
         }
         // 			if (!preg_replace("/[,\s]*/i", '', $_POST['tags']) || count(array_filter(explode(',', $_POST['tags']))) > 5) {
         // 				$this->error('标签不能为空或者不要超过5个');
         // 			}
         if ($_FILES['logo']['size'] > 0 && is_image_file($_FILES['logo']['name'])) {
             // 群组LOGO
             $options['allow_exts'] = 'jpg,gif,png,jpeg,bmp';
             $options['max_size'] = 2 * 1024 * 1024;
             $options['attach_type'] = 'group_logo';
             $data['upload_type'] = 'image';
             $info = model('Attach')->upload($data, $options);
             if ($info['status']) {
                 $group['logo'] = $info['info'][0]['save_path'] . $info['info'][0]['save_name'];
             }
         }
         $res = $this->group->where('id=' . $this->gid)->save($group);
         if ($res !== false) {
             D('Log')->writeLog($this->gid, $this->mid, '修改群组基本信息', 'setting');
             /* 	// 更新群组标签
             				D('GroupTag')->setGroupTag($_POST['tags'], $this->gid); */
             $this->assign('jumUrl', U('group/Manage/index', array('gid' => $this->gid)));
             $this->success('保存成功');
         }
         $this->error('保存失败');
     }
     //dump($this->groupinfo['tags']);exit;
     // 群组标签
     // 		foreach ($this->groupinfo['tags'] as $v) {
     // 			$_group_tags[] = $v['name'];
     // 		}
     // 		$this->assign('group_tags', implode(',', $_group_tags));
     // 		$this->assign('reTags', D('GroupTag')->getHotTags('recommend'));
     $this->assign('current', 'basic');
     $this->display();
 }
开发者ID:lyhiving,项目名称:icampus,代码行数:56,代码来源:ManageAction.class.php

示例2: sendFeeedback

 /**
  * 提交反馈信息
  *
  * @reuqest int $uid [null] 可为空,默认从token中读取
  * @reuqest string $content 反馈内容,不能为空
  * @return array
  * @author Medz Seven <lovevipdsw@vip.qq.com>
  **/
 public function sendFeeedback()
 {
     $uid = intval($_REQUEST['uid']);
     $uid or $uid = $this->mid;
     $content = t($_REQUEST['content']);
     /* # 检查是否有uid */
     if (!$uid) {
         $this->error(array('status' => 0, 'msg' => '缺少用户UID'));
         /* # 检查是否有反馈内容 */
     } elseif (!$content) {
         $this->error(array('status' => -1, 'msg' => '请输入反馈内容'));
         /* # 检查内容是否超出 */
     } elseif (get_str_length($content) > 500) {
         $this->error(array('status' => -2, 'msg' => '反馈长度超出最大小指500字'));
     }
     /* # 添加反馈,和错误提示 */
     model('Feedback')->add(1, $content, $uid) or $this->error(array('status' => -3, 'msg' => '反馈失败!'));
     /* # 反馈成功 */
     return array('status' => 1, 'msg' => '反馈成功');
 }
开发者ID:songhongyu,项目名称:THINKSNS,代码行数:28,代码来源:SystemApi.class.php

示例3: addVote

 /**
  * addVote
  * 添加投票
  * @param mixed $data
  * @param mixed $opt
  * @access public
  * @return void
  */
 public function addVote($data, $opt)
 {
     $deadline = $data['deadline'];
     if ($deadline < time()) {
         throw new ThinkException('投票截止时间不能早于发起投票的时间!');
     }
     //检测选项是否重复
     $opt_test = array_filter($opt);
     foreach ($opt as $value) {
         if (get_str_length($value) > 200) {
             throw new ThinkException("投票选项不能超过200个字符");
         }
     }
     $opt_test_count = count(array_unique($opt_test));
     if ($opt_test_count < count($opt_test)) {
         throw new ThinkException('投票不允许有重复项');
     }
     $vote_id = $this->add($data);
     if ($vote_id) {
         $voteUser = D("VoteUser");
         $voteUser->uid = $data['uid'];
         $voteUser->vote_id = $vote_id;
         $voteUser->cTime = time();
         $voteUser->add();
         //选项表
         $optDao = D("VoteOpt");
         foreach ($_POST["opt"] as $v) {
             if (!$v) {
                 continue;
             }
             $data["vote_id"] = $vote_id;
             $data["name"] = t($v);
             $add = $optDao->add($data);
         }
     }
     return $vote_id;
 }
开发者ID:lyhiving,项目名称:icampus,代码行数:45,代码来源:VoteModel.class.php

示例4: put

 /**
  * 添加分享
  * @param integer $uid 操作用户ID
  * @param string $app 分享应用类型,默认为public
  * @param string $type 分享类型,
  * @param array $data 分享相关数据
  * @param integer $app_id 应用资源ID,默认为0
  * @param string $app_table 应用资源表名,默认为feed
  * @param array  $extUid 额外用户ID,默认为null
  * @param array $lessUids 去除的用户ID,默认为null
  * @param boolean $isAtMe 是否为进行发送,默认为true
  * @return mix 添加失败返回false,成功返回新的分享ID
  */
 public function put($uid, $app = 'group', $type = '', $data = array(), $app_id = 0, $app_table = 'group_feed', $extUid = null, $lessUids = null, $isAtMe = true, $is_repost = 0)
 {
     // 判断数据的正确性
     if (!$uid || $type == '') {
         return false;
     }
     if (strpos($type, 'postvideo') !== false) {
         $type = 'postvideo';
     }
     //分享类型合法性验证 - 临时解决方案
     if (!in_array($type, array('post', 'repost', 'postvideo', 'postfile', 'postimage'))) {
         $type = 'post';
     }
     // //应用类型验证 用于分享框 - 临时解决方案
     // if ( !in_array( $app , array('public','weiba','tipoff') ) ){
     //     $app = 'public';
     //     $type = 'post';
     //     $app_table = 'feed';
     // }
     $app_table = strtolower($app_table);
     // 添加feed表记录
     $data['gid'] = $data['gid'];
     $data['uid'] = $uid;
     $data['app'] = $app;
     $data['type'] = $type;
     $data['app_row_id'] = $app_id;
     $data['app_row_table'] = $app_table;
     $data['publish_time'] = time();
     $data['from'] = isset($data['from']) ? intval($data['from']) : getVisitorClient();
     $data['is_del'] = $data['comment_count'] = $data['repost_count'] = 0;
     $data['is_repost'] = $is_repost;
     //判断是否先审后发
     //         $weiboSet = model('Xdata')->get('admin_Config:feed');
     //         $weibo_premission = $weiboSet['weibo_premission'];
     //         if(in_array('audit',$weibo_premission) || CheckPermission('core_normal','feed_audit')){
     //             $data['is_audit'] = 0;
     //         }else{
     $data['is_audit'] = 1;
     //         }
     // 分享内容处理
     if (Addons::requireHooks('weibo_publish_content')) {
         Addons::hook("weibo_publish_content", array(&$data));
     } else {
         // 拼装数据,如果是评论再转发、回复评论等情况,需要额外叠加对话数据
         $data['body'] = str_replace(SITE_URL, '[SITE_URL]', preg_html($data['body']));
         // 获取用户发送的内容,仅仅以//进行分割
         $scream = explode('//', $data['body']);
         // 截取内容信息为分享内容字数 - 重点
         $feedConf = model('Xdata')->get('admin_Config:feed');
         $feedNums = $feedConf['weibo_nums'];
         $body = array();
         foreach ($scream as $value) {
             $tbody[] = $value;
             $bodyStr = implode('//', $tbody);
             if (get_str_length($bodyStr) > $feedNums) {
                 break;
             }
             $body[] = $value;
             unset($bodyStr);
         }
         $data['body'] = implode('//', $body);
         // 获取用户发布内容
         $data['content'] = trim($scream[0]);
     }
     //分享到分享的应用资源,加入原资源链接
     $data['body'] .= $data['source_url'];
     $data['content'] .= $data['source_url'];
     // 分享类型插件钩子
     // if($type){
     //  $addonsData = array();
     //  Addons::hook("weibo_type",array("typeId"=>$type,"typeData"=>$type_data,"result"=>&$addonsData));
     //  $data = array_merge($data,$addonsData);
     // }
     if ($type == 'postvideo') {
         $typedata = model('Video')->_weiboTypePublish($_POST['videourl']);
         if ($typedata && $typedata['flashvar'] && $typedata['flashimg']) {
             $data = array_merge($data, $typedata);
         } else {
             $data['type'] = 'post';
         }
     }
     // 添加分享信息
     $feed_id = $this->data($data)->add();
     if (!$feed_id) {
         return false;
     }
     //         if(!$data['is_audit']){
//.........这里部分代码省略.........
开发者ID:omusico,项目名称:ThinkSNS-4,代码行数:101,代码来源:GroupFeedModel.class.php

示例5: editCategory

 public function editCategory()
 {
     if (isset($_POST['editSubmit'])) {
         $id = intval($_POST['id']);
         $cate['title'] = trim(t($_POST['title']));
         if (!$this->Category->getField('id', 'id=' . $id)) {
             $this->error('分类不存在!');
         }
         if (empty($cate['title'])) {
             $this->error('名称不能为空!');
         }
         if (get_str_length($cate['title']) > 25) {
             $this->error('名称不能超过25个字!');
         }
         // $pid = $cate ['pid'] = intval ( $_POST ['cid0'] ); //1级分类
         $pid = $this->Category->_digCateNew($_POST);
         $cate['pid'] = intval($pid);
         if ($pid == intval($_POST['id'])) {
             $this->error('不能选择所编辑分类为上级');
         }
         S('Cache_Group_Cate_0', null);
         S('Cache_Group_Cate_' . $pid, null);
         if ($pid != 0 && !$this->Category->getField('id', 'id=' . $pid)) {
             $this->error('父级分类错误!');
         } else {
             if ($pid == $id) {
                 $res = $this->Category->setField('title', $cate['title'], 'id=' . $id);
             } else {
                 $res = $this->Category->where("id={$id}")->save($cate);
             }
         }
         if (false !== $res) {
             S('Cache_Group_Cate_0', null);
             $this->success('操作成功!');
         } else {
             $this->error('操作失败!');
         }
     }
     $id = intval($_GET['id']);
     $category = $this->Category->where("id={$id}")->find();
     $this->assign('category', $category);
     $this->display();
 }
开发者ID:yang7hua,项目名称:hunshe,代码行数:43,代码来源:AdminAction.class.php

示例6: isValidName

 /**
  * 验证昵称内容的正确性
  * @param  string $name     输入昵称的信息
  * @param  string $old_name 原始昵称的信息
  * @return bool   是否验证成功
  */
 public function isValidName($name, $old_name = null)
 {
     // 默认不准使用的昵称
     $protected_name = array('name', 'uname', 'admin', 'profile', 'space');
     $site_config = model('Xdata')->get('admin_Config:site');
     !empty($site_config['sys_nickname']) && ($protected_name = array_merge($protected_name, explode(',', $site_config['sys_nickname'])));
     if (in_array($name, $protected_name)) {
         $this->_error = L('PUBLIC_NICKNAME_RESERVED');
         // 抱歉,该昵称不允许被使用
         return false;
     }
     //不能为手机号格式
     $phone_reg = preg_match($this->_phone_reg, $name) !== 0;
     if ($phone_reg) {
         $this->_error = '用户名不能为手机号格式';
         return false;
     }
     //其他格式
     $res = preg_match($this->_name_reg, $name) !== 0;
     if ($res) {
         $length = get_str_length($name);
         $res = $length >= 2 && $length <= 10;
         if (!$res) {
             $this->_error = L('PUBLIC_NICKNAME_LIMIT', array('nums' => '2-10'));
             // 昵称长度必须在2-10个汉字之间
             return false;
         }
     } else {
         $this->_error = '昵称仅支持中英文,数字,下划线';
         return false;
     }
     $old_user = \Ts\Models\User::existent()->byUserName($old_name)->first();
     $user = \Ts\Models\User::existent()->byUserName($name)->first();
     if ($name != $old_name && $old_name && $user && $old_user->uid != $user->uid) {
         $this->_error = '该用户名已经存在。';
         return false;
     }
     //敏感词
     if (filter_keyword($name) !== $name) {
         $this->_error = '抱歉,该昵称包含敏感词不允许被使用';
         return false;
     }
     return true;
 }
开发者ID:boxshadow,项目名称:ThinkSNS-4,代码行数:50,代码来源:RegisterModel.class.php

示例7: isValidName

 /**
  * 验证昵称内容的正确性
  * @param string $name 输入昵称的信息
  * @param string $old_name 原始昵称的信息
  * @return boolean 是否验证成功
  */
 public function isValidName($name, $old_name = null)
 {
     // 默认不准使用的昵称
     $protected_name = array('name', 'uname', 'admin', 'profile', 'space');
     $site_config = model('Xdata')->get('admin_Config:site');
     !empty($site_config['sys_nickname']) && ($protected_name = array_merge($protected_name, explode(',', $site_config['sys_nickname'])));
     $res = preg_match($this->_name_reg, $name) !== 0;
     if ($res) {
         $length = get_str_length($name);
         $res = $length >= 2 && $length <= 10;
     } else {
         $this->_error = '仅支持中英文,数字,下划线';
         $res = false;
         return $res;
     }
     // 预保留昵称
     if (in_array($name, $protected_name)) {
         $this->_error = L('PUBLIC_NICKNAME_RESERVED');
         // 抱歉,该昵称不允许被使用
         $res = false;
         return $res;
     }
     if (!$res) {
         $this->_error = L('PUBLIC_NICKNAME_LIMIT', array('nums' => '2-10'));
         // 昵称长度必须在2-10个汉字之间
         return $res;
     }
     if ($name != $old_name && $this->_user_model->where('`uname`="' . mysql_escape_string($name) . '"')->find()) {
         $this->_error = L('PUBLIC_ACCOUNT_USED');
         // 该用户名已被使用
         $res = false;
     }
     // 敏感词
     if (filter_keyword($name) !== $name) {
         $this->_error = '抱歉,该昵称包含敏感词不允许被使用';
         return false;
     }
     return $res;
 }
开发者ID:yang7hua,项目名称:hunshe,代码行数:45,代码来源:RegisterModel.class.php

示例8: doPost

 /**
  * 执行发布帖子
  * @return void
  */
 public function doPost()
 {
     if ($_GET['post_type'] == 'index') {
         $type = false;
     } else {
         $type = true;
     }
     $weibaid = intval($_POST['weiba_id']);
     if (!CheckPermission('weiba_normal', 'weiba_post')) {
         $this->error('对不起,您没有权限进行该操作!', $type);
     }
     $is_lock = M('weiba_blacklist')->where('weiba_id=' . $weibaid . ' and uid=' . $this->mid)->find();
     if ($is_lock) {
         $this->error('您是黑名单用户没有发帖权限', $type);
     }
     $weibaid = intval($_POST['weiba_id']);
     if (!$weibaid) {
         $this->error('请选择微吧,等待返回选择微吧', $type);
     }
     $weiba = D('weiba')->where('weiba_id=' . $weibaid)->find();
     //黑名单功能添加
     if (!CheckPermission('core_admin', 'admin_login')) {
         switch ($weiba['who_can_post']) {
             case 1:
                 $map['weiba_id'] = $weibaid;
                 $map['follower_uid'] = $this->mid;
                 $res = D('weiba_follow')->where($map)->find();
                 if (!$res && !CheckPermission('core_admin', 'admin_login')) {
                     $this->error('对不起,您没有发帖权限,请关注该微吧!', $type);
                 }
                 break;
             case 2:
                 $map['weiba_id'] = $weibaid;
                 $map['level'] = array('in', '2,3');
                 $weiba_admin = D('weiba_follow')->where($map)->order('level desc')->field('follower_uid')->findAll();
                 if (!in_array($this->mid, getSubByKey($weiba_admin, 'follower_uid')) && !CheckPermission('core_admin', 'admin_login')) {
                     $this->error('对不起,您没有发帖权限,仅限该吧管理员发帖!', $type);
                 }
                 break;
             case 3:
                 $map['weiba_id'] = $weibaid;
                 $map['level'] = 3;
                 $weiba_admin = D('weiba_follow')->where($map)->order('level desc')->field('follower_uid')->find();
                 if ($this->mid != $weiba_admin['follower_uid'] && !CheckPermission('core_admin', 'admin_login')) {
                     $this->error('对不起,您没有发帖权限,仅限该吧吧主发帖!', $type);
                 }
                 break;
         }
     }
     $checkContent = str_replace('&nbsp;', '', $_POST['content']);
     $checkContent = str_replace('<br />', '', $checkContent);
     $checkContent = str_replace('<p>', '', $checkContent);
     $checkContent = str_replace('</p>', '', $checkContent);
     $checkContents = preg_replace('/<img(.*?)src=/i', 'img', $checkContent);
     $checkContents = preg_replace('/<embed(.*?)src=/i', 'img', $checkContents);
     if (strlen(t($_POST['title'])) == 0) {
         $this->error('帖子标题不能为空,等待返回添加标题', $type);
     }
     if (strlen(t($checkContents)) == 0) {
         $this->error('帖子内容不能为空,等待返回添加内容', $type);
     }
     preg_match_all('/./us', t($_POST['title']), $match);
     if (count($match[0]) > 25) {
         //汉字和字母都为一个字
         $this->error('帖子标题不能超过25个字,等待返回修改标题', $type);
     }
     /* # 帖子内容 */
     $content = h($_POST['content']);
     if (get_str_length($content) >= 20000) {
         $this->error('帖子内容过长!无法发布!');
     }
     unset($content);
     if ($_POST['attach_ids']) {
         $attach = explode('|', $_POST['attach_ids']);
         foreach ($attach as $k => $a) {
             if (!$a) {
                 unset($attach[$k]);
             }
         }
         $attach = array_map('intval', $attach);
         $data['attach'] = serialize($attach);
     }
     $data['weiba_id'] = $weibaid;
     $data['title'] = t($_POST['title']);
     $data['content'] = h($_POST['content']);
     $data['post_uid'] = $this->mid;
     $data['post_time'] = time();
     $data['last_reply_uid'] = $this->mid;
     $data['last_reply_time'] = $data['post_time'];
     $filterTitleStatus = filter_words($data['title']);
     if (!$filterTitleStatus['status']) {
         $this->error($filterTitleStatus['data'], $type);
     }
     $data['title'] = $filterTitleStatus['data'];
     $filterContentStatus = filter_words($data['content']);
     if (!$filterContentStatus['status']) {
//.........这里部分代码省略.........
开发者ID:songhongyu,项目名称:THINKSNS,代码行数:101,代码来源:IndexAction.class.php

示例9: tags_filter

/**
 * 标签安全过滤
 * 长度不超过20
 */
function tags_filter($tag)
{
    //过滤敏感词  纯文本  限制汉字8个  英文16个
    //过滤标点符号(除了-与&)
    static $filter_symbol = null;
    if ($filter_symbol == null) {
        //第一次
        $filter_symbol = array('~', '!', '@', '#', '$', '%', '^', '*', '(', ')', '_', '+', '{', '}', '|', ':', '"', '<', '>', '?', '.', '`', '=', '[', ']', '\\', ';', '\'', ',', '.', '/', '!', '¥', '……', '…', ':', '“', '”', '《', '》', '?', ',', '。', ';', '‘', '’', '【', '】');
    }
    $tag = t($tag);
    $tag = str_replace($filter_symbol, '', $tag);
    $tag = filter_keyword(t($tag));
    return get_str_length($tag) > 8 ? getShort($tag, 8) : $tag;
}
开发者ID:jasonjiang123,项目名称:shuijian,代码行数:18,代码来源:common.php

示例10: formatFeedContent

 /**
  * 截取微博内容,将微博中的URL替换成{ts_urlX}进行字符数目统计
  * @param string $content 微博内容
  * @param string $weiboNums 微博截取数目,默认为0
  * @return array 格式化后的微博内容,body与content
  */
 public function formatFeedContent($content, $weiboNums = 0)
 {
     // 拼装数据,如果是评论再转发、回复评论等情况,需要额外叠加对话数据
     $content = str_replace(SITE_URL, '[SITE_URL]', preg_html($content));
     // 格式化微博信息 - URL
     $content = preg_replace_callback('/((?:https?|mailto|ftp):\\/\\/([^\\x{2e80}-\\x{9fff}\\s<\'\\"“”‘’,。}]*)?)/u', '_format_feed_content_url_length', $content);
     $replaceHash = $GLOBALS['replaceHash'];
     unset($GLOBALS['replaceHash']);
     // 获取用户发送的内容,仅仅以//进行分割
     $scream = explode('//', $content);
     // 截取内容信息为微博内容字数 - 重点
     $feedNums = 0;
     if (empty($weiboNums)) {
         $feedConf = model('Xdata')->get('admin_Config:feed');
         $feedNums = $feedConf['weibo_nums'];
     } else {
         $feedNums = $weiboNums;
     }
     $body = array();
     // 还原URL操作
     $patterns = array_keys($replaceHash);
     $replacements = array_values($replaceHash);
     foreach ($scream as $value) {
         $tbody[] = $value;
         $bodyStr = implode('//', $tbody);
         if (get_str_length(ltrim($bodyStr)) > $feedNums) {
             break;
         }
         $body[] = str_replace($patterns, $replacements, $value);
         unset($bodyStr);
     }
     $data['body'] = implode('//', $body);
     // 获取用户发布内容
     $scream[0] = str_replace($patterns, $replacements, $scream[0]);
     $data['content'] = trim($scream[0]);
     return $data;
 }
开发者ID:yang7hua,项目名称:hunshe,代码行数:43,代码来源:FeedModel.class.php

示例11: doSaveProfile

 /**
  * 保存基本信息操作
  *
  * @return json 返回操作后的JSON信息数据
  */
 public function doSaveProfile()
 {
     $res = true;
     // 保存用户表信息
     if (!empty($_POST['sex'])) {
         $save['sex'] = 1 == intval($_POST['sex']) ? 1 : 2;
         // $save['lang'] = t($_POST['lang']);
         $save['intro'] = t($_POST['intro']);
         /* # 检查用户简介是否超出字数限制 */
         if (get_str_length($save['intro']) > 150) {
             $this->ajaxReturn(null, '个人简介不得超过150字', 0);
         }
         // 添加地区信息
         $save['location'] = t($_POST['city_names']);
         $cityIds = t($_POST['city_ids']);
         $cityIds = explode(',', $cityIds);
         /* if (! $cityIds [0] || ! $cityIds [1] || ! $cityIds [2])
            $this->error ( '请选择完整地区' ); */
         isset($cityIds[0]) && ($save['province'] = intval($cityIds[0]));
         if ($_POST['input_city'] != '') {
             $save['input_city'] = t($_POST['input_city']);
             $save['city'] = 0;
             $save['area'] = 0;
         } else {
             isset($cityIds[1]) && ($save['city'] = intval($cityIds[1]));
             isset($cityIds[2]) && ($save['area'] = intval($cityIds[2]));
         }
         // 修改用户昵称
         $uname = t($_POST['uname']);
         $oldName = t($_POST['old_name']);
         $save['uname'] = filter_keyword($uname);
         $res = model('Register')->isValidName($uname, $oldName);
         if (!$res) {
             $error = model('Register')->getLastError();
             return $this->ajaxReturn(null, model('Register')->getLastError(), $res);
         }
         // 如果包含中文将中文翻译成拼音
         if (preg_match('/[\\x7f-\\xff]+/', $save['uname'])) {
             // 昵称和呢称拼音保存到搜索字段
             $save['search_key'] = $save['uname'] . ' ' . model('PinYin')->Pinyin($save['uname']);
         } else {
             $save['search_key'] = $save['uname'];
         }
         /* 用户首字母 */
         $save['first_letter'] = getShortPinyin($save['uname']);
         $res = model('User')->where("`uid`={$this->mid}")->save($save);
         $res && model('User')->cleanCache($this->mid);
         $user_feeds = model('Feed')->where('uid=' . $this->mid)->field('feed_id')->findAll();
         if ($user_feeds) {
             $feed_ids = getSubByKey($user_feeds, 'feed_id');
             model('Feed')->cleanCache($feed_ids, $this->mid);
         }
     }
     // 保存用户资料配置字段
     false !== $res && ($res = $this->_profile_model->saveUserProfile($this->mid, $_POST));
     // 保存用户标签信息
     $tagIds = t($_REQUEST['user_tags']);
     // 注册配置信息
     $this->_config = model('Xdata')->get('admin_Config:register');
     if (!empty($tagIds)) {
         $tagIds = explode(',', $tagIds);
         $rowId = intval($this->mid);
         if (!empty($rowId)) {
             $registerConfig = model('Xdata')->get('admin_Config:register');
             if (count($tagIds) > $registerConfig['tag_num']) {
                 return $this->ajaxReturn(null, '最多只能设置' . $registerConfig['tag_num'] . '个标签', false);
             }
             model('Tag')->setAppName('public')->setAppTable('user')->updateTagData($rowId, $tagIds);
         }
     } else {
         if (empty($tagIds) && isset($_REQUEST['user_tags'])) {
             return $this->ajaxReturn(null, '请至少选择一个标签', false);
         }
     }
     $result = $this->ajaxReturn(null, $this->_profile_model->getError(), $res);
     return $this->ajaxReturn(null, $this->_profile_model->getError(), $res);
 }
开发者ID:heroforroose,项目名称:ThinkSNS-4,代码行数:82,代码来源:AccountAction.class.php

示例12: doPost

 /**
  * 执行发布帖子
  * @return void
  */
 public function doPost()
 {
     if ($_GET['post_type'] == 'index') {
         $type = false;
     } else {
         $type = true;
     }
     $weibaid = intval($_POST['weiba_id']);
     if (!CheckPermission('weiba_normal', 'weiba_post')) {
         $this->error('对不起,您没有权限进行该操作!', $type);
     }
     $is_lock = M('weiba_blacklist')->where('weiba_id=' . $weibaid . ' and uid=' . $this->mid)->find();
     if ($is_lock) {
         $this->error('您是黑名单用户没有发帖权限', $type);
     }
     $weibaid = intval($_POST['weiba_id']);
     if (!$weibaid) {
         $this->error('请选择微吧,等待返回选择微吧', $type);
     }
     $weiba = D('weiba')->where('weiba_id=' . $weibaid)->find();
     //黑名单功能添加
     if (!CheckPermission('core_admin', 'admin_login')) {
         switch ($weiba['who_can_post']) {
             case 1:
                 $map['weiba_id'] = $weibaid;
                 $map['follower_uid'] = $this->mid;
                 $res = D('weiba_follow')->where($map)->find();
                 if (!$res && !CheckPermission('core_admin', 'admin_login')) {
                     $this->error('对不起,您没有发帖权限,请关注该微吧!', $type);
                 }
                 break;
             case 2:
                 $map['weiba_id'] = $weibaid;
                 $map['level'] = array('in', '2,3');
                 $weiba_admin = D('weiba_follow')->where($map)->order('level desc')->field('follower_uid')->findAll();
                 if (!in_array($this->mid, getSubByKey($weiba_admin, 'follower_uid')) && !CheckPermission('core_admin', 'admin_login')) {
                     $this->error('对不起,您没有发帖权限,仅限该吧管理员发帖!', $type);
                 }
                 break;
             case 3:
                 $map['weiba_id'] = $weibaid;
                 $map['level'] = 3;
                 $weiba_admin = D('weiba_follow')->where($map)->order('level desc')->field('follower_uid')->find();
                 if ($this->mid != $weiba_admin['follower_uid'] && !CheckPermission('core_admin', 'admin_login')) {
                     $this->error('对不起,您没有发帖权限,仅限该吧吧主发帖!', $type);
                 }
                 break;
         }
     }
     $checkContent = str_replace('&nbsp;', '', $_POST['content']);
     $checkContent = str_replace('<br />', '', $checkContent);
     $checkContent = str_replace('<p>', '', $checkContent);
     $checkContent = str_replace('</p>', '', $checkContent);
     $checkContents = preg_replace('/<img(.*?)src=/i', 'img', $checkContent);
     $checkContents = preg_replace('/<embed(.*?)src=/i', 'img', $checkContents);
     if (strlen(t($_POST['title'])) == 0) {
         $this->error('帖子标题不能为空,等待返回添加标题', $type);
     }
     if (strlen(t($checkContents)) == 0) {
         $this->error('帖子内容不能为空,等待返回添加内容', $type);
     }
     preg_match_all('/./us', t($_POST['title']), $match);
     if (count($match[0]) > 25) {
         //汉字和字母都为一个字
         $this->error('帖子标题不能超过25个字,等待返回修改标题', $type);
     }
     /* # 帖子内容 */
     $content = h($_POST['content']);
     if (get_str_length($content) >= 20000) {
         $this->error('帖子内容过长!无法发布!');
     }
     unset($content);
     if ($_POST['attach_ids']) {
         $attach = explode('|', $_POST['attach_ids']);
         foreach ($attach as $k => $a) {
             if (!$a) {
                 unset($attach[$k]);
             }
         }
         $attach = array_map('intval', $attach);
         $data['attach'] = serialize($attach);
     }
     $data['weiba_id'] = $weibaid;
     $data['title'] = t($_POST['title']);
     $data['content'] = h($_POST['content']);
     $data['post_uid'] = $this->mid;
     $data['post_time'] = time();
     $data['last_reply_uid'] = $this->mid;
     $data['last_reply_time'] = $data['post_time'];
     $filterTitleStatus = filter_words($data['title']);
     if (!$filterTitleStatus['status']) {
         $this->error($filterTitleStatus['data'], $type);
     }
     $data['title'] = $filterTitleStatus['data'];
     $filterContentStatus = filter_words($data['content']);
     if (!$filterContentStatus['status']) {
//.........这里部分代码省略.........
开发者ID:jacyxie,项目名称:xindongfang,代码行数:101,代码来源:IndexAction.class.php

示例13: getShort

&nbsp;&nbsp;发表在 <a href="<?php 
    echo $sourceInfo['weiba_url'];
    ?>
" target="_blank" class=""><?php 
    echo $sourceInfo['weiba_name'];
    ?>
</a><!--来自网站--></em></span>
  			<p class="txt-mt" onclick="core.weibo.clickRepost(this);" href="<?php 
    echo $sourceInfo['source_url'];
    ?>
"><a target="_blank" href="<?php 
    echo $sourceInfo['source_url'];
    ?>
">帖子&nbsp;|&nbsp;<?php 
    echo $sourceInfo['title'];
    ?>
</a>&nbsp;<?php 
    echo getShort($sourceInfo['content'], intval(($sourceInfo['pic_url_small'] ? 100 : 130) - get_str_length($sourceInfo['title'])), '...');
    ?>
</p>
  		</div>
    </dd>
    <?php 
} else {
    ?>
    <dd class="name">内容已被删除</dd>
    <?php 
}
?>
  </dl>
</div>
开发者ID:songhongyu,项目名称:THINKSNS,代码行数:31,代码来源:public_d9e5c6a6fcd3f287.php

示例14: getShort

<span class="title-from-source hidden"><i class="ico-weiba"></i>发表在 <a href="<?php 
echo $sourceInfo['weiba_url'];
?>
" target="_blank"><?php 
echo $sourceInfo['weiba_name'];
?>
</a></span>
<div class="contents clearfix">
		<p><a target="_blank" href="<?php 
echo $sourceInfo['source_url'];
?>
">帖子&nbsp;|&nbsp;<?php 
echo $sourceInfo['title'];
?>
</a>&nbsp;<?php 
echo getShort($sourceInfo['content'], intval(110 - get_str_length($sourceInfo['title'])), '...');
?>
</a></p>
    <?php 
if (!empty($sourceInfo['pic_url'])) {
    ?>
    <div class="feed_img_lists">
    	<ul class="small">
        	<li style="width: 205px; height: auto;">
            	<a target="_blank" href="<?php 
    echo $sourceInfo['source_url'];
    ?>
"><img onload="/*仅标签上有效,待改进*/;var li=$(this).parents('li');if(li.height()>300){li.css('height','300px');li.find('.pic-btm').show();}" class="imgicon" src="<?php 
    echo $sourceInfo['pic_url_medium'];
    ?>
" style="cursor:pointer" /></a>		
开发者ID:songhongyu,项目名称:THINKSNS,代码行数:31,代码来源:public_8b81386da7587460.php

示例15: __checkContent

 private function __checkContent($content, $mix = 5, $max = 5000)
 {
     $content_length = get_str_length($content, true);
     if (0 == $content_length) {
         $this->error('内容不能为空');
     } else {
         if ($content_length < $mix) {
             $this->error('内容不能少于' . $mix . '个字');
         } else {
             if ($content_length > $max) {
                 $this->error('内容不能超过' . $max . '个字');
             }
         }
     }
 }
开发者ID:lyhiving,项目名称:icampus,代码行数:15,代码来源:TopicAction.class.php


注:本文中的get_str_length函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。