public function artc()
 {
     $id = I('id');
     $info = D('Article')->get_info($id);
     if (!$info) {
         $this->error('非法ID!', U('Index/index'), false, true);
     }
     $info['description'] = stripcslashes($info['description']);
     preg_match_all("/(?<=\\[attach\\])([\\d]*)(?=\\[\\/attach\\])/", $info['description'], $arr);
     preg_match_all("/(?<=\\[qnattach\\])([\\d]*)(?=\\[\\/qnattach\\])/", $info['description'], $qnarr);
     foreach ($arr[0] as $key => $vo) {
         $replace = '<a href="' . U('File/download', array('id' => think_encrypt($vo))) . '" target="_blank" >' . getattachname($vo) . '</a><span class="attachspan">(下载次数:' . getattachdnum($vo) . '次;大小:' . format_bytes(getattachsize($vo)) . ')</span>';
         $info['description'] = str_replace('[attach]' . $vo . '[/attach]', $replace, $info['description']);
     }
     foreach ($qnarr[0] as $key1 => $vo1) {
         $replace1 = '<a href="' . U('File/download', array('qn' => 1, 'id' => think_encrypt($vo1))) . '" target="_blank" >' . getqnattachname($vo1) . '</a><span class="attachspan">(下载次数:' . getqnattachdnum($vo1) . '次;大小:' . format_bytes(getqnattachsize($vo1)) . ')</span>';
         $info['description'] = str_replace('[qnattach]' . $vo1 . '[/qnattach]', $replace1, $info['description']);
     }
     if ($info['status'] != 1 && $info['uid'] != $_SESSION['cs_home']['user_auth']['uid']) {
         $this->error('你无权查看该内容!', '', false, true);
     }
     $focus['rowid'] = $info['id'];
     $focus['type'] = 1;
     if ($sccount = M('focus')->where($focus)->count() != $info['sccount']) {
         D('Article')->where(array('id' => $id))->setField('sccount', $sccount);
     }
     D('Article')->where(array('id' => $id))->setInc('view', 1);
     if (!empty($info['tag'])) {
         $tags = explode(',', $info['tag']);
         $info['linktag'] = '';
         foreach ($tags as $key1 => $vo1) {
             $maptag['title'] = $vo1;
             $maptag['type'] = 1;
             $tagid = M('tags')->where($maptag)->getField('id');
             $url = CSU('/tagart/' . $tagid, 'Index/tagart', array('id' => $tagid));
             $info['linktag'] .= '<a style="margin-left:5px;" href="' . $url . '">[' . $vo1 . ']</a>';
             $info['tagarr'][$key1] = '<a class="tag" href="' . $url . '">' . $vo1 . '</a>';
         }
     }
     $shareurl = 'http://' . $_SERVER['HTTP_HOST'] . CSU('/artc/' . $info['id'], 'Index/artc', array('id' => $info['id']));
     $sharedes = '原文链接:' . $shareurl;
     $sharetitle = $info['title'] . '-' . C('WEB_SITE_TITLE');
     $authorinfo = query_user(array('space_url', 'signature', 'avatar64', 'nickname'), $info['uid']);
     $map['id'] = is_login();
     $map['rowid'] = $info['id'];
     $map['type'] = 1;
     if (M('Focus')->where($map)->count() > 0) {
         $hassc = true;
     }
     $this->assign('shareurl', $shareurl);
     $this->assign('hassc', $hassc);
     $this->assign('sharedes', $sharedes);
     $this->assign('sharetitle', $sharetitle);
     $this->assign('authorinfo', $authorinfo);
     $this->assign('info', $info);
     $this->assign('webdescription', $info['title']);
     $this->assign('webkeyword', $info['title']);
     $this->assign('webtitle', $info['title']);
     $this->display();
 }
