<?php

require_once 'includes/Mcrypt3Des.php';
$shareicon = ''; // 分享图片
$user_agent = $_SERVER['HTTP_USER_AGENT'];
$weixin=strpos($user_agent, 'MicroMessenger');
$h5_page=$_G['ppp']-1;
$postarr = array();
foreach($postlist as $key => $post) {
     if($post['first']) {
        $shareicon = getshareicon($post['message']);
	$shareicon = urlencode(str_replace('&amp;','&',$shareicon));
        $post['message'] = odz_format_message($post['message']);
        $post['message'] = str_replace('!post_hide!', '<h4>本帖隐藏的内容</h4>', $post['message']);
        $message = str_replace('size=', '', $post['message']);
        $postarr = $post;
        unset($postlist[$key]);
        break;
    }
}
$maingroup = $_G['group'];
if(array_key_exists('videolist', $postarr) && $postarr['videolist']) {
    foreach($postarr['videolist'] as $videourl) {

        if(preg_match('/http:\/\/v\.youku\.com\/v_show\/id_(\S+)\.html/i', $videourl, $match)) {
            $postarr['message'] .= '<div class="videoCon"><iframe src="http://player.youku.com/embed/'.$match[1].'" width="240" height="136" frameborder="0"></iframe></div>';
            continue;
        }
        if(preg_match('/static\.video\.qq\.com\/TPout\.swf\?vid=(\S+)\&auto=0/', $videourl, $match2)) {
            $postarr['message'].='<div class="videoCon"><iframe src="http://static.video.qq.com/TPout.swf?vid='.$match2[1].'&auto=0" width="240" height="136" frameborder="0"></iframe></div>';
            continue;
        }
        if(preg_match('/player\.ku6.com\/refer\/(([a-z]|[A-Z]|[0-9])+)\.\.\/v\.swf/', $videourl, $match)) {
            $postarr['message'].= '<video style="display:block;margin: 0px auto; padding: 0px; background-color: black; width: 240px; height: 136px; z-index: 1;" preload="meta" src="http://v.ku6.com/fetchwebm/'.$match[1].'...m3u8" controls="" poster="">';
            continue;
        }
    }
}

function getshareicons($message) {
    $shareicon = '';
    if(preg_match_all('/<img(\s+)class=(\'|")img_detail(\'|").*?data-original="(.+?)".*?src="(.+?)".*?\/?>/', $message, $matches) || preg_match_all('/<img(\s+)class=(\'|")img_detail(\'|").*?src="(.+?)".*?\/?>/', $message, $matches)) {
        foreach($matches[4] as $url) {
            // 排除 gif 格式的图片
            if(strtolower(substr($url, -3)) != 'gif') {
                $shareicon = $url;
                break;
            }
        }
    }
    return $shareicon;
}

