本文整理汇总了PHP中auth::acl方法的典型用法代码示例。如果您正苦于以下问题:PHP auth::acl方法的具体用法?PHP auth::acl怎么用?PHP auth::acl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类auth
的用法示例。
在下文中一共展示了auth::acl方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: main
function main($id, $mode)
{
global $config, $phpbb_root_path, $phpEx;
global $db, $user, $auth, $template;
$username = request_var('username', '', true);
$email = strtolower(request_var('email', ''));
$submit = isset($_POST['submit']) ? true : false;
if ($submit) {
$sql = 'SELECT user_id, username, user_permissions, user_email, user_jabber, user_notify_type, user_type, user_lang, user_inactive_reason
FROM ' . USERS_TABLE . "\n\t\t\t\tWHERE user_email = '" . $db->sql_escape($email) . "'\n\t\t\t\t\tAND username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'";
$result = $db->sql_query($sql);
$user_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if (!$user_row) {
trigger_error('NO_EMAIL_USER');
}
if ($user_row['user_type'] == USER_IGNORE) {
trigger_error('NO_USER');
}
if ($user_row['user_type'] == USER_INACTIVE) {
if ($user_row['user_inactive_reason'] == INACTIVE_MANUAL) {
trigger_error('ACCOUNT_DEACTIVATED');
} else {
trigger_error('ACCOUNT_NOT_ACTIVATED');
}
}
// Check users permissions
$auth2 = new auth();
$auth2->acl($user_row);
if (!$auth2->acl_get('u_chgpasswd')) {
trigger_error('NO_AUTH_PASSWORD_REMINDER');
}
$server_url = generate_board_url();
$key_len = 54 - strlen($server_url);
$key_len = max(6, $key_len);
// we want at least 6
$key_len = $config['max_pass_chars'] ? min($key_len, $config['max_pass_chars']) : $key_len;
// we want at most $config['max_pass_chars']
$user_actkey = substr(gen_rand_string(10), 0, $key_len);
$user_password = gen_rand_string(8);
$sql = 'UPDATE ' . USERS_TABLE . "\n\t\t\t\tSET user_newpasswd = '" . $db->sql_escape(phpbb_hash($user_password)) . "', user_actkey = '" . $db->sql_escape($user_actkey) . "'\n\t\t\t\tWHERE user_id = " . $user_row['user_id'];
$db->sql_query($sql);
include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
$messenger = new messenger(false);
$messenger->template('user_activate_passwd', $user_row['user_lang']);
$messenger->to($user_row['user_email'], $user_row['username']);
$messenger->im($user_row['user_jabber'], $user_row['username']);
$messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($user_row['username']), 'PASSWORD' => htmlspecialchars_decode($user_password), 'U_ACTIVATE' => "{$server_url}/ucp.{$phpEx}?mode=activate&u={$user_row['user_id']}&k={$user_actkey}"));
$messenger->send($user_row['user_notify_type']);
meta_refresh(3, append_sid("{$phpbb_root_path}index.{$phpEx}"));
$message = $user->lang['PASSWORD_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.{$phpEx}") . '">', '</a>');
trigger_error($message);
}
$template->assign_vars(array('USERNAME' => $username, 'EMAIL' => $email, 'S_PROFILE_ACTION' => append_sid($phpbb_root_path . 'ucp.' . $phpEx, 'mode=sendpassword')));
$this->tpl_name = 'ucp_remind';
$this->page_title = 'UCP_REMIND';
}
示例2: main
public function main()
{
global $config, $phpbb_root_path, $phpEx;
global $db, $user, $auth, $template;
$username = request_var('username', '', true);
$sql = 'SELECT user_id, username, user_permissions, user_email, user_jabber, user_notify_type, user_type, user_lang, user_inactive_reason
FROM ' . USERS_TABLE . "\r\r\n\t\t\tWHERE username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'";
$result = $db->sql_query($sql);
$user_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if (!$user_row) {
trigger_error('NO_EMAIL_USER');
}
if ($user_row['user_type'] == USER_IGNORE) {
trigger_error('NO_USER');
}
if ($user_row['user_type'] == USER_INACTIVE) {
if ($user_row['user_inactive_reason'] == INACTIVE_MANUAL) {
trigger_error('ACCOUNT_DEACTIVATED');
} else {
trigger_error('ACCOUNT_NOT_ACTIVATED');
}
}
// Check users permissions
$auth2 = new auth();
$auth2->acl($user_row);
if (!$auth2->acl_get('u_chgpasswd')) {
trigger_error('NO_AUTH_PASSWORD_REMINDER');
}
$result = tt_register_verify($_POST['tt_token'], $_POST['tt_code']);
if ($result->result && $user_row['user_email'] == $result->email) {
$this->result = true;
$this->verify = true;
return;
}
$this->result = false;
$this->result_text = 'Sorry, you can only retrieve your password from browser.';
return;
}
示例3: check_rule
/**
* Check Rule against Message Information
*/
function check_rule(&$rules, &$rule_row, &$message_row, $user_id)
{
global $user, $config;
if (!isset($rules[$rule_row['rule_check']][$rule_row['rule_connection']])) {
return false;
}
$check_ary = $rules[$rule_row['rule_check']][$rule_row['rule_connection']];
// Replace Check Literals
$evaluate = $check_ary['function'];
$evaluate = preg_replace('/{(CHECK[0-9])}/', '$message_row[$check_ary[strtolower("\\1")]]', $evaluate);
// Replace Rule Literals
$evaluate = preg_replace('/{(STRING|USER_ID|GROUP_ID)}/', '$rule_row["rule_" . strtolower("\\1")]', $evaluate);
// Evil Statement
$result = false;
eval('$result = (' . $evaluate . ') ? true : false;');
if (!$result) {
return false;
}
switch ($rule_row['rule_action']) {
case ACTION_PLACE_INTO_FOLDER:
return array('action' => $rule_row['rule_action'], 'folder_id' => $rule_row['rule_folder_id']);
break;
case ACTION_MARK_AS_READ:
case ACTION_MARK_AS_IMPORTANT:
return array('action' => $rule_row['rule_action'], 'pm_unread' => $message_row['pm_unread'], 'pm_marked' => $message_row['pm_marked']);
break;
case ACTION_DELETE_MESSAGE:
global $db, $auth;
// Check for admins/mods - users are not allowed to remove those messages...
// We do the check here to make sure the data we use is consistent
$sql = 'SELECT user_id, user_type, user_permissions
FROM ' . USERS_TABLE . '
WHERE user_id = ' . (int) $message_row['author_id'];
$result = $db->sql_query($sql);
$userdata = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$auth2 = new auth();
$auth2->acl($userdata);
if (!$auth2->acl_get('a_') && !$auth2->acl_get('m_') && !$auth2->acl_getf_global('m_')) {
return array('action' => $rule_row['rule_action'], 'pm_unread' => $message_row['pm_unread'], 'pm_marked' => $message_row['pm_marked']);
}
return false;
break;
default:
return false;
}
return false;
}
示例4: isset
/**
* Handles warning the user
*/
function mcp_warn_user_view($action)
{
global $phpEx, $phpbb_root_path, $config, $module;
global $template, $db, $user, $auth;
$user_id = request_var('u', 0);
$username = request_var('username', '', true);
$notify = isset($_REQUEST['notify_user']) ? true : false;
$warning = utf8_normalize_nfc(request_var('warning', '', true));
$sql_where = $user_id ? "user_id = {$user_id}" : "username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'";
$sql = 'SELECT *
FROM ' . USERS_TABLE . '
WHERE ' . $sql_where;
$result = $db->sql_query($sql);
$user_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if (!$user_row) {
trigger_error('NO_USER');
}
// Prevent someone from warning themselves
if ($user_row['user_id'] == $user->data['user_id']) {
trigger_error('CANNOT_WARN_SELF');
}
$user_id = $user_row['user_id'];
if (strpos($this->u_action, "&u={$user_id}") === false) {
$this->p_master->adjust_url('&u=' . $user_id);
$this->u_action .= "&u={$user_id}";
}
// Check if can send a notification
if ($config['allow_privmsg']) {
$auth2 = new auth();
$auth2->acl($user_row);
$s_can_notify = $auth2->acl_get('u_readpm') ? true : false;
unset($auth2);
} else {
$s_can_notify = false;
}
// Prevent against clever people
if ($notify && !$s_can_notify) {
$notify = false;
}
if ($warning && $action == 'add_warning') {
if (check_form_key('mcp_warn')) {
add_warning($user_row, $warning, $notify);
$msg = $user->lang['USER_WARNING_ADDED'];
} else {
$msg = $user->lang['FORM_INVALID'];
}
$redirect = append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i=notes&mode=user_notes&u={$user_id}");
meta_refresh(2, $redirect);
trigger_error($msg . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
}
// Generate the appropriate user information for the user we are looking at
if (!function_exists('get_user_avatar')) {
include $phpbb_root_path . 'includes/functions_display.' . $phpEx;
}
$rank_title = $rank_img = '';
$avatar_img = get_user_avatar($user_row['user_avatar'], $user_row['user_avatar_type'], $user_row['user_avatar_width'], $user_row['user_avatar_height']);
// OK, they didn't submit a warning so lets build the page for them to do so
$template->assign_vars(array('U_POST_ACTION' => $this->u_action, 'RANK_TITLE' => $rank_title, 'JOINED' => $user->format_date($user_row['user_regdate']), 'POSTS' => $user_row['user_posts'] ? $user_row['user_posts'] : 0, 'WARNINGS' => $user_row['user_warnings'] ? $user_row['user_warnings'] : 0, 'USERNAME_FULL' => get_username_string('full', $user_row['user_id'], $user_row['username'], $user_row['user_colour']), 'USERNAME_COLOUR' => get_username_string('colour', $user_row['user_id'], $user_row['username'], $user_row['user_colour']), 'USERNAME' => get_username_string('username', $user_row['user_id'], $user_row['username'], $user_row['user_colour']), 'U_PROFILE' => get_username_string('profile', $user_row['user_id'], $user_row['username'], $user_row['user_colour']), 'AVATAR_IMG' => $avatar_img, 'RANK_IMG' => $rank_img, 'S_CAN_NOTIFY' => $s_can_notify));
return $user_id;
}
示例5: array
/**
* Display a complete trace tree for the selected permission to determine where settings are set/unset
*/
function permission_trace($user_id, $forum_id, $permission)
{
global $db, $template, $user, $auth;
if ($user_id != $user->data['user_id']) {
$sql = 'SELECT user_id, username, user_permissions, user_type
FROM ' . USERS_TABLE . '
WHERE user_id = ' . $user_id;
$result = $db->sql_query($sql);
$userdata = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
} else {
$userdata = $user->data;
}
if (!$userdata) {
trigger_error('NO_USERS', E_USER_ERROR);
}
$forum_name = false;
if ($forum_id) {
$sql = 'SELECT forum_name
FROM ' . FORUMS_TABLE . "\n\t\t\t\tWHERE forum_id = {$forum_id}";
$result = $db->sql_query($sql, 3600);
$forum_name = $db->sql_fetchfield('forum_name');
$db->sql_freeresult($result);
}
$back = request_var('back', 0);
$template->assign_vars(array('PERMISSION' => $user->lang['acl_' . $permission]['lang'], 'PERMISSION_USERNAME' => $userdata['username'], 'FORUM_NAME' => $forum_name, 'S_GLOBAL_TRACE' => $forum_id ? false : true, 'U_BACK' => $back ? build_url(array('f', 'back')) . "&f={$back}" : ''));
$template->assign_block_vars('trace', array('WHO' => $user->lang['DEFAULT'], 'INFORMATION' => $user->lang['TRACE_DEFAULT'], 'S_SETTING_NO' => true, 'S_TOTAL_NO' => true));
$sql = 'SELECT DISTINCT g.group_name, g.group_id, g.group_type
FROM ' . GROUPS_TABLE . ' g
LEFT JOIN ' . USER_GROUP_TABLE . ' ug ON (ug.group_id = g.group_id)
WHERE ug.user_id = ' . $user_id . '
AND ug.user_pending = 0
ORDER BY g.group_type DESC, g.group_id DESC';
$result = $db->sql_query($sql);
$groups = array();
while ($row = $db->sql_fetchrow($result)) {
$groups[$row['group_id']] = array('auth_setting' => ACL_NO, 'group_name' => $row['group_type'] == GROUP_SPECIAL ? $user->lang['G_' . $row['group_name']] : $row['group_name']);
}
$db->sql_freeresult($result);
$total = ACL_NO;
$add_key = $forum_id ? '_LOCAL' : '';
if (sizeof($groups)) {
// Get group auth settings
$hold_ary = $auth->acl_group_raw_data(array_keys($groups), $permission, $forum_id);
foreach ($hold_ary as $group_id => $forum_ary) {
$groups[$group_id]['auth_setting'] = $hold_ary[$group_id][$forum_id][$permission];
}
unset($hold_ary);
foreach ($groups as $id => $row) {
switch ($row['auth_setting']) {
case ACL_NO:
$information = $user->lang['TRACE_GROUP_NO' . $add_key];
break;
case ACL_YES:
$information = $total == ACL_YES ? $user->lang['TRACE_GROUP_YES_TOTAL_YES' . $add_key] : ($total == ACL_NEVER ? $user->lang['TRACE_GROUP_YES_TOTAL_NEVER' . $add_key] : $user->lang['TRACE_GROUP_YES_TOTAL_NO' . $add_key]);
$total = $total == ACL_NO ? ACL_YES : $total;
break;
case ACL_NEVER:
$information = $total == ACL_YES ? $user->lang['TRACE_GROUP_NEVER_TOTAL_YES' . $add_key] : ($total == ACL_NEVER ? $user->lang['TRACE_GROUP_NEVER_TOTAL_NEVER' . $add_key] : $user->lang['TRACE_GROUP_NEVER_TOTAL_NO' . $add_key]);
$total = ACL_NEVER;
break;
}
$template->assign_block_vars('trace', array('WHO' => $row['group_name'], 'INFORMATION' => $information, 'S_SETTING_NO' => $row['auth_setting'] == ACL_NO ? true : false, 'S_SETTING_YES' => $row['auth_setting'] == ACL_YES ? true : false, 'S_SETTING_NEVER' => $row['auth_setting'] == ACL_NEVER ? true : false, 'S_TOTAL_NO' => $total == ACL_NO ? true : false, 'S_TOTAL_YES' => $total == ACL_YES ? true : false, 'S_TOTAL_NEVER' => $total == ACL_NEVER ? true : false));
}
}
// Get user specific permission... globally or for this forum
$hold_ary = $auth->acl_user_raw_data($user_id, $permission, $forum_id);
$auth_setting = !sizeof($hold_ary) ? ACL_NO : $hold_ary[$user_id][$forum_id][$permission];
switch ($auth_setting) {
case ACL_NO:
$information = $total == ACL_NO ? $user->lang['TRACE_USER_NO_TOTAL_NO' . $add_key] : $user->lang['TRACE_USER_KEPT' . $add_key];
$total = $total == ACL_NO ? ACL_NEVER : $total;
break;
case ACL_YES:
$information = $total == ACL_YES ? $user->lang['TRACE_USER_YES_TOTAL_YES' . $add_key] : ($total == ACL_NEVER ? $user->lang['TRACE_USER_YES_TOTAL_NEVER' . $add_key] : $user->lang['TRACE_USER_YES_TOTAL_NO' . $add_key]);
$total = $total == ACL_NO ? ACL_YES : $total;
break;
case ACL_NEVER:
$information = $total == ACL_YES ? $user->lang['TRACE_USER_NEVER_TOTAL_YES' . $add_key] : ($total == ACL_NEVER ? $user->lang['TRACE_USER_NEVER_TOTAL_NEVER' . $add_key] : $user->lang['TRACE_USER_NEVER_TOTAL_NO' . $add_key]);
$total = ACL_NEVER;
break;
}
$template->assign_block_vars('trace', array('WHO' => $userdata['username'], 'INFORMATION' => $information, 'S_SETTING_NO' => $auth_setting == ACL_NO ? true : false, 'S_SETTING_YES' => $auth_setting == ACL_YES ? true : false, 'S_SETTING_NEVER' => $auth_setting == ACL_NEVER ? true : false, 'S_TOTAL_NO' => false, 'S_TOTAL_YES' => $total == ACL_YES ? true : false, 'S_TOTAL_NEVER' => $total == ACL_NEVER ? true : false));
if ($forum_id != 0 && isset($auth->acl_options['global'][$permission])) {
if ($user_id != $user->data['user_id']) {
$auth2 = new auth();
$auth2->acl($userdata);
$auth_setting = $auth2->acl_get($permission);
} else {
$auth_setting = $auth->acl_get($permission);
}
if ($auth_setting) {
$information = $total == ACL_YES ? $user->lang['TRACE_USER_GLOBAL_YES_TOTAL_YES'] : $user->lang['TRACE_USER_GLOBAL_YES_TOTAL_NEVER'];
$total = ACL_YES;
} else {
$information = $user->lang['TRACE_USER_GLOBAL_NEVER_TOTAL_KEPT'];
}
//.........这里部分代码省略.........
示例6: main
function main($id, $mode)
{
global $config, $db, $user, $auth, $template, $cache;
global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix, $file_uploads;
$user->add_lang(array('posting', 'ucp', 'acp/users'));
$this->tpl_name = 'acp_users';
$this->page_title = 'ACP_USER_' . strtoupper($mode);
$error = array();
$username = utf8_normalize_nfc(request_var('username', '', true));
$user_id = request_var('u', 0);
$action = request_var('action', '');
$submit = isset($_POST['update']) && !isset($_POST['cancel']) ? true : false;
$form_name = 'acp_users';
add_form_key($form_name);
// Whois (special case)
if ($action == 'whois') {
include $phpbb_root_path . 'includes/functions_user.' . $phpEx;
$this->page_title = 'WHOIS';
$this->tpl_name = 'simple_body';
$user_ip = request_var('user_ip', '');
$domain = gethostbyaddr($user_ip);
$ipwhois = user_ipwhois($user_ip);
$template->assign_vars(array('MESSAGE_TITLE' => sprintf($user->lang['IP_WHOIS_FOR'], $domain), 'MESSAGE_TEXT' => nl2br($ipwhois)));
return;
}
// Show user selection mask
if (!$username && !$user_id) {
$this->page_title = 'SELECT_USER';
$template->assign_vars(array('U_ACTION' => $this->u_action, 'ANONYMOUS_USER_ID' => ANONYMOUS, 'S_SELECT_USER' => true, 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=searchuser&form=select_user&field=username&select_single=true')));
return;
}
if (!$user_id) {
$sql = 'SELECT user_id
FROM ' . USERS_TABLE . "\n\t\t\t\tWHERE username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'";
$result = $db->sql_query($sql);
$user_id = (int) $db->sql_fetchfield('user_id');
$db->sql_freeresult($result);
if (!$user_id) {
trigger_error($user->lang['NO_USER'] . adm_back_link($this->u_action), E_USER_WARNING);
}
}
// Generate content for all modes
$sql = 'SELECT u.*, s.*
FROM ' . USERS_TABLE . ' u
LEFT JOIN ' . SESSIONS_TABLE . ' s ON (s.session_user_id = u.user_id)
WHERE u.user_id = ' . $user_id . '
ORDER BY s.session_time DESC';
$result = $db->sql_query_limit($sql, 1);
$user_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if (!$user_row) {
trigger_error($user->lang['NO_USER'] . adm_back_link($this->u_action), E_USER_WARNING);
}
// Generate overall "header" for user admin
$s_form_options = '';
// Build modes dropdown list
$sql = 'SELECT module_mode, module_auth
FROM ' . MODULES_TABLE . "\n\t\t\tWHERE module_basename = 'users'\n\t\t\t\tAND module_enabled = 1\n\t\t\t\tAND module_class = 'acp'\n\t\t\tORDER BY left_id, module_mode";
$result = $db->sql_query($sql);
$dropdown_modes = array();
while ($row = $db->sql_fetchrow($result)) {
if (!$this->p_master->module_auth($row['module_auth'])) {
continue;
}
$dropdown_modes[$row['module_mode']] = true;
}
$db->sql_freeresult($result);
foreach ($dropdown_modes as $module_mode => $null) {
$selected = $mode == $module_mode ? ' selected="selected"' : '';
$s_form_options .= '<option value="' . $module_mode . '"' . $selected . '>' . $user->lang['ACP_USER_' . strtoupper($module_mode)] . '</option>';
}
$template->assign_vars(array('U_BACK' => $this->u_action, 'U_MODE_SELECT' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i={$id}&u={$user_id}"), 'U_ACTION' => $this->u_action . '&u=' . $user_id, 'S_FORM_OPTIONS' => $s_form_options, 'MANAGED_USERNAME' => $user_row['username']));
// Prevent normal users/admins change/view founders if they are not a founder by themselves
if ($user->data['user_type'] != USER_FOUNDER && $user_row['user_type'] == USER_FOUNDER) {
trigger_error($user->lang['NOT_MANAGE_FOUNDER'] . adm_back_link($this->u_action), E_USER_WARNING);
}
switch ($mode) {
case 'overview':
include $phpbb_root_path . 'includes/functions_user.' . $phpEx;
$user->add_lang('acp/ban');
$delete = request_var('delete', 0);
$delete_type = request_var('delete_type', '');
$ip = request_var('ip', 'ip');
if ($submit) {
// You can't delete the founder
if ($delete && $user_row['user_type'] != USER_FOUNDER) {
if (!$auth->acl_get('a_userdel')) {
trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
}
// Check if the user wants to remove himself or the guest user account
if ($user_id == ANONYMOUS) {
trigger_error($user->lang['CANNOT_REMOVE_ANONYMOUS'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
}
if ($user_id == $user->data['user_id']) {
trigger_error($user->lang['CANNOT_REMOVE_YOURSELF'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
}
if ($delete_type) {
if (confirm_box(true)) {
user_delete($delete_type, $user_id, $user_row['username']);
add_log('admin', 'LOG_USER_DELETED', $user_row['username']);
//.........这里部分代码省略.........
示例7: display_user_activity
/**
* Display user activity (action forum/topic)
*/
function display_user_activity(&$userdata)
{
global $auth, $template, $db, $user;
global $phpbb_root_path, $phpEx;
// Init new auth class if user is different
if ($user->data['user_id'] != $userdata['user_id']) {
$auth2 = new auth();
$auth2->acl($userdata);
$post_count_ary = $auth2->acl_getf('!f_postcount');
} else {
$post_count_ary = $auth->acl_getf('!f_postcount');
}
$forum_read_ary = $auth->acl_getf('!f_read');
$forum_ary = array();
// Do not include those forums the user is not having read access to...
foreach ($forum_read_ary as $forum_id => $not_allowed) {
if ($not_allowed['f_read']) {
$forum_ary[] = (int) $forum_id;
}
}
// Now do not include those forums where the posts do not count...
foreach ($post_count_ary as $forum_id => $not_counted) {
if ($not_counted['f_postcount']) {
$forum_ary[] = (int) $forum_id;
}
}
$forum_ary = array_unique($forum_ary);
$post_count_sql = sizeof($forum_ary) ? 'AND f.forum_id NOT IN (' . implode(', ', $forum_ary) . ')' : '';
// Firebird does not support ORDER BY on aliased columns
// MySQL does not support ORDER BY on functions
switch (SQL_LAYER) {
case 'firebird':
$sql = 'SELECT f.forum_id, COUNT(p.post_id) AS num_posts
FROM ' . POSTS_TABLE . ' p, ' . FORUMS_TABLE . ' f
WHERE p.poster_id = ' . $userdata['user_id'] . " \n\t\t\t\t\tAND f.forum_id = p.forum_id \n\t\t\t\t\t{$post_count_sql}\n\t\t\t\tGROUP BY f.forum_id\n\t\t\t\tORDER BY COUNT(p.post_id) DESC";
break;
default:
$sql = 'SELECT f.forum_id, COUNT(p.post_id) AS num_posts
FROM ' . POSTS_TABLE . ' p, ' . FORUMS_TABLE . ' f
WHERE p.poster_id = ' . $userdata['user_id'] . " \n\t\t\t\t\tAND f.forum_id = p.forum_id \n\t\t\t\t\t{$post_count_sql}\n\t\t\t\tGROUP BY f.forum_id\n\t\t\t\tORDER BY num_posts DESC";
break;
}
$result = $db->sql_query_limit($sql, 1);
$active_f_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if (!empty($active_f_row)) {
$sql = 'SELECT forum_name
FROM ' . FORUMS_TABLE . '
WHERE forum_id = ' . $active_f_row['forum_id'];
$result = $db->sql_query($sql, 3600);
$active_f_row['forum_name'] = (string) $db->sql_fetchfield('forum_name');
$db->sql_freeresult($result);
}
// Firebird does not support ORDER BY on aliased columns
// MySQL does not support ORDER BY on functions
switch (SQL_LAYER) {
case 'firebird':
$sql = 'SELECT t.topic_id, COUNT(p.post_id) AS num_posts
FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . ' f
WHERE p.poster_id = ' . $userdata['user_id'] . " \n\t\t\t\t\tAND t.topic_id = p.topic_id \n\t\t\t\t\tAND f.forum_id = t.forum_id \n\t\t\t\t\t{$post_count_sql}\n\t\t\t\tGROUP BY t.topic_id\n\t\t\t\tORDER BY COUNT(p.post_id) DESC";
break;
default:
$sql = 'SELECT t.topic_id, COUNT(p.post_id) AS num_posts
FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . ' f
WHERE p.poster_id = ' . $userdata['user_id'] . " \n\t\t\t\t\tAND t.topic_id = p.topic_id \n\t\t\t\t\tAND f.forum_id = t.forum_id \n\t\t\t\t\t{$post_count_sql}\n\t\t\t\tGROUP BY t.topic_id\n\t\t\t\tORDER BY num_posts DESC";
break;
}
$result = $db->sql_query_limit($sql, 1);
$active_t_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if (!empty($active_t_row)) {
$sql = 'SELECT topic_title
FROM ' . TOPICS_TABLE . '
WHERE topic_id = ' . $active_t_row['topic_id'];
$result = $db->sql_query($sql);
$active_t_row['topic_title'] = (string) $db->sql_fetchfield('topic_title');
$db->sql_freeresult($result);
}
$userdata['active_t_row'] = $active_t_row;
$userdata['active_f_row'] = $active_f_row;
$active_f_name = $active_f_id = $active_f_count = $active_f_pct = '';
if (!empty($active_f_row['num_posts'])) {
$active_f_name = $active_f_row['forum_name'];
$active_f_id = $active_f_row['forum_id'];
$active_f_count = $active_f_row['num_posts'];
$active_f_pct = $userdata['user_posts'] ? $active_f_count / $userdata['user_posts'] * 100 : 0;
}
$active_t_name = $active_t_id = $active_t_count = $active_t_pct = '';
if (!empty($active_t_row['num_posts'])) {
$active_t_name = $active_t_row['topic_title'];
$active_t_id = $active_t_row['topic_id'];
$active_t_count = $active_t_row['num_posts'];
$active_t_pct = $userdata['user_posts'] ? $active_t_count / $userdata['user_posts'] * 100 : 0;
}
$template->assign_vars(array('ACTIVE_FORUM' => $active_f_name, 'ACTIVE_FORUM_POSTS' => $active_f_count == 1 ? sprintf($user->lang['USER_POST'], 1) : sprintf($user->lang['USER_POSTS'], $active_f_count), 'ACTIVE_FORUM_PCT' => sprintf($user->lang['POST_PCT'], $active_f_pct), 'ACTIVE_TOPIC' => censor_text($active_t_name), 'ACTIVE_TOPIC_POSTS' => $active_t_count == 1 ? sprintf($user->lang['USER_POST'], 1) : sprintf($user->lang['USER_POSTS'], $active_t_count), 'ACTIVE_TOPIC_PCT' => sprintf($user->lang['POST_PCT'], $active_t_pct), 'U_ACTIVE_FORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $active_f_id), 'U_ACTIVE_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 't=' . $active_t_id)));
}
示例8: array
/**
* Get permission mask
* This function only supports getting permissions of one type (for example a_)
*
* @param set|view $mode defines the permissions we get, view gets effective permissions (checking user AND group permissions), set only gets the user or group permission set alone
* @param mixed $user_id user ids to search for (a user_id or a group_id has to be specified at least)
* @param mixed $group_id group ids to search for, return group related settings (a user_id or a group_id has to be specified at least)
* @param mixed $forum_id forum_ids to search for. Defining a forum id also means getting local settings
* @param string $auth_option the auth_option defines the permission setting to look for (a_ for example)
* @param local|global $scope the scope defines the permission scope. If local, a forum_id is additionally required
* @param ACL_NEVER|ACL_NO|ACL_YES $acl_fill defines the mode those permissions not set are getting filled with
*/
function get_mask($mode, $user_id = false, $group_id = false, $forum_id = false, $auth_option = false, $scope = false, $acl_fill = ACL_NEVER)
{
global $db, $user;
$hold_ary = array();
$view_user_mask = ($mode == 'view' && $group_id === false) ? true : false;
if ($auth_option === false || $scope === false)
{
return array();
}
$acl_user_function = ($mode == 'set') ? 'acl_user_raw_data' : 'acl_raw_data';
if (!$view_user_mask)
{
if ($forum_id !== false)
{
$hold_ary = ($group_id !== false) ? $this->acl_group_raw_data($group_id, $auth_option . '%', $forum_id) : $this->$acl_user_function($user_id, $auth_option . '%', $forum_id);
}
else
{
$hold_ary = ($group_id !== false) ? $this->acl_group_raw_data($group_id, $auth_option . '%', ($scope == 'global') ? 0 : false) : $this->$acl_user_function($user_id, $auth_option . '%', ($scope == 'global') ? 0 : false);
}
}
// Make sure hold_ary is filled with every setting (prevents missing forums/users/groups)
$ug_id = ($group_id !== false) ? ((!is_array($group_id)) ? array($group_id) : $group_id) : ((!is_array($user_id)) ? array($user_id) : $user_id);
$forum_ids = ($forum_id !== false) ? ((!is_array($forum_id)) ? array($forum_id) : $forum_id) : (($scope == 'global') ? array(0) : array());
// Only those options we need
$compare_options = array_diff(preg_replace('/^((?!' . $auth_option . ').+)|(' . $auth_option . ')$/', '', array_keys($this->acl_options[$scope])), array(''));
// If forum_ids is false and the scope is local we actually want to have all forums within the array
if ($scope == 'local' && !sizeof($forum_ids))
{
$sql = 'SELECT forum_id
FROM ' . FORUMS_TABLE;
$result = $db->sql_query($sql, 120);
while ($row = $db->sql_fetchrow($result))
{
$forum_ids[] = $row['forum_id'];
}
$db->sql_freeresult($result);
}
if ($view_user_mask)
{
$auth2 = null;
$sql = 'SELECT user_id, user_permissions, user_type
FROM ' . USERS_TABLE . '
WHERE ' . $db->sql_in_set('user_id', $ug_id);
$result = $db->sql_query($sql);
while ($userdata = $db->sql_fetchrow($result))
{
if ($user->data['user_id'] != $userdata['user_id'])
{
$auth2 = new auth();
$auth2->acl($userdata);
}
else
{
global $auth;
$auth2 = &$auth;
}
$hold_ary[$userdata['user_id']] = array();
foreach ($forum_ids as $f_id)
{
$hold_ary[$userdata['user_id']][$f_id] = array();
foreach ($compare_options as $option)
{
$hold_ary[$userdata['user_id']][$f_id][$option] = $auth2->acl_get($option, $f_id);
}
}
}
$db->sql_freeresult($result);
unset($userdata);
unset($auth2);
}
foreach ($ug_id as $_id)
{
//.........这里部分代码省略.........
示例9: viewtopic_php_data
public function viewtopic_php_data()
{
global $user, $db;
$sql = 'SELECT pb.id AS pb_id, pb.holding AS pb_holding,
FROM ' . POINTS_BANK_TABLE . '
WHERE poster_id = ' . (int) $poster_id;
$has_account = true;
$holding = empty($holding) ? array() : $holding;
$pointslock = $banklock = '';
if ($config['points_enable']) {
// Get the points status
$check_auth = new auth();
$check_auth->acl($row);
$pointslock = !$check_auth->acl_get('u_use_points');
// Get the bank status
if ($points_config['bank_enable']) {
$check_auth = new auth();
$check_auth->acl($row);
$banklock = !$check_auth->acl_get('u_use_bank');
}
if (!isset($row['pb_holding']) && $poster_id > 0) {
$has_account = false;
}
$holding[$poster_id] = $row['pb_holding'] ? $row['pb_holding'] : '0';
} else {
$holding[$poster_id] = '0';
}
}
示例10: change_poster
/**
* Change a post's poster
*/
function change_poster(&$post_info, $userdata)
{
global $auth, $db, $config;
if (empty($userdata) || $userdata['user_id'] == $post_info['user_id']) {
return;
}
$post_id = $post_info['post_id'];
$sql = 'UPDATE ' . POSTS_TABLE . "\n\t\tSET poster_id = {$userdata['user_id']}\n\t\tWHERE post_id = {$post_id}";
$db->sql_query($sql);
// Resync topic/forum if needed
if ($post_info['topic_last_post_id'] == $post_id || $post_info['forum_last_post_id'] == $post_id) {
sync('topic', 'topic_id', $post_info['topic_id'], false, false);
sync('forum', 'forum_id', $post_info['forum_id'], false, false);
}
// Adjust post counts
$auth_user_from = new auth();
$auth_user_from->acl($post_info);
$auth_user_to = new auth();
$auth_user_to->acl($userdata);
// Decrease post count by one for the old user
if ($auth_user_from->acl_get('f_postcount', $post_info['forum_id'])) {
$sql = 'UPDATE ' . USERS_TABLE . '
SET user_posts = user_posts - 1
WHERE user_id = ' . $post_info['user_id'];
$db->sql_query($sql);
}
// Increase post count by one for the new user
if ($auth_user_to->acl_get('f_postcount', $post_info['forum_id'])) {
$sql = 'UPDATE ' . USERS_TABLE . '
SET user_posts = user_posts + 1
WHERE user_id = ' . $userdata['user_id'];
$db->sql_query($sql);
}
// Add posted to information for this topic for the new user
markread('post', $post_info['forum_id'], $post_info['topic_id'], time(), $userdata['user_id']);
// Remove the dotted topic option if the old user has no more posts within this topic
if ($config['load_db_track'] && $post_info['user_id'] != ANONYMOUS) {
$sql = 'SELECT topic_id
FROM ' . POSTS_TABLE . '
WHERE topic_id = ' . $post_info['topic_id'] . '
AND poster_id = ' . $post_info['user_id'];
$result = $db->sql_query_limit($sql, 1);
$topic_id = (int) $db->sql_fetchfield('topic_id');
$db->sql_freeresult($result);
if (!$topic_id) {
$sql = 'DELETE FROM ' . TOPICS_POSTED_TABLE . '
WHERE user_id = ' . $post_info['user_id'] . '
AND topic_id = ' . $post_info['topic_id'];
$db->sql_query($sql);
}
}
// Do not change the poster_id within the attachments table, since they were still posted by the original user
$from_username = $post_info['username'];
$to_username = $userdata['username'];
// Renew post info
$post_info = get_post_data(array($post_id));
if (!sizeof($post_info)) {
trigger_error($user->lang['POST_NOT_EXIST']);
}
$post_info = $post_info[$post_id];
// Now add log entry
add_log('mod', $post_info['forum_id'], $post_info['topic_id'], 'LOG_MCP_CHANGE_POSTER', $post_info['topic_title'], $from_username, $to_username);
}
示例11: array
/**
* Get permission mask
* This function only supports getting permissions of one type (for example a_)
*
* @param set|view $mode defines the permissions we get, view gets effective permissions (checking user AND group permissions), set only gets the user or group permission set alone
* @param mixed $user_id user ids to search for (a user_id or a group_id has to be specified at least)
* @param mixed $group_id group ids to search for, return group related settings (a user_id or a group_id has to be specified at least)
* @param mixed $forum_id forum_ids to search for. Defining a forum id also means getting local settings
* @param string $auth_option the auth_option defines the permission setting to look for (a_ for example)
* @param local|global $scope the scope defines the permission scope. If local, a forum_id is additionally required
* @param ACL_NEVER|ACL_NO|ACL_YES $acl_fill defines the mode those permissions not set are getting filled with
*/
function get_mask($mode, $user_id = false, $group_id = false, $forum_id = false, $auth_option = false, $scope = false, $acl_fill = ACL_NEVER)
{
global $db, $user;
// Mighty Gorgon: we need to define this here to be allowed to use the class later...
global $cms_permissions;
$hold_ary = array();
$view_user_mask = $mode == 'view' && $group_id === false ? true : false;
if ($auth_option === false || $scope === false) {
return array();
}
$acl_user_function = $mode == 'set' ? 'acl_user_raw_data' : 'acl_raw_data';
if (!$view_user_mask) {
if ($forum_id !== false) {
$hold_ary = $group_id !== false ? $this->acl_group_raw_data($group_id, $auth_option . '%', $forum_id) : $this->{$acl_user_function}($user_id, $auth_option . '%', $forum_id);
} else {
$hold_ary = $group_id !== false ? $this->acl_group_raw_data($group_id, $auth_option . '%', $scope == 'global' ? 0 : false) : $this->{$acl_user_function}($user_id, $auth_option . '%', $scope == 'global' ? 0 : false);
}
}
// Make sure hold_ary is filled with every setting (prevents missing forums/users/groups)
$ug_id = $group_id !== false ? !is_array($group_id) ? array($group_id) : $group_id : (!is_array($user_id) ? array($user_id) : $user_id);
$forum_ids = $forum_id !== false ? !is_array($forum_id) ? array($forum_id) : $forum_id : ($scope == 'global' ? array(0) : array());
// Only those options we need
$compare_options = array_diff(preg_replace('/^((?!' . $auth_option . ').+)|(' . $auth_option . ')$/', '', array_keys($this->acl_options[$scope])), array(''));
// If forum_ids is false and the scope is local we actually want to have all forums within the array
if ($scope == 'local' && !sizeof($forum_ids)) {
// Mighty Gorgon: phpBB only uses local for forums, while we want to use this magic feature also for CMS!!!
if (!empty($cms_permissions->id_type) && method_exists($cms_permissions, 'check_existence')) {
$ids = array();
$ids_data = $cms_permissions->check_existence($cms_permissions->id_type, $ids, true);
foreach ($ids_data as $id_data) {
$forum_ids[] = (int) $id_data['id'];
}
} else {
$sql = 'SELECT forum_id
FROM ' . FORUMS_TABLE;
$result = $db->sql_query($sql, 120);
while ($row = $db->sql_fetchrow($result)) {
$forum_ids[] = (int) $row['forum_id'];
}
$db->sql_freeresult($result);
}
}
if ($view_user_mask) {
$auth2 = null;
$sql = 'SELECT user_id, user_permissions, user_type
FROM ' . USERS_TABLE . '
WHERE ' . $db->sql_in_set('user_id', $ug_id);
$result = $db->sql_query($sql);
while ($userdata = $db->sql_fetchrow($result)) {
if ($user->data['user_id'] != $userdata['user_id']) {
$auth2 = new auth();
$auth2->acl($userdata);
} else {
global $auth;
$auth2 =& $auth;
}
$hold_ary[$userdata['user_id']] = array();
foreach ($forum_ids as $f_id) {
$hold_ary[$userdata['user_id']][$f_id] = array();
foreach ($compare_options as $option) {
$hold_ary[$userdata['user_id']][$f_id][$option] = $auth2->acl_get($option, $f_id);
}
}
}
$db->sql_freeresult($result);
unset($userdata);
unset($auth2);
}
foreach ($ug_id as $_id) {
if (!isset($hold_ary[$_id])) {
$hold_ary[$_id] = array();
}
foreach ($forum_ids as $f_id) {
if (!isset($hold_ary[$_id][$f_id])) {
$hold_ary[$_id][$f_id] = array();
}
}
}
// Now, we need to fill the gaps with $acl_fill. ;)
// Now switch back to keys
if (sizeof($compare_options)) {
$compare_options = array_combine($compare_options, array_fill(1, sizeof($compare_options), $acl_fill));
}
// Defining the user-function here to save some memory
$return_acl_fill = create_function('$value', 'return ' . $acl_fill . ';');
// Actually fill the gaps
if (sizeof($hold_ary)) {
foreach ($hold_ary as $ug_id => $row) {
//.........这里部分代码省略.........
示例12: get_gym_links
/**
* get_gym_links($gym_config).
* retunrs the link array
*/
function get_gym_links($gym_config)
{
global $phpbb_root_path, $config, $phpEx, $user, $cache, $db, $phpbb_seo;
$links = array();
$_phpbb_seo = !empty($phpbb_seo);
$board_url = $_phpbb_seo ? $phpbb_seo->seo_path['phpbb_url'] : generate_board_url() . '/';
$gym_link_tpl = '<a href="%1$s" title="%3$s" class="gym"><img src="' . $board_url . 'gym_sitemaps/images/%2$s" alt="%3$s" width="14" height="14"/> %3$s</a>';
$google_threshold = max(1, (int) $gym_config['google_threshold']);
//compute guest auth
$cache_file = '_gym_auth_guests_forum';
if (($auth_guest_list = $cache->get($cache_file)) === false) {
$auth_guest_list = array('list' => array(), 'read' => array(), 'list_post' => array(), 'read_post' => array(), 'skip_pass' => array(), 'skip_cat' => array(), 'skip_all' => array(), 'skip_link' => array(), 'thresholded' => array(), 'empty' => array());
$guest_data = array('user_id' => ANONYMOUS, 'user_type' => USER_IGNORE, 'user_permissions' . (defined('XLANG_AKEY') ? XLANG_AKEY : '') => '');
$g_auth = new auth();
$g_auth->acl($guest_data);
// the forum id array
$forum_list_ary = $g_auth->acl_getf('f_list', true);
foreach ($forum_list_ary as $forum_id => $null) {
$auth_guest_list['list'][$forum_id] = (int) $forum_id;
}
$forum_read_ary = $g_auth->acl_getf('f_read', true);
foreach ($forum_read_ary as $forum_id => $null) {
$auth_guest_list['read'][$forum_id] = (int) $forum_id;
}
ksort($auth_guest_list['list']);
ksort($auth_guest_list['read']);
$sql = "SELECT forum_id, forum_type, forum_password\n\t\t\tFROM " . FORUMS_TABLE . "\n\t\t\tWHERE\tforum_type <> " . FORUM_POST . " OR forum_password <> ''";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
$forum_id = (int) $row['forum_id'];
if ($row['forum_password']) {
$auth_guest_list['skip_pass'][$forum_id] = $forum_id;
}
if ($row['forum_type'] == FORUM_CAT) {
$auth_guest_list['skip_cat'][$forum_id] = $forum_id;
} else {
if ($row['forum_type'] == FORUM_LINK) {
$auth_guest_list['skip_link'][$forum_id] = $forum_id;
}
}
$auth_guest_list['skip_all'][$forum_id] = $forum_id;
}
$db->sql_freeresult($result);
// Now let's grabb the list of forum with not enough topics to have a sitemap
// Only care about postable forum ;-)
$sql = "SELECT forum_id, forum_topics\n\t\t\tFROM " . FORUMS_TABLE . "\n\t\t\tWHERE\tforum_type = " . FORUM_POST . "\n\t\t\t\tAND forum_topics < {$google_threshold}";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
$forum_id = (int) $row['forum_id'];
$auth_guest_list['thresholded'][$forum_id] = $forum_id;
if (empty($row['forum_topics'])) {
$auth_guest_list['empty'][$forum_id] = $forum_id;
}
}
ksort($auth_guest_list['skip_pass']);
ksort($auth_guest_list['skip_all']);
ksort($auth_guest_list['skip_link']);
ksort($auth_guest_list['skip_cat']);
// Never mind about forum links
$auth_guest_list['read'] = array_diff_assoc($auth_guest_list['read'], $auth_guest_list['skip_link']);
$auth_guest_list['list'] = array_diff_assoc($auth_guest_list['list'], $auth_guest_list['skip_link']);
ksort($auth_guest_list['read']);
ksort($auth_guest_list['list']);
$auth_guest_list['list_post'] = array_diff_assoc($auth_guest_list['list'], $auth_guest_list['skip_all']);
$auth_guest_list['read_post'] = array_diff_assoc($auth_guest_list['read'], $auth_guest_list['skip_all']);
$cache->put($cache_file, $auth_guest_list);
}
$links = array();
$links['main'] = $links['setup']['google'] = $links['setup']['rss'] = $links['setup']['html'] = array();
// Find out about active modes
$google_active = $rss_active = $html_active = false;
$gym_modules = array('google' => array('forum', 'xml', 'txt'), 'rss' => array('forum'), 'html' => array('forum'));
foreach ($gym_modules as $type => $modules) {
foreach ($modules as $module) {
if (!empty($gym_config[$type . '_' . $module . '_installed'])) {
${$type . '_active'} = true;
break;
}
}
}
$do_display_cat = $do_display_main = $do_display_index = false;
// Google sitemaps
if ($google_active) {
$display_google_main_links = (bool) get_gym_option('google', 'gym', 'link_main', OVERRIDE_MODULE, $gym_config);
$display_google_index_links = (bool) get_gym_option('google', 'gym', 'link_index', OVERRIDE_MODULE, $gym_config);
$display_google_cat_links = (bool) get_gym_option('google', 'gym', 'link_cat', OVERRIDE_MODULE, $gym_config);
$override_google_mod_rewrite = get_override('google', 'modrewrite', $gym_config);
$google_mod_rewrite = (bool) get_gym_option('google', 'gym', 'modrewrite', $override_google_mod_rewrite, $gym_config);
$override_google_gzip = get_override('google', 'gzip', $gym_config);
$google_gzip = (bool) get_gym_option('google', 'forum', 'gzip', $override_google_gzip, $gym_config);
$google_gzip_ext = $google_gzip || $config['gzip_compress'] ? get_gym_option('google', 'forum', 'gzip_ext', $override_google_gzip, $gym_config) ? '.gz' : '' : '';
$google_url = $_phpbb_seo ? $phpbb_seo->sslify($gym_config['google_url'], $phpbb_seo->ssl['use'], false) : $gym_config['google_url'];
$sitemap_url = $google_url . ($google_mod_rewrite ? 'sitemapindex.xml' . $google_gzip_ext : "sitemap.{$phpEx}");
$links['setup']['google'] = array('override_mod_rewrite' => $override_google_mod_rewrite, 'mod_rewrite' => $google_mod_rewrite, 'override_gzip' => $override_google_gzip, 'link_main' => $display_google_main_links, 'link_index' => $display_google_index_links, 'link_cat' => $display_google_cat_links, 'gzip' => $google_gzip, 'gzip_ext' => $google_gzip_ext, 'google_url' => $google_url, 'threshold' => max(1, (int) $gym_config['google_threshold']), 'l_google_sitemap' => $user->lang['GOOGLE_SITEMAP'], 'l_google_sitemap_of' => $user->lang['GOOGLE_MAP_OF']);
// only publicly readable and not thresholded forums will be listed
if (!empty($gym_config['google_forum_installed'])) {
//.........这里部分代码省略.........
示例13: array
/**
* check_forum_auth()
* Returns various forum auth and properties
*/
function check_forum_auth($guest_auth = true)
{
global $auth, $db, $user, $cache;
$forum_auth_list = array('list' => array(), 'read' => array(), 'list_post' => array(), 'read_post' => array(), 'public_list' => array(), 'public_read' => array(), 'skip_pass' => array(), 'skip_cat' => array(), 'skip_all' => array(), 'skip_link' => array());
$need_cache = false;
$cache_file = '_gym_auth_forum_guest';
// First check the public forum list
if (($forum_auth_list = $cache->get($cache_file)) === false) {
$forum_auth_list = array('list' => array(), 'read' => array(), 'list_post' => array(), 'read_post' => array(), 'public_list' => array(), 'public_read' => array(), 'skip_pass' => array(), 'skip_cat' => array(), 'skip_all' => array(), 'skip_link' => array());
$guest_data = array('user_id' => ANONYMOUS, 'user_type' => USER_IGNORE, 'user_permissions' . (defined('XLANG_AKEY') ? XLANG_AKEY : '') => '');
$g_auth = new auth();
$g_auth->acl($guest_data);
// the forum id array
$forum_list_ary = $g_auth->acl_getf('f_list', true);
foreach ($forum_list_ary as $forum_id => $null) {
$forum_auth_list['list'][$forum_id] = (int) $forum_id;
}
$forum_read_ary = $g_auth->acl_getf('f_read', true);
foreach ($forum_read_ary as $forum_id => $null) {
$forum_auth_list['read'][$forum_id] = (int) $forum_id;
}
ksort($forum_auth_list['list']);
ksort($forum_auth_list['read']);
$sql = "SELECT forum_id, forum_type, forum_password\n\t\t\t\tFROM " . FORUMS_TABLE . "\n\t\t\t\tWHERE\tforum_type <> " . FORUM_POST . " OR forum_password <> ''";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
$forum_id = (int) $row['forum_id'];
if ($row['forum_password']) {
$forum_auth_list['skip_pass'][$forum_id] = $forum_id;
}
if ($row['forum_type'] == FORUM_CAT) {
$forum_auth_list['skip_cat'][$forum_id] = $forum_id;
} else {
if ($row['forum_type'] == FORUM_LINK) {
$forum_auth_list['skip_link'][$forum_id] = $forum_id;
}
}
$forum_auth_list['skip_all'][$forum_id] = $forum_id;
}
$db->sql_freeresult($result);
ksort($forum_auth_list['skip_pass']);
ksort($forum_auth_list['skip_all']);
ksort($forum_auth_list['skip_link']);
ksort($forum_auth_list['skip_cat']);
// Never mind about fourm links
$forum_auth_list['read'] = array_diff_assoc($forum_auth_list['read'], $forum_auth_list['skip_link']);
$forum_auth_list['list'] = array_diff_assoc($forum_auth_list['list'], $forum_auth_list['skip_link']);
ksort($forum_auth_list['read']);
ksort($forum_auth_list['list']);
$forum_auth_list['list_post'] = array_diff_assoc($forum_auth_list['list'], $forum_auth_list['skip_all']);
$forum_auth_list['read_post'] = array_diff_assoc($forum_auth_list['read'], $forum_auth_list['skip_all']);
$forum_auth_list['public_list'] = array_diff_assoc($forum_auth_list['list'], $forum_auth_list['skip_pass']);
$forum_auth_list['public_read'] = array_diff_assoc($forum_auth_list['read'], $forum_auth_list['skip_pass']);
$cache->put($cache_file, $forum_auth_list);
}
$this->module_auth['forum'] =& $forum_auth_list;
if ($guest_auth) {
// sometime, we need to only check guest auths, even if user is registered
$this->actions['auth_param'] = implode('-', $forum_auth_list['read_post']);
return $forum_auth_list['read_post'];
}
// else handle the real auth
$forum_auth_list['read'] = $forum_auth_list['list'] = array();
$forum_list_ary = $auth->acl_getf('f_list', true);
foreach ($forum_list_ary as $forum_id => $null) {
$forum_auth_list['list'][$forum_id] = (int) $forum_id;
}
$forum_read_ary = $auth->acl_getf('f_read', true);
foreach ($forum_read_ary as $forum_id => $null) {
$forum_auth_list['read'][$forum_id] = (int) $forum_id;
}
ksort($forum_auth_list['list']);
ksort($forum_auth_list['read']);
$forum_auth_list['list'] = array_diff_assoc($forum_auth_list['list'], $forum_auth_list['skip_link']);
$forum_auth_list['read'] = array_diff_assoc($forum_auth_list['read'], $forum_auth_list['skip_link']);
$forum_auth_list['list_post'] = array_diff_assoc($forum_auth_list['list'], $forum_auth_list['skip_all']);
$forum_auth_list['read_post'] = array_diff_assoc($forum_auth_list['read'], $forum_auth_list['skip_all']);
$this->actions['auth_param'] = implode('-', $forum_auth_list['read_post']);
return $forum_auth_list['read_post'];
}
示例14: while
while ($row = $_CLASS['core_db']->fetch_row_assoc($result)) {
$group_options .= '<option value="' . $row['group_id'] . '"' . ($member['user_group'] == $row['group_id'] ? ' selected="selected"' : '') . '>' . (isset($_CLASS['core_user']->lang['G_' . $row['group_name']]) ? $_CLASS['core_user']->lang['G_' . $row['group_name']] : $row['group_name']) . '</option>';
}
$_CLASS['core_db']->free_result($result);
$page_title = sprintf($_CLASS['core_user']->lang['VIEWING_PROFILE'], $member['username']);
$template_html = 'memberlist_view.html';
$sql = 'SELECT MAX(session_time) AS session_time
FROM ' . SESSIONS_TABLE . "\n\t\t\tWHERE session_user_id = {$user_id}";
$result = $_CLASS['core_db']->query($sql);
$row = $_CLASS['core_db']->fetch_row_assoc($result);
$_CLASS['core_db']->free_result($result);
$member['session_time'] = isset($row['session_time']) ? $row['session_time'] : 0;
unset($row);
// Obtain list of forums where this users post count is incremented
$auth2 = new auth();
$auth2->acl($member);
$f_postcount_ary = $auth2->acl_getf('f_postcount');
$sql_forums = array();
foreach ($f_postcount_ary as $forum_id => $allow) {
if ($allow['f_postcount']) {
$sql_forums[] = $forum_id;
}
}
$post_count_sql = sizeof($sql_forums) ? 'AND f.forum_id IN (' . implode(', ', $sql_forums) . ')' : '';
unset($sql_forums, $f_postcount_ary, $auth2);
// Grab all the relevant data
$sql = 'SELECT COUNT(p.post_id) AS num_posts
FROM ' . FORUMS_POSTS_TABLE . ' p, ' . FORUMS_FORUMS_TABLE . " f\n\t\t\tWHERE p.poster_id = {$user_id}\n\t\t\t\tAND f.forum_id = p.forum_id\n\t\t\t\t{$post_count_sql}";
$result = $_CLASS['core_db']->query($sql);
$row = $_CLASS['core_db']->fetch_row_assoc($result);
$_CLASS['core_db']->free_result($result);