Esempio n. 1
0
$content_handler =& JieqiOcontentHandler::getInstance('JieqiOcontentHandler');
$criteria = new CriteriaCompo(new Criteria('ochapterid', $_REQUEST['cid']));
$criteria->setLimit(1);
$content_handler->queryObjects($criteria);
unset($criteria);
$content = $content_handler->getObject();
if (!is_object($content)) {
    exit;
} else {
    include_once JIEQI_ROOT_PATH . '/include/changecode.php';
    include_once JIEQI_ROOT_PATH . '/lib/text/textfunction.php';
    include_once JIEQI_ROOT_PATH . '/lib/image/imagetext.php';
    $outstr = $content->getVar('ocontent', 'n');
    if ($_REQUEST['pic'] > 0) {
        $_REQUEST['pic'] = intval($_REQUEST['pic']);
        $outstr = jieqi_substr($outstr, ($_REQUEST['pic'] - 1) * $jieqiConfigs['obook']['obkpictxt'], $jieqiConfigs['obook']['obkpictxt'], '');
    }
    if (!empty($jieqiConfigs['obook']['obookreadhead'])) {
        $outstr = $jieqiConfigs['obook']['obookreadhead'] . "\r\n" . $outstr;
    }
    if (!empty($jieqiConfigs['obook']['obookreadfoot'])) {
        $outstr .= "\r\n" . $jieqiConfigs['obook']['obookreadfoot'];
    }
    $outstr = jieqi_limitwidth($outstr, $jieqiConfigs['obook']['obklinewidth']);
    //文字水印
    if (isset($jieqiConfigs['obook']['obkwaterformat'])) {
        $watertext = str_replace(array('<{$userid}>', '<{$username}>', '<{$date}>', '<{$time}>'), array($_SESSION['jieqiUserId'], $_SESSION['jieqiUserName'], date(JIEQI_DATE_FORMAT, JIEQI_NOW_TIME), date(JIEQI_TIME_FORMAT, JIEQI_NOW_TIME)), $jieqiConfigs['obook']['obkwaterformat']);
    } else {
        $watertext = $_SESSION['jieqiUserId'];
    }
    if (strlen($watertext) < 10) {
Esempio n. 2
0
/**
 * 字符串截取函数
 * 
 * @param      string      $text 输入的字符串
 * @param      int         $length 截取的长度
 * @param      string      $trimmarker 截取后末尾加上
 * @param      int         $html 字符串是否html代码
 * @access     public
 * @return     string
 */
function truncate($str, $length = 10, $trimmarker = '', $html = 1)
{
    $start = 0;
    if ($html && (strpos($str, '<') !== false || strpos($str, '&') !== false)) {
        $length = $length - strlen($trimmarker);
        //要截取的字符串
        $len = strlen($str);
        //原字符串长度
        $ret = '';
        //返回的字符串
        $i = 0;
        //原字符串指针
        $j = 0;
        //源字符串开始部分不截取的指针
        $l = 0;
        //返回字符串长度
        $htmltag = '';
        //html标记临时存储
        $htmlflag = 0;
        //html标记类型 1 - <>, 2 - &nbsp;
        $utf8 = JIEQI_SYSTEM_CHARSET == 'utf-8' ? true : false;
        while ($i < $len && $l < $length) {
            $cs = 1;
            //一个字有几个字节
            $cl = 1;
            //一个字相当于几个字节长度
            if ($str[$i] == '<') {
                $htmlflag = 1;
            } elseif ($str[$i] == '&') {
                $htmlflag = 2;
            }
            if ($htmlflag > 0) {
                $htmltag .= $str[$i];
                if ($htmlflag == 1 && $str[$i] == '>' || $htmlflag == 2 && $str[$i] == ';') {
                    if ($j >= $start) {
                        $ret .= $htmltag;
                    }
                    $htmlflag = 0;
                    $htmltag = '';
                }
            } else {
                $asc = ord($str[$i]);
                if ($asc > 0x80) {
                    if (!$utf8) {
                        $cs = 2;
                        $cl = 2;
                    } else {
                        if ($asc >= 192 && $asc <= 223) {
                            $cs = 2;
                            $cl = 2;
                        } elseif ($asc >= 224 && $asc <= 239) {
                            $cs = 3;
                            $cl = 2;
                        } elseif ($asc >= 240 && $asc <= 247) {
                            $cs = 4;
                            $cl = 2;
                        }
                    }
                }
                if ($j >= $start) {
                    $ret .= substr($str, $i, $cs);
                    $l += $cl;
                }
            }
            $i += $cs;
            $j += $cl;
        }
        if ($i < $len) {
            $ret .= $trimmarker;
        }
        return $ret;
    } else {
        return jieqi_substr($str, $start, $length, $trimmarker);
    }
}
Esempio n. 3
0
/**
 * 发帖提交后的内容校验
 * 
 * $post_set 相关参数:
 * 'module' - 程序所属模块名
 * 'ownerid' - 论坛或所有者ID
 * 'topicid' - 主题ID
 * 'postid' - 帖子ID
 * 'posttime' - 发帖时间
 * 'title' - 标题在$_POST里面的键名
 * 'content' - 内容在$_POST里面的键名
 * 'checkcode' - 验证码
 * 'attachment' - 附件信息,附件数组serialize后的字符串
 * 'emptytitle' - bool类型,主题贴是都允许不填主题,false-不允许,true-允许
 * 'isnew' - bool类型,true表示发新帖,false表示编辑帖子
 * 'istopic' - bool类型,true表示主题帖子,false表示回复帖子
 * 'istop' - bool类型,是否全区置顶帖子
 * 'sname' - string类型,发帖时间在session里面保存的变量名
 * 'attachfile' - array类型,附件上传信息变量
 * 'oldattach' - array类型,老的附件是否保留信息
 * 
 * $configs 相关参数:
 * 'minposttime' - int类型,发帖最少时间间隔,单位是秒
 * 'badpostwords' - string类型,禁止发表的词语,每个一行
 * 'checkpostrubbish' - bool类型,是否检查灌水贴
 * 'minpostsize' - int类型,帖子内容最少几个字节
 * 'maxpostsize' - int类型,帖子内容最多几个字节
 * 'hidepostwords' - string类型,发表后隐藏的词语,每个一行
 * 
 * @param      array       $post_set 发帖信息设置
 * @param      array       $configs 检查相关参数设置
 * @param      array       $check_errors 错误信息数组
 * @access     public
 * @return     bool
 */
function jieqi_post_checkvar(&$post_set, $configs, &$check_errors)
{
    global $jieqiLang;
    global $jieqiConfigs;
    if (!isset($jieqiLang['system']['post'])) {
        jieqi_loadlang('post', 'system');
    }
    if (!isset($jieqiConfigs['system'])) {
        jieqi_getconfigs('system', 'configs');
    }
    if (!is_array($check_errors)) {
        $check_errors = array();
    }
    $num_errors = count($check_errors);
    include_once JIEQI_ROOT_PATH . '/include/checker.php';
    $checker = new JieqiChecker();
    //提交处理
    if (isset($jieqiConfigs['system']['posttitlemax'])) {
        $jieqiConfigs['system']['posttitlemax'] = intval($jieqiConfigs['system']['posttitlemax']);
    }
    if (empty($jieqiConfigs['system']['posttitlemax']) || $jieqiConfigs['system']['posttitlemax'] <= 10) {
        $jieqiConfigs['system']['posttitlemax'] = 60;
    }
    $post_set['topictitle'] = jieqi_substr(trim($post_set['topictitle']), 0, $jieqiConfigs['system']['posttitlemax'], '...');
    //检查禁止发帖时间段
    if (!empty($jieqiConfigs['system']['postdenytimes'])) {
        if (!$checker->deny_time($jieqiConfigs['system']['postdenytimes'])) {
            $check_errors[] = sprintf($jieqiLang['system']['post_deny_times'], jieqi_htmlstr($jieqiConfigs['system']['postdenytimes']));
        }
    }
    //检查时间间隔,是否允许发贴
    if (!empty($jieqiConfigs['system']['postintervaltime']) && !empty($post_set['isnew'])) {
        if (!$checker->interval_time($jieqiConfigs['system']['postintervaltime'], $post_set['sname'], 'jieqiVisitTime')) {
            $check_errors[] = sprintf($jieqiLang['system']['post_time_limit'], $jieqiConfigs['system']['postintervaltime']);
        }
    }
    //验证码
    if ($jieqiConfigs['system']['postcheckcode'] > 0) {
        if ($post_set['checkcode'] != $_SESSION['jieqiCheckCode']) {
            $check_errors[] = $jieqiLang['system']['post_checkcode_error'];
        }
    }
    //检查禁用单词
    if (!empty($jieqiConfigs['system']['postdenywords'])) {
        $matchwords1 = $checker->deny_words($post_set['topictitle'], $jieqiConfigs['system']['postdenywords'], true);
        $matchwords2 = $checker->deny_words($post_set['posttext'], $jieqiConfigs['system']['postdenywords'], true);
        if (is_array($matchwords1) || is_array($matchwords2)) {
            $matchwords = array();
            if (is_array($matchwords1)) {
                $matchwords = array_merge($matchwords, $matchwords1);
            }
            if (is_array($matchwords2)) {
                $matchwords = array_merge($matchwords, $matchwords2);
            }
            $check_errors[] = sprintf($jieqiLang['system']['post_words_deny'], implode(' ', jieqi_funtoarray('htmlspecialchars', $matchwords)));
        }
    }
    //检查灌水
    if (!empty($jieqiConfigs['system']['postdenyrubbish'])) {
        if (!$checker->deny_rubbish($post_set['posttext'], $jieqiConfigs['system']['postdenyrubbish'])) {
            $check_errors[] = $jieqiLang['system']['post_words_water'];
        }
    }
    //检查标题
    if (!empty($post_set['istopic']) && $checker->is_required($post_set['topictitle']) == false) {
        if ($post_set['emptytitle']) {
            $post_set['topictitle'] = jieqi_substr(str_replace(array("\r", "\n", "\t", " "), '', preg_replace('/\\[[^\\[\\]]+\\]([^\\[\\]]*)\\[\\/[^\\[\\]]+\\]/isU', '\\1', $post_set['posttext'])), 0, 60);
            if (strlen($post_set['emptytitle']) == 0) {
                $post_set['emptytitle'] = '--';
            }
        } else {
            $check_errors[] = $jieqiLang['system']['post_need_title'];
        }
    }
    //检查内容
    if (!$checker->is_required($post_set['posttext'])) {
        $check_errors[] = $jieqiLang['system']['post_need_content'];
    }
    //检查最少字数
    if (!empty($jieqiConfigs['system']['postminsize']) && !$checker->str_min($post_set['posttext'], $jieqiConfigs['system']['postminsize'])) {
        $check_errors[] = sprintf($jieqiLang['system']['post_min_content'], $jieqiConfigs['system']['postminsize']);
    }
    //检查最多字数
    if (!empty($jieqiConfigs['system']['postmaxsize']) && !$checker->str_max($post_set['posttext'], $jieqiConfigs['system']['postmaxsize'])) {
        $check_errors[] = sprintf($jieqiLang['system']['post_max_content'], $jieqiConfigs['system']['postmaxsize']);
    }
    //替换单词
    if (isset($jieqiConfigs['system']['postreplacewords']) && !empty($jieqiConfigs['system']['postreplacewords'])) {
        $checker->replace_words($post_set['topictitle'], $jieqiConfigs['system']['postreplacewords']);
        $checker->replace_words($post_set['posttext'], $jieqiConfigs['system']['postreplacewords']);
    }
    return count($check_errors) > $num_errors ? false : true;
}
Esempio n. 4
0
/**
 * 传入小说实例对象,返回适合模板赋值的小说信息数组
 * 
 * @param      object      $article 论坛实例
 * @access     public
 * @return     array
 */
function jieqi_article_vars($article)
{
    global $jieqiModules;
    global $jieqiSort;
    global $jieqiConfigs;
    global $jieqiLang;
    global $article_static_url;
    global $article_dynamic_url;
    global $jieqiOption;
    if (!isset($jieqiSort['article'])) {
        jieqi_getconfigs('article', 'sort');
    }
    if (!isset($jieqiConfigs['article'])) {
        jieqi_getconfigs('article', 'configs');
    }
    if (!isset($jieqiLang['article'])) {
        jieqi_loadlang('list', JIEQI_MODULE_NAME);
    }
    if (!isset($article_static_url)) {
        $article_static_url = empty($jieqiConfigs['article']['staticurl']) ? $jieqiModules['article']['url'] : $jieqiConfigs['article']['staticurl'];
    }
    if (!isset($article_dynamic_url)) {
        $article_dynamic_url = empty($jieqiConfigs['article']['dynamicurl']) ? $jieqiModules['article']['url'] : $jieqiConfigs['article']['dynamicurl'];
    }
    $ret = array();
    $ret['articleid'] = $article->getVar('articleid');
    //文章序号
    $ret['articlename'] = $article->getVar('articlename');
    //文章名称
    $ret['intro'] = htmlspecialchars(jieqi_substr($article->getVar('intro', 'n'), 0, 250));
    $ret['articlesubdir'] = jieqi_getsubdir($article->getVar('articleid'));
    //子目录
    $ret['url_articleinfo'] = jieqi_geturl('article', 'article', $article->getVar('articleid'), 'info');
    if ($article->getVar('lastchapter') == '') {
        $ret['lastchapterid'] = 0;
        //章节序号
        $ret['lastchapter'] = '';
        //章节名称
        $ret['url_lastchapter'] = '';
        //章节地址
    } else {
        $ret['lastchapterid'] = $article->getVar('lastchapterid');
        $ret['lastchapter'] = $article->getVar('lastchapter');
        $ret['url_articleindex'] = jieqi_geturl('article', 'article', $article->getVar('articleid'), 'index');
        $ret['url_lastchapter'] = jieqi_geturl('article', 'chapter', $article->getVar('lastchapterid'), $article->getVar('articleid'));
    }
    $ret['url_index'] = $ret['url_articleindex'];
    $ret['lastvolumeid'] = $article->getVar('lastvolumeid');
    //分卷序号
    $ret['lastvolume'] = $article->getVar('lastvolume');
    //分卷名称
    $ret['authorid'] = $article->getVar('authorid');
    //作者
    $ret['author'] = $article->getVar('author');
    $ret['posterid'] = $article->getVar('posterid');
    //发表者
    $ret['poster'] = $article->getVar('poster');
    $ret['agentid'] = $article->getVar('agentid');
    //代理者
    $ret['agent'] = $article->getVar('agent');
    $ret['sortid'] = $article->getVar('sortid');
    //类别序号
    if (isset($jieqiSort['article'][$ret['sortid']]['caption'])) {
        $ret['sort'] = $jieqiSort['article'][$ret['sortid']]['caption'];
    } else {
        $ret['sort'] = '';
    }
    $ret['typeid'] = $article->getVar('typeid');
    //字类别序号
    if ($ret['typeid'] > 0 && isset($jieqiSort['article'][$ret['sortid']]['types'][$ret['typeid']])) {
        $ret['type'] = $jieqiSort['article'][$ret['sortid']]['types'][$ret['typeid']];
    } else {
        $ret['type'] = '';
    }
    if (empty($ret['type'])) {
        $ret['type'] = $ret['sort'];
    }
    $ret['size'] = $article->getVar('size');
    $ret['size_k'] = ceil($article->getVar('size') / 1024);
    $ret['size_c'] = ceil($article->getVar('size') / 2);
    $ret['dayvisit'] = $article->getVar('dayvisit');
    $ret['weekvisit'] = $article->getVar('weekvisit');
    $ret['monthvisit'] = $article->getVar('monthvisit');
    $ret['allvisit'] = $article->getVar('allvisit');
    $ret['dayvote'] = $article->getVar('dayvote');
    $ret['weekvote'] = $article->getVar('weekvote');
    $ret['monthvote'] = $article->getVar('monthvote');
    $ret['allvote'] = $article->getVar('allvote');
    $ret['goodnum'] = $article->getVar('goodnum');
    $ret['badnum'] = $article->getVar('badnum');
    $ret['display'] = $article->getVar('display');
    $ret['lastupdate'] = date('y-m-d', $article->getVar('lastupdate'));
    $ret['update'] = date('m-d', $article->getVar('lastupdate'));
    $ret['postdate'] = date('m-d', $article->getVar('postdate'));
    $ret['uptime'] = $article->getVar('lastupdate');
    $ret['posttime'] = $article->getVar('postdate');
    $ret['lastvote'] = $article->getVar('lastvote');
    $ret['isfull'] = $article->getVar('fullflag');
    if (!isset($jieqiOption)) {
        jieqi_getconfigs('article', 'option', 'jieqiOption');
    }
    $tmpvar = $article->getVar('fullflag');
    if (isset($jieqiOption['article']['fullflag']['items'][$tmpvar])) {
        $ret['fullflag'] = $jieqiOption['article']['fullflag']['items'][$tmpvar];
    } else {
        $ret['fullflag'] = $jieqiOption['article']['fullflag']['items'][$jieqiOption['article']['fullflag']['default']];
    }
    $tmpvar = $article->getVar('permission');
    if (isset($jieqiOption['article']['permission']['items'][$tmpvar])) {
        $ret['permission'] = $jieqiOption['article']['permission']['items'][$tmpvar];
    } else {
        $ret['permission'] = $jieqiOption['article']['permission']['items'][$jieqiOption['article']['permission']['default']];
    }
    $tmpvar = $article->getVar('firstflag');
    if (isset($jieqiOption['article']['firstflag']['items'][$tmpvar])) {
        $ret['firstflag'] = $jieqiOption['article']['firstflag']['items'][$tmpvar];
    } else {
        $ret['firstflag'] = $jieqiOption['article']['firstflag']['items'][$jieqiOption['article']['firstflag']['default']];
    }
    $ret['imgflag'] = $article->getVar('imgflag', 'n');
    $ret['url_image'] = jieqi_geturl('article', 'cover', $article->getVar('articleid'), 's', $article->getVar('imgflag', 'n'));
    return $ret;
}