<?php 
	include 'head.php';
	$classInfo = $DB->getRow("SELECT * FROM `pre_class` WHERE `path`='".$class."'");
?>
<div class="container">
    <br>
    <div class="col-lg-8">
		<div class="bg-image"  style="background-image: url('<?php echo siteHttp().'/'.rootPath('/');?>public/assets/index/images/wzbg.jpg');border-radius:20px 20px 0 0;box-shadow:0px 5px 10px 0 rgba(0, 0, 0, 0.25);">
		<div class="content content-full bg-flat-op" style="border-radius:20px 20px 0 0">
		<div class="row">
		<div class="col-xs-12">
		<h1 class="page-heading text-white text-center js-appear-enabled animated fadeInDown" data-toggle="appear" data-class="animated fadeInDown">
		 <?php 
     	if($class){
	         echo '<font size="4">当前文章分类：'.$classInfo['title'].'</font>';
	        }else{
	         echo '<font size="4">文章列表</font>';
        }
        ?>
		</h1>
		</div>
		</div>
		</div>
		</div>
		<div class="content content-mini bg-white" style="border-radius:0 0 20px 20px;box-shadow:0px 5px 10px 0 rgba(0, 0, 0, 0.25);">
		<ol class="breadcrumb push">
		<li><a class="link-effect" href="./">首页</a></li>
		<li>文章列表</li>
		</ol>
		</div>
		<br>
	<div class="block block-rounded" style="border-radius:20px;box-shadow:0px 5px 10px 0 rgba(0, 0, 0, 0.25);">
<div class="block-content">
        <div class="block-title">
        </div>
				<?php 
					if($class){
						$viewCount=$DB->getColumn("SELECT count(*) FROM `pre_view` WHERE `class`='".$classInfo['id']."'");
					}else{
						$viewCount=$DB->getColumn("SELECT count(*) FROM `pre_view`");
					}
					$pageSize=10;
					$pages=ceil($viewCount/$pageSize);
    				$page = isset($_GET['page'])?intval($_GET['page']):1;
					$offset=$pageSize*($page - 1);
					if($class){
						$viewInfo = $DB->query("SELECT id,title,title2,class,keywords,addtime FROM `pre_view` WHERE `class`='".$classInfo['id']."' ORDER BY id DESC LIMIT $offset,$pageSize");
					}else{
						$viewInfo = $DB->query("SELECT id,title,title2,class,keywords,addtime FROM `pre_view` ORDER BY id DESC LIMIT $offset,$pageSize");
					}
					$viewRow=array();
					while($res = $viewInfo->fetch()){
						$viewRow[]=$res;
					}
					echo '<div class="table-responsive">
			<table class="table table-hover table-bordered">
				<tbody id="msglist">';
					foreach($viewRow as $row){
						$classInfo = $DB->getRow("SELECT * FROM `pre_class` WHERE `id`='".$row['class']."'");
						if(conf('rewrite')==1){
	    					$isHref = './'.$classInfo['path'].'/'.$row['id'].'.html';
	    				}else{
	    					$isHref = './index.php?class='.$classInfo['path'].'&view='.$row['id'];
	    				}
						$keywords = $row['keywords'];
							echo '<tr>
						<td><a href="'.$isHref.'"><img style="border-radius:10px;" width="66" src="'.siteHttp().'/'.rootPath('/').'public/assets/index/images/img1.png"></a></td>
						<td>
						<a href="'.$isHref.'">
						<b class="pull-left">'.$row['title'].' - '.$row['title2'].'</b>
						<small class="pull-right"><span class="text-muted"><li class="fa fa fa-clock-o fa-fw"></li>'.$row['addtime'].'</span></small>
						</div>
						<br>
						<p style="margin-bottom:0;color: #6b6b6b;white-space: normal;word-break: break-all;word-wrap: break-word;overflow: hidden;text-overflow:ellipsis;white-space: nowrap;width: 80%;">'.$keywords.'</p>
						</a>
						</td>
						</tr>';
					}
				if(!$viewRow){
					echo '<tr><td class="text-center"><font color="grey">文章列表空空如也</font></td></tr>';
				}
				?>
				</tbody>
        </table>
		<?php 
			if($viewCount>$pageSize){
				if($page>1){
					if($class){
                		$isHref = './index.php?class='.$class.'&page='.($page-1).'';
					}else{
						$isHref = './index.php?page='.($page-1);
					}
					echo '<a href="'.$isHref.'" style="border-radius:10px;" class="btn btn-info"><li class="fa fa-arrow-circle-o-left fa-fw"></li>上一页</a>';
				}
				if($page<$pages){
					if($class){
                		$isHref = './index.php?class='.$class.'&page='.($page+1).'';
					}else{
						$isHref = './index.php?page='.($page+1);
					}
					echo '<a href="'.$isHref.'" style="border-radius:10px;" class="btn btn-info pull-right">下一页 <li class="fa fa-arrow-circle-o-right fa-fw"></li></a>';
				}
			}
		?>
			</div>
			<hr>
			<div class="form-group">
			</div>
        </div>
      </div>
    </div>
