{template 'member','header'}
<script type="text/javascript">
<?php
sajax_show_javascript();
?>
function codedocheck(){
    strcode = $('checkcodestr').value;
	x_codedocheck(strcode,codedocheck_cb);

function codedocheck_cb(z) {
    if(z == "true")
	{
	$('checkcodestr').style.backgroundColor="green";
	$('checkcodestr').style.color="white";
	}
	else
	{
	window.alert("验证码输入错误，请检查！");
	$('checkcodestr').style.backgroundColor="";
	$('checkcodestr').style.color="";
	$("imgaecode").src="{HS_PATH}checkcode.php?id='+Math.random()*5";
	}
}
}

function doCheck(){

	{if $MOD['check_code']}
	if ($('checkcodestr').value=='') {
		alert("请输入验证码！");
		$('checkcodestr').focus();
		return false;
	}
	{/if}
	
	if ($('catid').value=='0'){
		alert('指定的栏目不允许添加图片！只允许在其子栏目中添加图片。');
		$('catid').focus();
		return false;
	}
	if ($('title').value=='') {
		alert('请填写文章标题！');
        $('title').focus();
		return false;
	}
	if ($('copyfrom').value=='') {
		alert('请填所在服务器！');
        $('copyfrom').focus();
		return false;
	}
	if ($('author').value=='') {
		alert('请填写游戏昵称！');
        $('author').focus();
		return false;
	}
	
	if ($('pictureurls').value=='') {
		alert('请上传图片或填写远程图片地址！');
        $('pictureurls').focus();
		return false;
	}
	
	if ($('content').value=='') {
		alert('请填写图片说明！');
        $('content').focus();
		return false;
	}


}


function ShowPreview(){
var obj = $('pictureurls');
var r = document.selection.createRange();
var s = "TMP";
var rt = r.text;
var rv = rt+s;
r.text = rt+s;
var i = obj.value.indexOf(rv);
obj.value = obj.value.replace(s, '');
obj.blur();
var str;
if(obj.value.indexOf("\r") == -1){
	str = "\n";
}else{
	str = "\r\n";
}
var p = obj.value.substring(obj.value.lastIndexOf("|", i)+1, i)+obj.value.substring(i, obj.value.indexOf(str, i));
var l = obj.value.substring(i, obj.value.length);
if(l.indexOf("\n")==-1) p = obj.value.substring(obj.value.lastIndexOf("|", i)+1, i)+l;
var u = <?php echo "'";echo imgurl($HS['uploaddir'].'/'.$CHA['channeldir'].'/'.$MOD['upload_dir'].'/');echo "'"; ?>;
if(p.indexOf("://") != -1) u = '';
var m = p.match(/^[^\r\n\|]+\.(jpg|gif|png|bmp)$/);
if(m != null)
{
	window.open(u+p);
}
}

</script>
<DIV class=main>
<DIV class=main>
{template 'member','left_post'}
<DIV class="ad_rbarB boxC">

{if $action=='add'}
<DIV class=columnC><SPAN class="l_tit f_l">发布图片</SPAN></DIV>
<DIV class=mainboxD>
<TABLE class=regform cellSpacing=0 cellPadding=0 width="100%" align=center 
border=0>
  <TBODY>
<form action="{$HS[siteurl]}{$CHA[channeldir]}/myitem.php?action=add" method="post" name="myform" onsubmit="return doCheck();">
  <TR>
    <TH><font color=#FF0000>提示：</font> </TH>
    <TD colSpan=2><input type="hidden" name="catid" value="{$catid}"> <font color=#FF0000>请务必认真填写，信息一经通过审核，将无法修改！</font></TD></TR>
	 {if $MOD['check_code']}
  <TR>
    <TH>验证码： </TH>
    <TD colSpan=2><input onBlur="codedocheck()" class="inputC" name="checkcodestr" type="text" id="checkcodestr" value=""> 
	<img src="<?=HS_PATH?>checkcode.php" id="imgaecode" onclick="this.src='{HS_PATH}checkcode.php?id='+Math.random()*5;" style="cursor:pointer;" alt="验证码,看不清楚?请点击刷新验证码" align="absmiddle"/> 
	
	</TD>
	</TR>
	{/if}
  <TR>
    <TH>标题： </TH>
    <TD colSpan=2><input class="inputT" name="title" type="text" id="title" maxlength="30"> </TD></TR>
	<TR>
    <TH>所在服务器： </TH>
    <TD colSpan=2><input class="inputA" name="copyfrom" type="text" id="copyfrom"> </TD></TR>
	<TR>
    <TH>游戏中昵称： </TH>
    <TD colSpan=2><input class="inputA" name="author" type="text" id="author"> </TD></TR>
  <TR>
    <TH>图片： </TH>
    <TD colSpan=2><input class="inputT" name="pictureurls" id="pictureurls" ondblclick="ShowPreview();" value="{$pictureurls}">
		<input name="allpictureurls" id="allpictureurls" style="display:none;" value="{$allpictureurls}">
