func_mod.php
来自「sabreipb 2.1.6 utf-8中文版本!」· PHP 代码 · 共 1,245 行 · 第 1/3 页
PHP
1,245 行
} else { return FALSE; } } //----------------------------------------- // Get the topics.. //----------------------------------------- $topics = $this->ipsclass->DB->simple_exec_query( array( 'select' => 'COUNT(*) as count', 'from' => 'topics', 'where' => "approved=1 and forum_id=$fid" ) ); //----------------------------------------- // Get the QUEUED topics.. //----------------------------------------- $queued_topics = $this->ipsclass->DB->simple_exec_query( array( 'select' => 'COUNT(*) as count', 'from' => 'topics', 'where' => "approved=0 and forum_id=$fid" ) ); //----------------------------------------- // Get the posts.. //----------------------------------------- $posts = $this->ipsclass->DB->simple_exec_query( array( 'select' => 'SUM(posts) as replies', 'from' => 'topics', 'where' => "approved=1 and forum_id=$fid" ) ); //----------------------------------------- // Get the QUEUED posts.. //----------------------------------------- $queued_posts = $this->ipsclass->DB->simple_exec_query( array( 'select' => 'SUM(topic_queuedposts) as replies', 'from' => 'topics', 'where' => "forum_id=$fid" ) ); //----------------------------------------- // Get the forum last poster.. //----------------------------------------- $this->ipsclass->DB->simple_construct( array( 'select' => 'tid, title, last_poster_id, last_poster_name, last_post', 'from' => 'topics', 'where' => "approved=1 and forum_id=$fid", 'order' => 'last_post DESC', 'limit' => array( 0,1 ) ) ); $this->ipsclass->DB->simple_exec(); $last_post = $this->ipsclass->DB->fetch_row(); //----------------------------------------- // Reset this forums stats //----------------------------------------- $dbs = array( 'last_poster_id' => $last_post['last_poster_id'], 'last_poster_name' => $last_post['last_poster_name'], 'last_post' => $last_post['last_post'], 'last_title' => $last_post['title'], 'last_id' => $last_post['tid'], 'topics' => intval($topics['count']), 'posts' => intval($posts['replies']), 'queued_topics' => intval($queued_topics['count']), 'queued_posts' => intval($queued_posts['replies']), ); if ( $this->ipsclass->forums->forum_by_id[ $fid ]['_update_deletion'] ) { $dbs['forum_last_deletion'] = time(); } $this->ipsclass->DB->do_update( 'forums', $dbs, "id=".$fid ); //----------------------------------------- // Update forum cache //----------------------------------------- foreach( $dbs as $k => $v ) { $this->ipsclass->cache['forum_cache'][ $fid ][ $k ] = $v; } $this->ipsclass->update_cache( array( 'name' => 'forum_cache', 'array' => 1, 'deletefirst' => 0 ) ); return TRUE; } //----------------------------------------- // @stm_init: Clear statement ready for multi-actions // ----------- // Accepts: NOTHING // Returns: NOTHING (TRUE/FALSE) //----------------------------------------- function stm_init() { $this->stm = array(); return TRUE; } //----------------------------------------- // @stm_exec: Executes stored statement // ----------- // Accepts: Array ID's | Single ID // Returns: NOTHING (TRUE/FALSE) //----------------------------------------- function stm_exec($id) { if ( count($this->stm) < 1 ) { return FALSE; } $final_array = array(); foreach( $this->stm as $idx => $real_array ) { foreach( $real_array as $k => $v ) { $final_array[ $k ] = $v; } } $db_string = $this->ipsclass->DB->compile_db_update_string( $final_array ); if ( is_array($id) ) { if ( count($id) > 0 ) { $this->ipsclass->DB->simple_exec_query( array( 'update' => 'topics', 'set' => $db_string, 'where' => "tid IN(".implode( ",", $id ).")" ) ); return TRUE; } else { return FALSE; } } else if ( intval($id) != "" ) { $this->ipsclass->DB->simple_exec_query( array( 'update' => 'topics', 'set' => $db_string, 'where' => "tid=".intval($id) ) ); } else { return FALSE; } } //----------------------------------------- // @stm_add_pin: add pin command to statement // ----------- // Accepts: NOTHING // Returns: NOTHING (TRUE/FALSE) //----------------------------------------- function stm_add_pin() { $this->stm[] = array( 'pinned' => 1 ); return TRUE; } //----------------------------------------- // @stm_add_unpin: add unpin command to statement // ----------- // Accepts: NOTHING // Returns: NOTHING (TRUE/FALSE) //----------------------------------------- function stm_add_unpin() { $this->stm[] = array( 'pinned' => 0 ); return TRUE; } //----------------------------------------- // @stm_add_close: add close command to statement // ----------- // Accepts: NOTHING // Returns: NOTHING (TRUE/FALSE) //----------------------------------------- function stm_add_close() { $this->stm[] = array( 'state' => 'closed' ); $this->stm[] = array( 'topic_open_time' => 0 ); $this->stm[] = array( 'topic_close_time' => 0 ); return TRUE; } //----------------------------------------- // @stm_add_open: add open command to statement // ----------- // Accepts: NOTHING // Returns: NOTHING (TRUE/FALSE) //----------------------------------------- function stm_add_open() { $this->stm[] = array( 'state' => 'open' ); $this->stm[] = array( 'topic_open_time' => 0 ); $this->stm[] = array( 'topic_close_time' => 0 ); return TRUE; } //----------------------------------------- // @stm_add_title: add edit title command to statement // ----------- // Accepts: new_title // Returns: NOTHING (TRUE/FALSE) //----------------------------------------- function stm_add_title($new_title='') { if ( $new_title == "" ) { return FALSE; } $this->stm[] = array( 'title' => $new_title ); return TRUE; } //----------------------------------------- // @stm_add_desc: add edit desc command to statement // ----------- // Accepts: new_title // Returns: NOTHING (TRUE/FALSE) //----------------------------------------- function stm_add_desc($new_desc='') { if ( $new_desc == "" ) { return FALSE; } $this->stm[] = array( 'description' => $new_desc ); return TRUE; } //----------------------------------------- // @stm_add_approve: Approve topic // ----------- // Accepts: NOTHING // Returns: NOTHING (TRUE/FALSE) //----------------------------------------- function stm_add_approve() { $this->stm[] = array( 'approved' => 1 ); return TRUE; } //----------------------------------------- // @stm_add_unapprove: Unapprove topic // ----------- // Accepts: NOTHING // Returns: NOTHING (TRUE/FALSE) //----------------------------------------- function stm_add_unapprove() { $this->stm[] = array( 'approved' => 0 ); return TRUE; } //----------------------------------------- // @sql_prune_create: returns formatted SQL statement // ----------- // Accepts: forum_id, poss_starter_id, poss_topic_state, poss_post_min // poss_date_expiration, poss_ignore_pin_state // Returns: formatted sql query //----------------------------------------- function sql_prune_create( $forum_id, $starter_id="", $topic_state="", $post_min="", $date_exp="", $ignore_pin="", $pergo=0, $limit=0 ) { $sql = "SELECT tid FROM ibf_topics WHERE approved=1 and forum_id=".intval($forum_id); if ( intval($date_exp) ) { $sql .= " AND last_post < $date_exp"; } if ( intval($starter_id) ) { $sql .= " AND starter_id=$starter_id"; } if ( intval($post_min) ) { $sql .= " AND posts < $post_min"; } if ($topic_state != 'all') { if ($topic_state) { $sql .= " AND state='$topic_state'"; } } if ( $ignore_pin != "" ) { $sql .= " AND pinned=0"; } if ( $pergo ) { $this->ipsclass->DB->cur_query = $sql; $this->ipsclass->DB->simple_limit( 0, $pergo ); $sql = $this->ipsclass->DB->cur_query; $this->ipsclass->DB->flush_query(); } return $sql; } //----------------------------------------- // @mm_authorize: Authorizes current member // ----------- // Accepts: (NOTHING: Should already be passed to init) // Returns: NOTHING (TRUE/FALSE) //----------------------------------------- function mm_authorize() { $pass_go = FALSE; if ( $this->ipsclass->member['id'] ) { if ( $this->ipsclass->member['g_is_supmod'] ) { $pass_go = TRUE; } else if ( $this->moderator['can_mm'] == 1 ) { $pass_go = TRUE; } } return $pass_go; } //----------------------------------------- // @mm_check_id_in_forum: Checks to see if mm_id is in // the forum saved topic_mm_id // ----------- // Accepts: (forum_topic_mm_id , this_mm_id) // Returns: NOTHING (TRUE/FALSE) //----------------------------------------- function mm_check_id_in_forum( $fid, $mm_data) { $retval = FALSE; if ( $mm_data['mm_forums'] == '*' OR strstr( ",". $mm_data['mm_forums'].",", ",".$fid."," ) ) { $retval = TRUE; } return $retval; } //----------------------------------------- // @add_moderate_log: Adds entry to mod log // ----------- // Accepts: (forum_id, topic_id, topic_title, post_id, title) // Returns: NOTHING (TRUE/FALSE) //----------------------------------------- function add_moderate_log($fid, $tid, $pid, $t_title, $mod_title='Unknown') { $this->ipsclass->DB->do_insert( 'moderator_logs', array ( 'forum_id' => $fid, 'topic_id' => $tid, 'post_id' => $pid, 'member_id' => $this->ipsclass->member['id'], 'member_name' => $this->ipsclass->member['members_display_name'], 'ip_address' => $this->ipsclass->input['IP_ADDRESS'], 'http_referer'=> $_SERVER['HTTP_REFERER'], 'ctime' => time(), 'topic_title' => $t_title, 'action' => $mod_title, 'query_string'=> $_SERVER['QUERY_STRING'], ) ); return TRUE; } } ?>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?