usercp.php
来自「sabreipb 2.1.6 utf-8中文版本!」· PHP 代码 · 共 1,953 行 · 第 1/5 页
PHP
1,953 行
//----------------------------------------- // check dates //----------------------------------------- $start_date = 0; $end_date = 0; if ( strstr( $this->ipsclass->input['announce_start'], '-' ) ) { $start_array = explode( '-', $this->ipsclass->input['announce_start'] ); if ( $start_array[0] and $start_array[1] and $start_array[2] ) { if ( ! checkdate( $start_array[0], $start_array[1], $start_array[2] ) ) { $this->mod_announce_form( $type, $this->ipsclass->lang['announce_error_date'] ); return; } } $start_date = $this->ipsclass->date_gmmktime( 0, 0, 1, $start_array[0], $start_array[1], $start_array[2] ); } if ( strstr( $this->ipsclass->input['announce_end'], '-' ) ) { $end_array = explode( '-', $this->ipsclass->input['announce_end'] ); if ( $end_array[0] and $end_array[1] and $end_array[2] ) { if ( ! checkdate( $end_array[0], $end_array[1], $end_array[2] ) ) { $this->mod_announce_form( $type, $this->ipsclass->lang['announce_error_date'] ); return; } } $end_date = $this->ipsclass->date_gmmktime( 23, 59, 59, $end_array[0], $end_array[1], $end_array[2] ); } //----------------------------------------- // Build save array //----------------------------------------- $save_array = array( 'announce_title' => $this->ipsclass->input['announce_title'], 'announce_post' => $this->ipsclass->input['announce_post'], 'announce_active' => $this->ipsclass->input['announce_active'], 'announce_forum' => $forums_to_save, 'announce_html_enabled' => $this->ipsclass->input['announce_html_enabled'], 'announce_start' => $start_date, 'announce_end' => $end_date ); //----------------------------------------- // Save.. //----------------------------------------- if ( $type == 'add' ) { $save_array['announce_member_id'] = $this->ipsclass->member['id']; $this->ipsclass->DB->do_insert( 'announcements', $save_array ); } else { if ( $this->ipsclass->input['id'] ) { $this->ipsclass->DB->do_update( 'announcements', $save_array, 'announce_id='.intval($this->ipsclass->input['id']) ); } } //----------------------------------------- // Update cache //----------------------------------------- require_once( ROOT_PATH.'sources/action_public/announcements.php' ); $announcements = new announcements(); $announcements->ipsclass =& $this->ipsclass; $announcements->announce_recache(); $this->mod_announce_start(); return; } /*-------------------------------------------------------------------------*/ // ANNOUNCEMENTS: FORM (new/edit) /*-------------------------------------------------------------------------*/ function mod_announce_form($type='add', $msg="") { if ( ! $this->ipsclass->member['g_is_supmod'] ) { $this->output .= $this->ipsclass->compiled_templates['skin_ucp']->dead_section(); return; } //----------------------------------------- // Set up //----------------------------------------- if ( $type == 'add' ) { $button = $this->ipsclass->lang['announce_button_add']; $announce = array( 'announce_active' => 1 ); } else { $this->ipsclass->input['id'] = intval($this->ipsclass->input['id']); $button = $this->ipsclass->lang['announce_button_edit']; $announce = $this->ipsclass->DB->simple_exec_query( array( 'select' => '*', 'from' => 'announcements', 'where' => 'announce_id='.$this->ipsclass->input['id'] ) ); $announce['announce_forum'] = explode( ",", $announce['announce_forum'] ); $announce['announce_start'] = $announce['announce_start'] ? gmdate( 'm-d-Y', $announce['announce_start'] ) : ''; $announce['announce_end'] = $announce['announce_end'] ? gmdate( 'm-d-Y', $announce['announce_end'] ) : ''; } //----------------------------------------- // Do we have _POST? //----------------------------------------- foreach( array( 'announce_title', 'announce_post', 'announce_start', 'announce_end', 'announce_forum', 'announce_active' ) as $bit ) { if ( $_POST[$bit] ) { $announce[$bit] = $_POST[$bit]; } } //----------------------------------------- // Forums //----------------------------------------- $forum_html = "<option value='*'>{$this->ipsclass->lang['announce_form_allforums']}</option>" . $this->ipsclass->forums->forums_forum_jump(0,1,1); //----------------------------------------- // Save forums? //----------------------------------------- if ( is_array( $announce['announce_forum'] ) and count( $announce['announce_forum'] ) ) { foreach( $announce['announce_forum'] as $f ) { $forum_html = preg_replace( "#option\s+value=[\"'](".preg_quote($f,'#').")[\"']#i", "option value='\\1' selected='selected'", $forum_html ); } } if ( $announce['announce_active'] ) { $announce['announce_active_checked'] = 'checked="checked"'; } if ( $announce['announce_html_enabled'] ) { $announce['announce_html_enabled'] = 'checked="checked"'; } $announce['announce_post'] = $this->ipsclass->my_br2nl( $announce['announce_post'] ); $this->output .= $this->ipsclass->compiled_templates['skin_ucp']->ucp_announce_form($announce, $button, $forum_html, $type, $msg); $this->page_title = $this->ipsclass->lang['menu_announcements']; $this->nav = array( "<a href='".$this->ipsclass->base_url."act=UserCP&CODE=00'>".$this->ipsclass->lang['t_title']."</a>" ); $this->nav[] = $this->ipsclass->lang['menu_announcements']; } /*-------------------------------------------------------------------------*/ // ANNOUNCEMENTS: START (Show current) /*-------------------------------------------------------------------------*/ function mod_announce_start() { if ( ! $this->ipsclass->member['g_is_supmod'] ) { $this->output .= $this->ipsclass->compiled_templates['skin_ucp']->dead_section(); return; } //----------------------------------------- // Get announcements //----------------------------------------- $this->ipsclass->DB->cache_add_query( 'ucp_get_all_announcements', array() ); $this->ipsclass->DB->cache_exec_query(); $content = ""; while ( $r = $this->ipsclass->DB->fetch_row() ) { if ( $r['announce_start'] ) { $r['announce_starts_converted'] = gmdate( 'M-d-Y', $r['announce_start'] ); } else { $r['announce_starts_converted'] = '-'; } if ( $r['announce_end'] ) { $r['announce_end_converted'] = gmdate( 'M-d-Y', $r['announce_end'] ); } else { $r['announce_end_converted'] = '-'; } if ( $r['announce_forum'] == '*' ) { $r['announce_forum_show'] = $this->ipsclass->lang['announce_page_allforums']; } else { $tmp_forums = explode(",",$r['announce_forum']); if ( is_array( $tmp_forums ) and count($tmp_forums) ) { if ( count($tmp_forums) > 5 ) { $r['announce_forum_show'] = count($tmp_forums).' '.$this->ipsclass->lang['announce_page_numforums']; } else { $tmp2 = array(); foreach( $tmp_forums as $id ) { $tmp2[] = "<a href='{$this->ipsclass->base_url}showforum={$id}'>{$this->ipsclass->forums->forum_by_id[ $id ]['name']}</a>"; } $r['announce_forum_show'] = implode( "<br />", $tmp2 ); } } } if ( ! $r['announce_active'] ) { $r['announce_inactive'] = "<span class='desc'>{$this->ipsclass->lang['announce_page_disabled']}</span>"; } $content .= $this->ipsclass->compiled_templates['skin_ucp']->ucp_announce_manage_row( $r ); } $this->output .= $this->ipsclass->compiled_templates['skin_ucp']->ucp_announce_manage($content); $this->page_title = $this->ipsclass->lang['menu_announcements']; $this->nav = array( "<a href='".$this->ipsclass->base_url."act=UserCP&CODE=00'>".$this->ipsclass->lang['t_title']."</a>" ); $this->nav[] = $this->ipsclass->lang['menu_announcements']; } /*-------------------------------------------------------------------------*/ // MEMBER TOOL: START /*-------------------------------------------------------------------------*/ function mod_find_user_start($msg="") { if ( ! $this->ipsclass->member['g_is_supmod'] ) { $this->output .= $this->ipsclass->compiled_templates['skin_ucp']->dead_section(); return; } $this->output .= $this->ipsclass->compiled_templates['skin_ucp']->mod_find_user($msg); } /*-------------------------------------------------------------------------*/ // MEMBER TOOL: COMPLETE /*-------------------------------------------------------------------------*/ function mod_find_user_complete() { $this->ipsclass->input['name'] = trim(strtolower($this->ipsclass->input['name'])); if ( $this->ipsclass->input['name'] == "" ) { $this->mod_find_user_start($this->ipsclass->lang['cp_no_matches']); return; } //----------------------------------------- // Query the DB for possible matches //----------------------------------------- $this->start_val = intval($this->ipsclass->input['st'] ); $sql = "LOWER(name) LIKE '{$this->ipsclass->input['name']}%' OR LOWER(members_display_name) LIKE '%{$this->ipsclass->input['name']}%'"; $this->ipsclass->DB->simple_construct( array( 'select' => 'COUNT(id) as max', 'from' => 'members', 'where' => $sql ) ); $this->ipsclass->DB->simple_exec(); $total_possible = $this->ipsclass->DB->fetch_row(); if ($total_possible['max'] < 1) { $this->mod_find_user_start( $this->ipsclass->lang['cp_no_matches'] ); return; } $pages = $this->ipsclass->build_pagelinks( array( 'TOTAL_POSS' => $total_possible['max'], 'PER_PAGE' => 20, 'CUR_ST_VAL' => $this->start_val, 'L_SINGLE' => $this->ipsclass->lang['single_page_forum'], 'L_MULTI' => $this->ipsclass->lang['multi_page_forum'], 'BASE_URL' => $this->ipsclass->base_url."act=usercp&CODE=domemtool&name={$this->ipsclass->input['name']}", ) ); $content = ""; $this->ipsclass->DB->simple_construct( array( 'select' => 'name, members_display_name, id, ip_address, posts, joined, mgroup', 'from' => 'members', 'where' => $sql, 'order' => "joined DESC", 'limit' => array( $this->start_val,20 ) ) ); $this->ipsclass->DB->simple_exec(); while( $row = $this->ipsclass->DB->fetch_row() ) { $row['joined'] = $this->ipsclass->get_date( $row['joined'], 'JOINED' ); $row['groupname'] = $this->ipsclass->cache['group_cache'][ $row['mgroup'] ]['prefix'] . $this->ipsclass->cache['group_cache'][ $row['mgroup'] ]['g_title'] . $this->ipsclass->cache['group_cache'][ $row['mgroup'] ]['suffix']; if ( ($this->ipsclass->member['mgroup'] != $this->ipsclass->vars['admin_group']) and ($row['mgroup'] == $this->ipsclass->vars['admin_group']) ) { $row['ip_address'] = '--'; } $content .= $this->ipsclass->compiled_templates['skin_ucp']->mod_ip_member_row( $row, $this->ipsclass->return_md5_check() ); } $this->mod_find_user_start( $this->ipsclass->compiled_templates['skin_ucp']->mod_ip_member_results($pages, $content) ); } /*-------------------------------------------------------------------------*/ // IP TOOL: Start /*-------------------------------------------------------------------------*/ function mod_ip_tool_start($msg="") { if ( ! $this->ipsclass->member['g_is_supmod'] ) { $this->output .= $this->ipsclass->compiled_templates['skin_ucp']->dead_section(); return; } $this->output .= $this->ipsclass->compiled_templates['skin_ucp']->mod_ip_start_form($this->ipsclass->input['ip'], $msg); $this->page_title = $this->ipsclass->lang['menu_ipsearch']; $this->nav = array( "<a href='".$this->ipsclass->base_url."act=UserCP&CODE=00'>".$this->ipsclass->lang['t_title']."</a>" ); $this->nav[] = $this->ipsclass->lang['menu_ipsearch']; } /*-------------------------------------------------------------------------*/ // IP TOOL: Complete /*-------------------------------------------------------------------------*/ function mod_ip_tool_complete() { if ( ! $this->ipsclass->member['g_is_supmod'] ) { $this->output .= $this->ipsclass->compiled_templates['skin_ucp']->dead_section(); return; } //----------------------------------------- // Remove trailing periods //----------------------------------------- $exact_match = 1; $final_ip_string = trim( $this->ipsclass->input['ip'] ); $this->start_val = intval($this->ipsclass->input['st'] ); if ( strstr( $final_ip_string, '*' ) ) { $exact_match = 0; $final_ip_string = preg_replace( "/^(.+?)\*(.+?)?$/", "\\1", $final_ip_string ).'%'; } //----------------------------------------- // H'okay, what have we been asked to do? // (that's a metaphorical "we" in a rhetorical question) //----------------------------------------- if ($this->ipsclass->input['iptool'] == 'resolve') { $resolved = @gethostbyaddr($final_ip_string); if ($resolved == "") {
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?