<?php
require "../../Run.php";
if($admin != 1&&$admin !=2){
	ehtml("权限不足");
	exit;
}
echo head("注册短信设置");
if($_GET['cfg'] == 'yes')
{	
$wapid = WAPID;
	if(getMessCfg($wapid) == FALSE)
	{
	$sql = "INSERT INTO message_cfg(title,content,siteid,send) VALUES ('{$_POST["title"]}','{$_POST["content"]}','{$wapid}','{$_POST['send']}');";
	if(intosql($sql) == TRUE){
		echo '<div class="tip">成功创建配置文件</div>';
	}else{
		echo '<div class="tip">创建配置文件失败</div>';
		}
	}else{
	$sql = "UPDATE message_cfg SET title='{$_POST['title']}',content='{$_POST['content']}',send='{$_POST['send']}' WHERE siteid='{$wapid}'";
	if(intosql($sql) == TRUE){
		echo '<div class="tip">成功修改配置文件</div>';
	}else{
		echo '<div class="tip">修改配置文件失败</div>';
		}
	}
}
echo '<div class="title">首次注册短信配置</div>';
echo  '<form method="post" action="?cfg=yes">';
echo '<div class="content">';
echo '<br>短信标题<br>';
echo '<input name="title" type="text" value="'.getMessCfg('title').'">';
echo '<br>短信内容<br>';
echo '<input name="content" type="text" value="'.getMessCfg('content').'">';
echo '<br>是否发送，yes为发送否则为不发送<br>';
echo '<input name="send" type="text" value="'.getMessCfg('send').'"><br>';
echo '<input  type="submit" value="保存设置">';
echo '</div>';
echo '</form>';
echo '<div class="mylink">';
echo '<a href="http://'.HTTP_HOST.'/admin/wap_admin.php?">管理后台</a>';
echo '</div>';
echo footer(1);
?>