<?php
error_reporting(0);
if($_POST['action']||$action){	
	require_once (dirname(__FILE__)."/".'global.php');
}
?>
<html>
<head>
<title>Powered by PHP168.com</title>
<meta name='keywords' content='mmcbbs,php168,news,bbs,board,php,mysql,forums'>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0">
<?php
if($postfile){
	if( !ereg("^[0-9a-z_]+$",$dir) ){
		$dir="other";
	}
	$array[name]=is_array($postfile)?$_FILES[postfile][name]:$postfile_name;
	$array[path]=$webdb[updir]."/".$dir;
	$array[size]=is_array($postfile)?$_FILES[postfile][size]:$postfile_size;
	$lfjuid=$userdb[uid];	//處理上傳的文件名標志
	$filename=upfile(is_array($postfile)?$_FILES[postfile][tmp_name]:$postfile,$array);
    if(!$filename){
		echo "<CENTER>文件上傳失敗,請再次上傳，如果多次失敗，請聯系管理員<a href=\"javascript:history.go(-1)\"> 點擊返回</a></CENTER>";
		exit;
	}else {
		$newfile="$dir/$filename";
		echo "上傳succeed,<A HREF=?fn=$fn&label=$label&dir=$dir&label=$_GET[label]>繼續上傳</A>";
		$fn || $fn="upfile";
		echo "
			<script>
				if(self==top){
					window.opener.$fn('$newfile','$array[name]','$array[size]','$_GET[label]');
					window.self.close();
				}else{
					window.parent.$fn('$newfile','$array[name]','$array[size]','$_GET[label]');
				}
			</script>
			";
		exit;
	}
}
?>
<form name="form1" method="post" action="" enctype="multipart/form-data">
  <input  type="file" name="postfile" style="height:20px; background-color:#EBEBEB; border:1 solid black;" onMouseOver ="this.style.backgroundColor='#F0F0F0'" onMouseOut ="this.style.backgroundColor='#FAFAFA'" >
  <input  type="submit" name="Submit" value="上傳文件" style="height:20px; background-color:#EBEBEB; border:1 solid black;" onMouseOver ="this.style.backgroundColor='#F0F0F0'" onMouseOut ="this.style.backgroundColor='#FAFAFA'" >
  <input type="hidden" name="action" value="uploadfile">
</form>
</body>
</html>