<?php
/*
	[Phpup.Net!] (C)2009-2011 Phpup.net.
	This is NOT a freeware, use is subject to license terms

	$Id: admin.class.php 2010-08-24 10:42 $
*/

if(!defined('IN_PHPUP')) {
	exit('Access Denied');
}
?>
<?php include ROOT_PATH.'/views/admin/header.php';?>
<body>
<div class="subnav">
    <div class="content-menu ib-a blue line-x">
        <A HREF="index.php?con=<?php echo $GLOBALS['setting']['adminpath'];?>&act=site"class="on"><em>网站管理</em></A>
	</div>
</div>
<div id="man_zone">
<SCRIPT LANGUAGE="JavaScript">
<!--
	var data=new Array();
	data[0]='';

	<?php 
	$checked=array();
	foreach($GLOBALS['apirep'] as $k=>$v)
	{
		if(!empty($site['apikey']) && ($site['apikey']==$k))
		{
			$checked[$k]='selected';
		}
	 }?>
	function changerep(id)
	{
		if(id!='')
		{
			$('#showapirep').hide();
		}
		else
		{
			$('#showapirep').show();
		}
	}

	function checkform(theform)
	{
		if(theform.sitename.value=='')
		{
			alert('网站名不能为空');
			return false;
		}
		if(theform.pinyin.value=='')
		{
			alert('开头字母不能为空');
			return false;
		}
		if(theform.sitecity.value=='')
		{
			alert('开通城市不能为空');
			return false;
		}
		if(theform.siteurl.value=='')
		{
			alert('网站地址不能为空');
			return false;
		}
		if(theform.siteapi.value=='')
		{
			alert('网站API地址不能为空');
			return false;
		}
		if(theform.apikey.value=='')
		{
			if(theform.apirep.value=='')
			{
				alert('API规则不能为空');
				return false;
			}
		}
		
	}
	function checkapi()
	{
		if($('#siteapi').val())
		{
			url=site_root+"/models/checkapi.php?url="+$('#siteapi').val();
			$.get(url,{},
			function(data){
				if(data)
				{
					if(data=='QQ团')
					{
						alert('建议hao123/百度采集规则或QQ团规则');
					}
					else
					{
						alert(data);
					}
				}
			});
		}
		else
		{
			alert('请在采集API地址中填定相应规则，多城市采集请填写其中一个城市的api');
		}
	}
//-->
</SCRIPT>
<FORM METHOD="POST" ACTION="index.php?con=admin&act=sitemodify"  enctype="multipart/form-data" onsubmit="return checkform(this);">
<INPUT TYPE="hidden" NAME="updateid" value="<?php echo $site['id'];?>">



<STYLE TYPE="text/css">
	
	.morecitys{display:none;}
</STYLE>
<INPUT TYPE="hidden" NAME="commit" value="1">
<table width="100%" border="0" align="center"  cellpadding="3" cellspacing="1" class="table_form">
<tbody>
<tr>
<th width="120px"><span>网站名：</span></th>
<td><INPUT TYPE="text" class="input-text" NAME="sitename"  value="<?php echo $site['sitename'];?>"></td>
</tr>
<tr>
<th width="120px"><span>LOGO：</span></th>
<td><INPUT TYPE="file" NAME="logo">
<?php if($site['logo']){?>
<img src="<?php echo $site['logo'];?>" style="width:100px;"/>
<?php }?>
</td>
</tr>
<tr>
<th width="120px">
字体颜色：</th><td><SELECT NAME="css[color]">
<OPTION VALUE="">选择颜色</option>
	<OPTION VALUE="#ff0000" style="background:#ff0000;">#ff0000</option>
	<OPTION VALUE="#339900" style="background:#339900;">#339900</option>
	<OPTION VALUE="#3300FF" style="background:#3300FF;">#3300FF</option>
	<OPTION VALUE="#990000" style="background:#990000;">#990000</option>
	<OPTION VALUE="#FFFF00" style="background:#FFFF00;">#FFFF00</option>
	<OPTION VALUE="#FF9900" style="background:#FF9900;">#FF9900</option>
	<OPTION VALUE="#660000" style="background:#660000;">#660000</option>
