示例#1
0
function viewread($read, $start_limit)
{
    global $db, $_G, $isGM, $pwSystem, $groupid, $attach_url, $winduid, $tablecolor, $tpc_author, $tpc_buy, $tpc_pid, $tpc_tag, $count, $orderby, $pageinverse, $timestamp, $db_onlinetime, $attachdir, $attachpath, $readcolorone, $readcolortwo, $lpic, $ltitle, $imgpath, $db_ipfrom, $db_showonline, $stylepath, $db_windpost, $db_windpic, $db_signwindcode, $fid, $tid, $pid, $db_md_ifopen, $_MEDALDB, $rewardtype, $db_shield, $db_iftag, $db_readtag, $viewpic;
    global $ping_logs;
    if ($read['istop'] == 'topped') {
        $read['lou'] = $read['floor'];
    } else {
        $read['lou'] = $count - $start_limit;
    }
    $read['jupend'] = $start_limit == $count - 1 ? "<a name=a></a><a name={$read['pid']}></a>" : "<a name={$read['pid']}></a>";
    $tpc_buy = $read['buy'];
    $tpc_pid = $read['pid'];
    $tpc_tag = NULL;
    $tpc_shield = 0;
    $read['ifsign'] < 2 && ($read['content'] = str_replace("\n", "<br />", $read['content']));
    if ($read['anonymous']) {
        $anonymous = !$isGM && $winduid != $read['authorid'] && !$pwSystem['anonyhide'];
        $read['anonymousname'] = $GLOBALS['db_anonymousname'];
    } else {
        $anonymous = false;
        $read['anonymousname'] = $read['username'];
    }
    $read['ipfrom'] = $db_ipfrom == 1 && $_G['viewipfrom'] ? $read['ipfrom'] : '';
    $read['ip'] = $isGM || $pwSystem['viewip'] ? 'IP:' . $read['userip'] : '';
    if ($read['groupid'] && !$anonymous) {
        $read['groupid'] == '-1' && ($read['groupid'] = $read['memberid']);
        !array_key_exists($read['groupid'], (array) $lpic) && ($read['groupid'] = 8);
        $read['lpic'] = $lpic[$read['groupid']];
        $read['level'] = $ltitle[$read['groupid']];
        $read['regdate'] = get_date($read['regdate'], "Y-m-d");
        $read['lastlogin'] = get_date($read['lastvisit'], "Y-m-d");
        $read['rvrc'] = floor($read['rvrc'] / 10);
        $read['author'] = $read['username'];
        $tpc_author = $read['author'];
        if (!empty($GLOBALS['showfield'])) {
            $customdata = $read['customdata'] ? (array) unserialize($read['customdata']) : array();
            $read['customdata'] = array();
            foreach ($customdata as $key => $val) {
                if ($val && in_array($key, $GLOBALS['showfield'])) {
                    $read['customdata'][$key] = $val;
                }
            }
        }
        $read['ontime'] = (int) ($read['onlinetime'] / 3600);
        $read['groupid'] == 6 && ($read['honor'] = '');
        if ($read['groupid'] != 6 && ($read['ifsign'] == 1 || $read['ifsign'] == 3)) {
            global $sign;
            if (!$sign[$read['author']]) {
                global $db_signmoney, $db_signgroup, $tdtime, $db_signcurtype;
                if ($db_signmoney && strpos($db_signgroup, ",{$read['groupid']},") !== false && (!getstatus($read['userstatus'], PW_USERSTATUS_SHOWSIGN) || !$read['starttime'] || $read[$db_signcurtype] < ($tdtime - $read['starttime']) / 86400 * $db_signmoney)) {
                    $read['signature'] = '';
                } else {
                    if ($db_signwindcode && getstatus($read['userstatus'], PW_USERSTATUS_SIGNCHANGE)) {
                        if ($GLOBALS['gp_right'][$read['groupid']]['imgwidth'] && $GLOBALS['gp_right'][$read['groupid']]['imgheight']) {
                            $db_windpic['picwidth'] = $GLOBALS['gp_right'][$read['groupid']]['imgwidth'];
                            $db_windpic['picheight'] = $GLOBALS['gp_right'][$read['groupid']]['imgheight'];
                        }
                        if ($GLOBALS['gp_right'][$read['groupid']]['fontsize']) {
                            $db_windpic['size'] = $GLOBALS['gp_right'][$read['groupid']]['fontsize'];
                        }
                        $read['signature'] = convert($read['signature'], $db_windpic, 2);
                    }
                    $read['signature'] = str_replace("\n", "<br />", $read['signature']);
                }
                $sign[$read['author']] = $read['signature'];
            } else {
                $read['signature'] = $sign[$read['author']];
            }
        } else {
            $read['signature'] = '';
        }
    } else {
        $read['lpic'] = $lpic['2'];
        $read['level'] = $read['digests'] = $read['postnum'] = $read['money'] = $read['currency'] = '*';
        $read['rvrc'] = $read['lastlogin'] = $read['credit'] = $read['regdate'] = '*';
        $read['honor'] = $read['signature'] = $read['micon'] = $read['aliww'] = '';
        if ($anonymous) {
            $read['oicq'] = $read['ip'] = $read['medals'] = $read['ipfrom'] = '';
            $read['author'] = $GLOBALS['db_anonymousname'];
            $read['authorid'] = 0;
            foreach ($GLOBALS['customfield'] as $key => $val) {
                $field = "field_" . (int) $val['id'];
                $read[$field] = '*';
            }
        }
    }
    list($read['face'], , $httpWidth, $httpHeight, , , , $read['facesize']) = showfacedesign($read['micon'], true, 'm');
    if ($httpWidth > 120 || $httpHeight > 120 || $read['facesize'] == '') {
        $read['facesize'] = ' width="120" height="120"';
    }
    list($read['posttime'], $read['postdate']) = getLastDate($read['postdate']);
    $read['mark'] = $read['reward'] = $read['tag'] = NULL;
    if ($read['ifmark']) {
        $ping_logs[$read['pid']] = $read['ifmark'];
    }
    if ($rewardtype != null) {
        if ($read['lou'] == 0 || $read['ifreward'] > 0 || $rewardtype == '0' && $winduid == $GLOBALS['authorid'] && $winduid != $read['authorid']) {
            $read['reward'] = Getrewhtml($read['lou'], $read['ifreward'], $read['pid']);
        }
    }
    if ($read['icon']) {
        $read['icon'] = "<img src=\"{$imgpath}/post/emotion/{$read['icon']}.gif\" align=\"left\" border=\"0\" />";
    } else {
        $read['icon'] = '';
    }
    if ($db_md_ifopen && $read['medals']) {
        $medals = $ifMedalNotExist = '';
        $md_a = explode(',', $read['medals']);
        foreach ($md_a as $key => $value) {
            if ($value && $_MEDALDB[$value]) {
                $medals .= "<a href=\"apps.php?q=medal\" target=\"_blank\"><img src=\"{$_MEDALDB[$value][smallimage]}\" width=\"30\" height=\"30\"  title=\"{$_MEDALDB[$value][name]}\" /></a>";
            } else {
                unset($md_a[$key]);
                $ifMedalNotExist = 1;
            }
        }
        if ($ifMedalNotExist == 1) {
            $newMedalInfo = implode(',', $md_a);
            $userService = L::loadClass('UserService', 'user');
            /* @var $userService PW_UserService */
            $userService->update($read['authorid'], array('medals' => $newMedalInfo));
        }
        $read['medals'] = $medals . '<br />';
    } else {
        $read['medals'] = '';
    }
    $read['leaveword'] && ($read['content'] .= leaveword($read['leaveword'], $read['pid']));
    if ($read['ifshield'] || $read['groupid'] == 6 && $db_shield) {
        if ($read['ifshield'] == 2) {
            $read['content'] = shield('shield_del_article');
            $read['subject'] = '';
            $tpc_shield = 1;
        } else {
            if ($groupid == '3') {
                $read['subject'] = shield('shield_title');
            } else {
                $read['content'] = shield($read['ifshield'] ? 'shield_article' : 'ban_article');
                $read['subject'] = '';
                $tpc_shield = 1;
            }
        }
        $read['icon'] = '';
    }
    if (!$tpc_shield) {
        if ($read['ifwordsfb'] != $GLOBALS['db_wordsfb']) {
            $read['content'] = wordsConvert($read['content'], array('id' => $tpc_pid == 'tpc' ? $tid : $tpc_pid, 'type' => $tpc_pid == 'tpc' ? 'topic' : 'posts', 'code' => $read['ifwordsfb']));
        }
        if ($read['ifconvert'] == 2) {
            $read['content'] = convert($read['content'], $db_windpost);
        } else {
            $tpc_tag && ($read['content'] = relatetag($read['content'], $tpc_tag));
            strpos($read['content'], '[s:') !== false && ($read['content'] = showface($read['content']));
        }
        if ($read['aid'] && $GLOBALS['attachShow']->isShow($read['ifhide'], $tid)) {
            $read += $GLOBALS['attachShow']->parseAttachs($read['pid'], $read['content'], $winduid == $read['authorid']);
        }
    }
    /**
     * convert the post content
     */
    $read['alterinfo'] && ($read['content'] .= "<div id=\"alert_{$read['pid']}\" style=\"color:gray;margin-top:30px\">[ {$read['alterinfo']} ]</div>");
    if ($read['remindinfo']) {
        $remind = explode("\t", $read['remindinfo']);
        $remind[0] = str_replace("\n", "<br />", $remind[0]);
        $remind[2] && ($remind[2] = get_date($remind[2]));
        $read['remindinfo'] = $remind;
    }
    if ($_GET['keyword']) {
        $keywords = explode("|", $_GET['keyword']);
        foreach ($keywords as $key => $value) {
            if ($value) {
                $read['content'] = preg_replace("/(?<=[\\s\"\\]>()]|[-�]|^)(" . preg_quote($value, '/') . ")([.,:;-?!()\\s\"<\\[]|[-�]|\$)/siU", "<u><font color=\"red\">\\1</font></u>\\2", $read['content']);
            }
        }
    }
    //$GLOBALS['foruminfo']['copyctrl'] && $read['content'] = preg_replace("/<br \/>/eis","copyctrl()",$read['content']);
    return $read;
}
示例#2
0
function convert($message, $allow, $type = "post")
{
    global $isGM, $pwPostHide, $pwSellHide, $pwEncodeHide, $code_num, $code_htm, $phpcode_htm, $foruminfo, $db_picpath, $imgpath, $stylepath, $db_attachname, $attachpath, $tpc_author, $tpc_buy, $db_cvtimes, $forumset, $tpc_tag, $db_windcode;
    $code_num = 0;
    $code_htm = array();
    if (strpos($message, "[code]") !== false && strpos($message, "[/code]") !== false) {
        $message = preg_replace("/\\[code\\](.+?)\\[\\/code\\]/eis", "phpcode('\\1')", $message, $db_cvtimes);
    }
    if (strpos($message, "[payto]") !== false && strpos($message, "[/payto]") !== false) {
        require_once R_P . 'require/paytofunc.php';
        $message = preg_replace("/\\[payto\\](.+?)\\[\\/payto\\]/eis", "payto('\\1')", $message);
    }
    $message = preg_replace('/\\[list=([aA1]?)\\](.+?)\\[\\/list\\]/is', "<ol type=\"\\1\" style=\"margin:0 0 0 25px\">\\2</ol>", $message);
    $searcharray = array('[u]', '[/u]', '[b]', '[/b]', '[i]', '[/i]', '[list]', '[li]', '[/li]', '[/list]', '[sub]', '[/sub]', '[sup]', '[/sup]', '[strike]', '[/strike]', '[blockquote]', '[/blockquote]', '[hr]', '[/backcolor]', '[/color]', '[/font]', '[/size]', '[/align]');
    $replacearray = array('<u>', '</u>', '<b>', '</b>', '<i>', '</i>', '<ul style="margin:0 0 0 15px">', '<li>', '</li>', '</ul>', '<sub>', '</sub>', '<sup>', '</sup>', '<strike>', '</strike>', '<blockquote>', '</blockquote>', '<hr />', '</span>', '</span>', '</font>', '</font>', '</div>');
    $message = str_replace($searcharray, $replacearray, $message);
    $message = str_replace("p_w_upload", $db_attachname, $message);
    //此处位置不可调换
    $message = str_replace("p_w_picpath", $db_picpath, $message);
    //此处位置不可调换
    $searcharray = array("/\\[font=([^\\[\\(&\\;]+?)\\]/is", "/\\[color=([#0-9a-z]{1,15})\\]/is", "/\\[backcolor=([#0-9a-z]{1,10})\\]/is", "/\\[email=([^\\[]*)\\]([^\\[]*)\\[\\/email\\]/is", "/\\[email\\]([^\\[]*)\\[\\/email\\]/is", "/\\[size=(\\d+)\\]/eis", "/\\[align=(left|center|right|justify)\\]/is", "/\\[glow=(\\d+)\\,([0-9a-zA-Z]+?)\\,(\\d+)\\](.+?)\\[\\/glow\\]/is");
    $replacearray = array("<font face=\"\\1 \">", "<span style=\"color:\\1 \">", "<span style=\"background-color:\\1 \">", "<a href=\"mailto:\\1 \">\\2</a>", "<a href=\"mailto:\\1 \">\\1</a>", "size('\\1','{$allow['size']}')", "<div align=\"\\1\">", "<div style=\"width:\\1px;filter:glow(color=\\2,strength=\\3);\">\\4</div>");
    $message = preg_replace($searcharray, $replacearray, $message);
    if ($db_windcode) {
        $message = preg_replace($db_windcode['searcharray'], $db_windcode['replacearray'], $message);
    }
    if ($allow['pic']) {
        $message = preg_replace("/\\[img\\]([^\\<\r\n\"']+?)\\[\\/img\\]/eis", "cvpic('\\1','','{$allow['picwidth']}','{$allow['picheight']}')", $message, $db_cvtimes);
    } else {
        $message = preg_replace("/\\[img\\]([^\\<\r\n\"']+?)\\[\\/img\\]/eis", "nopic('\\1')", $message, $db_cvtimes);
    }
    if (strpos($message, '[/URL]') !== false || strpos($message, '[/url]') !== false) {
        $searcharray = array("/\\[url=(https?|ftp|gopher|news|telnet|mms|rtsp|thunder)([^\\[\\s]+?)(\\,(1))?\\](.+?)\\[\\/url\\]/eis", "/\\[url\\]www\\.([^\\[]+?)\\[\\/url\\]/eis", "/\\[url\\](https?|ftp|gopher|news|telnet|mms|rtsp|thunder)([^\\[]+?)\\[\\/url\\]/eis");
        $replacearray = array("cvurl('\\1','\\2','\\5','\\4','{$allow['checkurl']}')", "cvurl('\\1','','','','{$allow['checkurl']}')", "cvurl('\\1','\\2','','','{$allow['checkurl']}')");
        $message = preg_replace($searcharray, $replacearray, $message);
    }
    $searcharray = array("/\\[fly\\]([^\\[]*)\\[\\/fly\\]/is", "/\\[move\\]([^\\[]*)\\[\\/move\\]/is");
    $replacearray = array("<marquee width=90% behavior=alternate scrollamount=3>\\1</marquee>", "<marquee scrollamount=3>\\1</marquee>");
    $message = preg_replace($searcharray, $replacearray, $message);
    if ($type == 'post') {
        if ($foruminfo['allowhide'] && strpos($message, "[post]") !== false && strpos($message, "[/post]") !== false) {
            $message = preg_replace("/\\[post\\](.+?)\\[\\/post\\]/eis", "post('\\1')", $message);
        }
        if ($forumset['allowencode'] && strpos($message, "[hide=") !== false && strpos($message, "[/hide]") !== false) {
            $message = preg_replace("/\\[hide=(.+?)\\](.+?)\\[\\/hide\\]/eis", "hidden('\\1','\\2')", $message);
        }
        if ($foruminfo['allowsell'] && strpos($message, "[sell") !== false && strpos($message, "[/sell]") !== false) {
            $message = preg_replace("/\\[sell=(.+?)\\](.+?)\\[\\/sell\\]/eis", "sell('\\1','\\2')", $message);
        }
    }
    if (strpos($message, "[quote]") !== false && strpos($message, "[/quote]") !== false) {
        $message = preg_replace("/\\[quote\\](.+?)\\[\\/quote\\]/eis", "qoute('\\1')", $message);
    }
    if (is_array($code_htm)) {
        krsort($code_htm);
        foreach ($code_htm as $codehtm) {
            foreach ($codehtm as $key => $value) {
                $message = str_replace("<\twind_code_{$key}\t>", $value, $message);
            }
        }
    }
    if ($allow['flash']) {
        $message = preg_replace("/\\[flash=(\\d+?)\\,(\\d+?)(\\,(0|1))?\\]([^\\[\\<\r\n\"']+?)\\[\\/flash\\]/eis", "wplayer('\\5','\\1','\\2','\\4','flash')", $message, $db_cvtimes);
    } else {
        $message = preg_replace("/\\[flash=(\\d+?)\\,(\\d+?)(\\,(0|1))?\\]([^\\[\\<\r\n\"']+?)\\[\\/flash\\]/is", "<img src='{$imgpath}/{$stylepath}/file/music.gif' align='absbottom'> <a target='_blank' href='\\5 '>flash: \\5</a>", $message, $db_cvtimes);
    }
    if ($type == 'post') {
        $t = 0;
        while (strpos($message, '[table') !== false && strpos($message, '[/table]') !== false) {
            $message = preg_replace('/\\[table(=(\\d{1,3}(%|px)?))?\\](.*?)\\[\\/table\\]/eis', "tablefun('\\2','\\3','\\4')", $message);
            if (++$t > 4) {
                break;
            }
        }
        if ($allow['mpeg']) {
            $message = preg_replace(array("/\\[wmv=(0|1)\\]([^\\<\r\n\"']+?)\\[\\/wmv\\]/eis", "/\\[wmv(=([0-9]{1,3})\\,([0-9]{1,3})\\,(0|1))?\\]([^\\<\r\n\"']+?)\\[\\/wmv\\]/eis", "/\\[rm(=([0-9]{1,3})\\,([0-9]{1,3})\\,(0|1))?\\]([^\\<\r\n\"']+?)\\[\\/rm\\]/eis"), array("wplayer('\\2','314','53','\\1','wmv')", "wplayer('\\5','\\2','\\3','\\4','wmv')", "wplayer('\\5','\\2','\\3','\\4','rm')"), $message, $db_cvtimes);
        } else {
            $message = preg_replace(array("/\\[wmv=[01]{1}\\]([^\\<\r\n\"']+?)\\[\\/wmv\\]/is", "/\\[wmv(?:=[0-9]{1,3}\\,[0-9]{1,3}\\,[01]{1})?\\]([^\\<\r\n\"']+?)\\[\\/wmv\\]/is", "/\\[rm(?:=[0-9]{1,3}\\,[0-9]{1,3}\\,[01]{1})\\]([^\\<\r\n\"']+?)\\[\\/rm\\]/is"), "<img src=\"{$imgpath}/{$stylepath}/file/music.gif\" align=\"absbottom\"> <a target=\"_blank\" href=\"\\1 \">\\1</a>", $message, $db_cvtimes);
        }
        if ($allow['iframe']) {
            $message = preg_replace("/\\[iframe\\]([^\\[\\<\r\n\"']+?)\\[\\/iframe\\]/is", "<IFRAME SRC=\\1 FRAMEBORDER=0 ALLOWTRANSPARENCY=true SCROLLING=YES WIDTH=97% HEIGHT=340></IFRAME>", $message, $db_cvtimes);
        } else {
            $message = preg_replace("/\\[iframe\\]([^\\[\\<\r\n\"']+?)\\[\\/iframe\\]/is", "Iframe Close: <a target=_blank href='\\1 '>\\1</a>", $message, $db_cvtimes);
        }
        $tpc_tag && ($message = relatetag($message, $tpc_tag));
        strpos($message, '[s:') !== false && ($message = showface($message));
    }
    if (is_array($phpcode_htm)) {
        foreach ($phpcode_htm as $key => $value) {
            $message = str_replace("<\twind_phpcode_{$key}\t>", $value, $message);
        }
    }
    return $message;
}
示例#3
0
function viewread($read, $start_limit)
{
    global $db, $_G, $isGM, $pwSystem, $groupid, $attach_url, $winduid, $tablecolor, $tpc_author, $tpc_buy, $tpc_pid, $tpc_tag, $count, $orderby, $pageinverse, $timestamp, $db_onlinetime, $attachdir, $attachpath, $readcolorone, $readcolortwo, $lpic, $ltitle, $imgpath, $db_ipfrom, $db_showonline, $stylepath, $db_windpost, $db_windpic, $db_signwindcode, $fid, $tid, $pid, $md_ifopen, $_MEDALDB, $rewardtype, $db_shield, $db_iftag, $db_readtag;
    global $ping_logs;
    if ($read['istop'] == 'topped') {
        $read['lou'] = $read['floor'];
    } else {
        $read['lou'] = $orderby != 'desc' || $start_limit == 0 ? $start_limit : $count - $start_limit;
    }
    $read['jupend'] = $start_limit == $count - 1 ? "<a name=a></a><a name={$read['pid']}></a>" : "<a name={$read['pid']}></a>";
    $tpc_buy = $read['buy'];
    $tpc_pid = $read['pid'];
    $tpc_tag = NULL;
    $tpc_shield = 0;
    $read['ifsign'] < 2 && ($read['content'] = str_replace("\n", "<br />", $read['content']));
    if ($read['anonymous']) {
        $anonymous = !$isGM && $winduid != $read['authorid'] && !$pwSystem['anonyhide'];
        $read['anonymousname'] = $GLOBALS['db_anonymousname'];
    } else {
        $anonymous = false;
        $read['anonymousname'] = $read['username'];
    }
    $read['ipfrom'] = $db_ipfrom == 1 && $_G['viewipfrom'] ? $read['ipfrom'] : '';
    $read['ip'] = $isGM || $pwSystem['viewip'] ? 'IP:' . $read['userip'] : '';
    if ($read['groupid'] && !$anonymous) {
        $read['groupid'] == '-1' && ($read['groupid'] = $read['memberid']);
        !array_key_exists($read['groupid'], (array) $lpic) && ($read['groupid'] = 8);
        $read['lpic'] = $lpic[$read['groupid']];
        $read['level'] = $ltitle[$read['groupid']];
        $read['regdate'] = get_date($read['regdate'], "Y-m-d");
        $read['lastlogin'] = get_date($read['lastvisit'], "Y-m-d");
        $read['rvrc'] = floor($read['rvrc'] / 10);
        $read['author'] = $read['username'];
        $tpc_author = $read['author'];
        if (!empty($GLOBALS['showfield'])) {
            $customdata = $read['customdata'] ? (array) unserialize($read['customdata']) : array();
            $read['customdata'] = array();
            foreach ($customdata as $key => $val) {
                if ($val && in_array($key, $GLOBALS['showfield'])) {
                    $read['customdata'][$key] = $val;
                }
            }
        }
        $read['ontime'] = (int) ($read['onlinetime'] / 3600);
        $read['groupid'] == 6 && ($read['honor'] = '');
        if ($read['groupid'] != 6 && ($read['ifsign'] == 1 || $read['ifsign'] == 3)) {
            global $sign;
            if (!$sign[$read['author']]) {
                global $db_signmoney, $db_signgroup, $tdtime, $db_signcurtype;
                if ($db_signmoney && strpos($db_signgroup, ",{$read['groupid']},") !== false && (!getstatus($read['userstatus'], 10) || !$read['starttime'] || $read[$db_signcurtype] < ($tdtime - $read['starttime']) / 86400 * $db_signmoney)) {
                    $read['signature'] = '';
                } else {
                    if ($db_signwindcode && getstatus($read['userstatus'], 9)) {
                        if ($_G['right'][$read['groupid']]['imgwidth'] && $_G['right'][$read['groupid']]['imgheight']) {
                            $db_windpic['picwidth'] = $_G['right'][$read['groupid']]['imgwidth'];
                            $db_windpic['picheight'] = $_G['right'][$read['groupid']]['imgheight'];
                        }
                        if ($_G['right'][$read['groupid']]['fontsize']) {
                            $db_windpic['size'] = $_G['right'][$read['groupid']]['fontsize'];
                        }
                        $read['signature'] = convert($read['signature'], $db_windpic, 2);
                    }
                    $read['signature'] = str_replace("\n", "<br />", $read['signature']);
                }
                $sign[$read['author']] = $read['signature'];
            } else {
                $read['signature'] = $sign[$read['author']];
            }
        } else {
            $read['signature'] = '';
        }
    } else {
        $read['lpic'] = '8';
        $read['level'] = $read['digests'] = $read['postnum'] = $read['money'] = $read['currency'] = '*';
        $read['rvrc'] = $read['lastlogin'] = $read['credit'] = $read['regdate'] = '*';
        $read['honor'] = $read['signature'] = $read['micon'] = $read['aliww'] = '';
        if ($anonymous) {
            $read['oicq'] = $read['ip'] = $read['medals'] = $read['ipfrom'] = '';
            $read['author'] = $GLOBALS['db_anonymousname'];
            $read['authorid'] = 0;
            foreach ($GLOBALS['customfield'] as $key => $val) {
                $field = "field_" . (int) $val['id'];
                $read[$field] = '*';
            }
        }
    }
    $read['face'] = showfacedesign($read['micon']);
    list($read['posttime'], $read['postdate']) = getLastDate($read['postdate']);
    $read['mark'] = $read['reward'] = $read['tag'] = NULL;
    if ($read['ifmark']) {
        $ping_logs[$read['pid']] = $read['ifmark'];
    }
    if ($rewardtype != null) {
        if ($read['lou'] == 0 || $read['ifreward'] > 0 || $rewardtype == '0' && $winduid == $GLOBALS['authorid'] && $winduid != $read['authorid']) {
            $read['reward'] = Getrewhtml($read['lou'], $read['ifreward'], $read['pid']);
        }
    }
    if ($read['icon']) {
        $read['icon'] = "<img src=\"{$imgpath}/post/emotion/{$read['icon']}.gif\" align=\"left\" border=\"0\" />";
    } else {
        $read['icon'] = '';
    }
    if ($md_ifopen && $read['medals']) {
        $medals = $ifMedalNotExist = '';
        $md_a = explode(',', $read['medals']);
        foreach ($md_a as $key => $value) {
            if ($value && $_MEDALDB[$value]) {
                $medals .= "<img src=\"hack/medal/image/{$_MEDALDB[$value][picurl]}\" title=\"{$_MEDALDB[$value][name]}\" /> ";
            } else {
                unset($md_a[$key]);
                $ifMedalNotExist = 1;
            }
        }
        if ($ifMedalNotExist == 1) {
            $newMedalInfo = implode(',', $md_a);
            $db->update("UPDATE pw_members SET medals=" . pwEscape($newMedalInfo) . " WHERE uid=" . pwEscape($read['authorid']));
        }
        $read['medals'] = $medals . '<br />';
    } else {
        $read['medals'] = '';
    }
    $read['leaveword'] && ($read['content'] .= leaveword($read['leaveword'], $read['pid']));
    if ($db_iftag && $read['tags']) {
        list($tagdb, $tpc_tag) = explode("\t", $read['tags']);
        $tagdb = explode(' ', $tagdb);
        foreach ($tagdb as $key => $tag) {
            $tag && ($read['tag'] .= "<a href=\"job.php?action=tag&tagname=" . rawurlencode($tag) . "\"><span class=\"s3\">{$tag}</span></a> ");
        }
    }
    if ($read['ifshield'] || $read['groupid'] == 6 && $db_shield) {
        if ($read['ifshield'] == 2) {
            $read['content'] = shield('shield_del_article');
            $read['subject'] = '';
            $tpc_shield = 1;
        } else {
            if ($groupid == '3') {
                $read['subject'] = shield('shield_title');
            } else {
                $read['content'] = shield($read['ifshield'] ? 'shield_article' : 'ban_article');
                $read['subject'] = '';
                $tpc_shield = 1;
            }
        }
        $read['icon'] = '';
    }
    if (!$tpc_shield) {
        $aids = array();
        if ($read['aid']) {
            $attachs = $GLOBALS['attachdb'][$read['pid']];
            $read['ifhide'] > 0 && ifpost($tid) >= 1 && ($read['ifhide'] = 0);
            if (is_array($attachs) && !$read['ifhide']) {
                $aids = attachment($read['content']);
            }
        }
        if ($read['ifwordsfb'] != $GLOBALS['db_wordsfb']) {
            $read['content'] = wordsConvert($read['content'], array('id' => $tpc_pid == 'tpc' ? $tid : $tpc_pid, 'type' => $tpc_pid == 'tpc' ? 'topic' : 'posts', 'code' => $read['ifwordsfb']));
        }
        if ($read['ifconvert'] == 2) {
            $read['content'] = convert($read['content'], $db_windpost);
        } else {
            $tpc_tag && $db_readtag && ($read['content'] = relatetag($read['content'], $tpc_tag));
            strpos($read['content'], '[s:') !== false && ($read['content'] = showface($read['content']));
        }
        if ($attachs && is_array($attachs) && !$read['ifhide']) {
            if ($winduid == $read['authorid'] || $isGM || $pwSystem['delattach']) {
                $dfadmin = 1;
            } else {
                $dfadmin = 0;
            }
            foreach ($attachs as $at) {
                $atype = '';
                $rat = array();
                if ($at['type'] == 'img' && $at['needrvrc'] == 0 && (!$GLOBALS['downloadimg'] || !$GLOBALS['downloadmoney'] || $_G['allowdownload'] == 2)) {
                    $a_url = geturl($at['attachurl'], 'show');
                    if (is_array($a_url)) {
                        $atype = 'pic';
                        $dfurl = '<br>' . cvpic($a_url[0], 1, $db_windpost['picwidth'], $db_windpost['picheight'], $at['ifthumb']);
                        $rat = array('aid' => $at['aid'], 'name' => $at['name'], 'img' => $dfurl, 'dfadmin' => $dfadmin, 'desc' => $at['descrip']);
                    } elseif ($a_url == 'imgurl') {
                        $atype = 'picurl';
                        $rat = array('aid' => $at['aid'], 'name' => $at['name'], 'dfadmin' => $dfadmin, 'verify' => md5("showimg{$tid}{$read[pid]}{$fid}{$at[aid]}{$GLOBALS[db_hash]}"));
                    }
                } else {
                    $atype = 'downattach';
                    if ($at['needrvrc'] > 0) {
                        !$at['ctype'] && ($at['ctype'] = $at['special'] == 2 ? 'money' : 'rvrc');
                        $at['special'] == 2 && $GLOBALS['db_sellset']['price'] > 0 && ($at['needrvrc'] = min($at['needrvrc'], $GLOBALS['db_sellset']['price']));
                    }
                    $rat = array('aid' => $at['aid'], 'name' => $at['name'], 'size' => $at['size'], 'hits' => $at['hits'], 'needrvrc' => $at['needrvrc'], 'special' => $at['special'], 'cname' => $GLOBALS['creditnames'][$at['ctype']], 'type' => $at['type'], 'dfadmin' => $dfadmin, 'desc' => $at['descrip'], 'ext' => strtolower(substr(strrchr($at['name'], '.'), 1)));
                }
                if (!$atype) {
                    continue;
                }
                if (in_array($at['aid'], $aids)) {
                    $read['content'] = attcontent($read['content'], $atype, $rat);
                } else {
                    $read[$atype][$at['aid']] = $rat;
                }
            }
        }
    }
    /**
     * convert the post content
     */
    $read['alterinfo'] && ($read['content'] .= "<div id=\"alert_{$read['pid']}\" style=\"color:gray;margin-top:30px\">[ {$read['alterinfo']} ]</div>");
    if ($read['remindinfo']) {
        $remind = explode("\t", $read['remindinfo']);
        $remind[0] = str_replace("\n", "<br />", $remind[0]);
        $remind[2] && ($remind[2] = get_date($remind[2]));
        $read['remindinfo'] = $remind;
    }
    if ($_GET['keyword']) {
        $keywords = explode("|", $_GET['keyword']);
        foreach ($keywords as $key => $value) {
            if ($value) {
                $read['content'] = preg_replace("/(?<=[\\s\"\\]>()]|[-�]|^)(" . preg_quote($value, '/') . ")([.,:;-?!()\\s\"<\\[]|[-�]|\$)/siU", "<u><font color=\"red\">\\1</font></u>\\2", $read['content']);
            }
        }
    }
    $GLOBALS['foruminfo']['copyctrl'] && ($read['content'] = preg_replace("/<br \\/>/eis", "copyctrl()", $read['content']));
    return $read;
}
示例#4
0
function convert($message, $allow, $type = "post")
{
    global $isGM, $pwPostHide, $pwSellHide, $pwEncodeHide, $code_num, $code_htm, $phpcode_htm, $foruminfo, $db_picpath, $imgpath, $stylepath, $db_attachname, $attachpath, $db_cvtimes, $forumset, $tpc_tag, $db_windcode, $sell_num;
    $code_num = $sell_num = 0;
    $code_htm = array();
    if (strpos($message, "[code]") !== false && strpos($message, "[/code]") !== false) {
        $message = preg_replace("/\\[code\\](.+)?\\[\\/code\\]/eisU", "phpcode('\\1')", $message, $db_cvtimes);
    }
    if (strpos($message, "[payto]") !== false && strpos($message, "[/payto]") !== false) {
        require_once R_P . 'require/paytofunc.php';
        $message = preg_replace("/\\[payto\\](.+?)\\[\\/payto\\]/eis", "payto('\\1')", $message);
    }
    if (($pos = strpos($message, "[paragraph]")) !== false && $pos == min($pos, 10)) {
        $message = str_replace('[paragraph]', '', $message);
        $tmplist = explode('<br />', $message);
        $message = '<p style="text-indent: 2em;">' . implode('</p><p style="text-indent: 2em;">', $tmplist) . '</p>';
    }
    $message = preg_replace('/\\[list=([aA1]?)\\](.+?)\\[\\/list\\]/is', "<ol type=\"\\1\" style=\"margin:0 0 0 25px\">\\2</ol>", $message);
    $searcharray = array('[u]', '[/u]', '[b]', '[/b]', '[i]', '[/i]', '[list]', '[li]', '[/li]', '[/list]', '[sub]', '[/sub]', '[sup]', '[/sup]', '[strike]', '[/strike]', '[blockquote]', '[/blockquote]', '[hr]', '[/backcolor]', '[/color]', '[/font]', '[/size]', '[/align]');
    $replacearray = array('<u>', '</u>', '<b>', '</b>', '<i>', '</i>', '<ul style="margin:0 0 0 25px">', '<li>', '</li>', '</ul>', '<sub>', '</sub>', '<sup>', '</sup>', '<strike>', '</strike>', '<blockquote>', '</blockquote>', '<hr />', '</span>', '</span>', '</font>', '</font>', '</div>');
    $message = str_replace($searcharray, $replacearray, $message);
    $message = str_replace("p_w_upload", $db_attachname, $message);
    //此处位置不可调换
    $message = str_replace("p_w_picpath", $db_picpath, $message);
    //此处位置不可调换
    $searcharray = array("/\\[font=([^\\[\\(&\\;]+?)\\]/is", "/\\[color=([#0-9a-z]{1,15})\\]/is", "/\\[backcolor=([#0-9a-z]{1,10})\\]/is", "/\\[email=([^\\[]*)\\]([^\\[]*)\\[\\/email\\]/is", "/\\[email\\]([^\\[]*)\\[\\/email\\]/is", "/\\[size=(\\d+)\\]/eis", "/\\[align=(left|center|right|justify)\\]/is", "/\\[glow=(\\d+)\\,([0-9a-zA-Z]+?)\\,(\\d+)\\](.+?)\\[\\/glow\\]/is");
    $replacearray = array("<font face=\"\\1 \">", "<span style=\"color:\\1 \">", "<span style=\"background-color:\\1 \">", "<a href=\"mailto:\\1 \">\\2</a>", "<a href=\"mailto:\\1 \">\\1</a>", "size('\\1','{$allow['size']}')", "<div align=\"\\1\">", "<div style=\"width:\\1px;filter:glow(color=\\2,strength=\\3);\">\\4</div>");
    $message = preg_replace($searcharray, $replacearray, $message);
    if ($db_windcode) {
        $message = preg_replace($db_windcode['searcharray'], $db_windcode['replacearray'], $message);
    }
    if ($allow['pic']) {
        $message = preg_replace("/\\[img\\]([^\\<\r\n\"']+?)\\[\\/img\\]/eis", "cvpic('\\1','','{$allow['picwidth']}','{$allow['picheight']}')", $message, $db_cvtimes);
    } else {
        $message = preg_replace("/\\[img\\]([^\\<\r\n\"']+?)\\[\\/img\\]/eis", "nopic('\\1')", $message, $db_cvtimes);
    }
    if (strpos($message, '[/MUSIC]') !== false || strpos($message, '[/music]') !== false) {
        $message = preg_replace("/\\[music=(\\d+)\\](.+?)\\[\\/music\\]/eis", "SetMusic('\\1')", $message, $db_cvtimes);
    }
    if (strpos($message, '[/URL]') !== false || strpos($message, '[/url]') !== false) {
        $searcharray = array("/\\[url=(https?|ftp|gopher|news|telnet|mms|rtsp|thunder|ed2k|fs2you|flashget|qqdl)([^\\[\\s]+?)(\\,(1)\\/?)?\\](.+?)\\[\\/url\\]/eis", "/\\[url\\]www\\.([^\\[]+?)\\[\\/url\\]/eis", "/\\[url\\](https?|ftp|gopher|news|telnet|mms|rtsp|thunder|ed2k|fs2you|flashget|qqdl)([^\\[]+?)\\[\\/url\\]/eis", "/\\[url=([^\\[\\s]+?)(\\,(1)\\/?)?\\](.+?)\\[\\/url\\]/eis");
        $replacearray = array("cvurl('\\1','\\2','\\5','\\4','{$allow['checkurl']}')", "cvurl('\\1','','','','{$allow['checkurl']}')", "cvurl('\\1','\\2','','','{$allow['checkurl']}')", "cvurl('','\\1','\\4','\\3','{$allow['checkurl']}')");
        $message = preg_replace($searcharray, $replacearray, $message);
    }
    $searcharray = array("/\\[fly\\]([^\\[]*)\\[\\/fly\\]/is", "/\\[move\\]([^\\[]*)\\[\\/move\\]/is");
    $replacearray = array("<marquee width=90% behavior=alternate scrollamount=3>\\1</marquee>", "<marquee scrollamount=3>\\1</marquee>");
    $message = preg_replace($searcharray, $replacearray, $message);
    if ($type == 'post') {
        $tpc_tag && ($message = relatetag($message, $tpc_tag));
        if ($foruminfo['allowhide'] && strpos($message, "[post]") !== false && strpos($message, "[/post]") !== false) {
            $message = preg_replace("/\\[post\\](.+?)\\[\\/post\\]/eis", "post('\\1')", $message);
        }
        if ($forumset['allowencode'] && strpos($message, "[hide=") !== false && strpos($message, "[/hide]") !== false) {
            $message = preg_replace("/\\[hide=(.+?)\\](.+?)\\[\\/hide\\]/eis", "hidden('\\1','\\2')", $message);
        }
        if ($foruminfo['allowsell'] && strpos($message, "[sell") !== false && strpos($message, "[/sell]") !== false) {
            $message = preg_replace("/\\[sell=(.+?)\\](.+?)\\[\\/sell\\]/eis", "sell('\\1','\\2')", $message);
        }
    }
    if (strpos($message, "[quote]") !== false && strpos($message, "[/quote]") !== false) {
        $message = preg_replace("/\\[quote\\](.*?)\\[\\/quote\\]/eis", "qoute('\\1')", $message);
    }
    if (is_array($code_htm)) {
        krsort($code_htm);
        foreach ($code_htm as $codehtm) {
            foreach ($codehtm as $key => $value) {
                $message = str_replace("<\twind_code_{$key}\t>", $value, $message);
            }
        }
    }
    /* 去除quote中链接 */
    $quoteCode = "<blockquote class=\"blockquote3\"><div class=\"text\" style=\"padding:15px;\">";
    $quotePos = strpos($message, $quoteCode);
    /*fix 20110916*/
    if ($quotePos !== false) {
        $endQuotePos = strpos($message, "</div></blockquote>", $quotePos);
        $startQuotePos = $quotePos + strlen($quoteCode) - 1;
        $quoteContent = substr($message, $startQuotePos, $endQuotePos - $startQuotePos);
        $quoteContent = preg_replace('/(<br\\s*\\/?>\\s*){2,}/', '<br>', $quoteContent);
        $quoteContent = preg_replace_callback('/<a\\s+href=(\'|")([^\'"]+)(\'|")[^>]*>([^<]+)<\\/a>/is', 'stripQuoteLinks', $quoteContent);
        $message = substr_replace($message, $quoteContent, $startQuotePos, $endQuotePos - $startQuotePos);
    }
    if ($allow['flash'] && strpos($message, '[flash=') !== false || $allow['mpeg'] && (strpos($message, '[mp3=') !== false || strpos($message, '[rm=') !== false || strpos($message, '[wmv=') !== false)) {
        $message = "<script id=\"js_player\" src=\"js/player.js?1109\"></script>" . $message;
    }
    if ($allow['flash']) {
        $message = setVideo($message);
    } else {
        $message = preg_replace("/\\[flash=(\\d+?)\\,(\\d+?)(\\,(0|1))?\\]([^\\[\\<\r\n\"']+?)\\[\\/flash\\]/is", "<img src='{$imgpath}/wind/file/music.gif' align='absbottom'> <a target='_blank' href='\\5 '>flash: \\5</a>", $message, $db_cvtimes);
    }
    if ($type == 'post') {
        $t = 0;
        while (strpos($message, '[table') !== false && strpos($message, '[/table]') !== false) {
            $message = preg_replace('/\\[table(?:=(\\d{1,3}(?:%|px)?)(?:,(#\\w{6})?)?(?:,(#\\w{6})?)?(?:,(\\d+))?)?\\](.*?)\\[\\/table\\]/eis', "tablefun('\\5','\\1','\\2','\\3','\\4')", $message);
            if (++$t > 4) {
                break;
            }
        }
        if ($allow['mpeg']) {
            $message = setAudio($message);
        } else {
            $message = preg_replace(array("/\\[mp3=[01]{1}\\]([^\\<\r\n\"']+?)\\[\\/mp3\\]/is", "/\\[wmv=[01]{1}\\]([^\\<\r\n\"']+?)\\[\\/wmv\\]/is", "/\\[wmv(?:=[0-9]{1,3}\\,[0-9]{1,3}\\,[01]{1})?\\]([^\\<\r\n\"']+?)\\[\\/wmv\\]/is", "/\\[rm(?:=[0-9]{1,3}\\,[0-9]{1,3}\\,[01]{1})\\]([^\\<\r\n\"']+?)\\[\\/rm\\]/is"), "<img src=\"{$imgpath}/wind/file/music.gif\" align=\"absbottom\"> <a target=\"_blank\" href=\"\\1 \">\\1</a>", $message, $db_cvtimes);
        }
        //修复iframe安全问题 by taishici
        if ($allow['iframe']) {
            //iframe开启的情况
            //$message = preg_replace("/\[iframe\]([^\[\<\r\n\"']+?)\[\/iframe\]/is","<IFRAME SRC=\\1 FRAMEBORDER=0 ALLOWTRANSPARENCY=true SCROLLING=YES WIDTH=97% HEIGHT=340></IFRAME>",$message,$db_cvtimes);
            $message = preg_replace("/\\[iframe(=(\\d+?)\\,(\\d+?))?\\]([^\\[\\<\r\n\"']+?)\\[\\/iframe\\]/eis", "setIframe('\\4', '\\2', '\\3')", $message, $db_cvtimes);
        } else {
            //iframe没开启的情况
            //$message = preg_replace("/\[iframe\]([^\[\<\r\n\"']+?)\[\/iframe\]/is","Iframe Close: <a target=_blank href='\\1 '>\\1</a>",$message,$db_cvtimes);
            $message = preg_replace("/\\[iframe\\]([^\\[\\<\r\n\"']+?)\\[\\/iframe\\]/eis", "setIframeNo('\\1')", $message, $db_cvtimes);
        }
        strpos($message, '[s:') !== false && ($message = showface($message));
    }
    if (is_array($phpcode_htm)) {
        foreach ($phpcode_htm as $key => $value) {
            $message = str_replace("<\twind_phpcode_{$key}\t>", $value, $message);
        }
    }
    return $message;
}