diff --git a/inc/config.php b/inc/config.php index ca2bcf90..766d824f 100644 --- a/inc/config.php +++ b/inc/config.php @@ -137,6 +137,7 @@ $config['error']['invalidpost'] = 'That post doesn\'t exist…'; $config['error']['404'] = 'Page not found.'; $config['error']['modexists'] = 'That mod already exists!'; + $config['error']['invalidtheme'] = 'That theme doesn\'t exist!'; // How many reports you can create in the same request. $config['report_limit'] = 2; diff --git a/inc/functions.php b/inc/functions.php index fd00dc9f..b90abe1b 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -96,6 +96,9 @@ function loadThemeConfig($_theme) { global $config; + if(!file_exists($config['dir']['homepage'] . '/' . $_theme . '/theme.php')) + return false; + // Load theme information into $theme include $config['dir']['homepage'] . '/' . $_theme . '/theme.php'; return $theme; diff --git a/mod.php b/mod.php index ef77e6ea..8a27a44d 100644 --- a/mod.php +++ b/mod.php @@ -80,6 +80,7 @@ 'Boards' => '', 'Noticeboard' => '', 'Administration' => '', + 'Themes' => '', 'Search' => '', 'Logout' => '' ); @@ -158,6 +159,10 @@ $fieldset['Administration'] .= '
  • Show configuration
  • '; } + if($mod['type'] >= $config['mod']['themes']) { + $fieldset['Themes'] .= '
  • Manage themes
  • '; + } + if($mod['type'] >= $config['mod']['search']) { $fieldset['Search'] .= '
  • ' . ' ' . @@ -249,6 +254,19 @@ 'mod'=>true ) ); + } elseif(preg_match('/^\/themes\/none$/', $query, $match)) { + if($mod['type'] < $config['mod']['themes']) error($config['error']['noaccess']); + + // Clearsettings + query("TRUNCATE TABLE `theme_settings`") or error(db_error()); + + echo Element('page.html', Array( + 'config'=>$config, + 'title'=>'No theme', + 'body'=>'

    Successfully stopped using any themes. You\'ll have to create a homepage manually if you want one.

    ', + 'mod'=>true + ) + ); } elseif(preg_match('/^\/themes(\/(\w+))?$/', $query, $match)) { if($mod['type'] < $config['mod']['themes']) error($config['error']['noaccess']); @@ -260,7 +278,9 @@ if(isset($match[2])) { $_theme = $match[2]; - $theme = loadThemeConfig($_theme); + if(!$theme = loadThemeConfig($_theme)) { + error($config['error']['invalidtheme']); + } if(isset($_POST['install'])) { // Check if everything is submitted @@ -366,6 +386,9 @@ } $body .= ''; } + + $body .= '

    Don\'t use a theme.

    '; + echo Element('page.html', Array( 'config'=>$config, 'title'=>'Select theme',