OSDN Git Service

6bc8c7e7426f188365268873f5658a0632064a04
[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 1748 2012-04-13 13:27:57Z 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'    => _ERRORS_INSTALLDIR,
30                 'upgrades'              => _ERRORS_UPGRADESDIR,
31                 'convert'               => _ERRORS_CONVERTDIR
32         );
33         $aFound = array();
34         foreach ( $aFiles as $fileName => $fileDesc )
35         {
36                 if ( @file_exists($fileName) )
37                 {
38                         array_push($aFound, $fileDesc);
39                 }
40         }
41         if ( @is_writable('../config.php') )
42         {
43                 array_push($aFound, _ERRORS_CONFIGPHP);
44         }
45         if ( sizeof($aFound) > 0 )
46         {
47                 startUpError(
48                         _ERRORS_STARTUPERROR1. implode($aFound, '</li><li>')._ERRORS_STARTUPERROR2,
49                         _ERRORS_STARTUPERROR3
50                 );
51         }
52 }
53
54 $bNeedsLogin    = FALSE;
55 $bIsActivation  = in_array($action, array('activate', 'activatesetpwd'));
56
57 if ( $action == 'logout' )
58 {
59         $bNeedsLogin = TRUE;
60 }
61
62 if ( !$member->isLoggedIn() && !$bIsActivation )
63 {
64         $bNeedsLogin = TRUE;
65 }
66
67 // show error if member cannot login to admin
68 if ( $member->isLoggedIn() && !$member->canLogin() && !$bIsActivation )
69 {
70         $error = _ERROR_LOGINDISALLOWED;
71         $bNeedsLogin = TRUE;
72 }
73
74 if ( $bNeedsLogin )
75 {
76         // see Admin::login() (sets old action in POST vars)
77         setOldAction($action);
78         $action = 'showlogin';
79 }
80
81 /* FIXME: Skin class also output this HTTP1.1 headers
82 sendContentType('text/html', 'admin-' . $action);
83 */
84
85 if ( !Admin::initialize() )
86 {
87         $skin = new Skin(0, 'AdminActions', 'AdminSkin');
88         if ( $bNeedsLogin )
89         {
90                 $skin->parse('fileparse', $DIR_SKINS . 'admin/showlogin.skn');
91         }
92         else if ($action == 'adminskinieimport' )
93         {
94                 Admin::action($action);
95         }
96         else
97         {
98                 $skin->parse('importAdmin', $DIR_SKINS . 'admin/defaultimporter.skn');
99         }
100         /* TODO: something to handling errors */
101         exit;
102 }
103
104 Admin::action($action);
105 exit;