<?php

session_start();
require_once "../init.php";
require_once "../authority.inc.php";
if($edit==1){
	
	if(!file_exists("../../com_data/UploadFiles")) mkdir("../../com_data/UploadFiles");
	$savepath = "../../com_data/UploadFiles";
	//如果删除旧Logo
    if($DelOldLogo){
	   if($OldLogo){
		  $delpath = "../../com_data/UploadFiles/$OldLogo";
		  @unlink($delpath);
		  $plus .= "Logo='',";
		  $_POST[Logo]='';
	   }
	}
	//保存Logo
	if($_FILES['Logo'][size]>10){
	  //删除旧文件
	  if($OldLogo){
		  $delpath = "../../com_data/UploadFiles/$OldLogo";
		  @unlink($delpath);
	  }
	  $upload1 = SaveUploadFile($_FILES['Logo'],$savepath,"gif,jpeg,png,flash");
	  if($upload1['succ']==1){
		  $plus .= "Logo='".$upload1['filename']."',";
		  $_POST[Logo]=$upload1['filename'];
		  $mess .= "上传 ".$_FILES[Logo][name]." 成功<br>";
	  }else{
		 $mess .= "上传 ".$_FILES[Logo][name]." 失败，原因：".$upload1['msg']."<br>";
	  }
	}
	//如果删除旧 Banner
    if($DelOldBanner){
	   if($OldBanner){
		  $delpath = "../../com_data/UploadFiles/$OldBanner";
		  @unlink($delpath);
		  $plus .= "Banner='',";
		  $_POST[Banner]='';
	   }
	}
	//保存Banner
	if($_FILES['Banner'][size]>10){
	  //删除旧文件
	  if($OldBanner){
		  $delpath = "../../com_data/UploadFiles/$OldBanner";
		  @unlink($delpath);
	  }
	  $upload2 = SaveUploadFile($_FILES['Banner'],$savepath,"gif,jpeg,png,flash");
	  if($upload2['succ']==1){
		  $plus .= "Banner='".$upload2['filename']."',";
		  $_POST[Banner]=$upload2['filename'];
		  $mess .= "上传 ".$_FILES[Banner][name]." 成功<br>";
	  }else{
		 $mess .= "上传 ".$_FILES[Banner][name]." 失败，原因：".$upload2['msg']."<br>";
	  }
	}

	//更新数据库
	foreach ($_POST as $key => $val)
    {
		if($key=="aPassword" && !$val) continue;
        $sql = "UPDATE config SET value = '" . trim($val) . "' WHERE code = '" . $key . "'";
        $db->query($sql);
    }
	clear_tpl_files();
	
	$mess .= "<font color='green'><b> 平台设定已被更新 </b></font>";
	echo $mess;
}
//重新读取会员设定
$AgentInfo = load_config(1);
?>
<script language="javascript">
	function checkform(form){ 
		if(form.aUserName.value==''){
			alert("请输入用户名");
			form.aUserName.focus();
			return false;
		}
		if(form.aPassword.value != form.aPasswordC.value){
			alert("密码与确认密码不一致");
			form.aPassword.focus();
			return false;
		}
		if(form.SmtpServer.value==''){
			alert("请输入smtp服务器");
			form.SmtpServer.focus();
			return false;
		}
		if(form.SmtpUser.value==''){
			alert("请输入邮箱用户名");
			form.SmtpUser.focus();
			return false;
		}
		if(form.SmtpPW.value==''){
			alert("请输入邮箱密码");
			form.SmtpPW.focus();
			return false;
		}
		if(form.SmtpSender.value==''){
			alert("请输入发件人邮箱地址");
			form.SmtpSender.focus();
			return false;
		}
	}
</script>

<link rel="stylesheet" type="text/css" href="/admin/static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="/admin/lib/Hui-iconfont/1.0.7/iconfont.css" />
<link rel="stylesheet" type="text/css" href="/admin/lib/icheck/icheck.css" />
<link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/css/style.css" />
<link rel="stylesheet" type="text/css" href="/admin/edittpl/css/jquery.bigcolorpicker.css" />
<script type="text/javascript" src="/admin/edittpl/js/jquery-1.12.3.min.js"></script>
<script type="text/javascript" src="/admin/edittpl/js/jquery.bigcolorpicker.min.js"></script>

