From 5ccfcd541e3779550afc9ef3807777f49cf28754 Mon Sep 17 00:00:00 2001 From: slawkens Date: Sun, 14 May 2023 08:59:34 +0200 Subject: [PATCH] Allow pages to be placed in templates folder (second attempt) --- index.php | 28 +++++++++++-------- .../kathrine/{images => }/pages/test.php | 0 2 files changed, 16 insertions(+), 12 deletions(-) rename templates/kathrine/{images => }/pages/test.php (100%) diff --git a/index.php b/index.php index 6517e3fb..48baf85a 100644 --- a/index.php +++ b/index.php @@ -74,6 +74,14 @@ if((!isset($config['installed']) || !$config['installed']) && file_exists(BASE . throw new RuntimeException('Setup detected that install/ directory exists. Please visit this url to start MyAAC Installation.
Delete install/ directory if you already installed MyAAC.
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 myaac_account_actions of MyAAC doesn\'t exist in the database. This is a fatal error. You can try to reinstall MyAAC by visiting this url.'); +} + $found = false; if(empty($uri) || isset($_REQUEST['template'])) { $_REQUEST['p'] = 'news'; @@ -81,7 +89,11 @@ if(empty($uri) || isset($_REQUEST['template'])) { } 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; } @@ -133,13 +145,13 @@ else { '/^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); } @@ -180,18 +192,10 @@ define('PAGE', $page); $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 myaac_account_actions of MyAAC doesn\'t exist in the database. This is a fatal error. You can try to reinstall MyAAC by visiting this 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'; diff --git a/templates/kathrine/images/pages/test.php b/templates/kathrine/pages/test.php similarity index 100% rename from templates/kathrine/images/pages/test.php rename to templates/kathrine/pages/test.php