Exemple #1
0
 public function getUnreadMessage($user_id)
 {
     $user_id = intval($user_id);
     if (!isset($this->count_info[$user_id]['unread_message_count'])) {
         $this->getUserCount(User::getUser($user_id));
     }
     return isset($this->count_info[$user_id]['unread_message_count']) ? $this->count_info[$user_id]['unread_message_count'] : 0;
 }
Exemple #2
0
 public function user_permission($id = 0)
 {
     try {
         $user = User::getUser(0 + $id);
         $info = $user->Permission();
         $this->__view("Control/user_permission.php", ["info" => implode("\n", $info), "user_id" => $user->getId()]);
     } catch (\Exception $ex) {
         echo "<h3 class='text-danger'>用户权限加载失败:</h3><p>" . $ex->getMessage() . "</p>";
     }
 }
Exemple #3
0
/**
 * 获取用户主页地址
 * @param string|int $name 用户名或ID
 * @return string
 */
function user_link($name)
{
    static $router = NULL;
    if ($router === NULL) {
        $router = lib()->using('router');
    }
    if (is_numeric($name)) {
        try {
            $name = \ULib\User::getUser(intval($name))->getName();
        } catch (Exception $ex) {
            //nothing
        }
    }
    return get_url($router->getLink('user', $name));
}
Exemple #4
0
 /**
  * @param $user_id
  * @param $permission
  */
 public function PermissionSet($user_id, $permission)
 {
     $user = User::getUser($user_id);
     $ps = [];
     foreach (explode("\n", $permission) as $v) {
         $v = trim($v);
         if (!empty($v) && !in_array($v, $ps)) {
             $ps[] = $v;
         }
     }
     $ps = implode("\n", $ps);
     if ($ps === implode("\n", $user->Permission())) {
         $this->throwMsg(-2);
     }
     $user->getMeta()->set(['Permission' => $ps]);
 }
Exemple #5
0
 /**
  * 发送消息给关注用户
  * @param null $rt
  * @param int  $f_id 被关注ID
  * @param int  $u_id 关注者ID
  * @return null
  */
 public function message_follow_me($rt, $f_id, $u_id)
 {
     try {
         if ($this->notice($f_id, 'message', 'follow_me')) {
             $user = User::getUser($u_id);
             $follow_user = User::getUser($f_id);
             $mt = new MailTemplate("message_notice/follow_me.md");
             $mt->setUserInfo($follow_user->getInfo());
             $mt->setValues(['follow_user_aliases' => $user->getAliases(), 'follow_user_url' => user_link($user->getName()), 'follow_list_link' => get_url('Follow', 'ta'), 'follow_user_name' => $user->getName()]);
             $this->message->addNoticeMsg($mt->getTitle(), $mt->getContent(), $f_id);
         }
     } catch (\Exception $ex) {
         Log::write(_("Message to message_follow_me create a Exception.") . "EX:[" . $ex->getCode() . "]:" . $ex->getMessage(), Log::NOTICE);
     }
     return $rt;
 }