Exemple #2
0
 public function get_info($id)
 {
     $map['id'] = $id;
     $info = $this->where($map)->find();
     if ($info === false || empty($info)) {
         return false;
     }
     $info['copyright'] = str_replace('{link}', CSU('/artc/' . $info['id'], 'Index/artc', array('id' => $info['id'])), $info['copyright']);
     return $info;
 }
 public function article()
 {
     $Blogs = D('Article');
     $blog = $Blogs->where(array('status' => 1))->getField('id,title,description,create_time,uid');
     $RssConf = array('channelTitle' => 'zswin社交类博客', 'channelLink' => 'http://zswin.cn', 'channelDescrīption' => 'zswin开源博客', 'copyright' => 'zswin');
     $RSS = new Rss($RssConf);
     foreach ($blog as $k => $v) {
         $RSS->AddItem($v['title'], CSU('/artc/' . $v['id'], 'Index/artc', array('id' => $v['id'])), $v['description'], toDate($v['create_time']), $v['id'], get_username($v['uid']));
     }
     $RSS->SaveToFile("./rss.xml");
     echo $RSS->Show();
 }
Exemple #4
0
 public static function treeFormat($arr)
 {
     $html = '';
     foreach ($arr as $_v) {
         if (!empty($_v['child'])) {
             $html .= '<li id="cate' . $_v['id'] . '" class="dropdown"><a href="' . CSU('/artlist/' . $_v['id'], 'Index/artlist', array('cid' => $_v['id'])) . '">' . $_v['name'] . '<span class="caret"></span></a><div class="grid-container3"><ul>' . self::treeFormat($_v['child']) . '</ul></div></li>';
         } else {
             $html .= '<li  id="cate' . $_v['id'] . '"><a href="' . CSU('/artlist/' . $_v['id'], 'Index/artlist', array('cid' => $_v['id'])) . '">' . $_v['name'] . '</a></li>';
         }
     }
     $html .= '';
     return $html;
 }
Exemple #5
0
/**
 * 支持的字段有
 * member表中的所有字段,ucenter_member表中的所有字段
 * 等级:title
 * 头像:avatar32 avatar64 avatar128 avatar256 avatar512
 * 个人中心地址:space_url
 * 认证图标:icons_html
 *
 * @param      $fields array|string 如果是数组,则返回数组。如果不是数组,则返回对应的值
 * @param null $uid
 * @return array|null
 */
