/
functions_module.php
57 lines (47 loc) · 1.08 KB
/
functions_module.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
/**
*
* @package quickinstall
* @version $Id$
* @copyright (c) 2007, 2008 eviL3
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_QUICKINSTALL'))
{
exit;
}
/**
* Module handler from wiedler.ch, optimized for phpbb
* @package quickinstall
*/
class module_handler
{
protected $modules_path;
protected $modules_prefix;
public function __construct($modules_path, $modules_prefix = '')
{
$this->modules_path = (string) $modules_path;
$this->modules_prefix = (string) $modules_prefix;
}
public function load($module, $default)
{
global $phpEx, $user;
// just some security (thanks lordlebrand)
$module = basename($module);
if (!file_exists($this->modules_path . $this->modules_prefix . $module . '.' . $phpEx))
{
$module = $default;
}
if (false === @include($this->modules_path . $this->modules_prefix . $module . '.' . $phpEx))
{
trigger_error(sprintf($user->lang['NO_MODULE'], $module), E_USER_ERROR);
}
$class_name = $this->modules_prefix . $module;
return new $class_name();
}
}
?>