<input type="button" value="本地上传" onclick="javascript:openwinx('{HS_PATH}upload.php?keyid={$channelid}&uploadtext=temp&type=both&width=150&height=150&upload_dir={$MOD[upload_dir]}','upload','360','300')" style="BORDER-RIGHT: #ccc 1px solid; PADDING-RIGHT: 2px; BORDER-TOP: #666 1px solid; PADDING-LEFT: 2px; PADDING-BOTTOM: 2px; BORDER-LEFT: #666 1px solid; COLOR: #333; PADDING-TOP: 2px; BORDER-BOTTOM: #ccc 1px solid;BORDER-LEFT-COLOR: #ddd; BACKGROUND: #ddd; BORDER-BOTTOM-COLOR: #666; VERTICAL-ALIGN: middle; CURSOR: pointer; COLOR: #000; BORDER-TOP-COLOR: #ddd;BORDER-RIGHT-COLOR: #666;height:25px;">
		<input type="hidden" name="temp" id="temp" value="" onpropertychange="Picurls();">
	</TD></TR>
	  <TR>
    <TH>图片说明： </TH>
    <TD colSpan=2><input class="inputT" name="content" type="text" id="content" maxlength="30"> </TD></TR>
 <TR>
    <TH>　</TH>
	<TD colSpan=2><div style="text-align:left;"><input type="submit" name="dosubmit" class="hsbtn" value="发布"></div></TD>
    </TR>
	  </form>
	  </TBODY></TABLE>
</DIV>

{elseif $action=='edit'}
<DIV class=columnC><SPAN class="l_tit f_l">编辑</SPAN></DIV>
<DIV class=mainboxD>
<TABLE class=regform cellSpacing=0 cellPadding=0 width="100%" align=center 
border=0>
  <TBODY>
<form action="{$HS[siteurl]}{$CHA[channeldir]}/myitem.php?action=edit&pictureid={$pictureid}" method="post" name="myform" onsubmit="return doCheck();">
  <TR>
    <TH><font color=#FF0000>提示：</font> </TH>
    <TD colSpan=2><input type="hidden" name="catid" value="{$catid}"> <font color=#FF0000>请务必认真填写，信息一经通过审核，将无法修改！</font></TD></TR>
	 {if $MOD['check_code']}
  <TR>
    <TH>验证码： </TH>
    <TD colSpan=2><input onBlur="codedocheck()" class="inputC" name="checkcodestr" type="text" id="checkcodestr" value=""> 
	<img src="<?=HS_PATH?>checkcode.php" id="imgaecode" onclick="this.src='{HS_PATH}checkcode.php?id='+Math.random()*5;" style="cursor:pointer;" alt="验证码,看不清楚?请点击刷新验证码" align="absmiddle"/> 
	
	</TD>
	</TR>
	{/if}
  <TR>
    <TH>标题： </TH>
    <TD colSpan=2><input class="inputT" name="title" type="text" id="title" value="{$title}" maxlength="30"> </TD></TR>
	<TR>
    <TH>所在服务器： </TH>
    <TD colSpan=2><input class="inputA" name="copyfrom" type="text" id="copyfrom" value="{$copyfrom}"> </TD></TR>
	<TR>
    <TH>游戏中昵称： </TH>
    <TD colSpan=2><input class="inputA" name="author" type="text" id="author" value="{$author}"> </TD></TR>
  <TR>
    <TH>图片： </TH>
    <TD colSpan=2><input class="inputT" name="pictureurls" id="pictureurls" ondblclick="ShowPreview();" value="{$pictureurls}">
		<input name="allpictureurls" id="allpictureurls" style="display:none;" value="{$allpictureurls}">
