OSDN Git Service

sync the original code
[nucleus-jp/nucleus-jp-ancient.git] / nucleus / index.php
1 <?php\r
2 /*\r
3  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)\r
4  * Copyright (C) 2002-2005 The Nucleus Group\r
5  *\r
6  * This program is free software; you can redistribute it and/or\r
7  * modify it under the terms of the GNU General Public License\r
8  * as published by the Free Software Foundation; either version 2\r
9  * of the License, or (at your option) any later version.\r
10  * (see nucleus/documentation/index.html#license for more info)\r
11  */\r
12 /**\r
13  * @license http://nucleuscms.org/license.txt GNU General Public License\r
14  * @copyright Copyright (C) 2002-2005 The Nucleus Group\r
15  * @version $Id: index.php,v 1.6 2005-08-13 07:33:45 kimitake Exp $\r
16  * $NucleusJP: index.php,v 1.5 2005/03/16 07:55:05 kimitake Exp $\r
17  */\r
18         // we are using admin stuff:\r
19         $CONF = array();\r
20         $CONF['UsingAdminArea'] = 1;\r
21 \r
22         // include the admin code\r
23         include('../config.php');\r
24 \r
25         if ($CONF['alertOnSecurityRisk'] == 1)\r
26         {\r
27                 // check if files exist and generate an error if so\r
28                 $aFiles = array(\r
29                         '../install.sql' => 'install.sql should be deleted',\r
30                         '../install.php' => 'install.php should be deleted',\r
31                         'upgrades' => 'nucleus/upgrades directory should be deleted',\r
32                         'convert' => 'nucleus/convert directory should be deleted'\r
33                 );\r
34                 $aFound = array();\r
35                 foreach($aFiles as $fileName => $fileDesc)\r
36                 {\r
37                         if (@file_exists($fileName))\r
38                                 array_push($aFound, $fileDesc);\r
39                 }\r
40                 if (@is_writable('../config.php')) {\r
41                         array_push($aFound, 'config.php should be non-writable (chmod to 444)');\r
42                 }\r
43                 if (sizeof($aFound) > 0)\r
44                 {\r
45                         startUpError(\r
46                                 '<p>One or more of the Nucleus installation files are still present on the webserver, or are writable.</p><p>You should remove these files or change their permissions to ensure security. Here are the files that were found by Nucleus</p> <ul><li>'. implode($aFound, '</li><li>').'</li></ul><p>If you don\'t want to see this error message again, without solving the problem, set <code>$CONF[\'alertOnSecurityRisk\']</code> in <code>globalfunctions.php</code> to <code>0</code>, or do this at the end of <code>config.php</code>.</p>',\r
47                                 'Security Risk'\r
48                         );\r
49                 }\r
50         }\r
51 \r
52         $bNeedsLogin = false;\r
53         $bIsActivation = in_array($action, array('activate', 'activatesetpwd'));\r
54         \r
55         if ($action == 'logout') \r
56                 $bNeedsLogin = true;    \r
57         \r
58         if (!$member->isLoggedIn() && !$bIsActivation)\r
59                 $bNeedsLogin = true;\r
60 \r
61         // show error if member cannot login to admin\r
62         if ($member->isLoggedIn() && !$member->canLogin() && !$bIsActivation) {\r
63                 $error = _ERROR_LOGINDISALLOWED;\r
64                 $bNeedsLogin = true;\r
65         }\r
66         \r
67         if ($bNeedsLogin)\r
68         {\r
69                 setOldAction($action);  // see ADMIN::login() (sets old action in POST vars)\r
70                 $action = 'showlogin';\r
71         }\r
72 \r
73         sendContentType('application/xhtml+xml', 'admin-' . $action);\r
74         \r
75         $admin = new ADMIN();\r
76         $admin->action($action);\r
77 ?>\r