<script type="text/javascript">
$(function(){
	$("#c1").bigColorpicker("c1");
	$("#btn").bigColorpicker("c2");
	$("#img").bigColorpicker(function(el,color){
		$(el).css("background-color",color);
	});
	$(".ku").bigColorpicker(function(el,color){
		$(el).css("background-color",color);
	});
	$("#c5").bigColorpicker("c5","L",6);
});
</script>
	<form class="form form-horizontal" id="form-article-add" action="agent_set.php" method="post" enctype="multipart/form-data" onsubmit="return checkform(this)">
<div id="tab-system" class="HuiTab">
			<div class="tabBar cl"><span>基本信息</span><span>SEO设置</span><span>邮件设置</span><span>前台设置</span></div>


			<div class="tabCon">
<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>平台网址：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input type="text" id="website-title" name="API_WEB_URL"  value='<?=$AgentInfo['API_WEB_URL']?>' placeholder="如：http://www.baidu.com" value="" class="input-text">
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>公司名称：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input type="text" id="website-title" name="Company"  value='<?=$AgentInfo['Company']?>' placeholder="控制在25个字、50个字节以内" value="" class="input-text">
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2">联系电话：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input name="Tel" type="text" value='<?=$AgentInfo['Tel']?>' id="website-Keywords" placeholder="填写电话号码"  class="input-text">
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2">传真：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input name="Fax" type="text" value='<?=$AgentInfo['Fax']?>'  id="website-description" placeholder="填写电话号码" value="" class="input-text">
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2">E-Mail：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input name="Email" type="text" value='<?=$AgentInfo['Email']?>' id="website-static" placeholder="如：post@yinxi.net" value="" class="input-text">
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2">邮编：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input name="Zip" type="text" value='<?=$AgentInfo['Zip']?>' id="website-uploadfile" placeholder="" value="" class="input-text">
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2">地址：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input name="Addr" type="text" value='<?=$AgentInfo['Addr']?>' id="website-copyright" placeholder="&copy; 2016 H-ui.net" value="" class="input-text">
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2">备案号：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input name="ICP" type="text" value='<?=$AgentInfo['ICP']?>' id="website-icp" placeholder="京ICP备00000000号" value="" class="input-text">
					</div>
				</div>



<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>会员级别名称：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input name="AgentType" type="text" value='<?=$AgentInfo['AgentType']?>' id="website-uploadfile" placeholder="*请使用,号分隔(一至六)" class="input-text">*请使用,号分隔(一至六)
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2">公司简介：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<textarea class="textarea" name='Intro'><?=$AgentInfo['Intro']?></textarea>
					</div>
				</div>


<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2">付款方式：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<textarea rows='8' class='textarea' cols='90' name='Payway'><?=$AgentInfo['Payway']?></textarea>
					</div>
				</div>






			</div>
			<div class="tabCon">
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2">网站标题：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<textarea class="textarea" name="SiteTitle" ><?=$AgentInfo['SiteTitle']?></textarea>
					</div>
				</div>

<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2">网站关键字：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<textarea class="textarea" name="Keywords" ><?=$AgentInfo['Keywords']?></textarea>
					</div>
				</div>

	<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2">启用GZIP压缩：</label>
					<div class="formControls col-xs-8 col-sm-9">
					<select name="enable_gzip" class="select">
		<option value="1"<?=$AgentInfo['enable_gzip']?" selected":""?>>启用</option>
		<option value="0"<?=!$AgentInfo['enable_gzip']?" selected":""?>>禁止</option>
		</select>
		<br/>提示:必须服务器支持gzip才能使用该功能
					</div>
				</div>






			</div>
			<div class="tabCon">



				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2">SMTP服务器：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input name="SmtpServer" type="text" value='<?=$AgentInfo['SmtpServer']?>' class="input-text">
					</div>
				</div>
				
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2">邮箱用户：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input name="SmtpUser" type="text" value='<?=$AgentInfo['SmtpUser']?>'  class="input-text"  id="emailName"  >
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2">邮箱密码：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input type="password" id="email-password" name="SmtpPW" type="password" value='<?=$AgentInfo['SmtpPW']?>' class="input-text">
					</div>
				</div>

