Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit b184d04821ff3b171e55830c31c92860b4ea4b59 @jjNford committed Nov 13, 2011
1 .gitignore
@@ -0,0 +1 @@
+.DS_Store
1 README
@@ -0,0 +1 @@
+Please visit phpblueprint.com
23 application/config/application.php
@@ -0,0 +1,23 @@
+<?php if(!defined('RUN')){exit();}
+
+##################################################
+## ##
+## ERROR REPORTING CONFIGURATION ##
+## ##
+##################################################
+#
+# Don't forget to change the permissions on your log folder.
+#
+$config['error_reporting']['development_environment'] = true;
+$config['error_reporting']['log_errors'] = true;
+$config['error_reporting']['error_log'] = 'application/logs/errors.log';
+
+##################################################
+## ##
+## ROUTING CONFIGURATION ##
+## ##
+##################################################
+#
+$config['routing']['default_controller'] = 'welcome';
+$config['routing']['controller_segment'] = 1;
+$config['routing']['method_segment'] = 2;
13 application/config/database.php
@@ -0,0 +1,13 @@
+<?php if(!defined('RUN')){exit();}
+
+##################################################
+## ##
+## DATABASE CONFIGURATION ##
+## ##
+##################################################
+#
+$config['database']['driver'] = 'mysql';
+$config['database']['host'] = 'localhost';
+$config['database']['db_name'] = '';
+$config['database']['user_name'] = '';
+$config['database']['password'] = '';
14 application/controllers/Welcome.php
@@ -0,0 +1,14 @@
+<?php if(!defined('RUN')){exit();}
+
+class Welcome_Controller extends Controller {
+
+ public function __construct() {
+ parent::__construct();
+
+ // This is the default controller defined in the 'application' config file.
+
+ // Load the welcome page.
+ $data = array('page_title' => 'Welcome to PHP Blueprint');
+ $this->load->view('welcome', $data);
+ }
+}
35 application/core/Configuration.php
@@ -0,0 +1,35 @@
+<?php if(!defined('RUN')){exit();}
+
+##################################################
+## ##
+## CONFIGURATION ##
+## ##
+##################################################
+#
+class Configuration {
+
+ ##############################################
+ #
+ # Constructor
+ #
+ # 10.15.2011 - JJ Ford - Initial build.
+ #
+ public function __construct()
+ {
+ // Load all config files.
+ $config_files = scandir(APPLICATION.DS.CONFIG);
+
+ foreach ($config_files as $config_file) {
+ if ($config_file === '.' || $config_file === '..') {continue;}
+ include(APPLICATION.DS.CONFIG.DS.$config_file);
+ }
+
+ // Turn config array into objects.
+ $config_object = make_object($config);
+
+ // Turn config into Configuration member data.
+ foreach ($config_object as $member => $value) {
+ $this->$member = $value;
+ }
+ }
+}
28 application/core/Controller.php
@@ -0,0 +1,28 @@
+<?php if(!defined('RUN')){exit();}
+
+##################################################
+## ##
+## CONTROLLER ##
+## ##
+##################################################
+#
+# Parent controller for application controllers.
+#
+class Controller {
+
+ protected $config;
+ protected $load;
+
+ ##############################################
+ #
+ # Constructor
+ #
+ # 10.15.2011 - JJ Ford - Initial build.
+ #
+ public function __construct()
+ {
+ // Load the controllers Configuration and Loader objects.
+ $this->config =& load_class('Configuration', CORE);
+ $this->load =& load_class('Loader', CORE);
+ }
+}
115 application/core/Loader.php
@@ -0,0 +1,115 @@
+<?php if(!defined('RUN')){exit();}
+
+##################################################
+## ##
+## LOADER ##
+## ##
+##################################################
+#
+class Loader {
+
+ ##############################################
+ #
+ # Constructor
+ #
+ # 10.15.2011 - JJ Ford - Initial build.
+ #
+ public function __construct() {}
+
+
+
+ ##############################################
+ #
+ # controller
+ #
+ # Load application controller.
+ #
+ # param - Name of controller.
+ # return - Return controller if found.
+ #
+ # 10.15.2011 - JJ Ford - Initial build.
+ #
+ public function controller($name)
+ {
+ $name = ucfirst(strtolower($name));
+
+ if (file_exists(APPLICATION.DS.CONTROLLER.DS.$name.PHP)) {
+ require_once(APPLICATION.DS.CONTROLLER.DS.$name.PHP);
+ $name = $name.'_Controller';
+ return new $name();
+ }
+
+ // No bueno if we made it here...
+ echo "Unable to load the following controller: " . $name;
+ die();
+ }
+
+
+
+ ##############################################
+ #
+ # library
+ #
+ # Load application library.
+ #
+ # param - Name of library.
+ # return - Return library if found.
+ #
+ # 10.15.2011 - JJ Ford - Initial build.
+ #
+ public function library($name)
+ {
+ return load_class($name, LIBRARY);
+ }
+
+
+
+ ##############################################
+ #
+ # model
+ #
+ # Load application model.
+ #
+ # param - Name of model.
+ # return - Return model if found.
+ #
+ # 10.15.2011 - JJ Ford - Initial build.
+ #
+ public function model($name)
+ {
+ load_class('Model', CORE);
+ $name = ucfirst(strtolower($name));
+
+ if (file_exists(APPLICATION.DS.MODEL.DS.$name.PHP)) {
+ require_once(APPLICATION.DS.MODEL.DS.$name.PHP);
+ $name = $name.'_Model';
+ return new $name();
+ }
+
+ // No bueno if we made it here...
+ echo "Unable to load the following model: " . $name;
+ die();
+ }
+
+
+
+ ##############################################
+ #
+ # view
+ #
+ # Load application view.
+ #
+ # param - Name of view.
+ # param - Associative array of data.
+ #
+ # 10.15.2011 - JJ Ford - Initial build.
+ #
+ public function view($name, $data = null)
+ {
+ if($data) {extract($data);}
+
+ if (file_exists(APPLICATION.DS.VIEW.DS.$name.PHP)) {
+ include(APPLICATION.DS.VIEW.DS.$name.PHP);
+ }
+ }
+}
43 application/core/Logging.php
@@ -0,0 +1,43 @@
+<?php if(!defined('RUN')){exit();}
+
+##################################################
+## ##
+## LOGGING ##
+## ##
+##################################################
+#
+class Logging {
+
+ private $config;
+
+ ##############################################
+ #
+ # Constructor
+ #
+ # 10.15.2011 - JJ Ford - Initial build.
+ #
+ public function __construct()
+ {
+ // Load Configuration.
+ $this->config =& load_class('Configuration', CORE);
+
+ // Set logging.
+ $this->set_php_error_reporting();
+ }
+
+
+
+ ##############################################
+ #
+ # set_php_error_reporting
+ #
+ # 10.15.2011 - JJ Ford - Initial build.
+ #
+ private function set_php_error_reporting()
+ {
+ ini_set('error_reporting', E_ALL);
+ ini_set('log_errors', $this->config->error_reporting->log_errors);
+ ini_set('error_log', $this->config->error_reporting->error_log);
+ ini_set('display_errors', $this->config->error_reporting->development_environment);
+ }
+}
54 application/core/Model.php
@@ -0,0 +1,54 @@
+<?php if(!defined('RUN')){exit();}
+
+##################################################
+## ##
+## MODEL ##
+## ##
+##################################################
+#
+# Parent model for application controllers.
+#
+class Model {
+
+ // Database handle
+ protected $db;
+
+ ##############################################
+ #
+ # Constructor
+ #
+ # 10.15.2011
+ #
+ public function __construct()
+ {
+ // Load Configuration class.
+ $this->config =& load_class('Configuration', CORE);
+
+ // Set database configuration variables.
+ $driver = $this->config->database->driver;
+ $host = $this->config->database->host;
+ $dbname = $this->config->database->db_name;
+ $user = $this->config->database->user_name;
+ $pass = $this->config->database->password;
+
+ // Connect to database using PDO database object.
+ try {
+ $this->db = new PDO("$driver:host=$host;dbname=$dbname", $user, $pass);
+ } catch(Exception $e) {
+ echo "Database Configuration Invalid";
+ }
+ }
+
+
+
+ ##############################################
+ #
+ # Destructor
+ #
+ # 10.15.2011 - JJ Ford - Initial build.
+ #
+ public function __destruct()
+ {
+ $this->db = null;
+ }
+}
71 application/core/Router.php
@@ -0,0 +1,71 @@
+<?php if(!defined('RUN')){exit();}
+
+##################################################
+## ##
+## ROUTER ##
+## ##
+##################################################
+#
+class Router {
+
+ private $config;
+ private $load;
+
+ ##############################################
+ #
+ # Constructor
+ #
+ # 10.17.2011 - Initial build.
+ #
+ public function __construct()
+ {
+ // Get dependencies.
+ $this->config =& load_class('Configuration', CORE);
+ $this->load =& load_class('Loader', CORE);
+
+ // Start routing.
+ $this->route();
+ }
+
+
+
+ ##############################################
+ #
+ # router
+ #
+ # Route th application to the correct controller->method().
+ #
+ # 10.17.2011 - JJ Ford - Initial build.
+ #
+ public function route()
+ {
+ // Get the Uri.
+ $uri_segments = preg_split('@/@', remove_invisible_characters(trim($_SERVER['REQUEST_URI'], '/')), NULL, PREG_SPLIT_NO_EMPTY);
+
+ // Get controller from Uri.
+ $controller = $this->config->routing->default_controller;
+ $controller_segment = $this->config->routing->controller_segment - 1;
+ if (($controller_segment >= 0) && ($controller_segment < sizeof($uri_segments))) {
+ $controller = $uri_segments[$controller_segment];
+ }
+
+ // Get the method if applicatable.
+ if ($controller) {
+ $method = false;
+ $method_segment = $this->config->routing->method_segment - 1;
+ if (($method_segment >= 0) && ($method_segment < sizeof($uri_segments))) {
+ $method = $uri_segments[$method_segment];
+ }
+ }
+
+ // Route to correct location
+ if ($controller = $this->load->controller($controller)) {
+ if ($method && method_exists($controller, $method)) {
+ $controller->$method();
+ }
+ }
+
+ // Throw a 404 Error
+ else {include(APPLICATION.DS.ERRORS.DS.'404.html');}
+ }
+}
47 application/core/Security.php
@@ -0,0 +1,47 @@
+<?php if(!defined('RUN')){exit();}
+
+##################################################
+## ##
+## SECURITY ##
+## ##
+##################################################
+#
+class Security {
+
+ ##############################################
+ #
+ # Constructor
+ #
+ # 10.15.2011 - JJ Ford - Initial build.
+ #
+ public function __construct()
+ {
+ $this->cleanse_globals();
+ }
+
+
+
+ ##############################################
+ #
+ # Cleanse Globals
+ #
+ # Remove global variables from the envrionment.
+ #
+ # 10.15.2011 - JJ Ford - Initial build.
+ #
+ private function cleanse_globals()
+ {
+ if (ini_get('REGISTER_GLOBALS')) {
+
+ $type = array('_SESSION', '_POST', '_GET', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES');
+
+ foreach ($type as $value) {
+ foreach ($GLOBAL[$value] as $key => $var) {
+ if ($var === $GLOBALS[$key]) {
+ unset($GLOBAL[$key]);
+ }
+ }
+ }
+ }
+ }
+}
114 application/core/Utilities.php
@@ -0,0 +1,114 @@
+<?php if(!defined('RUN')){exit();}
+
+##################################################
+## ##
+## load_class ##
+## ##
+##################################################
+#
+# Load requested class, once loaded add it to an
+# array of loaded class references so it will not
+# need to be loaded again.
+#
+# param - Class to load.
+# param - Directory of class to load.
+# return - Instance of requested class to load.
+#
+# JJ Ford - 10.15.2011 - Initial build.
+#
+
+if ( ! function_exists('load_class'))
+{
+ function &load_class($class_to_load, $directory)
+ {
+ $class_to_load = ucfirst(strtolower($class_to_load));
+
+ // Create a static array of loaded classes.
+ static $loaded_classes = array();
+
+ // Check if requested class has been loaded and return it if so.
+ if (isset($loaded_classes[$class_to_load][$directory])) {return $loaded_classes[$class_to_load][$directory];}
+
+ // Check if the class exists and load it.
+ $class_found = false;
+ if (file_exists(APPLICATION.DS.$directory.DS.$class_to_load.PHP)) {
+
+ if (class_exists($class_to_load) === false) {
+ $class_found = true;
+ require_once(APPLICATION.DS.$directory.DS.$class_to_load.PHP);
+ }
+ }
+
+ // Kill the application if the class cannot be found.
+ if ($class_found === false) {exit('Unable to load the following ' . $directory . ' class: ' . $class_to_load);}
+
+ // If the class has been found and loaded add it to the array of loaded classes.
+ $loaded_classes[$class_to_load][$directory] = new $class_to_load();
+
+ return $loaded_classes[$class_to_load][$directory];
+ }
+}
+
+
+
+##################################################
+## ##
+## make_object ##
+## ##
+##################################################
+#
+# Turn given array into an object and returns the object.
+#
+# param - The array to convert.
+# return - The object created.
+#
+# 10.15.2011 - JJ Ford - Initial build.
+#
+if ( ! function_exists('make_object'))
+{
+ function make_object($array)
+ {
+ foreach ($array as $key => $value) {
+ if (is_array($value)) {
+ $array[$key] = make_object($value);
+ }
+ }
+
+ return (object) $array;
+ }
+}
+
+
+
+##################################################
+## ##
+## remove_invisible_characters ##
+## ##
+##################################################
+#
+# Prevent sandwhiching null characters between ascii characters, like Java\0script
+#
+# param - The array to convert.
+# return - The object created.
+#
+# 10.15.2011 - JJ Ford - Initial build (from CodeIgniter Source Code).
+#
+if ( ! function_exists('remove_invisible_characters'))
+{
+ function remove_invisible_characters($string)
+ {
+ // Define invisible characters.
+ $non_displayables = array();
+ $non_displayables[] = '/%0[0-8bcef]/';
+ $non_displayables[] = '/%1[0-9a-f]/';
+ $non_displayables[] = '/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S';
+
+ // Remove invisible characters.
+ do {
+ $str = preg_replace($non_displayables, '', $string, -1, $count);
+ }
+ while ($count);
+
+ return $string;
+ }
+}
46 application/errors/404.html
@@ -0,0 +1,46 @@
+<DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Page Not Found</title>
+
+ <style>
+
+ html {
+ height: 100%;
+ width: 100%;
+ }
+
+ body {
+ font-family: Helvetica, Verdana, Arial, sans-serif;
+ background: #f6f6f6;
+ }
+
+ div {
+ padding: 20px;
+ position: absolute;
+ top: 50%;
+ left: 50%;
+ margin-top: -200px;
+ margin-left: -171px;
+ width: 300px;
+ text-align: center;
+ color: #888;
+ background: #fff;
+ border: 1px solid #ddd;
+ -moz-border-radius: 5px;
+ -webkit-border-radius: 5px;
+ border-radius: 5px;
+ -webkit-box-shadow: 0px 0px 5px #ddd;
+ -moz-box-shadow: 0px 0px 5px #ddd;
+ box-shadow: 0px 0px 5px #ddd;
+ }
+
+ </style>
+</head>
+<body>
+ <div>
+ <h1>page not found</h1>
+ </div>
+</body>
+</html>
47 application/views/welcome.php
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+<head>
+
+ <meta charset="utf-8">
+ <title><?php echo $page_title; ?></title>
+
+ <style>
+
+ html {
+ height: 100%;
+ width: 100%;
+ }
+
+ body {
+ font-family: Helvetica, Verdana, Arial, sans-serif;
+ background: #f6f6f6;
+ }
+
+ div {
+ padding: 20px;
+ position: absolute;
+ top: 50%;
+ left: 50%;
+ margin-top: -200px;
+ margin-left: -271px;
+ width: 500px;
+ text-align: center;
+ color: #888;
+ background: #fff;
+ border: 1px solid #ddd;
+ -moz-border-radius: 5px;
+ -webkit-border-radius: 5px;
+ border-radius: 5px;
+ -webkit-box-shadow: 0px 0px 5px #ddd;
+ -moz-box-shadow: 0px 0px 5px #ddd;
+ box-shadow: 0px 0px 5px #ddd;
+ }
+
+ </style>
+</head>
+<body>
+ <div>
+ Welcome to PHP Blueprint. &nbsp;Documentation can be found <a href="documentation.html">here</a>.
+ </div>
+</body>
+</html>
178 documentation.html
@@ -0,0 +1,178 @@
+<!DOCTYPE html>
+
+<html class="no-js" lang="en">
+<head>
+
+ <!-- Meta Data -->
+ <meta charset="utf-8">
+
+ <!-- Page Information -->
+ <title>Documentation</title>
+ <meta name="description" content="PHP Blueprint Framework Documentation.">
+ <meta name="author" content="JJ Ford">
+
+ <!-- Mobile viewport optimized: j.mp/bplateviewport -->
+ <meta name="viewport" content="width=device-width,initial-scale=1">
+
+ <!-- CSS -->
+ <link href='http://fonts.googleapis.com/css?family=PT+Sans|Ubuntu|Antic' rel='stylesheet' type='text/css'>
+ <style>
+ html, body, div, span, applet, object, iframe,
+ h1, h2, h3, h4, h5, h6, p, blockquote, pre,
+ a, abbr, acronym, address, big, cite, code,
+ del, dfn, em, img, ins, kbd, q, s, samp,
+ small, strike, strong, sub, sup, tt, var,
+ b, u, i, center,
+ dl, dt, dd, ol, ul, li,
+ fieldset, form, label, legend,
+ table, caption, tbody, tfoot, thead, tr, th, td,
+ article, aside, canvas, details, embed,
+ figure, figcaption, footer, header, hgroup,
+ menu, nav, output, ruby, section, summary,
+ time, mark, audio, video {
+ margin: 0;
+ padding: 0;
+ border: 0;
+ font-size: 100%;
+ font: inherit;
+ vertical-align: baseline;
+ }
+ article, aside, details, figcaption, figure,
+ footer, header, hgroup, menu, nav, section {
+ display: block;
+ }
+ body {
+ line-height: 1;
+ }
+ ol, ul {
+ list-style: none;
+ }
+ blockquote, q {
+ quotes: none;
+ }
+ blockquote:before, blockquote:after,
+ q:before, q:after {
+ content: '';
+ content: none;
+ }
+ table {
+ border-collapse: collapse;
+ border-spacing: 0;
+ }
+
+ html {
+ height: 100%;
+ width: 100%;
+ }
+
+ body {
+ font-family: 'PT Sans', Verdana, Helvetica, Arial, sans-serif;
+ text-shadow: 0px 0px 100px #fff;
+ color: #fff;
+ background: #004785;
+ background-image: -ms-radial-gradient(center, circle cover, #1A90C0 0%, #004785 100%); /* IE10 */
+ background-image: -moz-radial-gradient(center, circle cover, #1A90C0 0%, #004785 100%); /* Mozilla Firefox */
+ background-image: -o-radial-gradient(center, circle cover, #1A90C0 0%, #004785 100%); /* Opera */
+ background-image: -webkit-gradient(radial, center center, 0, center center, 501, color-stop(0, #1A90C0), color-stop(1, #004785)); /* Webkit (Safari/Chrome 10) */
+ background-image: -webkit-radial-gradient(center, circle cover, #1A90C0 0%, #004785 100%); /* Webkit (Chrome 11+) */
+ background-image: radial-gradient(center, circle cover, #1A90C0 0%, #004785 100%); /* Proposed W3C Markup */
+ }
+
+ header {
+ margin-top: 100px;
+ margin-bottom: 50px;
+ }
+
+ #title {
+ font-family: 'Ubunut', Verdana, Helvetica, Arial, sans-serif;
+ font-size: 40px;
+ }
+
+ #title span {
+ color: #004e8c;
+ }
+
+ #title, #sub_title {
+ text-align: center;
+ }
+
+ #sub_title {
+ padding-top: 10px;
+ font-size: 14px;
+ letter-spacing: 3px;
+ }
+
+ #documentation {
+ width: 600px;
+ margin: 0 auto;
+ font-size: 12px;
+ text-shadow: none;
+ line-height: 20px;
+ }
+
+ #documentation ul li {
+ margin: 30px 0;
+ }
+
+ #documentation pre {
+ margin: 5px 0;
+ padding: 10px;
+ border: 1px solid #aaa;
+ }
+ </style>
+
+</head>
+<body>
+
+ <header>
+ <div id="title">php<span>blueprint</span>framework</div>
+ <div id="sub_title">simple, flexible, expandable</div>
+ </header>
+
+ <article id="documentation">
+
+ <section id="rules">
+ <ul>
+ <li>
+ Naming Conventions:<br />
+ 1. All files except view files must start with an uppercase followed by all lowercase.<br />
+ 2. All controller classes must have the suffix '_Controller' and follow rule 1.<br />
+ - &nbsp;Example, 'MyController' in the file 'Mycontroller.php' is 'class Mycontroller_Controller extends Controller'.<br />
+ 3. The same is done for models as for controllers in rule 2.<br />
+ - &nbsp;Example, 'MyModel' in the file 'Mymodel.php' is 'class Mymodel extends Model'.<br />
+ 4. Library class names must follow rule 1.
+ </li>
+
+ <li>All configuration file's $config variable's will be loaded into the parent model and controller classes as objects.</li>
+
+ <li>To access the configuration variable '$config['one']['two']' inside a model or controller use:
+ <pre>'$this->config->one->two'</pre>
+ </li>
+
+ <li>Controller classes extend 'Controller' and Model classes extend 'Model'. Don't forget to call the parent constructor to get the 'load' and 'config' objects.</li>
+
+ <li>To load a library object use:
+ <pre>'$this->load->library('my_library')'</pre>
+ </li>
+
+ <li>To load a model use
+ <pre>'$this->load->model('my_model')'</pre>
+ </li>
+
+ <li>To load a controller use:
+ <pre>'$this->load->controller('my_controller')'</pre>
+ </li>
+
+ <li>To load a view use:
+ <pre>'$this->load->view('my_view')'</pre>
+ </li>
+
+ <li>An associative array of data can be passed to the view and its key's will be extracted into variables to be used by the view by using:
+ <pre>'$this->load->view('my_view', $my_data_array)'</pre>
+ </li>
+ </ul>
+ </section>
+ </article>
+
+</body>
+</html>
255 htaccess
@@ -0,0 +1,255 @@
+# Apache Configuration File
+
+##################################################
+## ##
+## IE USERS ##
+## ##
+##################################################
+#
+# Use ChromeFrame if it's installed for better experience.
+<IfModule mod_headers.c>
+ Header set X-UA-Compatible "IE=Edge,chrome=1"
+
+ # mod_headers can't match by content-type, but we don't want to send this header on *everything*...
+ <FilesMatch "\.(js|css|gif|png|jpe?g|pdf|xml|oga|ogg|m4a|ogv|mp4|m4v|webm|svg|svgz|eot|ttf|otf|woff|ico|webp|appcache|manifest|htc|crx|xpi|safariextz|vcf)$" >
+ Header unset X-UA-Compatible
+ </FilesMatch>
+</IfModule>
+
+##################################################
+## ##
+## WEB FONTS ##
+## ##
+##################################################
+#
+# Allow access from all domains for webfonts.
+<FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css)$">
+ <IfModule mod_headers.c>
+ Header set Access-Control-Allow-Origin "*"
+ </IfModule>
+</FilesMatch>
+
+##################################################
+## ##
+## MIME TYPES ##
+## ##
+##################################################
+#
+# JavaScript
+AddType application/javascript js
+
+# Audio
+AddType audio/ogg oga ogg
+AddType audio/mp4 m4a
+
+# Video
+AddType video/ogg ogv
+AddType video/mp4 mp4 m4v
+AddType video/webm webm
+
+# SVG.
+# Required for svg webfonts on iPad
+# twitter.com/FontSquirrel/status/14855840545
+AddType image/svg+xml svg svgz
+AddEncoding gzip svgz
+
+# Webfonts
+AddType application/vnd.ms-fontobject eot
+AddType application/x-font-ttf ttf ttc
+AddType font/opentype otf
+AddType application/x-font-woff woff
+
+# Assorted types
+AddType image/x-icon ico
+AddType image/webp webp
+AddType text/cache-manifest appcache manifest
+AddType text/x-component htc
+AddType application/x-chrome-extension crx
+AddType application/x-xpinstall xpi
+AddType application/octet-stream safariextz
+AddType text/x-vcard vcf
+
+##################################################
+## ##
+## GZIP COMPRESSION ##
+## ##
+##################################################
+#
+<IfModule mod_deflate.c>
+
+ # Force deflate for mangled headers developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/
+ <IfModule mod_setenvif.c>
+ <IfModule mod_headers.c>
+ SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
+ RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
+ </IfModule>
+ </IfModule>
+
+ # HTML, TXT, CSS, JavaScript, JSON, XML, HTC:
+ <IfModule filter_module>
+ FilterDeclare COMPRESS
+ FilterProvider COMPRESS DEFLATE resp=Content-Type $text/html
+ FilterProvider COMPRESS DEFLATE resp=Content-Type $text/css
+ FilterProvider COMPRESS DEFLATE resp=Content-Type $text/plain
+ FilterProvider COMPRESS DEFLATE resp=Content-Type $text/xml
+ FilterProvider COMPRESS DEFLATE resp=Content-Type $text/x-component
+ FilterProvider COMPRESS DEFLATE resp=Content-Type $application/javascript
+ FilterProvider COMPRESS DEFLATE resp=Content-Type $application/json
+ FilterProvider COMPRESS DEFLATE resp=Content-Type $application/xml
+ FilterProvider COMPRESS DEFLATE resp=Content-Type $application/xhtml+xml
+ FilterProvider COMPRESS DEFLATE resp=Content-Type $application/rss+xml
+ FilterProvider COMPRESS DEFLATE resp=Content-Type $application/atom+xml
+ FilterProvider COMPRESS DEFLATE resp=Content-Type $application/vnd.ms-fontobject
+ FilterProvider COMPRESS DEFLATE resp=Content-Type $image/svg+xml
+ FilterProvider COMPRESS DEFLATE resp=Content-Type $application/x-font-ttf
+ FilterProvider COMPRESS DEFLATE resp=Content-Type $font/opentype
+ FilterChain COMPRESS
+ FilterProtocol COMPRESS DEFLATE change=yes;byteranges=no
+ </IfModule>
+
+ # Legacy versions of Apache
+ <IfModule !mod_filter.c>
+ AddOutputFilterByType DEFLATE text/html text/plain text/css application/json
+ AddOutputFilterByType DEFLATE application/javascript
+ AddOutputFilterByType DEFLATE text/xml application/xml text/x-component
+ AddOutputFilterByType DEFLATE application/xhtml+xml application/rss+xml application/atom+xml
+ AddOutputFilterByType DEFLATE image/svg+xml application/vnd.ms-fontobject application/x-font-ttf font/opentype
+ </IfModule>
+</IfModule>
+
+##################################################
+## ##
+## EXPIRED HEADERS FOR CACHE CONTROL ##
+## ##
+##################################################
+#
+<IfModule mod_expires.c>
+ ExpiresActive on
+
+ # Perhaps better to whitelist expires rules? Perhaps.
+ ExpiresDefault "access plus 1 month"
+
+ # cache.appcache needs re-requests in FF 3.6 (thanks Remy ~Introducing HTML5)
+ ExpiresByType text/cache-manifest "access plus 0 seconds"
+
+ # Your document html
+ ExpiresByType text/html "access plus 0 seconds"
+
+ # Data
+ ExpiresByType text/xml "access plus 0 seconds"
+ ExpiresByType application/xml "access plus 0 seconds"
+ ExpiresByType application/json "access plus 0 seconds"
+
+ # Feed
+ ExpiresByType application/rss+xml "access plus 1 hour"
+ ExpiresByType application/atom+xml "access plus 1 hour"
+
+ # Favicon (cannot be renamed)
+ ExpiresByType image/x-icon "access plus 1 week"
+
+ # Media: images, video, audio
+ ExpiresByType image/gif "access plus 1 month"
+ ExpiresByType image/png "access plus 1 month"
+ ExpiresByType image/jpg "access plus 1 month"
+ ExpiresByType image/jpeg "access plus 1 month"
+ ExpiresByType video/ogg "access plus 1 month"
+ ExpiresByType audio/ogg "access plus 1 month"
+ ExpiresByType video/mp4 "access plus 1 month"
+ ExpiresByType video/webm "access plus 1 month"
+
+ # HTC files (css3pie)
+ ExpiresByType text/x-component "access plus 1 month"
+
+ # Webfonts
+ ExpiresByType font/truetype "access plus 1 month"
+ ExpiresByType font/opentype "access plus 1 month"
+ ExpiresByType application/x-font-woff "access plus 1 month"
+ ExpiresByType image/svg+xml "access plus 1 month"
+ ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
+
+ # CSS and JavaScript
+ ExpiresByType text/css "access plus 1 year"
+ ExpiresByType application/javascript "access plus 1 year"
+
+ <IfModule mod_headers.c>
+ Header append Cache-Control "public"
+ </IfModule>
+</IfModule>
+
+##################################################
+## ##
+## REWRITE ##
+## ##
+##################################################
+#
+<IfModule mod_rewrite.c>
+
+ # Turn rewrite engine on.
+ RewriteEngine On
+ RewriteBase /
+
+ # Disable 404 if no folder exists.
+ Options -MultiViews
+
+ # Rewrite "www.example.com -> example.com"
+ RewriteCond %{HTTPS} !=on
+ RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
+ RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
+
+ # Rewrite "example.com -> www.example.com"
+ #RewriteCond %{HTTPS} !=on
+ #RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
+ #RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
+
+ # Follow Symbolic Links
+ Options +FollowSymlinks
+
+ # Block users from browsing through folders.
+ Options -Indexes
+
+ # Block access to hidden folders.
+ RewriteRule "(^|/)\." - [F]
+
+ # If the request is for a real file then index.php isn't served.
+ RewriteCond %{REQUEST_FILENAME} !-f
+
+ # If the request is for a real directroy then index.php isn't served.
+ RewriteCond %{REQUEST_FILENAME} !-d
+
+ # Redirect everything to index.php
+ RewriteRule ^.*$ ./index.php
+</IfModule>
+
+##################################################
+## ##
+## E_TAG REMOVAL ##
+## ##
+##################################################
+#
+FileETag None
+
+<IfModule mod_headers.c>
+ Header unset ETag
+</IfModule>
+
+##################################################
+## ##
+## UTF-8 ENCODING ##
+## ##
+##################################################
+#
+# Use UTF-8 encoding for anything served text/plain or text/html
+AddDefaultCharset utf-8
+
+# Force UTF-8 for a number of file formats
+AddCharset utf-8 .html .css .js .xml .json .rss .atom
+
+##################################################
+## ##
+## ERRORS ##
+## ##
+##################################################
+#
+#ErrorDocument 403 path/url
+ErrorDocument 404 /404.html
+#ErrorDocument 500 path/url
38 index.php
@@ -0,0 +1,38 @@
+<?php
+
+##################################################
+## ##
+## CREATE APPLICATION DEFINITIONS ##
+## ##
+##################################################
+#
+define('APPLICATION', 'application');
+define('CONFIG', 'config');
+define('CONTROLLER', 'controllers');
+define('CORE', 'core');
+define('DS', DIRECTORY_SEPARATOR);
+define('ERRORS', 'errors');
+define('LIBRARY', 'libraries');
+define('MODEL', 'models');
+define('RUN', true);
+define('PHP', '.php');
+define('VIEW', 'views');
+
+##################################################
+## ##
+## GET UTILITIES ##
+## ##
+##################################################
+#
+require_once(APPLICATION.DS.CORE.DS.'Utilities'.PHP);
+
+##################################################
+## ##
+## BOOTSTRAP ##
+## ##
+##################################################
+#
+load_class('Logging', CORE);
+load_class('Controller', CORE);
+load_class('Security', CORE);
+load_class('Router', CORE);
19 license.txt
@@ -0,0 +1,19 @@
+Copyright (C) 2011 by John (JJ) Nathaniel Ford
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.

0 comments on commit b184d04

Please sign in to comment.