把xoops的设置写入cache的hack - 效率优化 - 技术论坛

正在浏览:   1 名游客


 到底部   前一个主题   下一个主题  [无发表权] 请登录或者注册

« 1 (2) 3 »


Re: 把xoops的设置写入cache的hack
初级会员
注册日期:
2004/12/25 16:42
所属群组:
注册会员
帖子: 22
等级: 3; EXP: 41
HP : 0 / 60
MP : 7 / 236
离线
看不明白┅
到底可用不?
班里的网站,同学们都投诉速度很慢,开站时还可以┅但现在就┅唉┅
所以在这里请教两个问题,可以吗?
1.有甚麽会影响论坛的速度?怎解决?
2.同学们上呀上呀┅後来就不爱来了~都说要换功能好的~~我怎辨好?

2005/2/13 9:25
应用扩展 工具箱


Re: 把xoops的设置写入cache的hack
Support Team
注册日期:
2004/9/20 23:30
所属群组:
注册会员
Dev+Hack
帖子: 148
等级: 11; EXP: 22
HP : 0 / 255
MP : 49 / 1195
离线
可用可用,很好用!

2005/2/13 12:28
_________________
现在还是穷的不得了!xoops2.3快出炉了!MSN:[email protected]
应用扩展 工具箱


Re: 把xoops的设置写入cache的hack
新进会员
注册日期:
2004/12/13 14:09
所属群组:
注册会员
帖子: 20
等级: 3; EXP: 20
HP : 0 / 55
MP : 6 / 220
离线
那么,config文件夹就建立再根目录下,然后修改kernel/config
和kernel/module.php 就行了么?

2005/3/13 16:49
应用扩展 工具箱


Re: 把xoops的设置写入cache的hack
网站管理员
注册日期:
2004/7/5 23:02
所属群组:
网站管理员
注册会员
帖子: 533
等级: 21; EXP: 27
HP : 101 / 506
MP : 177 / 2684
离线
恩 大概就这样

修改文件的时候前面的2个函数路径要修改下 XOOPS_CACHE_PATH."/config" 要改成 XOOPS_ROOT_PATH."/config"

modules那里的也要改下路径

2005/3/13 17:14
_________________
泡泡堂
应用扩展 工具箱


Re: 把xoops的设置写入cache的hack
新进会员
注册日期:
2004/12/13 14:09
所属群组:
注册会员
帖子: 20
等级: 3; EXP: 20
HP : 0 / 55
MP : 6 / 220
离线
Fatal error: Call to undefined function: cacheconfigbycat() in /home2/tcwan/public_html/kernel/config.php on line 218
怎么回事?唉。郁闷。

2005/3/13 17:20
应用扩展 工具箱


Re: 把xoops的设置写入cache的hack
新进会员
注册日期:
2004/12/13 14:09
所属群组:
注册会员
帖子: 20
等级: 3; EXP: 20
HP : 0 / 55
MP : 6 / 220
离线
解决了。OK。不错。
不过:
Parse error: parse error, unexpected '=' in /home2/tcwan/public_html/config/conf_1_0.php on line 2

2005/3/13 17:50
应用扩展 工具箱


Re: 把xoops的设置写入cache的hack
网站管理员
注册日期:
2004/7/5 23:02
所属群组:
网站管理员
注册会员
帖子: 533
等级: 21; EXP: 27
HP : 101 / 506
MP : 177 / 2684
离线
引文:

hemeng 写道:
解决了。OK。不错。
不过:
Parse error: parse error, unexpected '=' in /home2/tcwan/public_html/config/conf_1_0.php on line 2

贴出文件看看?

2005/3/13 18:10
_________________
泡泡堂
应用扩展 工具箱


Re: 把xoops的设置写入cache的hack
新进会员
注册日期:
2004/12/13 14:09
所属群组:
注册会员
帖子: 20
等级: 3; EXP: 20
HP : 0 / 55
MP : 6 / 220
离线
<?php
 
