<?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,"public");

//設置手機短信參數
function eSetPhm($add,$userid,$username){
	global $empire,$dbtbpre;
	CheckLevel($userid,$username,$classid,"public");//驗證權限
	$phmmax=(int)$add['phmmax'];
	$phmdaymax=(int)$add['phmdaymax'];
	$phmonemax=(int)$add['phmonemax'];
	$phmretime=(int)$add['phmretime'];
	$phmlen=(int)$add['phmlen'];
	$phmouttime=(int)$add['phmouttime'];
	$phmtog=(int)$add['phmtog'];
	$phmopen=(int)$add['phmopen'];
	$phmern=(int)$add['phmern'];
	$phmmust=(int)$add['phmmust'];
	$phmreg=(int)$add['phmreg'];
	$phmckst=(int)$add['phmckst'];
	$phmlgtoreg=(int)$add['phmlgtoreg'];
	$phmckrnd=hRepPostStr($add['phmckrnd'],1,1);
	//允許的操作
	$phmdo='';
	$phmdock=$add['phmdock'];
	$phmdock=eCheckEmptyArray($phmdock);
	$phmdocount=count($phmdock);
	if($phmdocount)
	{
		$phmdo=',';
		for($pdi=0;$pdi<$phmdocount;$pdi++)
		{
			$phmdo.=$phmdock[$pdi].',';
		}
	}
	$phmdo=hRepPostStr($phmdo,1,1);
	
	$sql=$empire->query("update {$dbtbpre}enewspublicadd set phmmax='$phmmax',phmdaymax='$phmdaymax',phmonemax='$phmonemax',phmretime='$phmretime',phmlen='$phmlen',phmouttime='$phmouttime',phmtog='$phmtog',phmopen='$phmopen',phmern='$phmern',phmmust='$phmmust',phmreg='$phmreg',phmdo='$phmdo',phmckst='$phmckst',phmckrnd='$phmckrnd',phmlgtoreg='$phmlgtoreg'".do_dblimit_upone());
	if($sql)
	{
		GetConfig();
		//操作日誌
		insert_dolog("");
		printerror("SetPhmSuccess","SetPhm.php".hReturnEcmsHashStrHref2(1));
	}
	else
	{printerror("DbError","history.go(-1)");}
}


$enews=$_POST['enews'];
if(empty($enews))
{$enews=$_GET['enews'];}
if($enews)
{
	hCheckEcmsRHash();
}
if($enews=="SetPhm")//設置參數
{
	eSetPhm($_POST,$logininid,$loginin);
}
else
{}

$r=$empire->fetch1("select * from {$dbtbpre}enewspublicadd".do_dblimit_one());

?>
<!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"><p>位置：手機短信設置</p>
    </td>
  </tr>
