hook() public static method

调用插件Hook
public static hook ( string $name, array $param = [] )
$name string 钩子名称
$param array 相关参数
示例#1
0
 /**
  * 架构函数
  * @param boolean $location 是否本机调用,本机调用不需要认证
  * @return void
  */
 public function __construct($location = false)
 {
     //$this->mid = $_SESSION['mid'];
     //外部接口调用
     if ($location == false && !defined('DEBUG')) {
         $this->verifyUser();
         //本机调用
     } else {
         $this->mid = @intval($_SESSION['mid']);
     }
     $GLOBALS['ts']['mid'] = $this->mid;
     //默认参数处理
     $this->since_id = isset($_REQUEST['since_id']) ? intval($_REQUEST['since_id']) : '';
     $this->max_id = isset($_REQUEST['max_id']) ? intval($_REQUEST['max_id']) : '';
     $this->page = isset($_REQUEST['page']) ? intval($_REQUEST['page']) : 1;
     $this->count = isset($_REQUEST['count']) ? intval($_REQUEST['count']) : 20;
     $this->user_id = isset($_REQUEST['user_id']) ? intval($_REQUEST['user_id']) : 0;
     $this->user_name = isset($_REQUEST['user_name']) ? h($_REQUEST['user_name']) : '';
     $this->uid = isset($_REQUEST['uid']) ? intval($_REQUEST['uid']) : 0;
     $this->uname = isset($_REQUEST['uname']) ? h($_REQUEST['uname']) : '';
     $this->id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
     $this->data = $_REQUEST;
     // findPage
     $_REQUEST[C('VAR_PAGE')] = $this->page;
     //接口初始化钩子
     Addons::hook('core_filter_init_api');
     //控制器初始化
     if (method_exists($this, '_initialize')) {
         $this->_initialize();
     }
 }
示例#2
0
 /**
  * 架构函数,处理核心变量
  * 使用字符串返回 不能有任何输出
  */
 public function __construct()
 {
     //当前登录者uid
     $GLOBALS['ts']['mid'] = $this->mid = intval($_SESSION['mid']);
     //当前访问对象的uid
     $GLOBALS['ts']['uid'] = $this->uid = intval($_REQUEST['uid'] == 0 ? $this->mid : $_REQUEST['uid']);
     // 赋值当前访问者用户
     $GLOBALS['ts']['user'] = $this->user = model('User')->getUserInfo($this->mid);
     if ($this->mid != $this->uid) {
         $GLOBALS['ts']['_user'] = model('User')->getUserInfo($this->uid);
     } else {
         $GLOBALS['ts']['_user'] = $GLOBALS['ts']['user'];
     }
     //当前用户的所有已添加的应用
     $GLOBALS['ts']['_userApp'] = $userApp = model('UserApp')->getUserApp($this->uid);
     //当前用户的统计数据
     $GLOBALS['ts']['_userData'] = $userData = model('UserData')->getUserData($this->uid);
     $this->site = D('Xdata')->get('admin_Config:site');
     $this->site['logo'] = getSiteLogo($this->site['site_logo']);
     $GLOBALS['ts']['site'] = $this->site;
     //语言包判断
     if (TRUE_APPNAME != 'public' && APP_NAME != TRUE_APPNAME) {
         addLang(TRUE_APPNAME);
     }
     Addons::hook('core_filter_init_widget');
 }
