<?php
//分类导航菜单
foreach ($catearr as $k=>$vl){
	$sql="select * from {$tablepre}category where category_status=1 and category_parentid=".$vl['category_id']." order by category_order asc";
    $cate2arr=$db->get_all($sql);
    $catearr[$k]['category_two']=$cate2arr; //二级分类

    foreach ($cate2arr as $kv){
       $mytag = explode(",",$kv['category_desc']);
	   $catearr[$k]['category_tag'] = array_slice($mytag,0,10);//$mytag; //分类标签
    }

    #GROUP BY cm.msg_id,cm.category_id
	$msql="select m.*,cm.category_id,cm.hits_num,cm.down_num,cm.fav_num,pic.thumbnail_path from {$tablepre}message m 
	       inner join {$tablepre}categorymng cm on cm.msg_id=m.msg_id
	       inner join {$tablepre}attachmng pic ON pic.msg_id = m.msg_id
	       where pic.index_box=1 and cm.category_id in(select category_id from {$tablepre}category 
	       where category_parentid=".$vl['category_id'].") and m.msg_status=1 and m.msg_starttime<='".$getnow."' and m.msg_endtime>='".$getnow."'  
		   GROUP BY cm.msg_id order by m.msg_order DESC,m.msg_createtime DESC,pic.attach_id asc limit ".$index_cate_num."";

    $msgarr = $db->get_all($msql);
	if (!empty($msgarr)){
		$catearr[$k]['message']=$msgarr;
	}
}

$sql     = "select * from {$tablepre}treemenu where category_status=1 and category_parentid=19 order by category_order asc limit 0,5";
$pro_nav = $db->get_all($sql);
foreach ($pro_nav as $k=>$v){
	$field = end(explode('=', $v['category_url']));
	if ($a==$field){
	    $class_abc="prosel";
	}else{
	    $class_abc="pro";
	}
	$L_arr[$k]['category_name']=$v['category_name'];
	$L_arr[$k]['a']=$field;
	$L_arr[$k]['class']=$class_abc;
}

if ($html_flag==1){
    $indexlink="index";
	$registlink="regist";
	$toplink="downtop";
}else{
	$indexlink="index.php";
	$registlink="regist.php";
	$toplink="downtop.php";
}

?>
    <!--<div class="header clear container"></div>-->
	<!--search-->
<div align="center" class="head-div">
    <div class="sc-search">
	  <div style="margin-top:18px;display:inline;float:left;"><a href="<?php echo $indexlink;?>"><img src="../images/logo.png" height="70"></a></div>
      <div class="search" style="display:inline;float:left;">
        <div class="search-bd">
          <form action="search.php" id="search-form" class="form" method="GET" onclick="chk();">
            <div class="form-group">
              <input type="text" id="kw" name="kw" value="" autocomplete="off" placeholder="<?php echo $kw;?>">
              <button type="submit" id="search" name="" class="btn btn-primary">
                <i class="ftsucai icon-16"></i>查找
			  </button>
			  <!--
			  <input name="cateid" type="hidden" id="cateid" value="<?php echo $cateid;?>">
			  <input name="cid" type="hidden" id="cid" value="<?php echo $cid;?>">
			  -->
            </div>
          </form>
        </div>
      </div>
	  <div>
	  <ul class="button_flex clearfix">
	  <?php
	  if ($_SESSION["uid"]!=''){
	  ?>
	    <a class="text" href="userpost.php?a=2"><li><span>管理</span></li></a>
        <a class="text" href="logout.php"><li><span>退出</span></li></a>
		<!--<li><a class="text" href="publish.php?a=1">发布</a></li>-->
		<li>
          <div class="qrcode">
              <img src="images/ftsucai.png" width='118' height='118'>
          </div>
          <span>手机版</span>
        </li>
      <?php 
	  }else{
	  ?>
        <a class="text" href="<?php echo $registlink;?>"><li><span>注册</span></li></a>
        <a class="text login-layer" href="javascript:void(0);" id="userpost.php?a=2"><li><span>登录</span></li></a>
		<!--<li><a class="text login-layer" href="javascript:void(0);">发布</a></li>-->
		<li>
          <div class="qrcode">
              <img src="images/ftsucai.png" width='118' height='118'>
          </div>
          <span>手机版</span>
        </li>
	  <?php
	  }
	  ?>
	  </ul>
	  </div>
    </div>
</div>

<!--search-->
<table width="100%" border="0" cellspacing="0">
  <tr>
    <td>
	<div class="nav">
	  <div class="container clear">
		<div class="nav-bar right clear">
		  <ul>
			<li class="m"><a class="navtag" href="<?php echo $indexlink;?>">素材首页</a></li>
			<?php
			foreach ($catearr as $v){
				 if ($html_flag==1){
					$navlink="list-".$v['category_id'].".html";
				 }else{
					$navlink="list.php?cateid=".$v['category_id']."";
				 }
				 if($v['category_url']!=""){
					echo "<li class=\"m\"><a href=".$v['category_url']." class=\"navtag\">".$v['category_name']."</a></li>";
				 }else{
					echo "<li class=\"m\"><a href=".$navlink." class=\"navtag\">".$v['category_name']."</a>";
				 ?>
					<div class="nav-menu">
						  <div class="menu-box">
							<div class="pd-list">
							  <span class="main-sort">所有分类</span>
							  <div class="expand-sort clear">
                              <?php
							    foreach ($v['category_two'] as $tv){
								  if ($html_flag==1){
								     $lnk="list-c-".$tv['category_id'].".html";
								  }else{
								     $lnk="list.php?cid=".$tv['category_id'];
								  }
							  ?>
								<a href="<?php echo $lnk;?>"><?php echo $tv['category_name'];?></a>
							  <?php
							    }
							  ?>
							  </div>
							</div>
							
							<div class="pd-list" style="padding: 0 0 18px 16px;">
							  <span class="main-sort">热门标签</span>
							  <div class="expand-sort clear">
							  <?php
							  $hot_tag = explode(",",$v['category_desc']);
							  $hot_tag = array_slice($hot_tag,0,15);
							  foreach ($hot_tag as $v_tag){
							     if ($html_flag==1){
								     $taglnk="search-".$v['category_id']."-".$v_tag."-0.html";
								 }else{
								     $taglnk="search.php?category_id=".$v['category_id']."&kw=".$v_tag;
								 }
							  ?>
								<a href="<?php echo $taglnk;?>"><?php echo $v_tag;?></a>
							  <?php
							  }
							  ?>
							  </div>
							</div>
						 </div>
			        </div>
			<?php
				 }
			}	 
			?>
			<li class="m"><a class="navtag" href="<?php echo $toplink;?>">下载排行</a></li>
		  </ul>
		</div>
	  </div>
	</div>
	</td>
  </tr>
</table>

<!--登录开始-->
<div class="loginmask"></div>
<div class="layerbox" id="loginbox">
  <span class="switch-close">×</span>
  <div id="ftsc">
	<div id="error" class="login-publicTitle"></div>
	<div class="login-publicTitle2">
	  <div class="linebg"></div>
	  <p>登录<?php echo $site_name;?></p>
	</div>
	<div class="local-loginWay">
	  <form action="" method="post">
		<div class="form-group">
		  <input type="text" id="username" name="username" onBlur="msg_email(this.value);" style="background:url(images/email.png) no-repeat;background-position: 10px;padding-left:25px;">
		  <div id="name_msg" class="help-block"></div>
		</div>
		<div class="form-group">
		  <input type="password" id="password" name="password" onBlur="msg_pwd(this.value);" style="background:url(images/pwd.png) no-repeat;background-position: 10px;padding-left:25px;">
		  <div id="pwd_msg" class="help-block"></div>
		</div>
		<div class="form-group">
		  <div class="tncode" style="margin: 12px auto 0;text-align:center;height:42px;border-radius: 50px;width: 295px;"></div>
		</div>
		<input id="login" type="button" class="submit subtn" value="登录">
		<input type="hidden" name="reurl" id="reurl" />
		<div class="help-block" style="text-align:center;">忘记密码？<a class="getpwd" href='javascript:void(0);'>点击取回</a></div>
	  </form>
	</div>
  </div>
</div>
<!--登录结束-->