<?php
if( !defined('ISDVBBS') ){
	header('HTTP/1.0 404 Not Found');
	exit;
}
if($action=="nowused"){
?>
<br>
<table border="0" cellspacing="1" cellpadding="1"  align="center" class="tableborder">
  <tr>
    <td colspan="5" class="tit1" align="left"><?php echo $lang['template.info6']?></td>
  </tr>
  <tr>
    <td class="forumrow" style="text-align:center;" width="15%">
	<input type="submit" name="Submit" value="<? echo $lang['template.info11']?>" style="color: #FF0000;width:80px;height:50px;border:1px outset;">
	</td>
    <td colspan="4" class="forumrow" align="left"><b><?php echo $lang['template.info1']?></b><br><?php echo $lang['template.info2']?><br><?php echo $lang['template.info3']?></td>
  </tr>
</table>
<!--导航-->
<table border="0" cellspacing="0" cellpadding="0"  align="center" class="tableborder">
<tr align="center">
<td height="25" align="center" <?if($action=='nowused'){echo 'bgcolor="#C9DEFA"';}else{echo 'bgcolor="#F1F3F5"';}?>  width="10%"><a href="?action=nowused"><font color="<?if($action=='nowused'){echo 'red';}else{echo '#000000';}?>"><?=$lang['template.info8']?></font></a></td>
<td height="25" align="center" <?if($action=='addtable'){echo 'bgcolor="#C9DEFA"';}else{echo 'bgcolor="#F1F3F5"';}?> width="10%"><a href="?action=addtable"><font color="<?if($action=='addtable'){echo 'red';}else{echo '#000000';}?>"><?=$lang['template.info9']?></font></a></td>
<td width="10%" align="center" <?if($action==''){echo 'bgcolor="#C9DEFA"';}else{echo 'bgcolor="#F1F3F5"';}?>></font><a href="?action="><font color="<?if($action==''){echo 'red';}else{echo '#000000';}?>"><?=$lang['template.info10']?></font></a></td>
</tr>
</table>
<!--导航结束-->
<table border="0" cellspacing="0" cellpadding="0"  align="center" class="tableborder">
  	<form name="updateform" method="post" action="?action=update">
  <tr>
    <td colspan="5" class="tdtit"><?php echo $lang['template.info4']?></td>
  </tr>
  <tr class=forumrow2>
    <td align=center><?php echo $lang['table.info1']?></td>
    <td align=center><?php echo $lang['table.info2']?></td>
    <td align=center><?php echo $lang['table.info3']?></td>
    <td align=center><?php echo $lang['table.info4']?></td>
    <td align=center><?php echo $lang['table.info5']?></td>
  </tr>
<?php
	 if(!empty($tablelist)){
		if(is_array($tablelist)){
			foreach($tablelist as $tableval){
				$tablecount=$db->scalar("select count(1) from ".$tableval['tablename']."");

  ?>
  <tr class="forumrow">
    <td height="25" align=center><?php echo $tableval['tablename']?></td>
    <td height="25" align=center><?php echo $tableval['tabletype']?></td>
    <td height="25" align=center><?php echo $tablecount;?></td>
    <td height="25" align=center><input value="<?php echo $tableval['tablename']?>" <?if($tableval['tablename']==$default_table)echo "checked"?> name="d_table" type="radio"></td>
    <td height="25" align=center><a href="?action=del&tablename=<?php echo $tableval['tablename']?>" onclick="return confirm('<?php echo addslashes($lang['table.info7'])?>');"><?php echo $lang['table.info6']?></a></td>
  </tr>
  <?php
			}
		}
	 }
  ?>
  <tr><td colspan="5" class="forumrow1" height="30" style="text-align:center;"> <input type="submit" class="button" name="Submit" value="<?php echo $lang['template.submit']?>"></td></tr>
  </form>
</table>
<?}elseif($action=='addtable'){?>
<br>
<table border="0" cellspacing="1" cellpadding="1"  align="center" class="tableborder">
  <tr>
    <td colspan="5" class="tit1" align="left"><?php echo $lang['template.info6']?></td>
  </tr>
  <tr>
    <td class="forumrow" style="text-align:center;" width="15%">
	<input type="submit" name="Submit" value="<? echo $lang['template.info11']?>" style="color: #FF0000;width:80px;height:50px;border:1px outset;">
	</td>
    <td colspan="4" class="forumrow" align="left"><b><?php echo $lang['template.info1']?></b><br><?php echo $lang['template.info2']?><br><?php echo $lang['template.info3']?></td>
  </tr>
</table>
<!--导航-->
<table border="0" cellspacing="0" cellpadding="0"  align="center" class="tableborder">
<tr align="center">
<td height="25" align="center" <?if($action=='nowused'){echo 'bgcolor="#C9DEFA"';}else{echo 'bgcolor="#F1F3F5"';}?>  width="10%"><a href="?action=nowused"><font color="<?if($action=='nowused'){echo 'red';}else{echo '#000000';}?>"><?=$lang['template.info8']?></font></a></td>
<td height="25" align="center" <?if($action=='addtable'){echo 'bgcolor="#C9DEFA"';}else{echo 'bgcolor="#F1F3F5"';}?> width="10%"><a href="?action=addtable"><font color="<?if($action=='addtable'){echo 'red';}else{echo '#000000';}?>"><?=$lang['template.info9']?></font></a></td>
<td width="10%" align="center" <?if($action==''){echo 'bgcolor="#C9DEFA"';}else{echo 'bgcolor="#F1F3F5"';}?>></font><a href="?action="><font color="<?if($action==''){echo 'red';}else{echo '#000000';}?>"><?=$lang['template.info10']?></font></a></td>
</tr>
</table>
<!--导航结束-->
<table border="0" cellspacing="0" cellpadding="0"  align="center" class="tableborder">
  	<form name="createtableform" method="post" action="?action=createtable">
	<?php 
	$sql=$db->query("select max(tablename) from {$dv}tablelist");
	$arrval=$db->fetch_array($sql);
	$tablenum=substr($arrval['max(tablename)'],-1);
	$addnum=(int)$tablenum+1;
	$addnum="dv_bbs".$addnum;
  ?>
	<tr>
		<td colspan="2" class="tdtit"><?php echo $lang['table.info8']?></td>
	</tr>
  <tr>
    <td class="forumrow" height="25" width="25%"><?php echo $lang['table.info9']?></td>
    <td class="forumrow" height="25" width="75%"><input type="text" name="table_name" value="<?php echo $addnum;?>"size="30" id="table_name">  <?php echo $lang['table.info10']?></td>
  </tr>
  <tr>
    <td class="forumrow" height="25"  width="25%"><?php echo $lang['table.info11']?></td>
    <td class="forumrow" height="25"  width="75%"><input type="text" name="table_stu" size="30" id="table_stu">  <?php echo $lang['table.info12']?></td>
  </tr>
	<tr>
		<td colspan="2" class="forumrow1" height="30" style="text-align:center;"><input type="submit" class="button" name="Submit" value="<?php echo $lang['template.submit']?>"></td>
	</tr>
  </form>
</table>
<?php
	 }
  elseif($action=="search"){
?>
<br>
<table border="0" cellspacing="1" cellpadding="1"  align="center" class="tableborder">
  <tr>
    <td colspan="8" class="tit1" align="left"><?php echo $lang['template.info6']?></td>
  </tr>
  <tr>
    <td class="forumrow" style="text-align:center;" width="15%">
	<input type="submit" name="Submit" value="<? echo $lang['template.info11']?>" style="color: #FF0000;width:80px;height:50px;border:1px outset;">
	</td>
    <td colspan="6" align="left" height="30" class="forumrow"><b><?php echo $lang['swap.info1']?></b><br><?php echo $lang['search.info2']?></td>
  </tr>
</table>
<!--导航-->
<table border="0" cellspacing="0" cellpadding="0"  align="center" class="tableborder">
<tr align="center">
<td height="25" align="center" <?if($action=='nowused'){echo 'bgcolor="#C9DEFA"';}else{echo 'bgcolor="#F1F3F5"';}?>  width="10%"><a href="?action=nowused"><font color="<?if($action=='nowused'){echo 'red';}else{echo '#000000';}?>"><?=$lang['template.info8']?></font></a></td>
<td height="25" align="center" <?if($action=='addtable'){echo 'bgcolor="#C9DEFA"';}else{echo 'bgcolor="#F1F3F5"';}?> width="10%"><a href="?action=addtable"><font color="<?if($action=='addtable'){echo 'red';}else{echo '#000000';}?>"><?=$lang['template.info9']?></font></a></td>
<td width="10%" align="center" <?if($action==''){echo 'bgcolor="#C9DEFA"';}else{echo 'bgcolor="#F1F3F5"';}?>><a href="?action="><font color="<?if($action==''){echo 'red';}else{echo '#000000';}?>"><?=$lang['template.info10']?></font></a></td>
<td width="10%" align="center" <?if($action=='search'){echo 'bgcolor="#C9DEFA"';}else{echo 'bgcolor="#F1F3F5"';}?>><font color="red"><?=$lang['template.info10']?></font></td>
</tr>
</table>
<!--导航结束-->
<table border="0" cellspacing="0" cellpadding="0"  align="center" class="tableborder">
  <form name="form1" method="post" action="?reaction=searchswap&first_tablename=<? echo $tablename?>&k_condition=<? echo $keyword?>&select_type=<?php echo $searchwhat?>">
  <input type="hidden" value="<?=$keyword?>" name="keyword">
  <tr>
    <td colspan="6" class="tdtit"><?php echo $lang['search.info3']?>&nbsp;<?php echo $tablename;?>&nbsp;<?php echo $lang['search.info4']?></td>
  </tr>
  <tr class="forumrow2">
    <td height="25" width="5%" style="text-align:center;"><?php echo $lang['search.info5']?></td>
    <td height="25" width="50%" style="text-align:center;"><?php echo $lang['search.info6']?></td>
    <td height="25" width="15%" style="text-align:center;"><?php echo $lang['search.info7']?></td>
    <td height="25" width="5%" style="text-align:center;"><?php echo $lang['search.info8']?></td>
    <td height="25" width="15%" style="text-align:center;"><?php echo $lang['search.info9']?></td>
    <td height="25" width="10%" style="text-align:center;"><?php echo $lang['search.info10']?></td>
  </tr>
  <?php
	if(!empty($userforum_list)){
		if(is_array($userforum_list)){
			foreach ($userforum_list as $userforum_val){
	
?>
	<tr class="forumrow" style="padding:1px;">
    <td style="text-align:center;">
	<?php 
		if($userforum_val['locktopic']==1)
			echo $lang['search.info12'];
		elseif($userforum_val['isvote']==1)
			echo $lang['search.info13'];
		elseif(intval($userforum_val['isbest'])==1)
			echo $lang['search.info14'];
		else
			echo $lang['search.info15'];
	?>
	</td>
    <td style="text-align:left;">&nbsp;&nbsp;<?php echo $userforum_val['title']?></td>
    <td style="text-align:center;"><a href="user.php?action=modify&userid=<?php echo $userforum_val['postuserid']?>"><?php echo $userforum_val['postusername']?></a></td>
    <td style="text-align:center;"><?php echo $userforum_val['child']?></td>
    <td style="text-align:center;"><?php echo gmdate('Y-m-d H:i:s', $userforum_val['dateandtime']+getUserTimeZoneOffset())?></td>
    <td style="text-align:center;">
      <input type="checkbox" name="topicid[]" value="<?php echo $userforum_val['topicid']?>"><?php echo $userforum_val['topicid']?>
</td>
  </tr>
<?php
			}
		}
	}
	
?>
  <tr class="forumrow1">
    <td colspan="2">&nbsp;</td>
	<td colspan="4" style="text-align:center;"><?php echo $lang['search.info11']?>
      <input type="checkbox" name="select_all" id="select_all" value="Y">
      <select name="target_tablename">
	   <?php
			$result=$db->query("select id,tablename,tabletype from {$dv}tablelist");
			while ($t_list=$db->fetch_array($result)){
			echo "<option value=\"".$t_list['tablename']."\">".$t_list['tabletype']."--".$t_list['tablename']."</option>";
			}

		?>
      </select>
	  <input type="submit" class="button" name="Submit" value="<?php echo $lang['template.swap']?>">&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $lang['template.into5']?><input type="checkbox" name="select_currently" id="select_currently" value="curr_all" onclick="un(this)">
</td>
  </tr>
</form>
<tr>
<td class="forumrow" colspan=6>
<? if($total>0)	
  page_search($lang['edit.info11'],$lang['edit.info12'],'searchwhat',$searchwhat,'tablename',$tablename,'keyword',$keyword,'action',$action,'select_type',$searchwhat);
?>
	</td>
	</tr>
	</table>
<?php
  }
  else{
?>
<br>
<!--导航-->
<table border="0" cellspacing="1" cellpadding="1"  align="center" class="tableborder">
  <tr>
    <td colspan="5" class="tit1" align="left"><?php echo $lang['template.info7']?></td>
  </tr>
  <tr>
    <td style="text-align:center;" class="forumrow"><input type="submit" name="Submit" value="<? echo $lang['template.info11']?>" style="color: #FF0000;width:80px;height:50px;border:1px outset;"></td>
    <td colspan="4" align="left" class="forumrow"><b><?php echo $lang['swap.info1']?></b><br><?php echo $lang['swap.info2']?></td>
  </tr>
  </table>
<table border="0" cellspacing="0" cellpadding="0"  align="center" class="tableborder">
<tr align="center">
<td height="25" align="center" <?if($action=='nowused'){echo 'bgcolor="#C9DEFA"';}else{echo 'bgcolor="#F1F3F5"';}?>  width="10%"><a href="?action=nowused"><font color="<?if($action=='nowused'){echo 'red';}else{echo '#000000';}?>"><?=$lang['template.info8']?></font></a></td>
<td height="25" align="center" <?if($action=='addtable'){echo 'bgcolor="#C9DEFA"';}else{echo 'bgcolor="#F1F3F5"';}?> width="10%"><a href="?action=addtable"><font color="<?if($action=='addtable'){echo 'red';}else{echo '#000000';}?>"><?=$lang['template.info9']?></font></a></td>
<td width="10%" align="center" <?if($action==''){echo 'bgcolor="#C9DEFA"';}else{echo 'bgcolor="#F1F3F5"';}?>></font><a href="?action="><font color="<?if($action==''){echo 'red';}else{echo '#000000';}?>"><?=$lang['template.info10']?></font></a></td>
</tr>
</table>
<!--导航结束-->
<table border="0" cellspacing="0" cellpadding="0"  align="center" class="tableborder">
 <form name="searchform" method="post" action="?action=search">
   <tr>
    <td colspan="2" class="tdtit"><?php echo $lang['swap.info3']?></td>
  </tr>
  <tr>
    <td width="25%" class="forumrow"><?php echo $lang['swap.info4']?></td>
    <td width="75%"  class="forumrow">
      <input type="text" name="keyword" id="keyword" size="30">
      <select name="tablename">
	  <?php
			$result=$db->query("select id,tablename,tabletype from {$dv}tablelist");
			while ($t_list=$db->fetch_array($result)){
			echo "<option value=\"".$t_list['tablename']."\">".$t_list['tabletype']."--".$t_list['tablename']."</option>";
			}

		?>
      </select>
      <?php echo $lang['swap.info5']?><input type="radio" name="searchwhat" value="username" checked>
      <?php echo $lang['swap.info6']?><input type="radio" name="searchwhat" value="topic">
      <input type="submit" class="button" name="Submit" value="<?php echo $lang['template.search']?>">
</td>
  </tr>
  <tr>
    <td class="forumrow" height="30" colspan="2"><b><?php echo $lang['swap.info7']?></b><?php echo $lang['swap.info8']?></td>
  </tr>
</form>
 <form name="dataswapform" method="post" action="?action=dataswap">
 <tr>
    <td colspan="2" class="tit1"><?php echo $lang['swap.info9']?></td>
  </tr>
  <tr>
    <td class="forumrow" height="30" colspan="2">
      <select name="sourcetable">
	   <?php
			$result=$db->query("select id,tablename,tabletype from {$dv}tablelist");
			while ($t_list=$db->fetch_array($result)){
			echo "<option value=\"".$t_list['tablename']."\">".$t_list['tabletype']."--".$t_list['tablename']."</option>";
			}

		?>
      </select>
      <?php echo $lang['swap.info10']?><input type="radio" name="recordtopend" value="pre" checked>
      <?php echo $lang['swap.info11']?><input type="radio" name="recordtopend" value="end">
      <input type="text" name="forum_num" size="10" value="100"><?php echo $lang['swap.info14']?>&nbsp;&nbsp;<?php echo $lang['swap.info12']?>
      <select name="targettable">
	   <?php
			$result=$db->query("select id,tablename,tabletype from {$dv}tablelist");
			while ($t_list=$db->fetch_array($result)){
			echo "<option value=\"".$t_list['tablename']."\">".$t_list['tabletype']."--".$t_list['tablename']."</option>";
			}

		?>
      </select>
      <input type="submit" class="button" name="Submit" value="<?php echo $lang['template.submit']?>">
	</td>
  </tr>
  <tr>
    <td class="forumrow" height="1" colspan="2"><b><?php echo $lang['swap.info7']?></b><?php echo $lang['swap.info13']?></td>
  </tr>
</form>
</table>
<?php
}
?>