func_mod.php
来自「sabreipb 2.1.6 utf-8中文版本!」· PHP 代码 · 共 1,245 行 · 第 1/3 页
PHP
1,245 行
{ foreach( $seen_fids as $id ) { $this->forum_recount( $id ); } } } if ( $add_posts > 0 ) { $this->ipsclass->cache['stats']['total_replies'] += $add_posts; $this->ipsclass->update_cache( array( 'name' => 'stats', 'array' => 1, 'deletefirst' => 0 ) ); //----------------------------------------- // Update current members stuff //----------------------------------------- $pcount = ""; $mgroup = ""; if ( ($this->forum['inc_postcount']) and ($incpost != 0) ) { //----------------------------------------- // Increment the users post count //----------------------------------------- $pcount = "posts=posts+".$add_posts.", "; } //----------------------------------------- // Are we checking for auto promotion? //----------------------------------------- if ($this->ipsclass->member['g_promotion'] != '-1&-1') { list($gid, $gposts) = explode( '&', $this->ipsclass->member['g_promotion'] ); if ( $gid > 0 and $gposts > 0 ) { if ( $this->ipsclass->member['posts'] + $add_posts >= $gposts ) { $mgroup = "mgroup='$gid', "; } } } $this->ipsclass->DB->simple_exec_query( array( 'update' => 'members', 'set' => $pcount.$mgroup."last_post=".time(), 'where' => "id=".$this->ipsclass->member['id'] ) ); } return TRUE; } //----------------------------------------- // @topic_close: close topic ID's // ----------- // Accepts: Array ID's | Single ID // Returns: NOTHING (TRUE/FALSE) //----------------------------------------- function topic_close($id) { $this->stm_init(); $this->stm_add_close(); $this->stm_exec($id); return TRUE; } //----------------------------------------- // @topic_open: open topic ID's // ----------- // Accepts: Array ID's | Single ID // Returns: NOTHING (TRUE/FALSE) //----------------------------------------- function topic_open($id) { $this->stm_init(); $this->stm_add_open(); $this->stm_exec($id); return TRUE; } //----------------------------------------- // @topic_pin: pin topic ID's // ----------- // Accepts: Array ID's | Single ID // Returns: NOTHING (TRUE/FALSE) //----------------------------------------- function topic_pin($id) { $this->stm_init(); $this->stm_add_pin(); $this->stm_exec($id); return TRUE; } //----------------------------------------- // @topic_unpin: unpin topic ID's // ----------- // Accepts: Array ID's | Single ID // Returns: NOTHING (TRUE/FALSE) //----------------------------------------- function topic_unpin($id) { $this->stm_init(); $this->stm_add_unpin(); $this->stm_exec($id); return TRUE; } //----------------------------------------- // @topic_delete: deletetopic ID(s) // ----------- // Accepts: $id (array | string) // Returns: NOTHING (TRUE/FALSE) //----------------------------------------- function topic_delete($id, $nostats=0) { $posts = array(); $attach = array(); $this->error = ""; if ( is_array( $id ) ) { if ( count($id) > 0 ) { $tid = " IN(".implode(",",$id).")"; } else { return FALSE; } } else { if ( intval($id) ) { $tid = "=$id"; } else { return FALSE; } } //----------------------------------------- // Remove polls assigned to this topic //----------------------------------------- $this->ipsclass->DB->simple_exec_query( array( 'delete' => 'polls', 'where' => "tid".$tid ) ); //----------------------------------------- // Remove polls assigned to this topic //----------------------------------------- $this->ipsclass->DB->simple_exec_query( array( 'delete' => 'voters', 'where' => "tid".$tid ) ); //----------------------------------------- // Remove polls assigned to this topic //----------------------------------------- $this->ipsclass->DB->simple_exec_query( array( 'delete' => 'topics', 'where' => "tid".$tid ) ); //----------------------------------------- // Get PIDS for attachment deletion //----------------------------------------- $this->ipsclass->DB->simple_construct( array( 'select' => 'pid', 'from' => 'posts', 'where' => "topic_id".$tid ) ); $this->ipsclass->DB->simple_exec(); while ( $r = $this->ipsclass->DB->fetch_row() ) { $posts[] = $r['pid']; } //----------------------------------------- // Remove the attachments //----------------------------------------- if ( count( $posts ) ) { $this->ipsclass->DB->simple_construct( array( "select" => '*', 'from' => 'attachments', 'where' => "attach_pid IN (".implode(",",$posts).")" ) ); $o = $this->ipsclass->DB->simple_exec(); while ( $killmeh = $this->ipsclass->DB->fetch_row( $o ) ) { if ( $killmeh['attach_location'] ) { @unlink( $this->ipsclass->vars['upload_dir']."/".$killmeh['attach_location'] ); } if ( $killmeh['attach_thumb_location'] ) { @unlink( $this->ipsclass->vars['upload_dir']."/".$killmeh['attach_thumb_location'] ); } $attach[] = $killmeh['attach_id']; } if ( count( $attach ) ) { $this->ipsclass->DB->simple_construct( array( 'delete' => 'attachments', 'where' => "attach_id IN (".implode(",",$attach).")" ) ); $this->ipsclass->DB->simple_exec(); } } //----------------------------------------- // Remove the posts //----------------------------------------- $this->ipsclass->DB->simple_exec_query( array( 'delete' => 'posts', 'where' => "topic_id".$tid ) ); //----------------------------------------- // Recount forum... //----------------------------------------- if ( $nostats == 0 ) { if ( $this->forum['id'] ) { $this->ipsclass->forums->forum_by_id[ $this->forum['id'] ]['_update_deletion'] = 1; $this->forum_recount( $this->forum['id'] ); } $this->stats_recount(); } return TRUE; } //----------------------------------------- // @topic_move: move topic ID(s) // ----------- // Accepts: $topics (array | string) $source, // $moveto // Returns: NOTHING (TRUE/FALSE) //----------------------------------------- function topic_move($topics, $source, $moveto, $leavelink=0) { $this->error = ""; $source = intval($source); $moveto = intval($moveto); if ( is_array( $topics ) ) { if ( count($topics) > 0 ) { $tid = " IN(".implode(",",$topics).")"; } else { return FALSE; } } else { if ( intval($topics) ) { $tid = "=$topics"; } else { return FALSE; } } //----------------------------------------- // Update the topic //----------------------------------------- $this->ipsclass->DB->do_update( 'topics', array( 'forum_id' => $moveto ), "forum_id=$source AND tid".$tid ); //----------------------------------------- // Update the polls //----------------------------------------- $this->ipsclass->DB->do_update( 'polls', array( 'forum_id' => $moveto ), "forum_id=$source AND tid".$tid ); //----------------------------------------- // Are we leaving a stink er link? //----------------------------------------- if ( $leavelink != 0 ) { $this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'topics', 'where' => "tid".$tid ) ); $oq = $this->ipsclass->DB->simple_exec(); while ( $row = $this->ipsclass->DB->fetch_row($oq) ) { $this->ipsclass->DB->do_insert( 'topics', array ( 'title' => $row['title'], 'description' => $row['description'], 'state' => 'link', 'posts' => 0, 'views' => 0, 'starter_id' => $row['starter_id'], 'start_date' => $row['start_date'], 'starter_name' => $row['starter_name'], 'last_post' => $row['last_post'], 'forum_id' => $source, 'approved' => 1, 'pinned' => 0, 'moved_to' => $row['tid'].'&'.$moveto, 'last_poster_id' => $row['last_poster_id'], 'last_poster_name' => $row['last_poster_name'] ) ); } } //----------------------------------------- // Sort out subscriptions //----------------------------------------- $this->ipsclass->DB->cache_add_query( 'mod_func_get_topic_tracker', array( 'tid' => $tid ) ); $this->ipsclass->DB->cache_exec_query(); $trid_to_delete = array(); while ( $r = $this->ipsclass->DB->fetch_row() ) { //----------------------------------------- // Match the perm group against forum_mask //----------------------------------------- $perm_id = $r['g_perm_id']; if ( $r['org_perm_id'] ) { $perm_id = $r['org_perm_id']; } $pass = 0; $forum_perm_array = explode( ",", $this->ipsclass->forums->forum_by_id[ $r['forum_id'] ]['read_perms'] ); foreach( explode( ',', $perm_id ) as $u_id ) { if ( in_array( $u_id, $forum_perm_array ) ) { $pass = 1; } } if ( $pass != 1 ) { $trid_to_delete[] = $r['trid']; } } if ( count($trid_to_delete) > 0 ) { $this->ipsclass->DB->simple_exec_query( array( 'delete' => 'tracker', 'where' => "trid IN(".implode(',', $trid_to_delete ).")" ) ); } return TRUE; } //----------------------------------------- // @stats_recount: Recount all topics & posts // ----------- // Accepts: NOTHING // Returns: NOTHING (TRUE/FALSE) //----------------------------------------- function stats_recount() { if ( ! is_array($this->ipsclass->cache['stats']) ) { $stats = $this->ipsclass->DB->simple_exec_query( array( 'select' => '*', 'from' => 'cache_store', 'where' => "cs_key='stats'" ) ); $this->ipsclass->cache['stats'] = unserialize($this->ipsclass->txt_stripslashes($stats['cs_value'])); } $topics = $this->ipsclass->DB->simple_exec_query( array( 'select' => 'COUNT(*) as tcount', 'from' => 'topics', 'where' => 'approved=1' ) ); $posts = $this->ipsclass->DB->simple_exec_query( array( 'select' => 'SUM(posts) as replies', 'from' => 'topics', 'where' => 'approved=1' ) ); $this->ipsclass->cache['stats']['total_topics'] = $topics['tcount']; $this->ipsclass->cache['stats']['total_replies'] = $posts['replies']; $this->ipsclass->update_cache( array( 'name' => 'stats', 'array' => 1, 'deletefirst' => 0, 'donow' => 1 ) ); return TRUE; } //----------------------------------------- // @forum_recount: Recount topic & posts in a forum // ----------- // Accepts: forum_id // Returns: NOTHING (TRUE/FALSE) //----------------------------------------- function forum_recount($fid="") { $fid = intval($fid); if ( ! $fid ) { if ( $this->forum['id'] ) { $fid = $this->forum['id'];
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?