<?php
include "conn.php";
checkLogin("系统管理");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>管理区域</title>
<link rel="stylesheet" href="css/common.css" type="text/css" />
<script language="javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/js.js"></script>
<style>
#jmbox{
    overflow:auto;zoom:1;margin-top:5px;
}
.jmlabel{
    float:left;
    width:70px;text-align:right;
    height:22px;line-height:22px;
    font-size:14px;font-weight:bold;
    color:#0099CC;padding-right:4px
}
.txt1{float:left;}
.txtbox{width:820px;height:50px;color: #666;}
.w726{
    width:726px;
}
</style>
</head>

<body>
<div id="man_zone">
<?php
$act = $_GET['act'] ?? '';
if ($act == "save") {
    $webname = $_POST['webname'] ?? '';
    $keywords = $_POST['keywords'] ?? '';
    $description = $_POST['description'] ?? '';
    $indexwebname = $_POST['indexwebname'] ?? '';
    $copyright = $_POST['copyright'] ?? '';

    $query = "SELECT webname, keywords, description, indexwebname, copyright FROM inc WHERE id=1";
    $result = $conn->query($query);
    
    if ($result->num_rows > 0) {
        $sql = "UPDATE inc SET 
                webname = '$webname',
                keywords = '$keywords',
                description = '$description',
                indexwebname = '$indexwebname',
                copyright = '$copyright'
                WHERE id = 1";
    } else {
        $sql = "INSERT INTO inc (webname, keywords, description, indexwebname, copyright) 
                VALUES ('$webname', '$keywords', '$description', '$indexwebname', '$copyright')";
    }
    
    $conn->query($sql);
    echo "<script>alert('更新成功');top.location.href='index.php'</script>";
    exit;
}
?>
    <form name="form1" method="post" action="?act=save">
    <table width="100%" border="0" cellpadding="3" cellspacing="1" class="table1">
        <tbody>
            <tr>
                <th width="15%">网站名称</th>
                <td><input type="text" id="webname" name="webname" value="<?php echo textEncode($webname); ?>" class="txt1" /></td>
            </tr>
            <tr>
                <th width="15%">网站首页title</th>
                <td><input type="text" id="indexwebname" name="indexwebname" value="<?php echo textEncode($indexwebname); ?>" class="txt1" /></td>
            </tr>
            <tr>
                <th width="15%">网站默认关键词</th>
                <td><input type="text" id="keywords" name="keywords" value="<?php echo textEncode($webkeywords); ?>" class="txt1" /></td>
            </tr>
            <tr>
                <th width="15%">网站默认描述</th>
                <td><input type="text" id="description" name="description" value="<?php echo textEncode($webdescription); ?>" class="txt1" /></td>
            </tr>
            <tr>
                <th width="15%">版权信息</th>
                <td><input type="text" id="copyright" name="copyright" value="<?php echo textEncode($copyright); ?>" class="txt1" /></td>
            </tr>        
            <tr>
                <th></th>
                <td><input type="submit" name="save" id="save" value="确定" class="btn1" /> <input type="reset" name="save" id="save" value="重置" class="btn1" /></td>
            </tr>
        </tbody>
    </table>
    </form>
</div>
</body>
</html>