<input type="button" value="本地上传" onclick="javascript:openwinx('{HS_PATH}upload.php?keyid={$channelid}&uploadtext=temp&type=both&width=150&height=150&upload_dir={$MOD[upload_dir]}','upload','360','300')" style="BORDER-RIGHT: #ccc 1px solid; PADDING-RIGHT: 2px; BORDER-TOP: #666 1px solid; PADDING-LEFT: 2px; PADDING-BOTTOM: 2px; BORDER-LEFT: #666 1px solid; COLOR: #333; PADDING-TOP: 2px; BORDER-BOTTOM: #ccc 1px solid;BORDER-LEFT-COLOR: #ddd; BACKGROUND: #ddd; BORDER-BOTTOM-COLOR: #666; VERTICAL-ALIGN: middle; CURSOR: pointer; COLOR: #000; BORDER-TOP-COLOR: #ddd;BORDER-RIGHT-COLOR: #666;height:25px;">
		<input type="hidden" name="temp" id="temp" value="" onpropertychange="Picurls();">
	</TD></TR>
	  <TR>
    <TH>图片说明： </TH>
    <TD colSpan=2><input class="inputT" name="content" type="text" id="content"  value="{$introduce}" maxlength="30"> </TD></TR>
 <TR>
    <TH>　</TH>
	<TD colSpan=2><div style="text-align:left;"><input type="submit" name="dosubmit" class="hsbtn" value="编辑"></div></TD>
    </TR>
	  </form>
	  </TBODY></TABLE>
</DIV>
{elseif $action=='manage'}
<DIV class=columnC><input type="button" class="shsbtn" value="新稿件" onclick="window.location.href='/picture/myitem.php?action=add&catid={$catid}'"></DIV>
<DIV class=paylist id=block_bill>
<TABLE class=paylist cellSpacing=0 cellPadding=0 width=100% align=center border=0>
  <TBODY>
  <TR align=middle>
    <TH align=middle height="30">状态 </TH>
	<TH align=middle>标题(点击率) </TH>
    <TH align=middle>发布时间 </TH>
    <TH align=middle>审核时间 </TH>
    <TH align=middle>管理 </TH></TR>
	{loop $pictures  $picture}
  <TR align=middle>
    <TD align=middle width="10%" height="30">{if $picture['status']==3}<font color=green><b>已通过</b>{elseif $picture['status']==2}<font color=black><b>被退回</b>{else}<font color=red><b>待审核</b>{/if}</font></TD>
    <TD align=left width="26%" height="30">{if $picture['status']==3}<a href="{$picture['linkurl']}" target="_blank">{$picture['title']}</a> ({$picture['hits']}){else}{$picture['title']}{/if}</TD>
    <TD align=middle width="23%">{$picture['adddate']} </TD>
    <TD align=middle width="23%">{if $picture['checktime']!='1970-01-01 08:00:00'}{$picture['checktime']}{else}--{/if} </TD>
    <TD align=middle width="19%">{if $_groupid ==1 || $picture['status']<3}<a href="{$HS[siteurl]}{$CHA[channeldir]}/myitem.php?action=edit&pictureid={$picture[pictureid]}">编辑</a> | <a href="{$HS[siteurl]}{$CHA[channeldir]}/myitem.php?action=delete&pictureid={$picture[pictureid]}">删除</a>{else}<span style="color:#C0C0C0">编辑 | 删除</span>{/if} </TD></TR>
	{/loop}
</TBODY></TABLE>

</DIV>
{/if}
	  </DIV></DIV></DIV>
<script type="text/javascript">
function Picurls() {
	if($('temp').value != '') {
	var ss = $("pictureurls").value == '' ? '' : "\n";
	Field.clear('pictureurls');
	$('pictureurls').value += ss+$('temp').value.replace(/<?=$HS['uploaddir']?>\/<?=$CHA['channeldir']?>\/<?=$MOD['upload_dir']?>\//g, '');
	Field.clear('allpictureurls');
	$('allpictureurls').value += ss+$('temp').value.replace(/<?=$HS['uploaddir']?>\/<?=$CHA['channeldir']?>\/<?=$MOD['upload_dir']?>\//g, '');
	$('temp').value = '';
	}
}
</script>
{template 'member','footer'}