<?php
define('EmpireCMSAdmin','1');
require("../../../e/class/connect.php");
require("../../../e/class/functions.php");
$link=db_connect();
$empire=new mysqlquery();
$editor=1;
//驗證用戶
$lur=is_login();
$logininid=(int)$lur['userid'];
$loginin=$lur['username'];
$loginrnd=$lur['rnd'];
$loginlevel=(int)$lur['groupid'];
$loginadminstyleid=(int)$lur['adminstyleid'];
//ehash
$ecms_hashur=hReturnEcmsHashStrAll();
//驗證權限
CheckLevel($logininid,$loginin,$classid,"setsafe");
if($ecms_config['esafe']['openonlinesetting']==0||$ecms_config['esafe']['openonlinesetting']==1)
{
	echo"沒有開啟後台在線配置參數，如果要使用在線配置先修改/e/config/config.php文件的\$ecms_config['esafe']['openonlinesetting']變量設置開啟";
	exit();
}

$enews=$_POST['enews'];
if(empty($enews))
{$enews=$_GET['enews'];}
if($enews)
{
	hCheckEcmsRHash();
	include('setfun.php');
}
if($enews=='SetSafe')
{
	SetSafe($_POST,$logininid,$loginin);
}

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>安全參數配置</title>
<link href="../adminstyle/<?=$loginadminstyleid?>/adminstyle.css" rel="stylesheet" type="text/css">
</head>

<body>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1">
  <tr> 
    <td height="32">位置：<a href="SetSafe.php<?=$ecms_hashur['whehref']?>">安全參數配置</a> 
      <div align="right"> </div></td>
  </tr>
</table>
<form name="setform" method="post" action="SetSafe.php" onSubmit="return confirm('確認設置?');" autocomplete="off">
  <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
  <?=$ecms_hashur['form']?>
  <?php echo heformhash_get('SetSafe'); ?>
    <tr class="header"> 
      <td height="25" colspan="2">安全參數配置 
        <input name="enews" type="hidden" id="enews" value="SetSafe"> </td>
    </tr>
    <tr> 
      <td height="25" colspan="2">後台安全相關配置</td>
    </tr>
    <tr> 
      <td width="17%" height="25" bgcolor="#FFFFFF"> <div align="left">後台登錄認證碼</div></td>
      <td width="83%" height="25" bgcolor="#FFFFFF"> <input name="loginauth" type="password" id="loginauth" value="" size="35"> 
<?php
if($ecms_config['esafe']['loginauth'])
{
	echo'<font color="#FF0000">[已設置]</font>&nbsp;&nbsp;';
}
?>
		<font color="#666666">(如果設置登錄需要輸入此認證碼才能通過，不修改請留空，如果不設置填「null」)</font></td>
    </tr>
    <tr>
      <td height="25" bgcolor="#FFFFFF">後台登錄地址驗證參數變量名</td>
      <td height="25" bgcolor="#FFFFFF"><input name="eloginurlcsvar" type="text" id="eloginurlcsvar" value="<?=$ecms_config['esafe']['eloginurlcsvar']?>" size="35">
秒 <font color="#666666">(由字母和數字組成，需以字母為開頭。空為id)</font></td>
    </tr>
	<tr>
      <td height="25" bgcolor="#FFFFFF">後台登錄地址驗證參數</td>
      <td height="25" bgcolor="#FFFFFF"><input name="eloginurlcs" type="text" id="eloginurlcs" value="<?=$ecms_config['esafe']['eloginurlcs']?>" size="35">