Exemple #6
0
 /**
  * 发送信息
  * @param string $title
  * @param string $users
  * @param string $content
  * @param int    $send_user
  * @return array
  */
 public function send($title, $users, $content, $send_user)
 {
     if (login_user()->Permission('MessageDeny')) {
         $this->throwMsg(-10);
     }
     $title = trim($title);
     $users = array_map('trim', preg_split("/[\\s]+/", $users));
     $content = trim($content);
     if (strlen($content) < 1) {
         $this->throwMsg(-4);
     }
     $send_user = intval($send_user);
     if ($send_user < 0) {
         $this->throwMsg(-1);
     } else {
         if ($send_user === 0) {
             //系统信息
             if (!login_user()->Permission('MessageSystem')) {
                 $this->throwMsg(-2);
             }
         } else {
             //用户信息
             if (!User::getUser($send_user)->is_active()) {
                 //未激活不允许发送信息
                 $this->throwMsg(-3);
             }
             if (count($users) == 1 && $users[0] == User::getUser($send_user)->getName()) {
                 $this->throwMsg(-13);
             }
         }
     }
     if (count($users) < 1) {
         $this->throwMsg(-6);
     }
     if ($send_user > 0) {
         $this->checkLastSend($send_user);
     }
     if ($send_user > 0) {
         $list = $this->checkUser($users, $send_user);
         if (($l = count($list)) === 0) {
             $this->throwMsg(-6);
         } else {
             if ($l > hook()->apply("Message_send_number", 5)) {
                 $this->throwMsg(-7);
             }
         }
     } else {
         //系统发信,可以使用ID序列
         if (empty($title)) {
             //系统消息标题不能为空
             $this->throwMsg(-19);
         }
         $list_id = $this->db->select("users", ['id'], ['OR' => ['user_name' => $users, 'id' => $users]]);
         $list = [];
         if ($list_id === false) {
             Log::write(_("select user id list error on message."), Log::SQL);
         }
         foreach ($list_id as $v) {
             $list[] = $v['id'];
         }
     }
     $send_user !== 0 or $send_user = NULL;
     $time = date("Y-m-d H:i:s");
     $status = ['ok' => 0, 'error' => 0];
     foreach ($list as $t_id) {
         $data = ['msg_title' => $title, 'msg_content' => $content, 'msg_datetime' => $time, 'from_users_id' => $send_user, 'to_users_id' => $t_id];
         $data = hook()->apply('Message_send_before', $data);
         if (empty($data)) {
             continue;
         }
         $insert = $this->db->insert("message", $data);
         if ($insert > 0) {
             ++$status['ok'];
             //运行成功处理
             hook()->apply('Message_send_success', NULL, $data, $insert);
         } else {
             Log::write(_("Insert message error."), Log::SQL);
             ++$status['error'];
         }
     }
     return $status;
 }
Exemple #7
0
 * @var string $__error
 */
if (!empty($__error)) {
    ?>
	<div class="well text-danger"><h3><?php 
    echo $__error;
    ?>
</h3></div>
<?php 
} else {
    if ($__content['from_users_id'] > 0) {
        $from_user = \ULib\User::getUser($__content['from_users_id']);
    } else {
        $from_user = NULL;
    }
    $to_user = \ULib\User::getUser($__content['to_users_id']);
    ?>
	<div class="panel panel-primary">
		<div class="panel-heading">
			<h2 class="panel-title">消息阅读</h2>
		</div>
		<div class="panel-body">
			<?php 
    if (!empty($__content['msg_title'])) {
        ?>
				<h3 class=""><?php 
        echo $__content['msg_title'];
        ?>
</h3>
			<?php 
    }
Exemple #8
0
 /**
  * 构造方法,使用评论的信息和对应的用户类
  * @param array $set_info
  * @param int   $user_id
  */
 function __construct($set_info, $user_id)
 {
     $this->ip_c = Ip::getInstance();
     $this->user = User::getUser($user_id);
     if (is_array($set_info) && isset($set_info['comment_id'])) {
         static $names = [];
         if (count($names) === 0) {
             $ref = new \ReflectionClass($this);
             foreach ($ref->getProperties() as $ro) {
                 $names[] = $ro->getName();
             }
             $names = array_flip($names);
             unset($names['ip_c'], $names['user'], $names['sub_node']);
         }
         if (isset($set_info['comment_ip'])) {
             $set_info['comment_ip'] = $this->ip_c->bin2ip($set_info['comment_ip']);
         }
         foreach ($set_info as $k => $v) {
             if (isset($names[$k])) {
                 $this->{$k} = $v;
             }
         }
         self::$comment_stack[$this->getCommentId()] = $this;
     } else {
         Log::write(_("Comment class construct error"), Log::ALERT);
     }
 }
Exemple #9
0
 /**
  * 提交评论
  * @param string $content
  * @param int    $reply
  * @param int    $user_id
  * @return int
  */
 public function comment($content, $reply, $user_id)
 {
     if (!$this->checkAllowComment($this->id)) {
         $this->throwMsg(-11);
     }
     $user = User::getUser($user_id);
     $content = $this->comment_check($content);
     $reply = intval($reply);
     if ($reply < 0) {
         $this->throwMsg(-3);
     }
     $top = 0;
     if ($reply > 0) {
         $reply_info = $this->reply_comment_info($reply);
         if (!isset($reply_info['users_id'])) {
             $this->throwMsg(-4);
         }
         $top = intval($reply_info['comment_parent_top']);
         if ($top === 0 && $reply_info['comment_parent'] == 0) {
             $top = $reply;
         }
     }
     return $this->insert_comment($content, $reply, $top, $user->getId());
 }
Exemple #10
0
 /**
  * 对数组信息进行解析,和增加部分信息
  * @param array $list
  * @param bool  $convert_avatar 是否对头像进行处理
  * @return mixed
  */
 public function parsePic(&$list, $convert_avatar = true)
 {
     if ($convert_avatar) {
         lib()->load('User', 'Avatar');
     }
     for ($i = 0, $l = count($list); $i < $l; $i++) {
         if (!empty($list[$i]['user_avatar'])) {
             if ($convert_avatar) {
                 $list[$i]['user_avatar'] = Avatar::get($list[$i]['user_avatar'], User::getUser($list[$i]['user_id']));
             }
         }
         if (empty($list[$i]['server_url'])) {
             continue;
         }
         $list[$i]['pic_url'] = $this->makePictureUrl($list[$i]['server_url'], $list[$i]['pic_path'], $list[$i]['pic_path']);
         $list[$i]['pic_thumbnails_url'] = $this->makePictureUrl($list[$i]['server_url'], $list[$i]['pic_thumbnails_path'], $list[$i]['pic_path']);
         $list[$i]['pic_hd_url'] = $this->makePictureUrl($list[$i]['server_url'], $list[$i]['pic_hd_path'], $list[$i]['pic_path']);
         $list[$i]['pic_display_url'] = $this->makePictureUrl($list[$i]['server_url'], $list[$i]['pic_display_path'], $list[$i]['pic_path']);
     }
     return $list;
 }
Exemple #11
0
		<small>第<?php 
    echo $__number;
    ?>
页</small>
	</h2>
<?php 
}
?>
	<div id="Gallery_list">
		<?php 
