cat_hierarchy mod<<<還是你們知道更好的子分區MOD
在裝這個mod之前要裝 cache mod<<<下載下來的說明說的
按照以下方法安抓以後
代碼: 選擇全部
##############################################################
## MOD Title: Cache
## MOD Author: Ptirhiik < ptirhiik@clanmckeen.com > (Pierre) http://rpgnet.clanmckeen.com
## MOD Description:
## This mod will cache some tables. Used in Categories hierarchy and Profile Control Panel
## MOD Version: 0.0.2
##
## Installation Level: Easy
## Installation Time: 20 Minutes
## Files To Edit:
## viewtopic.php (not necessary with PCP)
##
## admin/admin_forumauth.php
## admin/admin_ranks.php
## admin/admin_smilies.php
## admin/admin_styles.php (need to be cleaned up from categories hierarchy)
## admin/admin_ug_auth.php (need to be cleaned up from categories hierarchy)
## admin/admin_words.php (need to be cleaned up from categories hierarchy)
##
## includes/bbcode.php
## includes/functions.php (clean some functions with categories hierarchy)
## includes/functions_admin.php (need to be cleaned up from categories hierarchy)
## includes/functions_post.php (need to be cleaned up from categories hierarchy)
## includes/usercp_register.php
##
## Included Files:
## includes/def_birthday.php
## includes/def_ranks.php
## includes/def_smilies.php
## includes/def_themes.php
## includes/def_tree.php
## includes/def_words.php
##
## includes/functions_cache.php
##
## includes/cache_tpls/def_birthday_def.tpl
## includes/cache_tpls/def_ranks_def.tpl
## includes/cache_tpls/def_smilies_def.tpl
## includes/cache_tpls/def_themes_def.tpl
## includes/cache_tpls/def_tree_def.tpl
## includes/cache_tpls/def_words_def.tpl
##
##############################################################
## For Security Purposes, Please Check: http://www.phpbb.com/mods/ for the
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered
## in our MOD-Database, located at: http://www.phpbb.com/mods/
##############################################################
## Author Notes:
##
## Files to CHMOD 666 :
## includes/def_birthday.php
## includes/def_ranks.php
## includes/def_smilies.php
## includes/def_themes.php
## includes/def_tree.php
## includes/def_words.php
##
## Reminder : clean index.php with categories hierarchy installed on the board stats
## Required categories hierarchy 2.0.5 and +
##
##############################################################
## MOD History:
##
## 2003-12-21 - Version 0.0.2
## - first stand-alone publication
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################
#
#-----[ COPY ]------------------------------------------------
#
# copy includes/*.* to includes/*.*
#
copy includes/def_birthday.php to includes/def_birthday.php
copy includes/def_ranks.php to includes/def_ranks.php
copy includes/def_smilies.php to includes/def_smilies.php
copy includes/def_themes.php to includes/def_themes.php
copy includes/def_tree.php to includes/def_tree.php
copy includes/def_words.php to includes/def_words.php
#
#-----[ COPY ]------------------------------------------------
#
copy includes/functions_cache.php to includes/functions_cache.php
#
#-----[ COPY ]------------------------------------------------
#
# copy includes/cache_tpls/*.* to includes/cache_tpls/*.*
#
copy includes/cache_tpls/def_birthday_def.tpl to includes/cache_tpls/def_birthday_def.tpl
copy includes/cache_tpls/def_ranks_def.tpl to includes/cache_tpls/def_ranks_def.tpl
copy includes/cache_tpls/def_smilies_def.tpl to includes/cache_tpls/def_smilies_def.tpl
copy includes/cache_tpls/def_themes_def.tpl to includes/cache_tpls/def_themes_def.tpl
copy includes/cache_tpls/def_tree_def.tpl to includes/cache_tpls/def_tree_def.tpl
copy includes/cache_tpls/def_words_def.tpl to includes/cache_tpls/def_words_def.tpl
#
#-----[ OPEN ]------------------------------------------------
#
viewtopic.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
$sql = "SELECT *
FROM " . RANKS_TABLE . "
ORDER BY rank_special, rank_min";
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
$ranks = array();
$ranksrow = array();
if ( defined('CACHE_RANKS') )
{
@include( $phpbb_root_path . './includes/def_ranks.' . $phpEx );
if ( empty($ranks) )
{
cache_ranks();
include( $phpbb_root_path . './includes/def_ranks.' . $phpEx );
}
@reset($ranks);
while ( list($rank_id, $rank_data) = @each($ranks) )
{
$ranksrow[] = $rank_data;
}
}
if ( empty($ranks) && !defined('CACHE_RANKS') )
{
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
$ranksrow[] = $row;
}
$db->sql_freeresult($result);
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
}
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
admin/admin_forumauth.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
# this is a partial search : the full line is longer
#
$message = $lang['Forum_auth_updated']
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
cache_tree(true);
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
admin/admin_ranks.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
# this is a partial search : the full-line is longer
#
$message .= "<br /><br />" . sprintf($lang['Click_return_rankadmin']
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
cache_ranks();
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
# this is a partial search : the full-line is longer
#
$message = $lang['Rank_removed']
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
cache_ranks();
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
admin/admin_smilies.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
# this is a partial search : the full-line is longer
#
$message = $lang['smiley_import_success']
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
cache_smilies();
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
# this is a partial search : the full-line is longer
#
$message = $lang['smiley_del_success']
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
cache_smilies();
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
# this is a partial search : the full-line is longer
#
$message = $lang['smiley_edit_success']
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
cache_smilies();
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
# this is a partial search : the full-line is longer
#
$message = $lang['smiley_add_success']
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
cache_smilies();
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
admin/admin_styles.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
# this is a partial search : the full-line is longer\r
#
$message = $lang['Theme_installed']
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
cache_themes();
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
# this is a partial search : the full-line is longer
#
$message = $lang['Theme_updated']
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
cache_themes();
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
# this is a partial search : the full-line is longer
#
$message = $lang['Theme_created']
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
cache_themes();
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
# this is a partial search : the full-line is longer
#
$message = $lang['Theme_info_saved']
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
cache_themes();
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
# this is a partial search : the full-line is longer
#
$message = $lang['Style_removed']
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
cache_themes();
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
admin/admin_ug_auth.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
# this is a partial search : the full line is longer
#
$message = $lang['Auth_updated']
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
cache_tree(true);
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
if ( $unset_mod != '' )
{
$sql = "UPDATE " . USERS_TABLE . "
SET user_level = " . USER . "
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
cache_tree(true);
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
admin/admin_words.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
# this is a partial search : the full-line is longer
#
$message .= "<br /><br />" . sprintf($lang['Click_return_wordadmin']
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
cache_words();
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
# this is a partial search : the full-line is longer
#
$message = $lang['Word_removed']
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
cache_words();
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
includes/bbcode.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
if (!isset($orig))
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
global $phpEx, $phpbb_root_path, $smilies, $board_config;
if ( defined('CACHE_SMILIES') )
{
@include( $phpbb_root_path . './includes/def_smilies.' . $phpEx );
if ( empty($smilies) )
{
cache_smilies();
include( $phpbb_root_path . './includes/def_smilies.' . $phpEx );
}
}
else
{
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
$smilies = $db->sql_fetchrowset($result);
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
}
}
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
}
if (count($orig))
#
#-----[ REPLACE WITH ]----------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- delete
// }
//-- fin mod : cache -------------------------------------------------------------------------------
if (count($orig))
#
#-----[ OPEN ]------------------------------------------------
#
includes/functions.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
*
***************************************************************************/
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
include_once( $phpbb_root_path . './includes/functions_cache.' . $phpEx);
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
function get_db_stat($mode)
{
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
global $board_config;
// first inits
if ( !isset($board_config['max_users']) || !isset($board_config['record_last_user_id']) || !isset($board_config['record_last_username']) )
{
users_stats();
cache_birthday();
}
if ( !isset($board_config['max_posts']) || !isset($board_config['max_topics']) )
{
board_stats();
}
switch ( $mode )
{
case 'usercount':
return intval($board_config['max_users']);
break;
case 'newestuser':
$row = array( 'user_id' => intval($board_config['record_last_user_id']), 'username' => $board_config['record_last_username']);
return $row;
break;
case 'postcount':
return intval($board_config['max_posts']);
break;
case 'topiccount':
return intval($board_config['max_topics']);
break;
}
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
$sql = "SELECT *
FROM " . THEMES_TABLE . "
WHERE themes_id = $style";
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
global $phpEx, $themes_style;
if ( defined('CACHE_THEMES') )
{
@include( $phpbb_root_path . './includes/def_themes.' . $phpEx );
if ( empty($themes_style) )
{
cache_themes();
include( $phpbb_root_path . './includes/def_themes.' . $phpEx );
}
}
if ( !empty($themes_style[$style]) )
{
$row = $themes_style[$style];
}
else
{
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
message_die(CRITICAL_ERROR, "Could not get theme data for themes_id [$style]");
}
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
}
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
function obtain_word_list(&$orig_word, &$replacement_word)
{
global $db;
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
global $phpbb_root_path, $phpEx;
// not processed yet
if ( empty($orig_word) )
{
// take them from the cache
if ( defined('CACHE_WORDS') )
{
@include($phpbb_root_path . './includes/def_words.' . $phpEx);
if ( !isset($censored_words) )
{
$censored_words = array();
cache_words();
include($phpbb_root_path . './includes/def_words.' . $phpEx);
}
// convert
$orig_word = array();
$replacement_word = array();
@reset($censored_words);
while ( list($word_id, $row) = @each($censored_words) )
{
$orig_word[] = '#\b(' . str_replace('\*', '\w*?', phpbb_preg_quote($row['word'], '#')) . ')\b#i';
$replacement_word[] = $row['replacement'];
}
}
else
{
// get them from the database
$sql = "SELECT * FROM " . WORDS_TABLE;
if ( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not get censored words from database', '', __LINE__, __FILE__, $sql);
}
// get the data
$censored_words = array();
while ( $row = $db->sql_fetchrow($result) )
{
$orig_word[] = '#\b(' . str_replace('\*', '\w*?', phpbb_preg_quote($row['word'], '#')) . ')\b#i';
$replacement_word[] = $row['replacement'];
}
}
}
// end the function
return true;
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
includes/functions_admin.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
return true;
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
global $board_config;
board_stats();
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
includes/functions_post.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
# this is a partial search : the full line is longer
#
$message = $lang['Stored']
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
board_stats();
cache_tree(true);
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
return;
}
//
// Delete a post/poll
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
board_stats();
cache_tree(true);
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
return;
}
//
// Handle user notification on new post
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
board_stats();
cache_tree(true);
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
$sql = "SELECT emoticon, code, smile_url
FROM " . SMILIES_TABLE . "
ORDER BY smilies_id";
if ($result = $db->sql_query($sql))
{
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
if ( defined('CACHE_SMILIES') )
{
@include( $phpbb_root_path . './includes/def_smilies.' . $phpEx );
if ( empty($smilies) )
{
cache_smilies();
include( $phpbb_root_path . './includes/def_smilies.' . $phpEx );
}
}
if ( empty($smilies) && !defined('CACHE_SMILIES') )
{
$smilies = array();
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
while ( $row = $db->sql_fetchrow($result) )
{
$smilies[] = $row;
}
}
}
if ( !empty($smilies) )
{
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
$num_smilies = 0;
$rowset = array();
while ($row = $db->sql_fetchrow($result))
#
#-----[ REPLACE WITH ]----------------------------------------
#
$num_smilies = 0;
$rowset = array();
//-- mod : cache -----------------------------------------------------------------------------------
//-- delete
// while ($row = $db->sql_fetchrow($result))
//-- add
@reset($smilies);
while ( list($row_id, $row) = @each($smilies) )
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
includes/usercp_register.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
# this is a partial search : the full line is longer
#
$message = $message . '<br /><br />' . sprintf($lang['Click_return_index']
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
users_stats();
cache_birthday();
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ SAVE/CLOSE ALL FILES ]--------------------------------
#
# EoMFatal error: Call to undefined function: init_userprefs() in c:\appserv\www\bs\index.php on line 34
連續試了3次都依樣\r
index.php 34行是這樣的
init_userprefs($userdata);
---------------------------------------------------------------
And here comes the Categories hierarchy v 2.0.5, still on Release Candidate stage
- Changelog:
- fix moderators not displaied in forums view
- split the cache module to a separate installation to use with other mods
- analyse and removal of sql requests usage
- reoganize distribution pack
Some numbers : installed on a vanilia phpBB : (second is when the phpbb_sessions is refreshed, first on standard navigation)
- index.php : 5/8 requests,
- viewforum.php : 7/10 requests,
- viewtopic.php : 8/11 requests
Without the mod :
- index.php : 13/16 requests,
- viewforum.php : 13/16 requests,
- viewtopic.php : 13/16 requests
This cache allows to compensate almost all the extra power required by Categories hierarchy


