Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Initial commit

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

0 comments on commit b184d04

Please sign in to comment.
Something went wrong with that request. Please try again.