Added some stuff.
git-svn-id: http://svn.cleancode.org/svn/pickles@17 4d10bc64-7434-11dc-a737-d2d0f8310089
This commit is contained in:
parent
6c31a4b587
commit
68efc9e5e9
4 changed files with 53 additions and 24 deletions
|
@ -5,21 +5,24 @@ class Controller {
|
|||
public function __construct() {
|
||||
global $smarty;
|
||||
|
||||
$sections = Config::get('sections');
|
||||
|
||||
if (
|
||||
isset($_REQUEST['section']) && in_array($_REQUEST['section'], array_keys($sections))
|
||||
|| file_exists('../logic/' . $_REQUEST['section'] . ($_REQUEST['action'] ? '.' . $_REQUEST['action'] : null) . '.php')
|
||||
) {
|
||||
$section = $_REQUEST['section'];
|
||||
define('PATH', '../logic/');
|
||||
|
||||
if (isset($_REQUEST['action'])) {
|
||||
$action = $_REQUEST['action'];
|
||||
$section = $action = null;
|
||||
|
||||
if (isset($_REQUEST['section'])) {
|
||||
// Check for section.action.php
|
||||
if (isset($_REQUEST['action']) && file_exists(PATH . $_REQUEST['section'] . '.' . $_REQUEST['action'] . '.php')) {
|
||||
$section = $_REQUEST['section'];
|
||||
$action = $_REQUEST['action'];
|
||||
}
|
||||
// else check for section.php
|
||||
else if (file_exists(PATH . $_REQUEST['section'] . '.php')) {
|
||||
$section = $_REQUEST['section'];
|
||||
}
|
||||
// else use the default section
|
||||
else {
|
||||
$section = Config::get('default');
|
||||
}
|
||||
}
|
||||
else {
|
||||
$section = Config::get('default');
|
||||
$action = '';
|
||||
}
|
||||
|
||||
$file = '../logic/' . $section . ($action ? '.' . $action : null) . '.php';
|
||||
|
@ -30,6 +33,8 @@ class Controller {
|
|||
}
|
||||
|
||||
/*
|
||||
@todo not sure I need this at all anymore...
|
||||
|
||||
if (!file_exists('../templates/' . $template)) {
|
||||
$section = Config::get('default');
|
||||
$action = '';
|
||||
|
@ -47,10 +52,10 @@ class Controller {
|
|||
}
|
||||
*/
|
||||
|
||||
$smarty->assign('sections', $sections);
|
||||
$smarty->assign('section', $section);
|
||||
$smarty->assign('action', $action);
|
||||
$smarty->assign('template', $template);
|
||||
$smarty->assign('navigation', Config::get('navigation'));
|
||||
$smarty->assign('section', $section);
|
||||
$smarty->assign('action', $action);
|
||||
$smarty->assign('template', $template);
|
||||
|
||||
header('Content-type: text/html; charset=UTF-8');
|
||||
$smarty->display('index.tpl');
|
||||
|
|
23
config/joshtronic.com.xml
Executable file
23
config/joshtronic.com.xml
Executable file
|
@ -0,0 +1,23 @@
|
|||
<config>
|
||||
<debug></debug>
|
||||
<disable></disable>
|
||||
<fckeditor></fckeditor>
|
||||
<session></session>
|
||||
<smarty>true</smarty>
|
||||
<magpierss></magpierss>
|
||||
<database>
|
||||
<hostname>localhost</hostname>
|
||||
<username>joshtronic</username>
|
||||
<password>j05h7r0n1c</password>
|
||||
<database>joshtronic</database>
|
||||
</database>
|
||||
<default>about</default>
|
||||
<sections>
|
||||
<about>About</about>
|
||||
<family>Family</family>
|
||||
<music>Music</music>
|
||||
<code>Code</code>
|
||||
</sections>
|
||||
<admin>
|
||||
</admin>
|
||||
</config>
|
|
@ -12,14 +12,14 @@
|
|||
<database>verynicenoise</database>
|
||||
</database>
|
||||
<default>home</default>
|
||||
<sections>
|
||||
<navigation>
|
||||
<home>Home</home>
|
||||
<about>About</about>
|
||||
<releases>Releases</releases>
|
||||
<artists>Artists</artists>
|
||||
<shop>Shop</shop>
|
||||
<contact>Contact</contact>
|
||||
</sections>
|
||||
</navigation>
|
||||
<admin>
|
||||
<news>News</news>
|
||||
<releases>Releases</releases>
|
||||
|
|
11
jLib.php
11
jLib.php
|
@ -9,17 +9,18 @@ function __autoload($class) {
|
|||
// Obliterates any passed in PHPSESSID (thanks Google)
|
||||
if (stripos($_SERVER['REQUEST_URI'], '?PHPSESSID=') !== false) {
|
||||
list($request_uri, $phpsessid) = split('\?PHPSESSID=', $_SERVER['REQUEST_URI'], 2);
|
||||
header("HTTP/1.1 301 Moved Permanently");
|
||||
header("Location: {$request_uri}");
|
||||
header('HTTP/1.1 301 Moved Permanently');
|
||||
header('Location: ' . $request_uri);
|
||||
exit();
|
||||
}
|
||||
|
||||
// XHTML compliancy stuff
|
||||
ini_set('arg_separator.output', '&');
|
||||
ini_set('url_rewriter.tags', 'a=href,area=href,frame=src,input=src,fieldset=');
|
||||
ini_set('url_rewriter.tags', 'a=href,area=href,frame=src,input=src,fieldset=');
|
||||
|
||||
// Strips the subdomain before loading the configuration file
|
||||
$config_array = split('\.', $_SERVER['SERVER_NAME']);
|
||||
$config_array = split('\.', $_SERVER['SERVER_NAME']);
|
||||
$subless_server = null;
|
||||
if (count($config_array) == 3) {
|
||||
$subless_server = $config_array[1] . '.' . $config_array[2];
|
||||
}
|
||||
|
@ -27,7 +28,7 @@ if (count($config_array) == 3) {
|
|||
// Do some prep work if we're working locally
|
||||
if (strpos($_SERVER['SERVER_NAME'], '.localhost')) {
|
||||
foreach (array('com', 'net', 'org') as $tld) {
|
||||
$config = str_replace('.localhost', '.' . $tld, $config);
|
||||
$config = str_replace('.localhost', '.' . $tld, $_SERVER['SERVER_NAME']);
|
||||
|
||||
if (Config::check($config)) {
|
||||
$_SERVER['SERVER_NAME'] = $config;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue