<?php
require('conn.php');
require('session.php');
require('functions.php');
//print_r($userdata);
$typeid=trim($_GET['type']);
if(is_numeric($typeid)==false){
	$typeid=0;
	$rows=$mysql->query("select * from `article` order by  -`top`,`id` desc limit 0,10");
}else{
	$rows=$mysql->query("select * from `article` where `type`='{$typeid}' order by  -`top`,`id` desc limit 0,10");	
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" />
<title>转发就赚钱 - <?php echo $config['sitename']?></title>
<meta name="keywords" content="<?php echo $config['sitename']?>" />
<meta name="description" content="<?php echo $config['sitename']?>">
<link href="<?php echo $site?>/static/all.css" type="text/css" rel="stylesheet" media="all">
<script type="text/javascript" src="<?php echo $site?>/static/jquery.js"></script>

</head>

<body class="mhome">

<?php include('header.php')?>

<div class="nav"> 
	<div class="nav_box">
		<div class="nav_d" id="nav">
			<ul class="nav_u" id="scroller" >
			<?php
			$rows_type=$mysql->query("select * from `typedata` order by `id` desc");
			$count_type=count($rows_type);
			foreach($rows_type as $v_type){
				echo "<li><a href=\"?type={$v_type['id']}\">{$v_type['name']}</a></li>";
			}
			?>
			</ul>
		</div>
		<div class="sab arr" ><img src="<?php echo $site?>/static/index/jt.png" /><img src="<?php echo $site?>/static/index/jt1.png" style="display:none;" /></div>
		<ul class="nav_u_down">
		<?php
		$row_type2=$mysql->query("select * from `typedata` order by `id` desc limit 12,{$count_type}");
		foreach($row_type2 as $v_type2){
				echo "<li class=\"hh\"><a href=\"?type={$v_type2['id']}\">{$v_type2['name']}</a></li>";
		}		
		?>
</ul>
	</div>
</div>


<div class="list">
<!--
<div class="gonggao">
	<p><a href="weixin.php">微信文章录入</a></p>
</div>
-->
<?php
//转发多域名支持
$arr_sharesite=explode('#',$config['sharesite']);
$rand=array_rand($arr_sharesite);
$sharesite=$arr_sharesite[$rand];

foreach($rows as $row){
$row_pic=str_replace('[weixin]','http://img01.store.sogou.com/net/a/04/link?appid=100520031&w=135&h=90&url=',$row['pic']);
if($row['pv_max']=='-1'){
	$pv_max='无限投放';
}else{
	$pv_max=$row['pv_max'];
}
if($row['top']==1){
print <<<div
		<div class="list_d">
    	<a class="list_dd bor_b" href="http://{$sharesite}/detail.php?aid={$row['id']}&uid={$userdata['id']}" target="_blank">
		<div class="list_l"><img src="{$row_pic}" width="135" height="90"/></div>
		<div class="list_lt">
			<dl class="list_ld">
				<dt><font color=red><b>[置顶]</b></font>{$row['title']}</dt>
				<dd>发布时间:{$row['day']} <font color=red>  点击分享赚{$v_type['type_pp']}元</dd>
				<!--<dd>阅读量：{$data['pv']}</dd>-->
			</dl>
		</div>
		</a>
		</div>
div;
}else{
print <<<div
		<div class="list_d">
    	<a class="list_dd bor_b" href="http://{$sharesite}/detail.php?aid={$row['id']}&uid={$userdata['id']}" target="_blank">
		<div class="list_l"><img src="{$row_pic}" width="135" height="90"/></div>
		<div class="list_lt">
			<dl class="list_ld">
				<dt>{$row['title']}</dt>
				<dd>发布时间:{$row['day']} <font color=red>  点击分享赚{$v_type['type_pp']}元</dd>
				<!--<dd>阅读量：{$data['pv']}</dd>-->
			</dl>
		</div>
		</a>
		</div>
div;
}
}
$mysql->__destruct();
$mysql->close();
?>
	</div>
<!--
<div style="background:#fff;">
	<ul class="pager"><li class="previous"><a href="#">上一页</a></li> <li class='next'><a target='_self' href=?page=1>下一页</a></li> </ul>
</div>
-->
<br><br><br>


<script type="text/javascript">
$(function() {
			var page_num = 1;
			var ident = true;
			var height_rate = 1.8;
			$(window).scroll(function(){
				//if($(document).height() - $(window).scrollTop() < $(window).height()*height_rate){
				if($(document).scrollTop()>=$(document).height()-$(window).height() - 2500 && ident){
                     page_num = page_num + 1;
					 ident = false;
                     $.get("/getlist.php", { page: page_num ,typeid:<?php echo $typeid?>},function(response){
						ident = true;
						$(".list_d").last().after(response);
						// if(response == ''){
							// ident = false;
							// $("#box-more").html('完');
						// }
                     },'html' );
				}
             });
			 
    function dropNav() {
        var $btn = $(".arr"),
        $Mn = $(".nav_u_down"),
        $true = true;
        $Mn.fadeOut();
        $btn.bind("click",
        function(e) {
            if ($true) {
                $Mn.fadeIn();
                $(".nav_box").addClass("nav_box1");
                $true = false;
            } else {
                $Mn.fadeOut();
                $(".nav_box").removeClass("nav_box1");
                $true = true;
            }
            e.preventDefault();
            return false;
        });
        $Mn.bind("click",
        function(e) {
            $Mn.fadeIn();
            $(".nav_box").addClass("nav_box1");
            $true = false;
            e.stopPropagation();
        });
        /*$(document).bind("click" ,function (){
		$Mn.fadeOut();
		$(".nav_box").removeClass("nav_box1");
		$(".sab>img").toggle();
		$true=true;
	});*/
        $(".sab").click(function() {
            $(".sab>img").toggle();
        });
    };
    $(function() {
        dropNav();
    });
})
</script>
<?php include('footer.php')?>
</body>
</html>