<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2">密码确认：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input  class="input-text" name="SmtpPW2" type="password" value='<?=$AgentInfo['SmtpPW']?>' >
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2">发件人邮箱：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input name="SmtpSender" type="text" value='<?=$AgentInfo['SmtpSender']?>' id="email-address" class="input-text">
					</div>
				</div>
			</div>
			<div class="tabCon">
				
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2">页面模板：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<select name='Skin' class='select'>
				<?
				$handel = opendir("../../skin");
				while($dirname = readdir($handel)){
					if($dirname=='.' || $dirname=='..') continue;
					if(!is_dir("../../skin/$dirname")) continue;
					if(strpos($dirname,"_bak")>0) continue;//2011-3-21
					$sel = $dirname == $AgentInfo['Skin']?"selected":"";
					echo "<option value='$dirname' $sel >$dirname</option>";
				}
				?>
			</select>
					</div>
				</div>



<div class="row cl"> 

					<label class="form-label col-xs-4 col-sm-2">页面宽度：</label>
					<div class="formControls col-xs-8 col-sm-9">
		 <input name="pagewidth" type="text" value="<?=$AgentInfo['pagewidth']?>">
	可以按模板宽度不修改，如有需要可自行设置如：1200px
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2">网站Logo：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input name="Logo" type="file" class="inputline">(如不修改请不能上传,只能上传图片文件或flash文件)
		 <input name="OldLogo" type="hidden" value="<?=$AgentInfo['Logo']?>">
		 <input name="DelOldLogo" id="DelOldLogo" type="checkbox" value="1" onchange="this.form.Logo.disabled = this.checked "> <label for='DelOldLogo'><font color='red'>删除 logo 图片</font></label>
		 <? 
		 	if($AgentInfo['Logo']){
			 	$src = "../../com_data/UploadFiles/".$AgentInfo['Logo'];
		   	
					if(preg_match("/(.swf)$/i",$AgentInfo['Logo'])){
			
			  		$imagesize = getimagesize($src);
			  		echo "<br><embed src='$src' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='$imagesize[0]' height='$imagesize[1]'></embed>";
		   		}
				else
				{
			  		echo "<br><img src='$src'><br><br>";
		   		}
		 	}
			else
			{
				$src = '';
				//默认模板
				$src = "../../skin/".$AgentInfo['Skin']."/resources/logo.png";
				$html = "<br><img src='$src'><br><br>";
				echo $html;
			}
		 ?>		
					</div>
	</div>

	<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2">页面背景：</label>
					<div class="formControls col-xs-8 col-sm-9">
					<input name="Banner" type="file" class="inputline">(如不修改请不能上传,只能上传图片文件)
		<input name="OldBanner" type="hidden" value="<?=$AgentInfo['Banner']?>">
		 <input name="DelOldBanner" id="DelOldBanner" type="checkbox" value="1" onchange="this.form.Banner.disabled = this.checked "> <label for='DelOldBanner'><font color='red'>删除 背景图片</font></label>
		<?if($AgentInfo['Banner']){
			 $src = "../../com_data/UploadFiles/".$AgentInfo['Banner'];
		 if(preg_match("/(.swf)$/i",$AgentInfo['Banner'])){
			
		
			  $imagesize = getimagesize($src);
			  echo "<br><embed src='$src' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='$imagesize[0]' height='$imagesize[1]'></embed>";
		   }else{
			  echo "<br><img src='$src'><br><br>";
		   }
		 }?>	
					</div>
				</div>



<div class="row cl"> 

					<label class="form-label col-xs-4 col-sm-2">背景重复：</label>
					<div class="formControls col-xs-8 col-sm-9">
				<select name="bg_repeat" class="select">
		<option value="no-repeat" <? if($AgentInfo['bg_repeat']=="no-repeat"){echo 'selected';}?>>不重复</option>
		<option value="repeat" <? if($AgentInfo['bg_repeat']=="repeat"){echo 'selected';}?>>重复</option>
		<option value="repeat-x" <? if($AgentInfo['bg_repeat']=="repeat-x"){echo 'selected';}?>>横向重复</option>
		<option value="repeat-y" <? if($AgentInfo['bg_repeat']=="repeat-y"){echo 'selected';}?>>众向重复</option>

		</select>
	
					</div>
				</div>


