Completed
Push — master ( 5852b3...e99317 )
by Jacob
04:02
created
utility/cron/TwitterCron.class.inc.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
utility/cron/StreamCron.class.inc.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -61,10 +61,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
utility/cron/ErrorCron.class.inc.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -13,23 +13,23 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
utility/cron/BookCron.class.inc.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,12 +19,12 @@  discard block
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
utility/cron/DistanceCron.class.inc.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,11 +20,11 @@  discard block
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
utility/Validate.class.inc.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -11,39 +11,39 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
utility/Header.class.inc.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -186,10 +186,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
utility/Request.class.inc.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -18,9 +18,9 @@  discard block
 block discarded – undo
18 18
 
19 19
 	static function getServer($key = null)
20 20
 	{
21
-		if($key)
21
+		if ($key)
22 22
 		{
23
-			if(isset(self::$server[$key]))
23
+			if (isset(self::$server[$key]))
24 24
 				return self::$server[$key];
25 25
 			return false;
26 26
 		}
@@ -29,16 +29,16 @@  discard block
 block discarded – undo
29 29
 
30 30
 	static function isAjax()
31 31
 	{
32
-		if(self::getServer(self::$AJAX_REQUEST))
32
+		if (self::getServer(self::$AJAX_REQUEST))
33 33
 			return true;
34 34
 		return false;
35 35
 	}
36 36
 
37 37
 	static function getGet($key = null)
38 38
 	{
39
-		if($key)
39
+		if ($key)
40 40
 		{
41
-			if(isset(self::$get[$key]))
41
+			if (isset(self::$get[$key]))
42 42
 				return self::$get[$key];
43 43
 			return false;
44 44
 		}
@@ -47,9 +47,9 @@  discard block
 block discarded – undo
47 47
 
48 48
 	static function getPost($key = null)
49 49
 	{
50
-		if($key)
50
+		if ($key)
51 51
 		{
52
-			if(isset(self::$post[$key]))
52
+			if (isset(self::$post[$key]))
53 53
 				return self::$post[$key];
54 54
 			return false;
55 55
 		}
Please login to merge, or discard this patch.
utility/Search.class.inc.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -39,20 +39,20 @@  discard block
 block discarded – undo
39 39
 	public function perform()
40 40
 	{
41 41
 		$weighted_array = array();
42
-		foreach($this->result as $row)
42
+		foreach ($this->result as $row)
43 43
 		{
44 44
 			$weight = $this->get_search_weight($row);
45
-			if($weight > 0)
45
+			if ($weight > 0)
46 46
 				$weighted_array[$row->id] = $weight;
47 47
 		}
48 48
 		arsort($weighted_array);
49 49
 		
50 50
 		$final_array = array();
51
-		foreach($weighted_array as $id => $weight)
51
+		foreach ($weighted_array as $id => $weight)
52 52
 		{
53
-			foreach($this->result as $row)
53
+			foreach ($this->result as $row)
54 54
 			{
55
-				if($row->id == $id)
55
+				if ($row->id == $id)
56 56
 					$final_array[] = $row;
57 57
 			}
58 58
 		}
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	private function get_search_weight($row)
63 63
 	{
64 64
 		$weight = 0;
65
-		foreach($this->weight as $weight_array)
65
+		foreach ($this->weight as $weight_array)
66 66
 		{
67 67
 			$text = $row->{$weight_array['field']};
68 68
 			$weight += $weight_array['weight'] * substr_count(strtolower($text), strtolower($this->query));
Please login to merge, or discard this patch.