function msgformat($topic) { $content_arr = explode("\n", $topic['message']); if (count($content_arr) > 1) { $content0 = $content_arr[0]; if (jstrlen($content0) <= 60 && strpos($content0, '[code]') === false) { $content_arr[0] = '<b>' . $content0 . '</b>'; $topic['message'] = implode("\n", $content_arr); } } if (false !== strpos($topic['message'], '[')) { if (false !== strpos($topic['message'], '[/image]') && preg_match_all('~\\[image\\](.+?)\\[\\/image\\]~', $topic['message'], $match)) { foreach ($match[0] as $k => $v) { if ($image_url = $topic['image_list'][$match[1][$k]]['image_small']) { $imageHTML = '<ul class="imgList"><li><img src="' . $image_url . '"/></li></ul>'; $topic['message'] = str_replace($v, $imageHTML, $topic['message']); unset($topic['image_list'][$match[1][$k]]); } else { $topic['message'] = str_replace($v, '', $topic['message']); } } } if (false !== strpos($topic['message'], '[/b]') && preg_match_all('/\\[b\\](.+?)\\[\\/b\\]/is', $topic['message'], $match)) { foreach ($match[0] as $k => $v) { $topic['message'] = str_replace($v, '<b>' . $match[1][$k] . '</b>', $topic['message']); } } if (false !== strpos($topic['message'], '[/color]') && preg_match_all('/\\[color=(.+?)\\](.+?)\\[\\/color\\]/is', $topic['message'], $match)) { foreach ($match[0] as $k => $v) { $topic['message'] = str_replace($v, '<span style="color:' . $match[1][$k] . ';">' . $match[2][$k] . '</span>', $topic['message']); } } if (false !== strpos($topic['message'], '[/quote]')) { $topic['message'] = str_replace(array("[quote]", "[/quote]"), array('<div class="quote">', '</div>'), $topic['message']); } if (false !== strpos($topic['message'], '[/code]') && preg_match_all('/\\[code\\](.+?)\\[\\/code\\]/is', $topic['message'], $match)) { foreach ($match[0] as $k => $v) { $html = "<br /><div class='code'><ul>"; $codeList = explode("\n", $match[1][$k]); if ($codeList) { $li = ''; foreach ($codeList as $code) { $li .= "<li>{$code}</li>"; } } $html .= $li . '</ul></div><br />'; $topic['message'] = str_replace($v, $html, $topic['message']); } } } return $topic; }
function Make($topic, $merge_sql = 0, $option = array(), $clist_img = 1, $islongtext = 0) { global $jishigou_rewrite; $clist_img = $clist_img && !$merge_sql && (true === IN_JISHIGOU_INDEX || true === IN_JISHIGOU_AJAX || true === IN_JISHIGOU_ADMIN); $make_member_fields = "`uid`,`ucuid`,`username`,`nickname`,`signature`,`face_url`,`face`,`validate`,`validate_category`,`level`"; $topic['content'] .= $topic['content2']; if ($topic['longtextid'] > 0) { $topic['content'] = $this->_content_end($topic['content']); } $topic['raw_content'] = strip_tags($topic['content']); unset($topic['content2']); if ($topic['dateline']) { $topic['addtime'] = $topic['dateline']; $topic['dateline'] = my_date_format2($topic['dateline']); } $topic['is_vote'] = 0; if (!$topic['random']) { $topic['random'] = mt_rand(); } if ($GLOBALS['_J']['plugins']['func']['printtopic']) { jlogic('plugin')->hookscript('printtopic', 'funcs', $topic, 'printtopic'); } if (false === strpos($topic['content'], '</a>') && (false !== strpos($topic['content'], $GLOBALS['_J']['config']['site_url']) || false !== strpos($topic['content'], '.wmv'))) { if (preg_match_all('~(?:https?\\:\\/\\/|www\\.)(?:[A-Za-z0-9\\_\\-]+\\.)+[A-Za-z0-9]{1,4}(?:\\:\\d{1,6})?(?:\\/[\\w\\d\\/=\\?%\\-\\&_\\~\\`\\:\\+\\#\\.]*(?:[^\\;\\@\\[\\]\\<\\>\'\\"\\n\\r\\t\\s\\x7f-\\xff])*)?~i', $topic['content'] . " ", $match)) { $cont_rpl = $cont_sch = array(); foreach ($match[0] as $v) { $v = trim($v); if (($vl = strlen($v)) < 8 || $vl > 200) { continue; } if ('.wmv' == substr($v, -4)) { $cont_sch[] = "{$v}"; if ($islongtext) { $cont_rpl[] = "<br><center><object border='0' data='{$v}' width='480' align='baseline' type='video/x-ms-wmv' height='400'></object></center><br>如要下载此视频,请右击此链接,选择“目标另存为”:<br><a target='_blank' href='{$v}'>{$v}</a>"; } else { $cont_rpl[] = "<a target='_blank' href='" . jurl('index.php?mod=topic&code=' . $topic['tid']) . "' title='单击播放'><img src='images/vd.gif'></a>"; } } if (strtolower($GLOBALS['_J']['config']['site_url']) == strtolower(substr($v, 0, strlen($GLOBALS['_J']['config']['site_url'])))) { $app_type = ''; $tmp_vid = 0; if (MEMBER_ID > 0) { if (preg_match("/mod=vote(?:&code=view)?&vid=([0-9]+)/", $v, $m) || preg_match("/vote(?:\\/view)?\\/vid\\-([0-9]+)/", $v, $m)) { $app_type = 'vote'; $tmp_vid = $m[1]; if ($topic['is_vote'] === 0) { $topic['is_vote'] = $tmp_vid; } } } if ($app_type == 'vote') { $cont_sch[] = "{$v}"; $vote_key = $topic['tid'] . '_' . $topic['random']; if (IN_JISHIGOU_WAP === true || IN_JISHIGOU_MOBILE === true) { $cont_rpl[] = "<a href='{$v}'>{$v}<img src='{$GLOBALS['_J']['config']['site_url']}/images/voteicon.gif'/></a>"; } else { $cont_rpl[] = "<a onclick='return getVoteDetailWidgets(\"{$vote_key}\", {$tmp_vid});' href='{$v}'>{$v}<img src='{$GLOBALS['_J']['config']['site_url']}/images/voteicon.gif'/></a>"; } } else { $cont_sch[] = "{$v}"; $cont_rpl[] = "<a target='_blank' href='{$v}'>{$v}</a>"; } } } if ($cont_rpl && $cont_sch) { $cont_sch = array_unique($cont_sch); $cont_rpl = array_unique($cont_rpl); $topic['content'] = trim($this->_str_replace($cont_sch, $cont_rpl, $topic['content'])); } } } $this->_parseAt($topic); $highlight = jget('highlight', 'txt'); if ($highlight && is_string($highlight)) { $topic['content'] = str_replace($highlight, "<font color=red>{$highlight}</font>", $topic['content']); } if (false !== strpos($topic['content'], '<T>#')) { static $topic_content_tag_href_pattern_static = ''; if (!$topic_content_tag_href_pattern_static) { $topic_content_tag_href_pattern_static = "index.php?mod=tag&code=|REPLACE_VALUE|"; if ($topic['item'] == 'qun') { $topic_content_tag_href_pattern_static = "index.php?mod=qun&qid={$topic['item_id']}&tag=|REPLACE_VALUE|"; } if ($jishigou_rewrite) { $topic_content_tag_href_pattern_static = $jishigou_rewrite->formatURL($topic_content_tag_href_pattern_static); } if (defined("IN_JISHIGOU_MOBILE")) { $topic_content_tag_href_pattern_static = 'javascript:goToTopicList(\\\'|REPLACE_VALUE| . "\')"'; } } $topic['content'] = preg_replace('~<T>#(.+?)#</T>~e', '\'<a href="' . str_replace('|REPLACE_VALUE|', '\' . ' . (defined('IN_JISHIGOU_MOBILE') ? '' : 'urlencode') . '(strip_tags(\'\\1\'))', $topic_content_tag_href_pattern_static) . ' . \'">#\\1#</a>\'', $topic['content']); } if (false !== strpos($topic['content'], '</U>')) { static $topic_content_url_href_pattern_static = ''; if (!$topic_content_url_href_pattern_static) { $topic_content_url_href_pattern_static = "index.php?mod=url&code=|REPLACE_VALUE|"; if ($jishigou_rewrite) { $topic_content_url_href_pattern_static = ltrim($jishigou_rewrite->formatURL($topic_content_url_href_pattern_static), '/'); } } $sys_site_url = $GLOBALS['_J']['config']['site_url']; if ($jishigou_rewrite) { $sys_site_url = false !== ($_tmp_pos = strpos($sys_site_url, '/', 10)) ? substr($sys_site_url, 0, $_tmp_pos) : $sys_site_url; } $topic['content'] = preg_replace('~<U ([0-9a-zA-Z]+)>(.+?)</U>~e', '\'<a title="\'.jhtmlspecialchars(strip_tags(\'\\2\')).\'" href="' . ($sys_site_url . '/' . str_replace('|REPLACE_VALUE|', '\\1', $topic_content_url_href_pattern_static)) . '" target="_blank">' . ($sys_site_url . '/' . str_replace('|REPLACE_VALUE|', '\\1', $topic_content_url_href_pattern_static)) . '</a>\'', $topic['content']); } if (false !== strpos($topic['content'], '<T>')) { $topic['content'] = str_replace(array('<T>', '</T>', '</U>', '<T', '</T'), '', $topic['content']); } if (false !== strpos($topic['content'], '<U')) { $topic['content'] = preg_replace('~(</U>|<U[^><]*?>|<U\\s*)~', '', $topic['content']); } $topic = $this->_make_topic_from($topic); $topic['top_parent_id'] = $topic['roottid']; $topic['parent_id'] = $topic['totid']; if ($topic['imageid'] && !$merge_sql) { $topic['image_list'] = jlogic('image')->image_list($topic['imageid']); } if ($topic['attachid'] && !$merge_sql) { $topic['attach_list'] = jlogic('attach')->attach_list($topic['attachid']); } $content_arr = explode("\n", $topic['content']); if (count($content_arr) > 1) { $content0 = $content_arr[0]; if (jstrlen(strip_tags($content0)) <= 78 && strpos($content0, '[code]') === false) { if ($islongtext) { $content_arr[0] = '<center><b>' . $content0 . '</b></center>'; } else { $content_arr[0] = '<b>' . $content0 . '</b>'; } $topic['content'] = implode("\n", $content_arr); } } if (false !== strpos($topic['content'], '[')) { if (false === strpos($topic['content'], '#[')) { if (preg_match_all('~\\[(.+?)\\]~', $topic['content'], $match)) { static $face_conf = null; if (!$face_conf) { $face_conf = jconf::get('face'); } foreach ($match[0] as $k => $v) { if (false != ($img_src = $face_conf[$match[1][$k]])) { if (defined("IN_JISHIGOU_MOBILE")) { $img_src = 'mobile/' . $img_src; } $topic['content'] = str_replace($v, '<img src="' . $GLOBALS['_J']['config']['site_url'] . '/' . $img_src . '" border="0"/>', $topic['content']); } } } } if (false !== strpos($topic['content'], '[/image]') && preg_match_all('~\\[image\\](.+?)\\[\\/image\\]~', $topic['content'], $match)) { $TPT = $option['TPT_id'] ? $option['TPT_id'] : ''; $ptidv = $option['ptidv'] ? $option['ptidv'] : ''; $type = $option['type'] ? $option['type'] : ''; foreach ($match[0] as $k => $v) { if ($option && ($image_url = $topic['image_list'][$match[1][$k]]['image_small']) && !$merge_sql && $clist_img) { $iid = $topic['image_list'][$match[1][$k]]['id']; $ikey = $topic['image_list'][$match[1][$k]]['image_key']; $image_original = $topic['image_list'][$match[1][$k]]['image_original']; if ($type == 'artZoom2') { $imageHTML = '<ul class="imgList"><li><a id="TV_img_a_' . $iid . '" href="' . $image_original . '" class="artZoom2" rel="' . $image_url . '"><img id="TV_img_' . $iid . '" src="' . $image_original . '" onload="TV_resizeImage(this, 550, ' . $iid . ')" /></a></li></ul>'; } else { $imageHTML = '<ul class="imgList"><li><a href="' . $image_original . '" class="artZoomAll" rel="' . $image_url . '" rev="' . $ikey . '"><img src="' . $image_url . '" onload="this.click();"/></a></li></ul>'; } $topic['content'] = str_replace($v, $imageHTML, $topic['content']); unset($topic['image_list'][$match[1][$k]]); } else { $topic['content'] = str_replace(array("<br />{$v}", "<br>{$v}", "{$v}<br />", "{$v}<br>", "{$v}"), '', $topic['content']); } } } if (false !== strpos($topic['content'], '[/b]') && preg_match_all('/\\[b\\](.+?)\\[\\/b\\]/is', $topic['content'], $match)) { foreach ($match[0] as $k => $v) { $topic['content'] = str_replace($v, '<b>' . $match[1][$k] . '</b>', $topic['content']); } } if (false !== strpos($topic['content'], '[/u]') && preg_match_all('/\\[u\\](.+?)\\[\\/u\\]/is', $topic['content'], $match)) { foreach ($match[0] as $k => $v) { $topic['content'] = str_replace($v, '<u>' . $match[1][$k] . '</u>', $topic['content']); } } if (false !== strpos($topic['content'], '[/color]') && preg_match_all('/\\[color=(.+?)\\](.+?)\\[\\/color\\]/is', $topic['content'], $match)) { foreach ($match[0] as $k => $v) { $topic['content'] = str_replace($v, '<span style="color:' . $match[1][$k] . ';">' . $match[2][$k] . '</span>', $topic['content']); } } #引用的样式 if (false !== strpos($topic['content'], '[/quote]') && preg_match_all('/\\[quote\\](.+?)\\[\\/quote\\]/is', $topic['content'], $match)) { foreach ($match[0] as $k => $v) { $topic['content'] = str_replace($v, '<div class="quote">' . $match[1][$k] . '</div>', $topic['content']); } } #代码的样式 if (false !== strpos($topic['content'], '[/code]') && preg_match_all('/\\[code\\](.+?)\\[\\/code\\]/is', $topic['content'], $match)) { foreach ($match[0] as $k => $v) { $html = "<br /><div class='code'><ul>"; $codeList = explode("\n", $match[1][$k]); if ($codeList) { $li = ''; foreach ($codeList as $code) { $li .= "<li>{$code}</li>"; } } $html .= $li . '</ul></div><br />'; $topic['content'] = str_replace($v, $html, $topic['content']); } } if (false !== strpos($topic['content'], '[')) { $topic['content'] = preg_replace('~\\[\\/?([\\w\\d\\=]+)\\]~i', '', $topic['content']); } } if ($topic['videoid'] > 0 && $GLOBALS['_J']['config']['video_status'] && !$merge_sql) { $sql = "select `id`,`video_hosts`,`video_link`,`video_img`,`video_img_url`,`video_url` from `" . TABLE_PREFIX . "topic_video` where `id`='" . $topic['videoid'] . "' "; $topic_video = DB::fetch_first($sql); $topic['VideoID'] = $topic_video['id']; $topic['VideoHosts'] = $topic_video['video_hosts']; $topic['VideoLink'] = $topic_video['video_link']; $topic['VideoUrl'] = $topic_video['video_url']; if ($topic_video['video_img']) { $topic['VideoImg'] = ($topic_video['video_img_url'] ? $topic_video['video_img_url'] : $GLOBALS['_J']['config']['site_url']) . '/' . $topic_video['video_img']; } else { $topic['VideoImg'] = $GLOBALS['_J']['config']['site_url'] . '/images/vd.gif'; } } if ($topic['musicid'] > 0 && !$merge_sql) { $sql = "select `id`,`music_url`,`xiami_id` from `" . TABLE_PREFIX . "topic_music` where `id`='" . $topic['musicid'] . "' "; $topic_music = DB::fetch_first($sql); $topic['MusicID'] = $topic_music['id']; $topic['MusicUrl'] = $topic_music['music_url']; $topic['xiami_id'] = $topic_music['xiami_id']; } if ($topic['image_list'] && !$merge_sql && $clist_img) { $addHtml = '<ul class="imgList">'; foreach ($topic['image_list'] as $k => $v) { $image_url = $v['image_small']; $iid = $v['id']; $image_original = $v['image_original']; $addHtml .= '<li><a href="' . $image_original . '" class="artZoomAll" rel="' . $image_url . '" rev="' . $ikey . '"><img src="' . $image_url . '" onload="this.click();"/></a></li>'; } $addHtml .= '</ul>'; $topic['content'] .= $addHtml; } if (!$merge_sql) { $topic = array_merge($topic, (array) $this->GetMember($topic['uid'], $make_member_fields)); if ($topic['anonymous']) { $topic = $this->_anonymous($topic); } } return $topic; }
function mb_strlen($str) { return jstrlen(jcode_convert_encoding($str, "EUC-JP", _CHARSET)); }
function mb_substr($str, $start, $length = NULL, $encoding = '') { // 注: EUC-JP専用, $encodingを使用しない return jsubstr($str, $start, $length === NULL ? jstrlen($str) : $length); }
function checkname($username, $is_nickname = 0, $ucuid = 0, $check_exists = -1) { $username = trim(strip_tags($username)); $username_len = jstrlen($username); $ulmax = $is_nickname && true !== UCENTER ? 50 : 15; $nickname_length = (int) $GLOBALS['_J']['config']['nickname_length']; $is_nickname && ($ulmax = !$nickname_length ? $ulmax : ($nickname_length > $ulmax ? $ulmax : $nickname_length)); if ($username_len < 3 || $username_len > $ulmax) { return -1; } if ($ucuid < 1) { if (is_numeric($username)) { return -1; } if ($is_nickname) { if (false != preg_match('~[\\<\\>\\?\\@\\$\\#\\[\\]\\{\\}\\s\\*\\"\'\\,\\`\\=\\/]+~', $username)) { return -1; } } else { if (false == preg_match('~^[\\w\\d\\_]+$~', $username)) { return -1; } } } $f_rets = filter($username); if ($f_rets && $f_rets['error']) { return -2; } if (isset($GLOBALS['_J']['config']['modules'][strtolower($username)])) { return -2; } $censoruser = jconf::get('user', 'forbid'); if ($censoruser) { $censorexp = '/^(' . trim(str_replace(array('\\*', "\r\n", ' '), array('.*', '|', ''), preg_quote(trim($censoruser), '/')), '| ') . ')$/i'; if (preg_match($censorexp, $username)) { return -2; } } if (true === UCENTER && $ucuid < 1) { $uc_result = uc_user_checkname($username); if ($uc_result < 1) { return $uc_result; } } if (true === PWUCENTER && $ucuid < 1) { define('P_W', 'admincp'); include_once ROOT_PATH . 'api/pw_api/security.php'; include_once ROOT_PATH . 'api/pw_api/pw_common.php'; include_once ROOT_PATH . './api/pw_client/uc_client.php'; $uc_result = uc_check_username($username); if ($uc_result < 1) { return $uc_result; } } if ($check_exists) { $username = addslashes($username); $row1 = DB::fetch_first("select `uid`, `username`, `nickname` from " . DB::table('members') . " where `username`='{$username}' limit 1"); $row2 = DB::fetch_first("select `uid`, `username`, `nickname` from " . DB::table('members') . " where `nickname`='{$username}' limit 1"); if ($row1 || $row2) { if (($check_uid = (int) $check_exists) > 0) { if ($row1 && $check_uid != $row1['uid'] || $row2 && $check_uid != $row2['uid']) { return -3; } else { return 1; } } return -3; } } return 1; }