<?php defined('IN_HS') or exit('Access Denied'); ?>
<?php include 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="<?php echo HS_PATH;?>checkcode.php?id='+Math.random()*5";
}
}
}

function doCheck(){

<?php if($MOD['check_code']) { ?>
if ($('checkcodestr').value=='') {
alert("请输入验证码！");
$('checkcodestr').focus();
return false;
}
<?php } ?>

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>

<?php include template('member','left_post'); ?>

<DIV class="ad_rbarB boxC">

<?php 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="<?php echo $HS['siteurl'];?><?php echo $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="<?php echo $catid;?>"> <font color=#FF0000>请务必认真填写，信息一经通过审核，将无法修改！</font></TD></TR>
 <?php 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='<?php echo HS_PATH;?>checkcode.php?id='+Math.random()*5;" style="cursor:pointer;" alt="验证码,看不清楚?请点击刷新验证码" align="absmiddle"/> 

</TD>
</TR>
<?php } ?>
  <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="<?php echo $pictureurls;?>">
<input name="allpictureurls" id="allpictureurls" style="display:none;" value="<?php echo $allpictureurls;?>">
<input type="button" value="本地上传" onclick="javascript:openwinx('<?php echo HS_PATH;?>upload.php?keyid=<?php echo $channelid;?>&uploadtext=temp&type=both&width=150&height=150&upload_dir=<?php echo $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>&nbsp;</TH>
<TD colSpan=2><div style="text-align:left;"><input type="submit" name="dosubmit" class="hsbtn" value="发布"></div></TD>
    </TR>
  </form>
  </TBODY></TABLE>
</DIV>

<?php } 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="<?php echo $HS['siteurl'];?><?php echo $CHA['channeldir'];?>/myitem.php?action=edit&pictureid=<?php echo $pictureid;?>" method="post" name="myform" onsubmit="return doCheck();">
  <TR>
    <TH><font color=#FF0000>提示：</font> </TH>
    <TD colSpan=2><input type="hidden" name="catid" value="<?php echo $catid;?>"> <font color=#FF0000>请务必认真填写，信息一经通过审核，将无法修改！</font></TD></TR>
 <?php 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='<?php echo HS_PATH;?>checkcode.php?id='+Math.random()*5;" style="cursor:pointer;" alt="验证码,看不清楚?请点击刷新验证码" align="absmiddle"/> 

</TD>
</TR>
<?php } ?>
  <TR>
    <TH>标题： </TH>
    <TD colSpan=2><input class="inputT" name="title" type="text" id="title" value="<?php echo $title;?>" maxlength="30"> </TD></TR>
<TR>
    <TH>所在服务器： </TH>
    <TD colSpan=2><input class="inputA" name="copyfrom" type="text" id="copyfrom" value="<?php echo $copyfrom;?>"> </TD></TR>
<TR>
    <TH>游戏中昵称： </TH>
    <TD colSpan=2><input class="inputA" name="author" type="text" id="author" value="<?php echo $author;?>"> </TD></TR>
  <TR>
    <TH>图片： </TH>
    <TD colSpan=2><input class="inputT" name="pictureurls" id="pictureurls" ondblclick="ShowPreview();" value="<?php echo $pictureurls;?>">
<input name="allpictureurls" id="allpictureurls" style="display:none;" value="<?php echo $allpictureurls;?>">
<input type="button" value="本地上传" onclick="javascript:openwinx('<?php echo HS_PATH;?>upload.php?keyid=<?php echo $channelid;?>&uploadtext=temp&type=both&width=150&height=150&upload_dir=<?php echo $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="<?php echo $introduce;?>" maxlength="30"> </TD></TR>
 <TR>
    <TH>&nbsp;</TH>
<TD colSpan=2><div style="text-align:left;"><input type="submit" name="dosubmit" class="hsbtn" value="编辑"></div></TD>
    </TR>
  </form>
  </TBODY></TABLE>
</DIV>
<?php } elseif ($action=='manage') { ?>
<DIV class=columnC><input type="button" class="shsbtn" value="新稿件" onclick="window.location.href='/picture/myitem.php?action=add&catid=<?php echo $catid;?>'"></DIV>
<DIV class=paylist id=block_bill>
<TABLE class=paylist cellSpacing=0 cellPadding=0 width=700 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>
<?php if(is_array($pictures)) foreach($pictures AS $picture) { ?>
  <TR align=middle>
    <TD align=middle width="10%" height="30"><?php if($picture['status']==3) { ?><font color=green><b>已通过</b><?php } elseif ($picture['status']==2) { ?><font color=black><b>被退回</b><?php } else { ?><font color=red><b>待审核</b><?php } ?></font></TD>
    <TD align=left width="37%" height="30"><?php if($picture['status']==3) { ?><a href="<?php echo $picture['linkurl'];?>" target="_blank"><?php echo $picture['title'];?></a> (<?php echo $picture['hits'];?>)<?php } else { ?><?php echo $picture['title'];?><?php } ?></TD>
    <TD align=middle width="20%"><?php echo $picture['adddate'];?> </TD>
    <TD align=middle width="20%"><?php if($picture['checktime']!='1970-01-01 08:00:00') { ?><?php echo $picture['checktime'];?><?php } else { ?>--<?php } ?> </TD>
    <TD align=middle width="13%"><?php if($_groupid ==1 || $picture['status']<3) { ?><a href="<?php echo $HS['siteurl'];?><?php echo $CHA['channeldir'];?>/myitem.php?action=edit&pictureid=<?php echo $picture['pictureid'];?>">编辑</a> | <a href="<?php echo $HS['siteurl'];?><?php echo $CHA['channeldir'];?>/myitem.php?action=delete&pictureid=<?php echo $picture['pictureid'];?>">删除</a><?php } else { ?><span style="color:#C0C0C0">编辑 | 删除</span><?php } ?> </TD></TR>

<?php } ?>

</TBODY></TABLE>

</DIV>
<?php } ?>
  </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>

<?php include template('member','footer'); ?>
