<?php
if( !defined('ISDVBBS') ){
	header('HTTP/1.0 404 Not Found');
	exit;
}?>
<?php include "header.php";?>
<div id="nav_top">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr width="100%">
<td id="user_right_td">
<!---##########################右边样式部分##########################--->
	<div id="tabtitle">
		<div id="topicbodyuser">
		<span>
			<div class="user_nav_topic">
<!--<?php
print <<<EOT
-->
<!--
EOT;
if ( $action == 'fadd' ){
	$count = count($iupload);
	for( $i = 0 ; $i < $count ; $i++ ){
		$filetypelist .= "<option value=\"{$i}\">{$iupload[$i]}</option>";
	}
print <<<EOT
-->
<table width="96%" border="0" cellspacing="0" cellpadding="0">
  <form action="?action=fsnew" method="post">
      <tr id="user_nav">
        <td align="left" width="100%" colSpan="2">{$lang['tpl.file.addn.str1']}</td>
      </tr>
      <tr>
        <td class="tablebody2" align="right" width="15%" height="26">{$lang['tpl.file.addn.str2']}</td>
        <td class="tablebody1" align="left" width="85%" height="26"><input size="80" value="http://" name="fileurl"> 
          {$lang['tpl.file.addn.str3']}</td>
      </tr>
      <tr>
        <td class="tablebody2" align="right" width="15%" height="26">{$lang['tpl.file.addn.str4']}</td>
        <td class="tablebody1" align="left" width="85%" height="26"><textarea name="F_Readme" rows="6" wrap="VIRTUAL" cols="80" value></textarea> 
          {$lang['tpl.file.addn.str5']}</td>
      </tr>
      <tr>
        <td class="tablebody2" vAlign="center" align="right">{$lang['tpl.file.addn.str6']}</td>
        <td class="tablebody1" vAlign="center" align="left"><select size="1" name="filetype">
            <option value selected>{$lang['tpl.file.addn.str7']}</option>
{$filetypelist}
          </select></td>
      </tr>
      <tr>
        <td class="tablebody2" vAlign="center" align="right">{$lang['tpl.file.addn.str8']}</td>
        <td class="tablebody1" vAlign="center" align="left"><input type="radio" CHECKED value="1" name="Fflag" class=radio>{$lang['tpl.file.addn.str9']}&nbsp; 
          <input type="radio" value="2" name="Fflag" class=radio>{$lang['tpl.file.addn.str10']}</td>
      </tr>
      <tr>
        <td class="tablebody1" width="100%" colSpan="2" height="26" align="left">{$lang['tpl.file.addn.str11']}
        </td>
      </tr>
      <tr>
        <td class=tablebody2 width="100%" colSpan="2" height="26">
		<button onMousemove="this.className='button_on';" onMouseout="this.className='button';" type="submit" name="Submit">{$lang['tpl.file.addn.str12']}</button></td>
      </tr>
      </FORM>
  </table>
<!--
EOT;
}elseif ( $action == 'edit' ){
	$F_Username = $result['f_username'];
	$F_Type = $result['f_type'];
	$filename = $result['f_filename'];
	$F_Flag = $result['f_flag'];
	$con = $result['f_readme'];
	if( strstr($filename,'//') === false || strstr($filename,':') === false ){
		$myurl = true;
		$filename = "{$filename}";
	}
	if( $F_Type == 1 ){
		$f_typename = "<IMG src=\"uploadfile/{$filename}\" style=\"border:1 solid #000000\" border=\"0\">";
	} else{
		$f_typename = $result['f_filetype'].$lang['tpl.file.strings5'];
	}
	if( $con != '' ){
		$body = str_replace('<br>',chr(13),$con);
		$body = str_replace('&nbsp;','',$body);
		$body .= chr(13);
	}
	if( $myurl === true ){
		if( strstr($result['f_announceid'],'|') !== false ){
			list($F_rootid,$F_bbsid) = explode('|',$result['f_announceid']);
		}
		$upfilexs = "<tr><td valign=\"middle\" align=\"right\" class=\"tablebody2\">{$lang[tpl.file.strings6]}</td><td width=\"100%\" height=\"26\" class=\"tablebody1\">";
		if( $master || $superboardmaster || $boardmaster || $groupsetting[48] == 1 ){
			$arrTmp = explode('||',$lang['tpl.file.strings7']);
			$upfilexs .= "{$arrTmp[0]}<input type=\"text\" name=\"F_BoardID\" value=\"{$result['f_boardid']}\" size=\"8\">&nbsp;{$arrTmp[1]}<input type=\"text\" name=\"F_AnnounceID\" value=\"{$result['f_announceid']}\">&nbsp;<font color=\"{$lang['Dvbbs.mainsetting1']}\">{$lang['tpl.file.strings8']}</font>";
		} else{
			$upfilexs .= "<input type=\"hidden\" name=\"{$F_BoardID}\" value=\"{$f_boardid}\"><input type=\"hidden\" name=F_AnnounceID value=\"{$result['f_announceid']}\">";
		}
		$upfilexs .= "<a href=\"dispbbs.php?boardid={$result['f_boardid']}&id={$F_rootid}&skin=1\" target=\"_blank\" title=\"{$lang['tpl.file.strings9']}\">[<font color=\"{$lang[Dvbbs.mainsetting1]}\">{$lang['tpl.file.strings11']}</font>]</a></td></tr>";
	} else{
		$upfilexs .= "<input type=\"hidden\" name=\"F_BoardID\" value=\"{$result['f_boardid']}\"><tr><td width=\"15%\" height=\"26\" class=\"tablebody2\" align=\"right\">{$lang[tpl.file.strings10]}</td><td width=\"85%\" class=\"tablebody1\" align=\"left\"><input type=\"text\" name=\"fileurl\" size=\"80%\" value=\"{$result['f_filename']}\"></td></tr>";
	}
	if( $F_Flag < 2 ){
		$checked1 = ' checked ';
		$checked2 = '';
	} else{
		$checked1 = '';
		$checked2 = ' checked ';
	}
	$f_username = htmlspecialchars($F_Username);
	$f_boardid = $result['f_boardid'];
	$f_id = $result['f_id'];
	$body = htmlspecialchars($body);
print <<<EOT
-->
<table width="96%" border="0" cellspacing="0" cellpadding="0">
  <form action="?action=fsave" method="post">
      <tr id="user_nav">
        <td align="left" width="100%" colSpan="2">{$lang['tpl.file.edit.str1']}{$f_username}{$lang['tpl.file.edit.str2']}</td>
      </tr>
      <tr>
        <td class="tablebody2" align="right" width="15%" height="26">{$lang['tpl.file.edit.str3']}</td>
        <td class="tablebody1" align="left" width="85%" height="26"><a href="fileshow.php?boardid={$f_boardid}&amp;id={$f_id}" target="_blank">{$f_typename}</a></td>
      </tr>
{$upfilexs}
      <tr>
        <td class="tablebody2" align="right" width="15%" height="26">{$lang['tpl.file.edit.str4']}</td>
        <td class="tablebody1" align="left" width="85%" height="26"><textarea name="F_Readme" rows="6" wrap="VIRTUAL" cols="80">{$body}</textarea>
          <input type="hidden" value="{$f_id}" name="saveid">{$lang['tpl.file.edit.str5']}</td>
      </tr>
      <tr>
        <td class="tablebody2" vAlign="center" align="right">{$lang['tpl.file.edit.str6']}</td>
        <td class="tablebody1" vAlign="center" align="left"><input type="radio" value="1" name="Fflag" {$checked1} class=radio>{$lang['tpl.file.edit.str7']}&nbsp; 
          <input type="radio" value="2" name="Fflag" {$checked2} class=radio>{$lang['tpl.file.edit.str8']}</td>
      </tr>
      <tr>
        <td class="tablebody1" width="100%" colSpan="2" height="26">{$lang['tpl.file.edit.str9']}
        </td>
      </tr>
      <tr>
        <td class="tablebody2" width="100%" colSpan="2" height="26"><button onMousemove="this.className='button_on';" onMouseout="this.className='button';" type="submit" name="Submit">{$lang['tpl.file.edit.str10']}</button></th>
      </tr>
      </FORM>
  </table>
<!--
EOT;
}else{
print <<<EOT
-->
<SCRIPT LANGUAGE="JavaScript">
<!--
function CheckAll(form) {
	for (var i=0;i<form.elements.length;i++){
		var e = form.elements[i];
		if (e.name != 'chkall')  e.checked = form.chkall.checked;
	}
}
//-->
</SCRIPT>
<table width="96%" border="0" cellspacing="0" cellpadding="0">
  <form action="myfile.php" method="get">
      <tr>
        <td align="left"><a href="?action=fadd">{$lang['tpl.file.str1']}</a>{$lang['usersms.str1']}<a href="show.php?username={$username}">{$lang['tpl.file.str2']}</a></td>
        <td align="right" width="200"><select onchange="javascript:submit()" name="Stype">
            <option value="all" selected>{$lang['tpl.file.str3']}</option>
            <option value="0">{$lang['tpl.file.str4']}</option>
            <option value="1">{$lang['tpl.file.str5']}</option>
            <option value="2">{$lang['tpl.file.str6']}</option>
            <option value="3">{$lang['tpl.file.str7']}</option>
            <option value="4">{$lang['tpl.file.str8']}</option>
            <option value="5">{$lang['tpl.file.str9']}</option>
          </select></td>
      </tr>
      </FORM>
  </table>
  <table width="96%" border="0" cellspacing="0" cellpadding="0">
    <form name="myfile" action="myfile.php?action=fdel" method="post">
        <tr id="user_nav">
          <td vAlign="center" align="middle" width="30"><b>{$lang['tpl.file.str11']}</b></td>
          <td vAlign="center" align="middle" width="*"><b>{$lang['tpl.file.str12']}</b></td>
          <td vAlign="center" align="middle" width="60"><b>{$lang['tpl.file.str13']}</b></td>
          <td vAlign="center" align="middle" width="60"><b>{$lang['tpl.file.str14']}</b></td>
          <td vAlign="center" align="middle" width="120"><b>{$lang['tpl.file.str15']}</b></td>
          <td vAlign="center" align="middle" width="60"><b>{$lang['tpl.file.str16']}</b></td>
          <td vAlign="center" align="middle" width="120"><b>{$lang['tpl.file.str17']}</b></td>
        </tr>
<!--
EOT;
if( $Pcount > 0 ):
	foreach( $_dbResults as $result ):
		$F_Type = $result['f_type'];
		if( $F_Type >= 1 && $F_Type <=4 ){
			$F_typename = $F_typenames[$F_Type];
		} else{
			$F_typename = $F_typenames[0];
		}
		if( $result['f_readme'] != '' || !is_null($result['f_readme']) ){
			if( strlen($result['f_readme']) > 26 ){
				$readme = substr( htmlspecialchars( str_replace( chr(10),' ',$result['f_readme'] ) ) ,0 , 26).'...';
			} else{
				$readme = htmlspecialchars($result['f_readme']);
			}
		}
		if( $groupsetting[48] == 1 ){
			if( (strstr() !== false || strstr() !== false) && intval($result['f_flag']) == 1 ){
				$useradmin = " <input type=\"checkbox\" name=\"delid[]\" value=\"{$result['f_id']}\" class=chkbox> ";
			} else{
				$useradmin = ' <input type="checkbox" value="" disabled class=chkbox> ';
			}
			$useradmin .= "<a href=\"?action=edit&editid={$result['f_id']}\">{$Mylist[0]}</a>  | <a href=\"fileshow.php?action=send&id={$result['f_id']}\">{$Mylist[1]}</a>";
		} else{
			$useradmin = ' '.$lang['usersms.str4'].$lang['usersms.str4'].' ';
		}
		$F_FileType = str_replace('_','',$result['f_filetype']);
		$boardid = $result['f_boardid'];
		$F_FileSize = intval($result['f_filesize']);
		$F_DownNum = intval($result['f_downnum']);
		$F_ViewNum = intval($result['f_viewnum']);
		$F_AddTime = gmdate('Y-m-d H:i:s', $result['f_addtime']+getUserTimeZoneOffset());
		$F_ID = $result['f_id'];
		print <<<EOT
-->
        <tr>
          <td vAlign="center" align="middle"><img src="images/filetype/{$F_FileType}.gif" border="0" width="16" height="16"></td>
          <td vAlign="center" align="left"><a href="fileshow.php?boardid={$boardid}&amp;id={$F_ID}" target="_blank">{$readme}</a></td>
          <td vAlign="center" align="right">{$F_FileSize} <b>B</b></td>
          <td vAlign="center" align="middle">{$F_DownNum}/{$F_ViewNum}</td>
          <td vAlign="center" align="left">{$F_AddTime}</td>
          <td vAlign="center" align="middle">{$F_typename}</td>
          <td vAlign="center" align="middle">{$useradmin}</td>
        </tr>

<!--
EOT;
	endforeach;
	$SearchStr = "boardid={$boardid}&reaction=onlineinfo";
	print <<<EOT
-->
<table width="96%" border="0" cellspacing="0" cellpadding="0">
<tr id="user_nav"><td valign=middle nowrap>
{$lang['tpl.file.str18']}<b>{$CurrentPage}</b>/<b>{$Pcount}</b>{$lang['tpl.file.str19']}<b><font color="{$redcolor}">{$totalrec}</font></b>{$lang['tpl.file.str20']}<b>{$PageNum}</b>{$lang['tpl.file.str21']}
</td>
<td valign=middle nowrap align=right>{$lang['tpl.file.str22']}
<SCRIPT LANGUAGE="JavaScript">
<!--
var CurrentPage={$CurrentPage};
var Pcount={$Pcount};
var Endpage=0;
if (CurrentPage > 4){
	document.write ('<a href="?page=1&{$SearchStr}">[1]</a> ...');
}
if (Pcount>CurrentPage+3)
{
	Endpage=CurrentPage+3
}
else{
	Endpage=Pcount
}
for (var i=CurrentPage-3;i<=Endpage;i++)
{
	if (i>=1){
		if (i == CurrentPage)
		{
			document.write (' <font color="{$redcolor}">['+i+']</font>');
			}
		else{
			document.write ('<a href="?page='+i+'&{$SearchStr}">['+i+']</a>');
		}
	}
}
if (CurrentPage+3 < Pcount){ 
	document.write ('... <a href="?page='+Pcount+'&{$SearchStr}">['+Pcount+']</a>');
}
if (Endpage == 0){ 
	document.write ('...');
}
//-->
</SCRIPT>
</td></tr>
<!--
EOT;
else:
	print <<<EOT
-->
<tr><td vAlign=center align=middle colSpan=7>{$lang['tpl.file.str23']}</td></tr>
<!--
EOT;
endif;
print <<<EOT
-->
        <tr>
          <td align="right" colSpan="7">{$lang['tpl.file.str24']}<input onclick="CheckAll(this.form)" type="checkbox" value="on" name="chkall" class=chkbox>{$lang['tpl.file.str25']}
            <button onclick="{if(confirm('{$lang['tpl.file.str26']}')){document.myfile.submit();return true;}return false;}" type="submit"  name="Submit" onMousemove="button_move(this)" onMouseout="button_out(this)">{$lang['tpl.file.str27']}</button></td>
        </tr>
        </FORM>
    </table>
<!--
EOT;
}
print <<<EOT
-->
<!--
EOT;
?>-->
</table>
<br />
			</div>
		</span>
		</div>
	</div>
</div>
</td><tr>
</table>
<!---########################## end 右边样式部分##########################--->