</table>
<form name="setpublic" method="post" action="SetPhm.php" onSubmit="return confirm('確認設置?');">
  <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
  <?=$ecms_hashur['form']?>
  <?php echo heformhash_get('SetPhm'); ?>
    <tr class="header"> 
      <td height="25" colspan="2">手機短信設置 
        <input name="enews" type="hidden" value="SetPhm"></td>
    </tr>
    
    <tr bgcolor="#FFFFFF">
      <td width="19%" height="25">開啟短信接口：</td>
      <td width="81%"><input name="phmopen" type="checkbox" id="phmopen" value="1"<?=$r['phmopen']==1?' checked':''?>>
        開啟</td>
    </tr>
	
	<tr bgcolor="#FFFFFF">
	  <td height="25">關閉的模塊：</td>
	  <td>
	  <input name="phmdock[]" type="checkbox" id="phmdock[]" value="login"<?=strstr($r['phmdo'],',login,')?' checked':''?>>
	  登錄
      <input name="phmdock[]" type="checkbox" id="phmdock[]" value="reg"<?=strstr($r['phmdo'],',reg,')?' checked':''?>>
	  註冊
      <input name="phmdock[]" type="checkbox" id="phmdock[]" value="bind"<?=strstr($r['phmdo'],',bind,')?' checked':''?>>
	  綁定手機
	  <input name="phmdock[]" type="checkbox" id="phmdock[]" value="delb"<?=strstr($r['phmdo'],',delb,')?' checked':''?>>
	  取消綁定手機</td>
    </tr>
	<tr bgcolor="#FFFFFF">
      <td height="25">手機註冊會員：</td>
      <td><select name="phmreg" id="phmreg">
        <option value="0"<?=$r['phmreg']==0?' selected':''?>>關閉</option>
        <option value="1"<?=$r['phmreg']==1?' selected':''?>>需填寫用戶名和密碼</option>
        <option value="2"<?=$r['phmreg']==2?' selected':''?>>只需填寫手機號</option>
      </select></td>
    </tr>
	<tr bgcolor="#FFFFFF">
      <td height="25">登錄時自動註冊會員：</td>
      <td><input name="phmlgtoreg" type="checkbox" id="phmlgtoreg" value="1"<?=$r['phmlgtoreg']==1?' checked':''?>>
        啟用 <font color="#666666">(登錄時，如果手機號不存在，則自動註冊會員)</font></td>
    </tr>

    <tr bgcolor="#FFFFFF">
      <td height="25">驗證碼字符數：</td>
      <td><input name="phmlen" type="text" id="phmlen" value="<?=$r['phmlen']?>" size="38">
        位</td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td height="25">驗證碼字符組成：</td>
      <td><select name="phmtog" id="phmtog">
        <option value="0"<?=$r['phmtog']==0?' selected':''?>>數字</option>
        <option value="1"<?=$r['phmtog']==1?' selected':''?>>字母</option>
        <option value="2"<?=$r['phmtog']==2?' selected':''?>>數字+字母</option>
      </select></td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td height="25">驗證碼超時時間：</td>
      <td><input name="phmouttime" type="text" id="phmouttime" value="<?=$r['phmouttime']?>" size="38">
        秒</td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td height="25">每天最大發送數：</td>
      <td><input name="phmdaymax" type="text" id="phmdaymax" value="<?=$r['phmdaymax']?>" size="38">
        條短信<font color="#666666">(0為不限)</font></td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td height="25">單人每天發送數：</td>
      <td><input name="phmonemax" type="text" id="phmonemax" value="<?=$r['phmonemax']?>" size="38">
條短信<font color="#666666">(0為不限)</font></td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td height="25">短信發送間隔時間：</td>
      <td><input name="phmretime" type="text" id="phmretime" value="<?=$r['phmretime']?>" size="38">
秒<font color="#666666">(0為不限)</font></td>
    </tr>
	<tr bgcolor="#FFFFFF">
      <td height="25">表單超時時間：</td>
      <td><input name="phmckst" type="text" id="phmckst" value="<?=$r['phmckst']?>" size="38">
        秒<font color="#666666">(0為不啟用，從頁面打開到發送短信時間間隔)</font></td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td height="25">表單超時驗證隨機碼：</td>
      <td>
	  <input name="phmckrnd" type="text" id="phmckrnd" value="<?=$r['phmckrnd']?>" size="38">
	    <font color="#666666">
	    <input type="button" name="Submit3222" value="隨機" onClick="document.setpublic.phmckrnd.value='<?=make_password(46)?>';">
      (填寫10~50個任意字符，最好多種字符組合)</font>
	  </td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td height="25">綁定手機後自動實名：</td>
      <td><input name="phmern" type="checkbox" id="phmern" value="1"<?=$r['phmern']==1?' checked':''?>>
        是 <font color="#666666">(選擇後將不能取消手機綁定，只能更改綁定)</font></td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td height="25">強制綁定手機：</td>
      <td><input name="phmmust" type="checkbox" id="phmmust" value="1"<?=$r['phmmust']==1?' checked':''?>>
        是 <font color="#666666">(設置後會員登錄會轉向綁定手機頁面) </font></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25">&nbsp;</td>
      <td height="25"><input type="submit" name="Submit" value="提交"> <input type="reset" name="Submit2" value="重置"></td>
    </tr>
  </table>
</form>
<br>
</body>
</html>
<?php
db_close();
$empire=null;
?>