/**
  * 根据角色获取默认头像
  * @param $role_id
  * @param $size
  * @return mixed|string
  * @author 郑钟良<*****@*****.**>
  */
 private function getImageUrlByRoleId($role_id, $size)
 {
     $avatar_id = S('Role_Avatar_Id_' . $role_id);
     if (!$avatar_id) {
         $map = getRoleConfigMap('avatar', $role_id);
         $avatar_id = M('RoleConfig')->where($map)->field('value')->find();
         S('Role_Avatar_Id_' . $role_id, $avatar_id, 600);
     }
     if ($avatar_id) {
         if ($size != 0) {
             $path = getThumbImageById($avatar_id['value'], $size, $size);
         } else {
             $path = getThumbImageById($avatar_id['value']);
         }
     } else {
         //角色没有默认
         if ($size != 0) {
             $default_avatar = "Public/images/default_avatar.jpg";
             $path = $this->getImageUrlByPath($default_avatar, $size, false);
         } else {
             $path = get_pic_src("Public/images/default_avatar.jpg");
         }
     }
     return $path;
 }
Esempio n. 2
0
 /**
  * 文件上传
  * @param  array  $files   要上传的文件列表(通常是$_FILES数组)
  * @param  array  $setting 文件上传配置
  * @param  string $driver  上传驱动名称
  * @param  array  $config  上传驱动配置
  * @return array           文件上传成功后的信息
  */
 public function upload($files, $setting, $driver = 'local', $config = null)
 {
     /* 上传文件 */
     $setting['callback'] = array($this, 'isFile');
     $setting['removeTrash'] = array($this, 'removeTrash');
     $Upload = new Upload($setting, $driver, $config);
     foreach ($files as $key => $file) {
         $ext = strtolower($file['ext']);
         if (in_array($ext, array('jpg', 'jpeg', 'bmp', 'png'))) {
             hook('dealPicture', $file['tmp_name']);
         }
     }
     $info = $Upload->upload($files);
     if ($info) {
         //文件上传成功,记录文件信息
         foreach ($info as $key => &$value) {
             /* 已经存在文件记录 */
             if (isset($value['id']) && is_numeric($value['id'])) {
                 continue;
             }
             /* 记录文件信息 */
             if (strtolower($driver) == 'sae') {
                 $value['path'] = $config['rootPath'] . 'Picture/' . $value['savepath'] . $value['savename'];
                 //在模板里的url路径
             } else {
                 if (strtolower($driver) != 'local') {
                     $value['path'] = $value['url'];
                 } else {
                     $value['path'] = substr($setting['rootPath'], 1) . $value['savepath'] . $value['savename'];
                     //在模板里的url路径
                 }
             }
             $value['type'] = $driver;
             if ($this->create($value) && ($id = $this->add())) {
                 $value['id'] = $id;
             } else {
                 //TODO: 文件上传成功,但是记录文件信息失败,需记录日志
                 unset($info[$key]);
             }
         }
         foreach ($info as &$t_info) {
             if ($t_info['type'] == 'local') {
                 $t_info['path'] = get_pic_src($t_info['path']);
             } else {
                 $t_info['path'] = $t_info['path'];
             }
         }
         /*  dump(getRootUrl());
             dump($info);
             exit;*/
         return $info;
         //文件上传成功
     } else {
         $this->error = $Upload->getError();
         return false;
     }
 }
 /**
  * fetchImage  渲染图片轻博客
  * @param $weibo
  * @return string
  * @author:xjw129xjt(肖骏涛) xjt@ourstu.com
  */
 public function fetchImage($weibo)
 {
     $weibo_data = unserialize($weibo['data']);
     $weibo_data['attach_ids'] = explode(',', $weibo_data['attach_ids']);
     foreach ($weibo_data['attach_ids'] as $k_i => $v_i) {
         $weibo_data['image'][$k_i]['small'] = getThumbImageById($v_i, 100, 100);
         $bi = D('Picture')->where(array('status' => 1))->getById($v_i);
         $weibo_data['image'][$k_i]['big'] = get_pic_src($bi['path']);
         $param['weibo'] = $weibo;
         $param['weibo']['weibo_data'] = $weibo_data;
     }
     $this->assign($param);
     return $this->fetch(T('Application://Mob@Type/fetchimage'));
 }
 /**
  * fetchImage  渲染图片轻博客
  * @param $weibo
  * @return string
  * @author:xjw129xjt(肖骏涛) xjt@ourstu.com
  */
 public function fetchImage($weibo)
 {
     $weibo_data = unserialize($weibo['data']);
     $weibo_data['attach_ids'] = explode(',', $weibo_data['attach_ids']);
     $tag = 'ttp:';
     switch (count($weibo_data['attach_ids'])) {
         case 1:
             foreach ($weibo_data['attach_ids'] as $k_i => $v_i) {
                 $weibo_data['image'][$k_i]['small'] = getThumbImageById($v_i, 1000, 1000);
                 $bi = D('Picture')->where(array('status' => 1))->getById($v_i);
                 $weibo_data['image'][$k_i]['big'] = get_pic_src($bi['path']);
                 $pi = $weibo_data['image'][$k_i]['big'];
                 $param['weibo'] = $weibo;
                 if (!strpos($pi, $tag)) {
                     $pi = '.' . $pi;
                 }
                 $hv = getimagesize($pi);
                 $weibo_data['image'][$k_i]['size'] = $hv[0] . 'x' . $hv[1];
                 $param['weibo']['weibo_data'] = $weibo_data;
             }
             break;
         case 2:
             foreach ($weibo_data['attach_ids'] as $k_i => $v_i) {
                 $weibo_data['image'][$k_i]['small'] = getThumbImageById($v_i, 350, 350);
                 $bi = D('Picture')->where(array('status' => 1))->getById($v_i);
                 $weibo_data['image'][$k_i]['big'] = get_pic_src($bi['path']);
                 $pi = $weibo_data['image'][$k_i]['big'];
                 $param['weibo'] = $weibo;
                 if (!strpos($pi, $tag)) {
                     $pi = '.' . $pi;
                 }
                 $hv = getimagesize($pi);
                 $weibo_data['image'][$k_i]['size'] = $hv[0] . 'x' . $hv[1];
                 $param['weibo']['weibo_data'] = $weibo_data;
             }
             break;
         case 3:
             foreach ($weibo_data['attach_ids'] as $k_i => $v_i) {
                 $weibo_data['image'][$k_i]['small'] = getThumbImageById($v_i, 300, 300);
                 $bi = D('Picture')->where(array('status' => 1))->getById($v_i);
                 $weibo_data['image'][$k_i]['big'] = get_pic_src($bi['path']);
                 $pi = $weibo_data['image'][$k_i]['big'];
                 $param['weibo'] = $weibo;
                 if (!strpos($pi, $tag)) {
                     $pi = '.' . $pi;
                 }
                 $hv = getimagesize($pi);
                 $weibo_data['image'][$k_i]['size'] = $hv[0] . 'x' . $hv[1];
                 $param['weibo']['weibo_data'] = $weibo_data;
             }
             break;
         case 4:
             foreach ($weibo_data['attach_ids'] as $k_i => $v_i) {
                 $weibo_data['image'][$k_i]['small'] = getThumbImageById($v_i, 300, 300);
                 $bi = D('Picture')->where(array('status' => 1))->getById($v_i);
                 $weibo_data['image'][$k_i]['big'] = get_pic_src($bi['path']);
                 $pi = $weibo_data['image'][$k_i]['big'];
                 $param['weibo'] = $weibo;
                 if (!strpos($pi, $tag)) {
                     $pi = '.' . $pi;
                 }
                 $hv = getimagesize($pi);
                 $weibo_data['image'][$k_i]['size'] = $hv[0] . 'x' . $hv[1];
                 $param['weibo']['weibo_data'] = $weibo_data;
             }
             break;
         default:
             foreach ($weibo_data['attach_ids'] as $k_i => $v_i) {
                 $weibo_data['image'][$k_i]['small'] = getThumbImageById($v_i, 200, 200);
                 $bi = D('Picture')->where(array('status' => 1))->getById($v_i);
                 $weibo_data['image'][$k_i]['big'] = get_pic_src($bi['path']);
                 $pi = $weibo_data['image'][$k_i]['big'];
                 $param['weibo'] = $weibo;
                 if (!strpos($pi, $tag)) {
                     $pi = '.' . $pi;
                 }
                 $hv = getimagesize($pi);
                 $weibo_data['image'][$k_i]['size'] = $hv[0] . 'x' . $hv[1];
                 $param['weibo']['weibo_data'] = $weibo_data;
             }
     }
     $this->assign('img_num', count($weibo_data['attach_ids']));
     $this->assign($param);
     return $this->fetch(T('Application://Weibo@Type/fetchimage'));
 }
