<?php
include_once("htui_header.php");
include_once("../classes/images.php");  //生成缩略图
include_once("../common/watermark.php");//图片添加水印

if (!empty($_POST)){

   if (!check_permission($_SESSION["a_uid"],'siteconfig.php',2)){
        $response_arr = array("status" => -1,"message"  => '对不起,您无权限操作!');
		echo json_encode($response_arr);
        exit;
   }

   $id=intval($_POST["id"]);
   $site_name=flc_request(trim($_POST["site_name"]));
   $site_key=flc_request(trim($_POST["site_key"]));
   $site_desc=flc_request(trim($_POST["site_desc"]));
   $site_icp=flc_request(trim($_POST["site_icp"]));
   $site_filesize=flc_request($_POST["site_filesize"]);
   $site_num=intval($_POST["site_num"]);
   $site_url=flc_request(trim($_POST["site_url"]));

   $index_cate_num=intval($_POST["index_cate_num"]);
   $site_admin_num=intval($_POST["site_admin_num"]);
   $site_filetype=flc_request($_POST["site_filetype"]);
   
   $downoff=intval($_POST["downoff"]);
   $html_flag=intval($_POST["html_flag"]);
   $linkoff=intval($_POST["linkoff"]);
   
   /*
   $alipay_id=flc_request($_POST["alipay_id"]);
   $alipay_key=flc_request($_POST["alipay_key"]);
   $alipay_email=flc_request($_POST["alipay_email"]);
   $notify_url=flc_request($_POST["notify_url"]);
   $return_url=flc_request($_POST["return_url"]);
   */
   
   $smtpoff=intval($_POST["smtpoff"]);
   $smtpserver=flc_request($_POST["smtpserver"]);
   $smtpusermail=flc_request($_POST["smtpusermail"]);
   $smtpport=intval($_POST["smtpport"]);
   $openssl=intval($_POST["openssl"]);
   $smtppass=flc_request($_POST["smtppass"]);
   
   $baidu_api=flc_request($_POST["baidu_api"]);
   $baidu_token=flc_request($_POST["baidu_token"]);

   $reset_pwd=flc_request($_POST["reset_pwd"]);
   
   $category_parentid=intval($_GET["category_parentid"]);
   $category_id=intval($_GET["category_id"]);
   
   $sql="update {$tablepre}siteconfig set site_name='".$site_name."',site_icp='".$site_icp."',site_url='".$site_url."',site_key='".$site_key."',
        site_desc='".$site_desc."',site_filesize='".$site_filesize."',site_num='".$site_num."',index_cate_num='".$index_cate_num."',
        site_admin_num='".$site_admin_num."',site_filetype='".$site_filetype."',downoff=".$downoff.",smtpoff=".$smtpoff.",
        html_flag=".$html_flag.",linkoff=".$linkoff.",smtpserver='".$smtpserver."',smtpusermail='".$smtpusermail."',smtpport='".$smtpport."',
        openssl='".$openssl."',smtppass='".$smtppass."',baidu_api='".$baidu_api."',baidu_token='".$baidu_token."',reset_pwd='".$reset_pwd."' where id=".$id;  
   $db->exec($sql);

   $response_arr = array("status" => 1,"message"  => '参数配置修改成功!');
   echo json_encode($response_arr);
   exit;
}

$sql="select * from {$tablepre}siteconfig order by id desc limit 1"; 
$myrow = $db->get_row($sql);
?>
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>后台管理中心-飞天素材网</title>
<meta name="author" content="ftsucai.com">
<link href="../css/bootstrap.min.css" rel="stylesheet">
<link href="../css/fonts.css" rel="stylesheet">
<link href="../css/htstyle.css" rel="stylesheet">
<link href="../js/bootstrap-datepicker/bootstrap-datepicker3.min.css" rel="stylesheet">
<link href="../js/bootstrap-colorpicker/css/bootstrap-colorpicker.min.css" rel="stylesheet">
</head>
  
