PageRenderTime 43ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/source/function/function_followcode.php

https://github.com/jinbo51/DiscuzX
PHP | 461 lines | 431 code | 24 blank | 6 comment | 32 complexity | 88916e701d68c48b942433417fe6a9ba MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: function_followcode.php 33302 2013-05-23 03:17:26Z andyzheng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. $_G['post_attach'] = array();
  12. function fcodedisp($code, $type='codehtml') {
  13. global $_G;
  14. $_G['forum_discuzcode']['pcodecount']++;
  15. $_G['forum_discuzcode'][$type][$_G['forum_discuzcode']['pcodecount']] = $code;
  16. $_G['forum_discuzcode']['codecount']++;
  17. return "[\tD_".$_G['forum_discuzcode']['pcodecount']."\t]";
  18. }
  19. function followcode($message, $tid = 0, $pid = 0, $length = 0, $allowimg = true) {
  20. global $_G;
  21. include_once libfile('function/post');
  22. $message = strip_tags($message);
  23. $message = messagesafeclear($message);
  24. if((strpos($message, '[/code]') || strpos($message, '[/CODE]')) !== FALSE) {
  25. $message = preg_replace("/\s?\[code\](.+?)\[\/code\]\s?/ies", "", $message);
  26. }
  27. $msglower = strtolower($message);
  28. $htmlon = 0;
  29. $message = dhtmlspecialchars($message);
  30. if($_G['setting']['plugins']['func'][HOOKTYPE]['discuzcode']) {
  31. $_G['discuzcodemessage'] = & $message;
  32. $param = func_get_args();
  33. hookscript('discuzcode', 'global', 'funcs', array('param' => $param, 'caller' => 'discuzcode'), 'discuzcode');
  34. }
  35. $_G['delattach'] = array();
  36. $message = fparsesmiles($message);
  37. if(strpos($msglower, 'attach://') !== FALSE) {
  38. $message = preg_replace("/attach:\/\/(\d+)\.?(\w*)/ie", '', $message);
  39. }
  40. if(strpos($msglower, 'ed2k://') !== FALSE) {
  41. $message = preg_replace("/ed2k:\/\/(.+?)\//e", '', $message);
  42. }
  43. if(strpos($msglower, '[/i]') !== FALSE) {
  44. $message = preg_replace("/\s*\[i=s\][\n\r]*(.+?)[\n\r]*\[\/i\]\s*/is", '', $message);
  45. }
  46. $message = str_replace('[/p]', "\n", $message);
  47. $message = str_replace(array(
  48. '[/color]', '[/backcolor]', '[/size]', '[/font]', '[/align]', '[b]', '[/b]', '[s]', '[/s]', '[hr]',
  49. '[i=s]', '[i]', '[/i]', '[u]', '[/u]', '[list]', '[list=1]', '[list=a]',
  50. '[list=A]', "\r\n[*]", '[*]', '[/list]', '[indent]', '[/indent]', '[/float]'
  51. ), '', preg_replace(array(
  52. "/\[color=([#\w]+?)\]/i",
  53. "/\[color=((rgb|rgba)\([\d\s,]+?\))\]/i",
  54. "/\[backcolor=([#\w]+?)\]/i",
  55. "/\[backcolor=((rgb|rgba)\([\d\s,]+?\))\]/i",
  56. "/\[size=(\d{1,2}?)\]/i",
  57. "/\[size=(\d{1,2}(\.\d{1,2}+)?(px|pt)+?)\]/i",
  58. "/\[font=([^\[\<]+?)\]/i",
  59. "/\[align=(left|center|right)\]/i",
  60. "/\[float=left\]/i",
  61. "/\[float=right\]/i"
  62. ), '', $message));
  63. if(strpos($msglower, '[/p]') !== FALSE) {
  64. $message = preg_replace("/\[p=(\d{1,2}|null), (\d{1,2}|null), (left|center|right)\]/i", "<p style=\"line-height:\\1px;text-indent:\\2em;text-align:left;\">", $message);
  65. $message = str_replace('[/p]', '</p>', $message);
  66. }
  67. if(strpos($msglower, '[/quote]') !== FALSE) {
  68. $message = preg_replace("/\s?\[quote\][\n\r]*(.+?)[\n\r]*\[\/quote\]\s?/is", '', $message);
  69. }
  70. if(strpos($msglower, '[/free]') !== FALSE) {
  71. $message = preg_replace("/\s*\[free\][\n\r]*(.+?)[\n\r]*\[\/free\]\s*/is", '', $message);
  72. }
  73. if(isset($_G['cache']['bbcodes'][-$allowbbcode])) {
  74. $message = preg_replace($_G['cache']['bbcodes'][-$allowbbcode]['searcharray'], '', $message);
  75. }
  76. if(strpos($msglower, '[/hide]') !== FALSE) {
  77. preg_replace("/\[hide.*?\]\s*(.*?)\s*\[\/hide\]/ies", "hideattach('\\1')", $message);
  78. if(strpos($msglower, '[hide]') !== FALSE) {
  79. $message = preg_replace("/\[hide\]\s*(.*?)\s*\[\/hide\]/is", '', $message);
  80. }
  81. if(strpos($msglower, '[hide=') !== FALSE) {
  82. $message = preg_replace("/\[hide=(d\d+)?[,]?(\d+)?\]\s*(.*?)\s*\[\/hide\]/ies", '', $message);
  83. }
  84. }
  85. if(strpos($msglower, '[/url]') !== FALSE) {
  86. $message = preg_replace("/\[url(=((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|thunder|qqdl|synacast){1}:\/\/|www\.|mailto:)?([^\r\n\[\"']+?))?\](.+?)\[\/url\]/ies", "fparseurl('\\1', '\\5', '\\2')", $message);
  87. }
  88. if(strpos($msglower, '[/email]') !== FALSE) {
  89. $message = preg_replace("/\[email(=([a-z0-9\-_.+]+)@([a-z0-9\-_]+[.][a-z0-9\-_.]+))?\](.+?)\[\/email\]/ies", "fparseemail('\\1', '\\4')", $message);
  90. }
  91. $nest = 0;
  92. while(strpos($msglower, '[table') !== FALSE && strpos($msglower, '[/table]') !== FALSE){
  93. $message = preg_replace("/\[table(?:=(\d{1,4}%?)(?:,([\(\)%,#\w ]+))?)?\]\s*(.+?)\s*\[\/table\]/ies", "fparsetable('\\1', '\\2', '\\3')", $message);
  94. if(++$nest > 4) break;
  95. }
  96. if(strpos($msglower, '[/media]') !== FALSE) {
  97. $message = preg_replace("/\[media=([\w,]+)\]\s*([^\[\<\r\n]+?)\s*\[\/media\]/ies", "fparsemedia('\\1', '\\2')", $message);
  98. }
  99. if(strpos($msglower, '[/audio]') !== FALSE) {
  100. $message = preg_replace("/\[audio(=1)*\]\s*([^\[\<\r\n]+?)\s*\[\/audio\]/ies", "fparseaudio('\\2')", $message);
  101. }
  102. if(strpos($msglower, '[/flash]') !== FALSE) {
  103. $message = preg_replace("/\[flash(=(\d+),(\d+))?\]\s*([^\[\<\r\n]+?)\s*\[\/flash\]/ies", "fparseflash('\\4');", $message);
  104. }
  105. if($parsetype != 1 && strpos($msglower, '[swf]') !== FALSE) {
  106. $message = preg_replace("/\[swf\]\s*([^\[\<\r\n]+?)\s*\[\/swf\]/ies", "bbcodeurl('\\1', ' <img src=\"'.STATICURL.'image/filetype/flash.gif\" align=\"absmiddle\" alt=\"\" /> <a href=\"{url}\" target=\"_blank\">Flash: {url}</a> ')", $message);
  107. }
  108. $flag = $length ? 1 : 0;
  109. if($tid) {
  110. $extra = "onclick=\"changefeed($tid, $pid, $flag, this)\"";
  111. }
  112. if(strpos($msglower, '[/img]') !== FALSE) {
  113. $message = preg_replace(array(
  114. "/\[img\]\s*([^\[\<\r\n]+?)\s*\[\/img\]/ies",
  115. "/\[img=(\d{1,4})[x|\,](\d{1,4})\]\s*([^\[\<\r\n]+?)\s*\[\/img\]/ies"
  116. ), $allowimg ? array(
  117. "fparseimg('\\1', '$extra')",
  118. "fparseimg('\\3', '$extra')"
  119. ) : '', $message);
  120. }
  121. if($tid && $pid) {
  122. $_G['post_attach'] = C::t('forum_attachment_n')->fetch_all_by_id(getattachtableid($tid), 'pid', $pid);
  123. foreach($_G['post_attach'] as $aid => $attach) {
  124. if(!empty($_G['delattach']) && in_array($aid, $_G['delattach'])) {
  125. continue;
  126. }
  127. $message .= "[attach]$attach[aid][/attach]";
  128. $message = preg_replace("/\[attach\]$attach[aid]\[\/attach\]/i", fparseattach($attach['aid'], $length, $extra), $message, 1);
  129. }
  130. }
  131. if(strpos($msglower, '[/attach]') !== FALSE) {
  132. $message = preg_replace("/\[attach\]\s*([^\[\<\r\n]+?)\s*\[\/attach\]/ies", '', $message);
  133. }
  134. $message = clearnl($message);
  135. if($length) {
  136. $sppos = strpos($message, chr(0).chr(0).chr(0));
  137. if($sppos !== false) {
  138. $message = substr($message, 0, $sppos);
  139. }
  140. $checkstr = cutstr($message, $length, '');
  141. if(strpos($checkstr, '[') && strpos(strrchr($checkstr, "["), ']') === FALSE) {
  142. $length = strpos($message, ']', strrpos($checkstr, strrchr($checkstr, "[")));
  143. }
  144. $message = cutstr($message, $length+1, ' <a href="javascript:;" class="flw_readfull xi2 xs1"'.$extra.'>'.lang('space', 'follow_view_fulltext').'</a>');
  145. } elseif($allowimg && !empty($extra)) {
  146. $message .= '<div class="ptm cl"><a href="javascript:;" class="flw_readfull y xi2 xs1"'.$extra.'>'.lang('space', 'follow_retract').'</a></div>';
  147. }
  148. for($i = 0; $i <= $_G['forum_discuzcode']['pcodecount']; $i++) {
  149. $code = '';
  150. if(isset($_G['forum_discuzcode']['codehtml'][$i]) && !empty($_G['forum_discuzcode']['codehtml'][$i])) {
  151. $code = $_G['forum_discuzcode']['codehtml'][$i];
  152. } elseif(!$length) {
  153. if(isset($_G['forum_discuzcode']['audio'][$i]) && !empty($_G['forum_discuzcode']['audio'][$i])) {
  154. $code = $_G['forum_discuzcode']['audio'][$i];
  155. } elseif(isset($_G['forum_discuzcode']['video'][$i]) && !empty($_G['forum_discuzcode']['video'][$i])) {
  156. $code = $_G['forum_discuzcode']['video'][$i];
  157. } elseif(isset($_G['forum_discuzcode']['media'][$i]) && !empty($_G['forum_discuzcode']['media'][$i])) {
  158. $code = $_G['forum_discuzcode']['media'][$i];
  159. } elseif(isset($_G['forum_discuzcode']['image'][$i]) && !empty($_G['forum_discuzcode']['image'][$i])) {
  160. $code = $_G['forum_discuzcode']['image'][$i];
  161. } elseif(isset($_G['forum_discuzcode']['attach'][$i]) && !empty($_G['forum_discuzcode']['attach'][$i])) {
  162. $code = $_G['forum_discuzcode']['attach'][$i];
  163. }
  164. }
  165. $message = str_replace("[\tD_$i\t]", $code, $message);
  166. }
  167. $message = clearnl($message);
  168. if(!empty($_GET['highlight'])) {
  169. $highlightarray = explode('+', $_GET['highlight']);
  170. $sppos = strrpos($message, chr(0).chr(0).chr(0));
  171. if($sppos !== FALSE) {
  172. $specialextra = substr($message, $sppos + 3);
  173. $message = substr($message, 0, $sppos);
  174. }
  175. $message = preg_replace(array("/(^|>)([^<]+)(?=<|$)/sUe", "/<highlight>(.*)<\/highlight>/siU"), array("highlightword('\\2', \$highlightarray, '\\1')", "<strong><font color=\"#FF0000\">\\1</font></strong>"), $message);
  176. if($sppos !== FALSE) {
  177. $message = $message.chr(0).chr(0).chr(0).$specialextra;
  178. }
  179. }
  180. unset($msglower);
  181. if($length) {
  182. $count = 0;
  183. $imagecode = $mediacode = $videocode = $audiocode = $mediahtml = '';
  184. for($i = 0; $i <= $_G['forum_discuzcode']['pcodecount']; $i++) {
  185. if(isset($_G['forum_discuzcode']['audio'][$i]) && !empty($_G['forum_discuzcode']['audio'][$i])) {
  186. $audiocode .= '<li>'.$_G['forum_discuzcode']['audio'][$attachcodei].'</li>';
  187. } elseif(isset($_G['forum_discuzcode']['video'][$i]) && !empty($_G['forum_discuzcode']['video'][$i])) {
  188. $videocode .= '<li>'.$_G['forum_discuzcode']['video'][$i].'</li>';
  189. } elseif(isset($_G['forum_discuzcode']['media'][$i]) && !empty($_G['forum_discuzcode']['media'][$i])) {
  190. $mediacode .= '<li>'.$_G['forum_discuzcode']['media'][$i].'</li>';
  191. } elseif(isset($_G['forum_discuzcode']['image'][$i]) && !empty($_G['forum_discuzcode']['image'][$i]) && $count < 4) {
  192. $imagecode .= '<li>'.$_G['forum_discuzcode']['image'][$i].'</li>';
  193. $count++;
  194. } elseif(isset($_G['forum_discuzcode']['attach'][$i]) && !empty($_G['forum_discuzcode']['attach'][$i])) {
  195. $attachcode .= '<li>'.$_G['forum_discuzcode']['attach'][$i].'</li>';
  196. }
  197. }
  198. if(!empty($audiocode)) {
  199. $message .= '<div class="flw_music"><ul>'.$audiocode.'</ul></div>';
  200. }
  201. if(!empty($videocode)) {
  202. $message .= '<div class="flw_video"><ul>'.$videocode.'</ul></div>';
  203. }
  204. if(!empty($mediacode)) {
  205. $message .= '<div class="flw_video"><ul>'.$mediacode.'</ul></div>';
  206. }
  207. if(!empty($imagecode)) {
  208. $message = '<div class="flw_image'.($count < 2 ? ' flw_image_1' : '').'"><ul>'.$imagecode.'</ul></div>'.$message;
  209. }
  210. if(!empty($attachcode)) {
  211. $message .= '<div class="flw_attach"><ul>'.$attachcode.'</ul></div>';
  212. }
  213. }
  214. return $htmlon ? $message : nl2br(str_replace(array("\t", ' ', ' '), ' ', $message));
  215. }
  216. function clearnl($message) {
  217. $message = preg_replace("/[\r\n|\n|\r]\s*[\r\n|\n|\r]/i", "\n", $message);
  218. $message = preg_replace("/^[\r\n|\n|\r]{1,}/i", "", $message);
  219. $message = preg_replace("/[\r\n|\n|\r]{2,}/i", "\n", $message);
  220. return $message;
  221. }
  222. function hideattach($hidestr) {
  223. global $_G;
  224. preg_match_all("/\[attach\]\s*(.*?)\s*\[\/attach\]/is", $hidestr, $del);
  225. foreach($del[1] as $aid) {
  226. $_G['delattach'][$aid] = $aid;
  227. }
  228. }
  229. function fparseurl($url, $text, $scheme) {
  230. global $_G;
  231. $html = '';
  232. if(!$url && preg_match("/((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|thunder|qqdl|synacast){1}:\/\/|www\.)[^\[\"']+/i", trim($text), $matches)) {
  233. $url = $matches[0];
  234. $length = 65;
  235. if(strlen($url) > $length) {
  236. $text = substr($url, 0, intval($length * 0.5)).' ... '.substr($url, - intval($length * 0.3));
  237. }
  238. $html = '<a href="'.(substr(strtolower($url), 0, 4) == 'www.' ? 'http://'.$url : $url).'" target="_blank">'.$text.'</a>';
  239. } else {
  240. $url = substr($url, 1);
  241. if(substr(strtolower($url), 0, 4) == 'www.') {
  242. $url = 'http://'.$url;
  243. }
  244. $url = !$scheme ? $_G['siteurl'].$url : $url;
  245. $atclass = substr(strtolower($text), 0, 1) == '@' ? ' class="xi2" ' : '';
  246. $html = '<a href="'.$url.'" target="_blank" '.$atclass.'>'.$text.'</a>';
  247. }
  248. return fcodedisp($html);
  249. }
  250. function fparseattach($aid, $length = 0, $extra = '') {
  251. global $_G;
  252. $html = '';
  253. if(!empty($_G['post_attach']) && !empty($_G['post_attach'][$aid])) {
  254. $attach = $_G['post_attach'][$aid];
  255. unset($_G['post_attach'][$attach['aid']]);
  256. $attach['url'] = ($attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']).'forum/';
  257. $attach['isimage'] = $attach['isimage'] && !$attach['price'] ? $attach['isimage'] : 0;
  258. $attach['refcheck'] = (!$attach['remote'] && $_G['setting']['attachrefcheck']) || ($attach['remote'] && ($_G['setting']['ftp']['hideurl'] || ($attach['isimage'] && $_G['setting']['attachimgpost'] && strtolower(substr($_G['setting']['ftp']['attachurl'], 0, 3)) == 'ftp')));
  259. $rimg_id = random(5).$attach['aid'];
  260. if($attach['isimage'] && !$attach['price'] && !$attach['readperm']) {
  261. $nothumb = $length ? 0 : 1;
  262. $src = $attach['url'].(!$attach['thumb'] ? $attach['attachment'] : getimgthumbname($attach['attachment']));
  263. $html = bbcodeurl($src, '<img id="aimg_'.$rimg_id.'" src="'.$src.'" border="0" alt="'.$attach['filename'].'" '.$extra.' style="cursor: pointer;" />');
  264. return fcodedisp($html, 'image');
  265. } else {
  266. if($attach['price'] || $attach['readperm']) {
  267. $html = '<a href="forum.php?mod=viewthread&tid='.$attach['tid'].'" id="attach_'.$rimg_id.'" target="_blank" class="flw_attach_price"><strong>'.$attach['filename'].'</strong><span>'.sizecount($attach['filesize']).'</span></a>';
  268. } else {
  269. require_once libfile('function/attachment');
  270. $aidencode = packaids($attach);
  271. $attachurl = "forum.php?mod=attachment&aid=$aidencode";
  272. $html = '<a href="'.$attachurl.'" id="attach_'.$rimg_id.'"><strong>'.$attach['filename'].'</strong><span>'.sizecount($attach['filesize']).'</span></a>';
  273. }
  274. return fcodedisp($html, 'attach');
  275. }
  276. }
  277. return '';
  278. }
  279. function fparseflash($url) {
  280. preg_match("/((https?){1}:\/\/|www\.)[^\[\"']+/i", $url, $matches);
  281. $url = $matches[0];
  282. if(fileext($url) != 'flv') {
  283. $rimg_id = 'swf_'.random(5);
  284. $html = bbcodeurl($url, '<img src="'.IMGDIR.'/flash.gif" alt="'.lang('space', 'follow_click_play').'" onclick="javascript:showFlash(\'flash\', \''.$url.'\', this, \''.$rimg_id.'\');" class="tn" style="cursor: pointer;" />');
  285. return fcodedisp($html, 'media');
  286. } else {
  287. $url = STATICURL.'image/common/flvplayer.swf?&autostart=true&file='.urlencode($matches[0]);
  288. return fmakeflv($url);
  289. }
  290. }
  291. function fparseemail($email, $text) {
  292. global $_G;
  293. $text = str_replace('\"', '"', $text);
  294. $html = '';
  295. if(!$email && preg_match("/\s*([a-z0-9\-_.+]+)@([a-z0-9\-_]+[.][a-z0-9\-_.]+)\s*/i", $text, $matches)) {
  296. $email = trim($matches[0]);
  297. $html = '<a href="mailto:'.$email.'">'.$email.'</a>';
  298. } else {
  299. $html = '<a href="mailto:'.substr($email, 1).'">'.$text.'</a>';
  300. }
  301. return fcodedisp($html);
  302. }
  303. function fparsetable($width, $bgcolor, $message) {
  304. global $_G;
  305. $html = '';
  306. if(strpos($message, '[/tr]') === FALSE && strpos($message, '[/td]') === FALSE) {
  307. $rows = explode("\n", $message);
  308. $html = '<table cellspacing="0" class="t_table" '.
  309. ($width == '' ? NULL : 'style="width:'.$width.'"').
  310. ($bgcolor ? ' bgcolor="'.$bgcolor.'">' : '>');
  311. foreach($rows as $row) {
  312. $html .= '<tr><td>'.str_replace(array('\|', '|', '\n'), array('&#124;', '</td><td>', "\n"), $row).'</td></tr>';
  313. }
  314. $html .= '</table>';
  315. } else {
  316. if(!preg_match("/^\[tr(?:=([\(\)\s%,#\w]+))?\]\s*\[td([=\d,%]+)?\]/", $message) && !preg_match("/^<tr[^>]*?>\s*<td[^>]*?>/", $message)) {
  317. return str_replace('\\"', '"', preg_replace("/\[tr(?:=([\(\)\s%,#\w]+))?\]|\[td([=\d,%]+)?\]|\[\/td\]|\[\/tr\]/", '', $message));
  318. }
  319. if(substr($width, -1) == '%') {
  320. $width = substr($width, 0, -1) <= 98 ? intval($width).'%' : '98%';
  321. } else {
  322. $width = intval($width);
  323. $width = $width ? ($width <= 560 ? $width.'px' : '98%') : '';
  324. }
  325. $html = '<table cellspacing="0" class="t_table" '.
  326. ($width == '' ? NULL : 'style="width:'.$width.'"').
  327. ($bgcolor ? ' bgcolor="'.$bgcolor.'">' : '>').
  328. str_replace('\\"', '"', preg_replace(array(
  329. "/\[tr(?:=([\(\)\s%,#\w]+))?\]\s*\[td(?:=(\d{1,4}%?))?\]/ie",
  330. "/\[\/td\]\s*\[td(?:=(\d{1,4}%?))?\]/ie",
  331. "/\[tr(?:=([\(\)\s%,#\w]+))?\]\s*\[td(?:=(\d{1,2}),(\d{1,2})(?:,(\d{1,4}%?))?)?\]/ie",
  332. "/\[\/td\]\s*\[td(?:=(\d{1,2}),(\d{1,2})(?:,(\d{1,4}%?))?)?\]/ie",
  333. "/\[\/td\]\s*\[\/tr\]\s*/i"
  334. ), array(
  335. "parsetrtd('\\1', '0', '0', '\\2')",
  336. "parsetrtd('td', '0', '0', '\\1')",
  337. "parsetrtd('\\1', '\\2', '\\3', '\\4')",
  338. "parsetrtd('td', '\\1', '\\2', '\\3')",
  339. '</td></tr>'
  340. ), $message)
  341. ).'</table>';
  342. }
  343. return fcodedisp($html);
  344. }
  345. function fparseaudio($url) {
  346. if(fileext($url) == 'mp3') {
  347. $randomid = 'music_'.random(3);
  348. $html = '<img src="'.IMGDIR.'/music.gif" alt="'.lang('space', 'follow_click_play').'" onclick="javascript:showFlash(\'music\', \''.$url.'\', this, \''.$randomid.'\');" class="tn" style="cursor: pointer;" />';
  349. return fcodedisp($html, 'audio');
  350. } else {
  351. $html = '<a href="'.$url.'" target="_blank">'.$url.'</a>';
  352. return $html;
  353. }
  354. }
  355. function fmakeflv($flv) {
  356. $randomid = 'video_'.random(3);
  357. $flv = is_array($flv) ? $flv : array('flv' => $flv);
  358. if(!empty($flv['imgurl'])) {
  359. $html = '<table class="mtm" title="'.lang('space', 'follow_click_play').'" onclick="javascript:showFlash(\'flash\', \''.$flv['flv'].'\', this, \''.$randomid.'\');"><tr><td class="vdtn hm" style="background: url('.$flv['imgurl'].') no-repeat; border: 1px solid #CDCDCD; cursor: pointer; height: 95px; width: 126px;"><img src="'.IMGDIR.'/vds.png" alt="'.lang('space', 'follow_click_play').'" /> </td></tr></table>';
  360. } else {
  361. $html = '<img src="'.IMGDIR.'/vd.gif" alt="'.lang('space', 'follow_click_play').'" onclick="javascript:showFlash(\'flash\', \''.$flv['flv'].'\', this, \''.$randomid.'\');" class="tn" style="cursor: pointer;" />';
  362. }
  363. return fcodedisp($html, 'video');
  364. }
  365. function fparsemedia($params, $url) {
  366. $params = explode(',', $params);
  367. $url = addslashes($url);
  368. $html = '';
  369. if($flv = parseflv($url, 0, 0)) {
  370. return fmakeflv($flv);
  371. }
  372. if(in_array(count($params), array(3, 4))) {
  373. $type = $params[0];
  374. $url = str_replace(array('<', '>'), '', str_replace('\\"', '\"', $url));
  375. switch($type) {
  376. case 'mp3':
  377. return fparseaudio($url);
  378. break;
  379. case 'flv':
  380. $url = STATICURL.'image/common/flvplayer.swf?&autostart=true&file='.urlencode($url);
  381. return fmakeflv($url);
  382. break;
  383. case 'swf':
  384. return fparseflash($url);
  385. break;
  386. default:
  387. $html = '<a href="'.$url.'" target="_blank">'.$url.'</a>';
  388. break;
  389. }
  390. }
  391. return fcodedisp($html, 'media');
  392. }
  393. function fparseimg($src, $extra = '') {
  394. global $_G;
  395. $rimg_id = random(5);
  396. $html = bbcodeurl($src, '<img id="iimg_'.$rimg_id.'" src="'.$src.'" border="0" alt="" '.$extra.' style="cursor: pointer;" />');
  397. return fcodedisp($html, 'image');
  398. }
  399. function fparsesmiles(&$message) {
  400. global $_G;
  401. static $enablesmiles;
  402. if($enablesmiles === null) {
  403. $enablesmiles = false;
  404. if(!empty($_G['cache']['smilies']) && is_array($_G['cache']['smilies'])) {
  405. foreach($_G['cache']['smilies']['replacearray'] AS $key => $smiley) {
  406. $_G['cache']['smilies']['replacearray'][$key] = '<img src="'.STATICURL.'image/smiley/'.$_G['cache']['smileytypes'][$_G['cache']['smilies']['typearray'][$key]]['directory'].'/'.$smiley.'" smilieid="'.$key.'" border="0" class="s" alt="" />';
  407. }
  408. $enablesmiles = true;
  409. }
  410. }
  411. $enablesmiles && $message = preg_replace($_G['cache']['smilies']['searcharray'], $_G['cache']['smilies']['replacearray'], $message, $_G['setting']['maxsmilies']);
  412. return $message;
  413. }
  414. ?>