function query_user($fields, $uid = null)
{
    //如果fields不是数组,则返回值也不是数组
    if (!is_array($fields)) {
        $result = query_user(array($fields), $uid);
        return $result[$fields];
    }
    //默认获取自己的资料
    $uid = $uid ? $uid : is_login();
    if (!$uid) {
        return null;
    }
    //获取两张用户表格中的所有字段
    $homeModel = M('Member');
    $ucenterModel = M('UcenterMember');
    $homeFields = $homeModel->getDbFields();
    $ucenterFields = $ucenterModel->getDbFields();
    //分析每个表格分别要读取哪些字段
    $avatarFields = array('avatar32', 'avatar64', 'avatar128', 'avatar256', 'avatar512');
    $avatarFields = array_intersect($avatarFields, $fields);
    $homeFields = array_intersect($homeFields, $fields);
    $ucenterFields = array_intersect($ucenterFields, $fields);
    //查询需要的字段
    $homeResult = array();
    $ucenterResult = array();
    if ($homeFields) {
        $homeResult = D('Home/Member')->where(array('uid' => $uid))->field($homeFields)->find();
    }
    if ($ucenterFields) {
        $model = D('User/UcenterMember');
        $ucenterResult = $model->where(array('id' => $uid))->field($ucenterFields)->find();
    }
    //读取头像数据
    $result = array();
    $avatarAddon = new \Addons\Avatar\AvatarAddon();
    foreach ($avatarFields as $e) {
        $avatarSize = intval(substr($e, 6));
        $avatarUrl = $avatarAddon->getAvatarPath($uid, $avatarSize);
        $result[$e] = $avatarUrl;
    }
    //读取等级数据
    if (in_array('title', $fields)) {
        $titleModel = D('Usercenter/Title');
        $title = $titleModel->getTitle($uid);
        $result['title'] = $title;
    }
    if (in_array('supportnum', $fields)) {
        $result['supportnum'];
    }
    if (in_array('commentnum', $fields)) {
        $result['commentnum'];
    }
    if (in_array('allartnum', $fields)) {
        $artnum = M('Article')->where(array('uid' => $uid))->count();
        $result['allartnum'] = empty($artnum) ? 0 : $artnum;
    }
    if (in_array('artnum', $fields)) {
        $artnum = M('Article')->where(array('uid' => $uid, 'status' => 1))->count();
        $result['artnum'] = empty($artnum) ? 0 : $artnum;
    }
    if (in_array('focusnum', $fields)) {
        $mapfocusnum['id'] = $uid;
        $mapfocusnum['type'] = 0;
        $result['focusnum'] = D('Focus')->where($mapfocusnum)->count();
    }
    if (in_array('scartnum', $fields)) {
        $mapscartnum['id'] = $uid;
        $mapscartnum['type'] = 1;
        $result['scartnum'] = D('Focus')->where($mapscartnum)->count();
    }
    if (in_array('tagfocusnum', $fields)) {
        $maptagfocusnum['id'] = $uid;
        $maptagfocusnum['type'] = 2;
        $result['tagfocusnum'] = D('Focus')->where($maptagfocusnum)->count();
    }
    if (in_array('zan', $fields)) {
        $zannum = M('Article')->where(array('uid' => $uid))->sum('ding');
        $result['zan'] = empty($zannum) ? 0 : $zannum;
    }
    //读取用户名拼音
    if (in_array('pinyin', $fields)) {
        $result['pinyin'] = D('Pinyin')->pinYin($result['nickname']);
    }
    //获取个人中心地址
    $spaceUrlResult = array();
    if (in_array('space_url', $fields)) {
        $result['space_url'] = CSU('/userart/' . $uid, 'Ucenter/userart', array('uid' => $uid));
    }
    $ucenterResult['nickname'] = op_t($ucenterResult['nickname']);
    //获取昵称链接
    if (in_array('space_link', $fields)) {
        $result['space_link'] = '<a ucard="' . $uid . '" href="' . CSU('/userart/' . $uid, 'Ucenter/userart', array('uid' => $uid)) . '">' . $ucenterResult['nickname'] . '</a>';
    }
    //获取用户头衔链接
    if (in_array('rank_link', $fields)) {
        $rank_List = D('rank_user')->where('uid=' . $uid)->select();
        $num = 0;
        foreach ($rank_List as &$val) {
            $rank = D('rank')->where('id=' . $val['rank_id'])->find();
            $val['title'] = $rank['title'];
            $val['logo_url'] = fixAttachUrl(D('picture')->where('id=' . $rank['logo'])->getField('path'));
            if ($val['is_show']) {
                $num = 1;
            }
        }
        if ($rank_List) {
            $rank_List[0]['num'] = $num;
            $result['rank_link'] = $rank_List;
        } else {
            $result['rank_link'] = array();
        }
    }
    if (in_array('signature', $fields)) {
        $result['signature'] = D('Home/Member')->where(array('uid' => $uid))->field($homeFields)->getField('signature');
        if ($result['signature'] == null) {
            $result['signature'] = '暂无个人签名';
        }
    }
    //获取用户认证图标
    if (in_array('icons_html', $fields)) {
        //判断是否有手机图标
        $static = C('TMPL_PARSE_STRING.__STATIC__');
        $iconUrls = array();
        $user = query_user(array('mobile'), $uid);
        if ($user['mobile']) {
            $iconUrls[] = "{$static}/images/mobile-bind.png";
        }
        //生成结果
        $result['icons_html'] = '<span class="usercenter-verify-icon-list">';
        foreach ($iconUrls as $e) {
            $result['icons_html'] .= "<img src=\"{$e}\" title=\"对方已绑定手机\"/>";
        }
        $result['icons_html'] .= '</span>';
    }
    //粉丝数、关注数
    if (in_array('fensi', $fields)) {
        $mapfensi['rowid'] = $uid;
        $mapfensi['type'] = 0;
        $result['fensi'] = D('Focus')->where($mapfensi)->count();
    }
    //↑↑↑ 新增字段应该写在在这行注释以上 ↑↑↑
    //合并结果,不包括缓存
    $result = array_merge($ucenterResult, $homeResult, $spaceUrlResult, $result);
    //返回结果
    return $result;
}
        <h2 class="title"><a href="<?php 
            echo CSU('/artc/' . $vo['id'], 'Index/artc', array('id' => $vo['id']));
            ?>