<body>

    <!--页面主要内容-->
    <main class="ftdms-layout-content">
      
      <div class="container-fluid" style="margin-bottom:90px;">
        
        <div class="row" style="margin-top:15px;">
          <div class="col-lg-12">
            <div class="card">
              <div class="card-header"><h4>修改参数配置</h4></div>
              <div class="card-body" style="padding:5px 20px;">
                
                <form class="form-horizontal" action="" method="post" id="form">

				  <div class="form-group">
                    <label class="col-xs-12" for="site_name">网站名称</label>
                    <div class="col-xs-12">
                      <input class="form-control" type="text" id="site_name" name="site_name" value="<?php echo $myrow['site_name'];?>">
                    </div>
                  </div>

				  <div class="form-group">
                    <label class="col-xs-12" for="site_url">网站网址</label>
                    <div class="col-xs-12">
                      <input class="form-control" type="text" id="site_url" name="site_url" value="<?php echo $myrow['site_url'];?>">
                    </div>
                  </div>

				  <div class="form-group">
                    <label class="col-xs-12" for="site_icp">备案序号</label>
                    <div class="col-xs-12">
                      <input class="form-control" type="text" id="site_icp" name="site_icp" value="<?php echo $myrow['site_icp'];?>">
                    </div>
                  </div>

				  <div class="form-group">
                    <label class="col-xs-12" for="site_key">网站关键字</label>
                    <div class="col-xs-12">
                      <input class="form-control" type="text" id="site_key" name="site_key" value="<?php echo $myrow['site_key'];?>">
                    </div>
                  </div>

				  <div class="form-group">
                    <label class="col-xs-12" for="site_desc">网站描述</label>
                    <div class="col-xs-12">
					   <input class="form-control" type="text" id="site_desc" name="site_desc" value="<?php echo $myrow['site_desc'];?>">
                    </div>
                  </div>

                  <div class="form-group">
                    <label class="col-xs-12" for="reset_pwd">重置默认密码</label>
                    <div class="col-xs-12">
					  <input class="form-control" type="text" id="reset_pwd" name="reset_pwd" value="<?php echo $myrow['reset_pwd'];?>">
                    </div>
                  </div>

				  <div class="form-group">
                    <label class="col-xs-12" for="statcode">统计代码</label>
                    <div class="col-xs-12">
					  <input class="form-control" type="text" id="statcode" name="statcode" value="<?php echo $myrow['statcode'];?>">
                    </div>
                  </div>

                  <div class="form-group">
                    <label class="col-xs-12" for="site_filesize">上传文件最大值(M)</label>
                    <div class="col-xs-12">
                      <input class="form-control" type="text" id="site_filesize" name="site_filesize" value="<?php echo $myrow['site_filesize'];?>">
                    </div>
                  </div>

				  <div class="form-group">
                    <label class="col-xs-12" for="site_filetype">允许上传的文件类型(多种类型用“|”线分开)</label>
                    <div class="col-xs-12">
                      <input class="form-control" type="text" id="site_filetype" name="site_filetype" value="<?php echo $myrow['site_filetype'];?>">
                    </div>
                  </div>

				  <div class="form-group">
                    <label class="col-xs-12" for="site_num">前台列表每页显示数</label>
                    <div class="col-xs-12">
                      <input class="form-control" type="text" id="site_num" name="site_num" value="<?php echo $myrow['site_num'];?>">
                    </div>
                  </div>

				  <div class="form-group">
                    <label class="col-xs-12" for="site_admin_num">后台列表每页显示数</label>
                    <div class="col-xs-12">
                      <input class="form-control" type="text" id="site_admin_num" name="site_admin_num" value="<?php echo $myrow['site_admin_num'];?>">
                    </div>
                  </div>

				  <div class="form-group">
                    <label class="col-xs-12" for="index_cate_num">首页各分类显示数</label>
                    <div class="col-xs-12">
                      <input class="form-control" type="text" id="index_cate_num" name="index_cate_num" value="<?php echo $myrow['index_cate_num'];?>">
                    </div>
                  </div>

				  <div class="form-group">
                    <label class="col-xs-12" for="downoff">登录后才允许下载</label>
					<div class="col-xs-12">
						<label class="ftdms-radio radio-inline radio-primary">
						<input type="radio" name="downoff" value="1" <?php if ($myrow['downoff']==1){?>checked<?php }?>><span>开启</span>
						</label>
						<label class="ftdms-radio radio-inline radio-primary">
						<input type="radio" name="downoff" value="0" <?php if ($myrow['downoff']==0){?>checked<?php }?>><span>关闭</span>
						</label>
					</div>
                  </div>

				  <div class="form-group">
                    <label class="col-xs-12" for="html_flag">伪静态开关</label>
					<div class="col-xs-12">
						<label class="ftdms-radio radio-inline radio-primary">
						<input type="radio" name="html_flag" value="1" <?php if ($myrow['html_flag']==1){?>checked<?php }?>><span>开启</span>
						</label>
						<label class="ftdms-radio radio-inline radio-primary">
						<input type="radio" name="html_flag" value="0" <?php if ($myrow['html_flag']==0){?>checked<?php }?>><span>关闭</span>
						</label>
					</div>
                  </div>

				  <div class="form-group">
                    <label class="col-xs-12" for="linkoff">防盗链开关</label>
					<div class="col-xs-12">
						<label class="ftdms-radio radio-inline radio-primary">
						<input type="radio" name="linkoff" value="1" <?php if ($myrow['linkoff']==1){?>checked<?php }?>><span>开启</span>
						</label>
						<label class="ftdms-radio radio-inline radio-primary">
						<input type="radio" name="linkoff" value="0" <?php if ($myrow['linkoff']==0){?>checked<?php }?>><span>关闭</span>
						</label>
					</div>
                  </div>

                  <div class="form-group">
                    <label class="col-xs-12" for="smtpoff">帐号激活认证</label>
					<div class="col-xs-12">
						<label class="ftdms-radio radio-inline radio-primary">
						<input type="radio" name="smtpoff" value="1" <?php if ($myrow['smtpoff']==1){?>checked<?php }?>><span>开启</span>
						</label>
						<label class="ftdms-radio radio-inline radio-primary">
						<input type="radio" name="smtpoff" value="0" <?php if ($myrow['smtpoff']==0){?>checked<?php }?>><span>关闭</span>
						</label>
					</div>
                  </div>

				  <div class="form-group">
                    <label class="col-xs-12" for="smtpserver">邮箱服务器</label>
                    <div class="col-xs-12">
                      <input class="form-control" type="text" id="smtpserver" name="smtpserver" value="<?php echo $myrow['smtpserver'];?>">
                    </div>
                  </div>

				  <div class="form-group">
                    <label class="col-xs-12" for="smtpusermail">发送的邮箱</label>
                    <div class="col-xs-12">
                      <input class="form-control" type="text" id="smtpusermail" name="smtpusermail" value="<?php echo $myrow['smtpusermail'];?>">
                    </div>
                  </div>

				  <div class="form-group">
                    <label class="col-xs-12" for="smtpport">服务器端口</label>
                    <div class="col-xs-12">
                      <input class="form-control" type="text" id="smtpport" name="smtpport" value="<?php echo $myrow['smtpport'];?>">
                    </div>
                  </div>

				  <div class="form-group">
                    <label class="col-xs-12" for="openssl">openssl开关</label>
                    <div class="col-xs-12">
                      <label class="ftdms-radio radio-inline radio-primary">
						<input type="radio" name="openssl" value="1" <?php if ($myrow['openssl']==1){?>checked<?php }?>><span>开启</span>
						</label>
						<label class="ftdms-radio radio-inline radio-primary">
						<input type="radio" name="openssl" value="0" <?php if ($myrow['openssl']==0){?>checked<?php }?>><span>关闭</span>
					 </label>
                    </div>
                  </div>

				  <div class="form-group">
                    <label class="col-xs-12" for="smtppass">邮箱的密码</label>
                    <div class="col-xs-12">
                      <input class="form-control" type="password" id="smtppass" name="smtppass" value="<?php echo $myrow['smtppass'];?>">
                    </div>
                  </div>

				  <div class="form-group">
                    <label class="col-xs-12" for="baidu_api">百度搜索接口</label>
                    <div class="col-xs-12">
                      <input class="form-control" type="text" id="baidu_api" name="baidu_api" value="<?php echo $myrow['baidu_api'];?>">
                    </div>
                  </div>

				  <div class="form-group">
                    <label class="col-xs-12" for="baidu_token">百度token</label>
                    <div class="col-xs-12">
                      <input class="form-control" type="text" id="baidu_token" name="baidu_token" value="<?php echo $myrow['baidu_token'];?>">
                    </div>
                  </div>
                  
                  <div class="form-group">
                    <div class="col-xs-12">
                       <input type="hidden" name="id" id="id" value="<?php echo $myrow['id'];?>">
					   <button class="btn btn-primary" type="button" id="submit">确认修改</button>
                    </div>
                  </div>
                </form>
				<br>
                
              </div>
            </div>
          </div>
          
        </div>
        
      </div>
      
    </main>
    <!--End 页面主要内容-->
<script src="../js/jquery.min.js"></script>
<script src="../js/bootstrap.js"></script>
<script src="../js/perfect-scrollbar.min.js"></script>
<script src="../js/main.min.js"></script>
<script src="../js/bootstrap-notify.min.js"></script>
<script src="../js/tips.js"></script>
<script>
$("#submit").click(function(){

    $.post("siteconfig.php", $("#form").serialize(), function(data) {
		var rs  = eval('('+data+')');
        if(rs.status==1){
           tips.notify(rs.message, 'success', 200, 'ftsucai-name', 'top', 'center');
		}else{
		   tips.notify(rs.message, 'danger', 200);
		}
    });
	
});
</script>
</body>
</html>