?>
<!DOCTYPE html>
<html lang="en">
    <head>
	<meta name="format-detection" content="telephone=yes">
        <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET ?>">
        <meta name="viewport" content="initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
        <title><?php echo $_G['forum_thread']['subject']; ?></title>
        <link rel="stylesheet" type="text/css" href="assets/css/mods.css?hash=<?php echo rand(0,100000);?>">
        <link rel="stylesheet" type="text/css" href="assets/css/style_3.css?hash=<?php echo rand(0,100000);?>">

		<script type="text/javascript" src="assets/js/jquery-1.8.3.min.js"></script>
        <!--<script type="text/javascript" src="assets/js/iscroll.js"></script>-->
        <script type="text/javascript" src="assets/js/commondz.js?hash=12121212"></script>

        <link rel="stylesheet" type="text/css" href="assets/css/activity.css?ver=12121212121">
        <style type="text/css">
        /*视频播放器*/
        .videowrap { margin: 10px 0; }
        .videocontainer { font-size: 12px; color:#666666; margin: 0 auto; width:300px; line-height: 0!important;}
        .video_menu { height:24px; line-height:24px; padding-left: 5px; }
        .video_menu a { color: #666666; text-decoration:none; }
        .video_text { padding-top: 90px; text-align: center; }
        .video_error { color: #ff0000; }
        .downapp {position: fixed;bottom:0px;}
        .downapp span {width: 50px;height: 50px;display: block;position: absolute;right:0px;top:0px;}
        .dh-option-table{table-layout: auto;width: 100%;border-collapse:collapse;margin:10px 2px;}
        .dh-option-table thead{background-color: #F0F0F0;font-weight: bold;line-height: 28px;font-size: 14px}
        .dh-option-table td{border:1px solid #eee;border-collapse:collapse;table-layout:fixed;padding: 5px}
        .dh-option-table .option-label{width: 80px}
        .bbs-feed-list .desc{ font-size: 16px; line-height: 1.6; padding-left: 20px;}
         #report-btn{display:inline-block;padding:1px;color:#fff;font-size:16px;padding:0px 6px;color: #4a4a4a;margin-top: 20px;}
        .html-data img { height: auto; }
        .bbs-feed-count a.replypost { color: #ff6600; }
        .videoCon {text-align: center;}
        .quote{background-color: #F8F8F8;padding: 6px;font-size: 14px;color: #7D7D7d;border-radius: 4px;margin-right: 11px;margin-bottom: 12px;margin-left: 42px;}
        .quote a{color: #7D7D7D!important;}
	.quote blockquote { margin: 0px 5px 0px 5px; font-size: 14px;}
        .itm_height{width: 100%;height:230px;}
        .report{z-index:1000;position:fixed; bottom:0px;left:0px;}
        .hd-s img {max-width:100%;height:auto;}
        /*表格信息*/
	.photo_size{width:300px;}
        .html-data table{width: 100%;font-size: 14px;}
        .html-data table tr td{padding: 6px 5px 6px 5px !important;}
        .html-data table caption{background: #FAFAFA;padding: 6px 5px 6px 5px !important;font-weight: bold;text-align: left;border:1px solid #EEEEEE;}
        .html-data table tr td{border-bottom:1px solid #C2D5E3;padding: 6px 5px 6px 5px !important;}
        .html-data table tr td.textname{border-bottom:1px solid #EEEEEE;border-left:1px solid #EEEEEE;border-right:1px solid #EEEEEE;color:#B0B0B0;width: 26%}
        .html-data table tr td.textvalue{border-bottom:1px solid #EEEEEE;border-right:1px solid #EEEEEE;color:#6F6F6F;}
        .join_show{width: 90%;margin: 0px auto;position: absolute;background-color: #fff;border-radius: 5px;z-index: 2000;left: 0px;top: 0px;display: none;}
        .join_show h4{padding: 8px 0px 8px 15px;}
        .join_pop{ border-top: solid 1px #E4E4E4;}
        .join_pop .ipt{background-color: #fff; margin-bottom: 15px;}
        .join_pop .ipt > div{margin-left: 10px; border-bottom: solid 1px #EEEEEE;padding: 15px 0px 15px 5px;}
        .join_pop .ipt p{margin-left: 10px; border-bottom: solid 1px #EEEEEE;padding: 15px 0px 15px 5px;}
        .join_pop .ipt .sn{color: #959595; width: 65px;display: block;float: left;}
        /*输入框*/
        .join_pop .ipt input{ margin-left: 10px;font-size: 14px; width:60%;border:1px solid #979797;}
        /*提交*/
        .join_pop  .sub{width: 30%;border-radius: 5px;background-color: #42A8EC; color: #fff;font-size: 20px;text-align: center;padding: 10px 0px 10px 0px;display: block;-webkit-appearance: none; float: left;}
        .jremarks{border: 1px solid #979797;}
        .jabolish{background-color: #42A8EC;color: #fff;font-size: 15px;text-align: center;padding: 5px 17px 5px 17px;border-radius: 5px;display: block;float: left;margin-right: 15px;}
        .jit{margin-left: 10px;}
        .join_b{overflow: hidden;float: right;margin-bottom: 15px;}
        .disabled{background: #B9B4B4;border-color:#908E8E;color: #7E7E7E}
        </style>
        <script type="text/javascript">
            var smiley_search = <?php echo make_smilie_json();?>;
            <?php if(!empty($reward_view)){?>
                var reward_socre = {"socre_name":"<?php  echo $reward_view['socre_name']; ?>","credits":"<?php echo $reward_view['credits']; ?>","score_list":<?php echo json_encode($reward_view['score_list']); ?>}
            <?php }else{?>
               var reward_socre = {"socre_name":"","credits":"","score_list":''}
           <?php }?>
        </script>
</head>
<body>
    <div class="shade"></div>
    <div class="subshade"></div>
        <div class="mobile-wrap">
            <div class="bbs-cv-info">
                <?php if($postarr['anonymous'] == 1 ||$_G['forum_thread']['authorid'] == ""):?>
                    <a href="javascript:void(0);"   class="user-hd">
                        <?php echo $default_avatar;?>
                    </a>
                    <?php else:?>
                    <a href="javascript:void(0);"   onclick="lbsPerson(<?php echo $_G['forum_thread']['authorid']; ?>)"   class="user-hd">
                        <?php echo $postarr['avatar'];?>
                    </a>
                <?php endif;?>
                <div class="user-txt">
                        <?php if($postarr['anonymous'] == 1 ||$_G['forum_thread']['authorid'] == ""):?>
                            <a href="javascript:void(0);"   class="user-txt-name namecolor"><?php echo odz_lang('anonymous'); ?></a>
                        <?php else:?>
                            <a href="javascript:void(0);"   onclick="lbsPerson(<?php echo $_G['forum_thread']['authorid']; ?>)"  class="user-txt-name namecolor"><?php echo $_G['forum_thread']['author']; ?></a>
                        <?php endif;?>
                        <p><?php echo $postarr['dateline']; ?>
                        <span class="discuss_span "><?php if($postarr['devicetype']){ ?><?php echo '来自'; }?><span class="discuss_span"><?php if($postarr['devicetype']){ ?><?php echo $postarr['devicetype'].'客户端'; }?></span></span></p>
                </div>
                <div class="attention_view"></div>
                    <?php if($follow_friend<1):?>
                        <?php if($_G['forum_thread']['authorid']!=$_G['uid']):   ?>
                            <p class="attention attention_n" onclick="follow_friend1(<?php echo $_G['forum_thread']['authorid']; ?>,'<?php echo $_G['forum_thread']['author'];?>','add_friend')">+ 关注</p>
                        <?php endif;?>
                    <?php else:?>
                    <p class="attention attention_y" onclick="follow_friend1(<?php echo $_G['forum_thread']['authorid']; ?>,'<?php echo $_G['forum_thread']['author'];?>','delete_friend')">已关注</p>
                    <?php endif;?>
        </div>
        <div class="bbs-cv-main">
            <div class="bbs-cv-hd">
                <p class="head_title"><?php echo $_G['forum_thread']['subject']; ?></p>
                <div class="btm">
                    <span class="head_from">来自</span>
                    <span class="head_type" onclick="toSection(<?php echo $_G['fid']?>);" ><?php echo $_G['forum']['name']?></span>
                </div>               
            </div>
             <div class="html-data hd-s ">
                 <div class="bbs-cv-nr">
                    <?php echo $postarr['message'];?>
                </div>
            </div> 
        </div>
           
        <div class="backtop">
            <img src="assets/images/backtop.png" alt="返回顶部" />
        </div>
       
    </div>

	<script type="text/javascript" src='assets/js/jquery.lazyload.min.js?_=201509291647dd33'></script>
	<script type="text/javascript">
		$(function() {
			$(".img_detail").lazyload();
		});
	</script>
        <script type="text/javascript">
                var doc= $(".img_detail").parent().parent('.discuss_box');
                doc.find(".img_detail").css('width','100%');
                 doc.find(".img_detail").removeAttr("width");
                  doc.find(".img_detail").removeAttr("height");
                doc.find(".img_detail").parent().css({"padding-right":"11px","padding-left":"42px"});
        </script>

<script type="text/javascript">
       var  uid = '<?php echo  $_G['uid']; ?>';
       var  get_uid = '<?php echo  $_G['uid']; ?>';
       var  siteurl = '<?php echo $_G['siteurl'] ?>';
       var  fuid = '<?php echo $_G['forum_thread']['authorid']; ?>';
       var  MocuzMobile = {
                Android: function() {
                    return /Android/i.test(navigator.userAgent);
                },
                BlackBerry: function() {
                    return /BlackBerry/i.test(navigator.userAgent);
                },
                iOS: function() {
                    return /iPhone|iPad|iPod/i.test(navigator.userAgent);
                },
                Windows: function() {
                    return /IEMobile/i.test(navigator.userAgent);
                },
                any: function() {
                    return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Windows());
                }
        };
    
      //跳转个人中心
    function lbsPerson(user_id){
        var user_id = '{"user_id":' + user_id + '}';
        if(MocuzMobile.Android()) {
            window.myjs.lbsPerson(user_id);//android
            return;
        }
        if(MocuzMobile.iOS()) {
            var cmd = "lbsPerson";
            window.location.href="objc://"+cmd+":/"+user_id;
            return;
        }
    }
   //关注好友3.0
   function follow_friend1(friend_id,fusername,type){
       if(!uid){
            if(!get_uid){
                if(MocuzMobile.Android()) {
                    window.myjs.get_uid();//android
		    return;
                }
                if(MocuzMobile.iOS()) {
                     window.location.href="objc://get_uid";
		     return;
                }
            }
            uid = get_uid;
        }
       var delete_friend="delete_friend";
        $.ajax({
             type: "POST",
             url: siteurl+"index.php?mod=follow_friend&friend_id="+friend_id+"&fusername="+fusername+"&type="+type+"&uid="+uid,
             dataType: "html",
             success: function(data){
                 if(data==1){
                    var delete_friend="delete_friend";
                    var follow_view = "<p class='attention attention_y' onclick=follow_friend1(" +fuid+ ",'" +fusername+ "','"+delete_friend+"')>已关注</p>" ;
                    $(".attention").remove();
                    $(".attention_view").append(follow_view);return;
                 }else if(data==2){
                    var add_friend="add_friend";
                    var follow_view = "<p class='attention attention_n' onclick=follow_friend1(" +fuid+ ",'" +fusername+ "','"+add_friend+"')>+ 关注</p>" 
                    $(".attention").remove();
                    $(".attention_view").append(follow_view);return;
                 }
                 alert(data);
             }
        });
    }
    
    function setdownappsize(){
        if (window.innerWidth)
            winWidth = window.innerWidth;
        else if ((document.body) && (document.body.clientWidth))
            winWidth = document.body.clientWidth;
        $('.downappimg').css('width',winWidth);
    }
    setdownappsize();


        /**
       * 夜间模式切换
       * @param isNight 是否启用夜间模式
       */
       function switchNightMode(isNight) {
           var colorVal = '';
           if (isNight == 1) {
               $('.bbs-cv-hd .btm').css('border-bottom','1px solid #454545');
               $('.bbs-feed-list li').css('border-top','1px solid #454545');
               $('.quote').css('background-color','#A5A7AA');
               colorVal = '#2C2D32';
           } else {
               colorVal = '';
           }
           document.body.style.backgroundColor = colorVal;
       }

  
         function scrollParameter(){
             $(window).bind('scroll', AdapterObj.scrollEvent);
         };
        //回复跳转
        //返回顶部
        $('.backtop').click(function(event) {
            $('.backtop img').attr('src','assets/images/backtop2.png');
            $("html,body").animate({scrollTop:"0px"},300,function(){
                $('.backtop img').attr('src','assets/images/backtop.png');
            });
        });
    // 快捷回复委托方法
        //图片点击交互
    function img_click(src){
        var i,jsonstr;
        var array=[];
        var thisbig_url;
        var imglist=$(".img_detail");
        for(var i=0;i<imglist.length;i++){
            if($(imglist[i]).attr("big_url")==""||typeof($(imglist[i]).attr("big_url"))=="undefined"){
                array.push($(imglist[i]).attr('data-original'));
            }else{
                array.push($(imglist[i]).attr('big_url'));
            }
        }

        var str = '{"thisimg":"'+src+'","imglist":["' + array.join('","') + '"]}'; 

        if (MocuzMobile.Android()) {
            window.myjs.openImage(src,str);//android
            return;
        }

       if (MocuzMobile.iOS()) {
            var cmd='openImage';
            window.location.href="objc://"+cmd+":/"+str+""
       }

       return false;
    }

    function toSection(fid){

        if(MocuzMobile.Android()){
                window.myjs.toSection(fid);//android
                return;
        }
        if(MocuzMobile.iOS()){
                window.location.href="objc://toSection:/"+fid;
                return;
        }
    }

    $(document).ajaxError(function(){
        alert("请求失败，请检查网络或稍后重试");
    });
    // 数据交互
    function jiaohu(cmd,str) {

        var sharelink="<?php echo urlencode($sharelink); ?>";  
        var share_text="<?php echo odz_format_sharetext($sharetext)?odz_format_sharetext($sharetext):odz_lang('biu_sharetext'); ?>";
        //var subject="<?php echo $_G['forum_thread']['subject']; ?>";
		var shareIcon="<?php echo $shareicon; ?>";
        var eventlink = "<?php echo $link?>";
		var subject   = "<?php echo $name?>";
		
        var cmd ='jiaohu';
        var str = '{"eventlink":"'+eventlink+'", "shareSNS":{"sharelink":"'+sharelink+'","shareIcon":"'+shareIcon+'", "sharetext":"'+share_text+'", "sharesubject":"'+subject+'"}}';
		//alert(str);
		//console.log(str);
        if(MocuzMobile.Android()) {
            window.shareInfo.jiaohu(str);//android
            return;
        }
        if (MocuzMobile.iOS()) {
            window.location.href="objc://"+cmd+":/"+str;
        }
    }
    window.onload = jiaohu();

</script>
</body>
</html>