Esempio n. 5
0
 /**
  * 活动成员
  * @param int $id
  * @param string $tip
  * autor:xjw129xjt
  */
 public function member($id = 0, $tip = 'all')
 {
     if ($tip == 'sign') {
         $map['status'] = 0;
     }
     if ($tip == 'attend') {
         $map['status'] = 1;
     }
     $event_content = $this->eventModel->where(array('status' => 1, 'id' => $id))->find();
     if (!$event_content) {
         $this->error('活动不存在!');
     }
     $map['event_id'] = $id;
     $member = $this->eventAttendModel->where($map)->select();
     foreach ($member as &$v) {
         $v['user_info'] = query_user(array('uid', 'nickname', 'space_url', 'avatar32', 'avatar64'), $v['uid']);
         if ($v['image']) {
             $v['image_info'] = '<div class="popup-gallery"><a class="popup" href="' . get_cover($v['image'], 'path') . '"><img src="' . getThumbImageById($v['image'], 50, 50) . '"/></a></div>';
         }
         $v['attach_info'] = D('File')->find($v['attach']);
         $v['attach_info']['link'] = get_pic_src($v['attach_info']['savepath'] . $v['attach_info']['savename']);
         if ($v['status'] == 0) {
             $v['status_info'] = '待审核';
         }
         if ($v['status'] == 1) {
             $v['status_info'] = '已审核';
         }
     }
     unset($v);
     $this->assign('all_count', $this->eventAttendModel->where(array('event_id' => $id))->count());
     $this->assign('sign_count', $this->eventAttendModel->where(array('event_id' => $id, 'status' => 0))->count());
     $this->assign('attend_count', $this->eventAttendModel->where(array('event_id' => $id, 'status' => 1))->count());
     $this->assign('event_member', $member);
     $this->assign('event_content', $event_content);
     $this->assign('tip', $tip);
     $this->setTitle($event_content['title'] . '——活动');
     $this->setKeywords($event_content['title'] . ',活动');
     $tmp = 'attend';
     $this->display($tmp);
 }
 public function getVideoInfo($link)
 {
     $return = S('video_info_' . md5($link));
     if (empty($return)) {
         require_once './ThinkPHP/Library/Vendor/Collection/phpQuery.php';
         preg_match("/(youku.com|ku6.com|sohu.com|sina.com.cn|qq.com|tudou.com|yinyuetai.com|iqiyi.com|bilibili.com)/i", $link, $hosts);
         $host = $hosts[1];
         $content = get_content_by_url($link);
         if ('youku.com' == $host) {
             \phpQuery::newDocument($content);
             $title = pq("title")->html();
             $flash_url = pq("#link2")->attr('value');
             // 获取缩略图
             preg_match("/sid\\/(.*?)\\//", $flash_url, $id);
             // $json = get_content_by_url('http://v.youku.com/player/getPlayList/VideoIDS/' . $id[1]);
             $json = get_content_by_url('http://play.youku.com/play/get.json?vid=' . $id[1] . '&ct=10&ran=1951');
             $json = json_decode($json, true);
             $img_url = $json['data']['video']['logo'];
         } elseif ('ku6.com' == $host) {
             \phpQuery::$defaultCharset = GBK;
             \phpQuery::newDocument($content);
             $title = pq("title")->html();
             $flash_url = pq(".ckl_input")->eq(0)->attr('value');
             $title = iconv("GBK", "UTF-8", $title);
             // 获取缩略图
             preg_match("/show\\/(.*?).html/", $link, $id);
             $json = get_content_by_url('http://v.ku6.com/fetch.htm?t=getVideo4Player&vid=' . $id[1]);
             $json = json_decode($json, true);
             $img_url = $json['data']['bigpicpath'];
         } elseif ('tudou.com' == $host) {
             \phpQuery::newDocument($content);
             $title = pq("title")->html();
             preg_match('/iid:(.*?)\\s+,icode/s', $content, $program);
             $programId = intval($program[1]);
             if (strpos($link, 'www.tudou.com/albumplay') !== false) {
                 preg_match("/albumplay\\/([\\w\\-\\.]+)[\\/|\\.]/", $link, $album);
                 $albumId = $album[1];
                 $flash_url = 'http://www.tudou.com/a/' . $albumId . '/&iid=' . $programId . '/v.swf';
             } elseif (strpos($link, 'www.tudou.com/programs') !== false) {
                 $flash_url = 'http://www.tudou.com/v/' . $programId . '/v.swf';
             } elseif (strpos($link, 'www.tudou.com/listplay') !== false) {
                 preg_match("/listplay\\/([\\w\\-\\.]+)\\//", $link, $list);
                 $listId = $list[1];
                 $flash_url = 'http://www.tudou.com/l/' . $listId . '/&iid=' . $programId . '/v.swf';
             }
             //获取缩略图
             $json = get_content_by_url('http://api.tudou.com/v6/video/info?app_key=myKey&format=json&itemCodes=' . $programId);
             $json = json_decode($json, true);
             $img_url = $json['results'][0]['bigPicUrl'];
         } elseif ('sohu.com' == $host) {
             \phpQuery::$defaultCharset = GBK;
             \phpQuery::newDocument($content);
             $title = pq("title")->html();
             $title = iconv("GBK", "UTF-8", $title);
             $flash_url = pq("[property='og:videosrc']")->attr('content');
             // 获取缩略图
             preg_match("/com\\/(.*?)\\/v.swf/", $flash_url, $id);
             $json = get_content_by_url('http://hot.vrs.sohu.com/vrs_flash.action?vid=' . $id[1]);
             $json = json_decode($json, true);
             $img_url = $json['data']['coverImg'];
         } elseif ('qq.com' == $host) {
             $contentType = 'text/html;charset=gbk';
             \phpQuery::newDocument($content, $contentType);
             preg_match("/vid:\"(.*)\"/i", $content, $vid);
             $vid = $vid[1];
             $flash_url = 'http://static.video.qq.com/TPout.swf?vid=' . $vid . '&auto=0';
             $title = $title = pq("#" . $vid)->attr('title');
             // 获取缩略图
             $img_url = 'http://vpic.video.qq.com/d/' . $vid . '_ori_1.jpg';
         } elseif ('sina.com.cn' == $host) {
             \phpQuery::newDocument($content);
             $title = pq("title")->html();
             preg_match("/swfOutsideUrl:\\'(.+?)\\'/i", $content, $flashvar);
             $flash_url = $flashvar[1];
             //获取缩略图
             preg_match("/pic[\\s]*:[\\s]*[\"|\\']?[\\s]*([^'|\"]+)?/", $content, $mch1);
             $img_url = $mch1[1];
         } elseif ('yinyuetai.com' == $host) {
             \phpQuery::newDocument($content);
             $title = pq("title")->html();
             $flash_url = pq("[property='og:videosrc']")->attr('content');
             //获取缩略图
             $img_url = pq("[property='og:image']")->attr('content');
         } elseif ('iqiyi.com' == $host) {
             \phpQuery::newDocument($content);
             $title = pq("title")->html();
             $obj = pq("#videoArea")->find('div')->eq(0);
             $temp1 = $obj->attr('data-player-videoid');
             preg_match("/iqiyi.com\\/(.*).html/i", $link, $temp2);
             $temp2 = $temp2[1];
             $temp3 = $obj->attr('data-player-albumid');
             $temp4 = $obj->attr('data-player-tvid');
             $flash_url = 'http://player.video.qiyi.com/' . $temp1 . '/0/0/' . $temp2 . '.swf-albumId=' . $temp3 . '-tvId=' . $temp4;
             //获取缩略图
             //$img_url = pq("[itemprop='thumbnailUrl']")->attr('content') ;
             //  $img_url = pq("[itemprop='image']")->attr('content') ;
             // 奇艺网有跨站过滤,使用默认图片
             $img_url = get_pic_src('/Public/images/iqiyi.jpg');
         } elseif ('bilibili.com' == $host) {
             $content = $this->gzdecode($content);
             \phpQuery::newDocument($content);
             $title = pq("title")->html();
             //获取缩略图
             $img_url = pq("[class='cover_image']")->attr('src');
             //获取视频地址
             $url_js = pq('#bofqi')->find('script')->eq(0)->html();
             preg_match("/(cid=\\w*)/", $url_js, $url_cid);
             preg_match("/aid=\\w*/", $url_js, $url_aid);
             $url_cid = substr($url_cid[0], strpos($url_cid[0], "=") + 1);
             $url_aid = substr($url_aid[0], strpos($url_aid[0], "=") + 1);
             $flash_url = "http://static.hdslb.com/play.swf" . "?cid=" . $url_cid . "&aid=" . $url_aid;
             //下载视频
             //                $link_bao = explode('bilibili.com',$link);
             //                $link_bi = $link_bao[0]."ibilibili.com".$link_bao[1];
             //                $content_bi = get_content_by_url($link_bi);
             //                \phpQuery::newDocument($content_bi);
             //                $obj_bi = pq("#firstLi")->find('a')->eq(3);
             //                $id_bi = $obj_bi->attr('onclick');
             //                preg_match("/[0-9]*/", $id_bi, $cid_bi);
         }
         $return['title'] = text($title);
         $return['flash_url'] = urldecode($flash_url);
         $return['img_url'] = urldecode($img_url);
         S('video_info_' . md5($link), $return, 60 * 60);
     }
     return $return;
 }
