|
Posted by Mike on 02/06/06 20:40
"Jerry Stuckle" <jstucklex@attglobal.net> wrote in message
news:jpSdncRvI4QQpHrenZ2dnUVZ_t2dnZ2d@comcast.com...
Mike wrote:
> Okay, start from scratch.
>
>
> Define code
>
> define('CERTACCESS_MEMENTRY', 0x01);
>
>
> Function
>
> function SecurityLevel_Check($security_byte, $securitylevel_bit) {
> //AND = 1 IF BOTH are 1
> echo "<P>SecurityLevel_Check";
> $binanswer = $security_byte & $securitylevel_bit;
> echo "<P>nonbin byte=".$security_byte." /bit=".$securitylevel_bit." /nonbin result is
> ".$binanswer;
> return $security_byte & $securitylevel_bit; }
>
>
> $securitylevel_bit is the defines like the one above. The $security_byte is the data in the
> database
> record for a person.
>
>
> Output is
> SecurityLevel_Check
>
> nonbin byte=xFE /bit=2 /nonbin result is 0
>
> SecurityLevel_Check
>
> nonbin byte=xFE /bit=1 /nonbin result is 0
>
> SecurityLevel_Check
>
> nonbin byte=xFE /bit=4 /nonbin result is 0
>
> SecurityLevel_Check
>
> nonbin byte=xFE /bit=8 /nonbin result is 0
>
> SecurityLevel_Check
>
> nonbin byte=xFE /bit=16 /nonbin result is 0
>
> SecurityLevel_Check
>
> nonbin byte=xFE /bit=32 /nonbin result is 0
>
> SecurityLevel_Check
>
> nonbin byte=xFE /bit=128 /nonbin result is 0
>
> SecurityLevel_Check
>
> nonbin byte=0x00 /bit=1 /nonbin result is 0
>
> SecurityLevel_Check
>
> nonbin byte=0x00 /bit=2 /nonbin result is 0
>
> SecurityLevel_Check
>
> nonbin byte=0x00 /bit=4 /nonbin result is 0
>
> SecurityLevel_Check
>
> nonbin byte=0x00 /bit=8 /nonbin result is 0
>
> SecurityLevel_Check
>
> nonbin byte=0x00 /bit=16 /nonbin result is 0
>
>
Mike,
You're getting closer - but you're still passing the STRING "xFE" as the
first parameter, not a HEX value. When converted to a number for the
bit operations, the string will be converted to zero.
You need to pass a numeric value to the function.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Ah, I did not catch that since I changed the user records. It puzzled me then I remembered DUH! the
organization records. So they are now changed.
However, everything still comes back zero. A question I do have is why does the first number
(varbinary(8) in MySQL) come back hex but the second number (PHP code as
define('CERTACCESS_MEMENTRY', 0x01);) come back as decimal (or so it looks like)? Could that be the
problem?
function SecurityLevel_Check($security_byte, $securitylevel_bit) {
// & = 1 IF BOTH are 1
echo "<P>SecurityLevel_Check";
$binanswer = $security_byte & $securitylevel_bit;
echo "<P>nonbin byte=".$security_byte." /bit=".$securitylevel_bit." /nonbin result is ".$binanswer;
return $security_byte & $securitylevel_bit; }
SecurityLevel_Check
nonbin byte=0xFE /bit=2 /nonbin result is 0
SecurityLevel_Check
nonbin byte=0xFE /bit=1 /nonbin result is 0
SecurityLevel_Check
nonbin byte=0xFE /bit=4 /nonbin result is 0
SecurityLevel_Check
nonbin byte=0xFE /bit=8 /nonbin result is 0
SecurityLevel_Check
nonbin byte=0xFE /bit=16 /nonbin result is 0
SecurityLevel_Check
nonbin byte=0xFE /bit=32 /nonbin result is 0
SecurityLevel_Check
nonbin byte=0xFE /bit=128 /nonbin result is 0
SecurityLevel_Check
nonbin byte=0x00 /bit=1 /nonbin result is 0
SecurityLevel_Check
nonbin byte=0x00 /bit=2 /nonbin result is 0
SecurityLevel_Check
nonbin byte=0x00 /bit=4 /nonbin result is 0
SecurityLevel_Check
nonbin byte=0x00 /bit=8 /nonbin result is 0
SecurityLevel_Check
nonbin byte=0x00 /bit=16 /nonbin result is 0
SecurityLevel_Check
nonbin byte=0x00 /bit=32 /nonbin result is 0
SecurityLevel_Check
nonbin byte=0x00 /bit=64 /nonbin result is 0
SecurityLevel_Check
nonbin byte=0x6E /bit=4 /nonbin result is 0
SecurityLevel_Check
nonbin byte=0x6E /bit=8 /nonbin result is 0
SecurityLevel_Check
nonbin byte=0x6E /bit=16 /nonbin result is 0
SecurityLevel_Check
nonbin byte=0x6E /bit=32 /nonbin result is 0
SecurityLevel_Check
nonbin byte=0x04 /bit=1 /nonbin result is 0
SecurityLevel_Check
nonbin byte=0x04 /bit=2 /nonbin result is 0
SecurityLevel_Check
nonbin byte=0x04 /bit=4 /nonbin result is 0
SecurityLevel_Check
nonbin byte=0x04 /bit=8 /nonbin result is 0
SecurityLevel_Check
nonbin byte=0x04 /bit=16 /nonbin result is 0
SecurityLevel_Check
nonbin byte=0x04 /bit=32 /nonbin result is 0
SecurityLevel_Check
nonbin byte=0x01 /bit=1 /nonbin result is 0
SecurityLevel_Check
nonbin byte=0x01 /bit=2 /nonbin result is 0
SecurityLevel_Check
nonbin byte=0x01 /bit=4 /nonbin result is 0
Navigation:
[Reply to this message]
|