<?php 
	require "../Run.php";
	
	if(!is_dir('album/'.WAPID)) {mkdir('album/'.WAPID);}
	
	if($_GET['userid'] == NULL ||$_GET['userid'] == '')
	{
	echo head(class_name($_GET['cid'],'cn',$wapid));
	$base_dir = 'album/'.WAPID.'/'; 
	     $fso       =  opendir($base_dir);  
	echo '<div class="title">'.class_name($_GET['cid'],'cn',$wapid).'[<a href="myalbum.php?cid='.$_GET['cid'].'">我的相册</a>]</div>';  
	$num = 0;
	while($flist = readdir($fso)){  
	$div = $num++%2 == 0?'line1':'line2';
		if($flist !='.' && $flist != '..'){
				
				$album_nmae = file_get_contents('album/'.WAPID.'/'.$flist.'/title.txt');
				
				if($album_name == NULL || $album_name == ''){
				
				$album_name =  user("nc",'id',$flist).'的相册';
				
				file_put_contents('album/'.WAPID.'/'.$flist.'/title.txt',user("nc",'id',$flist).'的相册');
				
				}
				
				echo '<div class="'.$div.'"><a href="list.php?cid='.$_GET['cid'].'&userid='.user('xid','id',$flist).'">'.$album_name.'</a></div>';
			
			}
		}  
		closedir($fso);
	echo footer(1);
}else{
		if($_GET['album'] == NULL){
		echo head(user2('nc',$_GET['userid'],WAPID));
		$base_dir = 'album/'.WAPID.'/'.user2('id',$_GET['userid'],WAPID).'/'; 
		$fso  = opendir($base_dir);  
		echo '<div class="title"><a href="list.php?cid='.$_GET['cid'].'">相册</a>>><a href="list.php?cid='.$_GET['cid'].'&userid='.$_GET['userid'].'">'.user2('nc',$_GET['userid'],WAPID).'的相册</a></div>';  
		$num = 0;
		while($flist = readdir($fso)){  
			$div = $num++%2 == 0?'line1':'line2';
			if($flist !='.' && $flist != '..' && $flist != 'title.txt')
			{
				echo '<div class="'.$div.'"><a href="list.php?cid='.$_GET['cid'].'&userid='.$_GET['userid'].'&album='.base64_encode($flist).'">'.$flist.'</a></div>';
			}
		
		}  
	closedir($fso);    
	echo footer(1); 
}else{
	echo head(base64_decode($_GET['album']));
	$base_dir = 'album/'.WAPID.'/'.user2('id',$_GET['userid'],WAPID).'/'.base64_decode($_GET['album']).'/'; 
		$fso  = opendir($base_dir);  
		echo '<div class="title"><a href="list.php?cid='.$_GET['cid'].'&userid='.$_GET['userid'].'">'.user2('nc',$_GET['userid'],WAPID).'的相册</a>>><a href="list.php?cid='.$_GET['cid'].'&userid='.$_GET['userid'].'&album='.$_GET['album'].'">'.base64_decode($_GET['album']).'</a></div>';  
		$num = 0;
		while($flist = readdir($fso)){  
		$div = $num++%2 == 0?'line1':'line2'; 
			if($flist !='.' && $flist != '..' && $flist != 'title.txt'){
				echo '<div class="album_gro"><a href="'.$base_dir.$flist.'">';
				echo '<img src="'.$base_dir.$flist.'" alt="'.$flist.'" style="height:80px;width:80px;"><br><text>'.$flist.'<text></div>';
				echo '</a>';
			}
		}  
	closedir($fso);    
	echo footer(1);
	}
}

?>