From 92310f445ca443bb6c83a372ba59761b15361c3b Mon Sep 17 00:00:00 2001
From: Savetheinternet
Date: Sat, 26 Mar 2011 18:23:15 +1100
Subject: [PATCH] Allow custom URLs for stylesheet/javascript/banner
---
inc/config.php | 5 +++++
inc/display.php | 4 ++--
inc/functions.php | 15 ++++++++-------
mod.php | 30 +++++++++++++++---------------
templates/index.html | 10 ++++++----
templates/page.html | 2 +-
templates/thread.html | 9 +++++----
7 files changed, 42 insertions(+), 33 deletions(-)
diff --git a/inc/config.php b/inc/config.php
index 640999ac..38468f57 100644
--- a/inc/config.php
+++ b/inc/config.php
@@ -419,4 +419,9 @@
// 'status' => 'http://status.example.org/'
//);
+ // Set custom locations for stylesheets, scripts and maybe a banner.
+ // This can be good for load balancing across multiple servers or hostnames.
+ // $config['url_stylesheet'] = 'http://static.example.org/style.css';
+ // $config['url_javascript'] = 'http://static.example.org/script.js';
+ // $config['url_banner'] = '/banner.php';
?>
\ No newline at end of file
diff --git a/inc/display.php b/inc/display.php
index c6570002..966ddab6 100644
--- a/inc/display.php
+++ b/inc/display.php
@@ -61,7 +61,7 @@
if(function_exists('sql_close')) sql_close();
die(Element('page.html', Array(
- 'index'=>$config['root'],
+ 'config'=>$config,
'title'=>'Error',
'subtitle'=>'An error has occured.',
'body'=>"" .
@@ -82,7 +82,7 @@
'index'=>$config['root'],
'title'=>'Login',
'body'=>Element('login.html', Array(
- 'index'=>$config['root'],
+ 'config'=>$config,
'error'=>$error,
'username'=>$username,
'redirect'=>$redirect
diff --git a/inc/functions.php b/inc/functions.php
index daa2d6d8..d930712f 100644
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -12,6 +12,11 @@
require $board['dir'] . '/config.php';
}
+ if(!isset($config['url_stylesheet']))
+ $config['url_stylesheet'] = $config['root'] . 'style.css';
+ if(!isset($config['url_javascript']))
+ $config['url_javascript'] = $config['root'] . 'script.js';
+
if(!isset($config['post_url']))
$config['post_url'] = $config['root'] . $config['file_post'];
@@ -56,7 +61,6 @@
else
$config['uri_img'] = sprintf($config['uri_img'], $board['dir']);
-
if($config['root_file']) {
chdir($config['root_file']);
}
@@ -256,7 +260,7 @@
// Show banned page and exit
die(Element('page.html', Array(
- 'index' => $config['root'],
+ 'config' => $config,
'title' => 'Banned',
'subtitle' => 'You are banned!',
'body' => $body
@@ -503,11 +507,10 @@
}
return Array(
- 'button'=>$config['button_newtopic'],
'board'=>$board,
'body'=>$body,
'post_url' => $config['post_url'],
- 'index' => $config['root'],
+ 'config' => $config,
'boardlist' => createBoardlist($mod)
);
}
@@ -1008,11 +1011,9 @@
if(!isset($thread)) error($config['error']['nonexistant']);
$body = Element('thread.html', Array(
- 'button'=>$config['button_reply'],
'board'=>$board,
'body'=>$thread->build(),
- 'post_url' => $config['post_url'],
- 'index' => $config['root'],
+ 'config' => $config,
'id' => $id,
'mod' => $mod,
'boardlist' => createBoardlist($mod),
diff --git a/mod.php b/mod.php
index ad3ee85d..37a86c4a 100644
--- a/mod.php
+++ b/mod.php
@@ -109,7 +109,7 @@
}
echo Element('page.html', Array(
- 'index'=>$config['root'],
+ 'config'=>$config,
'title'=>'Dashboard',
'body'=>$body
//,'mod'=>true /* All 'mod' does, at this point, is put the "Return to dashboard" link in. */
@@ -140,7 +140,7 @@
$body .= '';
echo Element('page.html', Array(
- 'index'=>$config['root'],
+ 'config'=>$config,
'title'=>'Moderation log',
'body'=>$body,
'mod'=>true
@@ -187,7 +187,7 @@
'';
echo Element('page.html', Array(
- 'index'=>$config['root'],
+ 'config'=>$config,
'title'=>'Private message',
'body'=>$body,
'mod'=>true
@@ -225,7 +225,7 @@
$query->execute() or error(db_error($query));
echo Element('page.html', Array(
- 'index'=>$config['root'],
+ 'config'=>$config,
'title'=>'PM sent',
'body'=>'Message sent successfully to ' . htmlentities($to['username']) . '.
',
'mod'=>true
@@ -252,7 +252,7 @@
'';
echo Element('page.html', Array(
- 'index'=>$config['root'],
+ 'config'=>$config,
'title'=>'New PM for ' . htmlentities($to['username']),
'body'=>$body
,'mod'=>true
@@ -314,7 +314,7 @@
$body .= '';
echo Element('page.html', Array(
- 'index'=>$config['root'],
+ 'config'=>$config,
'title'=>'Manage users',
'body'=>$body
,'mod'=>true
@@ -372,7 +372,7 @@
'';
echo Element('page.html', Array(
- 'index'=>$config['root'],
+ 'config'=>$config,
'title'=>'New user',
'body'=>$body
,'mod'=>true
@@ -461,7 +461,7 @@
'';
echo Element('page.html', Array(
- 'index'=>$config['root'],
+ 'config'=>$config,
'title'=>'Edit user',
'body'=>$body
,'mod'=>true
@@ -522,7 +522,7 @@
($reports == $count['count'] ? 'all ' . $reports . ' reports' : $reports . ' of ' . $count['count'] . ' reports') . '.
';
echo Element('page.html', Array(
- 'index'=>$config['root'],
+ 'config'=>$config,
'title'=>'Report queue',
'body'=>$body,
'mod'=>true
@@ -637,7 +637,7 @@
'';
echo Element('page.html', Array(
- 'index'=>$config['root'],
+ 'config'=>$config,
'title'=>'Manage – ' . sprintf($config['board_abbreviation'], $board['uri']),
'body'=>$body,
'mod'=>true
@@ -721,7 +721,7 @@
}
echo Element('page.html', Array(
- 'index'=>$config['root'],
+ 'config'=>$config,
'title'=>'Ban list',
'body'=>$body,
'mod'=>true
@@ -792,7 +792,7 @@
$body = '';
echo Element('page.html', Array(
- 'index'=>$config['root'],
+ 'config'=>$config,
'title'=>'Configuration',
'body'=>$body,
'mod'=>true
@@ -873,7 +873,7 @@
// TODO: Statistics, etc, in the dashboard.
echo Element('page.html', Array(
- 'index'=>$config['root'],
+ 'config'=>$config,
'title'=>'New board',
'body'=>$body,
'mod'=>true
@@ -1186,7 +1186,7 @@
$body = form_newBan($post['ip'], null, isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : false, $delete ? $post['id'] : false, $delete ? $boardName : false);
echo Element('page.html', Array(
- 'index'=>$config['root'],
+ 'config'=>$config,
'title'=>'New ban',
'body'=>$body,
'mod'=>true
@@ -1295,7 +1295,7 @@
$body .= form_newBan($ip, null, isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : false);
echo Element('page.html', Array(
- 'index'=>$config['root'],
+ 'config'=>$config,
'title'=>'IP: ' . $ip,
'subtitle' => $host,
'body'=>$body,
diff --git a/templates/index.html b/templates/index.html
index b14e2e4e..30cb3259 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -1,20 +1,22 @@
-
+
{board[url]} - {board[name]}
-
+
+ {config[meta_keywords]?}
{boardlist[top]}
{pm?{pm}
}
+ {config[url_banner]?}
{board[url]} - {board[name]}
-