"><?php 
            echo $vo["titleicon"];
            ?>
<span><?php 
            echo $vo["title"];
            ?>
</span></a></h2>
                 <?php 
            if ($vo['img'] != '') {
                ?>
<div class="entry-thumbnail">
<a href="<?php 
                echo CSU('/artc/' . $vo['id'], 'Index/artc', array('id' => $vo['id']));
                ?>
" title="<?php 
                echo $vo["title"];
                ?>
">
<img src="<?php 
                echo $vo["img"];
                ?>
" alt="<?php 
                echo $vo["title"];
                ?>
" ></a>
</div><?php 
            }
            ?>
Exemple #7
0
function navurl($id, $type)
{
    $info = D('nav')->where(array('id' => $id))->find();
    if ($type == 0) {
        $ctype = get_cate_typeByid($info['cid']);
        switch ($ctype) {
            case 1:
                $url = CSU('/artlist/' . $info['cid'], 'Index/artlist', array('cid' => $info['cid']));
                break;
            case 2:
                $url = CSU('/musiclist/' . $info['cid'], 'Index/musiclist', array('cid' => $info['cid']));
                break;
            case 3:
                $url = CSU('/grouplist/' . $info['cid'], 'Index/grouplist', array('cid' => $info['cid']));
                break;
        }
    }
    if ($type == 1) {
        switch ($info['gid']) {
            case 1:
                $url = CSU('/artlist/all', 'Index/artlist');
                break;
            case 2:
                $url = CSU('/musiclist/all', 'Index/musiclist');
                break;
            case 3:
                $url = CSU('/grouplist/all', 'Index/grouplist');
                break;
        }
    }
    if ($type == 2) {
        $url = U($info['controll'] . '/' . $info['action']);
    }
    if ($type == 3) {
        $url = $info['url'];
    }
    return $url;
}
 public function getArt($cate, $child = true, $uid, $status, $order, $field = true, $row, $onetag, $title, $position, $limit, $focus)
 {
     if ($onetag != '') {
         $map['tag'] = array('like', '%' . $onetag . '%');
     }
     if ($position != '') {
         $map['tj'] = array('in', $position);
     }
     if ($title != '') {
         $map['title'] = array('like', '%' . $title . '%');
     }
     if ($child) {
         $cateids = D('Home/Cate')->getChildrenId($cate);
     } else {
         $cateids = $cate;
     }
     if ($uid != 0) {
         $map['uid'] = array('in', $uid);
     }
     if ($cateids != null) {
         $map['cid'] = array('in', $cateids);
     }
     $map['status'] = array('in', $status);
     if ($focus) {
         $loginuid = is_login();
         $focusuid = M('focus')->where(array('id' => $loginuid, 'type' => 0))->getField('rowid', true);
         $focustag = M('focus')->where(array('id' => $loginuid, 'type' => 2))->getField('rowid', true);
         if ($focustag != null) {
             foreach ($focustag as $key => $vo) {
                 $focustagarr[$key] = '%' . M('tags')->where(array('id' => $vo))->getField('title') . '%';
             }
             $where['tag'] = array('like', $focustagarr, 'OR');
             if ($focusuid != null) {
                 $where['uid'] = array('in', $focusuid);
                 $where['_logic'] = 'or';
             }
             $map['_complex'] = $where;
         } else {
             if ($focusuid != null) {
                 $where['uid'] = array('in', $focusuid);
                 $map['_complex'] = $where;
             } else {
                 $map['status'] = -1;
             }
         }
     }
     $count = $this->model->where($map)->count();
     if ($count > 0) {
         $p = I(C('VAR_PAGE'));
         if ($limit) {
             $data = $this->model->where($map)->order($order)->limit($row)->field($field)->select();
         } else {
             $data = $this->model->where($map)->order($order)->page(!empty($p) ? $p : 1, $row)->field($field)->select();
         }
     }
     if ($data == null) {
         $this->apiError("获取文章列表失败", null);
     } else {
         foreach ($data as $key => $vo) {
             if ($vo['tj'] == 1) {
                 $data[$key]['titleicon'] = '[<i class="icon-thumbs-up"></i> 推荐]';
             }
             if ($vo['tj'] == 2) {
                 $data[$key]['titleicon'] = '[<i class="icon-arrow-up"></i> 置顶]';
             }
             $data[$key]['yesedit'] = getarteditauth($vo['id'], $uid) || is_admin($uid);
             $data[$key]['img'] = getImgs($vo['description'], 0);
             $data[$key]['user'] = query_user(array('nickname', 'username', 'space_url', 'avatar32', 'avatar64'), $vo['uid']);
             if ($title != '') {
                 $data[$key]['title'] = str_replace($title, '<b style="color:red">' . $title . '</b>', $vo['title']);
             }
             if (!empty($vo['tag'])) {
                 $tags = explode(',', $vo['tag']);
                 $data[$key]['linktag'] = '';
                 foreach ($tags as $key1 => $vo1) {
                     $maptag['title'] = $vo1;
                     $maptag['type'] = 1;
                     $tagid = M('tags')->where($maptag)->getField('id');
                     $url = CSU('/tagart/' . $tagid, 'Index/tagart', array('id' => $tagid));
                     if ($onetag != '' && $onetag == $vo1) {
                         $data[$key]['linktag'] .= '<a style="margin-left:5px;color:red;" href="' . $url . '">[' . $vo1 . ']</a>';
                     } else {
                         $data[$key]['linktag'] .= '<a style="margin-left:5px;" href="' . $url . '">[' . $vo1 . ']</a>';
                     }
                 }
             }
         }
         $this->apiSuccess("获取文章列表成功", null, array('data' => $data));
     }
 }
    <?php 