= array (
  
'sitename' => '陕西省铜川市计算机专业学校',
  
'slogan' => '',
  
'adminmail' => '[email protected]',
  
'language' => 'schinese',
  
'startpage' => '--',
  
'server_TZ' => 8,
  
'default_TZ' => 8,
  
'theme_set' => 'obscene',
  
'theme_fromfile' => 1,
  
'theme_set_allowed' => 
  array (
    
=> '',
  ),
  
'template_set' => 'default',
  
'anonymous' => '游客',
  
'gzip_compression' => 1,
  
'usercookie' => 'xoops_user',
  
'use_mysession' => 0,
  
'session_name' => 'xoops_session',
  
'session_expire' => 30,
  
'debug_mode' => 2,
  
'banners' => 0,
  
'closesite' => 0,
  
'closesite_okgrp' => 
  array (
    
=> '1',
  ),
  
'closesite_text' => '网站维护中,请稍后再访问。',
  
'my_ip' => '',
  
'use_ssl' => 0,
  
'sslpost_name' => 'xoops_ssl',
  
'sslloginlink' => 'http://',
  
'com_mode' => 'flat',
  
'com_order' => 0,
  
'enable_badips' => 1,
  
'bad_ips' => 
  array (
    
=> '',
  ),
  
'module_cache' => 
  array (
    
15 => '1800',
    
21 => '300',
    
40 => '300',
    
=> '300',
    
10 => '1800',
    
11 => '1800',
    
13 => '300',
    
16 => '300',
    
24 => '1800',
    
27 => '1800',
    
28 => '1800',
    
39 => '300',
    
48 => '300',
    
52 => '300',
    
56 => '1800',
    
59 => '300',
    
62 => '1800',
    
64 => '300',
    
69 => '1800',
    
82 => '1800',
    
84 => '300',
    
111 => '300',
    
113 => '300',
  ),
);
?>
这是conf_1_0_1.php的。


以下是kernel/config.php的
<?php
// $Id: config.php,v 1.6 2004/12/26 19:11:53 onokazu Exp $
//  ------------------------------------------------------------------------ //
//                XOOPS - PHP Content Management System                      //
//                    Copyright (c) 2000 XOOPS.org                           //
//                       <http://www.xoops.org/>                             //
//  ------------------------------------------------------------------------ //
//  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.                                      //
//                                                                           //
//  You may not change or alter any portion of this comment or credits       //
//  of supporting developers from this source code or any supporting         //
//  source code which is considered copyrighted (c) material of the          //
//  original comment or credit authors.                                      //
//                                                                           //
//  This program is distributed in the hope that it will be useful,          //
//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
//  GNU General Public License for more details.                             //
//                                                                           //
//  You should have received a copy of the GNU General Public License        //
//  along with this program; if not, write to the Free Software              //
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
//  ------------------------------------------------------------------------ //
// Author: Kazumi Ono (AKA onokazu)                                          //
// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ //
// Project: The XOOPS Project                                                //
// ------------------------------------------------------------------------- //

if (!defined('XOOPS_ROOT_PATH')) {
    exit();
}

require_once 
XOOPS_ROOT_PATH.'/kernel/configoption.php';
require_once 
XOOPS_ROOT_PATH.'/kernel/configitem.php';

/**
 * @package     kernel
 * 
 * @author        Kazumi Ono    <[email protected]>
 * @copyright    copyright (c) 2000-2003 XOOPS.org
 */


/**
* XOOPS configuration handling class.
* This class acts as an interface for handling general configurations of XOOPS
* and its modules.
*
*
* @author  Kazumi Ono <[email protected]>
* @todo    Tests that need to be made:
*          - error handling
* @access  public
*/

