@@ -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); |
@@ -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 | } |
@@ -22,13 +22,13 @@ |
||
22 | 22 | |
23 | 23 | public function activate() |
24 | 24 | { |
25 | - foreach($this->post_array as $post) |
|
25 | + foreach ($this->post_array as $post) |
|
26 | 26 | { |
27 | 27 | $blog_result = BlogCollector::getBlogByTitle($post->title); |
28 | - if($blog_result !== null) |
|
28 | + if ($blog_result !== null) |
|
29 | 29 | { |
30 | 30 | $comments = CommentCollector::getCommentCountForURL(2, $post->path); |
31 | - if($blog_result->comments != $comments) |
|
31 | + if ($blog_result->comments != $comments) |
|
32 | 32 | { |
33 | 33 | $query = sprintf(self::$UPDATE_COMMENTS_QUERY, $comments, $blog_result->id); |
34 | 34 | Database::execute($query); |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | private $oauth_array; |
84 | 84 | private function get_oauth_array() |
85 | 85 | { |
86 | - if(!isset($this->oauth_array)) |
|
86 | + if (!isset($this->oauth_array)) |
|
87 | 87 | { |
88 | 88 | $this->oauth_array = array( |
89 | 89 | 'screen_name' => self::$SCREEN_NAME, |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | { |
117 | 117 | $encoded_array = array(); |
118 | 118 | ksort($array); |
119 | - foreach($array as $key => $value) |
|
119 | + foreach ($array as $key => $value) |
|
120 | 120 | { |
121 | 121 | $value = rawurlencode($value); |
122 | 122 | $value = ($wrap_values) ? '"' . $value . '"' : $value; |
@@ -127,27 +127,27 @@ discard block |
||
127 | 127 | |
128 | 128 | public function activate() |
129 | 129 | { |
130 | - if(!$this->json) |
|
130 | + if (!$this->json) |
|
131 | 131 | return $this->error('Could not connect to twitter json feed.'); |
132 | 132 | |
133 | 133 | $count = 0; |
134 | - foreach($this->json as $status) |
|
134 | + foreach ($this->json as $status) |
|
135 | 135 | { |
136 | 136 | $text = Database::escape($status->text); |
137 | 137 | $date = date('Y-m-d H:i:s', strtotime($status->created_at)); |
138 | 138 | |
139 | 139 | $tweet_result = TwitterCollector::getTweetByFields($date, $text); |
140 | - if($tweet_result !== null) |
|
140 | + if ($tweet_result !== null) |
|
141 | 141 | { |
142 | 142 | $favorites = (int) $status->favorite_count; |
143 | - if($favorites != 0 && $tweet_result->favorites != $favorites) |
|
143 | + if ($favorites != 0 && $tweet_result->favorites != $favorites) |
|
144 | 144 | { |
145 | 145 | $query = sprintf(self::$UPDATE_FAVORITES_QUERY, $favorites, $tweet_result->id); |
146 | 146 | Database::execute($query); |
147 | 147 | } |
148 | 148 | |
149 | 149 | $retweets = (int) $status->retweet_count; |
150 | - if($retweets != 0 && $tweet_result->retweets != $retweets) |
|
150 | + if ($retweets != 0 && $tweet_result->retweets != $retweets) |
|
151 | 151 | { |
152 | 152 | $query = sprintf(self::$UPDATE_RETWEETS_QUERY, $retweets, $tweet_result->id); |
153 | 153 | Database::execute($query); |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | { |
158 | 158 | $twitter_id = (string) $status->id_str; |
159 | 159 | |
160 | - if(isset($status->retweeted_status)) |
|
160 | + if (isset($status->retweeted_status)) |
|
161 | 161 | { |
162 | 162 | $text_formatted = $this->get_formatted($status->retweeted_status->text, $status->retweeted_status->entities); |
163 | 163 | $text_formatted_full = $this->get_formatted($status->retweeted_status->text, $status->retweeted_status->entities, 'full'); |
@@ -200,9 +200,9 @@ discard block |
||
200 | 200 | |
201 | 201 | private function get_source($source) |
202 | 202 | { |
203 | - if(stristr($source, 'tweetdeck')) |
|
203 | + if (stristr($source, 'tweetdeck')) |
|
204 | 204 | return 'tweetdeck'; |
205 | - if(stristr($source, 'windows phone')) |
|
205 | + if (stristr($source, 'windows phone')) |
|
206 | 206 | return 'phone'; |
207 | 207 | else |
208 | 208 | return ''; |
@@ -211,9 +211,9 @@ discard block |
||
211 | 211 | private function get_formatted($text, $entities, $type = 'short') |
212 | 212 | { |
213 | 213 | $holder = array(); |
214 | - foreach($entities as $entity_type => $entity_collection) |
|
214 | + foreach ($entities as $entity_type => $entity_collection) |
|
215 | 215 | { |
216 | - foreach($entity_collection as $entity) |
|
216 | + foreach ($entity_collection as $entity) |
|
217 | 217 | { |
218 | 218 | $start = $entity->indices[0]; |
219 | 219 | $end = $entity->indices[1]; |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | |
229 | 229 | krsort($holder); |
230 | 230 | |
231 | - foreach($holder as $entity) |
|
231 | + foreach ($holder as $entity) |
|
232 | 232 | { |
233 | 233 | $text = mb_substr($text, 0, $entity->start, 'UTF-8') . $entity->replace . mb_substr($text, $entity->end, 5000, 'UTF-8'); |
234 | 234 | } |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | |
242 | 242 | private function get_replace_text($entity_type, $entity, $type) |
243 | 243 | { |
244 | - switch($entity_type) |
|
244 | + switch ($entity_type) |
|
245 | 245 | { |
246 | 246 | case 'hashtags' : |
247 | 247 | $replace = sprintf(self::$HASHTAG_LINK, $entity->text); |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | $replace = sprintf(self::$USER_MENTION_LINK, $entity->screen_name, $entity->name); |
254 | 254 | break; |
255 | 255 | case 'media' : |
256 | - if($type == 'full') |
|
256 | + if ($type == 'full') |
|
257 | 257 | $replace = sprintf(self::$MEDIA_LINK, $entity->url, $entity->display_url, $entity->media_url, 'large', 'Photo from Twitter', $entity->sizes->large->h, $entity->sizes->large->w); |
258 | 258 | else |
259 | 259 | $replace = sprintf(self::$URL_LINK, $entity->url, $entity->expanded_url, $entity->display_url); |
@@ -61,10 +61,10 @@ discard block |
||
61 | 61 | |
62 | 62 | private function remove_existing($result, $type) |
63 | 63 | { |
64 | - foreach($result as $key => $row) |
|
64 | + foreach ($result as $key => $row) |
|
65 | 65 | { |
66 | 66 | $stream_result = ActivityCollector::getPostByFields($row->id, $type); |
67 | - if($stream_result) |
|
67 | + if ($stream_result) |
|
68 | 68 | unset($result[$key]); |
69 | 69 | } |
70 | 70 | return $result; |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | |
73 | 73 | private function add_posts($result, $type) |
74 | 74 | { |
75 | - foreach($result as $row) |
|
75 | + foreach ($result as $row) |
|
76 | 76 | { |
77 | 77 | $query = sprintf(self::$QUERY, $type, $row->id, $row->date); |
78 | 78 | Database::execute($query); |
@@ -13,23 +13,23 @@ discard block |
||
13 | 13 | |
14 | 14 | function __construct() |
15 | 15 | { |
16 | - if(Loader::isLive()) |
|
16 | + if (Loader::isLive()) |
|
17 | 17 | $handle[] = self::$live_root; |
18 | 18 | else |
19 | 19 | $handle[] = self::$test_root; |
20 | 20 | |
21 | 21 | $i = 0; |
22 | - while(isset($handle[$i])) |
|
22 | + while (isset($handle[$i])) |
|
23 | 23 | { |
24 | 24 | $path = $handle[$i]; |
25 | 25 | $fh = opendir($path); |
26 | - while(false !== ($file = readdir($fh))) |
|
26 | + while (false !== ($file = readdir($fh))) |
|
27 | 27 | { |
28 | - if($file != '.' && $file != '..') |
|
28 | + if ($file != '.' && $file != '..') |
|
29 | 29 | { |
30 | - if(is_dir("{$path}/{$file}")) |
|
30 | + if (is_dir("{$path}/{$file}")) |
|
31 | 31 | $handle[] = "{$path}/{$file}"; |
32 | - if($file == 'error.log') |
|
32 | + if ($file == 'error.log') |
|
33 | 33 | $this->error_files[] = "{$path}/{$file}"; |
34 | 34 | } |
35 | 35 | } |
@@ -42,10 +42,10 @@ discard block |
||
42 | 42 | { |
43 | 43 | $message = ''; |
44 | 44 | |
45 | - if(count($this->error_files) > 0) |
|
45 | + if (count($this->error_files) > 0) |
|
46 | 46 | { |
47 | 47 | $message .= "Errors from flat-file logs.\n\n"; |
48 | - foreach($this->error_files as $error_file) |
|
48 | + foreach ($this->error_files as $error_file) |
|
49 | 49 | { |
50 | 50 | $contents = file_get_contents($error_file); |
51 | 51 | $message .= "{$error_file}\n{$contents}\n\n"; |
@@ -60,9 +60,9 @@ discard block |
||
60 | 60 | $mail->setMessage($message); |
61 | 61 | $mail->send(); |
62 | 62 | |
63 | - if(count($this->error_files) > 0) |
|
63 | + if (count($this->error_files) > 0) |
|
64 | 64 | { |
65 | - foreach($this->error_files as $error_file) |
|
65 | + foreach ($this->error_files as $error_file) |
|
66 | 66 | { |
67 | 67 | // if(file_exists($error_file)) |
68 | 68 | // unlink($error_file); |
@@ -19,12 +19,12 @@ discard block |
||
19 | 19 | |
20 | 20 | public function activate() |
21 | 21 | { |
22 | - if(!$this->xml) |
|
22 | + if (!$this->xml) |
|
23 | 23 | return $this->error('Could not connect to feed.'); |
24 | 24 | |
25 | - foreach($this->xml->channel->item as $item) |
|
25 | + foreach ($this->xml->channel->item as $item) |
|
26 | 26 | { |
27 | - if(strtotime($item->user_read_at) <= 0) |
|
27 | + if (strtotime($item->user_read_at) <= 0) |
|
28 | 28 | continue; |
29 | 29 | |
30 | 30 | $title = $item->title; |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $date_added = date('Y-m-d H:i:s', strtotime($item->user_date_created)); |
43 | 43 | |
44 | 44 | $book_result = BookCollector::getBookByFields($title, $author); |
45 | - if($book_result !== null) |
|
45 | + if ($book_result !== null) |
|
46 | 46 | continue; |
47 | 47 | |
48 | 48 | $query = sprintf(self::$QUERY, $title, $author, $link, $description, $image, $date_read, $date_added); |
@@ -20,11 +20,11 @@ discard block |
||
20 | 20 | |
21 | 21 | public function activate() |
22 | 22 | { |
23 | - if(!$this->json) |
|
23 | + if (!$this->json) |
|
24 | 24 | return $this->error('Could not connect to feed.'); |
25 | 25 | |
26 | 26 | $count = 0; |
27 | - foreach($this->json->entries as $entry) |
|
27 | + foreach ($this->json->entries as $entry) |
|
28 | 28 | { |
29 | 29 | $type = $entry->workout->activity_type; |
30 | 30 | $type = strtolower($type); |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | $date = date('Y-m-d H:i:s', strtotime($entry->at)); |
42 | 42 | |
43 | 43 | $distance_result = DistanceCollector::getDistanceByFields($date, $type, $distance); |
44 | - if($distance_result !== null) |
|
44 | + if ($distance_result !== null) |
|
45 | 45 | continue; |
46 | 46 | |
47 | 47 | $query = sprintf(self::$QUERY, $type, $distance, $url, $felt, $title, $message, $date); |
@@ -11,39 +11,39 @@ discard block |
||
11 | 11 | |
12 | 12 | public static function isBoolean($value, $strict = false) |
13 | 13 | { |
14 | - if($strict && ($value === true || $value === false)) |
|
14 | + if ($strict && ($value === true || $value === false)) |
|
15 | 15 | return true; |
16 | - if(!$strict && ((bool) $value === true || (bool) $value === false)) |
|
16 | + if (!$strict && ((bool) $value === true || (bool) $value === false)) |
|
17 | 17 | return true; |
18 | 18 | return false; |
19 | 19 | } |
20 | 20 | |
21 | 21 | public static function isDate($value) |
22 | 22 | { |
23 | - if(strtotime($value) !== -1) |
|
23 | + if (strtotime($value) !== -1) |
|
24 | 24 | return true; |
25 | - if(date('y', $value) !== false) |
|
25 | + if (date('y', $value) !== false) |
|
26 | 26 | return true; |
27 | 27 | return false; |
28 | 28 | } |
29 | 29 | |
30 | 30 | public static function isInteger($value, $strict = false) |
31 | 31 | { |
32 | - if($strict) |
|
32 | + if ($strict) |
|
33 | 33 | return is_int($value); |
34 | 34 | return (int) $value == $value; |
35 | 35 | } |
36 | 36 | |
37 | 37 | public static function isIP($value) |
38 | 38 | { |
39 | - if(self::isInteger(ip2long($value))) |
|
39 | + if (self::isInteger(ip2long($value))) |
|
40 | 40 | return true; |
41 | 41 | return false; |
42 | 42 | } |
43 | 43 | |
44 | 44 | public static function isString($value, $strict = false) |
45 | 45 | { |
46 | - if($strict) |
|
46 | + if ($strict) |
|
47 | 47 | return is_string($value); |
48 | 48 | return (string) $value == $value; |
49 | 49 | } |
@@ -67,14 +67,14 @@ discard block |
||
67 | 67 | private static function check_value($pattern, $string) |
68 | 68 | { |
69 | 69 | preg_match($pattern, $string, $matches); |
70 | - if(empty($matches)) |
|
70 | + if (empty($matches)) |
|
71 | 71 | return false; |
72 | 72 | return $matches[0] == $string; |
73 | 73 | } |
74 | 74 | |
75 | 75 | public static function checkRequest($type, $key, $validation, $strict = false) |
76 | 76 | { |
77 | - switch($type) |
|
77 | + switch ($type) |
|
78 | 78 | { |
79 | 79 | case 'server': |
80 | 80 | $value = Request::getServer($key); |
@@ -84,10 +84,10 @@ discard block |
||
84 | 84 | break; |
85 | 85 | } |
86 | 86 | |
87 | - if($value == false) |
|
87 | + if ($value == false) |
|
88 | 88 | return false; |
89 | 89 | |
90 | - switch($validation) |
|
90 | + switch ($validation) |
|
91 | 91 | { |
92 | 92 | case 'boolean': |
93 | 93 | return self::isBoolean($value, $strict); |
@@ -186,10 +186,10 @@ discard block |
||
186 | 186 | |
187 | 187 | private static function send($array, $gzip = true) |
188 | 188 | { |
189 | - if($gzip) |
|
189 | + if ($gzip) |
|
190 | 190 | self::start_gzipping(); |
191 | 191 | |
192 | - foreach($array as $row) |
|
192 | + foreach ($array as $row) |
|
193 | 193 | { |
194 | 194 | header($row, TRUE); |
195 | 195 | } |
@@ -197,14 +197,14 @@ discard block |
||
197 | 197 | |
198 | 198 | private static function get_date($timestamp = false) |
199 | 199 | { |
200 | - if($timestamp == 0) |
|
200 | + if ($timestamp == 0) |
|
201 | 201 | $timestamp = time(); |
202 | 202 | return gmdate('D, d M Y H:i:s \G\M\T', $timestamp); |
203 | 203 | } |
204 | 204 | |
205 | 205 | private static function start_gzipping() |
206 | 206 | { |
207 | - if(!ob_start('ob_gzhandler')) |
|
207 | + if (!ob_start('ob_gzhandler')) |
|
208 | 208 | ob_start(); |
209 | 209 | } |
210 | 210 |