echo hook('Advs', 'below_sidebar');
?>

</div><!-- /.layout-sidebar -->

				

<div class="col-xs-12 col-md-9 main mt30">
    <div class="panel panel-default panel-archive">
        <div class="panel-body">
            <!-- Nav tabs -->
            <ul class=" nav nav-pills pb10 mb10 mt10">
                <li class="active"><a href="<?php 
echo CSU('/course/', 'Index/course');
?>
">已选课程</a></li>
                <?php 
if (is_array($coursed)) {
    $i = 0;
    $__LIST__ = $coursed;
    if (count($__LIST__) == 0) {
        echo "";
    } else {
        foreach ($__LIST__ as $key => $vo) {
            $mod = $i % 2;
            ++$i;
            ?>
<li><a><?php 
            echo getNameById('course', $vo["couid"]);
			</form>
		</div><!-- end 搜索框 -->
	</div>
</div>


	<div class="wrap maincontent">
		
		<div class="container">
			<div class="row">
				

					<div class="panel-body">
						<h3 class="page-header">发布 <small>POST NEW</small></h3>
						<h4><a href="<?php 
echo CSU('/userart/' . $userinfo['uid'], 'Ucenter/userart', array('uid' => $userinfo['uid']));
?>
"><<返回我的文章列表</a></h4>
						<form editor="zswineditor" action="<?php 
echo U('Ucenter/artadd');
?>
" target="formAjax" method="post" noenter>
							<div class="form-group">
								<input type="text" class="form-control" name="title" placeholder="在此输入标题" value="">
							</div>

							<div class="form-group">



							<div class="markeditor">
 public function wxevent($data)
 {
     $artid = C('WXARTID');
     $mapart['id'] = array('in', explode(',', $artid));
     $artarr = M('article')->where($mapart)->order('tj desc')->select();
     $art = array();
     foreach ($artarr as $key => $vo) {
         $art[$key] = array('Title' => $vo['title'], 'Description' => cutstr_html(op_t($vo['description']), 50), 'PicUrl' => getImgs($vo['description'], 0), 'Url' => (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . '/' . C('WEB_DIR') . '/' . CSU('/artc/' . $vo['id'], 'Index/artc', array('id' => $vo['id'])));
     }
     if ($data['event'] == 'subscribe') {
         $result = array('MsgType' => 'text', 'Content' => C('WXWELCOME'));
     }
     if ($data['event'] == 'CLICK') {
         if ($data['key'] == 'newblog') {
             $result = array('MsgType' => 'news', 'Content' => $art);
         }
     }
     switch ($result['MsgType']) {
         case 'text':
             $this->wx->text($result['Content'])->reply();
             break;
         case 'news':
             $this->wx->news($result['Content'])->reply();
             break;
     }
 }
Exemple #12
0
 /**
  * 组装分页链接
  * @return string
  */
 public function show()
 {
     if (0 == $this->totalRows) {
         return '';
     }
     /* 生成URL */
     $this->parameter[$this->p] = '[PAGE]';
     foreach ($this->parameter as $vo) {
         $strarg .= '/' . $vo;
     }
     $this->url = CSU('/' . ACTION_NAME . $strarg, ACTION_NAME, $this->parameter);
     /* 计算分页信息 */
     $this->totalPages = ceil($this->totalRows / $this->listRows);
     //总页数
     if (!empty($this->totalPages) && $this->nowPage > $this->totalPages) {
         $this->nowPage = $this->totalPages;
     }
     /* 计算分页零时变量 */
     $now_cool_page = $this->rollPage / 2;
     $now_cool_page_ceil = ceil($now_cool_page);
     $this->lastSuffix && ($this->config['last'] = $this->totalPages);
     //上一页
     $up_row = $this->nowPage - 1;
     $up_page = $up_row > 0 ? '<li><a class="prev" href="' . $this->url($up_row) . '">' . $this->config['prev'] . '</a></li>' : '';
     //下一页
     $down_row = $this->nowPage + 1;
     $down_page = $down_row <= $this->totalPages ? '<li><a class="next" href="' . $this->url($down_row) . '">' . $this->config['next'] . '</a></li>' : '';
     //第一页
     $the_first = '';
     //当整个页面大于
     if ($this->totalPages > $this->rollPage && $this->nowPage - $now_cool_page >= 1) {
         $the_first = '<li><a class="first" href="' . $this->url(1) . '">' . $this->config['first'] . '</a></li>';
     }
     //下一个十页
     $nextrollpage = '';
     $the_end = '';
     if ($this->totalPages > $this->rollPage && $this->nowPage + $now_cool_page < $this->totalPages) {
         $the_end = '<li><a class="end" href="' . $this->url($this->totalPages) . '">' . $this->config['last'] . '</a></li>';
     }
     //最后一页
     $the_end = '';
     if ($this->totalPages > $this->rollPage && $this->nowPage + $now_cool_page < $this->totalPages) {
         $the_end = '<li><a class="end" href="' . $this->url($this->totalPages) . '">' . $this->config['last'] . '</a></li>';
     }
     //数字连接
     $link_page = "";
     for ($i = 1; $i <= $this->rollPage; $i++) {
         if ($this->nowPage - $now_cool_page <= 0) {
             $page = $i;
         } elseif ($this->nowPage + $now_cool_page - 1 >= $this->totalPages) {
             $page = $this->totalPages - $this->rollPage + $i;
         } else {
             $page = $this->nowPage - $now_cool_page_ceil + $i;
         }
         if ($page > 0 && $page != $this->nowPage) {
             if ($page <= $this->totalPages) {
                 $link_page .= '<li><a class="num" href="' . $this->url($page) . '">' . $page . '</a></li>';
             } else {
                 break;
             }
         } else {
             if ($page > 0 && $this->totalPages != 1) {
                 $link_page .= '<li class="disabled"><span class="current">' . $page . '</span></li>';
             }
         }
     }
     if ($the_first == '') {
         $prespan = '';
     } else {
         $prespan = '';
     }
     if ($the_end == '') {
         $nextspan = '';
     } else {
         $nextspan = '';
     }
     //替换分页内容
     $page_str = str_replace(array('%HEADER%', '%NOW_PAGE%', '%PRESPAN%', '%NEXTSPAN%', '%UP_PAGE%', '%DOWN_PAGE%', '%FIRST%', '%LINK_PAGE%', '%END%', '%TOTAL_ROW%', '%TOTAL_PAGE%'), array($this->config['header'], $this->nowPage, $prespan, $nextspan, $up_page, $down_page, $the_first, $link_page, $the_end, $this->totalRows, $this->totalPages), $this->config['theme']);
     return "<ul class='pagination'>{$page_str}</ul>";
 }