Skip to content

Commit

Permalink
Allow pages to be placed in templates folder (second attempt)
Browse files Browse the repository at this point in the history
  • Loading branch information
slawkens committed May 14, 2023
1 parent ba4d2a9 commit 5ccfcd5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions index.php
Expand Up @@ -74,14 +74,26 @@
throw new RuntimeException('Setup detected that <b>install/</b> directory exists. Please visit <a href="' . BASE_URL . 'install">this</a> url to start MyAAC Installation.<br/>Delete <b>install/</b> directory if you already installed MyAAC.<br/>Remember to REFRESH this page when you\'re done!');
}

require_once SYSTEM . 'init.php';
require_once SYSTEM . 'template.php';

// verify myaac tables exists in database
if(!$db->hasTable('myaac_account_actions')) {
throw new RuntimeException('Seems that the table <strong>myaac_account_actions</strong> of MyAAC doesn\'t exist in the database. This is a fatal error. You can try to reinstall MyAAC by visiting <a href="' . BASE_URL . 'install">this</a> url.');
}

$found = false;
if(empty($uri) || isset($_REQUEST['template'])) {
$_REQUEST['p'] = 'news';
$found = true;
}
else {
$tmp = strtolower($uri);
if(!preg_match('/[^A-z0-9_\-]/', $uri) && file_exists(SYSTEM . 'pages/' . $tmp . '.php')) {
if (!preg_match('/[^A-z0-9_\-]/', $uri) && file_exists(TEMPLATES . $template_name . '/pages/' . $tmp . '.php')) {
$_REQUEST['p'] = $uri;
$found = true;
}
else if (!preg_match('/[^A-z0-9_\-]/', $uri) && file_exists(SYSTEM . 'pages/' . $tmp . '.php')) {
$_REQUEST['p'] = $uri;
$found = true;
}
Expand Down Expand Up @@ -133,13 +145,13 @@
'/^houses\/view\/?$/' => array('subtopic' => 'houses', 'page' => 'view')
);

foreach($rules as $rule => $redirect) {
foreach ($rules as $rule => $redirect) {
if (preg_match($rule, $uri)) {
$tmp = explode('/', $uri);
/* @var $redirect array */
foreach($redirect as $key => $value) {
foreach ($redirect as $key => $value) {

if(strpos($value, '$') !== false) {
if (strpos($value, '$') !== false) {
$value = str_replace('$' . $value[1], $tmp[$value[1]], $value);
}

Expand Down Expand Up @@ -180,18 +192,10 @@

$template_place_holders = array();

require_once SYSTEM . 'init.php';

// verify myaac tables exists in database
if(!$db->hasTable('myaac_account_actions')) {
throw new RuntimeException('Seems that the table <strong>myaac_account_actions</strong> of MyAAC doesn\'t exist in the database. This is a fatal error. You can try to reinstall MyAAC by visiting <a href="' . BASE_URL . 'install">this</a> url.');
}

// event system
require_once SYSTEM . 'hooks.php';
$hooks = new Hooks();
$hooks->load();
require_once SYSTEM . 'template.php';
require_once SYSTEM . 'login.php';
require_once SYSTEM . 'status.php';

Expand Down
File renamed without changes.

0 comments on commit 5ccfcd5

Please sign in to comment.