class XoopsConfigHandler
{

    
/**
     * holds reference to config item handler(DAO) class
     * 
     * @var     object
     * @access    private
     */
    
var $_cHandler;

    
/**
     * holds reference to config option handler(DAO) class
     * 
     * @var        object
     * @access    private
     */
    
var $_oHandler;

    
/**
     * holds an array of cached references to config value arrays,
     *  indexed on module id and category id
     *
     * @var     array
     * @access  private
     */
    
var $_cachedConfigs = array();

    
/**
     * Constructor
     * 
     * @param    object  &$db    reference to database object
     */
    
function XoopsConfigHandler(&$db)
    {
        
$this->_cHandler = new XoopsConfigItemHandler($db);
        
$this->_oHandler = new XoopsConfigOptionHandler($db);
    }

    
/**
     * Create a config
     * 
     * @see     XoopsConfigItem
     * @return    object  reference to the new {@link XoopsConfigItem}
     */
    
function &createConfig()
    {
        return 
$this->_cHandler->create();
    }

    
/**
     * Get a config
     * 
     * @param    int     $id             ID of the config
     * @param    bool    $withoptions    load the config's options now?
     * @return    object  reference to the {@link XoopsConfig} 
     */
    
function &getConfig($id$withoptions false)
    {
        
$config =& $this->_cHandler->get($id);
        if (
$withoptions == true) {
            
$config->setConfOptions($this->getConfigOptions(new Criteria('conf_id'$id)));
        }
        return 
$config;
    }

    
/**
     * insert a new config in the database
     * 
     * @param    object  &$config    reference to the {@link XoopsConfigItem} 
     */
    
function insertConfig(&$config)
    {
        if (!
$this->_cHandler->insert($config)) {
            return 
false;
        }
        
$options =& $config->getConfOptions();
        
$count count($options);
        
$conf_id $config->getVar('conf_id');
        for (
$i 0$i $count$i++) {
            
$options[$i]->setVar('conf_id'$conf_id);
            if (!
$this->_oHandler->insert($options[$i])) {
                echo 
$options[$i]->getErrors();
            }
        }
        if (!empty(
$this->_cachedConfigs[$config->getVar('conf_modid')][$config->getVar('conf_catid')])) {
            
deleteConfigCacheByCat($config->getVar('conf_catid'),$config->getVar('conf_modid'));
unset (
$this->_cachedConfigs[$config->getVar('conf_modid')][$config->getVar('conf_catid')]);
        }
        return 
true;
    }

    
/**
     * Delete a config from the database
     * 
     * @param    object  &$config    reference to a {@link XoopsConfigItem} 
     */
    
function deleteConfig(&$config)
    {
        if (!
$this->_cHandler->delete($config)) {
            return 
false;
        }
        
$options =& $config->getConfOptions();
        
$count count($options);
        if (
$count == 0) {
            
$options =& $this->getConfigOptions(new Criteria('conf_id'$config->getVar('conf_id')));
            
$count count($options);
        }
        if (
is_array($options) && $count 0) {
            for (
$i 0$i $count$i++) {
                
$this->_oHandler->delete($options[$i]);
            }
        }
        if (!empty(
$this->_cachedConfigs[$config->getVar('conf_modid')][$config->getVar('conf_catid')])) {
            
deleteConfigCacheByCat($config->getVar('conf_catid'),$config->getVar('conf_modid'));
unset (
$this->_cachedConfigs[$config->getVar('conf_modid')][$config->getVar('conf_catid')]);
        }
        return 
true;
    }

    
/**
     * get one or more Configs
     * 
     * @param    object  $criteria       {@link CriteriaElement} 
     * @param    bool    $id_as_key      Use the configs' ID as keys?
     * @param    bool    $with_options   get the options now?
     * 
     * @return    array   Array of {@link XoopsConfigItem} objects
     */
    
function &getConfigs($criteria null$id_as_key false$with_options false)
    {
        return 
$this->_cHandler->getObjects($criteria$id_as_key);
    }

    
/**
     * Count some configs
     * 
     * @param    object  $criteria   {@link CriteriaElement} 
     */
    
function getConfigCount($criteria null)
    {
        return 
$this->_cHandler->getCount($criteria);
    }

    
/**
     * Get configs from a certain category
     * 
     * @param    int $category   ID of a category
     * @param    int $module     ID of a module
     * 
     * @return    array   array of {@link XoopsConfig}s 
     */
function &getConfigsByCat($category$module 0)
    {        if(
file_exists(XOOPS_ROOT_PATH.'/config/conf_'.$category.'_'.$module.'.php')){
            include 
XOOPS_ROOT_PATH.'/config/conf_'.$category.'_'.$module.'.php';
            return 
$conf;
        } else {
            return 
$this->cacheConfigByCat($category$module);
        }
    }

 
function &
cacheConfigByCat($category,$module=0)
    {
        static 
$_cachedConfigs;
        
$ret = array();
        
$criteria = new CriteriaCompo(new Criteria('conf_modid'intval($module)));
        if (!empty(
$category)) {
               
$criteria->add(new Criteria('conf_catid'intval($category)));
        }
        
$configs =& $this->getConfigs($criteriatrue);
        if (
is_array($configs)) {
               foreach (
array_keys($configs) as $i) {
                   
$ret[$configs[$i]->getVar('conf_name')] = $configs[$i]->getConfValueForOutput();
               }
        }
        
$_cachedConfigs[$module][$category] =& $ret;
        
$content "<?phpn$conf = ".var_export($ret,true).";n?>";
        
$fp fopen(XOOPS_ROOT_PATH.'/config/conf_'.$category.'_'.$module.'.php','w');
        
flock($fpLOCK_EX);
        
fwrite($fp,$content);
        
fclose($fp);
        return 
$ret;
    }
 
