UCHome关于查看加密图片的程序处理过程
2009年10月27日 浏览 15,738 次
例如要查看的地址是
http://127.0.0.1:8080/uchome/space.php?uid=1&do=album&view=we
是”好友最新相册的链接”
相对应该的文件是space_album.php
首页显示所有好友的相册,现在我们要讨论的是关于加密的相册,点加密码的相册
比如加密相册的地址是:http://127.0.0.1:8080/uchome/space.php?uid=3&do=album&id=2
其中的id为相册的id
if($id) {
//图片列表
$perpage = 20;
$perpage = mob_perpage($perpage);
$start = ($page-1)*$perpage;
//检查开始数
ckstart($start, $perpage);
//查询相册
if($id > 0) {
$query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('album')." WHERE albumid='$id' AND uid='$space[uid]' LIMIT 1");//该用户是否存在该相册
$album = $_SGLOBAL['db']->fetch_array($query);
//相册不存在
if(empty($album)) {
//如果相册为空,则提示"出问题了,您要查看的相册不存在"
showmessage('to_view_the_photo_does_not_exist');
}
//检查好友权限
ckfriend_album($album);
//查询
$wheresql = "albumid='$id'";
$count = $album['picnum'];//相册内的图片数
}
}
先判断相册id是否存在,然后通过相册id查找相册信息。
如果相册存在则通过 ckfriend_album($album);检查好友权限
function ckfriend_album($album) {
global $_SGLOBAL, $_SC, $_SCONFIG, $_SCOOKIE, $space, $_SN;
if(!ckfriend($album['uid'], $album['friend'], $album['target_ids'])) {
//检测图片开放的浏览的权限
//没有权限
include template('space_privacy');
exit();
} elseif(!$space['self'] && $album['friend'] == 4) {
//如果friend为4的话,则表示只有自己或要输入密码才能查看
//密码输入问题
$cookiename = "view_pwd_album_$album[albumid]";//与输入密码验证时生成的cookie密码进行匹配
$cookievalue = empty($_SCOOKIE[$cookiename])?'':$_SCOOKIE[$cookiename];
if($cookievalue != md5(md5($album['password']))) {
$invalue = $album;
include template('do_inputpwd');
exit();
}
}
}
如果查看的不是创建相册的本人,或是相册设置过了密码,则判断是否设置了该相册的$_SCOOKIE["view_pwd_album_$album[albumid]“]
如果不存在则显示输入密码页面do_inputpwd.htm,输入密码后提交do_input.php文件进行信息判断
if(submitcheck('pwdsubmit')) {
$blogid = empty($_POST['blogid'])?0:intval($_POST['blogid']); //日志
$albumid = empty($_POST['albumid'])?0:intval($_POST['albumid']); //相册
$itemarr = array();
if($blogid) {
$query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('blog')." WHERE blogid='$blogid'");
$itemarr = $_SGLOBAL['db']->fetch_array($query);
$itemurl = "space.php?uid=$itemarr[uid]&do=blog&id=$itemarr[blogid]";
$cookiename = 'view_pwd_blog_'.$blogid;
} elseif($albumid) {
//查看相册的信息
$query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('album')." WHERE albumid='$albumid'");
$itemarr = $_SGLOBAL['db']->fetch_array($query);
$itemurl = "space.php?uid=$itemarr[uid]&do=album&id=$itemarr[albumid]";
//设置相册的$_COOKIE名
$cookiename = 'view_pwd_album_'.$albumid;
}
if(empty($itemarr)) {
showmessage('news_does_not_exist');
}
if($itemarr['password'] && $_POST['viewpwd'] == $itemarr['password']) {
//如果密码存在,并且输入的密码与相册中的密码相同,则设置$_COOKE值
ssetcookie($cookiename, md5(md5($itemarr['password'])));
showmessage('proved_to_be_successful', $itemurl);
} else {
showmessage('password_is_not_passed', $itemurl);
}
}
通过这张页面的判断,如果输入的密码正确,则返回到刚才查看的相册,重新检查用户的权限
$cookievalue = empty($_SCOOKIE[$cookiename])?'':$_SCOOKIE[$cookiename];
if($cookievalue != md5(md5($album['password']))) {
$invalue = $album;
include template('do_inputpwd');
exit();
}
因为刚才设置过了cookie,所以这次将返回真。
这差不多就是相册密码查看的程序处理流程,像uchome中的日志关于查看加密日志程序处理过程与这个差不多