//检查隐私
function ckprivacy($type, $feedmode=0) { //feedmode =0,则为view的隐私,不等于0,则为feed的隐私
global $_SGLOBAL, $space, $_SCONFIG;
$var = "ckprivacy_{$type}_{$feedmode}"; //此三句为避免重复检查,提高效率
if(isset($_SGLOBAL[$var])) {
return $_SGLOBAL[$var];
}
$result = false; //初始化
if($feedmode) {
if($type == 'spaceopen') {
if(!empty($_SCONFIG['privacy']['feed'][$type])) { //还没有开通space的,从$_CONFIG中作判断
$result = true;
}
} elseif(!empty($space['privacy']['feed'][$type])) { //已经开通的,从space中作判断,这个参数的赋值是由getspace中 $space['privacy'] = empty($space['privacy'])?(empty($_SCONFIG['privacy'])?array():$_SCONFIG['privacy']):unserialize($space['privacy']);获得的,其实就是取$_SCONFIG['privacy']的值,$_SCONFIG['privacy']的值是在/data/data_config.php中进行的。
$result = true;
}
} elseif($space['self']){ //view的赋值 访问自己的space
//自己
$result = true;
} else {
if(empty($space['privacy']['view'][$type])) { //值为0,则有权限
$result = true;
}
if(!$result && $space['privacy']['view'][$type] == 1) { //值为1,则如果是好友,则有权限
//是否好友
if(!isset($space['isfriend'])) { //尚未判断好友的,用以下三句进行判断
$space['isfriend'] = $space['self']; //此句意义不大,
if($space['friends'] && in_array($_SGLOBAL['supe_uid'], $space['friends'])) {
$space['isfriend'] = 1;//是好友
}
}
if($space['isfriend']) {
$result = true;
}
}
}
$_SGLOBAL[$var] = $result;//当前页面缓存
return $result;
}
ckprivacy 重要注释保存供查阅
最新推荐文章于 2022-11-13 20:15:03 发布