Пример #1
0
 public function avatar($size = 0, $file = NULL)
 {
     $this->__lib('Avatar');
     if (Avatar::createOtherSizeAvatar($size, $file)) {
         header("Content-Type: image");
         echo Avatar::getAvatarContent($size, $file);
     } else {
         $this->__load_404();
     }
 }
Пример #2
0
 /**
  * @param User $user
  */
 public function upload_avatar($user)
 {
     c_lib()->load('upload');
     $upload = new Upload(['root_path' => 'avatar', 'exts' => ['jpg', 'png'], 'sub_status' => false, 'name_callback' => [function ($param) {
         return $param;
     }, $user->getId()], 'replace' => true, 'max_size' => 500 * 1024, 'save_ext' => 'jpg'], 'Local');
     if (!isset($_FILES['avatar'])) {
         $this->throwMsg(-16);
     }
     $info = $upload->uploadOne($_FILES['avatar']);
     lib()->load('Avatar');
     $avatar = new Avatar();
     $avatar->process_avatar($info['save_name'], 400, 400);
 }
Пример #3
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;
 }
Пример #4
0
				<div class="panel-heading">
					<h4 class="panel-title">
						<a data-toggle="collapse" data-toggle="collapse" data-parent="#accordion" href="#collapseThree">
							自定义上上传
						</a>
					</h4>
				</div>
				<div id="collapseThree" class="panel-collapse collapse<?php 
echo $__type === "{user_upload}" ? " in" : "";
?>
">
					<div class="panel-body">
						<p class="well well-sm text-warning">自己上传图片到服务器上,然后显示你的个性头像。建议上传400*400以上的图片,网站会将图片压缩到此尺寸。</p>
						<blockquote>
							<?php 
$u_a = \ULib\Avatar::upload_avatar(login_user());
if (!empty($u_a)) {
    ?>
								<p><img class="img-rounded" src="<?php 
    echo $u_a;
    ?>
?rand=<?php 
    echo time();
    ?>
" alt="avatar" width="200" height="200"></p>
								<small>当前上传的头像</small>
							<?php 
} else {
    ?>
								<small>当前未上传图片到服务器</small>
							<?php 
Пример #5
0
 /**
  * 获取头像
  * @param int $size
  * @return string
  */
 public function getAvatar($size = NULL)
 {
     if ($size !== NULL && is_numeric($size) && $size > 0 && $size < 400) {
         return Avatar::getSizeOfAvatar($this->avatar, $this->avatar_sql, $size);
     }
     return $this->avatar;
 }
Пример #6
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;
 }
Пример #7
0
 public function user_avatar_upload()
 {
     try {
         $this->throwMsgCheck('is_post', 'is_login');
         lib()->load("UserControl");
         $uc = new UserControl();
         $uc->upload_avatar(login_user());
         $this->rt_msg['content'] = Avatar::upload_avatar(login_user());
         if (!req()->is_ajax()) {
             header("Location: " . $_SERVER['HTTP_REFERER']);
         }
         $this->rt_msg['status'] = true;
     } catch (\Exception $ex) {
         $this->rt_msg['msg'] = $ex->getMessage();
         $this->rt_msg['code'] = $ex->getCode();
     }
 }