$i = 0;
$count = count($__list);
foreach ($__list as $v) {
    $pic_link = picture_link($v['pic_id']);
    $gallery_link = gallery_link($v['gallery_id']);
    $user = \ULib\User::getUser($v['users_id']);
    ?>
			<?php 
    if ($i % 2 === 0) {
        ?>
			<div class="row list_box">
		<?php 
    }
    ?>
			<div class="media col-md-6">
				<a href="<?php 
    echo $pic_link;
    ?>
" rel="external">
					<img class="media-object img-thumbnail" src="<?php 
    echo $v['pic_thumbnails_url'];
Exemple #12
0
 public function user_gallery_list($user = NULL, $page = 0)
 {
     $page = (int) $page;
     $this->__lib('ListGallery');
     $lg = new ListGallery();
     $lg->setPager($page, 6);
     $pager = ['previous' => NULL, 'next' => NULL];
     $list = $lg->getListOfUser($user);
     if (!isset($list[0]) || !reset($list[0])) {
         $this->__load_404();
     } else {
         $count = $lg->getCount();
         /**
          * @var \ULib\Router $router
          */
         $router = lib()->using('router');
         if ($count['page'] > 1) {
             if ($count['page'] == 2) {
                 $pager['previous'] = get_url($router->getLink("user_gallery_list", $user));
             } else {
                 $pager['previous'] = get_url($router->getLink("user_gallery_list_pager", $user, $count['page'] - 1));
             }
         }
         if ($count['page'] < $count['max']) {
             $pager['next'] = get_url($router->getLink("user_gallery_list_pager", $user, $count['page'] + 1));
         }
         $user = User::getUser($user);
         if ($page > 0) {
             $this->theme->setTitle($user->getName() . " 的图集列表 第{$page}页");
         } else {
             $this->theme->setTitle($user->getName() . " 的图集列表");
         }
         $this->__view("Home/header.php");
         $this->__view("Show/user_header.php", ['user' => $user]);
         $this->__view("Show/gallery_list.php", ['list' => $list, 'pager' => $pager, 'type' => 'user', 'number' => $count['page']]);
         $this->__view("Home/footer.php");
     }
 }
Exemple #13
0
 /**
  * 获取当前设置的图集信息
  * @return array
  */
 private function get()
 {
     $where = ['gallery.id' => $this->gallery_id];
     if ($this->user_id !== NULL) {
         $where = ['AND' => ['gallery.id' => $this->gallery_id, 'gallery.users_id' => intval($this->user_id)]];
     }
     $this->info = $this->db->select("gallery", ['[><]users' => ['users_id' => 'id'], '[>]users_like_gallery' => ['id' => 'gallery_id', '______' => ['users_like_gallery.users_id' => is_login() ? login_user()->getId() : 0]]], ['users.user_name' => 'user_name', 'users.user_url' => 'user_url', 'users.user_aliases' => 'user_aliases', 'users.user_status' => 'user_status', 'users.user_avatar' => 'user_avatar', 'gallery.id' => 'gallery_id', 'gallery.users_id' => 'user_id', 'gallery.gallery_title' => 'gallery_title', 'gallery.gallery_description' => 'gallery_description', 'gallery.gallery_create_time' => 'gallery_create_time', 'gallery.gallery_like_count' => 'gallery_like_count', 'gallery.gallery_update_time' => 'gallery_update_time', 'gallery.gallery_comment_count' => 'gallery_comment_count', 'gallery.gallery_comment_status' => 'gallery_comment_status', 'gallery.gallery_front_cover' => 'gallery_front_cover', 'gallery.gallery_status' => 'gallery_status', 'users_like_gallery.like_time' => 'gallery_like_time'], $where);
     if (!isset($this->info[0])) {
         $this->info = NULL;
         $this->error = _('Gallery not found.');
     } else {
         lib()->load('Avatar', 'User');
         $this->info = $this->info[0];
         $this->info['user_avatar'] = Avatar::get($this->info['user_avatar'], User::getUser($this->info['user_id']));
         $this->info['gallery_tags'] = $this->getTags($this->gallery_id);
         $this->info['gallery_pictures'] = $this->getPictures($this->gallery_id);
         $front_cover = intval($this->info['gallery_front_cover']);
         if ($front_cover > 0) {
             lib()->load('Picture');
             $pic = new Picture();
             $this->info['front_cover'] = $pic->get_pic($front_cover);
         }
     }
     return $this->info;
 }
Exemple #14
0
 public function time_line()
 {
     try {
         $this->throwMsgCheck('is_get', 'is_ajax', 'is_login');
         $id = (int) req()->get('id');
         $list = Feed::getInstance()->getList(login_user()->getId(), $id);
         $u = [];
         $c = [];
         foreach ($list as $fid => &$v) {
             $id = $v->getUserId();
             $oid = $v->getObjUserId();
             if (!isset($u[$id])) {
                 $u[$id] = User::getUser($id)->getSimpleInfo();
                 $u[$id]['link'] = user_link($u[$id]['name']);
             }
             if (!isset($u[$oid])) {
                 $u[$oid] = User::getUser($oid)->getSimpleInfo();
                 $u[$oid]['link'] = user_link($u[$oid]['name']);
             }
             $c[$fid] = $v->getInfo();
         }
         $this->rt_msg['content'] = ['list' => $c, 'user' => $u, 'count' => count($list)];
         $this->rt_msg['status'] = true;
     } catch (\Exception $ex) {
         $this->rt_msg['msg'] = $ex->getMessage();
         $this->rt_msg['code'] = $ex->getCode();
     }
 }
Exemple #15
0
 /**
  * @param $title
  * @param $name
  * @param $users_id
  * @return array
  */
 public function create($title, $name, $users_id)
 {
     $title = trim($title);
     $name = trim($name);
     $this->checkTitle($title);
     $this->checkName($name);
     if ($this->existsName($name)) {
         $this->throwMsg(-7);
     }
     User::getUser($users_id);
     $data = ['post_title' => $title, 'post_name' => $name, 'post_time' => date("Y-m-d H:i:s"), 'post_category' => $this->getCategory(0), 'post_status' => 0, 'post_update_time' => date("Y-m-d H:i:s"), 'post_content' => '', 'users_id' => $users_id];
     $insert = $this->db->insert("posts", $data);
     if ($insert < 1) {
         Log::write(_("Insert post content error."), Log::SQL);
         $this->throwMsg(-3);
     }
     $data['id'] = $insert;
     return $data;
 }
Exemple #16
0
 public function getListOfUser($user_name)
 {
     $user = User::getUser($user_name);
     if (!is_object($user)) {
         return [];
     }
     if (!$this->getCountInfo($user->getId(), 'user')) {
         return [];
     }
     $list = $this->db->select("pictures", ['[<]gallery' => ['id' => 'gallery_front_cover'], '[>]server' => ['server_name' => 'name']], ['gallery.id' => 'gallery_id', 'gallery.users_id' => 'users_id', 'gallery.gallery_title' => 'gallery_title', 'gallery.gallery_description' => 'gallery_description', 'gallery.gallery_create_time' => 'gallery_create_time', 'gallery.gallery_update_time' => 'gallery_update_time', 'gallery.gallery_like_count' => 'gallery_like_count', 'gallery.gallery_comment_count' => 'gallery_comment_count', 'gallery.gallery_comment_status' => 'gallery_comment_status', 'gallery.gallery_front_cover' => 'gallery_front_cover', 'pictures.id' => 'pic_id', 'pictures.server_name' => 'server_name', 'server.url' => 'server_url', 'pictures.pic_name' => 'pic_name', 'pictures.pic_path' => 'pic_path', 'pictures.pic_create_time' => 'pic_create_time', 'pictures.pic_width' => 'pic_width', 'pictures.pic_height' => 'pic_height', 'pictures.pic_description' => 'pic_description', 'pictures.pic_thumbnails_path' => 'pic_thumbnails_path', 'pictures.pic_thumbnails_width' => 'pic_thumbnails_width', 'pictures.pic_thumbnails_height' => 'pic_thumbnails_height', 'pictures.pic_hd_path' => 'pic_hd_path', 'pictures.pic_hd_width' => 'pic_hd_width', 'pictures.pic_hd_height' => 'pic_hd_height', 'pictures.pic_status' => 'pic_status', 'pictures.pic_comment_count' => 'pic_comment_count', 'pictures.pic_display_path' => 'pic_display_path', 'pictures.pic_display_width' => 'pic_display_width', 'pictures.pic_display_height' => 'pic_display_height'], ['AND' => ['gallery.gallery_status' => 1, 'gallery.users_id' => $user->getId()], 'ORDER' => 'gallery.id DESC', 'LIMIT' => [$this->count['number'] * ($this->count['page'] - 1), $this->count['number']]]);
     $this->parseList($list);
     return $list;
 }
Exemple #17
0
 public function send_activation_mail()
 {
     $req = req()->_plain();
     if ($req->is_post()) {
         try {
             $uid = intval($req->post('id'));
             $user = User::getUser($uid);
             if ($user->is_active()) {
                 $this->rt_msg['msg'] = "用户已激活,无需重复发送邮件";
             } else {
                 lib()->load('UserRegister');
                 $ur = new UserRegister();
                 if ($ur->SendActivationMail($user)) {
                     $this->rt_msg['status'] = true;
                 } else {
                     $this->rt_msg['msg'] = $ur->SendActivationMsg();
                 }
             }
         } catch (\Exception $ex) {
             $this->rt_msg['msg'] = $ex->getMessage();
         }
     } else {
         $this->rt_msg['msg'] = "必须以POST提交";
     }
 }
Exemple #18
0
                    echo $info['front_cover']['pic_thumbnails_url'];
                    ?>
" alt=""/></div>
						<?php 
                }
                ?>
						<div class="time"><span class="glyphicon-time glyphicon"></span><?php 
                echo $info['time'];
                ?>
</div>
					</div>
					<?php 
                break;
            case 'sharepicture':
                if ($info['share_users_id'] != $info['object_users_id']) {
                    $ou = \ULib\User::getUser($info['object_users_id']);
                    $other = "<a  rel='external' href='" . user_link($ou->getName()) . "'>" . $ou->getAliases() . "</a> ";
                }
                ?>
					<div id="Share_<?php 
                echo $id;
                ?>
" class="s_picture share_box">
						<button class="close" type="button">&times;</button>
						<h4><span>[<?php 
                echo $id;
                ?>
]</span>分享了<?php 
                echo $other;
                ?>
图片