OSDN Git Service

sync the original code
[nucleus-jp/nucleus-jp-ancient.git] / utf8 / nucleus / libs / PLUGINADMIN.php
1 <?php\r
2 \r
3 /*\r
4  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)\r
5  * Copyright (C) 2002-2005 The Nucleus Group\r
6  *\r
7  * This program is free software; you can redistribute it and/or\r
8  * modify it under the terms of the GNU General Public License\r
9  * as published by the Free Software Foundation; either version 2\r
10  * of the License, or (at your option) any later version.\r
11  * (see nucleus/documentation/index.html#license for more info)\r
12  */\r
13 /**\r
14  * code to make it easier to create plugin admin areas\r
15  *\r
16  * @license http://nucleuscms.org/license.txt GNU General Public License\r
17  * @copyright Copyright (C) 2002-2005 The Nucleus Group\r
18  * @version $Id: PLUGINADMIN.php,v 1.4 2005-08-13 07:33:02 kimitake Exp $\r
19  * $NucleusJP: PLUGINADMIN.php,v 1.3 2005/03/12 06:19:05 kimitake Exp $\r
20  */\r
21 \r
22 global $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_COOKIE_VARS, $HTTP_ENV_VARS, $HTTP_POST_FILES, $HTTP_SESSION_VARS;\r
23 $aVarsToCheck = array('DIR_LIBS');\r
24 foreach ($aVarsToCheck as $varName)\r
25 {\r
26         if (phpversion() >= '4.1.0')\r
27         {\r
28                 if (   isset($_GET[$varName]) \r
29                         || isset($_POST[$varName]) \r
30                         || isset($_COOKIE[$varName])\r
31                         || isset($_ENV[$varName])\r
32                         || isset($_SESSION[$varName])\r
33                         || isset($_FILES[$varName])\r
34                 ){\r
35                         die('Sorry. An error occurred.');\r
36                 }\r
37         } else {\r
38                 if (   isset($HTTP_GET_VARS[$varName]) \r
39                         || isset($HTTP_POST_VARS[$varName]) \r
40                         || isset($HTTP_COOKIE_VARS[$varName])\r
41                         || isset($HTTP_ENV_VARS[$varName])\r
42                         || isset($HTTP_SESSION_VARS[$varName])\r
43                         || isset($HTTP_POST_FILES[$varName])\r
44                 ){\r
45                         die('Sorry. An error occurred.');\r
46                 }               \r
47         }\r
48 }\r
49 \r
50 \r
51 include($DIR_LIBS . 'ADMIN.php');\r
52 \r
53 class PluginAdmin {\r
54         \r
55         var $strFullName;               // NP_SomeThing\r
56         var $plugin;                    // ref. to plugin object\r
57         var $bValid;                    // evaluates to true when object is considered valid\r
58         var $admin;                             // ref to an admin object\r
59         \r
60         function PluginAdmin($pluginName)\r
61         {\r
62                 global $manager;\r
63                 \r
64                 $this->strFullName = 'NP_' . $pluginName;\r
65                 \r
66                 // check if plugin exists and is installed\r
67                 if (!$manager->pluginInstalled($this->strFullName))\r
68                         doError('Invalid plugin');\r
69                 \r
70                 $this->plugin =& $manager->getPlugin($this->strFullName);\r
71                 $this->bValid = $this->plugin;\r
72         \r
73                 if (!$this->bValid)\r
74                         doError('Invalid plugin');\r
75                 \r
76                 $this->admin = new ADMIN();\r
77                 $this->admin->action = 'plugin_' . $pluginName;\r
78         }\r
79         \r
80         function start($extraHead = '')\r
81         {\r
82                 global $CONF;\r
83                 $strBaseHref  = '<base href="' . htmlspecialchars($CONF['AdminURL']) . '" />';  \r
84                 $extraHead .= $strBaseHref;\r
85                 \r
86                 $this->admin->pagehead($extraHead);\r
87         }\r
88         \r
89         function end()\r
90         {\r
91                 $this->admin->pagefoot();\r
92         }       \r
93 }\r
94 \r
95 \r
96 \r
97 ?>\r