<?php
require_once ('header.php');

$msg_id = intval($_GET["msg_id"]);
$sql="select * from {$tablepre}message m inner join {$tablepre}categorymng cm on
      m.msg_id=cm.msg_id inner join {$tablepre}category c on c.category_id=cm.category_id where cm.msg_id='".$msg_id."'";
$row = $db->get_row($sql);
$title=$row["msg_title"];
$keyword=$row["msg_keyword"];
$category_id=$row["category_id"];
$category_parentid=$row["category_parentid"];
$category_name=$row["category_name"];
$msg_demourl=$site_url.'/'.$row['msg_demourl'];

if ($html_flag==1){
   $lnk="view-".$category_id."-".$msg_id.".html";
}else{
   $lnk="view.php?cid=".$category_id."&msg_id=".$msg_id."";
}

$ext = end(explode('.',$row['msg_downurl']));
$ext = strtolower($ext);

//移动端资料用移动模板预览，否则就直接根据设置的地址预览
if ($category_parentid!=6){
   if ($row['msg_demourl']=="" || $row['msg_demourl']=="#" || $ext=='pdf' || $ext=='odt' || $ext=='ods' || $ext=='odp'){
       header("Location:".$lnk);
   }else{
       header("Location:".$row['msg_demourl']);
   }
   exit;
}
?>
<!DOCTYPE HTML>
<html style="padding-bottom: 30px;">
  
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <title><?php echo $title;?></title>
    <meta name="description" content="<?php echo $title;?>" />
    <meta name="keywords" content="手机模板、app模板，移动端模板，jquery,jquery插件,<?php echo $keyword;?>" />
    <link rel="Shortcut icon" href="favicon.ico" />
    <link href="css/demo.css" rel="stylesheet" media="all" />

    <script type="text/javascript">
	  var txt = "<?php echo $msg_demourl;?>";
      window.g1 = txt.substr(0, 3);
      window.g2 = txt.substr(0, 22);
	</script>
    <script src="js/pace.min.js" charset="gbk"></script>
    <script src="js/jquery.min.js"></script>
    <script src="js/jquery.qrcode.min.js"></script>
    <script type="text/javascript">
	  var dqfl = "APP模板";
      var theme_list_open = false;

      $(document).ready(function() {
        function fixHeight() {
          var headerHeight = $("#switcher").height();
          $("#iframe").attr("height", $(window).height() - 54 + "px");
        }
        $(window).resize(function() {
          fixHeight();
        }).resize();

        $('.icon-monitor').addClass('active');

        $(".icon-mobile-3").click(function() {
          $("#by").css("overflow-y", "auto");
          $('#iframe-wrap').removeClass().addClass('mobile-width-3');
          $('.icon-tablet,.icon-mobile-1,.icon-monitor,.icon-mobile-2,.icon-mobile-3').removeClass('active');
          $(this).addClass('active');
          return false;
        });

        $(".icon-mobile-2").click(function() {
          $("#by").css("overflow-y", "auto");
          $('#iframe-wrap').removeClass().addClass('mobile-width-2');
          $('.icon-tablet,.icon-mobile-1,.icon-monitor,.icon-mobile-2,.icon-mobile-3').removeClass('active');
          $(this).addClass('active');
          return false;
        });

        $(".icon-mobile-1").click(function() {
          $("#by").css("overflow-y", "auto");
          $('#iframe-wrap').removeClass().addClass('mobile-width');
          $('.icon-tablet,.icon-mobile,.icon-monitor,.icon-mobile-2,.icon-mobile-3').removeClass('active');
          $(this).addClass('active');
          return false;
        });

        $(".icon-tablet").click(function() {
          $("#by").css("overflow-y", "auto");
          $('#iframe-wrap').removeClass().addClass('tablet-width');
          $('.icon-tablet,.icon-mobile-1,.icon-monitor,.icon-mobile-2,.icon-mobile-3').removeClass('active');
          $(this).addClass('active');
          return false;
        });

        $(".icon-monitor").click(function() {
          $("#by").css("overflow-y", "hidden");
          $('#iframe-wrap').removeClass().addClass('full-width');
          $('.icon-tablet,.icon-mobile-1,.icon-monitor,.icon-mobile-2,.icon-mobile-3').removeClass('active');
          $(this).addClass('active');
          return false;
        });

        if (dqfl.indexOf("APP模板") != -1) {
          $("#by").css("overflow-y", "auto");
          $('#iframe-wrap').removeClass().addClass('mobile-width-2');
          $('.icon-tablet,.icon-mobile-1,.icon-monitor,.icon-mobile-2,.icon-mobile-3').removeClass('active');
          $(this).addClass('active');
          return false;
        }
      });
	</script>
    <script type="text/javascript">function Responsive($a) {
        if ($a == true) $("#Device").css("opacity", "100");
        if ($a == false) $("#Device").css("opacity", "0");
        $('#iframe-wrap').removeClass().addClass('full-width');
        $('.icon-tablet,.icon-mobile-1,.icon-monitor,.icon-mobile-2,.icon-mobile-3').removeClass('active');
        $(this).addClass('active');
        return false;
      };
	</script>
  </head>
  
  <body id="by" style="overflow-y: hidden">
    <div id="switcher">
      <div class="center">
        <ul>
          <li class="logoTop" id="sj2">
            <a href="<?php echo $lnk;?>"><?php echo $title;?></a></li>
          <div id="Device">
            <li class="device-monitor">
              <a href="javascript:">
                <div class="icon-monitor"></div>
              </a>
            </li>
            <li class="device-mobile">
              <a href="javascript:">
                <div class="icon-tablet"></div>
              </a>
            </li>
            <li class="device-mobile">
              <a href="javascript:">
                <div class="icon-mobile-1"></div>
              </a>
            </li>
            <li class="device-mobile-2">
              <a href="javascript:">
                <div class="icon-mobile-2"></div>
              </a>
            </li>
            <li class="device-mobile-3">
              <a href="javascript:">
                <div class="icon-mobile-3"></div>
              </a>
            </li>
          </div>
          <li class="top2" id="sj">
            <a href="#">手机二维码预览</a>
            <div class="vm">
              <div id="output"></div>
              <p style="color: #808080">扫一扫，直接在手机上打开</p></div>
          </li>
          <script>jQuery('#output').qrcode({
              width: 150,
              height: 150,
              //text: window.location.href
			  text: "<?php echo $msg_demourl;?>"
            });</script>
          <li class="remove_frame" style="display:n">
            <a href="<?php echo $msg_demourl;?>" title="移除框架"></a>
          </li>
        </ul>
      </div>
    </div>
    <div id="iframe-wrap">
      <iframe id="iframe" src="<?php echo $msg_demourl;?>" frameborder="0" width="100%"></iframe>
    </div>

      <script type="text/javascript">$(document).ready(function() {
          $(".fdr").click(function() {
            $(".fdad").hide();
          });
        });</script>
  </body>

</html>