</SELECT>
<input type="checkbox" name="css[font-weight]" value="bold">加粗  <?php if($site['css']){?><span style="<?php echo $site['css'];?>">已有样式</span><?php }?></td>
</tr>
<tr>
<th width="120px"><span>开头字母：</span></th>
<td>
<input type="text" name="pinyin" style="text-transform:capitalize;" value="<?php echo $site['pinyin'];?>">

</td>
</tr>

<th width="120px"><span>Email：</span></th>
<td><INPUT TYPE="text" class="input-text" NAME="email" size="40" value="<?php echo $site['email'];?>"></td>
</tr>
<!--
<tr>
<th width="120px"><span>QQ：</span></th>
<td><INPUT TYPE="text" class="input-text" NAME="qq" size="40" value=""></td>
</tr>
<tr>
<tr>
<th width="120px"><span>MSN：</span></th>
<td><INPUT TYPE="text" class="input-text" NAME="msn" size="40" value=""></td>
</tr>
-->
<tr>
<th width="120px"><span>联系电话：</span></th>
<td><INPUT TYPE="text" class="input-text" NAME="tel" size="40" value="<?php echo $site['tel'];?>"></td>
</tr>

<!--
<tr>
<th width="120px"><span>所属类别：</span></th>
<td>
<SELECT NAME="sitetype">
	
	< foreach($GLOBALS['sitecate'] as $k=>$v){?>
	<option value="< echo $k;?>" < if($site['sitetype']==$k){?>selected< }?>>< echo $v['sitecatename'];?></option>
	< }?>
	<option value="0">未分类</option>
</SELECT>
</td>
</tr>
-->

<tr>
<th width="120px"><span>网站URL：</span></th>
<td><INPUT TYPE="text" class="input-text" NAME="siteurl" size="40" value="<?php echo $site['siteurl'];?>"></td>
</tr>

<tr>
<th width="120px"><span>采集API地址：</span></th>
<td>
<INPUT TYPE="text" class="input-text" NAME="siteapi" id="siteapi" size="40" value="<?php echo $site['siteapi'];?>"><input type="button" value="检测api" onclick="checkapi();" class="button"> 多城市采集请填写其中一个城市的api,如：http://www.meituan.com/api/v2/<b style="color:#ff0000;">beijing</b>/deals</td>
</tr>
<tr>
<th width="120px"><span>API类型：</span></th>
<td>

<SELECT name="apikey" onchange="changerep(this.value);" id="apikey">
	<OPTION VALUE="">自定义</option>
	<?php foreach($GLOBALS['apirep'] as $k=>$v){?>
	<OPTION VALUE="<?php echo $k;?>" <?php echo $checked[$k];?>><?php echo $v[0];?></option>
	<?php }?>
</SELECT>
</td>
</tr>
<tr id="showapirep">
<th width="120px"><span>API规则：</span></th>
<td><textarea  NAME="apirep" id="apirep" class="input-texta" style="height:100px;width:450px;">
<?php echo $site['apirep'];?>
</textarea></td>
</tr>

<tr>
<th width="120px"><span>是否推荐：</span></th>
<td>
<SELECT NAME="recommend">
		<option value="0" <?php if($site['recommend']==0){?>selected<?php }?>>不推荐</option>
		<option value="1" <?php if($site['recommend']==1){?>selected<?php }?>>推荐</option>
</SELECT>
</td>
</tr>
<tr>
<th width="120px"><span>是否允许采集：</span></th>
<td>
<SELECT NAME="isallowed">
		<option value="0" <?php if($site['isallowed']==0){?>selected<?php }?>>不允许</option>
		<option value="1" <?php if($site['isallowed']==1){?>selected<?php }?>>允许</option>
	</SELECT>