    function 
deleteConfigCacheByCat($category,$module=0)
    {
        if(
file_exists(XOOPS_ROOT_PATH.'/config/conf_'.$category.'_'.$module.'.php')){
            
unlink(XOOPS_ROOT_PATH.'/config/conf_'.$category.'_'.$module.'.php');
        }
    }






   
/**
     * Make a new {@link XoopsConfigOption} 
     * 
     * @return    object  {@link XoopsConfigOption} 
     */
    
function &createConfigOption(){
        return 
$this->_oHandler->create();
    }

    
/**
     * Get a {@link XoopsConfigOption} 
     * 
     * @param    int $id ID of the config option
     * 
     * @return    object  {@link XoopsConfigOption} 
     */
    
function &getConfigOption($id)
    {
        return 
$this->_oHandler->get($id);
    }

    
/**
     * Get one or more {@link XoopsConfigOption}s
     * 
     * @param    object  $criteria   {@link CriteriaElement} 
     * @param    bool    $id_as_key  Use IDs as keys in the array?
     * 
     * @return    array   Array of {@link XoopsConfigOption}s
     */
    
function &getConfigOptions($criteria null$id_as_key false)
    {
        return 
$this->_oHandler->getObjects($criteria$id_as_key);
    }

    
/**
     * Count some {@link XoopsConfigOption}s
     * 
     * @param    object  $criteria   {@link CriteriaElement} 
     * 
     * @return    int     Count of {@link XoopsConfigOption}s matching $criteria
     */
    
function getConfigOptionsCount($criteria null)
    {
        return 
$this->_oHandler->getCount($criteria);
    }

    
/**
     * Get a list of configs
     * 
     * @param    int $conf_modid ID of the modules
     * @param    int $conf_catid ID of the category
     * 
     * @return    array   Associative array of name=>value pairs.
     */
    
function &getConfigList($conf_modid$conf_catid 0)
    {
        if (!empty(
$this->_cachedConfigs[$conf_modid][$conf_catid])) {
            return 
$this->_cachedConfigs[$conf_modid][$conf_catid];
        } else {
            
$criteria = new CriteriaCompo(new Criteria('conf_modid'$conf_modid));
            if (empty(
$conf_catid)) {
                
$criteria->add(new Criteria('conf_catid'$conf_catid));
            }
            
$configs =& $this->_cHandler->getObjects($criteria);
            
$confcount count($configs);
            
$ret = array();
            for (
$i 0$i $confcount$i++) {
                
$ret[$configs[$i]->getVar('conf_name')] = $configs[$i]->getConfValueForOutput();
            }
            
$this->_cachedConfigs[$conf_modid][$conf_catid] =& $ret;
            return 
$ret;
        }
    }
}


?>






而/kernel/module.php用的就是您提供的那个。

2005/3/13 20:41
应用扩展 工具箱


Re: 把xoops的设置写入cache的hack
网站管理员
注册日期:
2004/7/5 23:02
所属群组:
网站管理员
注册会员
帖子: 533
等级: 21; EXP: 27
HP : 101 / 506
MP : 177 / 2684
离线
$content = "<?phpn$conf = ".var_export($ret,true).";n?>";
2个n前面有\ $前面也有\

2005/3/13 20:53
_________________
泡泡堂
应用扩展 工具箱


Re: 把xoops的设置写入cache的hack
新进会员
注册日期:
2004/12/13 14:09
所属群组:
注册会员
帖子: 20
等级: 3; EXP: 20
HP : 0 / 55
MP : 6 / 220
离线
有的,我复制,粘贴过来,就消失了。问题不是在那里呀。唉。

2005/3/13 21:30
应用扩展 工具箱



 回顶部   前一个主题   下一个主题
« 1 (2) 3 »

 [无发表权] 请登录或者注册


可以查看帖子.
不可发帖.
不可回复.
不可编辑自己的帖子.
不可删除自己的帖子.
不可发起投票调查.
不可在投票调查中投票.
不可上传附件.
不可不经审核直接发帖.

[高级搜索]