新进会员
注册日期: 2004/12/13 14:09
所属群组:
注册会员
等级: 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 (
0 => '',
),
'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 (
0 => '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 (
0 => '',
),
'module_cache' =>
array (
15 => '1800',
21 => '300',
40 => '300',
3 => '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($criteria, true);
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($fp, LOCK_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
|