</td>
</tr>
<tr>
<th width="120px"><span>网站权重：</span></th>
<td>
<select name="level">
	<?php if($site['level']){?><option value="<?php echo $site['level'];?>" selected><?php echo $GLOBALS['level'][$site['level']];?></option><?php }?>
	<?php foreach($GLOBALS['level'] as $k=>$v){?>
		<option value="<?php echo $k;?>"><?php echo $v;?></option>
	<?php }?>
</select>
</td>
</tr>
<tr>
<th width="120px"><span>信息排序：</span></th>
<td><INPUT TYPE="text" class="input-text" NAME="goodorder" size="40" value="<?php echo $site['goodorder'];?>"></td>
</tr>
<tr>
<th width="120px"><span>自动排序方式：</span></th>
<td>
<input type="radio" value="0" name="gather_method" <?php echo empty($site['gather_method'])?'checked':'';?>> 不使用
<input type="radio" value="all" name="gather_method" <?php echo $site['gather_method']=='all'?'checked':'';?>> 全部
<input type="radio" value="first" name="gather_method" <?php echo $site['gather_method']=='first'?'checked':'';?>> 第一个
<input type="radio" value="last" name="gather_method" <?php echo $site['gather_method']=='last'?'checked':'';?>> 最后一个
</td>
</tr>
<tr>
<th width="120px"><span>开启多城市采集：</span></th>
<td>

<INPUT TYPE="checkbox" id="citys" onclick="$('.morecitys').toggle();"></td>
</tr>
<tr class="morecitys">
<th width="120px"><span>城市列表API地址：</span></th>
<td><INPUT TYPE="text" class="input-text" NAME="cityapi" size="40" value="<?php echo $site['cityapi'];?>"></td>
</tr>
<tr>
<th width="120px"><span>仅限采集城市：</span></th>
<td><INPUT TYPE="text" class="input-text" NAME="limitcity" size="40" value="<?php echo $site['limitcity'];?>"> <span style="color:#ff0000">(确保站点中包含此城市)</span> 不限制请留空,多个城市请以逗号隔开</td>
</tr>
<tr>
<th width="120px"><span>单城市采集数量：</span></th>
<td><INPUT TYPE="text" class="input-text" NAME="limitnum" size="40" value="<?php echo $site['limitnum'];?>"> 为0时为不限制</td>
</tr>
<tr class="morecitys">
<th width="120px"><span>城市列表采集规则：</span></th>
<td><textarea  NAME="cityrep" id="cityrep" class="input-texta" style="height:50px;width:300px;"><?php echo $site['cityrep'];?></textarea></td>
</tr>
<tr class="morecitys">
<th width="120px"><span>多城市API：</span></th>
<td><INPUT TYPE="text" class="input-text" NAME="citysiteapi" size="60" value="<?php echo $site['citysiteapi'];?>"><br/> 如:http://www.meituan.com/api/v2/<SPAN style="color:#ff0000">beijing</SPAN>/deals 替换为 http://www.meituan.com/api/v2/<SPAN style="color:blue">+cityid+</SPAN>/deals <br/>也可使用汉字名称如： http://open.client.lashou.com/api/detail/city/<SPAN style="color:#ff0000">北京</SPAN>/p/1/r/10 替换为 http://open.client.lashou.com/api/detail/city/<SPAN style="color:blue">+cityname+</SPAN>/p/1/r/10 </td>
</tr>
<?php if($site['citysiteapi'] && $site['cityrep'] && $site['cityapi']){?>
<SCRIPT LANGUAGE="JavaScript">
<!--
	$('#citys').attr('checked',true);
	$('.morecitys').show();
//-->
</SCRIPT>
<?php }?>



<tr>
<td colspan="4" align="center"><INPUT TYPE="submit" value="提交" class="button"></td>
</tr>
</tbody>
</table>
</FORM>
<SCRIPT LANGUAGE="JavaScript">
<!--
	changerep($('#apikey').val());
//-->
</SCRIPT>
</div>
</body>
</html>