OSDN Git Service

Merge branch '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-2009 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 <<<<<<< HEAD
15  * @copyright Copyright (C) 2002-2012 The Nucleus Group
16  * @version $Id: index.php 1748 2012-04-13 13:27:57Z sakamocchi $
17 =======
18  * @copyright Copyright (C) 2002-2009 The Nucleus Group
19  * @version $Id: index.php 1888 2012-06-17 08:38:54Z sakamocchi $
20 >>>>>>> skinnable-master
21  */
22
23 // we are using admin stuff:
24 $CONF = array();
25 $CONF['UsingAdminArea'] = 1;
26
27 // include the admin code
28 require_once('../config.php');
29
30 if ( $CONF['alertOnSecurityRisk'] == 1 )
31 {
32         // check if files exist and generate an error if so
33         $aFiles = array(
34                 '../install'    => _ERRORS_INSTALLDIR,
35                 'upgrades'              => _ERRORS_UPGRADESDIR,
36                 'convert'               => _ERRORS_CONVERTDIR
37         );
38         $aFound = array();
39         foreach ( $aFiles as $fileName => $fileDesc )
40         {
41                 if ( @file_exists($fileName) )
42                 {
43                         array_push($aFound, $fileDesc);
44                 }
45         }
46         if ( @is_writable('../config.php') )
47         {
48                 array_push($aFound, _ERRORS_CONFIGPHP);
49         }
50         if ( sizeof($aFound) > 0 )
51         {
52                 startUpError(
53                         _ERRORS_STARTUPERROR1. implode($aFound, '</li><li>')._ERRORS_STARTUPERROR2,
54                         _ERRORS_STARTUPERROR3
55                 );
56         }
57 }
58
59 $bNeedsLogin    = FALSE;
60 $bIsActivation  = in_array($action, array('activate', 'activatesetpwd'));
61
62 if ( $action == 'logout' )
63 {
64         $bNeedsLogin = TRUE;
65 }
66
67 if ( !$member->isLoggedIn() && !$bIsActivation )
68 {
69         $bNeedsLogin = TRUE;
70 }
71
72 // show error if member cannot login to admin
73 if ( $member->isLoggedIn() && !$member->canLogin() && !$bIsActivation )
74 {
75         $error = _ERROR_LOGINDISALLOWED;
76         $bNeedsLogin = TRUE;
77 }
78
79 if ( $bNeedsLogin )
80 {
81         // see Admin::login() (sets old action in POST vars)
82         setOldAction($action);
83         $action = 'showlogin';
84 }
85
86 if ( !Admin::initialize() )
87 {
88         /* TODO: this is a bad way... */
89         sendContentType('text/html', 'admin-' . $action);
90         
91         $skin =& $manager->getSkin(0, 'AdminActions', 'AdminSkin');
92         if ( $bNeedsLogin )
93         {
94                 $skin->parse('fileparse', $DIR_SKINS . 'admin/showlogin.skn');
95         }
96         else if ($action == 'adminskinieimport' )
97         {
98                 Admin::action($action);
99         }
100         else
101         {
102                 $skin->parse('importAdmin', $DIR_SKINS . 'admin/defaultimporter.skn');
103         }
104         /* TODO: something to handling errors */
105         exit;
106 }
107
108 Admin::action($action);
109 exit;