<?php
if( !defined('ISDVBBS') ){
	header('HTTP/1.0 404 Not Found');
	exit;
}
?>
<br>
<table border="0" cellpadding="0" cellspacing="0" align="center" class="tableborder">
<tr>
<td class="tit1" colspan="6"><?=$lang['limit.info10']?></td>
</tr>
<tr>
<td class="forumrow1" style="text-align:center;" width="18%">
	<input type="submit" name="Submit" value="<?=$lang['limit.info9']?>" style="color: #FF0000;width:80px;height:50px;border:1px outset;">
</td>
<td  class="forumrow2" colspan="4" width="82%"><?=$lang['limit.info11']?></td>
</tr>
<tr>
<td height="23" align="center" width="15%" <?if($action=='add'){echo 'bgcolor="#C9DEFA"';}else{echo 'bgcolor="#F1F3F5"';}?>><a href="?action=add"><font color="<?if($action=='add'){echo 'red';}else{echo '#000000';}?>"><?=$lang['limit.info12']?></font></a></td>
<td height="23" align="center" width="15%" <?if($action==''){echo 'bgcolor="#C9DEFA"';}else{echo 'bgcolor="#F1F3F5"';}?>><a href="?action="><font color="<?if($action==''){echo 'red';}else{echo '#000000';}?>"><?=$lang['limit.info13']?></font></a></td>
<?if($action=='edit'){?>
	<td width="10%" bgcolor="#C9DEFA"><font color="red"><?=$lang['limit.info14']?></font></td>
<?}if($action=='pasword'){?>
	<td width="10%" bgcolor="#C9DEFA"><font color="red"><?=$lang['limit.info15']?></font></td>
<?}?>
<td width="50%" bgcolor="#F1F3F5"></td>
</tr>
</table>
<?
if($action=="add"){
?>
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <form name="form1" method="post" action="?action=addok">
  <tr>
    <td>
		<table border="0" cellspacing="0" cellpadding="0"  align="center" class="tableborder">
		  <tr>
			<td colspan="2" class="tdtit"><?php echo $lang['template.info9']?></td>
		  </tr>
		  <tr>
			<td height="30" width="30%" class="forumrow" style="text-align:right;"><?php echo $lang['template.info10']?></td>
			<td width="70%" height="30" class="forumrow"><input type="text" name="endusername" size="30">&nbsp;&nbsp;<?php echo $lang['template.info11']?>
		</td>
		  </tr>
		  <tr>
			<td height="30" class="forumrow" style="text-align:right;"><?php echo $lang['template.info12']?></td>
			<td height="30" class="forumrow"><input type="password" name="endpassword" size="30">&nbsp;&nbsp;<?php echo $lang['template.info13']?></td>
		  </tr>
		  <tr>
			<td height="30" class="forumrow" style="text-align:right;"><?php echo $lang['template.info14']?></td>
			<td height="30" class="forumrow"><input type="text" name="preusername" size="30">&nbsp;&nbsp;<?php echo $lang['template.info15']?></td>
		  </tr>
		  <tr>
			<td height="30" class="forumrow" style="text-align:right;"><?php echo $lang['template.info16']?></td>
			<td height="30" class="forumrow"><?php echo $lang['template.info17']?><input type="radio" name="view" value="yes" checked>
			  <?php echo $lang['template.info18']?><input type="radio" name="view" value="no"><?php echo $lang['template.info19']?></td>
		  </tr>
		</table>
		<?//权限?>
		<table border="0" cellspacing="0" cellpadding="0"  align="center" class="tableborder">
		  <tr>
			<td class="tit1"><? echo $lang['limit.info1']?><b><font color="ffff00"><? echo $name?></font></b><? echo $lang['limit.info2']?></td>
		  </tr>
		  <tr>
			<td class="forumrow1"><? echo $lang['limit.info3']?></td>
		  </tr>
		  <tr>
			<td class="forumrow">
		<?
			foreach ($menulists as $val) {
				echo "<b>".$val['menu0']['title']."</b><br>";
				for ($ii = 1; $ii < $val['lcount'] + 1; $ii++ ){
		?>
					<input type="checkbox" name="limit[]" value="<?=$val["menu".$ii]['item1']['permission']?>">
					<a href="<?=$val["menu".$ii]['item1']['link']?>"><?=$val["menu".$ii]['item1']['title']?></a>
		<?
					if($val["menu".$ii]['mcount'] > 1 ){
						if($val["menu".$ii]['item2']['readme'] != ''){
		?>			
							&nbsp;|&nbsp; <a href="<?=$val["menu".$ii]['item2']['link']?>"><?=$val["menu".$ii]['item2']['title']?></a>
		<?
						}else{
		?>
							<input type="checkbox" name="limit[]" value="<?=$val["menu".$ii]['item2']['permission']?>">
							<a href="<?=$val['menu'.$ii]['item2']['link']?>"><?=$val['menu'.$ii]['item2']['title']?></a>
		<?
						}
					}
				}
				echo "<br><br>";
			}
		?>
		</td>
		  </tr>
		  <tr>
			<td class="forumrow1" style="text-align:center">
			<input type="submit" class="button" name="Submit" value="<? echo $lang['template.info32']?>">&nbsp;&nbsp;
			<input type="checkbox" name="all_limit" value="Y" onclick="un(this)"><? echo $lang['limit.info4']?>
		</td>
		  </tr>
		</table>
	</td>
  </tr>
</form>
</table>
<?}
elseif($action=="pasword"){
?>
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <form name="form1" method="post" action="?action=edit_userok&id=<? echo $id?>">
  <tr>
    <td>
	<table border="0" cellspacing="0" cellpadding="0"  align="center" class="tableborder">
	  <?	
		$stmt=$db->query("select id,username,adduser,lastloginip,password,acceptip from {$dv}admin where id='".intval($id)."'");
		$user_list=$db->fetch_array($stmt);
		$iplist=str_replace("|","\r\n",$user_list['acceptip']);
	?>
	  <tr>
		<td colspan="2" class="tdtit"><?php echo $lang['pw.info1']?></td>
	  </tr>
	  <tr>
		<td class="forumrow" width="30%" style="text-align:right;"><?php echo $lang['template.info10']?></td>
		<td class="forumrow" width="70%"><input type="text" name="endusername" size="30" value="<? echo $user_list['username']?>">&nbsp;&nbsp;<?php echo $lang['template.info11']?>
	</td>
	  </tr>
	  <tr>
		<td class="forumrow" style="text-align:right;"><?php echo $lang['template.info12']?></td>
		<td class="forumrow"><input type="password" id="endpassword" value="<? echo $user_list['password']?>"name="endpassword" size="30">&nbsp;&nbsp;<?php echo $lang['template.info13']?></td>
	  </tr>
	  <tr>
		<td class="forumrow" style="text-align:right;"><?=$lang['template.info14']?></td>
		<td class="forumrow"><? echo $user_list['adduser']?></td>
	  </tr>
	  <tr>
		<td class="forumrow" style="text-align:right;"><? echo $lang['pw.info3']?></td>
		<td class="forumrow"><textarea name="login_ip" cols="40" rows="8"><? echo $iplist?></textarea><font color="red"><? echo $lang['pw.info14']?></font></td>
	  </tr>
	  <tr>
		<td class="forumrow1" style="text-align:right;">&nbsp;</td>
		<td class="forumrow1"><input type="button" class="button" name="" onclick="login_ip.value+='\r\n<? echo $ip?>'" value="<? echo $lang['pw.info11']?>">&nbsp;&nbsp;<? echo $ip?></td>
	  </tr>
	  <tr>
		<td class="forumrow" style="text-align:right;"><? echo $lang['pw.info3']?></td>
		<td class="forumrow">
				<b><? echo $lang['pw.info4']?></b>
				<ol>
				<LI><b><? echo $lang['pw.info5']?></b>
				<LI><b><font color=red><? echo $lang['pw.info6']?></font></b>
				<LI><b><? echo $lang['pw.info7']?></b>
				<LI><? echo $lang['pw.info8']?>
				<LI><? echo $lang['pw.info9']?>
				<LI><? echo $lang['pw.info10']?>
				</ol></td>
	  </tr>
	</table>
	<?//权限?>
	<table border="0" cellspacing="1" cellpadding="1"  align="center" class="tableborder">
	  <tr>
		<td class="tit1"><? echo $lang['limit.info1']?><b><font color="ffff00"><? echo $user_list['username']?></font></b><? echo $lang['limit.info2']?></td>
	  </tr>
	  <tr>
		<td class="forumrow1"><? echo $lang['limit.info3']?></td>
	  </tr>
	  <tr>
		<td class="forumrow">
	<?
		$sql=$db->query("select flag,adduser from {$dv}admin where username='".$user_list['username']."'");
		$sql_arr=$db->fetch_array($sql);
		$arr_flag=$sql_arr['flag'];
		if($sql_arr['adduser']!=$membername){//判断是否为超级管理员;
			$session_flag=",16,";
		}
		if(strpos(",".$arr_flag.",",$session_flag)!==false){
			$allcheck_select="disabled=true";
		}
		else{
			$allcheck_select="";			
		}
		foreach ($menulists as $val) {
			echo "<b>".$val['menu0']['title']."</b><br>";
			for ($ii = 1; $ii < $val['lcount'] + 1; $ii++ ){
				for ($jj=1; $jj < $val['menu'.$ii]['mcount']+1; $jj++){
	?>
					<input type="checkbox" name="limit[]" value="<?=$val['menu'.$ii]['item'.$jj]['permission']?>" 
						<? 
						if(strpos(",".$arr_flag.",",",".$val['menu'.$ii]['item'.$jj]['permission'].",")!==false){
							echo "checked";
						}
						else{
							echo "";
						}
						if(strpos(",".$arr_flag.",",$session_flag)!==false){ 
							echo " disabled=true";
						}
						?>
					>
					<a href="<?=$val['menu'.$ii]['item'.$jj]['link']?>"><?=$val['menu'.$ii]['item'.$jj]['title']?></a>
<?
				}
			}
			echo "<br><br>";
		}
	?>
	</td>
	  </tr>
	  <tr>
		<td class="forumrow1" style="text-align:center;">
		<input type="submit" class="button" name="Submit" value="<? echo $lang['limit.info5']?>">&nbsp;&nbsp;
		<input type="checkbox" name="all_limit" value="Y" <?=$allcheck_select?> onclick="un(this)"><? echo $lang['limit.info4']?>
	</td>
	  </tr>
	</table>
	</td>
  </tr>
</form>
</table>
<?}
	elseif($action=="edit"){
?>
<table border="0" cellspacing="0" cellpadding="0"  align="center" class="tableborder">
 <form name="form1" method="post" action="?action=limit_updateok&id=<? echo $id?>">
  <tr>
    <td class="tdtit"><? echo $lang['limit.info1']?><b><font color="ffff00"><? echo $name?></font></b><? echo $lang['limit.info2']?></td>
  </tr>
  <tr>
    <td class="forumrow2"><? echo $lang['limit.info3']?></td>
  </tr>
  <tr>
    <td class="forumrow">
<?
		$sql=$db->query("select flag,adduser from {$dv}admin where username='".$name."'");
		$sql_arr=$db->fetch_array($sql);
		$arr_flag=$sql_arr['flag'];
		if($sql_arr['adduser']!=$membername){//判断是否为超级管理员;
			$session_flag=",16,";
		}
		if(strpos(",".$arr_flag.",",$session_flag)!==false){
			$allcheck_select="disabled=true";
		}
		else{
			$allcheck_select="";			
		}
		foreach ($menulists as $val) {
			echo "<b>".$val['menu0']['title']."</b><br>";
			for ($ii = 1; $ii < $val['lcount'] + 1; $ii++ ){
				for ($jj=1; $jj < $val['menu'.$ii]['mcount']+1; $jj++){
?>
				<input type="checkbox" name="limit[]" value="<?=$val['menu'.$ii]['item'.$jj]['permission']?>"
					<? 
						if(strpos(",".$arr_flag.",",",".$val['menu'.$ii]['item'.$jj]['permission'].",")===false){
							echo "";
						}
						else{
							echo "checked";
						}
						if(strpos(",".$arr_flag.",",$session_flag)!==false){
							echo " disabled=true";
						}
					?>
				>
				<a href="<?=$val['menu'.$ii]['item'.$jj]['link']?>"><?=$val['menu'.$ii]['item'.$jj]['title']?></a>
<?
				}
			}
			echo "<br><br>";
		}
?>
</td>
  </tr>
  <tr>
    <td class="forumrow1" style="text-align:center;"><input type="submit"  class="button"  name="Submit" value="<? echo $lang['limit.info5']?>">
      &nbsp;&nbsp;<input type="checkbox" name="all_limit" value="Y" <?=$allcheck_select?> onclick="un(this)"><? echo $lang['limit.info4']?>
</td>
  </tr>
 </form>
</table>
<?
}
else{
?>
<table border="0" cellspacing="0" cellpadding="0"  align="center" class="tableborder">
  <tr>
    <td colspan="4" class="tdtit"><?php echo $lang['template.info1']?></td>
  </tr>
  <tr class="forumrow2">
    <td style="text-align:center;"><?php echo $lang['template.info2']?></td>
    <td style="text-align:center;"><?php echo $lang['template.info3']?></td>
    <td style="text-align:center;"><?php echo $lang['template.info4']?></td>
    <td style="text-align:center;"><?php echo $lang['template.info5']?></td>
  </tr>
  <?
  	$bgColor='#CAD7F7';
	if(!empty($info_list)){
		if(is_array($info_list)){
			foreach($info_list as $arr_list){
  ?>
  <tr class="forumrow" style="padding:1px;">
    <td height="20" align="center"><a href="admin.php?id=<? echo $arr_list['id']?>&action=pasword"><?php echo $arr_list['username']?></a></td>
    <td height="20" align="center"><?php if(empty($arr_list['lastlogin'])){echo "";}else{ echo gmdate('Y-m-d H:i:s', $arr_list['lastlogin']+getUserTimeZoneOffset());}?></td>
    <td height="20" align="center"><?php echo $arr_list['lastloginip']?></td>
    <td height="20" style="text-align:center;"><a href="admin.php?action=del&id=<? echo $arr_list['id']?>&name=<? echo $arr_list['adduser']?>" onclick="return confirm('<?php echo addslashes($lang['template.info8'])?>')"><?php echo $lang['template.info6']?></a>&nbsp;&nbsp;<a	href="admin.php?id=<?php echo $arr_list['id']?>&action=edit&name=<? echo $arr_list['username']?>"><?php echo "".$lang['template.info7']?></a></td>
  </tr>
  <?
			}
		}
	}
  ?>
</table>
<?}?>