<?php
$rows=9;
$page<1&&$page=1;
$min=($page-1)*$rows;
$query = $db->query("SELECT A.aid,A.title,A.fid,A.picurl,A.posttime,A.hits,A.comments,B.content FROM {$pre}article A LEFT JOIN {$pre}reply B ON A.aid=B.aid WHERE A.yz=1 AND A.mid=0 AND B.topic=1 ORDER BY A.levelstime DESC,A.aid DESC LIMIT $min,$rows");
$listArtic="";
$listArtic1="";
$listArtic2="";
$listArtic3="";
$j=0;
while($rs = $db->fetch_array($query)){
	$j++;
	$rs[content]=@preg_replace('/<([^<]*)>/is',"",$rs[content]);	//把HTML代码过滤掉
	$rs[content]=get_word($rs[content],150);
	$rs[posttime]=date('m-d',$rs[posttime]);
	$moreinfo="<dl class='moreinfo'><dt>浏览:<span>{$rs[hits]}</span>次 评论:<span>{$rs[comments]}</span>条</dt><dd>$rs[posttime]</dd></dl>\r\n";
	unset($picdb);
	$querys = $db->query("SELECT imgurl FROM `{$pre}article_pic` WHERE id='$rs[aid]'");
	while($rss = $db->fetch_array($querys)){
		if($rss[imgurl]){
			$picdb[]=tempdir($rss[imgurl],"160:100");
		}
	}
	$thispicnum=count($picdb);
	$thiscontent="";
	if($thispicnum>2){
		$thiscontent="<div class='ListMorpic'>\r\n<div class='title'><a href='wapbencandy.php?fid=$rs[fid]&id=$rs[aid]'>$rs[title]</a></div>\r\n<a href='wapbencandy.php?fid=$rs[fid]&id=$rs[aid]'><ul>\r\n";
		$i=0;
		foreach($picdb AS $keys=>$rss){
			$i++;
			if($i<4){
				$thiscontent.="	<li><span><img src='$rss' onError=\"this.src='$webdb[www_url]/images/default/nopic.jpg'\" onmouseover='thisimg_over(\$(this))' onmouseout='thisimg_out(\$(this))'/></span></li>\r\n";
			}
		}
		$thiscontent.="</ul>\r\n</a>\r\n";
		$thiscontent.=$moreinfo."</div>\r\n";
	}elseif($rs[picurl]){
		$rs[picurl]&&$rs[picurl]=tempdir($rs[picurl],"160:100");
		$rs[title]=get_word($rs[title],20);
		$rs[content]=get_word($rs[content],60);
		$thiscontent="<ul class='pic_word'>\r\n";
		$thiscontent.="	<ol><a href='wapbencandy.php?fid=$rs[fid]&id=$rs[aid]'><span><img src='$rs[picurl]' onError=\"this.src='$webdb[www_url]/images/default/nopic.jpg'\" onmouseover='thisimg_over(\$(this))' onmouseout='thisimg_out(\$(this))'/></span></a></ol>\r\n";
		$thiscontent.="	<li><div class='title'><a href='wapbencandy.php?fid=$rs[fid]&id=$rs[aid]'>$rs[title]</a></div>\r\n<p>{$rs[content]}</p>\r\n{$moreinfo}</li>\r\n";
		$thiscontent.="</ul>\r\n";
	}else{
		$thiscontent="<ul class='pic_word'>\r\n";
		$thiscontent.="	<li><div class='title'><a href='wapbencandy.php?fid=$rs[fid]&id=$rs[aid]'>$rs[title]</a></div>\r\n<p>{$rs[content]}</p>\r\n{$moreinfo}</li>\r\n";
		$thiscontent.="</ul>\r\n";
	}
	$listArtic.=$thiscontent;
	if($j<4){
		$listArtic1.=$thiscontent;
	}elseif($j<7){
		$listArtic2.=$thiscontent;
	}else{
		$listArtic3.=$thiscontent;
	}
}
if($job=='ShowMoreArtic'){
	ob_end_clean();
	$listArtic||$listArtic="notArtic";
	echo $listArtic;
	exit;
}
require(ROOT_PATH."inc/waphead.php");
?>
<!--<?php
print <<<EOT
-->
<link rel="stylesheet" type="text/css" href="$webdb[www_url]/images/news/wapindex.css">
<div class="MainContainerBox">
	<div class="MainSlideBox">
		$label[news_wapindex_slide]
	</div>
	<div class="ListConts">
		$listArtic1
		<div class="MiddleAdBox">$label[news_wapindex_ad1]</div>
		$listArtic2
		<div class="MiddleAdBox">$label[news_wapindex_ad2]</div>
		$listArtic3
		<div class="MiddleAdBox">$label[news_wapindex_ad3]</div>
	</div>
	<div class="ShowMoreArtic"><span>内容加载中……</span></div>
</div>
<script type="text/javascript">
<!--
var page=$page;
var check_showMore=1;
$('.ShowMoreArtic').hide();
function ShowMoreArtic(){
	page++;
	check_showMore=0;
	$('.ShowMoreArtic').fadeIn();
	$.get("$webdb[www_url]/wapindex.php?job=ShowMoreArtic&page="+page+"&"+Math.random(),function(d){
		$('.ShowMoreArtic').fadeOut();
		if(d=='notArtic'){
			//layer.alert("没有更多内容了！");
		}else{
			$('.MainContainerBox .ListConts').append(d);
			check_showMore=1;
		}	
	});
}
$(document).ready(function () {
	$(window).scroll(function () {
		var scroll_Height=$(window).scrollTop();
		if($('body').height()-scroll_Height<1300 && check_showMore==1){
			ShowMoreArtic();
		}
	});
	$('.MainContainerBox').hover(function(){
		$('.HeaerBox .SearchBox').fadeOut();
		$('.HeaerBox .members').fadeOut();
	});
});
//-->
</script>
<!--
EOT;
?>
-->
<?php
require(ROOT_PATH."inc/wapfoot.php");
?>