1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
You may not change or alter any portion of this comment or credits |
4
|
|
|
of supporting developers from this source code or any supporting source code |
5
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
6
|
|
|
|
7
|
|
|
This program is distributed in the hope that it will be useful, |
8
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
9
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
use Xoops\Core\Controller\FrontController; |
13
|
|
|
use Xoops\Core\FixedGroups; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* XOOPS global entry |
17
|
|
|
* |
18
|
|
|
* @copyright XOOPS Project (http://xoops.org) |
19
|
|
|
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) |
20
|
|
|
* @package core |
21
|
|
|
* @since 2.0.0 |
22
|
|
|
* @author Kazumi Ono <[email protected]> |
23
|
|
|
* @author Skalpa Keo <[email protected]> |
24
|
|
|
* @author Taiwen Jiang <[email protected]> |
25
|
|
|
* @version $Id$ |
26
|
|
|
*/ |
27
|
|
|
|
28
|
|
|
$mainfile = __DIR__ . '/mainfile.php'; |
29
|
|
|
if (file_exists($mainfile)) { |
30
|
|
|
include $mainfile; |
31
|
|
|
} elseif (file_exists(__DIR__ . '/install/index.php')) { |
32
|
|
|
header('Location: install/index.php'); |
33
|
|
|
exit; |
34
|
|
|
} |
35
|
|
|
unset($mainfile); |
36
|
|
|
|
37
|
|
|
class indexController extends FrontController |
38
|
|
|
{ |
39
|
|
|
public function doInit() |
|
|
|
|
40
|
|
|
{ |
41
|
|
|
parent::doInit(); |
42
|
|
|
|
43
|
|
|
$this->startEvent = 'core.index.start'; |
44
|
|
|
|
45
|
|
|
//check if start page is defined |
46
|
|
|
$startpage = $this->xoops->getConfig('startpage'); |
47
|
|
|
if ($this->xoops->isActiveModule($startpage)) { |
48
|
|
|
// Temporary solution for start page redirection |
49
|
|
|
define('XOOPS_STARTPAGE_REDIRECTED', 1); |
50
|
|
|
$module_handler = $this->xoops->getHandlerModule(); |
51
|
|
|
$this->xoops->module = $this->xoops->getModuleByDirname($startpage); |
|
|
|
|
52
|
|
|
if (!$this->xoops->isModule() || !$this->xoops->module->getVar('isactive')) { |
53
|
|
|
$this->xoops->header(); |
54
|
|
|
echo "<h4>" . XoopsLocale::E_NO_MODULE . "</h4>"; |
55
|
|
|
$this->xoops->footer(); |
56
|
|
|
exit; |
|
|
|
|
57
|
|
|
} |
58
|
|
|
$moduleperm_handler = $this->xoops->getHandlerGroupPermission(); |
59
|
|
|
$mid = $this->xoops->module->getVar('mid'); |
60
|
|
|
if ($this->xoops->isUser()) { |
61
|
|
|
if (!$moduleperm_handler->checkRight('module_read', $mid, $this->xoops->user->getGroups())) { |
62
|
|
|
$this->xoops->redirect($this->xoops_url, 1, XoopsLocale::E_NO_ACCESS_PERMISSION, false); |
63
|
|
|
} |
64
|
|
|
$this->xoops->userIsAdmin = $this->xoops->user->isAdmin($mid); |
65
|
|
|
} else { |
66
|
|
|
if (!$moduleperm_handler->checkRight('module_read', $mid, FixedGroups::ANONYMOUS)) { |
67
|
|
|
$this->xoops->redirect($this->xoops_url . "/user.php", 1, XoopsLocale::E_NO_ACCESS_PERMISSION); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
if ($this->xoops->module->getVar('hasconfig') == 1 |
71
|
|
|
|| $this->xoops->module->getVar('hascomments') == 1 |
72
|
|
|
|| $this->xoops->module->getVar('hasnotification') == 1 |
73
|
|
|
) { |
74
|
|
|
$this->xoops->moduleConfig = $this->xoops->getModuleConfigs(); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
chdir('modules/' . $startpage . '/'); |
78
|
|
|
$this->xoops->loadLanguage('main', $this->xoops->module->getVar('dirname', 'n')); |
79
|
|
|
$parsed = parse_url($this->xoops_url); |
80
|
|
|
$url = isset($parsed['scheme']) ? $parsed['scheme'] . '://' : 'http://'; |
81
|
|
View Code Duplication |
if (isset($parsed['host'])) { |
82
|
|
|
$url .= $parsed['host']; |
83
|
|
|
if (isset($parsed['port'])) { |
84
|
|
|
$url .= ':' . $parsed['port']; |
85
|
|
|
} |
86
|
|
|
} else { |
87
|
|
|
$url .= $_SERVER['HTTP_HOST']; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
$_SERVER['REQUEST_URI'] = |
91
|
|
|
substr($this->xoops_url, strlen($url)) . '/modules/' . $startpage . '/index.php'; |
92
|
|
|
include $this->xoops->path('modules/' . $startpage . '/index.php'); |
93
|
|
|
exit; |
|
|
|
|
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
public function doHeader() |
98
|
|
|
{ |
99
|
|
|
$this->xoops->setOption('show_cblock', 1); |
100
|
|
|
$this->template = "module:system/system_homepage.tpl"; |
101
|
|
|
parent::doHeader(); |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
$controller = new indexController(); |
106
|
|
|
$controller->run(); |
107
|
|
|
|
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: