62,272
社区成员
发帖
与我相关
我的任务
分享
class ubb {
var $subject = 'subject';
var $viewmode = 1;
var $submitCallback = '';
var $messagecodes = array();
var $bbcodes = array();
var $smilies = array();
var $maxsmilies = 10;
/**
* 构造函数
*/
function ubb() {
$this->smilies = array (
'searcharray' => array (
13 => '/\\:loveliness\\:/',
23 => '/\\:handshake/',
20 => '/\\:victory\\:/',
18 => '/\\:sleepy\\:/',
17 => '/\\:shutup\\:/',
16 => '/\\:dizzy\\:/',
15 => '/\\:curse\\:/',
43 => '/\\[g\\:03\\]/',
54 => '/\\[g\\:14\\]/',
34 => '/\\[m\\:10\\]/',
45 => '/\\[g\\:05\\]/',
56 => '/\\[g\\:16\\]/',
14 => '/\\:funk\\:/',
25 => '/\\[m\\:01\\]/',
36 => '/\\[m\\:12\\]/',
47 => '/\\[g\\:07\\]/',
27 => '/\\[m\\:03\\]/',
38 => '/\\[m\\:14\\]/',
49 => '/\\[g\\:09\\]/',
29 => '/\\[m\\:05\\]/',
40 => '/\\[m\\:16\\]/',
51 => '/\\[g\\:11\\]/',
31 => '/\\[m\\:07\\]/',
42 => '/\\[g\\:02\\]/',
53 => '/\\[g\\:13\\]/',
22 => '/\\:kiss\\:/',
33 => '/\\[m\\:09\\]/',
44 => '/\\[g\\:04\\]/',
55 => '/\\[g\\:15\\]/',
24 => '/\\:call\\:/',
35 => '/\\[m\\:11\\]/',
46 => '/\\[g\\:06\\]/',
57 => '/\\[g\\:17\\]/',
26 => '/\\[m\\:02\\]/',
37 => '/\\[m\\:13\\]/',
48 => '/\\[g\\:08\\]/',
28 => '/\\[m\\:04\\]/',
39 => '/\\[m\\:15\\]/',
50 => '/\\[g\\:10\\]/',
30 => '/\\[m\\:06\\]/',
41 => '/\\[g\\:01\\]/',
52 => '/\\[g\\:12\\]/',
21 => '/\\:time\\:/',
32 => '/\\[m\\:08\\]/',
19 => '/\\:hug\\:/',
12 => '/\\:lol/',
4 => '/\\:\'\\(/',
1 => '/\\:\\)/',
3 => '/\\:D/',
5 => '/\\:@/',
7 => '/\\:P/',
9 => '/;P/',
11 => '/\\:Q/',
2 => '/\\:\\(/',
6 => '/\\:o/',
8 => '/\\:\\$/',
10 => '/\\:L/',
),
'replacearray' =>
array (
13 => 'loveliness.gif',
23 => 'handshake.gif',
20 => 'victory.gif',
18 => 'sleepy.gif',
17 => 'shutup.gif',
16 => 'dizzy.gif',
15 => 'curse.gif',
43 => '03.gif',
54 => '14.gif',
34 => '10.gif',
45 => '05.gif',
56 => '16.gif',
14 => 'funk.gif',
25 => '01.gif',
36 => '12.gif',
47 => '07.gif',
27 => '03.gif',
38 => '14.gif',
49 => '09.gif',
29 => '05.gif',
40 => '16.gif',
51 => '11.gif',
31 => '07.gif',
42 => '02.gif',
53 => '13.gif',
22 => 'kiss.gif',
33 => '09.gif',
44 => '04.gif',
55 => '15.gif',
24 => 'call.gif',
35 => '11.gif',
46 => '06.gif',
57 => '17.gif',
26 => '02.gif',
37 => '13.gif',
48 => '08.gif',
28 => '04.gif',
39 => '15.gif',
50 => '10.gif',
30 => '06.gif',
41 => '01.gif',
52 => '12.gif',
21 => 'time.gif',
32 => '08.gif',
19 => 'hug.gif',
12 => 'lol.gif',
4 => 'cry.gif',
1 => 'smile.gif',
3 => 'biggrin.gif',
5 => 'huffy.gif',
7 => 'tongue.gif',
9 => 'titter.gif',
11 => 'mad.gif',
2 => 'sad.gif',
6 => 'shocked.gif',
8 => 'shy.gif',
10 => 'sweat.gif',
),
'typearray' =>
array (
13 => '1',
23 => '1',
20 => '1',
18 => '1',
17 => '1',
16 => '1',
15 => '1',
43 => '3',
54 => '3',
34 => '2',
45 => '3',
56 => '3',
14 => '1',
25 => '2',
36 => '2',
47 => '3',
27 => '2',
38 => '2',
49 => '3',
29 => '2',
40 => '2',
51 => '3',
31 => '2',
42 => '3',
53 => '3',
22 => '1',
33 => '2',
44 => '3',
55 => '3',
24 => '1',
35 => '2',
46 => '3',
57 => '3',
26 => '2',
37 => '2',
48 => '3',
28 => '2',
39 => '2',
50 => '3',
30 => '2',
41 => '3',
52 => '3',
21 => '1',
32 => '2',
19 => '1',
12 => '1',
4 => '1',
1 => '1',
3 => '1',
5 => '1',
7 => '1',
9 => '1',
11 => '1',
2 => '1',
6 => '1',
8 => '1',
10 => '1',
),
);
$this->smilies['smileytypes'] = array (
1 => array ('name' => '默认', 'directory' => 'default'),
2 => array ('name' => '酷猴', 'directory' => 'monkey'),
3 => array ('name' => '呆呆男', 'directory' => 'grapeman')
);
$this->bbcodes = array (
'searcharray' =>
array (
0 => '/\\[fly]([^"\\[]+?)\\[\\/fly\\]/is',
1 => '/\\[flash]([^"\\[]+?)\\[\\/flash\\]/is',
2 => '/\\[qq]([^"\\[]+?)\\[\\/qq\\]/is',
3 => '/\\[sup]([^"\\[]+?)\\[\\/sup\\]/is',
4 => '/\\[sub]([^"\\[]+?)\\[\\/sub\\]/is',
),
'replacearray' =>
array (
0 => '<marquee width="90%" behavior="alternate" scrollamount="3">\\1</marquee>',
1 => '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="550" height="400"><param name="allowScriptAccess" value="sameDomain"><param name="movie" value="\\1"><param name="quality" value="high"><param name="bgcolor" value="#ffffff"><embed src="\\1" quality="high" bgcolor="#ffffff" width="550" height="400" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>',
2 => '<a href="http://wpa.qq.com/msgrd?V=1&Uin=\\1&Site=[Discuz!]&Menu=yes" target="_blank"><img src="http://wpa.qq.com/pa?p=1:\\1:1" border="0"></a>',
3 => '<sup>\\1</sup>',
4 => '<sub>\\1</sub>',
),
);
$this->messagecodes['smiliesreplaced'] = 0;
}
function parsemedia($type, $width, $height, $autostart, $url) {
if(in_array($type, array('ra', 'rm', 'wma', 'wmv', 'mp3', 'mov'))) {
$url = str_replace(array('<', '>'), '', str_replace('\\"', '\"', $url));
$mediaid = 'media_'.random(3);
switch($type) {
case 'ra' : return '<object classid="clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA" width="'.$width.'" height="32"><param name="autostart" value="'.$autostart.'" /><param name="src" value="'.$url.'" /><param name="controls" value="controlpanel" /><param name="console" value="'.$mediaid.'_" /><embed src="'.$url.'" type="audio/x-pn-realaudio-plugin" controls="ControlPanel" '.($autostart ? 'autostart="true"' : '').' console="'.$mediaid.'_" width="'.$width.'" height="32"></embed></object>';break;
case 'rm' : return '<object classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" width="'.$width.'" height="'.$height.'"><param name="autostart" value="'.$autostart.'" /><param name="src" value="'.$url.'" /><param name="controls" value="imagewindow" /><param name="console" value="'.$mediaid.'_" /><embed src="'.$url.'" type="audio/x-pn-realaudio-plugin" controls="IMAGEWINDOW" console="'.$mediaid.'_" width="'.$width.'" height="'.$height.'"></embed></object><br /><object classid="clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA" width="'.$width.'" height="32"><param name="src" value="'.$url.'" /><param name="controls" value="controlpanel" /><param name="console" value="'.$mediaid.'_" /><embed src="'.$url.'" type="audio/x-pn-realaudio-plugin" controls="ControlPanel" '.($autostart ? 'autostart="true"' : '').' console="'.$mediaid.'_" width="'.$width.'" height="32"></embed></object>';break;
case 'wma' : return '<object classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="'.$width.'" height="64"><param name="autostart" value="'.$autostart.'" /><param name="url" value="'.$url.'" /><embed src="'.$url.'" autostart="'.$autostart.'" type="audio/x-ms-wma" width="'.$width.'" height="64"></embed></object>';break;
case 'wmv' : return '<object classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="'.$width.'" height="'.$height.'"><param name="autostart" value="'.$autostart.'" /><param name="url" value="'.$url.'" /><embed src="'.$url.'" autostart="'.$autostart.'" type="video/x-ms-wmv" width="'.$width.'" height="'.$height.'"></embed></object>';break;
case 'mp3' : return '<object classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="'.$width.'" height="64"><param name="autostart" value="'.$autostart.'" /><param name="url" value="'.$url.'" /><embed src="'.$url.'" autostart="'.$autostart.'" type="application/x-mplayer2" width="'.$width.'" height="64"></embed></object>';break;
case 'mov' : return '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="'.$width.'" height="'.$height.'"><param name="autostart" value="'.($autostart ? 'true' : 'false').'" /><param name="src" value="'.$url.'" /><embed controller="true" width="'.$width.'" height="'.$height.'" src="'.$url.'" autostart="'.($autostart ? 'true' : 'false').'"></embed></object>';break;
}
}
return;
}
function bbcodeurl($url, $tags) {
if(!preg_match("/<.+?>/s", $url)) {
if(!in_array(strtolower(substr($url, 0, 6)), array('http:/', 'https:', 'ftp://', 'rtsp:/', 'mms://'))) {
$url = 'http://'.$url;
}
return str_replace(array('submit', 'logging.php'), array('', ''), sprintf($tags, $url, addslashes($url)));
} else {
return ' '.$url;
}
}
function h($string) {
if(is_array($string)) {
foreach($string as $key => $val) {
$string[$key] = $this->h($val);
}
} else {
$string = preg_replace('/&((#(\d{3,5}|x[a-fA-F0-9]{4})|[a-zA-Z][a-z0-9]{2,5});)/', '&\\1',
str_replace(array('&', '"', '<', '>'), array('&', '"', '<', '>'), $string));
}
return $string;
}
}
function codedisp($code) {
$this->messagecodes['pcodecount']++;
$code = htmlspecialchars(str_replace('\\"', '"', preg_replace("/^[\n\r]*(.+?)[\n\r]*$/is", "\\1", $code)));
$code = str_replace("\n", "<li>", $code);
$this->messagecodes['codehtml'][$this->messagecodes['pcodecount']] = $this->tpl_codedisp($this->messagecodes, $code);
$this->messagecodes['codecount']++;
return "[\tISOSHU_CODE_{$this->messagecodes[pcodecount]}\t]";
}
function tpl_codedisp($messagecodes, $code) {
$codesid = 'code' . $messagecodes['codecount'];
$str = '<div class="blockcode"><div id="code'. $codesid . '"><ol><li>'.$code.'</li></ol></div>';
$str .= '<em onclick="copycode($(\''.$codesid.'\'));">复制</em></div>';
}
function tpl_quote() {
return '<div class="quote"><blockquote>\\1</blockquote></div>';
}
function tpl_free() {
return '<div class="quote"><blockquote>\\1</blockquote></div>';
}
function ubb2html($message) {
if((strpos($message, '') || strpos($message, '[/CODE]')) !== FALSE) {