|
28 | 28 | array_unshift($params, ""); |
29 | 29 | } |
30 | 30 |
|
| 31 | +// push url parameters to the registry file |
| 32 | +$registry->set("params", $params); |
| 33 | + |
31 | 34 | // if you have a user system you rely on you can deny access to all/specific controllers here. |
32 | 35 |
|
33 | 36 | // // check if user has credentials |
|
40 | 43 | // if($user !== true) { ...... |
41 | 44 |
|
42 | 45 | // now we need to include the controller based on the url's first parameter (welcome) |
43 | | -if(in_array($params[1].".controller.php", $controllers)) |
| 46 | +if(is_array($controllers) && in_array($params[1].".controller.php", $controllers)) |
44 | 47 | { |
45 | | - REQUIRE_ONCE 'controllers/'.$params[1].".controller.php"; |
46 | | - |
47 | | - // default classes to pass to the controller |
48 | | - $load = array( |
49 | | - "sec" => $Sec, // security |
50 | | - "db" => $DB, // database |
51 | | - "params" => $params, // url parameters |
52 | | - ); |
53 | | - |
54 | | - // additional classes to pass to the controller only if they are enabled in /app/config.php |
55 | | - if($_CONFIG['language']['enabled'] == true) |
56 | | - $load['language'] = $Language; |
57 | | - if($_CONFIG['upload']['enabled'] === true) |
58 | | - $load['upload'] = $Upload; |
59 | | - if($_CONFIG['api'] == 'enabled') |
60 | | - $load['api'] = $API; |
61 | | - |
62 | | - // then run the controller and initiate action_index |
63 | | - $name = "controller_".$params[1]; |
64 | | - $$name = new $name($load); |
65 | | - $$name->action_index(); |
| 48 | + require_once 'app/controllers/'.$params[1].".controller.php"; |
| 49 | + $new = 'controller_'.$params[1]; |
| 50 | + $registry->set($params[1], new $new); |
| 51 | + $registry->get($params[1])->action_index(); |
66 | 52 | } |
67 | 53 |
|
68 | 54 | else // 404 - controller not found - redirect to home page |
|
0 commit comments