<div class="row cl"> 

					<label class="form-label col-xs-4 col-sm-2">背景颜色：</label>
					<div class="formControls col-xs-8 col-sm-9">
			<input style="background:<?=$AgentInfo['bg_color']?>" class="jscolor input-text" name="bg_color" id="c1" value="<?=$AgentInfo['bg_color']?>">
			<a onclick="clearcolor();">[清除颜色]</a> 
					</div>
				</div>


<script>
	function clearcolor(){
document.getElementById("c1").value="";
}
</script>






<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2">开启手机版：</label>
					<div class="formControls col-xs-8 col-sm-9">
				<select name="show_mobile" class="select">
		<option value="1"<?=$AgentInfo['show_mobile']?" selected":""?>>启用</option>
		<option value="0"<?=!$AgentInfo['show_mobile']?" selected":""?>>禁止</option>
		</select>
		
					</div>
				</div>


<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2">启用QQ登录：</label>
					<div class="formControls col-xs-8 col-sm-9">
				<select name="show_qq" class="select">
		<option value="1"<?=$AgentInfo['show_qq']?" selected":""?>>启用</option>
		<option value="0"<?=!$AgentInfo['show_qq']?" selected":""?>>禁止</option>
		</select>
		
					</div>
				</div>


<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2">QQ-APPID：</label>
					<div class="formControls col-xs-8 col-sm-9">
									<input name="appid" type="text" value='<?=$AgentInfo['appid']?>' id="website-static" placeholder="QQ开放平台申请到的appid"  class="input-text">
		
					</div>
				</div>


<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2">QQ-appkey：</label>
					<div class="formControls col-xs-8 col-sm-9">
					<input name="appkey" type="text" value='<?=$AgentInfo['appkey']?>' id="website-static" placeholder="QQ开放平台申请到的appkey"  class="input-text">
		
					</div>
				</div>






<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2">启用QQ客服：</label>
					<div class="formControls col-xs-8 col-sm-9">
				<select name="show_qq_kefu" class=select>
		<option value="1"<?=$AgentInfo['show_qq_kefu']?" selected":""?>>启用</option>
		<option value="0"<?=!$AgentInfo['show_qq_kefu']?" selected":""?>>禁止</option>
		</select>
		[<a href="/admin/qq/qq_list.php"  target="_blank">设置客服号码</a>]
		
					</div>
					
				</div>

		
		


<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2">QQ客服面板位置：</label>
					<div class="formControls col-xs-8 col-sm-9">
				<select name="qq_weizi" class="select">
		<option value="1%"<?=$AgentInfo['qq_weizi']=="1%"?" selected":""?>>左边</option>
		<option value="92%"<?=$AgentInfo['qq_weizi']=="92%"?" selected":""?>>右边</option>
		</select>
	
					</div>
				</div>





<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2">支付宝快捷登录：</label>
					<div class="formControls col-xs-8 col-sm-9">
				<select name="iisp_zfb_show" class="select">
		<option value="1"<?=$AgentInfo['iisp_zfb_show']?" selected":""?>>启用</option>
		<option value="0"<?=!$AgentInfo['iisp_zfb_show']?" selected":""?>>禁止</option>
		</select>
		
					</div>
				</div>


<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2">支付宝商家ID：</label>
					<div class="formControls col-xs-8 col-sm-9">
									<input name="alipay_partner" type="text" value='<?=$AgentInfo['alipay_partner']?>' id="website-static" placeholder="支付宝签约商家ID"  class="input-text">
		
					</div>
				</div>


<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2">支付宝商家密钥：</label>
					<div class="formControls col-xs-8 col-sm-9">
					<input name="alipay_key" type="text" value='<?=$AgentInfo['alipay_key']?>' id="website-static" placeholder="支付宝签约商家密钥"  class="input-text">
		
					</div>
				</div>




	</div>


		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
<input name="edit" type="hidden" value="1">
			<input name="type" type="hidden" value="all">
				<button name="submit" type="submit" class="btn btn-primary radius" ><i class="Hui-iconfont">&#xe632;</i> 保存</button>
				<button name="reset" type="reset"  class="btn btn-default radius" >&nbsp;&nbsp;重置&nbsp;&nbsp;</button>

			</div>
		</div>

	</form>

