4 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
5 * Copyright (C) 2002-2007 The Nucleus Group
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 * (see nucleus/documentation/index.html#license for more info)
14 * code to make it easier to create plugin admin areas
16 * @license http://nucleuscms.org/license.txt GNU General Public License
17 * @copyright Copyright (C) 2002-2007 The Nucleus Group
18 * @version $Id: PLUGINADMIN.php,v 1.6 2007-02-04 06:28:46 kimitake Exp $
19 * $NucleusJP: PLUGINADMIN.php,v 1.5 2006/07/12 07:11:47 kimitake Exp $
22 global $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_COOKIE_VARS, $HTTP_ENV_VARS, $HTTP_POST_FILES, $HTTP_SESSION_VARS;
23 $aVarsToCheck = array('HTTP_GET_VARS', 'HTTP_POST_VARS', 'HTTP_COOKIE_VARS', 'HTTP_ENV_VARS', 'HTTP_SESSION_VARS', 'HTTP_POST_FILES', 'HTTP_SERVER_VARS', 'GLOBALS', 'argv', 'argc', '_GET', '_POST', '_COOKIE', '_ENV', '_SESSION', '_SERVER', '_FILES', 'DIR_LIBS');
25 foreach ($aVarsToCheck as $varName)
27 if (phpversion() >= '4.1.0')
29 if ( isset($_GET[$varName])
30 || isset($_POST[$varName])
31 || isset($_COOKIE[$varName])
32 || isset($_ENV[$varName])
33 || isset($_SESSION[$varName])
34 || isset($_FILES[$varName])
36 die('Sorry. An error occurred.');
39 if ( isset($HTTP_GET_VARS[$varName])
40 || isset($HTTP_POST_VARS[$varName])
41 || isset($HTTP_COOKIE_VARS[$varName])
42 || isset($HTTP_ENV_VARS[$varName])
43 || isset($HTTP_SESSION_VARS[$varName])
44 || isset($HTTP_POST_FILES[$varName])
46 die('Sorry. An error occurred.');
51 if (!isset($DIR_LIBS)) {
55 include($DIR_LIBS . 'ADMIN.php');
59 var $strFullName; // NP_SomeThing
60 var $plugin; // ref. to plugin object
61 var $bValid; // evaluates to true when object is considered valid
62 var $admin; // ref to an admin object
64 function PluginAdmin($pluginName)
68 $this->strFullName = 'NP_' . $pluginName;
70 // check if plugin exists and is installed
71 if (!$manager->pluginInstalled($this->strFullName))
72 doError('Invalid plugin');
74 $this->plugin =& $manager->getPlugin($this->strFullName);
75 $this->bValid = $this->plugin;
78 doError('Invalid plugin');
80 $this->admin = new ADMIN();
81 $this->admin->action = 'plugin_' . $pluginName;
84 function start($extraHead = '')
87 $strBaseHref = '<base href="' . htmlspecialchars($CONF['AdminURL']) . '" />';
88 $extraHead .= $strBaseHref;
90 $this->admin->pagehead($extraHead);
95 $this->admin->pagefoot();