Пример #1
0
/**
 * 传入帖子实例对象,返回适合模板赋值的帖子信息数组
 * 
 * @param      object      $post 帖子实例
 * @param      array       $configs 配置参数
 * @param      array       $addvars 附加赋值变量
 * @param      bool        $enableubb 是否允许解析UBB代码
 * @access     public
 * @return     array
 */
function jieqi_post_vars($post, $configs = array(), $addvars = array(), $enableubb = true)
{
    global $jieqiTxtcvt;
    global $jieqiHonors;
    global $jieqiGroups;
    global $jieqiModules;
    if (!isset($jieqiHonors)) {
        jieqi_getconfigs('system', 'honors', 'jieqiHonors');
    }
    if (!defined('JIEQI_SHOW_BADGE')) {
        if (!empty($jieqiModules['badge']['publish']) && is_file($GLOBALS['jieqiModules']['badge']['path'] . '/include/badgefunction.php')) {
            include_once $jieqiModules['badge']['path'] . '/include/badgefunction.php';
            define('JIEQI_SHOW_BADGE', 1);
        } else {
            define('JIEQI_SHOW_BADGE', 0);
        }
    }
    if (is_array($addvars)) {
        $ret = $addvars;
    } else {
        $ret = array();
    }
    $ret['postid'] = $post->getVar('postid');
    $ret['siteid'] = $post->getVar('siteid');
    $ret['istopic'] = $post->getVar('istopic');
    $ret['replypid'] = $post->getVar('replypid');
    $ret['ownerid'] = $post->getVar('ownerid');
    $ret['userid'] = intval($post->getVar('uid'));
    $ret['posterid'] = $post->getVar('posterid');
    $ret['poster'] = $ret['username'];
    $ret['posttime'] = $post->getVar('posttime');
    $ret['posterip'] = $post->getVar('posterip');
    $ret['editorid'] = $post->getVar('editorid');
    $ret['editor'] = $post->getVar('editor');
    $ret['edittime'] = $post->getVar('edittime');
    $ret['editorip'] = $post->getVar('editorip');
    $ret['editnote'] = $post->getVar('editnote');
    $ret['iconid'] = $post->getVar('iconid');
    $ret['subject'] = jieqi_substr($post->getVar('subject'), 0, 56);
    $ret['size'] = $post->getVar('size');
    $ret['attachimages'] = array();
    $ret['attachfiles'] = array();
    $tmpvar = $post->getVar('attachment', 'n');
    if (!empty($tmpvar)) {
        $attachs = unserialize($tmpvar);
        foreach ($attachs as $key => $val) {
            $url = jieqi_uploadurl($configs['attachdir'], $configs['attachurl'], JIEQI_MODULE_NAME) . '/' . date('Ymd', $post->getVar('posttime', 'n')) . '/' . $post->getVar('postid', 'n') . '_' . $val['attachid'] . '.' . $val['postfix'];
            if ($val['class'] == 'image') {
                $ret['attachimages'][] = array('id' => $val['attachid'], 'name' => jieqi_htmlstr($val['name']), 'url' => $url, 'posttime' => $post->getVar('posttime', 'n'), 'postid' => $post->getVar('postid', 'n'), 'postfix' => $val['postfix'], 'class' => $val['class'], 'size' => $val['size'], 'size_k' => ceil($val['size'] / 1024));
            } else {
                $ret['attachfiles'][] = array('id' => $val['attachid'], 'name' => jieqi_htmlstr($val['name']), 'url' => $url, 'posttime' => $post->getVar('posttime', 'n'), 'postid' => $post->getVar('postid', 'n'), 'postfix' => $val['postfix'], 'class' => $val['class'], 'size' => $val['size'], 'size_k' => ceil($val['size'] / 1024));
            }
        }
    }
    if ($enableubb) {
        if (!is_object($jieqiTxtcvt)) {
            include_once JIEQI_ROOT_PATH . '/lib/text/textconvert.php';
            $jieqiTxtcvt = TextConvert::getInstance('TextConvert');
        }
        $ret['posttext'] = $jieqiTxtcvt->displayTarea($post->getVar('posttext', 'n'), 0, 1, 1, 1, 1, 'screen.width*0.75');
    } else {
        if (!is_object($jieqiTxtcvt)) {
            include_once JIEQI_ROOT_PATH . '/lib/text/textconvert.php';
            $jieqiTxtcvt = TextConvert::getInstance('TextConvert');
        }
        $ret['posttext'] = jieqi_htmlstr(preg_replace(array('/\\[\\/?(code|url|color|font|align|email|b|i|u|d|img|quote|size)[^\\[\\]]*\\]/is'), '', $post->getVar('posttext', 'n')));
        $ret['posttext'] = $jieqiTxtcvt->smile(preg_replace('/https?:\\/\\/[^\\s\\r\\n\\t\\f<>]+/i', '<a href="\\0">\\0</a>', $ret['posttext']));
    }
    //加入文字水印
    if (!empty($configs['textwatermark']) && !defined('JIEQI_WAP_PAGE')) {
        $contentary = explode('<br />
<br />', $ret['posttext']);
        $ret['posttext'] = '';
        foreach ($contentary as $v) {
            if (empty($ret['posttext'])) {
                $ret['posttext'] .= $v;
            } else {
                srand((double) microtime() * 1000000);
                $randstr = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
                $randlen = rand(10, 20);
                $randtext = '';
                $l = strlen($randstr) - 1;
                for ($i = 0; $i < $randlen; $i++) {
                    $num = rand(0, $l);
                    $randtext .= $randstr[$num];
                }
                $textwatermark = str_replace('<{$randtext}>', $randtext, $configs['textwatermark']);
                $ret['posttext'] .= '<br />
' . $textwatermark . $v;
            }
        }
    }
    //本贴用户信息
    if ($ret['userid'] > 0) {
        $ret['useruname'] = $post->getVar('uname');
        $ret['username'] = $post->getVar('name') == '' ? $post->getVar('uname') : $post->getVar('name');
        $ret['viewemail'] = $post->getVar('viewemail');
        $ret['email'] = $post->getVar('email');
        $ret['qq'] = $post->getVar('qq');
        $ret['msn'] = $post->getVar('msn');
        $ret['groupname'] = $jieqiGroups[$post->getVar('groupid')];
        $ret['regdate'] = $post->getVar('regdate');
        $ret['experience'] = $post->getVar('experience');
        $ret['score'] = $post->getVar('score');
        $ret['sign'] = $post->getVar('sign');
        $ret['avatar'] = $post->getVar('avatar');
        $honorid = intval(jieqi_gethonorid($post->getVar('score'), $jieqiHonors));
        $ret['honor'] = isset($jieqiHonors[$honorid]['name'][intval($post->getVar('workid', 'n'))]) ? $jieqiHonors[$honorid]['name'][intval($post->getVar('workid', 'n'))] : $jieqiHonors[$honorid]['caption'];
        //头像图片
        if ($ret['avatar'] > 0) {
            $tmpary = jieqi_geturl('system', 'avatar', $ret['userid'], 'a', $ret['avatar']);
            $ret['base_avatar'] = $tmpary['d'];
            $ret['url_avatar'] = $tmpary['l'];
            $ret['url_avatars'] = $tmpary['s'];
            $ret['url_avatari'] = $tmpary['i'];
        }
        //徽章图片
        if (JIEQI_SHOW_BADGE == 1) {
            $checkfile = JIEQI_LOCAL_URL == JIEQI_MAIN_URL ? true : false;
            $checkfile = false;
            //等级徽章
            $ret['groupurl'] = getbadgeurl(1, $post->getVar('groupid'), 0, $checkfile);
            //头衔徽章
            $ret['honorurl'] = getbadgeurl(2, $honorid, 0, $checkfile);
            //自定义徽章
            $badgeary = unserialize($post->getVar('badges', 'n'));
            $ret['badgerows'] = array();
            if (is_array($badgeary)) {
                $m = 0;
                foreach ($badgeary as $badge) {
                    $ret['badgerows'][$m]['imageurl'] = getbadgeurl($badge['btypeid'], $badge['linkid'], $badge['imagetype']);
                    $ret['badgerows'][$m]['caption'] = jieqi_htmlstr($badge['caption']);
                    $m++;
                }
            }
        }
    }
    return $ret;
}
Пример #2
0
    function makeHtml($nowid, $dynamic = false, $show = false, $filter = false)
    {
        global $jieqiConfigs;
        global $jieqiSort;
        global $jieqiTpl;
        global $jieqi_file_postfix;
        if (!isset($jieqiSort['article'])) {
            jieqi_getconfigs('article', 'sort');
        }
        if ($nowid <= 0) {
            return false;
        }
        $chaptercount = count($this->chapters);
        if ($nowid > $chaptercount) {
            return false;
        }
        if (!in_array($jieqiConfigs['article']['htmlfile'], array('.html', '.htm', '.shtml'))) {
            $jieqiConfigs['article']['htmlfile'] = '.html';
        }
        $chapter = jieqi_htmlstr($this->chapters[$nowid - 1]['id']);
        $void = $nowid - 2;
        $volume = '';
        while ($void >= 0 && $this->chapters[$void]['content-type'] != 'volume') {
            $void--;
        }
        if ($void >= 0) {
            $volume = jieqi_htmlstr($this->chapters[$void]['id']);
        }
        $preid = $nowid - 2;
        while ($preid >= 0 && $this->chapters[$preid]['content-type'] == 'volume') {
            $preid--;
        }
        $preid++;
        $nextid = $nowid;
        while ($nextid < $chaptercount && $this->chapters[$nextid]['content-type'] == 'volume') {
            $nextid++;
        }
        if ($nextid >= $chaptercount) {
            $nextid = 0;
        } else {
            $nextid++;
        }
        if (!is_object($jieqiTpl)) {
            include_once JIEQI_ROOT_PATH . '/lib/template/template.php';
            $jieqiTpl =& JieqiTpl::getInstance();
        }
        //文件头变量赋值
        $jieqiTpl->assign('dynamic_url', ARTICLE_DYNAMIC_URL);
        $jieqiTpl->assign('static_url', ARTICLE_STATIC_URL);
        $jieqiTpl->assign('article_title', jieqi_htmlstr($this->metas['dc:Title']));
        $jieqiTpl->assign('jieqi_title', $volume . ' ' . $chapter);
        $jieqiTpl->assign('jieqi_volume', $volume);
        $jieqiTpl->assign('jieqi_chapter', $chapter);
        //其他序号及名称
        $jieqiTpl->assign('sortid', intval($this->metas['dc:Sortid']));
        if (!empty($jieqiSort['article'][$this->metas['dc:Sortid']]['caption'])) {
            $jieqiTpl->assign('sortname', $jieqiSort['article'][$this->metas['dc:Sortid']]['caption']);
        }
        $jieqiTpl->assign('authorid', intval($this->metas['dc:Creatorid']));
        $jieqiTpl->assign('author', jieqi_htmlstr($this->metas['dc:Creator']));
        $jieqiTpl->assign('fullflag', intval($this->metas['dc:Fullflag']));
        $articletype = intval($this->metas['dc:Articletype']);
        $jieqiTpl->assign('articletype', $articletype);
        if (($articletype & 1) > 0) {
            $jieqiTpl->assign('hasebook', 1);
        } else {
            $jieqiTpl->assign('hasebook', 0);
        }
        if (($articletype & 2) > 0) {
            $jieqiTpl->assign('hasobook', 1);
        } else {
            $jieqiTpl->assign('hasobook', 0);
        }
        if (($articletype & 4) > 0) {
            $jieqiTpl->assign('hastbook', 1);
        } else {
            $jieqiTpl->assign('hastbook', 0);
        }
        $jieqiTpl->assign('articleid', $this->id);
        $chapterid = $this->getCid($this->chapters[$nowid - 1]['href']);
        $jieqiTpl->assign('chapterid', $chapterid);
        $jieqiTpl->assign('new_url', JIEQI_LOCAL_URL);
        //全文阅读
        $jieqiTpl->assign('url_fullpage', jieqi_uploadurl($jieqiConfigs['article']['fulldir'], $jieqiConfigs['article']['fullurl'], 'article', ARTICLE_STATIC_URL) . jieqi_getsubdir($this->id) . '/' . $this->id . $jieqiConfigs['article']['htmlfile']);
        //打包下载
        $jieqiTpl->assign('url_download', jieqi_uploadurl($jieqiConfigs['article']['zipdir'], $jieqiConfigs['article']['zipurl'], 'article', ARTICLE_STATIC_URL) . jieqi_getsubdir($this->id) . '/' . $this->id . $jieqi_file_postfix['zip']);
        //自己页面
        if ($show) {
            $jieqiTpl->assign('url_thispage', ARTICLE_STATIC_URL . '/reader.php?aid=' . $this->id . '&cid=' . $chapterid);
        } else {
            $jieqiTpl->assign('url_thispage', $this->getDir('htmldir') . '/' . $chapterid . $jieqiConfigs['article']['htmlfile']);
        }
        $txtdir = $this->getDir('txtdir', true, false);
        //内容赋值
        include_once JIEQI_ROOT_PATH . '/lib/text/textconvert.php';
        $ts = TextConvert::getInstance('TextConvert');
        $tmpvar = jieqi_readfile($txtdir . '/' . $this->chapters[$nowid - 1]['href']);
        //文字过滤
        if ($filter && !empty($jieqiConfigs['article']['hidearticlewords'])) {
            $articlewordssplit = strlen($jieqiConfigs['article']['articlewordssplit']) == 0 ? ' ' : $jieqiConfigs['article']['articlewordssplit'];
            $filterary = explode($articlewordssplit, $jieqiConfigs['article']['hidearticlewords']);
            $tmpvar = str_replace($filterary, '', $tmpvar);
        }
        //网址改成可以点击的
        $tmpvar = $ts->makeClickable(jieqi_htmlstr($tmpvar));
        //加入文字水印
        if (!empty($jieqiConfigs['article']['textwatermark']) && JIEQI_MODULE_VTYPE != '' && JIEQI_MODULE_VTYPE != 'Free') {
            $contentary = preg_split('/<br\\s*\\/?>\\s*<br\\s*\\/?>/is', $tmpvar);
            $tmpvar = '';
            foreach ($contentary as $v) {
                if (empty($tmpvar)) {
                    $tmpvar .= $v;
                } else {
                    srand((double) microtime() * 1000000);
                    $randstr = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
                    $randlen = rand(10, 20);
                    $randtext = '';
                    $l = strlen($randstr) - 1;
                    for ($i = 0; $i < $randlen; $i++) {
                        $num = rand(0, $l);
                        $randtext .= $randstr[$num];
                    }
                    $textwatermark = str_replace('<{$randtext}>', $randtext, $jieqiConfigs['article']['textwatermark']);
                    $tmpvar .= '<br />
' . $textwatermark . '<br />' . $v;
                }
            }
        }
        $attachurl = jieqi_uploadurl($jieqiConfigs['article']['attachdir'], $jieqiConfigs['article']['attachurl'], 'article') . jieqi_getsubdir($this->id) . '/' . $this->id . '/' . $chapterid;
        if (!$jieqiConfigs['article']['packdbattach']) {
            //检查附件(检查文件是否存在)
            $attachdir = jieqi_uploadpath($jieqiConfigs['article']['attachdir'], 'article') . jieqi_getsubdir($this->id) . '/' . $this->id . '/' . $chapterid;
            if (is_dir($attachdir)) {
                $attachimage = '';
                $attachfile = '';
                $files = array();
                $dirhandle = @opendir($attachdir);
                while ($file = @readdir($dirhandle)) {
                    if ($file != '.' && $file != '..') {
                        $files[] = $file;
                    }
                }
                @closedir($dirhandle);
                sort($files);
                $image_code = $jieqiConfigs['article']['pageimagecode'];
                if (empty($image_code) || !preg_match('/\\<img/is', $image_code)) {
                    $image_code = '<div class="divimage"><img src="<{$imageurl}>" border="0" class="imagecontent"></div>';
                }
                foreach ($files as $file) {
                    if (is_file($attachdir . '/' . $file)) {
                        $url = $attachurl . '/' . $file;
                        if (eregi("\\.(gif|jpg|jpeg|png|bmp)\$", $file)) {
                            $attachimage .= str_replace('<{$imageurl}>', $url, $image_code);
                        } else {
                            $attachfile .= '<strong>file:</strong><a href="' . $url . '">' . $url . '</a>(' . ceil(filesize($attachdir . '/' . $file) / 1024) . 'K)<br /><br />';
                        }
                    }
                }
                if (!empty($attachimage) || !empty($attachfile)) {
                    if (!empty($tmpvar)) {
                        $tmpvar .= '<br /><br />';
                    }
                    $tmpvar .= $attachimage . $attachfile;
                }
            }
        } else {
            //检查附件-从数据库判断是不是有附件
            global $package_query;
            $sql = "SELECT attachment FROM " . jieqi_dbprefix('article_chapter') . " WHERE chapterid=" . intval($chapterid);
            $res = $package_query->execute($sql);
            $row = $package_query->db->fetchArray($res);
            $attachary = array();
            if (!empty($row['attachment'])) {
                $attachary = unserialize($row['attachment']);
            }
            if (is_array($attachary) && count($attachary) > 0) {
                $attachimage = '';
                $attachfile = '';
                $image_code = $jieqiConfigs['article']['pageimagecode'];
                if (empty($image_code) || !preg_match('/\\<img/is', $image_code)) {
                    $image_code = '<div class="divimage"><img src="<{$imageurl}>" border="0" class="imagecontent"></div>';
                }
                foreach ($attachary as $attachvar) {
                    $url = $attachurl . '/' . $attachvar['attachid'] . '.' . $attachvar['postfix'];
                    if ($attachvar['class'] == 'image') {
                        $attachimage .= str_replace('<{$imageurl}>', $url, $image_code);
                    } else {
                        $attachfile .= '<strong>file:</strong><a href="' . $url . '">' . $url . '</a>(' . ceil($attachvar['size'] / 1024) . 'K)<br /><br />';
                    }
                }
                if (!empty($attachimage) || !empty($attachfile)) {
                    if (!empty($tmpvar)) {
                        $tmpvar .= '<br /><br />';
                    }
                    $tmpvar .= $attachimage . $attachfile;
                }
            }
        }
        $jieqiTpl->assign('jieqi_content', $tmpvar);
        if ($preid > 0) {
            $tmpvar = $this->getCid($this->chapters[$preid - 1]['href']);
            if ($dynamic) {
                $tmpurl = ARTICLE_STATIC_URL . '/reader.php?aid=' . $this->id . '&cid=' . $tmpvar;
            } else {
                $tmpurl = $tmpvar . $jieqiConfigs['article']['htmlfile'];
            }
            $jieqiTpl->assign('preview_link', '<a href="' . $tmpurl . '">上一页</a>');
            $preview_page = $tmpurl;
            $jieqiTpl->assign('preview_page', $tmpurl);
            $jieqiTpl->assign('preview_chapterid', $tmpvar);
            $jieqiTpl->assign('first_page', 0);
        } else {
            $jieqiTpl->assign('preview_link', '上一页');
            if ($dynamic) {
                $tmpurl = ARTICLE_STATIC_URL . '/reader.php?aid=' . $this->id;
            } else {
                $tmpurl = 'index' . $jieqiConfigs['article']['htmlfile'];
            }
            $preview_page = $tmpurl;
            $jieqiTpl->assign('preview_page', $tmpurl);
            $jieqiTpl->assign('preview_chapterid', 0);
            $jieqiTpl->assign('first_page', 1);
        }
        if ($dynamic) {
            $tmpurl = ARTICLE_STATIC_URL . '/reader.php?aid=' . $this->id;
        } else {
            $tmpurl = 'index' . $jieqiConfigs['article']['htmlfile'];
        }
        $jieqiTpl->assign('index_link', '<a href="' . $tmpurl . '">返回目录</a>');
        $index_page = $tmpurl;
        $jieqiTpl->assign('index_page', $tmpurl);
        if ($nextid > 0) {
            $tmpvar = $this->getCid($this->chapters[$nextid - 1]['href']);
            if ($dynamic) {
                $tmpurl = ARTICLE_STATIC_URL . '/reader.php?aid=' . $this->id . '&cid=' . $tmpvar;
            } else {
                $tmpurl = $tmpvar . $jieqiConfigs['article']['htmlfile'];
            }
            $jieqiTpl->assign('next_link', '<a href="' . $tmpurl . '">下一页</a>');
            $next_page = $tmpurl;
            $jieqiTpl->assign('next_page', $tmpurl);
            $jieqiTpl->assign('next_chapterid', $tmpvar);
            $jieqiTpl->assign('last_page', 0);
        } else {
            $jieqiTpl->assign('next_link', '下一页');
            /*
            if($dynamic){
            $tmpurl=ARTICLE_STATIC_URL.'/reader.php?aid='.$this->id;
            }else{
            $tmpurl='index'.$jieqiConfigs['article']['htmlfile'];
            }
            */
            $tmpurl = ARTICLE_STATIC_URL . '/lastchapter.php?aid=' . $this->id . '&dynamic=' . intval($dynamic);
            $next_page = $tmpurl;
            $jieqiTpl->assign('next_page', $tmpurl);
            $jieqiTpl->assign('next_chapterid', 0);
            $jieqiTpl->assign('last_page', 1);
        }
        $jieqiTpl->setCaching(0);
        //页面跳转
        $jieqiTpl->assign('preview_page', $preview_page);
        $jieqiTpl->assign('next_page', $next_page);
        $jieqiTpl->assign('index_page', $index_page);
        $jieqiTpl->assign('article_id', $this->id);
        $jieqiTpl->assign('chapter_id', $chapterid);
        $jieqiTpl->assign('articlesubdir', jieqi_getsubdir($this->id));
        $jieqiTpl->assign('url_articleinfo', jieqi_geturl('article', 'article', $this->id, 'info'));
        $jieqiTpl->assign('url_bookroom', ARTICLE_DYNAMIC_URL . '/');
        if ($show) {
            $jieqiTpl->display($GLOBALS['jieqiModules']['article']['path'] . '/templates/style.html');
        } else {
            $htmldir = $this->getDir('htmldir');
            $jieqiTpl->assign('jieqi_charset', JIEQI_SYSTEM_CHARSET);
            jieqi_writefile($htmldir . '/' . $chapterid . $jieqiConfigs['article']['htmlfile'], $jieqiTpl->fetch($GLOBALS['jieqiModules']['article']['path'] . '/templates/style.html'));
        }
    }
Пример #3
0
if (!$report) {
    jieqi_printfail($jieqiLang['system']['report_no_exists']);
}
jieqi_getconfigs(JIEQI_MODULE_NAME, 'rsort', 'jieqiRsort');
include_once JIEQI_ROOT_PATH . '/admin/header.php';
$jieqiTpl->assign('reportid', $_REQUEST['id']);
$jieqiTpl->assign('siteid', $report->getVar('siteid'));
$jieqiTpl->assign('reporttime', $report->getVar('reporttime'));
$jieqiTpl->assign('reportuid', $report->getVar('reportuid'));
$jieqiTpl->assign('reportname', $report->getVar('reportname'));
$jieqiTpl->assign('authtime', $report->getVar('authtime'));
$jieqiTpl->assign('authuid', $report->getVar('authuid'));
$jieqiTpl->assign('authname', $report->getVar('authname'));
$jieqiTpl->assign('reporttitle', $report->getVar('reporttitle'));
include_once JIEQI_ROOT_PATH . '/lib/text/textconvert.php';
$ts = TextConvert::getInstance('TextConvert');
$jieqiTpl->assign('reporttext', $ts->makeClickable($report->getVar('reporttext')));
$jieqiTpl->assign('reportsize', $report->getVar('reportsize'));
$jieqiTpl->assign('reportfield', $report->getVar('reportfield'));
$jieqiTpl->assign('authnote', $report->getVar('authnote'));
$jieqiTpl->assign('reportsort', $report->getVar('reportsort'));
$jieqiTpl->assign('reporttype', $report->getVar('reporttype'));
$jieqiTpl->assign('authflag', $report->getVar('authflag'));
$jieqiTpl->assign('sortname', $jieqiRsort[$report->getVar('reportsort')]['caption']);
if (isset($jieqiRsort[$report->getVar('reportsort')]['types'][$report->getVar('reporttype')])) {
    $jieqiTpl->assign('typename', $jieqiRsort[$report->getVar('reportsort')]['types'][$report->getVar('reporttype')]);
} else {
    $reportrows[$k]['typename'] = $jieqiTpl->assign('typename', $jieqiLang['system']['report_type_other']);
}
$jieqiTpl->setCaching(0);
$jieqiTset['jieqi_contents_template'] = JIEQI_ROOT_PATH . '/templates/admin/reportdetail.html';