@@ -1,42 +1,37 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -abstract class Content |
|
4 | -{ |
|
3 | +abstract class Content |
|
4 | +{ |
|
5 | 5 | |
6 | 6 | protected $original_content; |
7 | 7 | protected $content; |
8 | 8 | |
9 | - function __construct($content) |
|
10 | - { |
|
9 | + function __construct($content) { |
|
11 | 10 | $this->original_content = $content; |
12 | 11 | $this->content = $content; |
13 | 12 | } |
14 | 13 | |
15 | - public function getOriginal() |
|
16 | - { |
|
14 | + public function getOriginal() { |
|
17 | 15 | return $this->original_content; |
18 | 16 | } |
19 | 17 | |
20 | 18 | abstract protected function execute(); |
21 | 19 | |
22 | - public function activate() |
|
23 | - { |
|
20 | + public function activate() { |
|
24 | 21 | $args = func_get_args(); |
25 | 22 | call_user_func_array(array($this, 'execute'), $args); |
26 | 23 | |
27 | 24 | return $this->content; |
28 | 25 | } |
29 | 26 | |
30 | - public function check() |
|
31 | - { |
|
27 | + public function check() { |
|
32 | 28 | $args = func_get_args(); |
33 | 29 | $return = call_user_func_array(array($this, 'execute'), $args); |
34 | 30 | |
35 | 31 | return $return; |
36 | 32 | } |
37 | 33 | |
38 | - public static function instance($class, $content) |
|
39 | - { |
|
34 | + public static function instance($class, $content) { |
|
40 | 35 | $class_name = "{$class}Content"; |
41 | 36 | Loader::load('utility', "content/{$class_name}"); |
42 | 37 | return new $class_name($content); |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -class Request |
|
4 | -{ |
|
3 | +class Request |
|
4 | +{ |
|
5 | 5 | |
6 | 6 | private static $server = array(); |
7 | 7 | private static $get = array(); |
@@ -9,70 +9,65 @@ discard block |
||
9 | 9 | |
10 | 10 | private static $AJAX_REQUEST = 'HTTP_X_REQUESTED_WITH'; |
11 | 11 | |
12 | - static function init() |
|
13 | - { |
|
12 | + static function init() { |
|
14 | 13 | self::make_server(); |
15 | 14 | self::make_get(); |
16 | 15 | self::make_post(); |
17 | 16 | } |
18 | 17 | |
19 | - static function getServer($key = null) |
|
20 | - { |
|
18 | + static function getServer($key = null) { |
|
21 | 19 | if($key) |
22 | 20 | { |
23 | - if(isset(self::$server[$key])) |
|
24 | - return self::$server[$key]; |
|
21 | + if(isset(self::$server[$key])) { |
|
22 | + return self::$server[$key]; |
|
23 | + } |
|
25 | 24 | return false; |
26 | 25 | } |
27 | 26 | return self::$server; |
28 | 27 | } |
29 | 28 | |
30 | - static function isAjax() |
|
31 | - { |
|
32 | - if(self::getServer(self::$AJAX_REQUEST)) |
|
33 | - return true; |
|
29 | + static function isAjax() { |
|
30 | + if(self::getServer(self::$AJAX_REQUEST)) { |
|
31 | + return true; |
|
32 | + } |
|
34 | 33 | return false; |
35 | 34 | } |
36 | 35 | |
37 | - static function getGet($key = null) |
|
38 | - { |
|
36 | + static function getGet($key = null) { |
|
39 | 37 | if($key) |
40 | 38 | { |
41 | - if(isset(self::$get[$key])) |
|
42 | - return self::$get[$key]; |
|
39 | + if(isset(self::$get[$key])) { |
|
40 | + return self::$get[$key]; |
|
41 | + } |
|
43 | 42 | return false; |
44 | 43 | } |
45 | 44 | return self::$get; |
46 | 45 | } |
47 | 46 | |
48 | - static function getPost($key = null) |
|
49 | - { |
|
47 | + static function getPost($key = null) { |
|
50 | 48 | if($key) |
51 | 49 | { |
52 | - if(isset(self::$post[$key])) |
|
53 | - return self::$post[$key]; |
|
50 | + if(isset(self::$post[$key])) { |
|
51 | + return self::$post[$key]; |
|
52 | + } |
|
54 | 53 | return false; |
55 | 54 | } |
56 | 55 | return self::$post; |
57 | 56 | } |
58 | 57 | |
59 | - public static function hasPost() |
|
60 | - { |
|
58 | + public static function hasPost() { |
|
61 | 59 | return is_array(self::$post) && !empty(self::$post); |
62 | 60 | } |
63 | 61 | |
64 | - static function make_server() |
|
65 | - { |
|
62 | + static function make_server() { |
|
66 | 63 | self::$server = $_SERVER; |
67 | 64 | } |
68 | 65 | |
69 | - static function make_get() |
|
70 | - { |
|
66 | + static function make_get() { |
|
71 | 67 | self::$get = $_GET; |
72 | 68 | } |
73 | 69 | |
74 | - static function make_post() |
|
75 | - { |
|
70 | + static function make_post() { |
|
76 | 71 | self::$post = $_POST; |
77 | 72 | } |
78 | 73 |
@@ -1,10 +1,9 @@ discard block |
||
1 | 1 | <? |
2 | 2 | |
3 | -final class Header |
|
4 | -{ |
|
3 | +final class Header |
|
4 | +{ |
|
5 | 5 | |
6 | - public static function sendJSON() |
|
7 | - { |
|
6 | + public static function sendJSON() { |
|
8 | 7 | $array = array( |
9 | 8 | 'HTTP/1.1 200 OK', |
10 | 9 | 'Cache-Control: no-cache', |
@@ -16,8 +15,7 @@ discard block |
||
16 | 15 | self::send($array); |
17 | 16 | } |
18 | 17 | |
19 | - public static function sendHTML() |
|
20 | - { |
|
18 | + public static function sendHTML() { |
|
21 | 19 | $array = array( |
22 | 20 | 'HTTP/1.1 200 OK', |
23 | 21 | 'Cache-Control: no-cache', |
@@ -29,14 +27,12 @@ discard block |
||
29 | 27 | self::send($array); |
30 | 28 | } |
31 | 29 | |
32 | - public static function redirect($location, $method = 301) |
|
33 | - { |
|
30 | + public static function redirect($location, $method = 301) { |
|
34 | 31 | header("Location: {$location}", TRUE, $method); |
35 | 32 | exit(); |
36 | 33 | } |
37 | 34 | |
38 | - public static function send404() |
|
39 | - { |
|
35 | + public static function send404() { |
|
40 | 36 | $array = array( |
41 | 37 | 'HTTP/1.1 404 Not Found', |
42 | 38 | 'Cache-Control: no-cache', |
@@ -48,8 +44,7 @@ discard block |
||
48 | 44 | self::send($array); |
49 | 45 | } |
50 | 46 | |
51 | - public static function send503() |
|
52 | - { |
|
47 | + public static function send503() { |
|
53 | 48 | $array = array( |
54 | 49 | 'HTTP/1.1 503 Service Unavailable', |
55 | 50 | 'Cache-Control: no-cache', |
@@ -61,10 +56,10 @@ discard block |
||
61 | 56 | self::send($array); |
62 | 57 | } |
63 | 58 | |
64 | - private static function send($array, $gzip = true) |
|
65 | - { |
|
66 | - if($gzip) |
|
67 | - self::start_gzipping(); |
|
59 | + private static function send($array, $gzip = true) { |
|
60 | + if($gzip) { |
|
61 | + self::start_gzipping(); |
|
62 | + } |
|
68 | 63 | |
69 | 64 | foreach($array as $row) |
70 | 65 | { |
@@ -72,17 +67,17 @@ discard block |
||
72 | 67 | } |
73 | 68 | } |
74 | 69 | |
75 | - private static function get_date($timestamp = false) |
|
76 | - { |
|
77 | - if($timestamp == 0) |
|
78 | - $timestamp = time(); |
|
70 | + private static function get_date($timestamp = false) { |
|
71 | + if($timestamp == 0) { |
|
72 | + $timestamp = time(); |
|
73 | + } |
|
79 | 74 | return gmdate('D, d M Y H:i:s \G\M\T', $timestamp); |
80 | 75 | } |
81 | 76 | |
82 | - private static function start_gzipping() |
|
83 | - { |
|
84 | - if(!ob_start('ob_gzhandler')) |
|
85 | - ob_start(); |
|
77 | + private static function start_gzipping() { |
|
78 | + if(!ob_start('ob_gzhandler')) { |
|
79 | + ob_start(); |
|
80 | + } |
|
86 | 81 | } |
87 | 82 | |
88 | 83 | } |
@@ -2,78 +2,76 @@ discard block |
||
2 | 2 | |
3 | 3 | Loader::load('utility', 'Request'); |
4 | 4 | |
5 | -class Validate |
|
6 | -{ |
|
5 | +class Validate |
|
6 | +{ |
|
7 | 7 | |
8 | 8 | private static $NAME_REGEX = '@[a-z\s\'-]+@i'; |
9 | 9 | private static $EMAIL_REGEX = '@(?:[a-z0-9!#$%&\'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")\@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])@i'; |
10 | 10 | private static $URL_REGEX = '@((https?|ftp)\:\/\/)?([a-z0-9-.]*)\.([a-z]{2,3})(\/([a-z0-9+\$_-]\.?)+)*\/?(\?[a-z+&\$_.-][a-z0-9;:\@&%=+\/\$_.-]*)?(#[a-z_.-][a-z0-9+\$_.-]*)?@i'; |
11 | 11 | |
12 | - public static function isBoolean($value, $strict = false) |
|
13 | - { |
|
14 | - if($strict && ($value === true || $value === false)) |
|
15 | - return true; |
|
16 | - if(!$strict && ((bool) $value === true || (bool) $value === false)) |
|
17 | - return true; |
|
12 | + public static function isBoolean($value, $strict = false) { |
|
13 | + if($strict && ($value === true || $value === false)) { |
|
14 | + return true; |
|
15 | + } |
|
16 | + if(!$strict && ((bool) $value === true || (bool) $value === false)) { |
|
17 | + return true; |
|
18 | + } |
|
18 | 19 | return false; |
19 | 20 | } |
20 | 21 | |
21 | - public static function isDate($value) |
|
22 | - { |
|
23 | - if(strtotime($value) !== -1) |
|
24 | - return true; |
|
25 | - if(date('y', $value) !== false) |
|
26 | - return true; |
|
22 | + public static function isDate($value) { |
|
23 | + if(strtotime($value) !== -1) { |
|
24 | + return true; |
|
25 | + } |
|
26 | + if(date('y', $value) !== false) { |
|
27 | + return true; |
|
28 | + } |
|
27 | 29 | return false; |
28 | 30 | } |
29 | 31 | |
30 | - public static function isInteger($value, $strict = false) |
|
31 | - { |
|
32 | - if($strict) |
|
33 | - return is_int($value); |
|
32 | + public static function isInteger($value, $strict = false) { |
|
33 | + if($strict) { |
|
34 | + return is_int($value); |
|
35 | + } |
|
34 | 36 | return (int) $value == $value; |
35 | 37 | } |
36 | 38 | |
37 | - public static function isIP($value) |
|
38 | - { |
|
39 | - if(self::isInteger(ip2long($value))) |
|
40 | - return true; |
|
39 | + public static function isIP($value) { |
|
40 | + if(self::isInteger(ip2long($value))) { |
|
41 | + return true; |
|
42 | + } |
|
41 | 43 | return false; |
42 | 44 | } |
43 | 45 | |
44 | - public static function isString($value, $strict = false) |
|
45 | - { |
|
46 | - if($strict) |
|
47 | - return is_string($value); |
|
46 | + public static function isString($value, $strict = false) { |
|
47 | + if($strict) { |
|
48 | + return is_string($value); |
|
49 | + } |
|
48 | 50 | return (string) $value == $value; |
49 | 51 | } |
50 | 52 | |
51 | - public static function isURL($value) |
|
52 | - { |
|
53 | + public static function isURL($value) { |
|
53 | 54 | return true; |
54 | 55 | return self::check_value(self::$URL_REGEX, $value); |
55 | 56 | } |
56 | 57 | |
57 | - public static function isName($value) |
|
58 | - { |
|
58 | + public static function isName($value) { |
|
59 | 59 | return self::check_value(self::$NAME_REGEX, $value); |
60 | 60 | } |
61 | 61 | |
62 | - public static function isEmail($value) |
|
63 | - { |
|
62 | + public static function isEmail($value) { |
|
64 | 63 | return self::check_value(self::$EMAIL_REGEX, $value); |
65 | 64 | } |
66 | 65 | |
67 | - private static function check_value($pattern, $string) |
|
68 | - { |
|
66 | + private static function check_value($pattern, $string) { |
|
69 | 67 | preg_match($pattern, $string, $matches); |
70 | - if(empty($matches)) |
|
71 | - return false; |
|
68 | + if(empty($matches)) { |
|
69 | + return false; |
|
70 | + } |
|
72 | 71 | return $matches[0] == $string; |
73 | 72 | } |
74 | 73 | |
75 | - public static function checkRequest($type, $key, $validation, $strict = false) |
|
76 | - { |
|
74 | + public static function checkRequest($type, $key, $validation, $strict = false) { |
|
77 | 75 | switch($type) |
78 | 76 | { |
79 | 77 | case 'server': |
@@ -84,8 +82,9 @@ discard block |
||
84 | 82 | break; |
85 | 83 | } |
86 | 84 | |
87 | - if($value == false) |
|
88 | - return false; |
|
85 | + if($value == false) { |
|
86 | + return false; |
|
87 | + } |
|
89 | 88 | |
90 | 89 | switch($validation) |
91 | 90 | { |
@@ -5,11 +5,10 @@ discard block |
||
5 | 5 | 'waterfall/WaterfallCollector')); |
6 | 6 | Loader::load('router', 'Router'); |
7 | 7 | |
8 | -class WaterfallRouter extends Router |
|
9 | -{ |
|
8 | +class WaterfallRouter extends Router |
|
9 | +{ |
|
10 | 10 | |
11 | - protected function get_redirect_array() |
|
12 | - { |
|
11 | + protected function get_redirect_array() { |
|
13 | 12 | return array( |
14 | 13 | (object) array( |
15 | 14 | 'pattern' => '@/index.(html|htm|php)$@', |
@@ -71,8 +70,7 @@ discard block |
||
71 | 70 | ); |
72 | 71 | } |
73 | 72 | |
74 | - protected function check_for_special_redirect($uri) |
|
75 | - { |
|
73 | + protected function check_for_special_redirect($uri) { |
|
76 | 74 | if (preg_match('@^/falls/([a-z\'-]+)(/?)$@', $uri, $matches)) { |
77 | 75 | $alias = $matches[1]; |
78 | 76 | $alias = str_replace("'", '', $alias); |
@@ -128,8 +126,7 @@ discard block |
||
128 | 126 | return $uri; |
129 | 127 | } |
130 | 128 | |
131 | - protected function get_direct_array() |
|
132 | - { |
|
129 | + protected function get_direct_array() { |
|
133 | 130 | return array( |
134 | 131 | (object) array( |
135 | 132 | 'match' => '/', |
@@ -2,19 +2,17 @@ |
||
2 | 2 | |
3 | 3 | Loader::load('router', 'Router'); |
4 | 4 | |
5 | -final class HomeRouter extends Router |
|
6 | -{ |
|
5 | +final class HomeRouter extends Router |
|
6 | +{ |
|
7 | 7 | |
8 | - protected function get_redirect_array() |
|
9 | - { |
|
8 | + protected function get_redirect_array() { |
|
10 | 9 | return array( |
11 | 10 | (object) array( |
12 | 11 | 'pattern' => '@/index.(html|htm|php)$@', |
13 | 12 | 'replace' => '')); |
14 | 13 | } |
15 | 14 | |
16 | - protected function get_direct_array() |
|
17 | - { |
|
15 | + protected function get_direct_array() { |
|
18 | 16 | return array( |
19 | 17 | (object) array( |
20 | 18 | 'match' => '/', |
@@ -2,19 +2,17 @@ |
||
2 | 2 | |
3 | 3 | Loader::load('router', 'Router'); |
4 | 4 | |
5 | -class SiteRouter extends Router |
|
6 | -{ |
|
5 | +class SiteRouter extends Router |
|
6 | +{ |
|
7 | 7 | |
8 | - protected function get_redirect_array() |
|
9 | - { |
|
8 | + protected function get_redirect_array() { |
|
10 | 9 | return array( |
11 | 10 | (object) array( |
12 | 11 | 'pattern' => '@/index.(html|htm|php)$@', |
13 | 12 | 'replace' => '/')); |
14 | 13 | } |
15 | 14 | |
16 | - protected function get_direct_array() |
|
17 | - { |
|
15 | + protected function get_direct_array() { |
|
18 | 16 | return array( |
19 | 17 | (object) array( |
20 | 18 | 'match' => '/', |
@@ -4,22 +4,21 @@ discard block |
||
4 | 4 | 'Request', |
5 | 5 | 'URLDecode')); |
6 | 6 | |
7 | -abstract class Router |
|
8 | -{ |
|
7 | +abstract class Router |
|
8 | +{ |
|
9 | 9 | |
10 | 10 | public function __construct() {} |
11 | 11 | |
12 | - public static function instance() |
|
13 | - { |
|
12 | + public static function instance() { |
|
14 | 13 | $router_name = self::get_router_name(); |
15 | 14 | $router = Loader::loadNew('router', $router_name); |
16 | 15 | $router->route(); |
17 | 16 | } |
18 | 17 | |
19 | - private static function get_router_name() |
|
20 | - { |
|
21 | - if(Request::isAJAX()) |
|
22 | - return 'AJAXRouter'; |
|
18 | + private static function get_router_name() { |
|
19 | + if(Request::isAJAX()) { |
|
20 | + return 'AJAXRouter'; |
|
21 | + } |
|
23 | 22 | |
24 | 23 | switch(URLDecode::getSite()) |
25 | 24 | { |
@@ -49,8 +48,7 @@ discard block |
||
49 | 48 | Loader::loadNew('controller', '/Error404Controller')->activate(); |
50 | 49 | } |
51 | 50 | |
52 | - protected function route() |
|
53 | - { |
|
51 | + protected function route() { |
|
54 | 52 | $uri = URLDecode::getURI(); |
55 | 53 | |
56 | 54 | $this->check_for_redirect($uri); |
@@ -63,8 +61,7 @@ discard block |
||
63 | 61 | abstract protected function get_redirect_array(); |
64 | 62 | abstract protected function get_direct_array(); |
65 | 63 | |
66 | - final protected function check_for_redirect($redirect_uri) |
|
67 | - { |
|
64 | + final protected function check_for_redirect($redirect_uri) { |
|
68 | 65 | foreach($this->get_redirect_array() as $check) |
69 | 66 | { |
70 | 67 | $redirect_uri = preg_replace($check->pattern, $check->replace, $redirect_uri); |
@@ -72,16 +69,18 @@ discard block |
||
72 | 69 | |
73 | 70 | $redirect_uri = $this->check_for_special_redirect($redirect_uri); |
74 | 71 | |
75 | - if($this->requires_trailing_slash() && substr($redirect_uri, -1) != '/') |
|
76 | - $redirect_uri .= '/'; |
|
72 | + if($this->requires_trailing_slash() && substr($redirect_uri, -1) != '/') { |
|
73 | + $redirect_uri .= '/'; |
|
74 | + } |
|
77 | 75 | |
78 | 76 | if (URLDecode::getHost() == 'waterfalls.jacobemerick.com') { |
79 | 77 | $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http'; |
80 | 78 | $redirect_uri = $protocol . '://' . (!Loader::isLive() ? 'dev' : 'www') . '.waterfallsofthekeweenaw.com' . $redirect_uri; |
81 | 79 | } |
82 | 80 | |
83 | - if($redirect_uri == URLDecode::getURI()) |
|
84 | - return; |
|
81 | + if($redirect_uri == URLDecode::getURI()) { |
|
82 | + return; |
|
83 | + } |
|
85 | 84 | |
86 | 85 | $controller_check = $redirect_uri; |
87 | 86 | if(substr($redirect_uri, 0, 4) == 'http') { |
@@ -107,35 +106,34 @@ discard block |
||
107 | 106 | ->activate(); |
108 | 107 | } |
109 | 108 | |
110 | - protected function check_for_special_redirect($uri) |
|
111 | - { |
|
109 | + protected function check_for_special_redirect($uri) { |
|
112 | 110 | return $uri; |
113 | 111 | } |
114 | 112 | |
115 | - final private function get_controller($uri) |
|
116 | - { |
|
113 | + final private function get_controller($uri) { |
|
117 | 114 | foreach($this->get_direct_array() as $check) |
118 | 115 | { |
119 | - if($uri == $check->match) |
|
120 | - return "{$this->get_primary_folder()}/{$check->controller}"; |
|
116 | + if($uri == $check->match) { |
|
117 | + return "{$this->get_primary_folder()}/{$check->controller}"; |
|
118 | + } |
|
121 | 119 | |
122 | - if(preg_match("@^{$check->match}$@", $uri)) |
|
123 | - return "{$this->get_primary_folder()}/{$check->controller}"; |
|
120 | + if(preg_match("@^{$check->match}$@", $uri)) { |
|
121 | + return "{$this->get_primary_folder()}/{$check->controller}"; |
|
122 | + } |
|
124 | 123 | } |
125 | 124 | |
126 | 125 | return '/Error404Controller'; |
127 | 126 | } |
128 | 127 | |
129 | - final private function get_primary_folder() |
|
130 | - { |
|
131 | - if(Request::isAjax()) |
|
132 | - return 'ajax'; |
|
128 | + final private function get_primary_folder() { |
|
129 | + if(Request::isAjax()) { |
|
130 | + return 'ajax'; |
|
131 | + } |
|
133 | 132 | |
134 | 133 | return URLDecode::getSite(); |
135 | 134 | } |
136 | 135 | |
137 | - private function requires_trailing_slash() |
|
138 | - { |
|
136 | + private function requires_trailing_slash() { |
|
139 | 137 | return ( |
140 | 138 | URLDecode::getExtension() != 'json' && |
141 | 139 | strstr(URLDecode::getURI(), '#') === false); |
@@ -2,11 +2,10 @@ discard block |
||
2 | 2 | |
3 | 3 | Loader::load('router', 'Router'); |
4 | 4 | |
5 | -class LifestreamRouter extends Router |
|
6 | -{ |
|
5 | +class LifestreamRouter extends Router |
|
6 | +{ |
|
7 | 7 | |
8 | - protected function get_redirect_array() |
|
9 | - { |
|
8 | + protected function get_redirect_array() { |
|
10 | 9 | return array( |
11 | 10 | (object) array( |
12 | 11 | 'pattern' => '@/index.(html|htm|php)$@', |
@@ -31,8 +30,7 @@ discard block |
||
31 | 30 | 'replace' => '/')); |
32 | 31 | } |
33 | 32 | |
34 | - protected function get_direct_array() |
|
35 | - { |
|
33 | + protected function get_direct_array() { |
|
36 | 34 | return array( |
37 | 35 | (object) array( |
38 | 36 | 'match' => '/', |