<div class="col-lg-4">
      <div class="block block-rounded" style="border-radius:20px;box-shadow:0px 5px 10px 0 rgba(0, 0, 0, 0.25);">
        	<div class="block-header bg-amethyst text-center" style="border-radius: 20px 20px 0 0;">
        		<h3 class="block-title" style="color:#ffffff;">本站简介</h3>
        		</div>
        		<div class="block-content block-content-full text-center">
        		<div class="push">
        		<img class="img-avatar" src="http://q1.qlogo.cn/g?b=qq&nk=<?php echo conf('qq');?>&s=640" alt="">
        		</div>
        		<div class="font-w600 push-5"><?php echo conf('title')?></div>
        		<div class="text-muted"><?php echo $_SERVER['HTTP_HOST']?></div>
        		<hr>
        		<?php echo conf('description');?>
        	</div>
        </div>
        
        <div class="block block-rounded" style="border-radius:20px;box-shadow:0px 5px 10px 0 rgba(0, 0, 0, 0.25);">
        	<div class="block-header bg-flat text-center" style="border-radius: 20px 20px 0 0;">
        		<h3 class="block-title" style="color:#ffffff;">文章分类</h3>
        		</div>
        		<div class="block-content block-content-full text-center">
        		    <?php  
        		    	$classInfo = $DB->query("SELECT * FROM `pre_class`");
        		    	$i=0;
        		    	while($res = $classInfo->fetch()){
        		    		if($i%2==0){
        		    			$color="info";
        		    		}else{
        		    			$color="success";
        		    		}
        		    		echo '<a style="border-radius:10px;" href="./index.php?class='.$res['path'].'" class="btn btn-sm btn-'.$color.'">'.$res['title'].'</a> ';
        		    		$i++;
        		    	}
        		    ?>
        	</div>
        </div>
        <div class="block block-rounded" style="border-radius:20px;box-shadow:0px 5px 10px 0 rgba(0, 0, 0, 0.25);">
        	<div class="block-header bg-modern text-center" style="border-radius: 20px 20px 0 0;">
        		<h3 class="block-title" style="color:#ffffff;">热门文章</h3>
        		</div>
        	<div class="block-content block-content-full">
        		<?php 
        			$viewInfo = $DB->query("SELECT * FROM `pre_view` ORDER BY `pvAll` DESC limit 5");
        			while($res = $viewInfo->fetch()){
        				$classInfo = $DB->getRow("SELECT * FROM `pre_class` WHERE `id`='".$res['class']."'");
        				if(conf('rewrite')==1){
        					$isHref = './'.$classInfo['path'].'/'.$res['id'].'.html';
        				}else{
        					$isHref = './index.php?class='.$classInfo['path'].'&view='.$res['id'];
        				}
        		?>
        	   <tr class="animation-fadeInQuick"><td>
                    <a href="<?php echo $isHref; ?>"><div>
                    <b class="pull-left" style="overflow: hidden;text-overflow:ellipsis;white-space: nowrap;width: 100%;"><?php echo $res['title'].' - '.$res['title2'] ?></b>
                    <small class="pull-right"><span class="text-muted"><li class="fa fa fa-clock-o fa-fw"></li><?php echo $res['addtime'] ?></span></small>
                    </div>
                    <br>
                    <p style="margin-bottom: 0;color: #6b6b6b;white-space: normal;word-break: break-all;word-wrap: break-word;">&nbsp;</p>
                    </a>
                </td>
            </tr>
      	  <?php } ?>
				</div>
        </div>
        <div class="block block-rounded" style="border-radius:20px;box-shadow:0px 5px 10px 0 rgba(0, 0, 0, 0.25);">
        	<div class="block-header bg-info text-center" style="border-radius: 20px 20px 0 0;">
        		<h3 class="block-title" style="color:#ffffff;">随机文章</h3>
        		</div>
        	<div class="block-content block-content-full">
        	    <?php 
        			$viewInfo = $DB->query("SELECT * FROM `pre_view` ORDER BY RAND() LIMIT 5");
        			while($res = $viewInfo->fetch()){
        				$classInfo = $DB->getRow("SELECT * FROM `pre_class` WHERE `id`='".$res['class']."'");
        				if(conf('rewrite')==1){
        					$isHref = './'.$classInfo['path'].'/'.$res['id'].'.html';
        				}else{
        					$isHref = './index.php?class='.$classInfo['path'].'&view='.$res['id'];
        				}
        		?>
        	   <tr class="animation-fadeInQuick"><td>
                    <a href="<?php echo $isHref; ?>"><div>
                    <b class="pull-left" style="overflow: hidden;text-overflow:ellipsis;white-space: nowrap;width: 100%;"><?php echo $res['title'].' - '.$res['title2'] ?></b>
                    <small class="pull-right"><span class="text-muted"><li class="fa fa fa-clock-o fa-fw"></li><?php echo $res['addtime'] ?></span></small>
                    </div>
                    <br>
                    <p style="margin-bottom: 0;color: #6b6b6b;white-space: normal;word-break: break-all;word-wrap: break-word;">&nbsp;</p>
                    </a>
                </td>
            </tr>
      	  <?php } ?>
				</div>
        </div>
</div>
  </div>
  </div>
  </div>
 
</div>