class_forums.php
来自「sabreipb 2.1.6 utf-8中文版本!」· PHP 代码 · 共 866 行 · 第 1/2 页
PHP
866 行
<?php/*+--------------------------------------------------------------------------| Invision Power Board v2.1.5| =============================================| by Matthew Mecham| (c) 2001 - 2005 Invision Power Services, Inc.| | =============================================| Web: | Time: Wed, 01 Mar 2006 19:11:28 GMT| Release: | Licence Info: +---------------------------------------------------------------------------| > $Date: 2005-12-01 16:45:12 +0000 (Thu, 01 Dec 2005) $| > $Revision: 88 $| > $Author: bfarber $+---------------------------------------------------------------------------|| > FORUMS CLASS| > Module written by Matt Mecham| > Date started: 26th January 2004|| > Module Version Number: 1.0.0| > DBA Checked: Wed 19 May 2004+--------------------------------------------------------------------------*/class forum_functions{ var $forum_cache = array(); var $forum_by_id = array(); var $forum_built = array(); var $template_bit = ""; var $depth_guide = "--"; var $return = ""; var $this_forum = array(); var $strip_invisible = 0; var $mod_cache = array(); var $mod_cache_got = 0; var $read_topic_only = 0; /*-------------------------------------------------------------------------*/ // register_class // ------------------ // Register a $this-> class with this module /*-------------------------------------------------------------------------*/ function register_class() { //NO LONGER NEEDED } /*-------------------------------------------------------------------------*/ // forums_init // ------------------ // Grab all forums and stuff into array /*-------------------------------------------------------------------------*/ function forums_init() { if ( ! is_array( $this->ipsclass->cache['forum_cache'] ) ) { $this->ipsclass->update_forum_cache(); } $hide_parents = ','; $this->forum_cache = array(); $this->forum_by_id = array(); foreach( $this->ipsclass->cache['forum_cache'] as $i => $f ) { if ( $this->strip_invisible ) { if ( strstr( $hide_parents, ','. $f['parent_id'] .',' ) ) { // Don't show any children of hidden parents $hide_parents .= $f['id'].','; continue; } //if ( $f['status'] < 1 ) //{ // $hide_parents .= $f['id'].','; // continue; //} if ( $f['show_perms'] != '*' ) { if ( $this->ipsclass->check_perms($f['show_perms']) != TRUE ) { $hide_parents .= $f['id'].','; continue; } } } if ( $f['parent_id'] < 1 ) { $f['parent_id'] = 'root'; } $f['fid'] = $f['id']; $this->forum_cache[ $f['parent_id'] ][ $f['id'] ] = $f; $this->forum_by_id[ $f['id'] ] = &$this->forum_cache[ $f['parent_id'] ][ $f['id'] ]; } } function forums_remove_childless_parents() { foreach ( $this->forum_cache['root'] as $id => $forum_data ) { if ( ! is_array( $this->forum_cache['root'][ $forum_data['id'] ] ) ) { unset( $this->forum_cache['root'][ $forum_data['id'] ] ); unset( $this->forum_by_id[ $forum_data['id'] ] ); } } } /*-------------------------------------------------------------------------*/ // forums_get_moderator_cache // ------------------ // Grab all mods innit /*-------------------------------------------------------------------------*/ function forums_get_moderator_cache() { $this->can_see_queued = array(); if ( ! is_array( $this->ipsclass->cache['moderators'] ) ) { $this->ipsclass->cache['moderators'] = array(); define( "IN_ACP", 1 ); require_once( ROOT_PATH.'sources/action_admin/moderator.php' ); $this->mod = new ad_moderator(); $this->mod->ipsclass =& $this->ipsclass; $this->mod->rebuild_moderator_cache(); } if ( count($this->ipsclass->cache['moderators']) ) { foreach( $this->ipsclass->cache['moderators'] as $i => $r ) { $this->mod_cache[ $r['forum_id'] ][ $r['mid'] ] = array( 'name' => $r['members_display_name'], 'memid' => $r['member_id'], 'id' => $r['mid'], 'isg' => $r['is_group'], 'gname' => $r['group_name'], 'gid' => $r['group_id'], ); } } $this->mod_cache_got = 1; } /*-------------------------------------------------------------------------*/ // forums_get_moderators // ------------------ // Grab all mods innit /*-------------------------------------------------------------------------*/ function forums_get_moderators($forum_id="") { if ( ! $this->mod_cache_got ) { $this->forums_get_moderator_cache(); } $mod_string = ""; if ($forum_id == "") { return ""; } if (isset($this->mod_cache[ $forum_id ] ) ) { $mod_string = $this->ipsclass->lang['forum_leader'].' '; if (is_array($this->mod_cache[ $forum_id ]) ) { foreach ($this->mod_cache[ $forum_id ] as $moderator) { if ($moderator['isg'] == 1) { $mod_string .= "<a href='{$this->ipsclass->base_url}act=Members&max_results=30&filter={$moderator['gid']}&sort_order=asc&sort_key=members_display_name&st=0&b=1'>{$moderator['gname']}</a>, "; } else { if ( ! $moderator['name'] ) { continue; } $mod_string .= "<a href='{$this->ipsclass->base_url}showuser={$moderator['memid']}'>{$moderator['name']}</a>, "; } } $mod_string = preg_replace( "!,\s+$!", "", $mod_string ); } else { if ($moderator['isg'] == 1) { $mod_string .= "<a href='{$this->ipsclass->base_url}act=Members&max_results=30&filter={$this->mods[$forum_id]['gid']}&sort_order=asc&sort_key=name&st=0&b=1'>{$this->mods[$forum_id]['gname']}</a>, "; } else { $mod_string .= "<a href='{$this->ipsclass->base_url}showuser={$this->mods[$forum_id]['memid']}'>{$this->mods[$forum_id]['name']}</a>"; } } } return $mod_string; } /*-------------------------------------------------------------------------*/ // Forums check access // ------------------ // Blah-de-blah /*-------------------------------------------------------------------------*/ function forums_check_access($fid, $prompt_login=0, $in='forum') { $deny_access = 1; if ( $this->ipsclass->check_perms($this->forum_by_id[$fid]['show_perms']) == TRUE ) { if ( $this->ipsclass->check_perms($this->forum_by_id[$fid]['read_perms']) == TRUE ) { $deny_access = 0; } else { //----------------------------------------- // Can see topics? //----------------------------------------- if ( $this->forum_by_id[$fid]['permission_showtopic'] ) { $this->read_topic_only = 1; if ( $in == 'forum' ) { $deny_access = 0; } else { //----------------------------------------- // Custom error? //----------------------------------------- $this->forums_custom_error($fid); $deny_access = 1; } } else { $this->forums_custom_error($fid); $deny_access = 1; } } } else { //----------------------------------------- // custom error //----------------------------------------- $this->forums_custom_error($fid); $deny_access = 1; } //----------------------------------------- // Do we have permission to even see the password page? //----------------------------------------- if ($deny_access == 0) { if ( $this->forum_by_id[$fid]['password'] AND $this->forum_by_id[$fid]['sub_can_post'] ) { if ( $this->forums_compare_password( $fid ) == TRUE ) { $deny_access = 0; } else { $deny_access = 1; if ( $prompt_login == 1 ) { $this->forums_show_login( $fid ); } } } } if ($deny_access == 1) { $this->ipsclass->Error( array( LEVEL => 1, MSG => 'no_permission') ); } } /*-------------------------------------------------------------------------*/ // Compare forum pasword /*-------------------------------------------------------------------------*/ function forums_compare_password( $fid ) { $cookie_pass = $this->ipsclass->my_getcookie( 'ipbforumpass_'.$fid ); if ( trim($cookie_pass) == md5($this->forum_by_id[$fid]['password']) ) { return TRUE; } else { return FALSE; } } /*-------------------------------------------------------------------------*/ // Quick check /*-------------------------------------------------------------------------*/ function forums_quick_check_access($fid) { $deny_access = 1; if ( $this->ipsclass->check_perms($this->forum_by_id[$fid]['show_perms']) == TRUE ) { $deny_access = 0; } //----------------------------------------- // Do we have permission to even see the password page? //----------------------------------------- if ($deny_access == 0) { if ($this->forum_by_id[$fid]['password']) { if ( $this->forums_compare_password( $fid ) == TRUE ) { $deny_access = 0; } else { $deny_access = 1; } } } return $deny_access; } /*-------------------------------------------------------------------------*/ // Forums custom error // ------------------ // Blah-de-blah /*-------------------------------------------------------------------------*/ function forums_custom_error( $fid ) { $tmp = $this->ipsclass->DB->simple_exec_query( array( 'select' => 'permission_custom_error', 'from' => 'forums', 'where' => "id=".$fid) ); if ( $tmp['permission_custom_error'] ) { $this->ipsclass->load_language("lang_error"); if ( ! $this->ipsclass->compiled_templates['skin_global'] ) { $this->load_template('skin_global'); } //----------------------------------------- // Update session //----------------------------------------- $this->ipsclass->DB->do_shutdown_update( 'sessions', array( 'in_error' => 1 ), "id='{$this->ipsclass->my_session}'" ); list($em_1, $em_2) = explode( '@', $this->ipsclass->vars['email_in'] ); $html = $this->ipsclass->compiled_templates['skin_global']->Error( $tmp['permission_custom_error'], $em_1, $em_2); $print = new display(); $this->ipsclass->print->add_output($html); $this->ipsclass->print->do_output( array('TITLE' => $this->ipsclass->lang['error_title'] ) ); } } /*-------------------------------------------------------------------------*/ // Forums log in screen // ------------------ // Blah-de-blah /*-------------------------------------------------------------------------*/ function forums_show_login( $fid ) { if ( ! class_exists( 'skin_forum' ) ) { $this->ipsclass->load_template('skin_forum'); $this->ipsclass->load_language('lang_forum'); } else { $this->html = new skin_forum(); } if (empty($this->ipsclass->member['id'])) { $this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_guests' ) ); } $this->output = $this->ipsclass->compiled_templates['skin_forum']->forum_password_log_in( $fid );
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?