<?php 
require "../Run.php";
require "../include/upload.class.php";
if(LOGIN != 1)
{
	echo head('您还没有登录');
	
	echo '<div class="tip">您好，您还没有登录，请登录后再使用本功能</a>';
	echo '<div class="mylink"><a href="myalbum.php?">我的相册</a><a href="list.php?">相册列表</a></div>';
	
	echo SYSTEM_BOOTOM;
	
	exit;
}
if($_GET['act'] == 'upload'){
	echo head('照片上传');
	echo '<div class="title">照片上传</div>';
	$path = 'album/'.WAPID.'/'.MYID.'/'.base64_decode($_POST['album']);
	$allowtype = array("jpeg","jpg","png","gif");
	$fileid = 'userfile';
	if($_GET['nums'] == NULL)
	{
	$nums = 1;
	}else{
	$nums = $_GET['nums'];
	}
	$upload = new file(WAPID,$name,$path,$allowtype,$nums,$fileid);
	$upload_back = $upload->uploadfile();
	foreach($upload_back as $value){
		if($value != 0 || $value != '-1'){
			echo '文件上传成功<br>';
		}else{
			echo '文件上传失败<br>';
		}
	}
	echo '<div class="mylink"><a href="myalbum.php?">我的相册</a><a href="list.php?">相册列表</a></div>';
	echo SYSTEM_BOOTOM;
exit;
}

	echo head('图片上传');
    echo '<form method="post" enctype="multipart/form-data" action="?act=upload">';
	$base_dir = 'album/'.WAPID.'/'.MYID.'/'; 
		$fso  = opendir($base_dir);  
		echo '<div class="title">上传照片至分类</div>';  
		$num = 0;
		echo '<select name="album">';
		while($flist = readdir($fso)){  
			if($flist !='.' && $flist != '..' && $flist != 'title.txt')
			{
			$div = $num++%2 == 0?'line1':'line2'; 
				echo '<option value="'.$flist.'">'.base64_decode($flist).'</option>';
			}
		}  
	echo '</select>';
	echo '<input type="file" name="userfile1" id="fileField" value="图片上传"/>';
	echo '<br><input type="submit" value="提交">';
	echo '</form>';
	echo '<div class="mylink"><a href="myalbum.php?">我的相册</a><a href="list.php?">相册列表</a></div>';
	echo footer(1);
?>