OSDN Git Service

Merge branch 'master' into skinnable-master
[nucleus-jp/nucleus-next.git] / nucleus / index.php
1 <?php
2 /*
3  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
4  * Copyright (C) 2002-2012 The Nucleus Group
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  * (see nucleus/documentation/index.html#license for more info)
11  */
12 /**
13  * @license http://nucleuscms.org/license.txt GNU General Public License
14  * @copyright Copyright (C) 2002-2012 The Nucleus Group
15  * @version $Id: index.php 1638 2012-01-29 08:07:27Z sakamocchi $
16  */
17
18 // we are using admin stuff:
19 $CONF = array();
20 $CONF['UsingAdminArea'] = 1;
21
22 // include the admin code
23 require_once('../config.php');
24
25 if ($CONF['alertOnSecurityRisk'] == 1)
26 {
27         // check if files exist and generate an error if so
28         $aFiles = array(
29                 '../install.sql' => _ERRORS_INSTALLSQL,
30                 '../install.php' => _ERRORS_INSTALLPHP,
31                 'upgrades' => _ERRORS_UPGRADESDIR,
32                 'convert' => _ERRORS_CONVERTDIR
33         );
34         $aFound = array();
35         foreach($aFiles as $fileName => $fileDesc)
36         {
37                 if (@file_exists($fileName))
38                         array_push($aFound, $fileDesc);
39         }
40         if (@is_writable('../config.php')) {
41                 array_push($aFound, _ERRORS_CONFIGPHP);
42         }
43         if (sizeof($aFound) > 0)
44         {
45                 startUpError(
46                         _ERRORS_STARTUPERROR1. implode($aFound, '</li><li>')._ERRORS_STARTUPERROR2,
47                         _ERRORS_STARTUPERROR3
48                 );
49         }
50 }
51
52 $bNeedsLogin = false;
53 $bIsActivation = in_array($action, array('activate', 'activatesetpwd'));
54
55 if ( $action == 'logout' )
56 {
57         $bNeedsLogin = true;
58 }
59
60 if ( !$member->isLoggedIn() && !$bIsActivation )
61 {
62         $bNeedsLogin = true;
63 }
64
65 // show error if member cannot login to admin
66 if ( $member->isLoggedIn() && !$member->canLogin() && !$bIsActivation )
67 {
68         $error = _ERROR_LOGINDISALLOWED;
69         $bNeedsLogin = true;
70 }
71
72 if ( $bNeedsLogin )
73 {
74         // see Admin::login() (sets old action in POST vars)
75         setOldAction($action);
76         $action = 'showlogin';
77 }
78
79 sendContentType('text/html', 'admin-' . $action);
80
81 $admin = new Admin();
82 $admin->action($action);