php学习3(权限判断)
2008-03-12 19:01
288 查看
#///////权限封装的是否有权限的处理////////////
function ModlePowerBool($BtypeValue,$BtypeSign){
$FinValue=0; //最终的返回数值
if(($BtypeValue&$BtypeSign)==$BtypeSign)
$FinValue=1;
return $FinValue;
}
function BitDouble($DecValue,$Type=2){
$FinValue=0; //最终的返回数组-1为定义起始点
$TmpFinValue=array(-1 => true); //最终的返回数组-1为定义起始点
$DecArrayValue=DecToBitArray($DecValue);
foreach($DecArrayValue as $DecValue)
{
for($IntFor=0;$IntFor<$Type;$IntFor++)
{
$TmpFinValue[]=$DecValue;
}
}
$FinValue=BitArrayToDec($TmpFinValue);
return $FinValue;
}
//返回为1,0.
function ChildModlePowerBool($BtypeValue,$ChildBtypeValue,$BtypeSign){
$FinValue=0;
$TmpValue=BitDouble($BtypeValue);
$TmpValue=$TmpValue&$ChildBtypeValue;
$FinValue=ModlePowerBool($TmpValue,$BtypeSign);
return $FinValue;
}
//返回为"true","false"字符.
function ChildModlePowerBoolEx($BtypeValue,$ChildBtypeValue,$BtypeSign){
$FinValue="false";
$TmpValue=BitDouble($BtypeValue);
$TmpValue=$TmpValue&$ChildBtypeValue;
if(ModlePowerBool($TmpValue,$BtypeSign))
$FinValue="true";
return $FinValue;
}
function ModlePowerBool($BtypeValue,$BtypeSign){
$FinValue=0; //最终的返回数值
if(($BtypeValue&$BtypeSign)==$BtypeSign)
$FinValue=1;
return $FinValue;
}
function BitDouble($DecValue,$Type=2){
$FinValue=0; //最终的返回数组-1为定义起始点
$TmpFinValue=array(-1 => true); //最终的返回数组-1为定义起始点
$DecArrayValue=DecToBitArray($DecValue);
foreach($DecArrayValue as $DecValue)
{
for($IntFor=0;$IntFor<$Type;$IntFor++)
{
$TmpFinValue[]=$DecValue;
}
}
$FinValue=BitArrayToDec($TmpFinValue);
return $FinValue;
}
//返回为1,0.
function ChildModlePowerBool($BtypeValue,$ChildBtypeValue,$BtypeSign){
$FinValue=0;
$TmpValue=BitDouble($BtypeValue);
$TmpValue=$TmpValue&$ChildBtypeValue;
$FinValue=ModlePowerBool($TmpValue,$BtypeSign);
return $FinValue;
}
//返回为"true","false"字符.
function ChildModlePowerBoolEx($BtypeValue,$ChildBtypeValue,$BtypeSign){
$FinValue="false";
$TmpValue=BitDouble($BtypeValue);
$TmpValue=$TmpValue&$ChildBtypeValue;
if(ModlePowerBool($TmpValue,$BtypeSign))
$FinValue="true";
return $FinValue;
}
相关文章推荐
- php学习基础-文件系统(一) 文件处理,文件权限
- php中判断文件空目录是否有读写权限
- php学习:array->判断值在数组中是否存在
- 【小白笔记】PHP学习之路 (25) --文件判断与操作
- php运用readfile函数给隐藏下载文件地址增加权限判断
- php 权限数据库设计,很值得学习
- PHP学习笔记之字符串编码的转换和判断
- PHP学习笔记之字符串编码的转换和判断
- php判断是否有权限下载
- php——学习笔记,var_dump来判断表达式是否正确
- php学习 之 Smarty 逻辑判断 和 循环
- [PHP学习教程 - 文件]002.判断远程文件是否存在(Remote File Exists)
- PHP会员登录,和判断用户权限,登录超时踢除用户
- PHP会员登录,和判断用户权限,登录超时踢除用户
- php学习笔记 定义常量,包含文件,判断常量是否存在
- php中判断文件空目录是否有读写权限的函数代码
- [PHP学习]Js判断跳转PC还是Wap端网站方法
- php学习之道:php中is_file和file_exist的区别,and判断目录is_dir
- php判断文件夹是否存在0777权限判断