if not array of array(s) -> ERROR ---------------------------------------------------------*/ /* (1) If not array of array(s) -> ERROR */ foreach($expected as $permission_group) if( !is_array($permission_group) ) return new Error(Err::FormatError); /* (2) For each OR group ---------------------------------------------------------*/ foreach($expected as $OR_group){ /* (1) By default suppose the group is valid */ // -> an empty group will grant permission to all $valid_group = true; /* (2) Check for each AND permission in the group */ foreach($OR_group as $AND_perm){ /* (3) If not in session.auth -> invalidate the permission group */ if( !in_array($AND_perm, $_SESSION['AUTH']) ){ $valid_group = false; break; } } /* (4) If valid group -> Success */ if( $valid_group ) return new Error(Err::Success); } /* (5) If no valid group -> permission error */ return new Error(Err::PermissionError); } } ?>