<!--#
##
#	Project: PHPDISK File Storage Solution
#	This is NOT a freeware, use is subject to license terms.
#
#	Site: http://www.phpdisk.com
#
#	$Id: admin.tpl.php 145 2015-08-01 06:06:46Z along $
#
#	Copyright (C) 2008-2016 PHPDisk Team. All Rights Reserved.
#
##
#-->
<!--#
if($action =='add_site' || $action =='edit_site'){
#-->
<div id="container">
<!--#if($action =='add_site'){#-->
<h1>添加SSO子网站</h1>
<!--#}else{#-->
<h1>编辑SSO子网站</h1>
<!--#}#-->
<div>
<div class="tips_box"><img class="img_light" src="images/light.gif" align="absmiddle" /> <b><?=__('tips')?>: </b>
<span class="txtgray">请确认您添加的SSO子网站能正常访问，并能与主网站正常通信成功。</span>
</div>
<form action="{#urr(ADMINCP,"item=plugins&menu=plugin&app=$app")#}" method="post" onsubmit="return dosubmit(this);">
<input type="hidden" name="action" value="{$action}" />
<input type="hidden" name="task" value="{$action}" />
<input type="hidden" name="id" value="{$id}" />
<input type="hidden" name="formhash" value="{$formhash}" />
<table align="center" width="100%" cellpadding="4" cellspacing="0" border="0" class="td_line">
<tr>
	<td width="30%"><span class="bold">标识名称:</span><br /><span class="txtgray"></span></td>
	<td><input type="text" name="subject" value="{$p[subject]}" maxlength="50" /></td>
</tr>
<tr>
	<td><span class="bold">SSO子网站网址:</span><br /><span class="txtgray"></span></td>
	<td><input type="text" name="site_url" value="{$p[site_url]}" size="40" maxlength="100" /></td>
</tr>
<tr>
	<td><span class="bold">SSO子网站密钥:</span><br /><span class="txtgray"></span></td>
	<td><input type="text" name="site_key" id="site_key" value="{$p[site_key]}" maxlength="30" />&nbsp;<input type="button" value="<?=__('make_random')?>" class="btn" onclick="make_code();" /></td>
</tr>
<tr>
	<td><span class="bold">是否启用子网站:</span><br /><span class="txtgray"></span></td>
	<td><input type="radio" name="site_status" value="0" {#ifchecked(0,$p[site_status])#} /><?=__('yes')?>&nbsp;&nbsp;<input type="radio" name="site_status" value="1" {#ifchecked(1,$p[site_status])#} /><?=__('no')?></td>
</tr>
<tr>
	<td>&nbsp;</td>
	<td><input type="submit" class="btn" id="s1" value="<?=__('btn_submit')?>"/>&nbsp;&nbsp;<input type="button" class="btn" value="<?=__('btn_back')?>" onclick="javascript:history.back();" /></td>
</tr>
</table>
</form>
</div>
</div>
<script language="javascript">
function dosubmit(o){
	if(o.subject.value.strtrim().length <2){
		atips("请填写标识名称");
		o.subject.focus();
		return false;
	}
	if(o.site_url.value.strtrim().length <6){
		atips("请填写SSO子网站网址");
		o.site_url.focus();
		return false;
	}
	if(o.site_key.value.strtrim() == ''){
		atips("请填写通信SSO子网站通信密钥");
		o.site_key.focus();
	}
	getId('s1').disabled = true;
	getId('s1').value = "<?=__('txt_processing')?>";
}
function make_code(){
   var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
   var tmp = "";
   var code = "";
   for(var i=0;i<12;i++){
	   code += chars.charAt(Math.ceil(Math.random()*100000000)%chars.length);
   }
   getId('site_key').value = code;
}
<!--#if($action =='add_site'){#-->
make_code();
<!--#}#-->
</script>
<!--#}elseif($action=='sso_log'){#-->
<div id="container">
<h1>网站单点登录整合管理</h1>
<div>
<div class="tips_box"><img class="img_light" src="images/light.gif" align="absmiddle" /> <b><?=__('tips')?>: </b>
<span class="txtgray">相应的SSO子网站也需要密钥一至同时通信成功</span>
</div>
<div class="search_box">
<a href="{#urr(ADMINCP,"item=plugins&menu=$menu&app=$app")#}" id="n_">配置管理</a>&nbsp;&nbsp;
<a href="{#urr(ADMINCP,"item=plugins&menu=$menu&app=$app&action=sso_log")#}" id="n_sso_log">错误记录</a>&nbsp;&nbsp;
</div>
<script type="text/javascript">getId('n_{$action}').className = 'sel_a';</script>
<table align="center" width="100%" cellpadding="4" cellspacing="0" border="0" class="td_line">
<!--#
if(count($logs)){
#-->
<tr>
	<td class="bold" width="150">所在网站</td>
	<td class="bold">行为</td>
	<td align="center" width="150" class="bold">日志时间</td>
	<td align="center" class="bold">操作IP</td>
	<td align="center" class="bold" width="50%">错误参数</td>
</tr>
<!--#
	foreach($logs as $k => $v){
		$color = ($k%2 ==0) ? 'color1' :'color4';
#-->
<tr class="{$color}">

	<td>{$v['site']}</td>
	<td>{$v['action']}</td>
	<td>{$v['intime']}</td>
	<td align="center" class="txtgray">{$v['ip']}</td>
	<td align="center" class="txtgray">{$v['param']}</td>
</tr>	
<!--#
	}
	unset($logs);
#-->
<!--#if($page_nav){#-->
<tr>
	<td colspan="6">{$page_nav}</td>
</tr>
<!--#}#-->
<tr>
	<td colspan="6">
	<input type="button" class="btn" onclick="if(confirm('确认清空所有？')){go('{#urr(ADMINCP,"item=plugins&menu=plugin&app=$app&action=$action&task=del_log_all")#}');}" value="一键清空日志"/>
	</td>
</tr>
<!--#	
}else{	
#-->
<tr>
	<td align="center" colspan="6">暂无日志</td>
</tr>
<!--#
}
#-->
</table>
</div>
</div>
<!--#}else{#-->
<script type="text/javascript">
function ping_ss(id,url){
	$.getJSON(url,function(cb){
		if(cb.success){
			$('#ss_'+id).html('<span class="txtgreen">'+cb.msg+'</span>');
		}else{
			$('#ss_'+id).html('<span class="txtred">'+cb.msg+'</span>');
		}
	});
}
</script>
<div id="container">
<h1>网站单点登录整合管理</h1>
<div>
<div class="tips_box"><img class="img_light" src="images/light.gif" align="absmiddle" /> <b><?=__('tips')?>: </b>
<span class="txtgray">相应的SSO子网站也需要密钥一至同时通信成功</span>
</div>
<div class="search_box">
<a href="{#urr(ADMINCP,"item=plugins&menu=$menu&app=$app")#}" id="n_">配置管理</a>&nbsp;&nbsp;
<a href="{#urr(ADMINCP,"item=plugins&menu=$menu&app=$app&action=sso_log")#}" id="n_sso_log">错误记录</a>&nbsp;&nbsp;
</div>
<script type="text/javascript">getId('n_{$action}').className = 'sel_a';</script>
<form action="{#urr(ADMINCP,"item=plugins&menu=plugin&app=$app")#}" method="post">
<input type="hidden" name="action" value="{$action}"/>
<input type="hidden" name="task" value="update"/>
<input type="hidden" name="formhash" value="{$formhash}" />
<table align="center" width="100%" cellpadding="4" cellspacing="0" border="0" class="td_line">
<tr>
	<td width="30%"><span class="bold">开启SSO整合登录</span>: <br /><span class="txtgray"></span></td>
	<td><input type="radio" name="setting[open_sso]" value="1" {#ifchecked(1,$settings['open_sso'])#}/><?=__('yes')?>&nbsp;&nbsp;<input type="radio" name="setting[open_sso]" value="0" {#ifchecked(0,$settings['open_sso'])#}/><?=__('no')?></td>
</tr>
<tr>
	<td><span class="bold">SSO整合属性</span>: <br /><span class="txtgray">此网站作为SSO的主网站或子网站</span></td>
	<td><input type="radio" name="setting[is_sso_main]" value="1" {#ifchecked(1,$settings['is_sso_main'])#}/>作为主网站&nbsp;&nbsp;<input type="radio" name="setting[is_sso_main]" value="0" {#ifchecked(0,$settings['is_sso_main'])#}/>作为子网站</td>
</tr>
</table>
<!--#if($settings['is_sso_main']){#-->
<fieldset><legend></legend>
<table align="center" width="100%" cellpadding="4" cellspacing="0" border="0" class="td_line">
<tr>
	<td colspan="10" class="bold">SSO子网站列表:</td>
</tr>
<!--#
if(count($site_arr)){
#-->
<tr>
	<td width="200">标识名称</td>
	<td>子网站地址</td>
	<td>通信状态</td>
	<td align="right" width="100"><?=__('operation')?></td>
</tr>
<!--#
	foreach($site_arr as $k => $v){
		$color = ($k%2==0) ? 'color1' : 'color4';
#-->
<tr class="{$color}">
	<td>{$v['subject']}</td>
	<td>{$v['site_url']}</td>
	<td><span id="ss_{$v[id]}"><img src="images/ajax_loading.gif" align="absmiddle" border="0" /></span><script type="text/javascript">ping_ss({$v[id]},'{$v[a_test_site]}')</script></td>
	<td align="right">
	<a href="{$v['a_edit_site']}" id="p_{$k}"><img src="images/menu_edit.gif" align="absmiddle" border="0" /></a>
	<div id="c_{$k}" class="menu_box2 menu_common">
	<a href="{$v['a_edit_site']}"><?=__('modify')?></a>
	<a href="javascript:;" onclick="aconfirm('确认删除此SSO子网站吗？','{$v['a_del_site']}');"><?=__('delete')?></a>
	</div>
	<script type="text/javascript">on_menu('p_{$k}','c_{$k}','-x','');</script>
	</td>
</tr>
<!--#
	}
	unset($site_arr);
}else{	
#-->
<tr>
	<td colspan="10" align="center">暂无记录</td>
</tr>
<!--#
}
#-->
<tr>
	<td colspan="10"><input type="button" class="btn" value="添加SSO子网站" onclick="go('{#urr(ADMINCP,"item=plugins&menu=plugin&app=$app&action=add_site")#}');" /></td>
</tr>
</table>
</fieldset>
<!--#}else{#-->
<fieldset><legend></legend>
<table align="center" width="100%" cellpadding="4" cellspacing="0" border="0" class="td_line">
<tr>
	<td width="30%" class="bold">需要连接的主网站网址：</td>
	<td><input type="text" name="setting[sso_main_site_url]" value="{$settings[sso_main_site_url]}"  size="40" /></td>
</tr>
<tr>
	<td class="bold">与主网站配置的通信密钥：</td>
	<td><input type="text" name="setting[sso_main_site_key]" value="{$settings[sso_main_site_key]}" /></td>
</tr>
</table>
</fieldset>
<!--#}#-->
<table align="center" width="100%" cellpadding="4" cellspacing="0" border="0" class="td_line">
<tr>
	<td width="30%">&nbsp;</td>
	<td><input type="submit" class="btn" value="<?=__('btn_submit')?>"/>&nbsp;&nbsp;<input type="button" class="btn" value="<?=__('btn_back')?>" onclick="javascript:history.back();" /></td>
</tr>
</table>
</form>
</div>
</div>
<!--#
}
#-->