Esempio n. 7
0
function getThumbImageById($cover_id, $width = 100, $height = 'auto', $type = 0, $replace = false)
{
    $picture = S('picture_' . $cover_id);
    if (empty($picture)) {
        $picture = M('Picture')->where(array('status' => 1))->getById($cover_id);
        S('picture_' . $cover_id, $picture);
    }
    if (empty($picture)) {
        return get_pic_src('Public/images/nopic.png');
    }
    if ($picture['type'] == 'local') {
        $attach = getThumbImage($picture['path'], $width, $height, $type, $replace);
        return get_pic_src($attach['src']);
    } else {
        $new_img = $picture['path'];
        $name = get_addon_class($picture['type']);
        if (class_exists($name)) {
            $class = new $name();
            if (method_exists($class, 'thumb')) {
                $new_img = $class->thumb($picture['path'], $width, $height, $type, $replace);
            }
        }
        return get_pic_src($new_img);
    }
}
 public function rankVerify($rank_user_id = null)
 {
     $uid = isset($uid) ? $uid : is_login();
     $rank_user_id = intval($rank_user_id);
     $map_already['uid'] = $uid;
     //重新申请头衔
     if ($rank_user_id) {
         $model = D('rank_user')->where(array('id' => $rank_user_id));
         $old_rank_user = $model->field('id,rank_id,reason')->find();
         if (!$old_rank_user) {
             $this->error(L('_ERROR_RANK_RE_SELECT_'));
         }
         $this->assign('old_rank_user', $old_rank_user);
         $map_already['id'] = array('neq', $rank_user_id);
         D('Message')->sendMessageWithoutCheckSelf(is_login(), L(''), L(''), 'Ucenter/Message/message', array('tab' => 'system'));
     }
     $alreadyRank = D('rank_user')->where($map_already)->field('rank_id')->select();
     $alreadyRank = array_column($alreadyRank, 'rank_id');
     if ($alreadyRank) {
         $map['id'] = array('not in', $alreadyRank);
     }
     $map['types'] = 1;
     $rankList = D('rank')->where($map)->select();
     foreach ($rankList as &$rank) {
         $rank['logo_url'] = get_pic_src(M('picture')->where('id=' . $rank['logo'])->field('path')->getField('path'));
     }
     unset($rank);
     $this->assign('rankList', $rankList);
     $this->assign('tab', 'rankVerify');
     //四处一词 seo
     $str = '{$user_info.nickname|op_t}';
     $this->setTitle($str . L('_RANK_APPLY_TITLE_'));
     $this->setKeywords($str . L('_RANK_APPLY_KEYWORDS_'));
     $this->setDescription($str . L('_RANK_APPLY_TITLE_'));
     //四处一词 seo end
     $this->display('rank_verify');
 }
 /**
  * @param $fields
  * @param $uid
  * @param $val
  * @param $result
  * @return array
  */
 public function getRankLink($fields, $uid, $val, $result)
 {
     //获取用户头衔链接
     if (in_array('rank_link', $fields)) {
         $rank_List = D('rank_user')->where(array('uid' => $uid, 'status' => 1))->select();
         $num = 0;
         foreach ($rank_List as &$val) {
             $rank = M('rank')->where('id=' . $val['rank_id'])->find();
             $val['title'] = $rank['title'];
             $val['logo_url'] = get_pic_src(M('picture')->where('id=' . $rank['logo'])->field('path')->getField('path'));
             $val['label_content'] = $rank['label_content'];
             $val['label_bg'] = $rank['label_bg'];
             $val['label_color'] = $rank['label_color'];
             if ($val['is_show']) {
                 $num = 1;
             }
         }
         if ($rank_List) {
             $rank_List[0]['num'] = $num;
             $result['rank_link'] = $rank_List;
             return array($val, $result);
         } else {
             $result['rank_link'] = array();
             return array($val, $result);
         }
     }
     return array($val, $result);
 }
Esempio n. 10
0
function render_picture_path($path)
{
    $path = get_pic_src($path);
    return is_bool(strpos($path, 'http://')) ? 'http://' . str_replace('//', '/', $_SERVER['HTTP_HOST'] . '/' . $path) : $path;
}