@@ -1,7 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | $namespace = 'blog'; |
| 4 | -require_once __DIR__ . '/../../bootstrap.php'; |
|
| 4 | +require_once __DIR__.'/../../bootstrap.php'; |
|
| 5 | 5 | |
| 6 | 6 | // route |
| 7 | 7 | Loader::loadInstance('router', 'Router'); |
@@ -1,7 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | $namespace = 'portfolio'; |
| 4 | -require_once __DIR__ . '/../../bootstrap.php'; |
|
| 4 | +require_once __DIR__.'/../../bootstrap.php'; |
|
| 5 | 5 | |
| 6 | 6 | // route |
| 7 | 7 | Loader::loadInstance('router', 'Router'); |
@@ -10,8 +10,8 @@ discard block |
||
| 10 | 10 | 'Cache-Control: no-cache', |
| 11 | 11 | 'Content-Language: en', |
| 12 | 12 | 'Content-Type: application/json', |
| 13 | - 'Expires: ' . self::get_date(time() - 1), |
|
| 14 | - 'Last-Modified: ' . self::get_date(), |
|
| 13 | + 'Expires: '.self::get_date(time() - 1), |
|
| 14 | + 'Last-Modified: '.self::get_date(), |
|
| 15 | 15 | 'X-Powered-By: jacobemerick.com'); |
| 16 | 16 | self::send($array); |
| 17 | 17 | } |
@@ -23,8 +23,8 @@ discard block |
||
| 23 | 23 | 'Cache-Control: no-cache', |
| 24 | 24 | 'Content-Language: en', |
| 25 | 25 | 'Content-Type: text/html', |
| 26 | - 'Expires: ' . self::get_date(time() - 1), |
|
| 27 | - 'Last-Modified: ' . self::get_date(), |
|
| 26 | + 'Expires: '.self::get_date(time() - 1), |
|
| 27 | + 'Last-Modified: '.self::get_date(), |
|
| 28 | 28 | 'X-Powered-By: jacobemerick.com'); |
| 29 | 29 | self::send($array); |
| 30 | 30 | } |
@@ -42,8 +42,8 @@ discard block |
||
| 42 | 42 | 'Cache-Control: no-cache', |
| 43 | 43 | 'Content-Language: en', |
| 44 | 44 | 'Content-Type: text/html', |
| 45 | - 'Expires: ' . self::get_date(time() - 1), |
|
| 46 | - 'Last-Modified: ' . self::get_date(), |
|
| 45 | + 'Expires: '.self::get_date(time() - 1), |
|
| 46 | + 'Last-Modified: '.self::get_date(), |
|
| 47 | 47 | 'X-Powered-By: jacobemerick.com'); |
| 48 | 48 | self::send($array); |
| 49 | 49 | } |
@@ -55,18 +55,18 @@ discard block |
||
| 55 | 55 | 'Cache-Control: no-cache', |
| 56 | 56 | 'Content-Language: en', |
| 57 | 57 | 'Content-Type: text/html', |
| 58 | - 'Expires: ' . self::get_date(time() - 1), |
|
| 59 | - 'Last-Modified: ' . self::get_date(), |
|
| 58 | + 'Expires: '.self::get_date(time() - 1), |
|
| 59 | + 'Last-Modified: '.self::get_date(), |
|
| 60 | 60 | 'X-Powered-By: jacobemerick.com'); |
| 61 | 61 | self::send($array); |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | private static function send($array, $gzip = true) |
| 65 | 65 | { |
| 66 | - if($gzip) |
|
| 66 | + if ($gzip) |
|
| 67 | 67 | self::start_gzipping(); |
| 68 | 68 | |
| 69 | - foreach($array as $row) |
|
| 69 | + foreach ($array as $row) |
|
| 70 | 70 | { |
| 71 | 71 | header($row, TRUE); |
| 72 | 72 | } |
@@ -74,14 +74,14 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | private static function get_date($timestamp = false) |
| 76 | 76 | { |
| 77 | - if($timestamp == 0) |
|
| 77 | + if ($timestamp == 0) |
|
| 78 | 78 | $timestamp = time(); |
| 79 | 79 | return gmdate('D, d M Y H:i:s \G\M\T', $timestamp); |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | private static function start_gzipping() |
| 83 | 83 | { |
| 84 | - if(!ob_start('ob_gzhandler')) |
|
| 84 | + if (!ob_start('ob_gzhandler')) |
|
| 85 | 85 | ob_start(); |
| 86 | 86 | } |
| 87 | 87 | |
@@ -26,16 +26,16 @@ discard block |
||
| 26 | 26 | |
| 27 | 27 | switch ($type) { |
| 28 | 28 | case 'full miles' : |
| 29 | - $this->content = number_format(round($number / (12 * 3 * 1760))) . ' miles'; |
|
| 29 | + $this->content = number_format(round($number / (12 * 3 * 1760))).' miles'; |
|
| 30 | 30 | break; |
| 31 | 31 | case 'tenth miles' : |
| 32 | - $this->content = round($number / (12 * 3 * 1760), 1) . ' miles'; |
|
| 32 | + $this->content = round($number / (12 * 3 * 1760), 1).' miles'; |
|
| 33 | 33 | break; |
| 34 | 34 | case 'yards' : |
| 35 | - $this->content = number_format(round($number / (12 * 3))) . ' yards'; |
|
| 35 | + $this->content = number_format(round($number / (12 * 3))).' yards'; |
|
| 36 | 36 | break; |
| 37 | 37 | case 'feet' : |
| 38 | - $this->content = number_format(round($number / 12)) . "'"; |
|
| 38 | + $this->content = number_format(round($number / 12))."'"; |
|
| 39 | 39 | break; |
| 40 | 40 | case 'inches' : |
| 41 | 41 | $feet = floor($number / 12); |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | $this->content = ''; |
| 52 | - $this->content .= number_format($feet) . "'"; |
|
| 52 | + $this->content .= number_format($feet)."'"; |
|
| 53 | 53 | if (isset($inches) && $inches > 0) { |
| 54 | 54 | $this->content .= " {$inches}\""; |
| 55 | 55 | } |
@@ -40,10 +40,10 @@ discard block |
||
| 40 | 40 | { |
| 41 | 41 | $match_count = preg_match_all($pattern, $this->content, $matches, PREG_SET_ORDER); |
| 42 | 42 | |
| 43 | - if($match_count < 1) |
|
| 43 | + if ($match_count < 1) |
|
| 44 | 44 | return; |
| 45 | 45 | |
| 46 | - foreach($matches as $match) |
|
| 46 | + foreach ($matches as $match) |
|
| 47 | 47 | { |
| 48 | 48 | $full_match = array_shift($match); |
| 49 | 49 | $placeholder = $this->create_placeholder($full_match); |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | private function create_placeholder($text) |
| 58 | 58 | { |
| 59 | - return md5($text . rand()); |
|
| 59 | + return md5($text.rand()); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | private function create_full_match_pattern($text) |
@@ -79,10 +79,10 @@ discard block |
||
| 79 | 79 | { |
| 80 | 80 | $match_count = preg_match_all($pattern, $this->content, $matches, PREG_SET_ORDER); |
| 81 | 81 | |
| 82 | - if($match_count < 1) |
|
| 82 | + if ($match_count < 1) |
|
| 83 | 83 | return; |
| 84 | 84 | |
| 85 | - foreach($matches as $match) |
|
| 85 | + foreach ($matches as $match) |
|
| 86 | 86 | { |
| 87 | 87 | $full_match = array_shift($match); |
| 88 | 88 | $full_match_pattern = $this->create_full_match_pattern($full_match); |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | |
| 100 | 100 | private function replace_element_patterns() |
| 101 | 101 | { |
| 102 | - foreach($this->replacement_array as $key => $replace) |
|
| 102 | + foreach ($this->replacement_array as $key => $replace) |
|
| 103 | 103 | { |
| 104 | 104 | $this->content = str_replace($key, $replace, $this->content); |
| 105 | 105 | } |
@@ -27,20 +27,20 @@ discard block |
||
| 27 | 27 | protected function execute() |
| 28 | 28 | { |
| 29 | 29 | $args = func_get_args(); |
| 30 | - if(count($args) < 1) |
|
| 30 | + if (count($args) < 1) |
|
| 31 | 31 | { |
| 32 | 32 | trigger_error('Someone called SmartTrimContent w/o defining a length... bad!'); |
| 33 | 33 | return; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - if(count($args) == 2) |
|
| 36 | + if (count($args) == 2) |
|
| 37 | 37 | $etc = $args[1]; |
| 38 | 38 | else |
| 39 | 39 | $etc = self::$ETC; |
| 40 | 40 | |
| 41 | 41 | $length = $args[0]; |
| 42 | 42 | |
| 43 | - if($length < strlen($this->content)) |
|
| 43 | + if ($length < strlen($this->content)) |
|
| 44 | 44 | $this->trim_string($length); |
| 45 | 45 | else |
| 46 | 46 | $etc = ''; |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | $last_right_bracket_position = strripos($content, self::$RIGHT_BRACKET); |
| 56 | 56 | $last_left_bracket_position = strripos($content, self::$LEFT_BRACKET); |
| 57 | - if($last_left_bracket_position > $last_right_bracket_position) |
|
| 57 | + if ($last_left_bracket_position > $last_right_bracket_position) |
|
| 58 | 58 | $content = substr($content, 0, $last_left_bracket_position); |
| 59 | 59 | $content = trim($content); |
| 60 | 60 | |
@@ -73,16 +73,16 @@ discard block |
||
| 73 | 73 | $content = current($content); |
| 74 | 74 | |
| 75 | 75 | $max_length = $length; |
| 76 | - foreach($matches[0] as $match) |
|
| 76 | + foreach ($matches[0] as $match) |
|
| 77 | 77 | { |
| 78 | 78 | $max_length += strlen($match[0]); |
| 79 | - if($max_length <= $match[1]) |
|
| 79 | + if ($max_length <= $match[1]) |
|
| 80 | 80 | break; |
| 81 | 81 | |
| 82 | - $content = substr($content, 0, $match[1]) . $match[0] . substr($content, $match[1]); |
|
| 82 | + $content = substr($content, 0, $match[1]).$match[0].substr($content, $match[1]); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - if(substr($content, -7) == '</p><p>') |
|
| 85 | + if (substr($content, -7) == '</p><p>') |
|
| 86 | 86 | $content = substr($content, 0, -7); |
| 87 | 87 | |
| 88 | 88 | return $content; |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | $tags_preg = $this->get_tags_preg(self::$EXCLUDE_TAGS); |
| 95 | 95 | preg_match_all($tags_preg, $content, $matches, PREG_OFFSET_CAPTURE); |
| 96 | 96 | |
| 97 | - if(count($matches[1]) % 2 == 1) |
|
| 97 | + if (count($matches[1]) % 2 == 1) |
|
| 98 | 98 | { |
| 99 | 99 | $cut_tag = end($matches[1]); |
| 100 | 100 | $cut_tag_position = $cut_tag[1] - 1; |
@@ -112,9 +112,9 @@ discard block |
||
| 112 | 112 | preg_match_all($tags_preg, $content, $matches); |
| 113 | 113 | $open_tags = array(); |
| 114 | 114 | |
| 115 | - foreach($matches[1] as $tag) |
|
| 115 | + foreach ($matches[1] as $tag) |
|
| 116 | 116 | { |
| 117 | - if(in_array($tag, $open_tags)) |
|
| 117 | + if (in_array($tag, $open_tags)) |
|
| 118 | 118 | { |
| 119 | 119 | $key = array_search($tag, $open_tags); |
| 120 | 120 | unset($open_tags[$key]); |
@@ -124,11 +124,11 @@ discard block |
||
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | $open_tags = array_reverse($open_tags); |
| 127 | - if(count($open_tags) > 0) |
|
| 127 | + if (count($open_tags) > 0) |
|
| 128 | 128 | { |
| 129 | - foreach($open_tags as $key => $open_tag) |
|
| 129 | + foreach ($open_tags as $key => $open_tag) |
|
| 130 | 130 | { |
| 131 | - if($key == count($open_tags) - 1) |
|
| 131 | + if ($key == count($open_tags) - 1) |
|
| 132 | 132 | $content .= $etc; |
| 133 | 133 | $content .= "</{$open_tag}>"; |
| 134 | 134 | } |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | |
| 142 | 142 | private function get_tags_preg($tag_array) |
| 143 | 143 | { |
| 144 | - return '@</?(' . implode('|', $tag_array) . ')@'; |
|
| 144 | + return '@</?('.implode('|', $tag_array).')@'; |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | } |
@@ -15,11 +15,11 @@ discard block |
||
| 15 | 15 | static private function form_url_array($host, $uri) |
| 16 | 16 | { |
| 17 | 17 | $uri = substr($uri, 1); |
| 18 | - if(strpos($uri, '?')) |
|
| 18 | + if (strpos($uri, '?')) |
|
| 19 | 19 | $uri = substr($uri, 0, strpos($uri, '?')); |
| 20 | 20 | $uri_array = explode('/', $uri); |
| 21 | 21 | |
| 22 | - if(!Loader::isLive()) |
|
| 22 | + if (!Loader::isLive()) |
|
| 23 | 23 | $host = substr($host, strpos($host, '.') + 1); |
| 24 | 24 | |
| 25 | 25 | self::$array['host'] = $host; |
@@ -41,9 +41,9 @@ discard block |
||
| 41 | 41 | $base .= '/'; |
| 42 | 42 | |
| 43 | 43 | self::$array['base'] = $base; |
| 44 | - self::$array['uri'] = '/' . implode('/', $uri_array); |
|
| 44 | + self::$array['uri'] = '/'.implode('/', $uri_array); |
|
| 45 | 45 | |
| 46 | - if(end($uri_array) == '') |
|
| 46 | + if (end($uri_array) == '') |
|
| 47 | 47 | $uri_array = array_slice($uri_array, 0, count($uri_array) - 1); |
| 48 | 48 | self::$array['pieces'] = (array) $uri_array; |
| 49 | 49 | } |
@@ -71,21 +71,21 @@ discard block |
||
| 71 | 71 | static function getExtension() |
| 72 | 72 | { |
| 73 | 73 | $file = self::getPiece(-1); |
| 74 | - if(substr($file, -1) == '/') |
|
| 74 | + if (substr($file, -1) == '/') |
|
| 75 | 75 | return false; |
| 76 | - return substr($file, strrpos($file, '.') + 1);; |
|
| 76 | + return substr($file, strrpos($file, '.') + 1); ; |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | static function getPiece($piece = null) |
| 80 | 80 | { |
| 81 | - if(!$piece) |
|
| 81 | + if (!$piece) |
|
| 82 | 82 | return self::$array['pieces']; |
| 83 | 83 | |
| 84 | - if($piece == -1) |
|
| 84 | + if ($piece == -1) |
|
| 85 | 85 | return end(self::$array['pieces']); |
| 86 | 86 | |
| 87 | 87 | $piece = $piece - 1; |
| 88 | - if(array_key_exists($piece, self::$array['pieces'])) |
|
| 88 | + if (array_key_exists($piece, self::$array['pieces'])) |
|
| 89 | 89 | return self::$array['pieces'][$piece]; |
| 90 | 90 | return; |
| 91 | 91 | } |
@@ -17,14 +17,14 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | public static function instance() |
| 19 | 19 | { |
| 20 | - if(!isset(self::$instance)) |
|
| 20 | + if (!isset(self::$instance)) |
|
| 21 | 21 | self::$instance = new Loader(); |
| 22 | 22 | return self::$instance; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | private function get_root() |
| 26 | 26 | { |
| 27 | - if(!isset($this->root)) |
|
| 27 | + if (!isset($this->root)) |
|
| 28 | 28 | { |
| 29 | 29 | $current_directory = dirname(__FILE__); |
| 30 | 30 | $current_directory = substr($current_directory, 0, -7); |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | private static function get_extension($type) |
| 54 | 54 | { |
| 55 | - switch($type) |
|
| 55 | + switch ($type) |
|
| 56 | 56 | { |
| 57 | 57 | case 'collector' : |
| 58 | 58 | case 'controller' : |
@@ -104,15 +104,15 @@ discard block |
||
| 104 | 104 | |
| 105 | 105 | public static function load($type, $files, $data = array()) |
| 106 | 106 | { |
| 107 | - foreach((array) $files as $file) |
|
| 107 | + foreach ((array) $files as $file) |
|
| 108 | 108 | { |
| 109 | 109 | $file_path = self::instance()->get_path($type, $file); |
| 110 | - if(in_array($file_path, self::instance()->get_included_files()) && $type !== 'view') |
|
| 110 | + if (in_array($file_path, self::instance()->get_included_files()) && $type !== 'view') |
|
| 111 | 111 | continue; |
| 112 | 112 | |
| 113 | 113 | self::instance()->add_included_file($file_path); |
| 114 | 114 | |
| 115 | - switch($type) |
|
| 115 | + switch ($type) |
|
| 116 | 116 | { |
| 117 | 117 | case 'images' : |
| 118 | 118 | case 'scripts' : |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | |
| 143 | 143 | $reflectionObject = self::create_reflection_class($file); |
| 144 | 144 | |
| 145 | - if( |
|
| 145 | + if ( |
|
| 146 | 146 | $reflectionObject->hasMethod('instance') && |
| 147 | 147 | $reflectionObject->getMethod('instance')->isStatic()) |
| 148 | 148 | { |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | |
| 158 | 158 | $reflectionObject = self::create_reflection_class($file); |
| 159 | 159 | |
| 160 | - if($reflectionObject->hasMethod('__construct')) |
|
| 160 | + if ($reflectionObject->hasMethod('__construct')) |
|
| 161 | 161 | return $reflectionObject->newInstanceArgs($data); |
| 162 | 162 | else |
| 163 | 163 | return $reflectionObject->newInstance(); |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | if ($site == 'waterfalls' && self::instance()->is_live) { |
| 181 | 181 | return "{$protocol}://www.waterfallsofthekeweenaw.com/"; |
| 182 | 182 | } else { |
| 183 | - return $protocol . '://' . (self::instance()->is_live ? '' : 'dev.') . $site . '.jacobemerick.com/'; |
|
| 183 | + return $protocol.'://'.(self::instance()->is_live ? '' : 'dev.').$site.'.jacobemerick.com/'; |
|
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | 186 | return '/'; |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | $mysqli = new mysqli($host, $username, $password); |
| 37 | 37 | |
| 38 | 38 | $has_connection_error = $mysqli->connect_error; |
| 39 | - if(isset($has_connection_error)) |
|
| 39 | + if (isset($has_connection_error)) |
|
| 40 | 40 | $this->has_connection_error = true; |
| 41 | 41 | |
| 42 | 42 | return $mysqli; |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | public static function instance() |
| 46 | 46 | { |
| 47 | - if(!isset(self::$instance)) { |
|
| 47 | + if (!isset(self::$instance)) { |
|
| 48 | 48 | global $config; |
| 49 | 49 | self::$instance = new Database( |
| 50 | 50 | $config->database->master, |
@@ -63,23 +63,23 @@ discard block |
||
| 63 | 63 | public static function select($query) |
| 64 | 64 | { |
| 65 | 65 | $start = microtime(true); |
| 66 | - if($result = self::instance()->read_connection->query($query)) |
|
| 66 | + if ($result = self::instance()->read_connection->query($query)) |
|
| 67 | 67 | { |
| 68 | 68 | self::instance()->log_query($query, $start); |
| 69 | 69 | $array = array(); |
| 70 | - while($row = $result->fetch_object()) |
|
| 70 | + while ($row = $result->fetch_object()) |
|
| 71 | 71 | $array[] = $row; |
| 72 | 72 | $result->close(); |
| 73 | 73 | return $array; |
| 74 | 74 | } |
| 75 | - trigger_error('Could not preform query - ' . $query . ' - ' . self::instance()->read_connection->error); |
|
| 75 | + trigger_error('Could not preform query - '.$query.' - '.self::instance()->read_connection->error); |
|
| 76 | 76 | return false; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | public static function selectRow($query) |
| 80 | 80 | { |
| 81 | 81 | $result = self::select($query); |
| 82 | - if(is_array($result)) |
|
| 82 | + if (is_array($result)) |
|
| 83 | 83 | return array_pop($result); |
| 84 | 84 | return false; |
| 85 | 85 | } |
@@ -87,19 +87,19 @@ discard block |
||
| 87 | 87 | public static function execute($query) |
| 88 | 88 | { |
| 89 | 89 | $start = microtime(true); |
| 90 | - if(self::instance()->write_connection->query($query)) |
|
| 90 | + if (self::instance()->write_connection->query($query)) |
|
| 91 | 91 | { |
| 92 | 92 | self::instance()->log_query($query, $start); |
| 93 | 93 | return true; |
| 94 | 94 | } |
| 95 | - trigger_error('Could not preform query - ' . $query . '-' . self::instance()->write_connection->error); |
|
| 95 | + trigger_error('Could not preform query - '.$query.'-'.self::instance()->write_connection->error); |
|
| 96 | 96 | return false; |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | public static function lastInsertID() |
| 100 | 100 | { |
| 101 | 101 | $id = self::instance()->write_connection->insert_id; |
| 102 | - if($id == 0) |
|
| 102 | + if ($id == 0) |
|
| 103 | 103 | return false; |
| 104 | 104 | return $id; |
| 105 | 105 | } |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | private function gather_query_data() |
| 120 | 120 | { |
| 121 | 121 | $query_data = array(); |
| 122 | - foreach($this->query_log as $query) |
|
| 122 | + foreach ($this->query_log as $query) |
|
| 123 | 123 | { |
| 124 | 124 | $query = self::explain($query); |
| 125 | 125 | $query_data[] = $query; |
@@ -129,9 +129,9 @@ discard block |
||
| 129 | 129 | |
| 130 | 130 | public static function explain($query) |
| 131 | 131 | { |
| 132 | - $sql = 'EXPLAIN ' . $query['sql']; |
|
| 132 | + $sql = 'EXPLAIN '.$query['sql']; |
|
| 133 | 133 | |
| 134 | - if($result = self::instance()->read_connection->query($sql)) |
|
| 134 | + if ($result = self::instance()->read_connection->query($sql)) |
|
| 135 | 135 | { |
| 136 | 136 | $row = $result->fetch_assoc(); |
| 137 | 137 | $query['explain'] = $row; |