秒 <font color="#666666">(可填寫除「&lt;、&gt;、'、"、&」以外的字符，空為不開啟；設置後，後台訪問地址後面要加「?參數變量名=該參數」)</font></td>
    </tr>
    <tr> 
      <td height="25" bgcolor="#FFFFFF"> <div align="left">後台登錄COOKIE認證碼</div></td>
      <td height="25" bgcolor="#FFFFFF"> <input name="ecookiernd" type="text" id="ecookiernd" value="<?=$ecms_config['esafe']['ecookiernd']?>" size="35"> 
        <input type="button" name="Submit3" value="隨機" onClick="document.setform.ecookiernd.value='<?=make_password(36)?>';"> 
        <font color="#666666">(填寫10~50個任意字符，最好多種字符組合)</font></td>
    </tr>
	<tr> 
      <td height="25" bgcolor="#FFFFFF">後台開啟一次性密碼登錄</td>
      <td height="25" bgcolor="#FFFFFF"> <input type="radio" name="loginonepass" value="1"<?=$ecms_config['esafe']['loginonepass']==1?' checked':''?>>
        開啟 
        <input type="radio" name="loginonepass" value="0"<?=$ecms_config['esafe']['loginonepass']==0?' checked':''?>>
        關閉
      </td>
    </tr>
    <tr> 
      <td height="25" bgcolor="#FFFFFF">後台開啟驗證登錄IP</td>
      <td height="25" bgcolor="#FFFFFF"> <input type="radio" name="ckhloginip" value="1"<?=$ecms_config['esafe']['ckhloginip']==1?' checked':''?>>
        開啟 
        <input type="radio" name="ckhloginip" value="0"<?=$ecms_config['esafe']['ckhloginip']==0?' checked':''?>>
        關閉 <font color="#666666">(如果上網的IP是變動的，不要開啟)</font></td>
    </tr>
    <tr> 
      <td height="25" bgcolor="#FFFFFF">後台啟用SESSION驗證</td>
      <td height="25" bgcolor="#FFFFFF"><input type="radio" name="ckhsession" value="1"<?=$ecms_config['esafe']['ckhsession']==1?' checked':''?>>
        開啟 
        <input type="radio" name="ckhsession" value="0"<?=$ecms_config['esafe']['ckhsession']==0?' checked':''?>>
        關閉 <font color="#666666">(更安全，需空間支持SESSION)</font></td>
    </tr>
    <tr> 
      <td height="25" bgcolor="#FFFFFF">記錄登錄日誌</td>
      <td height="25" bgcolor="#FFFFFF"> <input type="radio" name="theloginlog" value="0"<?=$ecms_config['esafe']['theloginlog']==0?' checked':''?>>
        開啟 
        <input type="radio" name="theloginlog" value="1"<?=$ecms_config['esafe']['theloginlog']==1?' checked':''?>>
        關閉</td>
    </tr>
    <tr> 
      <td height="25" bgcolor="#FFFFFF">記錄操作日誌</td>
      <td height="25" bgcolor="#FFFFFF"> <input type="radio" name="thedolog" value="0"<?=$ecms_config['esafe']['thedolog']==0?' checked':''?>>
        開啟 
        <input type="radio" name="thedolog" value="1"<?=$ecms_config['esafe']['thedolog']==1?' checked':''?>>
        關閉</td>
    </tr>
    <tr>
      <td height="25" bgcolor="#FFFFFF">開啟訪問來源驗證</td>
      <td height="25" bgcolor="#FFFFFF"><select name="ckfromurl" id="ckfromurl">
          <option value="0"<?=$ecms_config['esafe']['ckfromurl']==0?' selected':''?>>不開啟驗證</option>
          <option value="1"<?=$ecms_config['esafe']['ckfromurl']==1?' selected':''?>>開啟前後台驗證</option>
          <option value="2"<?=$ecms_config['esafe']['ckfromurl']==2?' selected':''?>>僅開啟後台驗證</option>
          <option value="3"<?=$ecms_config['esafe']['ckfromurl']==3?' selected':''?>>僅開啟前台驗證</option>
		  <option value="4"<?=$ecms_config['esafe']['ckfromurl']==4?' selected':''?>>開啟前後台驗證(嚴格)</option>
		  <option value="5"<?=$ecms_config['esafe']['ckfromurl']==5?' selected':''?>>僅開啟後台驗證(嚴格)</option>
		  <option value="6"<?=$ecms_config['esafe']['ckfromurl']==6?' selected':''?>>僅開啟前台驗證(嚴格)</option>
        </select>
        <font color="#666666">(設置禁止非本站訪問地址來源)</font></td>
    </tr>
    <tr>
      <td height="25" bgcolor="#FFFFFF">開啟後台來源認證碼</td>
      <td height="25" bgcolor="#FFFFFF"><select name="ckhash" id="ckhash">
        <option value="0"<?=$ecms_config['esafe']['ckhash']==0?' selected':''?>>金剛模式</option>
        <option value="1"<?=$ecms_config['esafe']['ckhash']==1?' selected':''?>>刺蝟模式</option>
        <option value="2"<?=$ecms_config['esafe']['ckhash']==2?' selected':''?>>關閉驗證</option>
      </select>
        <font color="#666666">(推薦啟用「金剛模式」，對外部訪問與提交進行防禦)</font></td>
    </tr>
    <tr>
      <td height="25" bgcolor="#FFFFFF">&nbsp;</td>
      <td height="25" bgcolor="#FFFFFF">訪問變量名：
        <input name="ckhashename" type="text" id="ckhashename" value="<?=$ecms_config['esafe']['ckhashename']?>" size="12">
      ，提交變量名：
      <input name="ckhashrname" type="text" id="ckhashrname" value="<?=$ecms_config['esafe']['ckhashrname']?>" size="12">
      <font color="#666666">(必須字母開頭,並且只能由字母、數字、下劃線組成)</font></td>
    </tr>
	<tr>
      <td height="25" bgcolor="#FFFFFF">後台表單獨立來源認證碼</td>
      <td height="25" bgcolor="#FFFFFF"><select name="ckformhash" id="ckformhash">
        <option value="0"<?=$ecms_config['esafe']['ckformhash']==0?' selected':''?>>開啟</option>
        <option value="1"<?=$ecms_config['esafe']['ckformhash']==1?' selected':''?>>關閉</option>
      </select>
        <font color="#666666">(對外部提交進行防禦，開啟後每個表單都採用獨立認證碼)</font></td>
    </tr>
    <tr>
      <td height="25" bgcolor="#FFFFFF">後台訪問的UserAgent包含</td>
      <td height="25" bgcolor="#FFFFFF"><input name="ckhuagjgecms" type="text" id="ckhuagjgecms" value="<?=$ecms_config['esafe']['ckhuseragent']?>" size="35" autocomplete="off">
        <font color="#666666">(區分大小寫，多個用「||」半角雙豎線隔開，設置後UserAgent信息必須包含這些字符才能訪問後台)</font></td>
    </tr>
    <tr>
      <td height="25" bgcolor="#FFFFFF">後台數據加密組合字符串</td>
      <td height="25" bgcolor="#FFFFFF"><input name="hendatakey" type="text" id="hendatakey" value="<?=$ecms_config['esafe']['hendatakey']?>" size="35">
        <input type="button" name="Submit323" value="隨機" onClick="document.setform.hendatakey.value='<?=make_password(52)?>';">
      <font color="#666666">(填寫30~70個任意字符)</font></td>
    </tr>
    <tr>
      <td height="25" bgcolor="#FFFFFF">前台數據加密組合字符串</td>
      <td height="25" bgcolor="#FFFFFF"><input name="endatakey" type="text" id="endatakey" value="<?=$ecms_config['esafe']['endatakey']?>" size="35">
        <input type="button" name="Submit324" value="隨機" onClick="document.setform.endatakey.value='<?=make_password(52)?>';">
      <font color="#666666">(填寫30~70個任意字符)</font></td>
    </tr>
	<tr> 
      <td width="17%" height="25" bgcolor="#FFFFFF"> <div align="left">整站訪問密碼</div></td>
      <td width="83%" height="25" bgcolor="#FFFFFF"> <input name="viewpass" type="password" id="viewpass" size="35"> 
<?php
if($ecms_config['esafe']['viewpass'])
{
	echo'<font color="#FF0000">[已設置]</font>&nbsp;&nbsp;';
}
?>
		<font color="#666666">(如果設置訪問所有動態頁面需要輸入此密碼才能訪問，不修改請留空，如果不設置填「null」)</font></td>
    </tr>
	 <tr> 
      <td width="17%" height="25" bgcolor="#FFFFFF"> <div align="left">整站訪問密碼驗證變量名</div></td>
      <td width="83%" height="25" bgcolor="#FFFFFF"> <input name="viewpassvar" type="text" id="viewpassvar" value="<?=$ecms_config['esafe']['viewpassvar']?>" size="35"> 
		<font color="#666666">(由字母和數字組成，需以字母為開頭)</font></td>
    </tr>
	<tr> 
      <td width="17%" height="25" bgcolor="#FFFFFF"> <div align="left">後台訪問密碼</div></td>
      <td width="83%" height="25" bgcolor="#FFFFFF"> <input name="hviewpass" type="password" id="hviewpass" value="" size="35"> 
<?php
if($ecms_config['esafe']['hviewpass'])
{
	echo'<font color="#FF0000">[已設置]</font>&nbsp;&nbsp;';
}
?>
		<font color="#666666">(如果設置訪問後台動態頁面需要輸入此密碼才能訪問，不修改請留空，如果不設置填「null」)</font></td>
    </tr>
	 <tr> 
      <td width="17%" height="25" bgcolor="#FFFFFF"> <div align="left">後台訪問密碼驗證變量名</div></td>
      <td width="83%" height="25" bgcolor="#FFFFFF"> <input name="hviewpassvar" type="text" id="hviewpassvar" value="<?=$ecms_config['esafe']['hviewpassvar']?>" size="35"> 
		<font color="#666666">(由字母和數字組成，需以字母為開頭)</font></td>
    </tr>
    <tr> 
      <td height="25" colspan="2">COOKIE配置</td>
    </tr>
    <tr> 
      <td height="25" bgcolor="#FFFFFF">COOKIE作用域</td>
      <td height="25" bgcolor="#FFFFFF"> <input name="cookiedomain" type="text" id="cookiedomain" value="<?=$ecms_config['cks']['ckdomain']?>" size="35">      </td>
    </tr>
    <tr> 
      <td height="25" bgcolor="#FFFFFF">COOKIE作用路徑</td>
      <td height="25" bgcolor="#FFFFFF"><input name="cookiepath" type="text" id="cookiepath" value="<?=$ecms_config['cks']['ckpath']?>" size="35"></td>
    </tr>
    <tr>
      <td height="25" bgcolor="#FFFFFF">後台COOKIE作用域</td>
      <td height="25" bgcolor="#FFFFFF"><input name="cookieadmindomain" type="text" id="cookieadmindomain" value="<?=$ecms_config['cks']['ckadmindomain']?>" size="35"></td>
    </tr>
    <tr>
      <td height="25" bgcolor="#FFFFFF">後台COOKIE作用路徑</td>
      <td height="25" bgcolor="#FFFFFF"><input name="cookieadminpath" type="text" id="cookieadminpath" value="<?=$ecms_config['cks']['ckadminpath']?>" size="35"></td>
    </tr>
    <tr>
      <td height="25" bgcolor="#FFFFFF">COOKIE的HttpOnly屬性</td>
      <td height="25" bgcolor="#FFFFFF"><select name="ckhttponly" id="ckhttponly">
        <option value="0"<?=$ecms_config['cks']['ckhttponly']==0?' selected':''?>>關閉</option>
        <option value="1"<?=$ecms_config['cks']['ckhttponly']==1?' selected':''?>>開啟</option>
        <option value="2"<?=$ecms_config['cks']['ckhttponly']==2?' selected':''?>>只後台開啟</option>
        <option value="3"<?=$ecms_config['cks']['ckhttponly']==3?' selected':''?>>只前台開啟</option>
      </select>      </td>
    </tr>
    <tr>
      <td height="25" bgcolor="#FFFFFF">COOKIE的secure屬性</td>
      <td height="25" bgcolor="#FFFFFF"><select name="cksecure" id="cksecure">
        <option value="0"<?=$ecms_config['cks']['cksecure']==0?' selected':''?>>自動識別</option>
		<option value="1"<?=$ecms_config['cks']['cksecure']==1?' selected':''?>>關閉</option>
        <option value="2"<?=$ecms_config['cks']['cksecure']==2?' selected':''?>>開啟</option>
        <option value="3"<?=$ecms_config['cks']['cksecure']==3?' selected':''?>>只後台開啟</option>
        <option value="4"<?=$ecms_config['cks']['cksecure']==4?' selected':''?>>只前台開啟</option>
      </select>
        <font color="#666666">(開啟需要https支持)</font></td>
    </tr>
    <tr> 
      <td height="25" bgcolor="#FFFFFF">前台COOKIE變量前綴</td>
      <td height="25" bgcolor="#FFFFFF"><input name="cookievarpre" type="text" id="cookievarpre" value="<?=$ecms_config['cks']['ckvarpre']?>" size="35"> 
        <font color="#666666">(由英文字母組成,5~12個字符組成)</font></td>
    </tr>
    <tr> 
      <td height="25" bgcolor="#FFFFFF">後台COOKIE變量前綴</td>
      <td height="25" bgcolor="#FFFFFF"><input name="cookieadminvarpre" type="text" id="cookieadminvarpre" value="<?=$ecms_config['cks']['ckadminvarpre']?>" size="35"> 
        <font color="#666666">(由英文字母組成,5~12個字符組成)</font></td>
    </tr>
    <tr> 
      <td height="25" bgcolor="#FFFFFF">COOKIE驗證隨機碼</td>
      <td height="25" bgcolor="#FFFFFF"> <input name="cookieckrnd" type="text" id="cookieckrnd" value="<?=$ecms_config['cks']['ckrnd']?>" size="35"> 
        <input type="button" name="Submit32" value="隨機" onClick="document.setform.cookieckrnd.value='<?=make_password(36)?>';"> 
        <font color="#666666">(填寫10~50個任意字符，最好多種字符組合)</font></td>
    </tr>
    <tr>
      <td height="25" bgcolor="#FFFFFF">COOKIE驗證隨機碼2</td>
      <td height="25" bgcolor="#FFFFFF"><input name="cookieckrndtwo" type="text" id="cookieckrndtwo" value="<?=$ecms_config['cks']['ckrndtwo']?>" size="35">
        <input type="button" name="Submit322" value="隨機" onClick="document.setform.cookieckrndtwo.value='<?=make_password(36)?>';">
        <font color="#666666">(填寫10~50個任意字符，最好多種字符組合)</font></td>
    </tr>
    <tr>
      <td height="25" bgcolor="#FFFFFF">COOKIE驗證隨機碼3</td>
      <td height="25" bgcolor="#FFFFFF"><input name="cookieckrndthree" type="text" id="cookieckrndthree" value="<?=$ecms_config['cks']['ckrndthree']?>" size="35">
        <input type="button" name="Submit3222" value="隨機" onClick="document.setform.cookieckrndthree.value='<?=make_password(36)?>';">
        <font color="#666666">(填寫10~50個任意字符，最好多種字符組合)</font></td>
    </tr>
    <tr>
      <td height="25" bgcolor="#FFFFFF">COOKIE驗證隨機碼4</td>
      <td height="25" bgcolor="#FFFFFF"><input name="cookieckrndfour" type="text" id="cookieckrndfour" value="<?=$ecms_config['cks']['ckrndfour']?>" size="35">
        <input type="button" name="Submit32222" value="隨機" onClick="document.setform.cookieckrndfour.value='<?=make_password(36)?>';">
        <font color="#666666">(填寫10~50個任意字符，最好多種字符組合)</font></td>
    </tr>
    <tr>
      <td height="25" bgcolor="#FFFFFF">COOKIE驗證隨機碼5</td>
      <td height="25" bgcolor="#FFFFFF"><input name="cookieckrndfive" type="text" id="cookieckrndfive" value="<?=$ecms_config['cks']['ckrndfive']?>" size="35">
        <input type="button" name="Submit322222" value="隨機" onClick="document.setform.cookieckrndfive.value='<?=make_password(36)?>';">
        <font color="#666666">(填寫10~50個任意字符，最好多種字符組合)</font></td>
    </tr>
    <tr> 
      <td height="25" bgcolor="#FFFFFF"></td>
      <td height="25" bgcolor="#FFFFFF"> <input type="submit" name="Submit" value=" 設 置 "> 
        &nbsp;&nbsp;&nbsp; <input type="reset" name="Submit2" value="重置"></td>
    </tr>
  </table>
</form>
<br>
</body>
</html>
<?php
db_close();
$empire=null;
?>