示例#3
0
 var $id;
 var $data;
 private $_module_white_list = null;
 // 白名单模块
 /**
  * 架构函数
  * @param boolean $location 是否本机调用,本机调用不需要认证
  * @return void
  */
 public function __construct($location = false)
 {
     $this->_module_white_list = array('Oauth', 'Sitelist');
     //$this->mid = $_SESSION['mid'];
     //外部接口调用
     if ($location == false) {
         if (!$this->mid && !in_array(MODULE_NAME, $this->_module_white_list)) {
             $this->verifyUser();
         }
         //本机调用
     } else {
         $this->mid = $_SESSION['mid'];
     }
     $GLOBALS['ts']['mid'] = $this->mid;
     //默认参数处理
     $this->since_id = $_REQUEST['since_id'] ? intval($_REQUEST['since_id']) : '';
     $this->max_id = $_REQUEST['max_id'] ? intval($_REQUEST['max_id']) : '';
     $this->page = $_REQUEST['page'] ? intval($_REQUEST['page']) : 1;
     $this->count = $_REQUEST['count'] ? intval($_REQUEST['count']) : 20;
     $this->user_id = $_REQUEST['user_id'] ? intval($_REQUEST['user_id']) : 0;
     $this->user_name = $_REQUEST['user_name'] ? h($_REQUEST['user_name']) : '';
示例#4
0
 public function home_account_page($param)
 {
     if ($param['extend'] == 'bind') {
         $bindData = array();
         Addons::hook('account_bind_after', array('bindInfo' => &$bindData));
         $this->assign('bind', $bindData);
         $param['data'] = $this->fetch('account_bind');
     }
 }
 public function profile()
 {
     $pUserProfile = D('UserProfile');
     $pUserProfile->uid = $this->uid;
     $data['userInfo'] = $pUserProfile->getUserInfo(true);
     // 个人情况-钩子
     Addons::hook('home_space_profile_intro', array('uid' => $this->uid, 'intro' => &$data['userInfo']['intro']['list']));
     // 联系方式-钩子
     Addons::hook('home_space_profile_contact', array('uid' => $this->uid, 'contact' => &$data['userInfo']['contact']['list']));
     $this->assign($data);
     $this->setTitle('Thông tin chi tiết của ' . getUserName($this->uid));
     $this->display();
 }
 function bind()
 {
     $user = M('user')->where('uid=' . $this->mid)->field('email')->find();
     $replace = substr($user['email'], 2, -3);
     for ($i = 1; $i <= strlen($replace); $i++) {
         $replacestring .= '*';
     }
     $data['email'] = str_replace($replace, $replacestring, $user['email']);
     $bindData = array();
     Addons::hook('account_bind_after', array('bindInfo' => &$bindData));
     $data['bind'] = $bindData;
     $this->assign($data);
     $this->setTitle(L('setting') . ' - ' . L('outer_bind'));
     $this->display();
 }
示例#7
0
function getUserSpace($uid, $class, $target, $text, $icon = true)
{
    static $_userinfo = array();
    if (!isset($_userinfo[$uid])) {
        $_userinfo[$uid] = D('User', 'home')->getUserByIdentifier($uid, 'uid');
    }
    $target = $target ? $target : '_self';
    $text = $text ? $text : $_userinfo[$uid]['uname'];
    preg_match('|{(.*?)}|isU', $text, $t);
    if ($t) {
        if ($t['1'] == 'uname') {
            $text = str_replace("{uname}", $_userinfo[$uid]['uname'], $text);
            $class = $class ? $class : 'username';
        } else {
            $face = preg_replace("/{uavatar}|{uavatar\\=(.*?)}/e", "getUserFace(\$uid, '\\1')", $text);
            $text = "<img src=" . $face . ">";
            $class = $class ? $class : 'userface';
            $icon = false;
        }
    }
    if ($icon) {
        $user_name_end = null;
        Addons::hook('user_name_end', array('uid' => $uid, 'html' => &$user_name_end));
    }
    if ($_userinfo[$uid]['domain']) {
        $url = U('home/Space/index', array('uid' => $_userinfo[$uid]['domain']));
    } else {
        $url = U('home/Space/index', array('uid' => $uid));
    }
    $user_space_info = "<a href='{$url}' class='{$class}' target='{$target}'>{$text}" . $user_name_end . "</a>";
    Addons::hook('get_user_space_output', array('uid' => $uid, 'space_info' => &$user_space_info));
    return $user_space_info;
}
 private function __getWeiboList($install_app, $type)
 {
     global $ts;
     // 关注的分组列表
     $myFollowData = $this->__paramUserFollowGroup($type);
     $data = $myFollowData;
     $data['indexType'] = $indexType = intval($_GET['type']);
     $temp = $ts['my_group_list'];
     $group_list = array();
     foreach ($temp as $value) {
         if ($value['openWeibo']) {
             $group_list[] = $value;
         }
     }
     $data['group_list'] = $group_list;
     $data['gid'] = intval($_GET['gid']);
     $data['hasGroupWeibo'] = $this->__hasGroupWeibo($group_list);
     if ($indexType == self::INDEX_TYPE_WEIBO) {
         $data['weibo_menu'] = array('' => L('all'), 'original' => L('original'));
         Addons::hook('home_index_weibo_tab', array(&$data['weibo_menu']));
     }
     switch ($indexType) {
         case self::INDEX_TYPE_WEIBO:
             $data['list'] = D('Operate', 'weibo')->getHomeList($this->mid, $type, '', '', $data['follow_gid']);
             break;
         case self::INDEX_TYPE_GROUP:
             $data['list'] = D('WeiboOperate', 'group')->getHomeList($this->mid, $data['gid'], '', '');
             break;
         case self::INDEX_TYPE_ALL:
             $order = 'weibo_id DESC';
             $data['list'] = D('Operate', 'weibo')->doSearchTopic("", $order, $this->mid);
             break;
         default:
             $data['list'] = D('Operate', 'weibo')->getHomeList($this->mid, $type, '', '', $data['follow_gid']);
     }
     if ($data['list']['data']) {
         // 最新一条微博的Id (countNew时使用)
         $data['lastId'] = $data['list']['data'][0]['weibo_id'];
         $_since_weibo = end($data['list']['data']);
         $data['sinceId'] = $_since_weibo['weibo_id'];
     }
     return $data;
 }
            <input type="password" name="login_password" class="text" style=" position:absolute; z-index:100;" onfocus="$('.login_password').hide()" onblur="if(this.value=='') $('.login_password').show()" value=""/>
          </div>
          <div class="mb20"><a class="act-but submit" href="javascript:;" onclick="$('#ajax_login_form').submit();" >登录</a></div>
          <div class="clearfix mb20"> <a class="login-rm" event-node="login_remember" href="javascript:;"> <span class="check-ok">
            <input type="hidden" name="login_remember" value="0" id="check-box" class="checkbox"/>
            <!-- JS选择记住密码时要JS将login_remember值变为1 --></span>记住用户名</a> <a href="<?php 
echo U('public/Passport/findPassword');
?>
" class="login-fgetpwd">忘记密码?</a></div>
          <?php 
if (Addons::requireHooks('login_input_footer') && Addons::hook('login_input_footer')) {
    ?>
              <div class="login-ft">
                  <div class="login-ft-head">使用第三方账号登录</div>
                  <?php 
    echo Addons::hook('login_input_footer');
    ?>
              </div>
         	<?php 
}
?>
          <div class="hasno-account">
            <p>还没有帐号?</p>
            <div class="other-but"> <a  onclick="javascript:window.open('<?php 
echo U('public/Register');
?>
','_self')" class="white-but fl"><i class="arow-left"></i>去注册</a> <a href="<?php 
echo U('public/Index/index');
?>
" class="white-but fr">先看看<i class="arow-right"></i></a> </div>
          </div>
 public function render($data)
 {
     if (empty($data['feed_id']) || empty($data['feed_uid'])) {
         return '';
     }
     // 获取分享ID
     $feedId = intval($data['feed_id']);
     // 获取分享发布者UID
     $feedUid = intval($data['feed_uid']);
     // 管理员删除分享权限
     $adminfeeddel = CheckPermission('core_admin', 'feed_del');
     // 推荐到频道权限
     $feed = model('Feed')->get($data['feed_id']);
     if ($feed['is_repost'] == 1) {
         $adminchannelrecom = false;
     } else {
         $adminchannelrecom = CheckPermission('channel_admin', 'channel_recommend');
     }
     // 推荐到事务权限
     $admintaskrecom = CheckPermission('vtask_admin', 'vtask_recommend');
     // 插件显示 - 个人空间分享置顶权限
     Addons::hook('check_feed_manage', array('feed_id' => $data['feed_id'], 'uid' => $data['feed_uid'], 'plugin_list' => &$pluginList));
     $checkShowBtn = array();
     $checkShowBtn[] = $adminfeeddel;
     $checkShowBtn[] = $adminchannelrecom;
     $checkShowBtn[] = $admintaskrecom;
     !empty($pluginList) && ($checkShowBtn = array_merge($checkShowBtn, getSubByKey($pluginList, 'status')));
     // 判断是否显示管理权限
     $showBtn = true;
     if (!in_array(true, $checkShowBtn)) {
         $showBtn = false;
     }
     if (!$showBtn) {
         return '';
     }
     // 管理参数组合
     $args = array();
     $args['feed_id'] = $feedId;
     $args['uid'] = $feedUid;
     $args['is_recommend'] = $data['is_recommend'];
     $args['feed_del'] = $adminfeeddel;
     $args['feed_recommend'] = CheckPermission('core_admin', 'feed_recommend');
     $args['channel_recommend'] = $adminchannelrecom;
     $args['vtask_recommend'] = $admintaskrecom;
     foreach ($pluginList as $value) {
         $args[$value['plugin']] = $value['status'];
     }
     isset($data['channel_id']) && ($args['channel_id'] = intval($data['channel_id']));
     isset($data['clear']) && ($args['clear'] = intval($data['clear']));
     isset($data['isrefresh']) && ($args['isrefresh'] = intval($data['isrefresh']));
     $var['feed_id'] = $feedId;
     // 获取列表页面HTML
     $var['listHtml'] = $this->renderFile(dirname(__FILE__) . '/list.html', $args);
     $tmp = array();
     foreach ($args as $key => $val) {
         $tmp[] = $key . '=' . intval($val);
     }
     $eventArgs = implode('&', $tmp);
     $var['eventArgs'] = $eventArgs;
     $manageClass = isset($data['manage_class']) ? $data['manage_class'] : 'right hover dp-cs';
     $var['manageClass'] = $manageClass;
     $content = $this->renderFile(dirname(__FILE__) . '/manage.html', $var);
     return $content;
 }
示例#11
0
 /**
  * 操作成功跳转的快捷方
  * @param  string  $message 提示信息
  * @param  Boolean $ajax    是否为Ajax方
  * @return voi
  */
 protected function success($message = '', $ajax = false)
 {
     Addons::hook('core_filter_success_message', $message);
     $this->_dispatch_jump($message, 1, $ajax);
 }
 public function doaddcomment($uid, $post, $api = false)
 {
     $data['uid'] = $uid;
     $data['reply_comment_id'] = intval($post['reply_comment_id']);
     $data['weibo_id'] = intval($post['weibo_id']);
     $data['content'] = t(getShort($post['content'], $GLOBALS['ts']['site']['length']));
     $data['ctime'] = time();
     $miniInfo = D('Weibo', 'weibo')->where('weibo_id=' . $data['weibo_id'] . ' AND isdel=0')->find();
     if ($data['reply_comment_id']) {
         $replyInfo = $this->where('comment_id=' . $data['reply_comment_id'] . ' AND isdel=0')->find();
         $data['reply_uid'] = $replyInfo['uid'];
     } else {
         $data['reply_uid'] = $miniInfo['uid'];
         $notify['reply_type'] = 'weibo';
     }
     if ($comment_id = $this->addcomment($data)) {
         //微博回复积分操作
         if ($data['uid'] != $data['reply_uid']) {
             X('Credit')->setUserCredit($data['uid'], 'reply_weibo')->setUserCredit($data['reply_uid'], 'replied_weibo');
         }
         $data['comment'] = $miniInfo['comment'] + 1;
         $return['data'] = $data;
         $return['html'] = '<div class="position_list" id="comment_list_c_' . $comment_id . '"> <a href="' . U('home/space/index', array('uid' => $this->mid)) . '" class="pic">
         		<img class="pic30" src="' . getUserFace($uid, 's') . '" /></a>
                   <p class="list_c">' . getUserSpace($uid, 'fn', '', '{uname}') . getUserGroupIcon($uid) . ' : ' . formatComment($data['content'], true) . ' (刚刚)</p>
                   <div class="alR clear"><a href="javascript:void(0)" onclick="ui.confirm(this,\'确认要删除此评论?\')" callback="delComment(' . $comment_id . ')">Xóa</a>&nbsp;&nbsp;<a href="javascript:void(0)" onclick="reply(\'' . getUserName($uid) . '\',' . $data['weibo_id'] . ')">Trả lời</a></div>
                 </div>';
         if ($post['transpond'] != 0) {
             if ($miniInfo['transpond_id'] != 0) {
                 $transpondData['content'] = $data['content'] . ($data['reply_comment_id'] ? " //@" . getUserName($replyInfo['uid']) . " :" . $replyInfo['content'] : '') . " //@" . getUserName($miniInfo['uid']) . ":" . $miniInfo['content'];
                 $transpondData['transpond_id'] = $miniInfo['transpond_id'];
                 $transpondInfo = M('weibo')->where('weibo_id=' . $miniInfo['transpond_id'] . ' AND isdel=0')->find();
                 $transpondData['transpond_uid'] = $transpondInfo['uid'];
             } else {
                 $transpondData['content'] = $data['content'] . ($data['reply_comment_id'] ? " //@" . getUserName($replyInfo['uid']) . " :" . $replyInfo['content'] : '');
                 $transpondData['transpond_id'] = $miniInfo['weibo_id'];
                 $transpondData['transpond_uid'] = $miniInfo['uid'];
             }
             $id = D('Weibo', 'weibo')->doSaveWeibo($uid, $transpondData, $post['from']);
             if ($id) {
                 //当转发的微博uid 与 回复人的uid不一致时发布@到我
                 if ($transpondData['transpond_uid'] != $data['reply_uid']) {
                     D('Weibo', 'weibo')->notifyToAtme($uid, $id, $transpondData['content'], $transpondData['transpond_uid']);
                 } else {
                     D('Weibo', 'weibo')->notifyToAtme($uid, $id, $transpondData['content'], $transpondData['transpond_uid'], false);
                 }
             }
         }
         //添加统计
         if ($api) {
             if ($data['reply_uid'] != $miniInfo['uid']) {
                 Model('UserCount')->addCount($miniInfo['uid'], 'comment');
             }
         } else {
             Model('UserCount')->addCount($data['reply_uid'], 'comment');
             if ($data['reply_uid'] != $miniInfo['uid']) {
                 Model('UserCount')->addCount($miniInfo['uid'], 'comment');
             }
         }
         Addons::hook('weibo_comment_publish', array($comment_id, $data));
         if ($api) {
             return true;
         } else {
             return json_encode($return);
         }
     } else {
         return '0';
     }
 }
              </a>
              <?php 
            }
        }
        ?>
            <?php 
        if ($actions["at"] == "true") {
            if (in_array('at', $weibo_type)) {
                ?>
              <a event-node="insert_at" class="at-block" href="javascript:;" title="@某人"> <i class="at"></i>@某人</a>
              <?php 
            }
        }
        ?>
            <?php 
        echo Addons::hook('home_index_middle_publish_type', array('position' => 'index'));
        ?>
 </div>
          <div class="clear"></div>
          <div model-node ='faceDiv'></div>
        </div>
      </div>
    </div>
  </div>
