').' 1 ? ' colspan="'.$colspan.'"' : '').($rowspan > 1 ? ' rowspan="'.$rowspan.'"' : '').($width && !defined('IN_MOBILE') ? ' width="'.$width.'"' : '').'>';
}
function parseaudio($url, $width = 400) {
$url = addslashes($url);
if(!in_array(strtolower(substr($url, 0, 6)), array('http:/', 'https:', 'ftp://', 'rtsp:/', 'mms://')) && !preg_match('/^static\//', $url) && !preg_match('/^data\//', $url)) {
return dhtmlspecialchars($url);
}
$ext = fileext($url);
switch($ext) {
case 'mp3':
$randomid = 'mp3_'.random(3);
return '';
case 'wma':
case 'mid':
case 'wav':
return '';
case 'ra':
case 'rm':
case 'ram':
$mediaid = 'media_'.random(3);
return '';
}
}
function parsemedia($params, $url) {
$params = explode(',', $params);
$width = intval($params[1]) > 800 ? 800 : intval($params[1]);
$height = intval($params[2]) > 600 ? 600 : intval($params[2]);
$url = addslashes($url);
if(!in_array(strtolower(substr($url, 0, 6)), array('http:/', 'https:', 'ftp://', 'rtsp:/', 'mms://')) && !preg_match('/^static\//', $url) && !preg_match('/^data\//', $url)) {
return dhtmlspecialchars($url);
}
if($flv = parseflv($url, $width, $height)) {
return $flv;
}
if(in_array(count($params), array(3, 4))) {
$type = $params[0];
$url = htmlspecialchars(str_replace(array('<', '>'), '', str_replace('\\"', '\"', $url)));
switch($type) {
case 'mp3':
case 'wma':
case 'ra':
case 'ram':
case 'wav':
case 'mid':
return parseaudio($url, $width);
case 'rm':
case 'rmvb':
case 'rtsp':
$mediaid = 'media_'.random(3);
return ' ';
case 'flv':
$randomid = 'flv_'.random(3);
return '';
case 'swf':
$randomid = 'swf_'.random(3);
return '';
case 'asf':
case 'asx':
case 'wmv':
case 'mms':
case 'avi':
case 'mpg':
case 'mpeg':
return '';
case 'mov':
return '';
default:
return ''.$url.'';
}
}
return;
}
function bbcodeurl($url, $tags) {
if(!preg_match("/<.+?>/s", $url)) {
if(!in_array(strtolower(substr($url, 0, 6)), array('http:/', 'https:', 'ftp://', 'rtsp:/', 'mms://')) && !preg_match('/^static\//', $url) && !preg_match('/^data\//', $url)) {
$url = 'http://'.$url;
}
return str_replace(array('submit', 'member.php?mod=logging'), array('', ''), str_replace('{url}', addslashes($url), $tags));
} else {
return ' '.$url;
}
}
function jammer() {
$randomstr = '';
for($i = 0; $i < mt_rand(5, 15); $i++) {
$randomstr .= chr(mt_rand(32, 59)).' '.chr(mt_rand(63, 126));
}
return mt_rand(0, 1) ? ''.$randomstr.''."\r\n" :
"\r\n".''.$randomstr.'';
}
function highlightword($text, $words, $prepend) {
$text = str_replace('\"', '"', $text);
foreach($words AS $key => $replaceword) {
$text = str_replace($replaceword, ''.$replaceword.'', $text);
}
return "$prepend$text";
}
function parseflv($url, $width = 0, $height = 0) {
$lowerurl = strtolower($url);
$flv = $iframe = $imgurl = '';
if($lowerurl != str_replace(array('player.youku.com/player.php/sid/','tudou.com/v/','player.ku6.com/refer/'), '', $lowerurl)) {
$flv = $url;
} elseif(strpos($lowerurl, 'v.youku.com/v_show/') !== FALSE) {
$ctx = stream_context_create(array('http' => array('timeout' => 10)));
if(preg_match("/^https?:\/\/v.youku.com\/v_show\/id_([^\/]+)(.html|)/i", $url, $matches)) {
$flv = 'https://player.youku.com/player.php/sid/'.$matches[1].'/v.swf';
$iframe = 'https://player.youku.com/embed/'.$matches[1];
if(!$width && !$height) {
$api = 'http://v.youku.com/player/getPlayList/VideoIDS/'.$matches[1];
$str = stripslashes(file_get_contents($api, false, $ctx));
if(!empty($str) && preg_match("/\"logo\":\"(.+?)\"/i", $str, $image)) {
$url = substr($image[1], 0, strrpos($image[1], '/')+1);
$filename = substr($image[1], strrpos($image[1], '/')+2);
$imgurl = $url.'0'.$filename;
}
}
}
} elseif(strpos($lowerurl, 'tudou.com/programs/view/') !== FALSE) {
if(preg_match("/^http:\/\/(www.)?tudou.com\/programs\/view\/([^\/]+)/i", $url, $matches)) {
$flv = 'http://www.tudou.com/v/'.$matches[2];
$iframe = 'http://www.tudou.com/programs/view/html5embed.action?code='.$matches[2];
if(!$width && !$height) {
$str = file_get_contents($url, false, $ctx);
if(!empty($str) && preg_match("/(.+?)<\/span>/i", $str, $image)) {
$imgurl = trim($image[1]);
}
}
}
} elseif(strpos($lowerurl, 'v.ku6.com/show/') !== FALSE) {
if(preg_match("/^http:\/\/v.ku6.com\/show\/([^\/]+).html/i", $url, $matches)) {
$flv = 'http://player.ku6.com/refer/'.$matches[1].'/v.swf';
if(!$width && !$height) {
$api = 'http://vo.ku6.com/fetchVideo4Player/1/'.$matches[1].'.html';
$str = file_get_contents($api, false, $ctx);
if(!empty($str) && preg_match("/\"picpath\":\"(.+?)\"/i", $str, $image)) {
$imgurl = str_replace(array('\u003a', '\u002e'), array(':', '.'), $image[1]);
}
}
}
} elseif(strpos($lowerurl, 'v.ku6.com/special/show_') !== FALSE) {
if(preg_match("/^http:\/\/v.ku6.com\/special\/show_\d+\/([^\/]+).html/i", $url, $matches)) {
$flv = 'http://player.ku6.com/refer/'.$matches[1].'/v.swf';
if(!$width && !$height) {
$api = 'http://vo.ku6.com/fetchVideo4Player/1/'.$matches[1].'.html';
$str = file_get_contents($api, false, $ctx);
if(!empty($str) && preg_match("/\"picpath\":\"(.+?)\"/i", $str, $image)) {
$imgurl = str_replace(array('\u003a', '\u002e'), array(':', '.'), $image[1]);
}
}
}
} elseif(strpos($lowerurl, 'www.youtube.com/watch?') !== FALSE) {
if(preg_match("/^https?:\/\/www.youtube.com\/watch\?v=([^\/&]+)&?/i", $url, $matches)) {
$flv = 'https://www.youtube.com/v/'.$matches[1].'&hl=zh_CN&fs=1';
$iframe = 'https://www.youtube.com/embed/'.$matches[1];
if(!$width && !$height) {
$str = file_get_contents($url, false, $ctx);
if(!empty($str) && preg_match("/'VIDEO_HQ_THUMB':\s'(.+?)'/i", $str, $image)) {
$url = substr($image[1], 0, strrpos($image[1], '/')+1);
$filename = substr($image[1], strrpos($image[1], '/')+3);
$imgurl = $url.$filename;
}
}
}
} elseif(strpos($lowerurl, 'video.sina.com.cn/v/b/') !== FALSE) {
if(preg_match("/^http:\/\/video.sina.com.cn\/v\/b\/(\d+)-(\d+).html/i", $url, $matches)) {
$flv = 'http://vhead.blog.sina.com.cn/player/outer_player.swf?vid='.$matches[1];
if(!$width && !$height) {
$api = 'http://interface.video.sina.com.cn/interface/common/getVideoImage.php?vid='.$matches[1];
$str = file_get_contents($api, false, $ctx);
if(!empty($str)) {
$imgurl = str_replace('imgurl=', '', trim($str));
}
}
}
} elseif(strpos($lowerurl, 'you.video.sina.com.cn/b/') !== FALSE) {
if(preg_match("/^http:\/\/you.video.sina.com.cn\/b\/(\d+)-(\d+).html/i", $url, $matches)) {
$flv = 'http://vhead.blog.sina.com.cn/player/outer_player.swf?vid='.$matches[1];
if(!$width && !$height) {
$api = 'http://interface.video.sina.com.cn/interface/common/getVideoImage.php?vid='.$matches[1];
$str = file_get_contents($api, false, $ctx);
if(!empty($str)) {
$imgurl = str_replace('imgurl=', '', trim($str));
}
}
}
} elseif(strpos($lowerurl, 'http://my.tv.sohu.com/u/') !== FALSE) {
if(preg_match("/^http:\/\/my.tv.sohu.com\/u\/[^\/]+\/(\d+)/i", $url, $matches)) {
$flv = 'http://v.blog.sohu.com/fo/v4/'.$matches[1];
if(!$width && !$height) {
$api = 'http://v.blog.sohu.com/videinfo.jhtml?m=view&id='.$matches[1].'&outType=3';
$str = file_get_contents($api, false, $ctx);
if(!empty($str) && preg_match("/\"cutCoverURL\":\"(.+?)\"/i", $str, $image)) {
$imgurl = str_replace(array('\u003a', '\u002e'), array(':', '.'), $image[1]);
}
}
}
} elseif(strpos($lowerurl, 'http://v.blog.sohu.com/u/') !== FALSE) {
if(preg_match("/^http:\/\/v.blog.sohu.com\/u\/[^\/]+\/(\d+)/i", $url, $matches)) {
$flv = 'http://v.blog.sohu.com/fo/v4/'.$matches[1];
if(!$width && !$height) {
$api = 'http://v.blog.sohu.com/videinfo.jhtml?m=view&id='.$matches[1].'&outType=3';
$str = file_get_contents($api, false, $ctx);
if(!empty($str) && preg_match("/\"cutCoverURL\":\"(.+?)\"/i", $str, $image)) {
$imgurl = str_replace(array('\u003a', '\u002e'), array(':', '.'), $image[1]);
}
}
}
} elseif(strpos($lowerurl, 'http://www.56.com') !== FALSE) {
if(preg_match("/^http:\/\/www.56.com\/\S+\/play_album-aid-(\d+)_vid-(.+?).html/i", $url, $matches)) {
$flv = 'http://player.56.com/v_'.$matches[2].'.swf';
$matches[1] = $matches[2];
} elseif(preg_match("/^http:\/\/www.56.com\/\S+\/([^\/]+).html/i", $url, $matches)) {
$flv = 'http://player.56.com/'.$matches[1].'.swf';
}
if(!$width && !$height && !empty($matches[1])) {
$api = 'http://vxml.56.com/json/'.str_replace('v_', '', $matches[1]).'/?src=out';
$str = file_get_contents($api, false, $ctx);
if(!empty($str) && preg_match("/\"img\":\"(.+?)\"/i", $str, $image)) {
$imgurl = trim($image[1]);
}
}
}
if($flv) {
if(!$width && !$height) {
return array('flv' => $flv, 'imgurl' => $imgurl);
} else {
$width = addslashes($width);
$height = addslashes($height);
$flv = addslashes($flv);
$iframe = addslashes($iframe);
$randomid = 'flv_'.random(3);
$enablemobile = $iframe ? 'mobileplayer() ? "" : ' : '';
return '';
}
} else {
return FALSE;
}
}
function parseimg($width, $height, $src, $lazyload, $pid, $extra = '') {
global $_G;
static $styleoutput = null;
if($_G['setting']['domainwhitelist_affectimg']) {
$tmp = parse_url($src);
if(!empty($tmp['host']) && !iswhitelist($tmp['host'])) {
return $src;
}
}
if(strstr($src, 'file:') || substr($src, 1, 1) == ':') {
return $src;
}
if($width > $_G['setting']['imagemaxwidth']) {
$height = intval($_G['setting']['imagemaxwidth'] * $height / $width);
$width = $_G['setting']['imagemaxwidth'];
if(defined('IN_MOBILE')) {
$extra = '';
} else {
$extra = 'onmouseover="img_onmouseoverfunc(this)" onclick="zoom(this)" style="cursor:pointer"';
}
}
$attrsrc = !IS_ROBOT && $lazyload ? 'file' : 'src';
$rimg_id = random(5);
$GLOBALS['aimgs'][$pid][] = $rimg_id;
$guestviewthumb = !empty($_G['setting']['guestviewthumb']['flag']) && empty($_G['uid']);
$img = '';
if($guestviewthumb) {
if(!isset($styleoutput)) {
$img .= guestviewthumbstyle();
$styleoutput = true;
}
$img .= '';
} else {
if(defined('IN_MOBILE')) {
$img = ' 0 ? ' width="'.$width.'"' : '').($height > 0 ? ' height="'.$height.'"' : '').' src="{url}" border="0" alt="" />';
} else {
$img = ' 0 ? ' width="'.$width.'"' : '').($height > 0 ? ' height="'.$height.'"' : '').' '.$attrsrc.'="{url}" '.($extra ? $extra.' ' : '').'border="0" alt="" />';
}
}
$code = bbcodeurl($src, $img);
if($guestviewthumb) {
$code = str_replace('{loginurl}', 'member.php?mod=logging&action=login', $code);
}
return $code;
}
function parsesmiles(&$message) {
global $_G;
static $enablesmiles;
if($enablesmiles === null) {
$enablesmiles = false;
if(!empty($_G['cache']['smilies']) && is_array($_G['cache']['smilies'])) {
foreach($_G['cache']['smilies']['replacearray'] AS $key => $smiley) {
$_G['cache']['smilies']['replacearray'][$key] = '';
}
$enablesmiles = true;
}
}
$enablesmiles && $message = preg_replace($_G['cache']['smilies']['searcharray'], $_G['cache']['smilies']['replacearray'], $message, $_G['setting']['maxsmilies']);
return $message;
}
function parsepostbg($bgimg, $pid) {
global $_G;
static $postbg;
if($postbg[$pid]) {
return '';
}
loadcache('postimg');
foreach($_G['cache']['postimg']['postbg'] as $postbg) {
if($postbg['url'] != $bgimg) {
continue;
}
$bgimg = dhtmlspecialchars(basename($bgimg), ENT_QUOTES);
$postbg[$pid] = true;
$_G['forum_posthtml']['header'][$pid] .= '';
break;
}
return '';
}
function parsepassword($password, $pid) {
global $_G;
static $postpw;
if($postpw[$pid]) {
return '';
}
$postpw[$pid] = true;
if(empty($_G['cookie']['postpw_'.$pid]) || $_G['cookie']['postpw_'.$pid] != md5($password)) {
$_G['forum_discuzcode']['passwordlock'][$pid] = 1;
}
return '';
}
function guestviewthumbstyle() {
static $styleoutput = null;
$return = '';
if ($styleoutput === null) {
global $_G;
$return = '';
$styleoutput = true;
}
return $return;
}
?> |