/** * Used for determining if Forum ID is authed, please use this Function on all Posting Screens */ function is_forum_authed($auth_cache, $check_forum_id) { $one_char_encoding = '#'; $two_char_encoding = '.'; if (trim($auth_cache) == '') { return true; } $auth = array(); $auth_len = 1; for ($pos = 0; $pos < strlen($auth_cache); $pos += $auth_len) { $forum_auth = substr($auth_cache, $pos, 1); if ($forum_auth == $one_char_encoding) { $auth_len = 1; continue; } elseif ($forum_auth == $two_char_encoding) { $auth_len = 2; $pos--; continue; } $forum_auth = substr($auth_cache, $pos, $auth_len); $forum_id = (int) base64_unpack($forum_auth); if ($forum_id == $check_forum_id) { return true; } } return false; }
/** * Reverse the auth_pack process */ function auth_unpack($auth_cache) { $one_char_encoding = '#'; $two_char_encoding = '.'; $auth = array(); $auth_len = 1; for ($pos = 0; $pos < strlen($auth_cache); $pos += $auth_len) { $forum_auth = substr($auth_cache, $pos, 1); if ($forum_auth == $one_char_encoding) { $auth_len = 1; continue; } elseif ($forum_auth == $two_char_encoding) { $auth_len = 2; $pos--; continue; } $forum_auth = substr($auth_cache, $pos, $auth_len); $forum_id = base64_unpack($forum_auth); $auth[] = intval($forum_id); } return $auth; }
/** * Obtain list of forums in which different attachment categories can be used */ function phpbb_attachment_forum_perms($forum_permissions) { if (empty($forum_permissions)) { return ''; } // Decode forum permissions $forum_ids = array(); $one_char_encoding = '#'; $two_char_encoding = '.'; $auth_len = 1; for ($pos = 0; $pos < strlen($forum_permissions); $pos += $auth_len) { $forum_auth = substr($forum_permissions, $pos, 1); if ($forum_auth == $one_char_encoding) { $auth_len = 1; continue; } else if ($forum_auth == $two_char_encoding) { $auth_len = 2; $pos--; continue; } $forum_auth = substr($forum_permissions, $pos, $auth_len); $forum_id = base64_unpack($forum_auth); $forum_ids[] = (int) $forum_id; } if (sizeof($forum_ids)) { return attachment_forum_perms($forum_ids); } return ''; }