</div>
<?php 
    } elseif ($GLOBALS['ts']['mid']) {
        ?>
<div class="send_weibo">
  <div class="box-purview"><div class="nologin"><i class="ico-error"></i>您没有权限发布分享</div></div>
</div>
示例#14
0
 /**
  * 添加分享
  * @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 = 'public', $type = '', $data = array(), $app_id = 0, $app_table = 'feed', $extUid = null, $lessUids = null, $isAtMe = true, $is_repost = 0)
 {
     if (isSubmitLocked()) {
         $this->error = '发布内容过于频繁,请稍后再试';
         return false;
     }
     // 判断数据的正确性
     if (!$uid || $type == '') {
         $this->error = L('PUBLIC_ADMIN_OPRETING_ERROR');
         return false;
     }
     if (strpos($type, 'postvideo') !== false) {
         $type = 'postvideo';
     }
     //分享类型合法性验证 - 临时解决方案
     $checkType = array('post', 'repost', 'postvideo', 'postfile', 'postimage', 'weiba_post', 'weiba_repost', 'long_post', 'photo_post', 'photo_repost', 'vote_post', 'vote_repost', 'event_post', 'event_repost', 'blog_post', 'blog_repost', 'poster_post', 'poster_repost');
     if (!in_array($type, $checkType)) {
         $type = 'post';
     }
     //应用类型验证 用于分享框 - 临时解决方案
     $checkApp = array('w3g', 'public', 'weiba', 'tipoff', 'photo', 'vote', 'event', 'blog', 'poster');
     if (!in_array($app, $checkApp)) {
         $app = 'public';
         $type = 'post';
         $app_table = 'feed';
     }
     $app_table = strtolower($app_table);
     // 添加feed表记录
     $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;
     //判断是否先审后发
     $filterStatus = filter_words($data['body']);
     $weiboSet = model('Xdata')->get('admin_Config:feed');
     $weibo_premission = $weiboSet['weibo_premission'];
     if (in_array('audit', $weibo_premission) || CheckPermission('core_normal', 'feed_audit') || $filterStatus['type'] == 2) {
         $data['is_audit'] = 0;
     } else {
         $data['is_audit'] = 1;
     }
     // 分享内容处理
     if (Addons::requireHooks('weibo_publish_content')) {
         Addons::hook("weibo_publish_content", array(&$data));
     } else {
         // 截取内容信息为分享内容字数 - 长分享
         //$feedConf = model('Xdata')->get('admin_Config:feed');
         //$feedNums = $feedConf['weibo_nums'];
         //if(Addons::requireHooks('show_longtext_button')){
         //	$feedNums = 20000;
         //	$data['body'] = str_replace(SITE_URL, '[SITE_URL]', $data['body']);
         //}else{
         //	$data['body'] = str_replace(SITE_URL, '[SITE_URL]', preg_html($data['body']));
         //}
         $content = $this->formatFeedContent($data['body']);
         $data['body'] = $content['body'];
         $data['content'] = $content['content'];
     }
     //分享到分享的应用资源,加入原资源链接
     $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') {
         if ($_POST['video_id']) {
             $video_info = D('video')->where('video_id=' . $data['video_id'])->find();
             $data['transfer_id'] = $video_info['transfer_id'];
             $data['video_path'] = $video_info['video_path'];
             $data['video_mobile_path'] = $video_info['video_mobile_path'];
             $data['video_part_path'] = $video_info['video_part_path'];
             $data['image_path'] = $video_info['image_path'];
             $data['image_width'] = $video_info['image_width'];
             $data['image_height'] = $video_info['image_height'];
         } else {
             $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['video_id']) {
         D('video')->where('video_id=' . $data['video_id'])->setField('feed_id', $feed_id);
         //如果有的话
         if (D('video_transfer')->where('video_id=' . $data['video_id'])->count()) {
             D('video_transfer')->where('video_id=' . $data['video_id'])->setField('feed_id', $feed_id);
         }
     }
     if (!$data['is_audit']) {
         $touid = D('user_group_link')->where('user_group_id=1')->field('uid')->findAll();
         foreach ($touid as $k => $v) {
             model('Notify')->sendNotify($v['uid'], 'feed_audit');
         }
     }
     // 目前处理方案格式化数据
     $data['content'] = str_replace(chr(31), '', $data['content']);
     $data['body'] = str_replace(chr(31), '', $data['body']);
     // 添加关联数据
     $feed_data = D('FeedData')->data(array('feed_id' => $feed_id, 'feed_data' => serialize($data), 'client_ip' => get_client_ip(), 'client_port' => get_client_port(), 'feed_content' => $data['body']))->add();
     // 添加分享成功后
     if ($feed_id && $feed_data) {
         //锁定发布
         lockSubmit();
         //分享发布成功后的钩子
         //Addons::hook("weibo_publish_after",array('weibo_id'=>$feed_id,'post'=>$data));
         // 发送通知消息 - 重点 - 需要简化把上节点的信息去掉.
         if ($data['is_repost'] == 1) {
             // 转发分享
             $isAtMe && ($content = $data['content']);
             // 内容用户
             $extUid[] = $data['sourceInfo']['transpond_data']['uid'];
             // 资源作者用户
             if ($isAtMe && !empty($data['curid'])) {
                 // 上节点用户
                 $appRowData = $this->get($data['curid']);
                 $extUid[] = $appRowData['uid'];
             }
         } else {
             // 其他分享
             $content = $data['content'];
             //更新最近@的人
             model('Atme')->updateRecentAt($content);
             // 内容用户
         }
         // 发送@消息
         model('Atme')->setAppName('Public')->setAppTable('feed')->addAtme($content, $feed_id, $extUid, $lessUids);
         $data['client_ip'] = get_client_ip();
         $data['feed_id'] = $feed_id;
         $data['feed_data'] = serialize($data);
         // 主动创建渲染后的缓存
         $return = $this->setFeedCache($data);
         $return['user_info'] = model('User')->getUserInfo($uid);
         $return['GroupData'] = model('UserGroupLink')->getUserGroupData($uid);
         //获取用户组信息
         $return['feed_id'] = $feed_id;
         $return['app_row_id'] = $data['app_row_id'];
         $return['is_audit'] = $data['is_audit'];
         // 统计数修改
         model('UserData')->setUid($uid)->updateKey('feed_count', 1);
         // if($app =='public'){ //TODO 分享验证条件
         model('UserData')->setUid($uid)->updateKey('weibo_count', 1);
         // }
         //更新附件信息
         $attach_info['app_name'] = 'public';
         $attach_info['table'] = 'feed';
         $attach_info['row_id'] = $feed_id;
         $attach_map['attach_id'] = array('IN', $data['attach_id']);
         model('Attach')->where($attach_map)->save($attach_info);
         if (!$return) {
             $this->error = L('PUBLIC_CACHE_FAIL');
             // Feed缓存写入失败
         }
         return $return;
     } else {
         $this->error = L('PUBLIC_ADMIN_OPRETING_ERROR');
         // 操作失败
         return false;
     }
 }
示例#15
0
 /**
  * 添加分享
  * @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']){
     //             $touid = D('user_group_link')->where('user_group_id=1')->field('uid')->findAll();
     //             foreach($touid as $k=>$v){
     //                 model('Notify')->sendNotify($v['uid'], 'feed_audit');
     //             }
     //         }
     // 添加关联数据
     $feed_data = D('group_feed_data')->data(array('feed_id' => $feed_id, 'feed_data' => serialize($data), 'client_ip' => get_client_ip(), 'feed_content' => $data['body']))->add();
     // 添加分享成功后
     if ($feed_id && $feed_data) {
         //分享发布成功后的钩子
         //             Addons::hook("weibo_publish_after",array('weibo_id'=>$feed_id,'post'=>$data));
         // 发送通知消息 - 重点 - 需要简化把上节点的信息去掉.
         if ($data['is_repost'] == 1) {
             // 转发分享
             $isAtMe && ($content = $data['content']);
             // 内容用户
             $extUid[] = $data['sourceInfo']['transpond_data']['uid'];
             // 资源作者用户
             if ($isAtMe && !empty($data['curid'])) {
                 // 上节点用户
                 $appRowData = $this->get($data['curid']);
                 $extUid[] = $appRowData['uid'];
             }
         } else {
             // 其他分享
             $content = $data['content'];
         }
         // 发送@消息
         D('GroupAtme')->setAppName('group')->setAppTable('group_feed')->addAtme($content, $feed_id, $extUid, $lessUids, $data['gid']);
         $data['client_ip'] = get_client_ip();
         $data['feed_id'] = $feed_id;
         $data['feed_data'] = serialize($data);
         // 主动创建渲染后的缓存
         $return = $this->setFeedCache($data);
         $return['user_info'] = model('User')->getUserInfo($uid);
         $return['GroupData'] = model('UserGroupLink')->getUserGroupData($uid);
         //获取用户组信息
         $return['feed_id'] = $feed_id;
         $return['app_row_id'] = $data['app_row_id'];
         $return['is_audit'] = $data['is_audit'];
         // 统计数修改
         //             model('UserData')->setUid($uid)->updateKey('feed_count', 1);
         // if($app =='public'){ //TODO 分享验证条件
         //                 model('UserData')->setUid($uid)->updateKey('weibo_count', 1);
         // }
         if (!$return) {
             $this->error = L('PUBLIC_CACHE_FAIL');
             // Feed缓存写入失败
         }
         return $return;
     } else {
         $this->error = L('PUBLIC_ADMIN_OPRETING_ERROR');
         // 操作失败
         return false;
     }
 }
', '<?php 
    echo $channel_id;
    ?>
', '<?php 
    echo $clear;
    ?>
');">推荐到频道</a></li>
		<?php 
}
?>
		<?php 
if ($vtask_recommend == 1) {
    ?>
		<li><a href="javascript:;" onclick="addToVtask('<?php 
    echo $feed_id;
    ?>
');">添加到事务</a></li>
		<?php 
}
?>
		<?php 
if ($feed_del == 1) {
    ?>
		<?php 
}
?>
		<?php 
echo Addons::hook('feed_manage_li', array('feed_id' => $feed_id, 'uid' => $uid));
?>
	</ul>
</div>
 /**
  * 帐号绑定
  */
 public function bind()
 {
     // 邮箱绑定
     // $user = M('user')->where('uid='.$this->mid)->field('email')->find();
     // $replace = substr($user['email'],2,-3);
     // for ($i=1;$i<=strlen($replace);$i++){
     // $replacestring.='*';
     // }
     // $data['email'] = str_replace( $replace, $replacestring ,$user['email'] );
     // 站外帐号绑定
     $bindData = array();
     Addons::hook('account_bind_after', array('bindInfo' => &$bindData));
     $data['bind'] = $bindData;
     $this->assign($data);
     $user = model('User')->getUserInfo($this->mid);
     $this->setTitle('帐号绑定');
     $this->setKeywords('帐号绑定');
     $this->setDescription(t(implode(',', getSubByKey($data['bind'], 'name'))));
     $this->display();
 }
 public function index()
 {
     $cacheTime = 3600;
     // 今日看点
     $data = S('S_square_xdata');
     if (empty($data)) {
         $res = model('Xdata')->lget('weibo');
         $data['aboutkey'] = $res['todaytopic'];
         $data['aboutkey_id'] = M('weibo_topic')->getField('topic_id', "name='{$data['aboutkey']}'");
         $data['aboutkey_follow'] = getFollowState($this->mid, array('name' => $data['aboutkey']), 1);
         S('S_square_xdata', $data, $cacheTime);
     }
     $user_model = D('User', 'home');
     $user_count_model = model('UserCount');
     // 今日看点相关的用户
     $data['userlist'] = S('S_square_userlist');
     if (empty($data['userlist'])) {
         $data['userlist'] = M('weibo')->where("transpond_id=0 AND isdel=0 AND content LIKE '%" . $data['aboutkey'] . "%'")->limit(10)->order('ctime DESC')->findAll();
         $uids = getSubByKey($data['userlist'], 'uid');
         if (!in_array($this->mid, $uids)) {
             $uid = array_merge($this->mid);
         }
         $user_model->setUserObjectCache($uids);
         $user_count_model->setUserFollowingCount($uids);
         $user_count_model->setUserFollowerCount($uids);
         unset($uids);
         foreach ($data['userlist'] as $key => $value) {
             $data['userlist'][$key]['userinfo'] = $user_model->getUserByIdentifier($value['uid']);
             $data['userlist'][$key]['following'] = $user_count_model->getUserFollowingCount($value['uid']);
             $data['userlist'][$key]['follower'] = $user_count_model->getUserFollowerCount($value['uid']);
             //$data['userlist'][$key]['followState']  = getFollowState( $this->mid , $value['uid'] );
         }
         S('S_square_userlist', $data['userlist'], $cacheTime);
     }
     // 关注的话题
     $data['followTopic'] = D('Follow', 'weibo')->getTopicList($this->mid);
     // 搜索热词
     if (count($data['hotTopic']) > 3) {
         $data['hotkeys'] = $this->_getRandomSubArray($data['hotTopic'], 3);
     } else {
         $data['hotkeys'] = $data['hotTopic'];
     }
     // 活跃用户
     $data['hotUser'] = S('S_square_hotUser');
     if (empty($data['hotUser'])) {
         global $ts;
         $huNumPerRow = $ts['site']['site_theme'] == 'weibo' ? 4 : 4;
         $hotUserNum = $huNumPerRow * 10;
         $time_range = model('Xdata')->get('square:hotuser');
         if (!is_numeric($time_range) || $time_range < 1) {
             $time_range = 1;
         }
         $today = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
         $yesterday = $today - $time_range * 24 * 3600;
         $db_prefix = C('DB_PREFIX');
         $hotUser = M()->query("SELECT uid,count(weibo_id) as weibo_num FROM {$db_prefix}weibo where ctime>{$yesterday} AND ctime<{$today} AND isdel=0 GROUP BY uid ORDER BY weibo_num DESC LIMIT {$hotUserNum}");
         if ($hotUser) {
             $data['hotUserSlide'] = count($hotUser) > $huNumPerRow ? 1 : 0;
             $uids = getSubByKey($hotUser, 'uid');
             $user_model->setUserObjectCache($uids);
             $user_count_model->setUserFollowerCount($uids);
             unset($uids);
             foreach ($hotUser as $key => $value) {
                 $hotUserRow = ceil(($key + 1) / $huNumPerRow);
                 $data['hotUser'][$hotUserRow][$key] = $user_model->getUserByIdentifier($value['uid']);
                 $data['hotUser'][$hotUserRow][$key]['follower'] = $user_count_model->getUserFollowerCount($value['uid']);
             }
         } else {
             $data['hotUser'] = '';
         }
         S('S_square_hotUser', $data['hotUser'], $cacheTime);
     }
     //名人推荐:是否具有名人
     $data['star_list'] = S('S_square_star_list');
     if (empty($data['star_list'])) {
         $star = D('weibo_star')->find();
         if ($star) {
             $data['star_list'] = 1;
         }
         S('S_square_star_list', $data['star_list'], $cacheTime);
     }
     //粉丝与关注情况
     $data['followInfo'] = S('S_square_followInfo');
     if (empty($data['followInfo'])) {
         $data['followInfo'] = array('following' => $user_count_model->getUserFollowingCount($this->mid), 'follower' => $user_count_model->getUserFollowerCount($this->mid));
         S('S_square_followInfo', $data['followInfo'], $cacheTime);
     }
     // 粉丝榜
     $data['topfollow'] = D('Follow', 'weibo')->getTopFollowerUser();
     $uids = getSubByKey($data['topfollow'], 'uid');
     $user_model->setUserObjectCache($uids);
     // 底部微博Tab
     $data['square_list_menu'] = array('' => L('other_say'), 'transpond' => L('hot_transmit'), 'comment' => L('hot_reply'));
     Addons::hook('home_square_index_list_tab', array(&$data['square_list_menu']));
     $this->assign($data);
     $this->setTitle(L('square') . date('Y' . L('year') . 'm' . L('month') . 'd' . L('day')) . L('hot_weibo'));
     $this->display();
 }
 private function __parseTemplate($value)
 {
     static $rand;
     if ($rand) {
         $rand++;
     } else {
         $rand = time() . $value['transpond_id'];
     }
     $typedata = unserialize($value['type_data']);
     $type = $value['type'];
     $template = '';
     Addons::hook('weibo_type_parse_tpl', array('typeId' => $type, 'typeData' => $typedata, 'rand' => $rand, 'result' => &$template));
     return $template;
 }
echo $GLOBALS["ts"]["site"]["site_footer_des"];
?>
</p>
      <p class="f8">Powered by <a href="http://www.thinksns.com">ThinkSNS</a>&nbsp;<?php 
echo $GLOBALS["ts"]["site"]["site_footer"];
?>
 </p>
      </div>
    </div>
  </div>
  <!--footer end--> 
  
</div>
<!--page end--> 
<?php 
echo Addons::hook('public_footer');
?>
 
<!-- 统计代码-->
<div id="site_analytics_code" style="display:none;"> <?php 
echo base64_decode($site["site_analytics_code"]);
?>
 </div>
<?php 
if ($site["site_online_count"] == "1") {
    ?>
<script src="<?php 
    echo SITE_URL;
    ?>
/online_check.php?uid=<?php 
    echo $mid;
示例#21
0
 /**
  * 添加微博
  * @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 = 'public', $type = '', $data = array(), $app_id = 0, $app_table = 'feed', $extUid = null, $lessUids = null, $isAtMe = true, $is_repost = 0)
 {
     if (isSubmitLocked()) {
         $this->error = '发布内容过于频繁,请稍后再试';
         return false;
     }
     // 判断数据的正确性
     if (!$uid || $type == '') {
         $this->error = L('PUBLIC_ADMIN_OPRETING_ERROR');
         return false;
     }
     if (strpos($type, 'postvideo') !== false) {
         $type = 'postvideo';
     }
     //微博类型合法性验证 - 临时解决方案
     if (!in_array($type, array('post', 'repost', 'postvideo', 'postfile', 'postimage', 'weiba_post', 'weiba_repost'))) {
         $type = 'post';
     }
     //应用类型验证 用于分享框 - 临时解决方案
     if (!in_array($app, array('w3g', 'public', 'weiba', 'tipoff'))) {
         $app = 'public';
         $type = 'post';
         $app_table = 'feed';
     }
     $app_table = strtolower($app_table);
     // 添加feed表记录
     $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 {
         $content = $this->formatFeedContent($data['body']);
         $data['body'] = $content['body'];
         $data['content'] = $content['content'];
     }
     //分享到微博的应用资源,加入原资源链接
     $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']) {
         $touid = D('user_group_link')->where('user_group_id=1')->field('uid')->findAll();
         foreach ($touid as $k => $v) {
             model('Notify')->sendNotify($v['uid'], 'feed_audit');
         }
     }
     // 目前处理方案格式化数据
     $data['content'] = str_replace(chr(31), '', $data['content']);
     $data['body'] = str_replace(chr(31), '', $data['body']);
     // 添加关联数据
     $feed_data = D('FeedData')->data(array('feed_id' => $feed_id, 'feed_data' => serialize($data), 'client_ip' => get_client_ip(), 'feed_content' => $data['body']))->add();
     // 添加微博成功后
     if ($feed_id && $feed_data) {
         //锁定发布
         lockSubmit();
         //微博发布成功后的钩子
         //Addons::hook("weibo_publish_after",array('weibo_id'=>$feed_id,'post'=>$data));
         // 发送通知消息 - 重点 - 需要简化把上节点的信息去掉.
         if ($data['is_repost'] == 1) {
             // 转发微博
             $isAtMe && ($content = $data['content']);
             // 内容用户
             $extUid[] = $data['sourceInfo']['transpond_data']['uid'];
             // 资源作者用户
             if ($isAtMe && !empty($data['curid'])) {
                 // 上节点用户
                 $appRowData = $this->get($data['curid']);
                 $extUid[] = $appRowData['uid'];
             }
         } else {
             // 其他微博
             $content = $data['content'];
             //更新最近@的人
             model('Atme')->updateRecentAt($content);
             // 内容用户
         }
         // 发送@消息
         model('Atme')->setAppName('Public')->setAppTable('feed')->addAtme($content, $feed_id, $extUid, $lessUids);
         $data['client_ip'] = get_client_ip();
         $data['feed_id'] = $feed_id;
         $data['feed_data'] = serialize($data);
         // 主动创建渲染后的缓存
         $return = $this->setFeedCache($data);
         $return['user_info'] = model('User')->getUserInfo($uid);
         $return['GroupData'] = model('UserGroupLink')->getUserGroupData($uid);
         //获取用户组信息
         $return['feed_id'] = $feed_id;
         $return['app_row_id'] = $data['app_row_id'];
         $return['is_audit'] = $data['is_audit'];
         // 统计数修改
         model('UserData')->setUid($uid)->updateKey('feed_count', 1);
         // if($app =='public'){ //TODO 微博验证条件
         model('UserData')->setUid($uid)->updateKey('weibo_count', 1);
         // }
         if (!$return) {
             $this->error = L('PUBLIC_CACHE_FAIL');
             // Feed缓存写入失败
         }
         return $return;
     } else {
         $this->error = L('PUBLIC_ADMIN_OPRETING_ERROR');
         // 操作失败
         return false;
     }
 }
 /**
  * 注销本地登录
  * @return void
  */
 public function logoutLocal()
 {
     unset($_SESSION['mid'], $_SESSION['SITE_KEY']);
     // 注销session
     cookie('TSV3_LOGGED_USER', NULL);
     // 注销cookie
     Addons::hook('passport_logout_local', array('login' => $login, 'password' => $password));
     //UC同步退出
     if (UC_SYNC) {
         echo $this->ucLogout();
     }
 }
	 * @return string 短URL地址
	 */
    public function __construct()
    {
        $this->option = model('Xdata')->lget('shorturl');