diff --git a/.htaccess b/.htaccess
index 87b9cf81..7238b8dc 100644
--- a/.htaccess
+++ b/.htaccess
@@ -2,7 +2,7 @@
RewriteEngine On
# Installation directory
-RewriteBase /kohana/
+RewriteBase /osb/
# Protect hidden files from being viewed
@@ -11,11 +11,11 @@ RewriteBase /kohana/
# Protect application and system files from being viewed
-RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]
+RewriteRule ^(?:application|modules|includes/kohana)\b.* kh.php/$0 [L]
# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
-# Rewrite all other URLs to index.php/URL
-RewriteRule .* index.php/$0 [PT]
+# Rewrite all other URLs to kh.php/URL
+RewriteRule .* kh.php/$0 [PT]
diff --git a/application/bootstrap.php b/application/bootstrap.php
index f87c7454..d0af2600 100644
--- a/application/bootstrap.php
+++ b/application/bootstrap.php
@@ -8,7 +8,7 @@
* @see http://kohanaframework.org/guide/using.configuration
* @see http://php.net/timezones
*/
-date_default_timezone_set('America/Chicago');
+date_default_timezone_set('Australia/Melbourne');
/**
* Set the default locale.
@@ -50,7 +50,8 @@ ini_set('unserialize_callback_func', 'spl_autoload_call');
* - boolean caching enable or disable internal caching FALSE
*/
Kohana::init(array(
- 'base_url' => '/',
+ 'base_url' => '/osb',
+ 'index_file' => '',
));
/**
@@ -67,16 +68,32 @@ Kohana::$config->attach(new Kohana_Config_File);
* Enable modules. Modules are referenced by a relative or absolute path.
*/
Kohana::modules(array(
- // 'auth' => SMDPATH.'auth', // Basic authentication
- // 'cache' => SMDPATH.'cache', // Caching with multiple backends
+ 'auth' => SMDPATH.'auth', // Basic authentication
+ 'cache' => SMDPATH.'cache', // Caching with multiple backends
// 'codebench' => SMDPATH.'codebench', // Benchmarking tool
- // 'database' => SMDPATH.'database', // Database access
+ 'database' => SMDPATH.'database', // Database access
// 'image' => SMDPATH.'image', // Image manipulation
- // 'orm' => SMDPATH.'orm', // Object Relationship Mapping
+ 'orm' => SMDPATH.'orm', // Object Relationship Mapping
// 'oauth' => SMDPATH.'oauth', // OAuth authentication
// 'pagination' => SMDPATH.'pagination', // Paging of results
// 'unittest' => SMDPATH.'unittest', // Unit testing
// 'userguide' => SMDPATH.'userguide', // User guide and API documentation
+ 'xml' => SMDPATH.'xml', // XML module for Kohana 3 PHP Framework
+ 'email' => SMDPATH.'email', // Email module for Kohana 3 PHP Framework
+ 'gchart' => MODPATH.'gchart', // Google Chart Module
+ ));
+
+/**
+ * Load our modules defined in the DB
+ */
+Kohana::modules(array_merge(Kohana::modules(),Config::appmodules()));
+
+/**
+ * Enable admin, user (account), reseller and affiliate interfaces
+ */
+Route::set('sections', '/(/(/(/)))',
+ array(
+ 'directory' => '('.implode('|',Kohana::config('config.method_directory')).')' //(account|admin|affiliate|reseller|task)'
));
/**
@@ -89,6 +106,20 @@ Route::set('default', '((/(/)))')
'action' => 'index',
));
+// Static file serving (CSS, JS, images)
+Route::set('default/media', 'media(/)', array('file' => '.+'))
+ ->defaults(array(
+ 'controller' => 'welcome',
+ 'action' => 'media',
+ 'file' => NULL,
+ ));
+
+// Make sure their PHP version is current enough
+if (strcmp(phpversion(),'5.3') < 0) {
+ echo 'This application requires PHP 5.3 or newer to run';
+ die();
+}
+
if ( ! defined('SUPPRESS_REQUEST'))
{
/**
diff --git a/application/cache/.htaccess b/application/cache/.htaccess
new file mode 100644
index 00000000..281d5c33
--- /dev/null
+++ b/application/cache/.htaccess
@@ -0,0 +1,2 @@
+order allow,deny
+deny from all
diff --git a/application/classes/block.php b/application/classes/block.php
new file mode 100644
index 00000000..0b6b536a
--- /dev/null
+++ b/application/classes/block.php
@@ -0,0 +1,4 @@
+
diff --git a/application/classes/breadcrumb.php b/application/classes/breadcrumb.php
new file mode 100644
index 00000000..61fc6976
--- /dev/null
+++ b/application/classes/breadcrumb.php
@@ -0,0 +1,4 @@
+
diff --git a/application/classes/company.php b/application/classes/company.php
new file mode 100644
index 00000000..fd19965e
--- /dev/null
+++ b/application/classes/company.php
@@ -0,0 +1,50 @@
+') {
+ // @todo Company address should be calculated
+ return implode($ln,array('PO Box 149','Bendigo, VIC 3550'));
+ }
+
+ public static function contacts() {
+ // @todo Company phone should be calculated
+ return 'Tel: 03 5410 1135';
+ }
+
+ public static function render() {
+ echo static::name();
+ echo static::address();
+ echo static::contacts();
+ }
+
+ /**
+ * Return the HTML to render the company address
+ */
+ public function __toString() {
+ try {
+ return static::render();
+ }
+
+ // Display the exception message
+ catch (Exception $e) {
+ Kohana::exception_handler($e);
+
+ return '';
+ }
+ }
+}
+?>
diff --git a/application/classes/config.php b/application/classes/config.php
new file mode 100644
index 00000000..fd71789f
--- /dev/null
+++ b/application/classes/config.php
@@ -0,0 +1,4 @@
+
diff --git a/application/classes/controller/default.php b/application/classes/controller/default.php
new file mode 100644
index 00000000..478f8eeb
--- /dev/null
+++ b/application/classes/controller/default.php
@@ -0,0 +1,4 @@
+
diff --git a/application/classes/controller/lnapp/default.php b/application/classes/controller/lnapp/default.php
new file mode 100644
index 00000000..fe5d1d91
--- /dev/null
+++ b/application/classes/controller/lnapp/default.php
@@ -0,0 +1,75 @@
+ 'admin' will only allow users with the role admin to access action_adminpanel
+ * 'moderatorpanel' => array('login', 'moderator') will only allow users with the roles login and moderator to access action_moderatorpanel
+ *
+ * @var array actions that require a valid user
+ */
+ protected $secure_actions = array();
+
+ /**
+ * Check and see if this controller needs authentication
+ *
+ * if $this->auth_required is TRUE, then the user must be logged in only.
+ * if $this->auth_required is FALSE, AND $this->secure_actions has an array of
+ * methods set to TRUE, then the user must be logged in AND a member of the
+ * role.
+ *
+ * @return boolean
+ */
+ protected function _auth_required() {
+ // If our global configurable is disabled, then continue
+ if (! Kohana::Config('config.method_security'))
+ return FALSE;
+
+ return (($this->auth_required !== FALSE && Auth::instance()->logged_in() === FALSE) ||
+ (is_array($this->secure_actions) && array_key_exists($this->request->action,$this->secure_actions) &&
+ Auth::instance()->logged_in($this->secure_actions[$this->request->action]) === FALSE));
+ }
+
+ public function before() {
+ parent::before();
+
+ // Check user auth and role
+ if ($this->_auth_required()) {
+ // For AJAX/JSON requests, authorisation is controlled in the method.
+ if (Request::$is_ajax && $this->request->action === 'json') {
+ // Nothing required.
+
+ // For no AJAX/JSON requests, display an access page
+ } elseif (Auth::instance()->logged_in(NULL,get_class($this).'|'.__METHOD__)) {
+ Request::instance()->redirect('login/noaccess');
+
+ } else {
+ Session::instance()->set('afterlogin',Request::instance()->uri());
+ Request::instance()->redirect($this->noauth_redirect);
+ }
+ }
+ }
+}
+?>
diff --git a/application/classes/controller/lnapp/logout.php b/application/classes/controller/lnapp/logout.php
new file mode 100644
index 00000000..7e964ed4
--- /dev/null
+++ b/application/classes/controller/lnapp/logout.php
@@ -0,0 +1,26 @@
+logged_in()!= 0) {
+ Auth::instance()->logout();
+
+ Request::instance()->redirect('login');
+ }
+
+ Request::instance()->redirect('welcome/index');
+ }
+}
+?>
diff --git a/application/classes/controller/lnapp/templatedefault.php b/application/classes/controller/lnapp/templatedefault.php
new file mode 100644
index 00000000..343804f3
--- /dev/null
+++ b/application/classes/controller/lnapp/templatedefault.php
@@ -0,0 +1,279 @@
+ 'admin' will only allow users with the role admin to access action_adminpanel
+ * 'moderatorpanel' => array('login', 'moderator') will only allow users with the roles login and moderator to access action_moderatorpanel
+ *
+ * @var array actions that require a valid user
+ */
+ protected $secure_actions = array(
+ 'menu' => TRUE,
+ );
+
+ /**
+ * Check and see if this controller needs authentication
+ *
+ * if $this->auth_required is TRUE, then the user must be logged in only.
+ * if $this->auth_required is FALSE, AND $this->secure_actions has an array of
+ * methods set to TRUE, then the user must be logged in AND a member of the
+ * role.
+ *
+ * @return boolean
+ */
+ protected function _auth_required() {
+ // If our global configurable is disabled, then continue
+ if (! Kohana::Config('config.method_security'))
+ return FALSE;
+
+ return (($this->auth_required !== FALSE && Auth::instance()->logged_in() === FALSE) ||
+ (is_array($this->secure_actions) && array_key_exists($this->request->action,$this->secure_actions) &&
+ Auth::instance()->logged_in($this->secure_actions[$this->request->action]) === FALSE));
+ }
+
+ /**
+ * Loads the template [View] object.
+ *
+ * Page information is provided by [meta].
+ * @uses meta
+ */
+ public function before() {
+ // Do not template media files
+ if ($this->request->action === 'media') {
+ $this->auto_render = FALSE;
+ return;
+ }
+
+ parent::before();
+
+ // Check user auth and role
+ if ($this->_auth_required()) {
+ if (Kohana::$is_cli)
+ throw new Kohana_Exception('Cant run :method, authentication not possible',array(':method'=>$this->request->action));
+
+ // If auth is required and the user is logged in, then they dont have access.
+ // (We have already checked authorisation.)
+ if (Auth::instance()->logged_in(NULL,get_class($this).'|'.__METHOD__)) {
+ if (Config::sitemode() == Kohana::DEVELOPMENT)
+ SystemMessage::add(array(
+ 'title'=>_('Insufficient Access'),
+ 'type'=>'debug',
+ 'body'=>Kohana::debug(array('required'=>$this->auth_required,'action'=>$this->request->action,'user'=>Auth::instance()->get_user()->username)),
+ ));
+
+ // @todo Login No Access redirects are not handled in JS?
+ if (Request::$is_ajax) {
+ echo _('You dont have enough permissions.');
+ die();
+ } else
+ Request::instance()->redirect('login/noaccess');
+
+ } else {
+ Session::instance()->set('afterlogin',Request::instance()->uri());
+ Request::instance()->redirect($this->noauth_redirect);
+ }
+ }
+
+ // For AJAX calls, we dont need to render the complete page.
+ if (Request::$is_ajax) {
+ $this->auto_render = FALSE;
+ return;
+ }
+
+ // Bind our template meta variable
+ $this->meta = new meta;
+ View::bind_global('meta',$this->meta);
+
+ // Our default style sheet
+ Style::add(array(
+ 'type'=>'file',
+ 'data'=>'css/default.css',
+ ));
+
+ // Our default scripts
+ // This is in a reverse list, since we push them to the beginging of the scripts to render.
+ foreach (array('file'=>array(
+ 'js/jquery.cookie.js',
+ 'js/jquery.jstree-1.0rc.js',
+ 'js/jquery-1.4.2.js',
+ )) as $type => $datas) {
+
+ foreach ($datas as $data) {
+ Script::add(array(
+ 'type'=>$type,
+ 'data'=>$data,
+ ),TRUE);
+ }
+ }
+
+ // Initialise our content
+ $this->template->left = '';
+ $this->template->content = '';
+ $this->template->right = '';
+ }
+
+ public function after() {
+ if ($this->auto_render) {
+ // Application Title
+ $this->meta->title = 'Application Title';
+ $this->template->title = '';
+
+ // Style Sheets Properties
+ $this->meta->styles = Style::factory();
+
+ // Script Properties
+ $this->meta->scripts = Script::factory();
+
+ // Application logo
+ $this->template->logo = Config::logo();
+
+ // Link images on the header line
+ $this->template->headimages = $this->_headimages();
+
+ // Control Line
+ $this->template->control = $this->_control();
+
+ // System Messages line
+ $this->template->sysmsg = $this->_sysmsg();
+
+ // Left Item
+ $this->template->left = $this->_left();
+
+ // Right Item
+ $this->template->right = $this->_right();
+
+ // Footer
+ $this->template->footer = $this->_footer();
+
+ // For any ajax rendered actions, we'll need to capture the content and put it in the response
+ } elseif (Request::$is_ajax && isset($this->template->content) && ! $this->request->response) {
+ // @todo move this formatting to a view?
+ if ($s = $this->_sysmsg() AND (string)$s) {
+ $this->request->response = sprintf('
%s
',$s);
+ } else
+ $this->request->response = '';
+
+ # In case there any style sheets or scrpits for this render.
+ $this->request->response .= Style::factory();
+
+ # Get the response body
+ $this->request->response .= sprintf('