@@ -36,8 +36,9 @@ 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)) |
|
| 40 | - $this->has_connection_error = true; |
|
| 39 | + if(isset($has_connection_error)) {
|
|
| 40 | + $this->has_connection_error = true; |
|
| 41 | + } |
|
| 41 | 42 | |
| 42 | 43 | return $mysqli; |
| 43 | 44 | } |
@@ -67,8 +68,9 @@ discard block |
||
| 67 | 68 | { |
| 68 | 69 | self::instance()->log_query($query, $start); |
| 69 | 70 | $array = array(); |
| 70 | - while($row = $result->fetch_object()) |
|
| 71 | - $array[] = $row; |
|
| 71 | + while($row = $result->fetch_object()) {
|
|
| 72 | + $array[] = $row; |
|
| 73 | + } |
|
| 72 | 74 | $result->close(); |
| 73 | 75 | return $array; |
| 74 | 76 | } |
@@ -79,8 +81,9 @@ discard block |
||
| 79 | 81 | public static function selectRow($query) |
| 80 | 82 | { |
| 81 | 83 | $result = self::select($query); |
| 82 | - if(is_array($result)) |
|
| 83 | - return array_pop($result); |
|
| 84 | + if(is_array($result)) {
|
|
| 85 | + return array_pop($result); |
|
| 86 | + } |
|
| 84 | 87 | return false; |
| 85 | 88 | } |
| 86 | 89 | |
@@ -99,8 +102,9 @@ discard block |
||
| 99 | 102 | public static function lastInsertID() |
| 100 | 103 | { |
| 101 | 104 | $id = self::instance()->write_connection->insert_id; |
| 102 | - if($id == 0) |
|
| 103 | - return false; |
|
| 105 | + if($id == 0) {
|
|
| 106 | + return false; |
|
| 107 | + } |
|
| 104 | 108 | return $id; |
| 105 | 109 | } |
| 106 | 110 | |
@@ -17,8 +17,9 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | public static function instance() |
| 19 | 19 | { |
| 20 | - if(!isset(self::$instance)) |
|
| 21 | - self::$instance = new Loader(); |
|
| 20 | + if(!isset(self::$instance)) {
|
|
| 21 | + self::$instance = new Loader(); |
|
| 22 | + } |
|
| 22 | 23 | return self::$instance; |
| 23 | 24 | } |
| 24 | 25 | |
@@ -71,8 +72,9 @@ discard block |
||
| 71 | 72 | |
| 72 | 73 | public static function getImagePath($type, $file) |
| 73 | 74 | { |
| 74 | - if($type == 'photo') |
|
| 75 | - $type = 'photo/processed'; |
|
| 75 | + if($type == 'photo') {
|
|
| 76 | + $type = 'photo/processed'; |
|
| 77 | + } |
|
| 76 | 78 | |
| 77 | 79 | $path = self::instance()->get_root(); |
| 78 | 80 | $path .= 'images'; |
@@ -110,11 +112,13 @@ discard block |
||
| 110 | 112 | foreach((array) $files as $file) |
| 111 | 113 | { |
| 112 | 114 | $file_path = self::instance()->get_path($type, $file); |
| 113 | - if(in_array($file_path, self::instance()->get_included_files()) && $type !== 'view') |
|
| 114 | - continue; |
|
| 115 | + if(in_array($file_path, self::instance()->get_included_files()) && $type !== 'view') {
|
|
| 116 | + continue; |
|
| 117 | + } |
|
| 115 | 118 | |
| 116 | - if(!file_exists($file_path)) |
|
| 117 | - Debugger::logMessage("Requested file does not exist: {$type}, {$file}"); |
|
| 119 | + if(!file_exists($file_path)) {
|
|
| 120 | + Debugger::logMessage("Requested file does not exist: {$type}, {$file}");
|
|
| 121 | + } |
|
| 118 | 122 | |
| 119 | 123 | self::instance()->add_included_file($file_path); |
| 120 | 124 | |
@@ -163,10 +167,11 @@ discard block |
||
| 163 | 167 | |
| 164 | 168 | $reflectionObject = self::create_reflection_class($file); |
| 165 | 169 | |
| 166 | - if($reflectionObject->hasMethod('__construct')) |
|
| 167 | - return $reflectionObject->newInstanceArgs($data); |
|
| 168 | - else |
|
| 169 | - return $reflectionObject->newInstance(); |
|
| 170 | + if($reflectionObject->hasMethod('__construct')) {
|
|
| 171 | + return $reflectionObject->newInstanceArgs($data); |
|
| 172 | + } else {
|
|
| 173 | + return $reflectionObject->newInstance(); |
|
| 174 | + } |
|
| 170 | 175 | } |
| 171 | 176 | |
| 172 | 177 | public static function getRoot() |
@@ -15,12 +15,14 @@ discard block |
||
| 15 | 15 | static private function form_url_array($host, $uri) |
| 16 | 16 | { |
| 17 | 17 | $uri = substr($uri, 1); |
| 18 | - if(strpos($uri, '?')) |
|
| 19 | - $uri = substr($uri, 0, strpos($uri, '?')); |
|
| 18 | + if(strpos($uri, '?')) {
|
|
| 19 | + $uri = substr($uri, 0, strpos($uri, '?')); |
|
| 20 | + } |
|
| 20 | 21 | $uri_array = explode('/', $uri); |
| 21 | 22 | |
| 22 | - if(!Loader::isLive()) |
|
| 23 | - $host = substr($host, strpos($host, '.') + 1); |
|
| 23 | + if(!Loader::isLive()) {
|
|
| 24 | + $host = substr($host, strpos($host, '.') + 1); |
|
| 25 | + } |
|
| 24 | 26 | |
| 25 | 27 | self::$array['host'] = $host; |
| 26 | 28 | |
@@ -33,8 +35,9 @@ discard block |
||
| 33 | 35 | self::$array['base'] = 'http://' . (!Loader::isLive() ? 'dev.' : '') . $host . '/'; |
| 34 | 36 | self::$array['uri'] = '/' . implode('/', $uri_array); |
| 35 | 37 | |
| 36 | - if(end($uri_array) == '') |
|
| 37 | - $uri_array = array_slice($uri_array, 0, count($uri_array) - 1); |
|
| 38 | + if(end($uri_array) == '') {
|
|
| 39 | + $uri_array = array_slice($uri_array, 0, count($uri_array) - 1); |
|
| 40 | + } |
|
| 38 | 41 | self::$array['pieces'] = (array) $uri_array; |
| 39 | 42 | } |
| 40 | 43 | |
@@ -61,22 +64,26 @@ discard block |
||
| 61 | 64 | static function getExtension() |
| 62 | 65 | { |
| 63 | 66 | $file = self::getPiece(-1); |
| 64 | - if(substr($file, -1) == '/') |
|
| 65 | - return false; |
|
| 67 | + if(substr($file, -1) == '/') {
|
|
| 68 | + return false; |
|
| 69 | + } |
|
| 66 | 70 | return substr($file, strrpos($file, '.') + 1);; |
| 67 | 71 | } |
| 68 | 72 | |
| 69 | 73 | static function getPiece($piece = null) |
| 70 | 74 | { |
| 71 | - if(!$piece) |
|
| 72 | - return self::$array['pieces']; |
|
| 75 | + if(!$piece) {
|
|
| 76 | + return self::$array['pieces']; |
|
| 77 | + } |
|
| 73 | 78 | |
| 74 | - if($piece == -1) |
|
| 75 | - return end(self::$array['pieces']); |
|
| 79 | + if($piece == -1) {
|
|
| 80 | + return end(self::$array['pieces']); |
|
| 81 | + } |
|
| 76 | 82 | |
| 77 | 83 | $piece = $piece - 1; |
| 78 | - if(array_key_exists($piece, self::$array['pieces'])) |
|
| 79 | - return self::$array['pieces'][$piece]; |
|
| 84 | + if(array_key_exists($piece, self::$array['pieces'])) {
|
|
| 85 | + return self::$array['pieces'][$piece]; |
|
| 86 | + } |
|
| 80 | 87 | return; |
| 81 | 88 | } |
| 82 | 89 | |
@@ -21,8 +21,9 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | public function setValue($value) |
| 23 | 23 | { |
| 24 | - if(!$this->is_loaded) |
|
| 25 | - $this->load(); |
|
| 24 | + if(!$this->is_loaded) {
|
|
| 25 | + $this->load(); |
|
| 26 | + } |
|
| 26 | 27 | |
| 27 | 28 | $this->value = $value; |
| 28 | 29 | return $this; |
@@ -30,8 +31,9 @@ discard block |
||
| 30 | 31 | |
| 31 | 32 | public function getValue() |
| 32 | 33 | { |
| 33 | - if(!$this->is_loaded) |
|
| 34 | - $this->load(); |
|
| 34 | + if(!$this->is_loaded) {
|
|
| 35 | + $this->load(); |
|
| 36 | + } |
|
| 35 | 37 | return $this->value; |
| 36 | 38 | } |
| 37 | 39 | |
@@ -42,24 +44,26 @@ discard block |
||
| 42 | 44 | |
| 43 | 45 | public function exists() |
| 44 | 46 | { |
| 45 | - if(!$this->is_loaded) |
|
| 46 | - $this->load(); |
|
| 47 | + if(!$this->is_loaded) {
|
|
| 48 | + $this->load(); |
|
| 49 | + } |
|
| 47 | 50 | return $this->exists; |
| 48 | 51 | } |
| 49 | 52 | |
| 50 | 53 | private final function load() |
| 51 | 54 | { |
| 52 | 55 | $name = $this->getName(); |
| 53 | - if(isset($_COOKIE[$name])) |
|
| 54 | - $value = $_COOKIE[$name]; |
|
| 56 | + if(isset($_COOKIE[$name])) {
|
|
| 57 | + $value = $_COOKIE[$name]; |
|
| 58 | + } |
|
| 55 | 59 | |
| 56 | 60 | if(isset($value)) |
| 57 | 61 | { |
| 58 | 62 | $this->value = $value; |
| 59 | 63 | $this->exists = true; |
| 60 | - } |
|
| 61 | - else |
|
| 62 | - $this->exists = false; |
|
| 64 | + } else {
|
|
| 65 | + $this->exists = false; |
|
| 66 | + } |
|
| 63 | 67 | |
| 64 | 68 | $this->is_loaded = true; |
| 65 | 69 | } |
@@ -84,24 +88,29 @@ discard block |
||
| 84 | 88 | private final function check_values() |
| 85 | 89 | { |
| 86 | 90 | $name = $this->getName(); |
| 87 | - if(empty($name) || strlen($name) < 1) |
|
| 88 | - return false; |
|
| 91 | + if(empty($name) || strlen($name) < 1) {
|
|
| 92 | + return false; |
|
| 93 | + } |
|
| 89 | 94 | |
| 90 | 95 | $value = $this->getValue(); |
| 91 | - if(!isset($value) || strlen($value) < 1) |
|
| 92 | - return false; |
|
| 96 | + if(!isset($value) || strlen($value) < 1) {
|
|
| 97 | + return false; |
|
| 98 | + } |
|
| 93 | 99 | |
| 94 | 100 | $expiration = $this->getExpiration(); |
| 95 | - if(!isset($expiration) || !is_int($expiration)) |
|
| 96 | - return false; |
|
| 101 | + if(!isset($expiration) || !is_int($expiration)) {
|
|
| 102 | + return false; |
|
| 103 | + } |
|
| 97 | 104 | |
| 98 | 105 | $domain = $this->getDomain(); |
| 99 | - if(!isset($domain) || strlen($domain) < 1) |
|
| 100 | - return false; |
|
| 106 | + if(!isset($domain) || strlen($domain) < 1) {
|
|
| 107 | + return false; |
|
| 108 | + } |
|
| 101 | 109 | |
| 102 | 110 | $path = $this->getPath(); |
| 103 | - if(!isset($path) || strlen($path) < 1) |
|
| 104 | - return false; |
|
| 111 | + if(!isset($path) || strlen($path) < 1) {
|
|
| 112 | + return false; |
|
| 113 | + } |
|
| 105 | 114 | |
| 106 | 115 | return true; |
| 107 | 116 | } |
@@ -26,8 +26,9 @@ discard block |
||
| 26 | 26 | |
| 27 | 27 | public static function instance() |
| 28 | 28 | { |
| 29 | - if(!isset(self::$instance)) |
|
| 30 | - self::$instance = new Visitor(); |
|
| 29 | + if(!isset(self::$instance)) {
|
|
| 30 | + self::$instance = new Visitor(); |
|
| 31 | + } |
|
| 31 | 32 | return self::$instance; |
| 32 | 33 | } |
| 33 | 34 | |
@@ -35,8 +36,9 @@ discard block |
||
| 35 | 36 | public static function getBrowser() |
| 36 | 37 | { |
| 37 | 38 | Loader::load('utility', 'environment/BrowserEnvironment'); |
| 38 | - if(!isset(self::instance()->browser)) |
|
| 39 | - self::instance()->browser = new BrowserEnvironment(); |
|
| 39 | + if(!isset(self::instance()->browser)) {
|
|
| 40 | + self::instance()->browser = new BrowserEnvironment(); |
|
| 41 | + } |
|
| 40 | 42 | return self::instance()->browser; |
| 41 | 43 | } |
| 42 | 44 | |
@@ -44,8 +46,9 @@ discard block |
||
| 44 | 46 | public static function getPlatform() |
| 45 | 47 | { |
| 46 | 48 | Loader::load('utility', 'environment/PlatformEnvironment'); |
| 47 | - if(!isset(self::instance()->platform)) |
|
| 48 | - self::instance()->platform = new PlatformEnvironment(); |
|
| 49 | + if(!isset(self::instance()->platform)) {
|
|
| 50 | + self::instance()->platform = new PlatformEnvironment(); |
|
| 51 | + } |
|
| 49 | 52 | return self::instance()->platform; |
| 50 | 53 | } |
| 51 | 54 | |
@@ -53,8 +56,9 @@ discard block |
||
| 53 | 56 | public static function getIP() |
| 54 | 57 | { |
| 55 | 58 | Loader::load('utility', 'Request'); |
| 56 | - if(!isset(self::instance()->ip_address)) |
|
| 57 | - self::instance()->ip_address = Request::getServer('REMOTE_ADDR'); |
|
| 59 | + if(!isset(self::instance()->ip_address)) {
|
|
| 60 | + self::instance()->ip_address = Request::getServer('REMOTE_ADDR');
|
|
| 61 | + } |
|
| 58 | 62 | return self::instance()->ip_address; |
| 59 | 63 | } |
| 60 | 64 | |
@@ -52,18 +52,20 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | public function setSize($size) |
| 54 | 54 | { |
| 55 | - if($this->get_version() > 1) |
|
| 56 | - $position = strrpos($this->file, '-v'); |
|
| 57 | - else |
|
| 58 | - $position = strrpos($this->file, '.'); |
|
| 55 | + if($this->get_version() > 1) {
|
|
| 56 | + $position = strrpos($this->file, '-v'); |
|
| 57 | + } else {
|
|
| 58 | + $position = strrpos($this->file, '.'); |
|
| 59 | + } |
|
| 59 | 60 | |
| 60 | 61 | $this->file = substr($this->file, 0, $position) . '-s' . $size . substr($this->file, $position); |
| 61 | 62 | } |
| 62 | 63 | |
| 63 | 64 | public function getDimensions() |
| 64 | 65 | { |
| 65 | - if(!$this->isValid()) |
|
| 66 | - return false; |
|
| 66 | + if(!$this->isValid()) {
|
|
| 67 | + return false; |
|
| 68 | + } |
|
| 67 | 69 | $imageinfo = getimagesize($this->getInternalPath()); |
| 68 | 70 | return array($imageinfo[0], $imageinfo[1]); |
| 69 | 71 | } |
@@ -85,10 +87,11 @@ discard block |
||
| 85 | 87 | |
| 86 | 88 | private function get_image($image) |
| 87 | 89 | { |
| 88 | - if(preg_match(self::$VERSION_PREG_MATCH, $image)) |
|
| 89 | - return preg_replace(self::$VERSION_PREG_MATCH, '', $image); |
|
| 90 | - else |
|
| 91 | - return $image; |
|
| 90 | + if(preg_match(self::$VERSION_PREG_MATCH, $image)) {
|
|
| 91 | + return preg_replace(self::$VERSION_PREG_MATCH, '', $image); |
|
| 92 | + } else {
|
|
| 93 | + return $image; |
|
| 94 | + } |
|
| 92 | 95 | } |
| 93 | 96 | |
| 94 | 97 | private function get_image_meta($image) |
@@ -103,9 +106,9 @@ discard block |
||
| 103 | 106 | { |
| 104 | 107 | $position = strrpos($image, '.'); |
| 105 | 108 | return substr($image, 0, $position) . '-v' . $this->get_version() . substr($image, $position); |
| 106 | - } |
|
| 107 | - else |
|
| 108 | - return $image; |
|
| 109 | + } else {
|
|
| 110 | + return $image; |
|
| 111 | + } |
|
| 109 | 112 | } |
| 110 | 113 | |
| 111 | 114 | private $version; |
@@ -118,10 +121,11 @@ discard block |
||
| 118 | 121 | if(count($files) > 0) |
| 119 | 122 | { |
| 120 | 123 | preg_match(self::$VERSION_PREG_MATCH, $files[0], $matches); |
| 121 | - if(count($matches)) |
|
| 122 | - $this->version = $matches[1]; |
|
| 123 | - else |
|
| 124 | - $this->version = 1; |
|
| 124 | + if(count($matches)) {
|
|
| 125 | + $this->version = $matches[1]; |
|
| 126 | + } else {
|
|
| 127 | + $this->version = 1; |
|
| 128 | + } |
|
| 125 | 129 | } |
| 126 | 130 | } |
| 127 | 131 | return $this->version; |
@@ -10,8 +10,9 @@ |
||
| 10 | 10 | protected function execute($title = '') |
| 11 | 11 | { |
| 12 | 12 | preg_match_all(self::$MARKUP_DELIMITER, $this->content, $matches); |
| 13 | - if(count($matches[1]) == 0) |
|
| 14 | - return; |
|
| 13 | + if(count($matches[1]) == 0) {
|
|
| 14 | + return; |
|
| 15 | + } |
|
| 15 | 16 | |
| 16 | 17 | foreach($matches[3] as $key => $match) |
| 17 | 18 | { |
@@ -14,10 +14,11 @@ discard block |
||
| 14 | 14 | preg_match_all(self::$LINK_PLACEHOLDER_MATCH, $this->content, $matches); |
| 15 | 15 | foreach($matches[1] as $key => $match) |
| 16 | 16 | { |
| 17 | - if(isset($matches[3][$key])) |
|
| 18 | - $link_content = $this->get_link($match, $is_absolute, $matches[3][$key]); |
|
| 19 | - else |
|
| 20 | - $link_content = $this->get_link($match, $is_absolute); |
|
| 17 | + if(isset($matches[3][$key])) {
|
|
| 18 | + $link_content = $this->get_link($match, $is_absolute, $matches[3][$key]); |
|
| 19 | + } else {
|
|
| 20 | + $link_content = $this->get_link($match, $is_absolute); |
|
| 21 | + } |
|
| 21 | 22 | $this->content = str_replace($matches[0][$key], $link_content, $this->content); |
| 22 | 23 | } |
| 23 | 24 | return; |
@@ -35,14 +36,16 @@ discard block |
||
| 35 | 36 | Loader::load('collector', 'blog/PostCollector'); |
| 36 | 37 | $post = PostCollector::getPostByURI($uri); |
| 37 | 38 | |
| 38 | - if($post === NULL) |
|
| 39 | - return; |
|
| 39 | + if($post === NULL) {
|
|
| 40 | + return; |
|
| 41 | + } |
|
| 40 | 42 | |
| 41 | 43 | $link .= ($is_absolute) ? Loader::getRootURL('blog') : '/'; |
| 42 | 44 | $link .= "{$post->category}/{$post->path}/"; |
| 43 | 45 | |
| 44 | - if($anchor == '') |
|
| 45 | - $anchor = $post->title; |
|
| 46 | + if($anchor == '') {
|
|
| 47 | + $anchor = $post->title; |
|
| 48 | + } |
|
| 46 | 49 | |
| 47 | 50 | break; |
| 48 | 51 | case 'blog-tag' : |
@@ -61,14 +64,16 @@ discard block |
||
| 61 | 64 | Loader::load('collector', 'waterfall/LogCollector'); |
| 62 | 65 | $log = LogCollector::getByAlias($uri); |
| 63 | 66 | |
| 64 | - if($log === NULL) |
|
| 65 | - return; |
|
| 67 | + if($log === NULL) {
|
|
| 68 | + return; |
|
| 69 | + } |
|
| 66 | 70 | |
| 67 | 71 | $link .= ($is_absolute) ? Loader::getRootURL('waterfalls') : '/'; |
| 68 | 72 | $link .= "journal/{$log->alias}/"; |
| 69 | 73 | |
| 70 | - if($anchor == '') |
|
| 71 | - $anchor = $log->title; |
|
| 74 | + if($anchor == '') {
|
|
| 75 | + $anchor = $log->title; |
|
| 76 | + } |
|
| 72 | 77 | |
| 73 | 78 | break; |
| 74 | 79 | case 'falls' : |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | $is_acceptable = true; |
| 12 | 12 | foreach($this->getUnacceptableWords() as $unacceptableWord) |
| 13 | 13 | { |
| 14 | - if(stristr($unacceptableWord->word, $this->content)) |
|
| 15 | - $is_acceptable = false; |
|
| 14 | + if(stristr($unacceptableWord->word, $this->content)) {
|
|
| 15 | + $is_acceptable = false; |
|
| 16 | + } |
|
| 16 | 17 | } |
| 17 | 18 | return $is_acceptable; |
| 18 | 19 | } |
@@ -20,8 +21,9 @@ discard block |
||
| 20 | 21 | private $unacceptableWords; |
| 21 | 22 | private function getUnacceptableWords() |
| 22 | 23 | { |
| 23 | - if(!$this->unacceptableWords) |
|
| 24 | - $this->unacceptableWords = UnacceptableWordCollector::getWords(); |
|
| 24 | + if(!$this->unacceptableWords) {
|
|
| 25 | + $this->unacceptableWords = UnacceptableWordCollector::getWords(); |
|
| 26 | + } |
|
| 25 | 27 | return $this->unacceptableWords; |
| 26 | 28 | } |
| 27 | 29 | |