<?php
require_once('../common.php');
require_once('head.php');
if ($userrow['xm']=="" or $userrow['xb']=="" or $userrow['xh']=="" or $userrow['ch']=="" or $userrow['sr']=="" or $userrow['zz']=="" or $userrow['phone']=="" or $userrow['mail']=="" or $userrow['xz']=="" or $userrow['ah']=="" or $userrow['tc']=="") {
  exit("<script language='javascript'>alert('请先完善资料！');window.location.href='xgzl.php';</script>");
}
$uid=is_numeric($_GET['uid'])?$_GET['uid']:'0';
$p=is_numeric($_GET['p'])?$_GET['p']:'1';
$pp=$p+8;
$pagesize=8;
$start=($p-1)*$pagesize;


if($pp>$pages) $pp=$pages;
if($p==1){
	$prev=1;
}else{
	$prev=$p-1;
}
if($p==$pages){
	$next=$p;
}else{
	$next=$p+1;
}
if($_GET['do']=='search' && $s=safestr($_GET['s'])){
	$pagedo='seach';
	$users=$db->get_results("select * from ".C('DB_PREFIX')."users where uid='{$s}' or xm like'%{$s}%' or xh like'%{$s}%' or qq like'%{$s}%'  order by (case when uid='{$s}' then 8 else 0 end)+(case when user like '%{$s}%' then 3 else 0 end)+(case when mail like '%{$s}%' then 2 else 0 end)+(case when phone like '%{$s}%' then 1 else 0 end) desc limit 20");
}else{
	$pages=ceil(get_count('users','1=1','uid')/$pagesize);
	$users=$db->get_results("select * from ".C('DB_PREFIX')."users order by uid desc limit $start,$pagesize");
}
?>

<!DOCTYPE html>
<title>同学录-<?=C('webname')?> </title>
<body>
<!--main content start-->
  <section id="container" class="">
      <section id="main-content">
          <section class="wrapper">
<div class="inbox-head">
                          <h3>找一找你的小伙伴们！</h3>
                          <form action="?" class="navbar-right" method="GET">
				<input type="hidden" name="do" value="search">
                              <div class="input-append">
                              
                                  <input type="text" name='s'  placeholder="姓名/学号/QQ" class="sr-input">
                                  <button value="search"  type="hidden" class="btn sr-btn"><i class="icon-search"></i></button>
                              </div>
                          </form>
                      </div>
                      <br>
		  <?php
 if($users){foreach($users as $user ){?>

  <div class="col-lg-6">
                      <!--widget start-->
                      <aside class="profile-nav alt green-border">
                          <section class="panel">
                          <div class="user-heading alt blue-bg">
                                  <a href="#">
                                      <img alt="" src="http://q1.qlogo.cn/g?b=qq&nk=<?=$user['qq']?>&s=160">
                                  </a>
                                  <h1><?=$user['xm']?><span class="badge bg-info"><?php 
                                  if ($user['xtj']==1) {
                                  	echo $user['tj'];
                                  }
                                   ?></span></h1>
                                  <br>

                                  <p><?=$user['gxqm']?></p>
                                  
                                  

                                  
                              </div>
                              <table class="table">
                              <thead>
                             
                              </thead>
                              <tbody>
                              <tr>
                                  <td>姓名：<?=$user['xm']?></td>
                                  <td>性别：<?php 
                                  if ($user['xb']==1) {
                                  	echo "男";
                                  }
                                  elseif ($user['xb']==2) {
                                  	echo "女";
                                  }
                                  else{
                                  	echo "人妖";
                                  }
                                  

                                  

                                     ?></td>
                              </tr>
                              <tr>
                                  <td>学号：<?=$user['xh']?></td>
                                  <td>绰号：<?=$user['ch']?></td>
                                  
                                 
                              </tr>
                              <tr>
                              <td>生日：<?=$user['sr']?></td>
                               <td>住址：<?=$user['zz']?></td>
                              </tr>
                              <tr>
                              <td>电话：<?=$user['phone']?></td>
                               <td>邮箱：<?=$user['mail']?></td>
                              </tr>
                              <tr>
                              <td>QQ：<?=$user['qq']?></td>
                               <td>职位：<?=$user['zw']?></td>
                              </tr>
                              <tr>
                              <td>星座：<?=$user['xz']?></td>
                               <td>爱好：<?=$user['ah']?></td>
                               
                              </tr>
                              <tr>
                              <td>特长：<?=$user['tc']?></td>
                               <td>口头禅：<?=$user['ktc']?></td>
                               
                              </tr>
                              
                              </tbody>
                          </table>
                             
                          </section>
                      </aside>
                    </div>
					</div>
					<?php }?>	
					<?php }?>
					</section>
					</section>
					<? if($pagedo!='seach'){?>
			<div class="row" style="text-align:center;">
				<ul class="pagination pagination-lg">
					<li <?php if($p==1){echo'class="disabled"';}?>><a href="?p=1">首页</a></li>
					<li <?php if($prev==$p){echo'class="disabled"';}?>><a href="?p=<?=$prev?>">&laquo;</a></li>
					<?php for($i=$p;$i<=$pp;$i++){?>
					<li <?php if($i==$p){echo'class="active"';}?>><a href="?p=<?=$i?>"><?=$i?></a></li>
					<?php }?>
					<li <?php if($next==$p){echo'class="disabled"';}?>><a href="?p=<?=$next?>">&raquo;</a></li>
					<li <?php if($p==$pages){echo'class="disabled"';}?>><a href="?p=<?=$pages?>">末页</a></li>
				</ul>
				<?php } ?>
				
			</div>
		 
<?php
require_once('foot.php');
?>
  </body>
</html>
