aboutsummaryrefslogtreecommitdiff
path: root/modules.php
blob: 9cd6350f21d1eab73beb07750183c775643fb6dd (plain) (blame)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
/**
 * Bayonet Content Management System
 * Copyright (C) 2008  Joseph Hunkeler
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */ 
 
define("MODULE_FILE",true);

global $load,$index_module;

if(isset($_GET['load']))
    $load = $_GET['load'];

if(isset($_GET['file']))
    $file = $_GET['file'];

if(is_null($load))
{
  $load = $config['modules']['default'];
}

$deny_chars = $config['modules']['deny_chars'];

$load_temp = $load;

/*
 * broken i guess.
for($chars = 0; $chars <= strlen($load_temp); ++$chars)
{
  foreach($deny_chars as $deny)
  {
    if($load_temp[$chars] == $deny)
    {
      OpenTable();
      ReportHack("Invalid characters detected.\n");
      CloseTable();       
    } 
  }
}
*/

/* If the error stack has recieved messages, output each failure in a clean fashion */
global $error_stack_messages;
if(!empty($error_stack_messages))
{
	$messageBuffer = NULL;
	foreach($error_stack_messages as $order => $error)
	{
		$messageBuffer .= "<p><b>Stack Order:</b> $order<br/>$error</p>";
	}
	ReportError($messageBuffer);
	//exit(1);
}

if(isset($load) && !empty($load) && !isset($file))
{
  if(file_exists("modules/" . $load))
  {
    include 'modules/' . $load . '/index.php';
  }
  else
  {
    ReportError("Cannot load module directory.<br>\n"); 
  }
}
elseif(isset($load) && isset($file))
{
  if(file_exists("modules/" . $load))
  {
    //$file_temp = explode('.',$file);
    //$file = $file_temp[0];
  
    $run = "modules/" . $load . "/" . $file;
    
    if(file_exists($run))
    {
      include $run;     
    }
    else
    {
      ReportError("Cannot load module directory.<br>\n");     
    }
  }
  else
  {
    ReportError("Cannot load module file.<br>\n");
  }
}
else
{
  ReportError("Failure to load module.<br>\n");  
}


?>