<?
if (!defined("_GNUBOARD_")) exit;
include_once("./_common.php");
include_once("$g4[path]/head.sub.php");
define("_CO_POINT_RANK_", TRUE);
$html_title = "포인트 랭킹";
$g4[title] = "" . $html_title;

// 접근 권한 검사(내 스타일)
/*if (!$member[mb_id]) {
	
    alert("회원이 아니시면 포인트 순위를 볼 수 없습니다..\\n로그인을 해주세요.\\n");

}*/
?>
<style type="text/css">
<!--
.bk123 {
	border: 1px solid #CCCCCC;
}
-->
</style>

<table width="99%" border="0" cellpadding="0" cellspacing="0" align="center">
  <tr height="5"><td></td></tr>
  <tr>
    <td colspan="8">
	<table width="100%" border="0" cellpadding="0" cellspacing="0" class="bk123">
        <tr>
          <td height="40" align="center"><img src="<?=$g4[path]?>/img/level_img/level0.gif"> 씨앗
		  <img src="<?=$g4[path]?>/img/level_img/level3.gif"> 새싹
		  <img src="<?=$g4[path]?>/img/level_img/level4.gif"> 어린 나무
		  <img src="<?=$g4[path]?>/img/level_img/level5.gif"> 나무
		  <img src="<?=$g4[path]?>/img/level_img/level6.gif"> 큰 나무 
		  <img src="<?=$g4[path]?>/img/level_img/level7.gif"> 진보한 나무
		  <img src="<?=$g4[path]?>/img/level_img/level8.gif"> 희귀한 나무
		  <img src="<?=$g4[path]?>/img/level_img/level9.gif"> 전설의 나무 
		  <img src="<?=$g4[path]?>/img/level_img/level10.gif"> 고유의 나무</td>
        </tr>
		<?
		if ($member[mb_id]) 
{
?>
        <tr>
          <td height="35" style="padding-left:20px;" align="center"><?
$sql = " select sum(mb_point) as sum_point from $g4[member_table]";
$row = sql_fetch($sql);
$sum_point = $row[sum_point];

if ($member[mb_id] == $config[cf_admin]){
	echo "관리자님은 제외 대상입니다.";
}else{
	echo "현재 <b>".$member[mb_id]."</b>님의 포인트는 <B>".$member[mb_point]."점</B>";
	   $sql = " select count(mb_id) as cnt from $g4[member_table]
				  where mb_id <> '$config[cf_admin]' and mb_point >= '$member[mb_point]' order by mb_point desc ";
		$row = sql_fetch($sql);
	   
		 $sql2 = "  select count(mb_id) as cnt from $g4[member_table]
				  where mb_id <> '$config[cf_admin]'";
		$row2 = sql_fetch($sql2);
		 $total_count = $row2[cnt];
		echo "&nbsp;이고,&nbsp;랭킹은 전체회원수 <b>".$total_count."</b>명중 <B>".number_format($row[cnt])."등</B> 입니다.<br>";}
?></td>
        </tr>
		<? } ?>
    </table></td>
  </tr>
  <tr height="5"><td></td></tr>
 <tr>
<td width="6%" align="center"><b>랭킹</b></td>
<td width="20%" height="25" align="center"><b>닉네임/이름</b></td>
<td width="8%" height="25" align="center"><b>권한</b></td>
<td width="8%" align="center"><b>등급</b></td>
<td width="15%" align="center"><b>경험치</b></td>
<td width="18%" height="25" align="center"><b>아이디</b></td>
<td width="10%" height="25" align="center"><b>회원권한</b></td>
<td width="16%" align="center"><b>포인트</b></td>
</tr>
 <tr>
 <td colspan="8" height="5"></td>
</tr>
 <tr>
 <td colspan="8" height="1" bgcolor="#CCCCCC"></td>
</tr>
 <tr>
 <td colspan="8" height="5"></td>
</tr>
<?
$sql = " select count(*) as cnt from $g4[member_table]";
$row = sql_fetch($sql);
$total_count = $row[cnt];
 
$rows = 30;
$total_page  = ceil($total_count / $rows); 
if ($page == "") { $page = 1; }
$from_record = ($page - 1) * $rows; 

$mod = 48;
$tbl_col =2 ;

$tbl_col_sep = (int)($mod / $tbl_col) + ($mod % $tbl_col)  ;
if($_GET[keyword]!="")
{
if($_GET[type]==0)
{
$keyword_yi="and mb_nick='$_GET[keyword]'";
}
if($_GET[type]==1)
{
$keyword_yi="and mb_name='$_GET[keyword]'";
}
if($_GET[type]==2)
{
$keyword_yi="and mb_id='$_GET[keyword]'";
}
}
$sql = " select * from $g4[member_table] where mb_id <> '$config[cf_admin]' $keyword_yi 
          order by mb_point desc, mb_today_login desc 
          limit $from_record, $rows ";
		  $sql11 = " select count(*) from $g4[member_table] where mb_id <> '$config[cf_admin]' $keyword_yi 
          order by mb_point desc, mb_today_login desc 
          ";
