Home >php教程 >php手册 >discuz中正则替换soso表情标标签

discuz中正则替换soso表情标标签

WBOY
WBOYOriginal
2016-06-06 20:08:521903browse

/** * 替换内容中SOSO表情标签 * @author tangw * @param type $message */function parse_soso_smiles($message) { $message = preg_replace("/\{\:soso_((e\d+)|(_\d+_\d))\:\}/ies", "rep_soso_smiles('\\1')", $message); return $message;}/** * 替换so

/**
 * 替换内容中SOSO表情标签
 * @author tangw
 * @param type $message
 */
function parse_soso_smiles($message) {
    $message = preg_replace("/\{\:soso_((e\d+)|(_\d+_\d))\:\}/ies", "rep_soso_smiles('\\1')", $message);
    return $message;
}
/**
 * 替换soso表情标签为img
 * (正则替换表情方法:parse_soso_smiles)
 * @author tangw
 * @param type $smilieid 正则替换后数据
 */
function rep_soso_smiles($smilieid) {
    $imgid = 'soso_' . $smilieid;
    $width = '24';
    $height = "24";
    if (strpos($smilieid, '_') === 0) {
        $realsmilieid = $smiliekey = substr($smilieid, 0, -2);
        $serverid = intval(substr($smilieid, -1));
        $imgsrc = "http://piccache{$serverid}.soso.com/face/{$realsmilieid}";
        $ar_img = getimagesize($imgsrc);
        if ($ar_img) {
            $width = $ar_img[0];
            $height = $ar_img[1];
        }
    } elseif (strpos($smilieid, 'e') === 0) {
        $imgsrc = "http://cache.soso.com/img/img/{$smilieid}.gif";
    }
    return "<img class='\"expression_img\"' src="http://www.tangwen.org/archives/%5C" smilieid='\"{$imgid}\"'   style="max-width:90%"width:"' . border='\"0\"' alt='\"\"'>";
}

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:wordpress中的php+ajaxNext article:程序猿ProMonkey V2.03