@@ -2,11 +2,10 @@ discard block |
||
2 | 2 | |
3 | 3 | Loader::load('controller', 'site/DefaultPageController'); |
4 | 4 | |
5 | -final class TermsController extends DefaultPageController |
|
6 | -{ |
|
5 | +final class TermsController extends DefaultPageController |
|
6 | +{ |
|
7 | 7 | |
8 | - protected function set_head_data() |
|
9 | - { |
|
8 | + protected function set_head_data() { |
|
10 | 9 | $this->set_title("Terms of Use for Jacob Emerick's Sites"); |
11 | 10 | $this->set_description("Some basic (and boring) legal jargon and perferred usage of the content on Jacob Emerick's sites. Includes re-use terms and advice on retracing hikes."); |
12 | 11 | $this->set_keywords(array('terms of use', 'legal', 'accountability', 'trespassing', 'Jacob Emerick')); |
@@ -14,8 +13,7 @@ discard block |
||
14 | 13 | parent::set_head_data(); |
15 | 14 | } |
16 | 15 | |
17 | - protected function set_body_data() |
|
18 | - { |
|
16 | + protected function set_body_data() { |
|
19 | 17 | $this->set_body('top_data', array('title' => 'Terms of Use')); |
20 | 18 | |
21 | 19 | $this->set_body('body_view', 'Terms'); |
@@ -4,11 +4,10 @@ discard block |
||
4 | 4 | |
5 | 5 | Loader::load('controller', 'site/DefaultPageController'); |
6 | 6 | |
7 | -final class ChangelogController extends DefaultPageController |
|
8 | -{ |
|
7 | +final class ChangelogController extends DefaultPageController |
|
8 | +{ |
|
9 | 9 | |
10 | - protected function set_head_data() |
|
11 | - { |
|
10 | + protected function set_head_data() { |
|
12 | 11 | $this->set_title("Changelog for Jacob Emerick's Sites"); |
13 | 12 | $this->set_description("Listing of the last changes done on the framework behind Jacob Emerick's websites. Yeah, he's down with that version control."); |
14 | 13 | $this->set_keywords(array('changelog', 'version control', 'code', 'comments', 'Jacob Emerick')); |
@@ -16,8 +15,7 @@ discard block |
||
16 | 15 | parent::set_head_data(); |
17 | 16 | } |
18 | 17 | |
19 | - protected function set_body_data() |
|
20 | - { |
|
18 | + protected function set_body_data() { |
|
21 | 19 | parent::set_body_data(); |
22 | 20 | |
23 | 21 | $this->set_body('top_data', array('title' => 'Change Log')); |
@@ -26,8 +24,7 @@ discard block |
||
26 | 24 | $this->set_body('body_view', 'Changelog'); |
27 | 25 | } |
28 | 26 | |
29 | - private function get_changelog() |
|
30 | - { |
|
27 | + private function get_changelog() { |
|
31 | 28 | global $container; |
32 | 29 | $changelogRepository = new MysqlChangelogRepository($container['db_connection_locator']); |
33 | 30 | $changelog_result = $changelogRepository->getChanges(40); |
@@ -2,8 +2,8 @@ discard block |
||
2 | 2 | |
3 | 3 | Loader::load('controller', '/PageController'); |
4 | 4 | |
5 | -abstract class DefaultPageController extends PageController |
|
6 | -{ |
|
5 | +abstract class DefaultPageController extends PageController |
|
6 | +{ |
|
7 | 7 | |
8 | 8 | private static $MENU = array( |
9 | 9 | array( |
@@ -19,14 +19,12 @@ discard block |
||
19 | 19 | 'name' => 'Contact', |
20 | 20 | 'uri' => 'contact')); |
21 | 21 | |
22 | - protected function set_head_data() |
|
23 | - { |
|
22 | + protected function set_head_data() { |
|
24 | 23 | $this->add_css('reset'); |
25 | 24 | $this->add_css('site'); |
26 | 25 | } |
27 | 26 | |
28 | - protected function set_body_data() |
|
29 | - { |
|
27 | + protected function set_body_data() { |
|
30 | 28 | $this->set_body('top_data', array()); |
31 | 29 | $this->set_body('body_data', array()); |
32 | 30 | |
@@ -36,8 +34,7 @@ discard block |
||
36 | 34 | $this->set_body_view('Page'); |
37 | 35 | } |
38 | 36 | |
39 | - private function get_menu() |
|
40 | - { |
|
37 | + private function get_menu() { |
|
41 | 38 | $active_page = $this->get_active_page(); |
42 | 39 | |
43 | 40 | $menu = array(); |
@@ -52,18 +49,19 @@ discard block |
||
52 | 49 | return $menu; |
53 | 50 | } |
54 | 51 | |
55 | - private function get_active_page() |
|
56 | - { |
|
52 | + private function get_active_page() { |
|
57 | 53 | $current_uri = URLDecode::getPiece(1); |
58 | 54 | |
59 | - if(!isset($current_uri)) |
|
60 | - return 'About'; |
|
55 | + if(!isset($current_uri)) { |
|
56 | + return 'About'; |
|
57 | + } |
|
61 | 58 | |
62 | 59 | $menu = self::$MENU; |
63 | 60 | foreach($menu as $link) |
64 | 61 | { |
65 | - if($link['uri'] == $current_uri) |
|
66 | - return $link['name']; |
|
62 | + if($link['uri'] == $current_uri) { |
|
63 | + return $link['name']; |
|
64 | + } |
|
67 | 65 | } |
68 | 66 | |
69 | 67 | return 'About'; |
@@ -4,11 +4,10 @@ discard block |
||
4 | 4 | Loader::load('utility', array( |
5 | 5 | 'Validate')); |
6 | 6 | |
7 | -final class ContactController extends DefaultPageController |
|
8 | -{ |
|
7 | +final class ContactController extends DefaultPageController |
|
8 | +{ |
|
9 | 9 | |
10 | - protected function set_head_data() |
|
11 | - { |
|
10 | + protected function set_head_data() { |
|
12 | 11 | $this->set_title("Contact Form for Jacob Emerick's Sites"); |
13 | 12 | $this->set_description("Want to reach out to Jacob Emerick with questions or concerns? Well, then here's a handy contact form for you that will connect you with the man himself."); |
14 | 13 | $this->set_keywords(array('contact', 'webmaster', 'support', 'help', 'Jacob Emerick')); |
@@ -16,8 +15,7 @@ discard block |
||
16 | 15 | parent::set_head_data(); |
17 | 16 | } |
18 | 17 | |
19 | - protected function set_body_data() |
|
20 | - { |
|
18 | + protected function set_body_data() { |
|
21 | 19 | parent::set_body_data(); |
22 | 20 | |
23 | 21 | $this->set_body('top_data', array('title' => 'Contact Me')); |
@@ -26,17 +24,20 @@ discard block |
||
26 | 24 | $this->set_body('body_view', 'Contact'); |
27 | 25 | } |
28 | 26 | |
29 | - private function get_form_results() |
|
30 | - { |
|
31 | - if(!Request::hasPost()) |
|
32 | - return array(); |
|
27 | + private function get_form_results() { |
|
28 | + if(!Request::hasPost()) { |
|
29 | + return array(); |
|
30 | + } |
|
33 | 31 | |
34 | - if(!Validate::checkRequest('post', 'name', 'string')) |
|
35 | - $error_message['name'] = 'Please enter a value for your name.'; |
|
36 | - if(!Validate::checkRequest('post', 'email', 'string')) |
|
37 | - $error_message['email'] = 'Please enter a valid email address.'; |
|
38 | - if(!Validate::checkRequest('post', 'message', 'string')) |
|
39 | - $error_message['message'] = 'Please enter a message.'; |
|
32 | + if(!Validate::checkRequest('post', 'name', 'string')) { |
|
33 | + $error_message['name'] = 'Please enter a value for your name.'; |
|
34 | + } |
|
35 | + if(!Validate::checkRequest('post', 'email', 'string')) { |
|
36 | + $error_message['email'] = 'Please enter a valid email address.'; |
|
37 | + } |
|
38 | + if(!Validate::checkRequest('post', 'message', 'string')) { |
|
39 | + $error_message['message'] = 'Please enter a message.'; |
|
40 | + } |
|
40 | 41 | |
41 | 42 | if(!empty($error_message)) |
42 | 43 | { |
@@ -2,11 +2,10 @@ discard block |
||
2 | 2 | |
3 | 3 | Loader::load('controller', 'site/DefaultPageController'); |
4 | 4 | |
5 | -final class HomeController extends DefaultPageController |
|
6 | -{ |
|
5 | +final class HomeController extends DefaultPageController |
|
6 | +{ |
|
7 | 7 | |
8 | - protected function set_head_data() |
|
9 | - { |
|
8 | + protected function set_head_data() { |
|
10 | 9 | $this->set_title("Jacob Emerick's Site Information | General and Technical Information"); |
11 | 10 | $this->set_description("Meta information about Jacob Emerick's websites and content. Introduces the man behind the code, discusses the reasons behind the sites, and goes into some technical background of the custom framework."); |
12 | 11 | $this->set_keywords(array('site', 'technical', 'support', 'help', 'information', 'Jacob Emerick')); |
@@ -14,8 +13,7 @@ discard block |
||
14 | 13 | parent::set_head_data(); |
15 | 14 | } |
16 | 15 | |
17 | - protected function set_body_data() |
|
18 | - { |
|
16 | + protected function set_body_data() { |
|
19 | 17 | $this->set_body('body_view', 'Home'); |
20 | 18 | |
21 | 19 | parent::set_body_data(); |
@@ -2,11 +2,10 @@ |
||
2 | 2 | |
3 | 3 | Loader::load('controller', '/PageController'); |
4 | 4 | |
5 | -class Error303Controller extends PageController |
|
6 | -{ |
|
5 | +class Error303Controller extends PageController |
|
6 | +{ |
|
7 | 7 | |
8 | - public function __construct($uri) |
|
9 | - { |
|
8 | + public function __construct($uri) { |
|
10 | 9 | Header::redirect($uri, 303); |
11 | 10 | exit; |
12 | 11 | } |
@@ -2,11 +2,10 @@ discard block |
||
2 | 2 | |
3 | 3 | Loader::load('controller', '/PageController'); |
4 | 4 | |
5 | -class Error404Controller extends PageController |
|
6 | -{ |
|
5 | +class Error404Controller extends PageController |
|
6 | +{ |
|
7 | 7 | |
8 | - protected function set_head_data() |
|
9 | - { |
|
8 | + protected function set_head_data() { |
|
10 | 9 | $this->set_header_method('send404'); |
11 | 10 | $this->add_css('normalize'); |
12 | 11 | $this->add_css('404'); |
@@ -16,15 +15,13 @@ discard block |
||
16 | 15 | $this->set_head('keywords', ''); |
17 | 16 | } |
18 | 17 | |
19 | - protected function set_body_data() |
|
20 | - { |
|
18 | + protected function set_body_data() { |
|
21 | 19 | $this->set_body('site_list', $this->get_sites()); |
22 | 20 | |
23 | 21 | $this->set_body_view('/404'); |
24 | 22 | } |
25 | 23 | |
26 | - private function get_sites() |
|
27 | - { |
|
24 | + private function get_sites() { |
|
28 | 25 | return [ |
29 | 26 | [ |
30 | 27 | 'url' => 'https://home.jacobemerick.com/', |
@@ -1,26 +1,26 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -class URLDecode |
|
4 | -{ |
|
3 | +class URLDecode |
|
4 | +{ |
|
5 | 5 | |
6 | 6 | private static $array = array(); |
7 | 7 | |
8 | - static function init() |
|
9 | - { |
|
8 | + static function init() { |
|
10 | 9 | $host = $_SERVER['HTTP_HOST']; |
11 | 10 | $uri = $_SERVER['REQUEST_URI']; |
12 | 11 | self::form_url_array($host, $uri); |
13 | 12 | } |
14 | 13 | |
15 | - static private function form_url_array($host, $uri) |
|
16 | - { |
|
14 | + static private function form_url_array($host, $uri) { |
|
17 | 15 | $uri = substr($uri, 1); |
18 | - if(strpos($uri, '?')) |
|
19 | - $uri = substr($uri, 0, strpos($uri, '?')); |
|
16 | + if(strpos($uri, '?')) { |
|
17 | + $uri = substr($uri, 0, strpos($uri, '?')); |
|
18 | + } |
|
20 | 19 | $uri_array = explode('/', $uri); |
21 | 20 | |
22 | - if(!Loader::isLive()) |
|
23 | - $host = substr($host, strpos($host, '.') + 1); |
|
21 | + if(!Loader::isLive()) { |
|
22 | + $host = substr($host, strpos($host, '.') + 1); |
|
23 | + } |
|
24 | 24 | |
25 | 25 | self::$array['host'] = $host; |
26 | 26 | |
@@ -43,50 +43,49 @@ discard block |
||
43 | 43 | self::$array['base'] = $base; |
44 | 44 | self::$array['uri'] = '/' . implode('/', $uri_array); |
45 | 45 | |
46 | - if(end($uri_array) == '') |
|
47 | - $uri_array = array_slice($uri_array, 0, count($uri_array) - 1); |
|
46 | + if(end($uri_array) == '') { |
|
47 | + $uri_array = array_slice($uri_array, 0, count($uri_array) - 1); |
|
48 | + } |
|
48 | 49 | self::$array['pieces'] = (array) $uri_array; |
49 | 50 | } |
50 | 51 | |
51 | - static function getSite() |
|
52 | - { |
|
52 | + static function getSite() { |
|
53 | 53 | return self::$array['site']; |
54 | 54 | } |
55 | 55 | |
56 | - static function getHost() |
|
57 | - { |
|
56 | + static function getHost() { |
|
58 | 57 | return self::$array['host']; |
59 | 58 | } |
60 | 59 | |
61 | - static function getBase() |
|
62 | - { |
|
60 | + static function getBase() { |
|
63 | 61 | return self::$array['base']; |
64 | 62 | } |
65 | 63 | |
66 | - static function getURI() |
|
67 | - { |
|
64 | + static function getURI() { |
|
68 | 65 | return self::$array['uri']; |
69 | 66 | } |
70 | 67 | |
71 | - static function getExtension() |
|
72 | - { |
|
68 | + static function getExtension() { |
|
73 | 69 | $file = self::getPiece(-1); |
74 | - if(substr($file, -1) == '/') |
|
75 | - return false; |
|
70 | + if(substr($file, -1) == '/') { |
|
71 | + return false; |
|
72 | + } |
|
76 | 73 | return substr($file, strrpos($file, '.') + 1);; |
77 | 74 | } |
78 | 75 | |
79 | - static function getPiece($piece = null) |
|
80 | - { |
|
81 | - if(!$piece) |
|
82 | - return self::$array['pieces']; |
|
76 | + static function getPiece($piece = null) { |
|
77 | + if(!$piece) { |
|
78 | + return self::$array['pieces']; |
|
79 | + } |
|
83 | 80 | |
84 | - if($piece == -1) |
|
85 | - return end(self::$array['pieces']); |
|
81 | + if($piece == -1) { |
|
82 | + return end(self::$array['pieces']); |
|
83 | + } |
|
86 | 84 | |
87 | 85 | $piece = $piece - 1; |
88 | - if(array_key_exists($piece, self::$array['pieces'])) |
|
89 | - return self::$array['pieces'][$piece]; |
|
86 | + if(array_key_exists($piece, self::$array['pieces'])) { |
|
87 | + return self::$array['pieces'][$piece]; |
|
88 | + } |
|
90 | 89 | return; |
91 | 90 | } |
92 | 91 |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -final class Database |
|
4 | -{ |
|
3 | +final class Database |
|
4 | +{ |
|
5 | 5 | |
6 | 6 | private $read_connection; |
7 | 7 | private $write_connection; |
@@ -14,8 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | private static $instance; |
16 | 16 | |
17 | - private function __construct($write_params, $read_params) |
|
18 | - { |
|
17 | + private function __construct($write_params, $read_params) { |
|
19 | 18 | $this->write_connection = $this->connect( |
20 | 19 | $write_params->host, |
21 | 20 | $write_params->user, |
@@ -31,19 +30,18 @@ discard block |
||
31 | 30 | return $this; |
32 | 31 | } |
33 | 32 | |
34 | - private function connect($host, $username, $password) |
|
35 | - { |
|
33 | + private function connect($host, $username, $password) { |
|
36 | 34 | $mysqli = new mysqli($host, $username, $password); |
37 | 35 | |
38 | 36 | $has_connection_error = $mysqli->connect_error; |
39 | - if(isset($has_connection_error)) |
|
40 | - $this->has_connection_error = true; |
|
37 | + if(isset($has_connection_error)) { |
|
38 | + $this->has_connection_error = true; |
|
39 | + } |
|
41 | 40 | |
42 | 41 | return $mysqli; |
43 | 42 | } |
44 | 43 | |
45 | - public static function instance() |
|
46 | - { |
|
44 | + public static function instance() { |
|
47 | 45 | if(!isset(self::$instance)) { |
48 | 46 | global $config; |
49 | 47 | self::$instance = new Database( |
@@ -55,20 +53,19 @@ discard block |
||
55 | 53 | return self::$instance; |
56 | 54 | } |
57 | 55 | |
58 | - public static function escape($string) |
|
59 | - { |
|
56 | + public static function escape($string) { |
|
60 | 57 | return self::instance()->read_connection->real_escape_string($string); |
61 | 58 | } |
62 | 59 | |
63 | - public static function select($query) |
|
64 | - { |
|
60 | + public static function select($query) { |
|
65 | 61 | $start = microtime(true); |
66 | 62 | if($result = self::instance()->read_connection->query($query)) |
67 | 63 | { |
68 | 64 | self::instance()->log_query($query, $start); |
69 | 65 | $array = array(); |
70 | - while($row = $result->fetch_object()) |
|
71 | - $array[] = $row; |
|
66 | + while($row = $result->fetch_object()) { |
|
67 | + $array[] = $row; |
|
68 | + } |
|
72 | 69 | $result->close(); |
73 | 70 | return $array; |
74 | 71 | } |
@@ -76,16 +73,15 @@ discard block |
||
76 | 73 | return false; |
77 | 74 | } |
78 | 75 | |
79 | - public static function selectRow($query) |
|
80 | - { |
|
76 | + public static function selectRow($query) { |
|
81 | 77 | $result = self::select($query); |
82 | - if(is_array($result)) |
|
83 | - return array_pop($result); |
|
78 | + if(is_array($result)) { |
|
79 | + return array_pop($result); |
|
80 | + } |
|
84 | 81 | return false; |
85 | 82 | } |
86 | 83 | |
87 | - public static function execute($query) |
|
88 | - { |
|
84 | + public static function execute($query) { |
|
89 | 85 | $start = microtime(true); |
90 | 86 | if(self::instance()->write_connection->query($query)) |
91 | 87 | { |
@@ -96,16 +92,15 @@ discard block |
||
96 | 92 | return false; |
97 | 93 | } |
98 | 94 | |
99 | - public static function lastInsertID() |
|
100 | - { |
|
95 | + public static function lastInsertID() { |
|
101 | 96 | $id = self::instance()->write_connection->insert_id; |
102 | - if($id == 0) |
|
103 | - return false; |
|
97 | + if($id == 0) { |
|
98 | + return false; |
|
99 | + } |
|
104 | 100 | return $id; |
105 | 101 | } |
106 | 102 | |
107 | - private function log_query($query, $start) |
|
108 | - { |
|
103 | + private function log_query($query, $start) { |
|
109 | 104 | $time = (microtime(true) - $start) * 1000; |
110 | 105 | $query = array( |
111 | 106 | 'sql' => $query, |
@@ -116,8 +111,7 @@ discard block |
||
116 | 111 | $this->query_total['time'] += $time; |
117 | 112 | } |
118 | 113 | |
119 | - private function gather_query_data() |
|
120 | - { |
|
114 | + private function gather_query_data() { |
|
121 | 115 | $query_data = array(); |
122 | 116 | foreach($this->query_log as $query) |
123 | 117 | { |
@@ -127,8 +121,7 @@ discard block |
||
127 | 121 | return $query_data; |
128 | 122 | } |
129 | 123 | |
130 | - public static function explain($query) |
|
131 | - { |
|
124 | + public static function explain($query) { |
|
132 | 125 | $sql = 'EXPLAIN ' . $query['sql']; |
133 | 126 | |
134 | 127 | if($result = self::instance()->read_connection->query($sql)) |
@@ -140,18 +133,15 @@ discard block |
||
140 | 133 | return $query; |
141 | 134 | } |
142 | 135 | |
143 | - public static function getQueryLog() |
|
144 | - { |
|
136 | + public static function getQueryLog() { |
|
145 | 137 | return self::instance()->gather_query_data(); |
146 | 138 | } |
147 | 139 | |
148 | - public static function getQueryTotals() |
|
149 | - { |
|
140 | + public static function getQueryTotals() { |
|
150 | 141 | return self::instance()->query_total; |
151 | 142 | } |
152 | 143 | |
153 | - public static function isConnected() |
|
154 | - { |
|
144 | + public static function isConnected() { |
|
155 | 145 | return !self::instance()->has_connection_error; |
156 | 146 | } |
157 | 147 |