$result = sql_query($sql);
$result11 = sql_query($sql11);
//echo $rsn11;
$rsn11=mysql_fetch_array($result11);
if($rsn11[0]==0)
{
if($_GET[type]==0)
{
$ty="닉네임";
}
if($_GET[type]==1)
{
$ty="이름";
}
if($_GET[type]==2)
{
$ty="아이디";
}


echo "<tr><td colspan=8 align=center height=150> 검색하신 $ty \"<font color=red>$_GET[keyword]</font>\" 에 대한 검색결과가 없습니다</td></tr>";
}
for ($i=0; $row=sql_fetch_array($result); $i++) 
{

    $rank = (($page - 1) * $rows) + $i + 1;
    $point = number_format($row[mb_point]);
	$id = $row[mb_id];
   

?>
<? if($row[mb_id] == $member[mb_id]){$rank_color="#ff5555"; $tr_color="#fff6f6";}else{ $rank_color=""; $tr_color="";}?>
<tr height="30" bgcolor=<?=$tr_color?>>
<td align="center"><font color="<?=$rank_color?>"><?=$rank?></font></td>
<td><?=level_icon($row[mb_level])?><a title="쪽지보내기" onfocus='this.blur()' style="FILTER: blendTrans(duration=0.7); CURSOR: pointer" onclick="window.open('memo_form.php?me_recv_mb_id=<?=$row[mb_id]?>','www_onuri_co_kr1','width=602,height=521,toolbars=no,resizable=no,scrollbars=no')"><?=$row[mb_nick]?> <!-- (<?//=$row[mb_name]?>) --></a>&nbsp;&nbsp;</td>
<td align="center"><?=$row[mb_level]?></td>
<td align="center"><?=get_member_level($row[mb_id],$row[mb_point])?></td>
<td align="center"><?=exp_bar($row[mb_id],$row[mb_point],1);?></td>
<td height="35" align="center"><a title="정보보기" onfocus='this.blur()' style="FILTER: blendTrans(duration=0.7); CURSOR: pointer" onclick="window.open('profile.php?mb_id=<?=$row[mb_id]?>','www_onuri_co_kr2','width=602,height=521,toolbars=no,resizable=no,scrollbars=no')"><b><?=$row[mb_id]?></b></a></td>
<td height="35" align="center">

<?
if ($level = $row[mb_level] == 10)$level="<font color=#FF6666>고유한 나무</font>"; 
else if ($level = $row[mb_level] == 9)$level="<font color=#FF6666>전설의 나무</font>"; 
else if ($level = $row[mb_level] == 8)$level="<font color=#dd000>희귀한 나무</font>"; 
else if ($level = $row[mb_level] == 7)$level="<font color=#85B3FF>진보한 나무</font>"; 
else if ($level = $row[mb_level] == 6)$level="<font color=#85B3FF>큰 나무</font>"; 
else if ($level = $row[mb_level] == 5)$level="<font color=#90D133>나무</font>";
else if ($level = $row[mb_level] == 4)$level="<font color=#85B3FF>어린 나무</font>"; 
else if ($level = $row[mb_level] == 3)$level="<font color=#FFA147>새싹</font>"; 
else if ($level = $row[mb_level] == 2)$level="<font color=#aaaaaa>씨앗</font>";
//else if ($level = $row[mb_level] == 1)$level="<font color=#aaaaaa>방문자</font>"; 
//else if ($level = $row[mb_level] == 0)$level="<font color=#aaaaaa>방문자</font>"; 
?>
<?=$level?></td>
<td height="35" align="right"><?=$point?>&nbsp;&nbsp;점&nbsp;&nbsp;</font></td>
</tr>
<tr>
<td colspan="8" height="1" background="img/dot_line.gif"></td>
</tr>
 <?	} ?>
  <tr>
 <td colspan="8" height="10"></td>
</tr>
 <tr>
 <td height="40" colspan="8">
 <?
$page = get_paging($config[cf_write_pages], $page, $total_page, "?$qstr&page=");
echo "<p><table width=100% cellpadding=0 cellspacing=0><tr><td align=center>$page</td></tr></table><br>";

?></td>
</tr>
<tr>
<td colspan="8">
<form id="form1" name="form1" method="get" action="">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr height="1"><td colspan="5" bgcolor=#cccccc></td></tr>
	<tr height="10"><td colspan="5"></td></tr>
	<tr>
		<td></td>
		<td align="right">
		<select name="type" id="type">
           <option value="0" <?php if($_GET[type]==0){ echo "selected";}?>>닉네임</option>
           <option value="1" <?php if($_GET[type]==1){ echo "selected";}?>>이름</option>
           <option value="2" <?php if($_GET[type]==2){ echo "selected";}?>>아이디</option>
         </select>
		 </td>
		<td width="5"></td>
		 <td width="105"><input name="keyword" type="text" class="ed" id="keyword" style='width:150px;height:21;' value="<?=$_GET[keyword]?>"/></td>
		 <td width="5"></td>
		 <td width="25"><input type="image" name="imageField" src="<?=$g4[path]?>/img/btn_search.gif" /></td>
		</tr>
</table>
</form>	

</td>
</tr>
</table>              


     
