本文整理汇总了PHP中getRootUrl函数的典型用法代码示例。如果您正苦于以下问题:PHP getRootUrl函数的具体用法?PHP getRootUrl怎么用?PHP getRootUrl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getRootUrl函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAtlasQiniuImageById
/**
* 使用七牛模块
*
* @param $type 0=imageView2, 1=imageMogr2
*/
function getAtlasQiniuImageById($cover_id, $type = 0, $parameters)
{
$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 getRootUrl() . 'Public/images/nopic.png';
}
switch ($picture['type']) {
case 'qiniu':
$qiniuConfig = C('UPLOAD_QINIU_CONFIG');
if ($type == 0) {
//imageView2
$parameters ? $picture['path'] = $picture['path'] . '?imageView/' . $parameters : '';
} else {
//imageMogr2
$parameters ? $picture['path'] = $picture['path'] . '?imageMogr2/' . $parameters : '';
}
//return $picture['path'];
break;
}
return 'http://' . $qiniuConfig['domain'] . '/' . $picture['path'];
}
示例2: getImageUrlByRoleId
/**
* 根据角色获取默认头像
* @param $role_id
* @param $size
* @return mixed|string
* @author 郑钟良<zzl@ourstu.com>
*/
private function getImageUrlByRoleId($role_id, $size)
{
$avatar_id = S('Role_Avatar_Id_' . $role_id);
if (!$avatar_id) {
$map = getRoleConfigMap('avatar', $role_id);
$avatar_id = D('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);
} else {
$path = getRootUrl() . "Public/images/default_avatar.jpg";
}
}
return $path;
}
示例3: getImageUrlByPath
function getImageUrlByPath($path, $size)
{
$thumb = getThumbImage($path, $size);
$thumb = $thumb['src'];
$thumb = substr($thumb, 1);
return getRootUrl() . $thumb;
}
示例4: issueDetail
/**
* @param $id
* 专辑详情页
*/
public function issueDetail($id)
{
// dump($id);exit;
$aPage = I('post.page', 0, 'op_t');
$aCount = I('post.count', 5, 'op_t');
$map['id'] = array('eq', $id);
$mapl['row_id'] = array('eq', $id);
$issuedetail = D('Issue_content')->where($map)->select();
$issuecomment = D('Local_comment')->where(array('status' => 1, $mapl))->page($aPage, $aCount)->order('create_time desc')->select();
D('IssueContent')->where(array('id' => $id))->setInc('view_count');
//查看数加1
$support['appname'] = 'Issue';
//查找需要判断是否点赞的数据
$support['table'] = 'issue_content';
$support['uid'] = is_login();
$is_zan = D('Support')->where($support)->select();
$is_zan = array_column($is_zan, 'row');
$issue_uid = D('IssueContent')->where(array('status' => 1, 'id' => $id))->find();
//根据微博ID查找专辑发送人的UID
foreach ($issuedetail as &$k) {
$k['user'] = query_user(array('nickname', 'avatar32'), $k['uid']);
$k['cover_url'] = getThumbImageByCoverId($k['cover_id']);
//获得原图
$bi = M('Picture')->where(array('status' => 1))->getById($k['cover_id']);
if (!is_bool(strpos($bi['path'], 'http://'))) {
$k['cover_url'] = $bi['path'];
} else {
$k['cover_url'] = getRootUrl() . substr($bi['path'], 1);
}
if (in_array($k['id'], $is_zan)) {
//判断是否已经点赞
$k['is_support'] = '1';
} else {
$k['is_support'] = '0';
}
if (is_administrator(get_uid()) || $issue_uid['uid'] == get_uid()) {
//如果是管理员,则可以删除评论
$k['is_admin_or_mine'] = '1';
} else {
$k['is_admin_or_mine'] = '0';
}
}
foreach ($issuecomment as &$v) {
$v['user'] = query_user(array('nickname', 'avatar32'), $v['uid']);
$v['cover_url'] = getThumbImageByCoverId($v['cover_id']);
$v['content'] = parse_weibo_mobile_content($v['content']);
}
//dump($issuedetail);exit;
$this->assign('issuedetail', $issuedetail);
$this->assign('issuecomment', $issuecomment);
$this->display();
}
示例5: pageHeader
/**
* 站点头部钩子,加载换肤插件所需样式
* @param array $param 相关参数
* @return bool
* @author 郑钟良<zzl@ourstu.com>
*/
public function pageHeader($param)
{
$SkinsUrl = getRootUrl() . "Addons/Skin/Skins/";
$config = getAddonConfig();
if ($config['canSet'] == 0 || $config['mandatory'] == 1) {
//强制执行管理员设置的默认皮肤
// 载入换肤插件默认样式
echo '<link href="' . $SkinsUrl . $config['defaultSkin'] . '/style.css" data-role="skin_link" rel="stylesheet" type="text/css"/>';
} else {
//执行用户设置样式
// 载入换肤插件用户样式
$userSkin = getUserConfig();
echo '<link href="' . $SkinsUrl . $userSkin['skin'] . '/style.css" data-role="skin_link" rel="stylesheet" type="text/css"/>';
}
}
示例6: getSkinInfoList
/**
* 根据皮肤列表,获取皮肤详细信息
* @param $skinList 皮肤列表
* @return array
* @author 郑钟良<zzl@ourstu.com>
*/
function getSkinInfoList($skinList)
{
$skinInfoList = array();
$skinUrl = getRootUrl() . preg_replace('|^' . ONETHINK_ADDON_PATH . '|', 'Addons/', SKIN_PATH);
foreach ($skinList as $path) {
$skinConf = (include SKIN_PATH . 'Skins/' . $path . '/config.php');
$skin['value'] = $path;
$skin['name'] = $skinConf['name'];
$skin['sort'] = $skinConf['sort'];
$skin['thumb_url'] = $skinUrl . 'Skins/' . $path . '/thumb.png';
$skinInfoList[] = $skin;
}
unset($path, $skin);
$skinInfoList = list_sort_by($skinInfoList, 'sort', 'asc');
return $skinInfoList;
}
示例7: 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']);
foreach ($weibo_data['attach_ids'] as $k_i => $v_i) {
$weibo_data['image'][$k_i]['small'] = getThumbImageById($v_i, 100, 100);
$bi = M('Picture')->where(array('status' => 1))->getById($v_i);
if (!is_bool(strpos($bi['path'], 'http://'))) {
$weibo_data['image'][$k_i]['big'] = $bi['path'];
} else {
$weibo_data['image'][$k_i]['big'] = getRootUrl() . substr($bi['path'], 1);
}
$param['weibo'] = $weibo;
$param['weibo']['weibo_data'] = $weibo_data;
}
$this->assign($param);
return $this->fetch(T('Application://Weibo@Type/fetchimage'));
}
示例8: fetchImage
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) {
if (strtolower(C('PICTURE_UPLOAD_DRIVER')) == 'sae') {
$weibo_data['image'][$k_i]['small'] = getThumbImageById($v_i, 100, 100);
// dump( $weibo_data['image'][$k_i]['small']);exit;
$bi = M('Picture')->where(array('status' => 1))->getById($v_i);
$weibo_data['image'][$k_i]['big'] = $bi['path'];
} else {
$weibo_data['image'][$k_i]['small'] = getThumbImageById($v_i, 100, 100);
$bi = M('Picture')->where(array('status' => 1))->getById($v_i);
$weibo_data['image'][$k_i]['big'] = getRootUrl() . substr($bi['path'], 1);
}
$param['weibo'] = $weibo;
$param['weibo']['weibo_data'] = $weibo_data;
}
$this->assign($param);
return $this->fetch('display');
}
示例9: _doEditQusetion
private function _doEditQusetion()
{
$aId = I('post.id', 0, 'intval');
$need_audit = modC('QUESTION_NEED_AUDIT', 1, 'Question');
if ($aId) {
$data['id'] = $aId;
$now_data = M('Mob/Question')->getData($aId);
$this->checkAuth('Question/Index/edit', $now_data['uid'], '没有编辑该问题权限!');
if ($need_audit) {
$data['status'] = 2;
}
$this->checkActionLimit('edit_question', 'question', $now_data['id'], get_uid());
} else {
$this->checkAuth('Question/Index/add', -1, '没有发布问题的权限!');
$this->checkActionLimit('add_question', 'question', 0, get_uid());
$data['uid'] = get_uid();
$data['answer_num'] = $data['good_question'] = 0;
if ($need_audit) {
$data['status'] = 2;
} else {
$data['status'] = 1;
}
}
$data['title'] = I('post.title', '', 'text');
$data['category'] = I('post.category', 0, 'intval');
$attach_ids = I('post.attach_ids', '0', 'op_t');
if ($attach_ids) {
$data['description'] = I('post.description', '', 'filter_content');
$img_ids = explode(',', $attach_ids);
//把图片和内容结合
// dump($img_ids);
foreach ($img_ids as &$v) {
$v = D('Picture')->where(array('status' => 1))->getById($v);
if (!is_bool(strpos($v['path'], 'http://'))) {
$v = $v['path'];
} else {
$v = getRootUrl() . substr($v['path'], 1);
}
$v = '<p><img src="' . $v . '" style=""/></p><br>';
}
$img_ids = implode('', $img_ids);
// dump($img_ids);
$data['description'] = $img_ids . $data['description'];
$contentHandler = new ContentHandlerModel();
$data['description'] = $contentHandler->filterHtmlContent($data['description']);
//把图片和内容结合END
} else {
$data['description'] = I('post.description', '', 'filter_content');
}
if (!mb_strlen($data['title'], 'utf-8')) {
$this->error('标题不能为空!');
}
$res = M('Mob/Question')->editData($data);
$title = $aId ? "编辑" : "提";
if ($res) {
if (!$aId) {
$aId = $res;
if ($need_audit) {
$data['status'] = 1;
$data['info'] = $title . '问题成功!' . ' 请等待审核~';
$this->ajaxReturn($data);
}
}
if (M('Common/Module')->isInstalled('Weibo')) {
//安装了轻博客模块
//同步到轻博客
$postUrl = "http://{$_SERVER['HTTP_HOST']}" . U('Mob/Question/questionDetail', array('id' => $aId));
$weiboModel = M('Mob/Weibo');
$weiboModel->addWeibo("我问了一个问题【" . $data['title'] . "】:" . $postUrl);
}
$data['status'] = 1;
$data['info'] = $title . '问题成功!' . ' 请等待审核~';
} else {
$data['status'] = 0;
$data['info'] = $title . '问题失败!';
}
$this->ajaxReturn($data);
}
示例10: doSendBlog
public function doSendBlog()
{
$aId = I('post.id', 0, 'intval');
$data['category'] = I('post.category', 0, 'intval');
if ($aId) {
$data['id'] = $aId;
$now_data = M('News/News')->getData($aId);
if ($now_data['status'] == 1) {
$this->error('该资讯已被审核,不能被编辑!');
}
$category = M('News/newsCategory')->where(array('status' => 1, 'id' => $data['category']))->find();
if ($category) {
if ($category['can_post']) {
if ($category['need_audit']) {
$data['status'] = 2;
} else {
$data['status'] = 1;
}
} else {
$this->error('该分类不能投稿!');
}
} else {
$this->error('该分类不存在或被禁用!');
}
$data['status'] = 2;
$data['template'] = $now_data['detail']['template'] ?: '';
} else {
$this->checkActionLimit('add_news', 'news', 0, is_login(), true);
$data['uid'] = get_uid();
$data['sort'] = $data['position'] = $data['view'] = $data['comment'] = $data['collection'] = 0;
$category = M('News/NewsCategory')->where(array('status' => 1, 'id' => $data['category']))->find();
if ($category) {
if ($category['can_post']) {
if ($category['need_audit']) {
$data['status'] = 2;
} else {
$data['status'] = 1;
}
} else {
$this->error('该分类不能投稿!');
}
} else {
$this->error('该分类不存在或被禁用!');
}
$data['template'] = '';
}
$data['title'] = I('post.title', '', 'text');
$data['cover'] = I('post.one_attach_id', 0, 'intval');
$data['description'] = I('post.description', '', 'text');
$data['dead_line'] = I('post.dead_line', '', 'text');
$data['content_img'] = I('post.attach_ids', '', 'text');
if ($data['dead_line'] == '') {
$data['dead_line'] = 99999999999;
} else {
$data['dead_line'] = strtotime($data['dead_line']);
}
$data['source'] = I('post.source', '', 'text');
$data['content'] = I('post.content', '', 'html');
if (!mb_strlen($data['title'], 'utf-8')) {
$this->error('标题不能为空!');
}
if (mb_strlen($data['content'], 'utf-8') < 20) {
$this->error('内容不能少于20个字!');
}
if ($data['content_img']) {
$img_ids = explode(',', $data['content_img']);
//把图片和内容结合
foreach ($img_ids as &$v) {
$v = D('Picture')->where(array('status' => 1))->getById($v);
if (!is_bool(strpos($v['path'], 'http://'))) {
$v = $v['path'];
} else {
$v = getRootUrl() . substr($v['path'], 1);
}
$v = '<p><img src="' . $v . '" style=""/></p><br>';
}
$img_ids = implode('', $img_ids);
$data['content'] = $img_ids . $data['content'];
$contentHandler = new ContentHandlerModel();
$data['content'] = $contentHandler->filterHtmlContent($data['content']);
//把图片和内容结合END
}
// dump($data['content']);exit;
$res = M('News/news')->editData($data);
// dump(M('News/newsModel')->getLastSql());exit;
$title = $aId ? "编辑" : "新增";
if ($res) {
if (!$aId) {
$aId = $res;
if ($category['need_audit']) {
$return['status'] = 1;
$return['info'] = $title . '资讯成功!请等待审核~';
}
}
$return['status'] = 1;
$return['info'] = $title . '资讯成功!';
} else {
$return['status'] = 0;
$return['info'] = $title . '资讯失败!';
}
//.........这里部分代码省略.........
示例11: tfu_info
function tfu_info($file)
{
global $use_image_magic;
unset($_SESSION['TFU_LAST_UPLOADS']);
$_SESSION['TFU_LAST_PREVIEW'] = fixUrl(getRootUrl() . $file);
echo '&size=' . filesize($file);
// we check if the image can be resized
if (is_supported_tfu_image($file)) {
set_error_handler('on_error_no_output');
// is needed because error are most likly but we don't care about fields we don't even know
$oldsize = @getimagesize($file);
set_error_handler('on_error');
if ($oldsize) {
if (isMemoryOk($oldsize, "")) {
echo '&hasPreview=true&tfu_x=' . $oldsize[0] . '&tfu_y=' . $oldsize[1];
// has preview!
} else {
echo '&hasPreview=error';
// too big! - same error massage as hasPreview=false
}
return;
}
echo '&hasPreview=false';
// no image!
}
if (preg_match("/.*\\.(p|P)(d|D)(f|F)\$/", $file) && $use_image_magic && file_exists(dirname(__FILE__) . '/thumbs') && is_writable(dirname(__FILE__) . '/thumbs')) {
// check if pdf
echo '&hasPreview=true&tfu_x=1000&tfu_y=1000';
// has preview! - pdfs are max 1000x1000';
return;
}
echo '&hasPreview=false';
}
示例12: getProfile
public function getProfile($uid = null)
{
//默认查看自己的详细资料
if (!$uid) {
$this->requireLogin();
$uid = $this->getUid();
}
//读取数据库中的用户详细资料
$map = array('uid' => $uid);
$user1 = D('Home/Member')->where($map)->find();
$user2 = D('User/UcenterMember')->where(array('id' => $uid))->find();
//获取头像信息
$avatar = new AvatarAddon();
$avatar_path = $avatar->getAvatarPath($uid);
$avatar_url = getRootUrl() . $avatar->getAvatarPath($uid);
//缩略头像
$avatar128_path = getThumbImage($avatar_path, 128);
$avatar128_path = '/' . $avatar128_path['src'];
$avatar128_url = getRootUrl() . $avatar128_path;
//获取等级
$title = D('Usercenter/Title')->getTitle($user1['score']);
//只返回必要的详细资料
$this->apiSuccess("获取成功", null, array('uid' => $uid, 'avatar_url' => $avatar_url, 'avatar128_url' => $avatar128_url, 'signature' => $user1['signature'], 'email' => $user2['email'], 'mobile' => $user2['mobile'], 'score' => $user1['score'], 'name' => $user1['name'], 'sex' => $this->encodeSex($user1['sex']), 'birthday' => $user1['birthday'], 'title' => $title, 'username' => $user2['username']));
}
示例13: addmoreWeibo
public function addmoreWeibo()
{
$aPage = I('post.page', 1, 'op_t');
$aCount = I('post.count', 10, 'op_t');
$uid = I('post.uid', '', 'op_t');
$weibo = D('Weibo')->where(array('status' => 1, 'uid' => $uid))->order('create_time desc')->page($aPage, $aCount)->select();
//我关注的人的微博
$support['appname'] = 'Weibo';
//查找是否点赞
$support['table'] = 'weibo';
$support['uid'] = is_login();
$is_zan = D('Support')->where($support)->select();
$is_zan = array_column($is_zan, 'row');
foreach ($weibo as &$v) {
$v['user'] = query_user(array('nickname', 'avatar64', 'space_mob_url'), $v['uid']);
$v['rand_title'] = mob_get_head_title($v['uid']);
$v['support'] = D('Support')->where(array('appname' => 'Weibo', 'table' => 'weibo', 'row' => $v['id']))->count();
$v['content'] = parse_weibo_mobile_content($v['content']);
if (empty($v['from'])) {
$v['from'] = "网站端";
}
$v['data'] = unserialize($v['data']);
//字符串转换成数组,获取微博源ID
if ($v['data']['sourceId']) {
//判断是否是源微博
$v['sourceId'] = $v['data']['sourceId'];
$v['is_sourceId'] = '1';
} else {
$v['sourceId'] = $v['id'];
$v['is_sourceId'] = '0';
}
$v['sourceId_user'] = D('Weibo')->where(array('status' => 1, 'id' => $v['sourceId']))->find();
//源微博用户名
$v['sourceId_user'] = $v['sourceId_user']['uid'];
$v['sourceId_user'] = query_user(array('nickname', 'space_mob_url'), $v['sourceId_user']);
$v['sourceId_content'] = D('Weibo')->where(array('status' => 1, 'id' => $v['sourceId']))->field('content')->find();
//源微博内容
$v['sourceId_content'] = parse_weibo_mobile_content($v['sourceId_content']['content']);
//把表情显示出来。
$v['sourceId_repost_count'] = D('Weibo')->where(array('status' => 1, 'id' => $v['sourceId']))->field('repost_count')->find();
//源微博转发数
$v['sourceId_from'] = D('Weibo')->where(array('status' => 1, 'id' => $v['sourceId']))->field('from')->find();
//源微博来源
if (empty($v['sourceId_from']['from'])) {
$v['sourceId_from'] = "网站端";
} else {
$v['sourceId_from'] = "手机网页版";
}
$v['sourceId_img'] = D('Weibo')->where(array('status' => 1, 'id' => $v['sourceId']))->field('data')->find();
//为了获取源微图片
$v['sourceId_img'] = unserialize($v['sourceId_img']['data']);
$v['sourceId_img'] = explode(',', $v['sourceId_img']['attach_ids']);
//把attach_ids里的图片ID转出来
foreach ($v['sourceId_img'] as &$b) {
$v['sourceId_img_path'][] = getThumbImageById($b, 100, 100);
//获得缩略图
//获得原图
$bi = M('Picture')->where(array('status' => 1))->getById($b);
if (!is_bool(strpos($bi['path'], 'http://'))) {
$v['sourceId_img_big'][] = $bi['path'];
} else {
$v['sourceId_img_big'][] = getRootUrl() . substr($bi['path'], 1);
}
}
$v['cover_url'] = explode(',', $v['data']['attach_ids']);
//把attach_ids里的图片ID转出来
foreach ($v['cover_url'] as &$a) {
$v['img_path'][] = getThumbImageById($a, 100, 100);
//获得原图
$bi = M('Picture')->where(array('status' => 1))->getById($b);
if (!is_bool(strpos($bi['path'], 'http://'))) {
$v['sourceId_img_big'][] = $bi['path'];
} else {
$v['sourceId_img_big'][] = getRootUrl() . substr($bi['path'], 1);
}
}
if (in_array($v['id'], $is_zan)) {
//判断是否已经点赞
$v['is_support'] = '1';
} else {
$v['is_support'] = '0';
}
if (empty($v['data']['attach_ids'])) {
//判断是否是图片
$v['is_img'] = '0';
} else {
$v['is_img'] = '1';
}
if (empty($v['sourceId_img']['0'])) {
$v['sourceId_is_img'] = '0';
} else {
$v['sourceId_is_img'] = '1';
}
}
if ($weibo) {
$data['html'] = "";
foreach ($weibo as $val) {
$this->assign("vo", $val);
$data['html'] .= $this->fetch("_myweibo");
$data['status'] = 1;
//.........这里部分代码省略.........
示例14: fixAttachUrl
function fixAttachUrl($url)
{
if (is_local()) {
return str_replace('//', '/', getRootUrl() . $url);
//防止双斜杠的出现
} else {
return $url;
}
}
示例15: get_pic_src
/**
* get_pic_src 渲染图片链接
* @param $path
* @return mixed
* @author:xjw129xjt(肖骏涛) xjt@ourstu.com
*/
function get_pic_src($path)
{
//不存在http://
$not_http_remote = strpos($path, 'http://') === false;
//不存在https://
$not_https_remote = strpos($path, 'https://') === false;
if ($not_http_remote && $not_https_remote) {
//本地url
return str_replace('//', '/', getRootUrl() . $path);
//防止双斜杠的出现
} else {
//远端url
return $path;
}
}