Minahito
minah****@users*****
2006年 6月 22日 (木) 14:56:23 JST
Index: xoops2jp/html/modules/base/preload/IPbanningFilter.class.php diff -u /dev/null xoops2jp/html/modules/base/preload/IPbanningFilter.class.php:1.1.2.1 --- /dev/null Thu Jun 22 14:56:23 2006 +++ xoops2jp/html/modules/base/preload/IPbanningFilter.class.php Thu Jun 22 14:56:22 2006 @@ -0,0 +1,20 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +class Base_IPbanningFilter extends XCube_ActionFilter +{ + function preBlockFilter() + { + if ($this->mController->mConfig['enable_badips']) { + if(isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR']) { + foreach ($this->mController->mConfig['bad_ips'] as $bi) { + if(strstr($_SERVER['REMOTE_ADDR'],$bi)!==false) + die(); + } + } + } + } +} + +?> \ No newline at end of file Index: xoops2jp/html/modules/base/preload/ThemeSelect.class.php diff -u /dev/null xoops2jp/html/modules/base/preload/ThemeSelect.class.php:1.1.2.1 --- /dev/null Thu Jun 22 14:56:23 2006 +++ xoops2jp/html/modules/base/preload/ThemeSelect.class.php Thu Jun 22 14:56:22 2006 @@ -0,0 +1,65 @@ +<?php +// $Id: ThemeSelect.class.php,v 1.1.2.1 2006/06/22 05:56:22 minahito 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 // +// ------------------------------------------------------------------------ // + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +class Base_ThemeSelect extends XCube_ActionFilter +{ + function preBlockFilter() + { + if (!empty($_POST['xoops_theme_select']) && in_array($_POST['xoops_theme_select'], $this->mController->mConfig['theme_set_allowed'])) { + $this->mController->mConfig['theme_set'] = $_POST['xoops_theme_select']; + $_SESSION['xoopsUserTheme'] = $_POST['xoops_theme_select']; + } elseif (!empty($_SESSION['xoopsUserTheme']) && in_array($_SESSION['xoopsUserTheme'], $this->mController->mConfig['theme_set_allowed'])) { + $this->mController->mConfig['theme_set'] = $_SESSION['xoopsUserTheme']; + } + + $delegate=new XCube_Delegate("ThemeSelect_Filter","callbackCheckLoginSuccess"); + $this->mController->mRoot->mEventManager->add("Site.CheckLogin.Success",$delegate); + } + + function callbackCheckLoginSuccess(&$controller,&$eventArgs) + { + // + // This check is not needed. :) + // + if(!is_object($eventArgs['xoopsUser'])) + return; + + $user=&$eventArgs['xoopsUser']; + + // + // Check Theme and set it to session. + // + $userTheme=$eventArgs['xoopsUser']->getVar('theme'); + if(is_array($userTheme) && in_array($userTheme,$controller->getConfig('theme_set_allowed'))) { + $_SESSION['xoopsUserTheme'] = $userTheme; + } + } +} + +?> \ No newline at end of file Index: xoops2jp/html/modules/base/preload/SiteClose.class.php diff -u /dev/null xoops2jp/html/modules/base/preload/SiteClose.class.php:1.1.2.1 --- /dev/null Thu Jun 22 14:56:23 2006 +++ xoops2jp/html/modules/base/preload/SiteClose.class.php Thu Jun 22 14:56:22 2006 @@ -0,0 +1,184 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +class Base_SiteClose extends XCube_ActionFilter +{ + function preBlockFilter() + { + if(($this->mController->mConfig['closesite']==1)||is_array(XCube_Utils::checkSystemModules())) { + $this->mController->mRoot->mEventManager->add("Site.Login",new XCube_InstanceDelegate($this,"callbackSiteLogin")); + $this->mController->mRoot->mEventManager->add("Site.CheckLogin.Success",new XCube_InstanceDelegate($this,"callbackCheckLoginSuccess")); + } + } + + function callbackSiteLogin() + { + $retArray = XCube_Utils::checkSystemModules(); + $accessAllowFlag = false; + if(!empty($_POST['xoops_login'])) { + if (is_array($retArray)) { + define('XOOPS_CPFUNC_LOADED',1); + } + require_once XOOPS_ROOT_PATH.'/include/checklogin.php'; + return; + } elseif(is_object($this->mController->mXoopsUser)) { + foreach ($this->mController->mXoopsUser->getGroups() as $group) { + if (in_array($group, $this->mController->mConfig['closesite_okgrp']) || XOOPS_GROUP_ADMIN == $group) { + $accessAllowFlag = true; + break; + } + } + } + // @todo Devide following lines to another preload file + if ($accessAllowFlag) { + if (is_array($retArray)) { + if (in_array(XOOPS_GROUP_ADMIN, $this->mController->mXoopsUser->getGroups())) { + $GLOBALS['xoopsUser'] = $this->mController->mXoopsUser; + if (!empty($_POST['cube_module_install'])) { //@todo use Ticket + require_once XOOPS_BASE_PATH."/admin/class/ModuleInstaller.class.php"; + if (isset($_POST['uninstalled_modules']) && is_array($_POST['uninstalled_modules']) ){ + foreach($_POST['uninstalled_modules'] as $module) { + $module = basename($module); + if (in_array($module, $retArray['uninstalled'])) { + $installer = new Legacy_ModuleInstaller($module); + $installer->execute(); + } + } + } + if (isset($_POST['disabled_modules']) &&is_array($_POST['disabled_modules'])){ + $moduleHandler =& xoops_gethandler('module'); + foreach($_POST['disabled_modules'] as $module) { + $module = basename($module); + if (in_array($module, $retArray['disabled'])) { + if($moduleObject =& $moduleHandler->getByDirname($module)) { + $moduleObject->setVar('isactive',1); + $moduleHandler->insert($moduleObject); + } + } + } + } + if (isset($_POST['option_modules']) && is_array($_POST['option_modules']) ){ + $handler =& xoops_getmodulehandler('non_installation_module','base'); + $objects = $handler->getObjects(); + $optionModules = array(); + foreach($objects as $module) { + if (!in_array($module->getVar('dirname'), $retArray['uninstalled'])) { + $optionModules[] = $module->getVar('dirname'); + } + } + foreach($_POST['option_modules'] as $module) { + $module = basename($module); + if (in_array($module, $optionModules)) { + $installer = new Legacy_ModuleInstaller($module); + $installer->execute(); + } + } + } + XCube_Utils::redirectHeader(XOOPS_URL,1); + } else if (!empty($_GET['cube_module_uninstall'])) { + require_once XOOPS_ROOT_PATH.'/class/template.php'; + $xoopsTpl = new XoopsTpl(); + $xoopsTpl->assign('cube_module_uninstall',htmlspecialchars($_GET['cube_module_uninstall'],ENT_QUOTES)); + $xoopsTpl->assign( array( + 'xoops_sitename' => htmlspecialchars($this->mController->mConfig['sitename']), + 'xoops_themecss' => xoops_getcss(), + 'xoops_imageurl' => XOOPS_THEME_URL.'/'.$this->mController->mConfig['theme_set'].'/', + )); + ///< @todo filebase template with absolute file path + $xoopsTpl->compile_check = true; + $xoopsTpl->display(XOOPS_ROOT_PATH.'/modules/base/templates/legacy_uninstall_modules.html'); + exit(); + } else if (!empty($_POST['cube_module_uninstallok'])) { //@todo use Ticket + require_once XOOPS_BASE_PATH."/admin/class/ModuleUninstaller.class.php"; + $module = basename($_POST['cube_module_uninstallok']); + if (in_array($module, $retArray['disabled'])) { + $uninstaller = new Legacy_ModuleUninstaller($module); + $uninstaller->execute(); + } + XCube_Utils::redirectHeader(XOOPS_URL,1); + } else { + $handler =& xoops_getmodulehandler('non_installation_module','base'); + $objects = $handler->getObjects(); + $optionModules = array(); + foreach($objects as $module) { + $dirname = $module->getVar('dirname'); + if (!in_array($dirname, $retArray['uninstalled'])) { + $optionModule['dirname'] = $dirname; + if (in_array($dirname, $retArray['recommended'])) { + $optionModule['checked'] = 'checked="checked"'; + $optionModule['desc'] = _SYS_RECOMMENDED_MODULES; + } else { + $optionModule['checked'] = ''; + $optionModule['desc'] = _SYS_OPTION_MODULES; + } + $optionModules[] = $optionModule; + } + } + require_once XOOPS_ROOT_PATH.'/class/template.php'; + $xoopsTpl = new XoopsTpl(); + $xoopsTpl->assign('uninstalled',$retArray['uninstalled']); + $xoopsTpl->assign('disabled',$retArray['disabled']); + $xoopsTpl->assign('option',$optionModules); + $xoopsTpl->assign( array( + 'xoops_sitename' => htmlspecialchars($this->mController->mConfig['sitename']), + 'xoops_themecss' => xoops_getcss(), + 'xoops_imageurl' => XOOPS_THEME_URL.'/'.$this->mController->mConfig['theme_set'].'/', + )); + ///< @todo filebase template with absolute file path + $xoopsTpl->compile_check = true; + $xoopsTpl->display(XOOPS_ROOT_PATH.'/modules/base/templates/legacy_install_modules.html'); + exit(); + } + } else { + $accessAllowFlag = false; + } + } + } + + if (!$accessAllowFlag) { + require_once XOOPS_ROOT_PATH.'/class/template.php'; + $xoopsTpl = new XoopsTpl(); + $xoopsTpl->assign( array('xoops_sitename' => htmlspecialchars($this->mController->mConfig['sitename']), + 'xoops_themecss' => xoops_getcss(), + 'xoops_imageurl' => XOOPS_THEME_URL.'/'.$this->mController->mConfig['theme_set'].'/', + 'lang_login' => _LOGIN, + 'lang_username' => _USERNAME, + 'lang_password' => _PASSWORD, + 'lang_siteclosemsg' => $this->mController->mConfig['closesite_text'])); + $xoopsTpl->compile_check = true; + // @todo filebase template with absolute file path + $xoopsTpl->display(XOOPS_ROOT_PATH.'/modules/base/templates/legacy_site_closed.html'); + exit(); + } + } + + function callbackCheckLoginSuccess(&$controller,&$eventArgs) + { + // + // This check is not needed. :) + // + if(!is_object($eventArgs['xoopsUser'])) + return; + + $user=&$eventArgs['xoopsUser']; + + // Site close + if($controller->getConfig('closesite')) { + $accessAllowed=false; + + foreach($user->getGroups() as $group) { + if(in_array($group,$controller->getConfig('closesite_okgrp')) || ($group==XOOPS_GROUP_ADMIN)) { + $accessAllowed=true; + break; + } + } + + if(!$accessAllowed) { + XCube_Utils::redirectHeader(XOOPS_URL,1,_NOPERM); + } + } + } +} + +?> \ No newline at end of file