<?php
include("includes/db.inc.php");
include("includes/config.php");
$msql=new SHARP_SQL;
$fsql=new SHARP_SQL;
if(!isset($AUTOUSERID) || $AUTOUSERID=="" || $AUTOUSERID=="deleted"){
header("Location: log.php3?fm=modcon.php3");
}else{
$userid=$AUTOUSERID;
}
?><HTML><HEAD><TITLE></TITLE>



<META content="text/html; charset=big5" http-equiv=Content-Type>



<STYLE>HTML {TEXT-DECORATION: none}



A:link {COLOR: #000000; TEXT-DECORATION: underline}



A:hover {COLOR: rgb(0,147,43); TEXT-DECORATION: underline}



EM {FONT-FAMILY: CourierNew; FONT-SIZE: 16pt; FONT-STYLE: normal}



A {FONT-SIZE: 9pt}



TD {FONT-SIZE: 9pt}



P {



FONT-SIZE: 9pt



}



.hh input {background-color: #ffffff; border-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px}



</STYLE>



</HEAD>



<BODY aLink=#000000 bgColor=#00CCFF leftMargin=0 link=#000000 topMargin=0 vLink=#000000 marginwidth="0" marginheight="0">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr valign="bottom"> 
    <td height="27" width="22%"><font color="#000000">■ 網站內容維護</font><font color="#000000"></font></td>
    <td height="27" width="78%">&nbsp;</td>
  </tr>
  <tr> 
    <td height="1" width="22%" bgcolor="#FF3300"><img src="images/dot.gif" width="22" height="1"></td>
    <td height="1" width="78%" bgcolor="#FF3300"><img src="images/dot.gif" width="22" height="1"></td>
  </tr>
  <tr valign="top"> 
    <td height="413" width="22%" bgcolor="#FFFFFF"> 
      <div align="center"></div>
      <div align="center"></div>
      <table width="100%" border="0" cellspacing="2" cellpadding="2">
        <tr bgcolor="#FF6600"> 
          <td width="9%" height="21" bgcolor="#0099FF"> 
            <div align="center"></div>
          </td>
          <td width="91%" height="21" bgcolor="#0099FF"> 
            <div align="center">請選擇欄目</div>
          </td>
        </tr>
        <?php
$msql->query("select * from auto_dir where userid='$AUTOUSERID' and parentid=0 and (mod='0' or mod='1' or mod='2') order by xuhao");
$i=0;
while($msql->next_record()){
$dirid=$msql->f('dirid');
$ifson=$msql->f('ifson');
$dirname=$msql->f('dirname');
$mod=$msql->f('mod');

?> 
        <tr> 
          <td bgcolor="#0099FF" width="9%" height="17"> 
            <div align="center"></div>
          </td>
          <td width="91%" height="17" bgcolor="#FFCC66"> <img src="images/plus.gif" width="35" height="17"> 
            <?php

if($mod=='0'){
		echo "<a href=moduser.php3>$dirname</a>";
}
if($mod!='0' and $ifson!='1'){
		$n[$i]=$dirname;
		$v[$i]=$dirid;
		$i++;
		echo "<a href=modcon1.php3?nowdir=$dirid>$dirname</a>";
}elseif($mod!='0' and $ifson=='1'){
		echo "$dirname";
}



?> </td>
        </tr>
        <?php
if($ifson=="1"){
$fsql->query("select * from auto_dir where parentid='$dirid' and userid='$AUTOUSERID'");
while($fsql->next_record()){
$dirid=$fsql->f('dirid');
$dirname=$fsql->f('dirname');
$mod=$fsql->f('mod');

?> 
        <tr> 
          <td width="9%" height="17" bgcolor="#0099FF" align="center">&nbsp;</td>
          <td width="91%" height="17" bgcolor="#FFCC66"> <img src="images/dot.gif" width="14" height="14"><img src="images/open.gif" width="32" height="18"> 
            <?php
		$n[$i]=$dirname;
		$v[$i]=$dirid;
		$i++;

echo "<a href=modcon1.php3?nowdir=$dirid>$dirname</a>";
?> </td>
        </tr>
        <?php
}
}
}
?> 
      </table>
      <p>&nbsp;</p>
    </td>
    <td height="413" width="78%"> 
      <table width="100%" border="0" cellspacing="2" cellpadding="0">
        <tr bgcolor="#FF6600"> 
          <td height="21" bgcolor="#0099FF"> 
            <div align="center">以下是該欄目的內容，請進行修改/刪除/移動欄目等操作
              <?php
if($step=="move"){
if($cc=="刪除"){
$msql->query("delete from auto_con where id='$id' and userid='$AUTOUSERID'");
$save_directory = "comimg/";
  			$savefile=$save_directory.$id.".jpg";
		if(file_exists($savefile)){
  			unlink($savefile);
		}
}elseif($cc=="↓"){
	$msql->query("update auto_con set xuhao=xuhao+1 where id='$id' and userid='$AUTOUSERID'");
}elseif($cc=="↑"){
	$msql->query("update auto_con set xuhao=xuhao-1 where id='$id' and userid='$AUTOUSERID'");
}else{
$msql->query("select dirid from auto_dir where dirid='$todir' and ifson!='1' and userid='$AUTOUSERID' and (mod='1' or mod='2')");
if($msql->next_record()){
}else{
sendback("欄目選擇錯誤，請返回");
}
$msql->query("update auto_con set dirid='$todir' where id='$id' and userid='$AUTOUSERID'");
}
}
?>
            </div>
          </td>
        </tr>
        <tr> 
          <td height="21">
            <table width="100%" border="0" cellspacing="0" cellpadding="2">
              <?php
$msql->query("select title, ms1, id from auto_con where dirid='$nowdir' and userid='$AUTOUSERID' order by xuhao asc");
while($msql->next_record()){
$title=$msql->f('title');
$ms1=$msql->f('ms1');
$id=$msql->f('id');

?> 
              <tr bgcolor="#FFCC66"> 
                <td height="21" width="37%"> 
                  <table width="100%" border="0" cellspacing="1" cellpadding="0">
                    <tr bgcolor="#FFFFFF"> 
                      <td height="21"><font color="#C7C9AF">■</font> <?php echo "$title" . '<br>' . $ms1; ?> 
                      </td>
                    </tr>
                  </table>
                  
                </td>
                <form method="post" action="moddetail.php3">
                  <td height="21" width="15%"> 
                    <input type="submit" name="Submit" value="修改">
                    <input type="hidden" name="id" value="<?php echo "$id"; ?>">
                  </td>
                </form>
                <form method="post" action="">
                  <td height="21" colspan="2" width="48%"> 
                    <input type="submit" name="cc" value="刪除">
					<input type="submit" name="cc" value="↑"> 
					<input type="submit" name="cc" value="↓">
                    <input type="submit" name="Submit2" value="移動到">
                    <select name="todir">
                      <?php



for($p=0;$p<$i;$p++){
echo "<option value=$v[$p]>$n[$p]</option>";
}
?> 
                    </select>
                    <input type="hidden" name="step" value="move">
                    <input type="hidden" name="id" value="<?php echo "$id"; ?>">
                  </td>
                </form>
              </tr>
              <?php
}
?> 
            </table>
          </td>
        </tr>
      </table>
      
      <br>
      <table width="300" border="1" cellspacing="2" cellpadding="0" align="center" bordercolor="#333333">
        <tr bgcolor="#FFCC66" align="center" valign="middle"> <?php
if($nowdir!=""){
?> 
          <form method="post" action="addcon1.php3">
            <?php
}else{
?> <?php
echo "<form method=post action=addcon.php3>";
}
?> 
            <td height="65" width="33%"> 
              <input type="submit" name="Submit3" value="新增新的內容">
              <input type="hidden" name="dirid" value="<?php echo "$nowdir"; ?>">
            </td>
          </form>
         
        </tr>
      </table>
      <div align="center"><br>
        &lt;- 如需修改各欄目的內容，在左側選擇欄目名稱</div>
    </td>
  </tr>
</table>
</BODY></HTML>



