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

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:08:52
Original
1943 people have browsed it

/** * 替换内容中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 src="/static/imghw/default1.png" data-src="http://www.tangwen.org/archives/\" class="lazy" smilieid='\"{$imgid}\"'   style="max-width:90%"width:"' . border='\"0\"' alt='\"\"'>";
}
Copy after login

Statement of this Website
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
Latest Issues
php - discuz single sign-on problem
From 1970-01-01 08:00:00
0
0
0
How to install discuz in phpStudy
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template