class_session.php
来自「sabreipb 2.1.6 utf-8中文版本!」· PHP 代码 · 共 1,207 行 · 第 1/3 页
PHP
1,207 行
//----------------------------------------- // Set up main 'display' group //----------------------------------------- $this->member = array_merge( $this->member, $this->ipsclass->cache['group_cache'][ $this->member['mgroup'] ] ); //----------------------------------------- // Are we a member of several groups? //----------------------------------------- $this->build_group_permissions(); //----------------------------------------- // Are we a mod? //----------------------------------------- if ( $this->member['mgroup'] != $this->ipsclass->vars['guest_group'] ) { //----------------------------------------- // Sprinkle on some moderator stuff... //----------------------------------------- if ( $this->member['g_is_supmod'] == 1 ) { $this->member['is_mod'] = 1; } else if ( count($this->ipsclass->cache['moderators']) ) { foreach( $this->ipsclass->cache['moderators'] as $i => $r ) { if ( $r['member_id'] == $this->member['id'] or $r['group_id'] == $this->member['mgroup'] ) { $this->member['_moderator'][ $r['forum_id'] ] = $r; $this->member['is_mod'] = 1; } } } //----------------------------------------- // Forum markers //----------------------------------------- $this->member['members_markers'] = unserialize(stripslashes( $this->member['members_markers'] ) ); } //header('content-type:text/plain'); print_r($this->member); exit(); //----------------------------------------- // Synchronise the last visit and activity times if // we have some in the member profile //----------------------------------------- if ( $this->member['id'] ) { if ( ! $this->ipsclass->input['last_activity'] ) { $this->ipsclass->input['last_activity'] = $this->member['last_activity'] ? $this->member['last_activity'] : $this->time_now; } if ( ! $this->ipsclass->input['last_visit'] ) { $this->ipsclass->input['last_visit'] = $this->member['last_visit'] ? $this->member['last_visit'] : $this->time_now; } //----------------------------------------- // If there hasn't been a cookie update in 2 hours, // we assume that they've gone and come back //----------------------------------------- if ( ! $this->member['last_visit'] ) { //----------------------------------------- // No last visit set, do so now! //----------------------------------------- $this->ipsclass->DB->simple_construct( array( 'update' => 'members', 'set' => "last_visit=".$this->time_now.", last_activity=".$this->time_now, 'where' => "id=".$this->member['id'] ) ); $this->ipsclass->DB->simple_shutdown_exec(); } else if ( (time() - $this->ipsclass->input['last_activity']) > 300 ) { //----------------------------------------- // If the last click was longer than 5 mins ago and this is a member // Update their profile. //----------------------------------------- list( $be_anon, $loggedin ) = explode( '&', $this->member['login_anonymous'] ); $this->ipsclass->DB->simple_construct( array( 'update' => 'members', 'set' => "login_anonymous='$be_anon&1', last_activity=".$this->time_now, 'where' => "id=".$this->member['id'] ) ); $this->ipsclass->DB->simple_shutdown_exec(); } //----------------------------------------- // Check ban status //----------------------------------------- if ( $this->member['temp_ban'] ) { $ban_arr = $this->ipsclass->hdl_ban_line( $this->member['temp_ban'] ); if ( time() >= $ban_arr['date_end'] ) { //----------------------------------------- // Update this member's profile //----------------------------------------- $this->ipsclass->DB->simple_construct( array( 'update' => 'members', 'set' => "temp_ban=''", 'where' => "id=".$this->member['id'] ) ); $this->ipsclass->DB->simple_shutdown_exec(); } else { $this->ipsclass->member = $this->member; $this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'account_susp', 'INIT' => 1, 'EXTRA' => $this->ipsclass->get_date($ban_arr['date_end'],'LONG', 1) ) ); } } } //----------------------------------------- // Set a session ID cookie //----------------------------------------- $this->ipsclass->my_setcookie("session_id", $this->session_id, -1); return $this->member; } /*-------------------------------------------------------------------------*/ // Build group permissions /*-------------------------------------------------------------------------*/ function build_group_permissions() { if ( $this->member['mgroup_others'] ) { $groups_id = explode( ',', $this->member['mgroup_others'] ); $exclude = array( 'g_title', 'g_icon', 'prefix', 'suffix', 'g_promotion', 'g_photo_max_vars' ); $less_is_more = array( 'g_search_flood' ); $zero_is_best = array( 'g_attach_max', 'g_edit_cutoff' ); if ( count( $groups_id ) ) { foreach( $groups_id as $pid ) { if ( ! $this->ipsclass->cache['group_cache'][ $pid ]['g_id'] ) { continue; } //----------------------------------------- // Loop through and mix //----------------------------------------- foreach( $this->ipsclass->cache['group_cache'][ $pid ] as $k => $v ) { if ( ! in_array( $k, $exclude ) ) { //----------------------------------------- // Add to perm id list //----------------------------------------- if ( $k == 'g_perm_id' ) { $this->member['g_perm_id'] .= ','.$v; } else if ( in_array( $k, $zero_is_best ) ) { if( $this->member[ $k ] == 0 ) { continue; } else if( $v > $this->member[ $k ] ) { $this->member[ $k ] = $v; } } else if ( in_array( $k, $less_is_more ) ) { if ( $v < $this->member[ $k ] ) { $this->member[ $k ] = $v; } } else { if ( $v > $this->member[ $k ] ) { $this->member[ $k ] = $v; } } } } } } //----------------------------------------- // Tidy perms_id //----------------------------------------- $rmp = array(); $tmp = explode( ',', $this->ipsclass->clean_perm_string($this->member['g_perm_id']) ); if ( count( $tmp ) ) { foreach( $tmp as $t ) { $rmp[ $t ] = $t; } } if ( count( $rmp ) ) { $this->member['g_perm_id'] = implode( ',', $rmp ); } } $this->ipsclass->perm_id = ( $this->member['org_perm_id'] ) ? $this->member['org_perm_id'] : $this->member['g_perm_id']; $this->ipsclass->perm_id_array = explode( ",", $this->ipsclass->perm_id ); } /*-------------------------------------------------------------------------*/ // Attempt to load a member /*-------------------------------------------------------------------------*/ function load_member($member_id=0) { $member_id = intval($member_id); if ($member_id != 0) { $this->ipsclass->DB->build_query( array( 'select' => "id, name, mgroup, member_login_key, email, restrict_post, view_sigs, view_avs, view_pop, view_img, auto_track, mod_posts, language, skin, new_msg, show_popup, msg_total, time_offset, posts, joined, last_post, subs_pkg_chosen, ignored_users, login_anonymous, last_visit, last_activity, dst_in_use, view_prefs, org_perm_id, mgroup_others, temp_ban, sub_end, has_blog, members_markers, members_editor_choice, members_auto_dst, members_display_name, members_created_remote, members_cache, members_disable_pm", 'from' => 'members', 'where' => 'id='.$member_id ) ); $this->ipsclass->DB->exec_query(); if ( $this->ipsclass->DB->get_num_rows() ) { $this->member = $this->ipsclass->DB->fetch_row(); } //----------------------------------------- // Unless they have a member id, log 'em in as a guest //----------------------------------------- if ( ($this->member['id'] == 0) or (empty($this->member['id'])) ) { $this->unload_member(); } } //----------------------------------------- // Unpack cache //----------------------------------------- if ( $this->member['members_cache'] ) { $this->member['_cache'] = $this->ipsclass->unpack_member_cache( $this->member['members_cache'] ); } else { $this->member['_cache'] = array(); } unset($member_id); } /*-------------------------------------------------------------------------*/ // Remove the users cookies /*-------------------------------------------------------------------------*/ function unload_member() { $this->ipsclass->my_setcookie( "member_id" , "0", -1 ); $this->ipsclass->my_setcookie( "pass_hash" , "0", -1 ); $this->member['id'] = 0; $this->member['name'] = ""; $this->member['members_display_name'] = ""; } /*-------------------------------------------------------------------------*/ // Updates a current session. /*-------------------------------------------------------------------------*/ function update_member_session() { //----------------------------------------- // Make sure we have a session id. //----------------------------------------- if ( ! $this->session_id ) { $this->create_member_session(); return; } if ( empty($this->member['id']) ) { $this->unload_member(); $this->create_guest_session(); return; } //----------------------------------------- // Get module settings //----------------------------------------- $vars = $this->_get_location_settings(); //----------------------------------------- // Still update? //----------------------------------------- if ( ! $this->do_update ) { return; } $this->ipsclass->DB->do_shutdown_update( 'sessions', array( 'member_name' => $this->member['members_display_name'], 'member_id' => intval($this->member['id']), 'member_group' => $this->member['mgroup'], 'login_type' => substr($this->member['login_anonymous'],0, 1), 'running_time' => $this->time_now, 'location' => $vars['location'], 'in_error' => 0, 'location_1_type' => $vars['1_type'], 'location_1_id' => $vars['1_id'], 'location_2_type' => $vars['2_type'], 'location_2_id' => $vars['2_id'], 'location_3_type' => $vars['3_type'], 'location_3_id' => $vars['3_id'], ), "id='{$this->session_id}'" ); } /*-------------------------------------------------------------------------*/ // Update guest session /*-------------------------------------------------------------------------*/ function update_guest_session() { //----------------------------------------- // Make sure we have a session id. //----------------------------------------- if ( ! $this->session_id ) { $this->create_guest_session(); return; } //----------------------------------------- // Get module settings //----------------------------------------- $vars = $this->_get_location_settings(); //----------------------------------------- // Still update? //----------------------------------------- if ( ! $this->do_update ) { return; } $this->ipsclass->DB->do_shutdown_update( 'sessions', array( 'member_name' => "", 'member_id' => 0, 'member_group' => $this->ipsclass->vars['guest_group'], 'login_type' => substr($this->member['login_anonymous'],0, 1), 'running_time' => $this->time_now, 'location' => $vars['location'], 'in_error' => 0, 'location_1_type' => $vars['1_type'], 'location_1_id' => $vars['1_id'], 'location_2_type' => $vars['2_type'], 'location_2_id' => $vars['2_id'], 'location_3_type' => $vars['3_type'], 'location_3_id' => $vars['3_id'],
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?