<?php
session_start();
require_once 'head.php';
//判断该用户是否已经登录
//声明数组保存相应用户相册的Id
$loginId=array();
$link=mysql_connect("localhost","root","");
mysql_select_db("db_photos");
mysql_query("set names gb2312");
//声明空间访问权限默认为0 即未公开
$zoneRight=1;
if(isset($_SESSION["userId"]))
{
$userId=$_SESSION["userId"];
$hostid=$userId;
if(isset($_GET["userid"])){
$userId = $_GET["userid"];
}
if(isset($_GET["isPublic"]))
{
$zoneRight=$_GET["isPublic"];
}
$sql=mysql_query("select albumName from tb_albums where userId='$userId'");
while($rows=mysql_fetch_array($sql))
{
$loginId[]=$rows[0];
}
$uid=1;//表示已经登录
}
else {
//声明数组保存公开相册的名称
if(isset($_GET["userid"])){
$userId = $_GET["userid"];
}
if(isset($_GET["isPublic"]))
{
$zoneRight=$_GET["isPublic"];
}
if(isset($userId)){
$rs=mysql_query("select albumName from tb_albums where userId='$userId'");
}
else{
$zoneRight=1;
$rs=mysql_query("SELECT albumName FROM `tb_albums` ");
}
while($rows=mysql_fetch_array($rs,MYSQL_BOTH))
{
$loginId[]=$rows[0];
}
$uid=0;//表示未登录
}
//获取当前的目录
if(isset($_GET["filename"]))
{
$path=$_GET["filename"];
}
else {
$path="photos";
}
//中文编码转换,遇到中文目录时需要转换编码,否则容易出现乱码
function charset($char,$data)
{
if($char=="g")
{
return @iconv("utf-8", "gb2312", $data);
}
else {
return @iconv("gb2312", "gb2312", $data);
}
}
//查询出isPublic为1:即相册为公开状态
//声明数组保存未公开相册的名称
function pwdAlbum()
{
$pwdalbum=array();
$rs=mysql_query("SELECT albumName FROM `tb_albums` WHERE isPublic = 0");
while($rows=mysql_fetch_array($rs,MYSQL_BOTH)){
$pwdalbum[]=$rows[0];
}
return $pwdalbum;
}
$modeAlbums = pwdAlbum();
?>
<html>
<head>
<title>文件上传</title>
<link rel="stylesheet" href="css/scce.css" type="text/css" media="all" />
<script language="javascript" src="css/javascript/index.js"></script>
<script type="text/javascript">
function del(path,file,mark)
{
if(mark=="file")
{
if(confirm("你确认要删除文件\“"+file+"\”么?"))
{
location.href="del.php?path="+path+"&file="+file;
}
}
if(mark=="dir")
{
if(confirm("你确认要删除目录“"+path+"”么?"))
{
location.href="del.php?path="+path;
}
}
}
</script>
</head>
<body>
<?php
require_once 'head.php';
?>
<?php
//生成导航条,目录逐层增加,超链接跟上
$pathArr=explode('/', $path);
$str_a="";
$arrLen=@count($pathArr);
for($i=($arrLen-1);$i>=0;$i--)
{
$href="";
for($z=$i;$z>=0;$z--)
{
if($z==$i)
{
$href=$pathArr[$z];
}
else {
$href=$pathArr[$z].'/'.$href;
}
}
if($i==0)
{
$str_a='<a href="?filename='.$href.'" target="_self">'.$pathArr[$i].'</a>'.$str_a;
}
else {
$str_a=' >><a href="?filename='.$href.'" target="_self">'.$pathArr[$i].'</a>'.$str_a;
}
}
?>
<!-- 显示好友列表 -->
<div class="center">
<div class="titles"><?php echo $str_a; ?></div>
<div class="friend"><span>好友列表</span> <?php
$usernames=array();//声明数组保存查询到的好友名称与空间访问权限
$users=array();
$sql=mysql_query("select id,userName,isPublic from tb_userinfo");
while($rw=mysql_fetch_array($sql))
{
?>
<ul>
<li style="list-style-type: none"><a
href="index.php?isPublic=<?php echo $rw[2];?>&userid=<?php echo $rw[0];?>"><?php echo $rw[1]."(".($rw[2]==1?"公开":"未公开").")" ;?></a></li>
</ul>
<?php
}
?></div>
<?php
if(!is_dir($path))
{
echo '<div style="text-align:center;line-height:28px;">
'.$path.'不存在<div>';
exit();
}
else {
$fileArr=@scandir($path);
//判断目录是否为空
if(@count($fileArr)<=2)
{
//判断是根目录或某个文件相册目录
if(@count(explode("/", $path))>=2)
{
echo '<div style="text-align:center;line-height:300px;">
您的相册如此空空,赶快<a style="color:#ff00ff;" href="upload.php" target="_self">上传图片</a>吧</div>';
echo '<div class="cenDo">
<a href="index.php" target="_self" target="返回相册">返回相册</a>
<a href="login.php" target="_self" target="退出系统">退出系统</a></div>';
//require_once 'bottom.php';
exit();
}
else {
echo '<div style="text-align:center;line-height:300px;">
您的相册如此空空,赶快<a style="color:#ff00ff;" href="create.php" target="_self">创建一个</a>吧</div>';
echo '<div class="cenDo">
<a href="login.php" target="_self" target="退出系统">退出系统</a></div>';
//require_once 'bottom.php';
exit();
}
}
}
//判断好友空间是否公开
if($zoneRight==0)
{
echo '<div class="con" style="font-size:22px;font-weight:bold;font-family:隶书;margin-left:100px;margin-top:125px;width:400px;">
该好友空间未公开,您没有访问权限!
</div>';
}
else{
//判断好友是否存在相册
if(count($loginId)<=0)
{
echo '<div class="con" style="font-size:22px;font-weight:bold;font-family:隶书;margin-left:100px;margin-top:125px;width:400px;">
该好友还未创建任何相册!
</div>';
}
foreach ($fileArr as $v)
{
//排除点开头目录
if(($v!="..")&&($v!="."))
{
//判断显示登录人的相册
if(is_dir(charset('g',$path).'/'.$v))
{
if(in_array($v, $loginId))
{
$fiels = scandir($path.'/'.$v);
$firstName = "";//显示 封面
foreach ($fiels as $g){
if($g!=".."&&$g!="."){
$firstName = $g;
break;
}
}
$cover = (in_array($v, $modeAlbums))?("css/images/no.gif"):(((count($fiels)>2)?($path.'/'.$v.'/'.$firstName):("css/images/no_photo_s.png")));
echo '<div class="con">
<a href="index.php?filename='.$path.'/'.$v.'" target="_self" title="'.$v.'">
<img src="'. $cover .'" width="70" height="66" border="0"><br/>'.$v.'<a/><br/>
<span class="time">
'.date("Y-m-d H:i:s",filectime($path.'/'.$v)).'</span>
<br/>'.(($uid==1)?(($hostid==$userId)?('<a href="editAlbum.php">编辑</a>'):('')):('')).'
'.(($uid==1)?(($hostid==$userId)?('<a href="javascript:del(\''.$path.'/'.$v.'\',\'NULL\',\'dir\')" class="del">删除</a>'):('')):('')).
'</div> ';
}
}
else {
echo '<div class="con">
<a href="'.$path.'/'.$v.'" target="_blank" title="'.$v.'">
<img src="'.$path.'/'.$v.'" width="140" height="100" border="0"><br/>'.$v.'</a><br/>
<span class="time">'.date("Y-m:d H:i:s",filectime($path.'/'.$v)).'</span>
<br/>'.(($uid==1)?(($hostid==$userId)?('<a href="reviewImg.php?imageName='.$v.' ">编辑</a>'):('')):('')).'
'.(($uid==1)?(($hostid==$userId)?('<a href="javascript:del(\''.$path.'/'.$v.'\',\'NULL\',\'dir\')" class="del">删除</a>'):('')):('')).'
</div>';
}
}
}
}
?>
<br style="clear: both" />
<!-- 遮罩层 -->
<div id="cover"></div>
<!-- 显示层 -->
<div id="show">
<a href="#" onclick="closeWin();" style="float:right;">[关闭]</a>
<center>
<form name="frmCheck" method="post" action="checkGoAlbum.php">
<!-- <input type="hidden" name="userId" id="userId" />
<input type="hidden" name="option" id="option" />-->
<input type="hidden" name="albumName" id="albumName" />
<table width="300px" border="0" cellpadding="0" cellspacing="0" style="font-size:12px;margin-left:30px;margin-top:90px;" >
<tr>
<td width="110px;">请输入空间对应的密码:</td>
<td><input type="text" name="userPwd" id="userPwd" style="border:1px solid gray;width:120px;" /></td>
<td><input type="submit" name="" value="确定" /></td>
</tr>
</table>
</form>
</center>
</div>
<?php if(isset($_SESSION["userId"]))
{
?>
<div class="cenDo"><a href="upload.php" target="_self" target="上传照片">上传照片</a>
<a href="create.php" target="_self"
target="新建相册">新建相册</a>
<a href
PHP电子相册(附MySQL数据库)
4星 · 超过85%的资源 需积分: 34 173 浏览量
2011-01-15
21:33:24
上传
评论 4
收藏 2.96MB RAR 举报
firewang3797783
- 粉丝: 2
- 资源: 12
最新资源
- Python大作业:音乐播放软件(爬虫+可视化+数据分析+数据库)
- 课程设计-python爬虫-爬取日报,爬取日报文章后存储到本地,附带源代码+课程设计报告
- 软件和信息技术服务行业投资与前景预测.pptx
- 课程设计-基于SpringBoot + Mybatis+python爬虫NBA球员数据爬取可视化+源代码+文档+sql+效果图
- 软件品质管理系列二项目策划规范.doc
- 基于TensorFlow+PyQt+GUI的酒店评论情感分析,支持分析本地数据文件和网络爬取数据分析+源代码+文档说明+安装教程
- 软件定义无线电中的模拟电路测试技术.pptx
- 软件开发协议(作为技术开发合同附件).doc
- 软件开发和咨询行业技术趋势分析.pptx
- 软件测试题详解及答案.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
- 3
- 4
前往页