Completed
Push — trunk ( ad61f6...5a98ee )
by SuperNova.WS
04:15
created
includes/init.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 use \Core\SnBootstrap;
4 4
 
5 5
 // Защита от двойного инита
6
-if(defined('INIT')) {
6
+if (defined('INIT')) {
7 7
   return;
8 8
 }
9 9
 
@@ -116,18 +116,18 @@  discard block
 block discarded – undo
116 116
 // Но нужно, пока у нас есть не MVC-страницы
117 117
 $sn_page_data = $sn_mvc['pages'][$sn_page_name];
118 118
 $sn_page_name_file = 'includes/pages/' . $sn_page_data['filename'] . DOT_PHP_EX;
119
-if($sn_page_name) {
119
+if ($sn_page_name) {
120 120
   // Merging page options to global option pull
121
-  if(is_array($sn_page_data['options'])) {
121
+  if (is_array($sn_page_data['options'])) {
122 122
     classSupernova::$options = array_merge(classSupernova::$options, $sn_page_data['options']);
123 123
   }
124 124
 
125
-  if(isset($sn_page_data) && file_exists($sn_page_name_file)) {
125
+  if (isset($sn_page_data) && file_exists($sn_page_name_file)) {
126 126
     require_once($sn_page_name_file);
127 127
   }
128 128
 }
129 129
 
130
-if((defined('IN_AJAX') && IN_AJAX === true) || (defined('IN_ADMIN') && IN_ADMIN === true)) {
130
+if ((defined('IN_AJAX') && IN_AJAX === true) || (defined('IN_ADMIN') && IN_ADMIN === true)) {
131 131
   classSupernova::$options['fleet_update_skip'] = true;
132 132
 }
133 133
 
@@ -141,10 +141,10 @@  discard block
 block discarded – undo
141 141
 $load_order = array();
142 142
 $sn_req = array();
143 143
 
144
-foreach($sn_module as $loaded_module_name => $module_data) {
144
+foreach ($sn_module as $loaded_module_name => $module_data) {
145 145
   $load_order[$loaded_module_name] = isset($module_data->manifest['load_order']) && !empty($module_data->manifest['load_order']) ? $module_data->manifest['load_order'] : 100000;
146
-  if(isset($module_data->manifest['require']) && !empty($module_data->manifest['require'])) {
147
-    foreach($module_data->manifest['require'] as $require_name) {
146
+  if (isset($module_data->manifest['require']) && !empty($module_data->manifest['require'])) {
147
+    foreach ($module_data->manifest['require'] as $require_name) {
148 148
       $sn_req[$loaded_module_name][$require_name] = 0;
149 149
     }
150 150
   }
@@ -155,10 +155,10 @@  discard block
 block discarded – undo
155 155
 do {
156 156
   $prev_order = $load_order;
157 157
 
158
-  foreach($sn_req as $loaded_module_name => &$req_data) {
158
+  foreach ($sn_req as $loaded_module_name => &$req_data) {
159 159
     $level = 1;
160
-    foreach($req_data as $req_name => &$req_level) {
161
-      if($load_order[$req_name] == -1 || !isset($load_order[$req_name])) {
160
+    foreach ($req_data as $req_name => &$req_level) {
161
+      if ($load_order[$req_name] == -1 || !isset($load_order[$req_name])) {
162 162
         $level = $req_level = -1;
163 163
         break;
164 164
       } else {
@@ -166,21 +166,21 @@  discard block
 block discarded – undo
166 166
       }
167 167
       $req_level = $load_order[$req_name];
168 168
     }
169
-    if($level > $load_order[$loaded_module_name] || $level == -1) {
169
+    if ($level > $load_order[$loaded_module_name] || $level == -1) {
170 170
       $load_order[$loaded_module_name] = $level;
171 171
     }
172 172
   }
173 173
 }
174
-while($prev_order != $load_order);
174
+while ($prev_order != $load_order);
175 175
 
176 176
 asort($load_order);
177 177
 
178 178
 // Инициализируем модули
179 179
 // По нормальным делам это должна быть загрузка модулей и лишь затем инициализация - что бы минимизировать размер процесса в памяти
180
-foreach($load_order as $loaded_module_name => $load_order_order) {
181
-  if($load_order_order >= 0) {
180
+foreach ($load_order as $loaded_module_name => $load_order_order) {
181
+  if ($load_order_order >= 0) {
182 182
     $sn_module[$loaded_module_name]->check_status();
183
-    if(!$sn_module[$loaded_module_name]->manifest['active']) {
183
+    if (!$sn_module[$loaded_module_name]->manifest['active']) {
184 184
       unset($sn_module[$loaded_module_name]);
185 185
       continue;
186 186
     }
@@ -198,29 +198,29 @@  discard block
 block discarded – undo
198 198
 
199 199
 // А теперь проверяем - поддерживают ли у нас загруженный код такую страницу
200 200
 // TODO - костыль, что бы работали старые модули. Убрать!
201
-if(is_array($sn_data['pages'])) {
201
+if (is_array($sn_data['pages'])) {
202 202
   $sn_mvc['pages'] = array_merge($sn_mvc['pages'], $sn_data['pages']);
203 203
 }
204
-if(!isset($sn_mvc['pages'][$sn_page_name])) {
204
+if (!isset($sn_mvc['pages'][$sn_page_name])) {
205 205
   $sn_page_name = '';
206 206
 }
207 207
 
208 208
 $lang->lng_switch(sys_get_param_str('lang'));
209 209
 
210 210
 
211
-if(classSupernova::$config->server_updater_check_auto && classSupernova::$config->server_updater_check_last + classSupernova::$config->server_updater_check_period <= SN_TIME_NOW) {
211
+if (classSupernova::$config->server_updater_check_auto && classSupernova::$config->server_updater_check_last + classSupernova::$config->server_updater_check_period <= SN_TIME_NOW) {
212 212
   \Tools\VersionCheckerDeprecated::performCheckVersion();
213 213
 }
214 214
 
215
-if(classSupernova::$config->user_birthday_gift && SN_TIME_NOW - classSupernova::$config->user_birthday_celebrate > PERIOD_DAY) {
215
+if (classSupernova::$config->user_birthday_gift && SN_TIME_NOW - classSupernova::$config->user_birthday_celebrate > PERIOD_DAY) {
216 216
   require_once(SN_ROOT_PHYSICAL . 'includes/includes/user_birthday_celebrate.php');
217 217
   sn_user_birthday_celebrate();
218 218
 }
219 219
 
220
-if(!classSupernova::$config->var_online_user_count || classSupernova::$config->var_online_user_time + 30 < SN_TIME_NOW) {
220
+if (!classSupernova::$config->var_online_user_count || classSupernova::$config->var_online_user_time + 30 < SN_TIME_NOW) {
221 221
   classSupernova::$config->db_saveItem('var_online_user_count', db_user_count(true));
222 222
   classSupernova::$config->db_saveItem('var_online_user_time', SN_TIME_NOW);
223
-  if(classSupernova::$config->server_log_online) {
223
+  if (classSupernova::$config->server_log_online) {
224 224
     doquery("INSERT IGNORE INTO {{log_users_online}} SET online_count = " . classSupernova::$config->var_online_user_count . ";");
225 225
   }
226 226
 }
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 
244 244
 $template_result[F_ACCOUNT_IS_AUTHORIZED] = $sys_user_logged_in = !empty($user) && isset($user['id']) && $user['id'];
245 245
 
246
-if(!empty($user['id'])) {
246
+if (!empty($user['id'])) {
247 247
   classSupernova::$user_options->user_change($user['id']);
248 248
 }
249 249
 
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
         : false
257 257
       );
258 258
 
259
-if($template_result[F_LOGIN_STATUS] == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) {
259
+if ($template_result[F_LOGIN_STATUS] == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) {
260 260
   $prohibited_characters = array_map(function($value) {
261 261
     return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'";
262 262
   }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED));
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 }
265 265
 
266 266
 
267
-if(defined('DEBUG_AUTH') && DEBUG_AUTH && !defined('IN_AJAX')) {
267
+if (defined('DEBUG_AUTH') && DEBUG_AUTH && !defined('IN_AJAX')) {
268 268
   pdump('Отключи отладку перед продакшном!');
269 269
 }
270 270
 
@@ -278,17 +278,17 @@  discard block
 block discarded – undo
278 278
 
279 279
 StatUpdateLauncher::unlock();
280 280
 
281
-if($template_result[F_GAME_DISABLE] = classSupernova::$config->game_disable) {
281
+if ($template_result[F_GAME_DISABLE] = classSupernova::$config->game_disable) {
282 282
   $template_result[F_GAME_DISABLE_REASON] = HelperString::nl2br(
283 283
     classSupernova::$config->game_disable == GAME_DISABLE_REASON
284 284
       ? classSupernova::$config->game_disable_reason
285 285
       : $lang['sys_game_disable_reason'][classSupernova::$config->game_disable]
286 286
   );
287
-  if(defined('IN_API')) {
287
+  if (defined('IN_API')) {
288 288
     return;
289 289
   }
290 290
 
291
-  if(
291
+  if (
292 292
     ($user['authlevel'] < 1 || !(defined('IN_ADMIN') && IN_ADMIN))
293 293
     &&
294 294
     !(defined('INSTALL_MODE') && defined('LOGIN_LOGOUT'))
@@ -301,8 +301,8 @@  discard block
 block discarded – undo
301 301
 
302 302
 // TODO ban
303 303
 // TODO $skip_ban_check
304
-if($template_result[F_BANNED_STATUS] && !$skip_ban_check) {
305
-  if(defined('IN_API')) {
304
+if ($template_result[F_BANNED_STATUS] && !$skip_ban_check) {
305
+  if (defined('IN_API')) {
306 306
     return;
307 307
   }
308 308
 
@@ -316,10 +316,10 @@  discard block
 block discarded – undo
316 316
 $allow_anonymous = $allow_anonymous || (isset($sn_page_data['allow_anonymous']) && $sn_page_data['allow_anonymous']);
317 317
 
318 318
 
319
-if($sys_user_logged_in && INITIAL_PAGE == 'login') {
319
+if ($sys_user_logged_in && INITIAL_PAGE == 'login') {
320 320
   sys_redirect(SN_ROOT_VIRTUAL . 'overview.php');
321
-} elseif($account_logged_in && !$sys_user_logged_in) { // empty(core_auth::$user['id'])
322
-} elseif(!$allow_anonymous && !$sys_user_logged_in) {
321
+} elseif ($account_logged_in && !$sys_user_logged_in) { // empty(core_auth::$user['id'])
322
+} elseif (!$allow_anonymous && !$sys_user_logged_in) {
323 323
   sys_redirect(SN_ROOT_VIRTUAL . 'login.php');
324 324
 }
325 325
 
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
   'fleet_update_last',
344 344
   classSupernova::$config->fleet_update_interval,
345 345
   // Promise
346
-  function () {classSupernova::$gc->fleetDispatcher->dispatch();},
346
+  function() {classSupernova::$gc->fleetDispatcher->dispatch(); },
347 347
   WATCHDOG_TIME_SQL,
348 348
   false
349 349
 );
Please login to merge, or discard this patch.
classes/phpbb_hook.php 3 patches
Indentation   +224 added lines, -224 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 */
17 17
 if (!defined('IN_PHPBB'))
18 18
 {
19
-	exit;
19
+  exit;
20 20
 }
21 21
 
22 22
 /**
@@ -24,227 +24,227 @@  discard block
 block discarded – undo
24 24
 */
25 25
 class phpbb_hook
26 26
 {
27
-	/**
28
-	* Registered hooks
29
-	*/
30
-	var $hooks = array();
31
-
32
-	/**
33
-	* Results returned by functions called
34
-	*/
35
-	var $hook_result = array();
36
-
37
-	/**
38
-	* internal pointer
39
-	*/
40
-	var $current_hook = NULL;
41
-
42
-	/**
43
-	* Initialize hook class.
44
-	*
45
-	* @param array $valid_hooks array containing the hookable functions/methods
46
-	*/
47
-	function phpbb_hook($valid_hooks)
48
-	{
49
-		foreach ($valid_hooks as $_null => $method)
50
-		{
51
-			$this->add_hook($method);
52
-		}
53
-
54
-		if (function_exists('phpbb_hook_register'))
55
-		{
56
-			phpbb_hook_register($this);
57
-		}
58
-	}
59
-
60
-	/**
61
-	* Register function/method to be called within hook
62
-	* This function is normally called by the modification/application to attach/register the functions.
63
-	*
64
-	* @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
65
-	* @param mixed $hook The replacement function/method to be called. Passing function name or array with object/class definition
66
-	* @param string $mode Specify the priority/chain mode. 'normal' -> hook gets appended to the chain. 'standalone' -> only the specified hook gets called - later hooks are not able to overwrite this (E_NOTICE is triggered then). 'first' -> hook is called as the first one within the chain. 'last' -> hook is called as the last one within the chain.
67
-	*/
68
-	function register($definition, $hook, $mode = 'normal')
69
-	{
70
-		$class = (!is_array($definition)) ? '__global' : $definition[0];
71
-		$function = (!is_array($definition)) ? $definition : $definition[1];
72
-
73
-		// Method able to be hooked?
74
-		if (isset($this->hooks[$class][$function]))
75
-		{
76
-			switch ($mode)
77
-			{
78
-				case 'standalone':
79
-					if (!isset($this->hooks[$class][$function]['standalone']))
80
-					{
81
-						$this->hooks[$class][$function] = array('standalone' => $hook);
82
-					}
83
-					else
84
-					{
85
-						trigger_error('Hook not able to be called standalone, previous hook already standalone.', E_NOTICE);
86
-					}
87
-				break;
88
-
89
-				case 'first':
90
-				case 'last':
91
-					$this->hooks[$class][$function][$mode][] = $hook;
92
-				break;
93
-
94
-				case 'normal':
95
-				default:
96
-					$this->hooks[$class][$function]['normal'][] = $hook;
97
-				break;
98
-			}
99
-		}
100
-	}
101
-
102
-	/**
103
-	* Calling all functions/methods attached to a specified hook.
104
-	* Called by the function allowing hooks...
105
-	*
106
-	* @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
107
-	* @return bool False if no hook got executed, true otherwise
108
-	*/
109
-	function call_hook($definition)
110
-	{
111
-		$class = (!is_array($definition)) ? '__global' : $definition[0];
112
-		$function = (!is_array($definition)) ? $definition : $definition[1];
113
-
114
-		if (!empty($this->hooks[$class][$function]))
115
-		{
116
-			// Developer tries to call a hooked function within the hooked function...
117
-			if ($this->current_hook !== NULL && $this->current_hook['class'] === $class && $this->current_hook['function'] === $function)
118
-			{
119
-				return false;
120
-			}
121
-
122
-			// Call the hook with the arguments attached and store result
123
-			$arguments = func_get_args();
124
-			$this->current_hook = array('class' => $class, 'function' => $function);
125
-			$arguments[0] = &$this;
126
-
127
-			// Call the hook chain...
128
-			if (isset($this->hooks[$class][$function]['standalone']))
129
-			{
130
-				$this->hook_result[$class][$function] = call_user_func_array($this->hooks[$class][$function]['standalone'], $arguments);
131
-			}
132
-			else
133
-			{
134
-				foreach (array('first', 'normal', 'last') as $mode)
135
-				{
136
-					if (!isset($this->hooks[$class][$function][$mode]))
137
-					{
138
-						continue;
139
-					}
140
-
141
-					foreach ($this->hooks[$class][$function][$mode] as $hook)
142
-					{
143
-						$this->hook_result[$class][$function] = call_user_func_array($hook, $arguments);
144
-					}
145
-				}
146
-			}
147
-
148
-			$this->current_hook = NULL;
149
-			return true;
150
-		}
151
-
152
-		$this->current_hook = NULL;
153
-		return false;
154
-	}
155
-
156
-	/**
157
-	* Get result from previously called functions/methods for the same hook
158
-	*
159
-	* @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
160
-	* @return mixed False if nothing returned if there is no result, else array('result' => ... )
161
-	*/
162
-	function previous_hook_result($definition)
163
-	{
164
-		$class = (!is_array($definition)) ? '__global' : $definition[0];
165
-		$function = (!is_array($definition)) ? $definition : $definition[1];
166
-
167
-		if (!empty($this->hooks[$class][$function]) && isset($this->hook_result[$class][$function]))
168
-		{
169
-			return array('result' => $this->hook_result[$class][$function]);
170
-		}
171
-
172
-		return false;
173
-	}
174
-
175
-	/**
176
-	* Check if the called functions/methods returned something.
177
-	*
178
-	* @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
179
-	* @return bool True if results are there, false if not
180
-	*/
181
-	function hook_return($definition)
182
-	{
183
-		$class = (!is_array($definition)) ? '__global' : $definition[0];
184
-		$function = (!is_array($definition)) ? $definition : $definition[1];
185
-
186
-		if (!empty($this->hooks[$class][$function]) && isset($this->hook_result[$class][$function]))
187
-		{
188
-			return true;
189
-		}
190
-
191
-		return false;
192
-	}
193
-
194
-	/**
195
-	* Give actual result from called functions/methods back.
196
-	*
197
-	* @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
198
-	* @return mixed The result
199
-	*/
200
-	function hook_return_result($definition)
201
-	{
202
-		$class = (!is_array($definition)) ? '__global' : $definition[0];
203
-		$function = (!is_array($definition)) ? $definition : $definition[1];
204
-
205
-		if (!empty($this->hooks[$class][$function]) && isset($this->hook_result[$class][$function]))
206
-		{
207
-			$result = $this->hook_result[$class][$function];
208
-			unset($this->hook_result[$class][$function]);
209
-			return $result;
210
-		}
211
-
212
-		return;
213
-	}
214
-
215
-	/**
216
-	* Add new function to the allowed hooks.
217
-	*
218
-	* @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
219
-	*/
220
-	function add_hook($definition)
221
-	{
222
-		if (!is_array($definition))
223
-		{
224
-			$definition = array('__global', $definition);
225
-		}
226
-
227
-		$this->hooks[$definition[0]][$definition[1]] = array();
228
-	}
229
-
230
-	/**
231
-	* Remove function from the allowed hooks.
232
-	*
233
-	* @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
234
-	*/
235
-	function remove_hook($definition)
236
-	{
237
-		$class = (!is_array($definition)) ? '__global' : $definition[0];
238
-		$function = (!is_array($definition)) ? $definition : $definition[1];
239
-
240
-		if (isset($this->hooks[$class][$function]))
241
-		{
242
-			unset($this->hooks[$class][$function]);
243
-
244
-			if (isset($this->hook_result[$class][$function]))
245
-			{
246
-				unset($this->hook_result[$class][$function]);
247
-			}
248
-		}
249
-	}
27
+  /**
28
+   * Registered hooks
29
+   */
30
+  var $hooks = array();
31
+
32
+  /**
33
+   * Results returned by functions called
34
+   */
35
+  var $hook_result = array();
36
+
37
+  /**
38
+   * internal pointer
39
+   */
40
+  var $current_hook = NULL;
41
+
42
+  /**
43
+   * Initialize hook class.
44
+   *
45
+   * @param array $valid_hooks array containing the hookable functions/methods
46
+   */
47
+  function phpbb_hook($valid_hooks)
48
+  {
49
+    foreach ($valid_hooks as $_null => $method)
50
+    {
51
+      $this->add_hook($method);
52
+    }
53
+
54
+    if (function_exists('phpbb_hook_register'))
55
+    {
56
+      phpbb_hook_register($this);
57
+    }
58
+  }
59
+
60
+  /**
61
+   * Register function/method to be called within hook
62
+   * This function is normally called by the modification/application to attach/register the functions.
63
+   *
64
+   * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
65
+   * @param mixed $hook The replacement function/method to be called. Passing function name or array with object/class definition
66
+   * @param string $mode Specify the priority/chain mode. 'normal' -> hook gets appended to the chain. 'standalone' -> only the specified hook gets called - later hooks are not able to overwrite this (E_NOTICE is triggered then). 'first' -> hook is called as the first one within the chain. 'last' -> hook is called as the last one within the chain.
67
+   */
68
+  function register($definition, $hook, $mode = 'normal')
69
+  {
70
+    $class = (!is_array($definition)) ? '__global' : $definition[0];
71
+    $function = (!is_array($definition)) ? $definition : $definition[1];
72
+
73
+    // Method able to be hooked?
74
+    if (isset($this->hooks[$class][$function]))
75
+    {
76
+      switch ($mode)
77
+      {
78
+        case 'standalone':
79
+          if (!isset($this->hooks[$class][$function]['standalone']))
80
+          {
81
+            $this->hooks[$class][$function] = array('standalone' => $hook);
82
+          }
83
+          else
84
+          {
85
+            trigger_error('Hook not able to be called standalone, previous hook already standalone.', E_NOTICE);
86
+          }
87
+        break;
88
+
89
+        case 'first':
90
+        case 'last':
91
+          $this->hooks[$class][$function][$mode][] = $hook;
92
+        break;
93
+
94
+        case 'normal':
95
+        default:
96
+          $this->hooks[$class][$function]['normal'][] = $hook;
97
+        break;
98
+      }
99
+    }
100
+  }
101
+
102
+  /**
103
+   * Calling all functions/methods attached to a specified hook.
104
+   * Called by the function allowing hooks...
105
+   *
106
+   * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
107
+   * @return bool False if no hook got executed, true otherwise
108
+   */
109
+  function call_hook($definition)
110
+  {
111
+    $class = (!is_array($definition)) ? '__global' : $definition[0];
112
+    $function = (!is_array($definition)) ? $definition : $definition[1];
113
+
114
+    if (!empty($this->hooks[$class][$function]))
115
+    {
116
+      // Developer tries to call a hooked function within the hooked function...
117
+      if ($this->current_hook !== NULL && $this->current_hook['class'] === $class && $this->current_hook['function'] === $function)
118
+      {
119
+        return false;
120
+      }
121
+
122
+      // Call the hook with the arguments attached and store result
123
+      $arguments = func_get_args();
124
+      $this->current_hook = array('class' => $class, 'function' => $function);
125
+      $arguments[0] = &$this;
126
+
127
+      // Call the hook chain...
128
+      if (isset($this->hooks[$class][$function]['standalone']))
129
+      {
130
+        $this->hook_result[$class][$function] = call_user_func_array($this->hooks[$class][$function]['standalone'], $arguments);
131
+      }
132
+      else
133
+      {
134
+        foreach (array('first', 'normal', 'last') as $mode)
135
+        {
136
+          if (!isset($this->hooks[$class][$function][$mode]))
137
+          {
138
+            continue;
139
+          }
140
+
141
+          foreach ($this->hooks[$class][$function][$mode] as $hook)
142
+          {
143
+            $this->hook_result[$class][$function] = call_user_func_array($hook, $arguments);
144
+          }
145
+        }
146
+      }
147
+
148
+      $this->current_hook = NULL;
149
+      return true;
150
+    }
151
+
152
+    $this->current_hook = NULL;
153
+    return false;
154
+  }
155
+
156
+  /**
157
+   * Get result from previously called functions/methods for the same hook
158
+   *
159
+   * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
160
+   * @return mixed False if nothing returned if there is no result, else array('result' => ... )
161
+   */
162
+  function previous_hook_result($definition)
163
+  {
164
+    $class = (!is_array($definition)) ? '__global' : $definition[0];
165
+    $function = (!is_array($definition)) ? $definition : $definition[1];
166
+
167
+    if (!empty($this->hooks[$class][$function]) && isset($this->hook_result[$class][$function]))
168
+    {
169
+      return array('result' => $this->hook_result[$class][$function]);
170
+    }
171
+
172
+    return false;
173
+  }
174
+
175
+  /**
176
+   * Check if the called functions/methods returned something.
177
+   *
178
+   * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
179
+   * @return bool True if results are there, false if not
180
+   */
181
+  function hook_return($definition)
182
+  {
183
+    $class = (!is_array($definition)) ? '__global' : $definition[0];
184
+    $function = (!is_array($definition)) ? $definition : $definition[1];
185
+
186
+    if (!empty($this->hooks[$class][$function]) && isset($this->hook_result[$class][$function]))
187
+    {
188
+      return true;
189
+    }
190
+
191
+    return false;
192
+  }
193
+
194
+  /**
195
+   * Give actual result from called functions/methods back.
196
+   *
197
+   * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
198
+   * @return mixed The result
199
+   */
200
+  function hook_return_result($definition)
201
+  {
202
+    $class = (!is_array($definition)) ? '__global' : $definition[0];
203
+    $function = (!is_array($definition)) ? $definition : $definition[1];
204
+
205
+    if (!empty($this->hooks[$class][$function]) && isset($this->hook_result[$class][$function]))
206
+    {
207
+      $result = $this->hook_result[$class][$function];
208
+      unset($this->hook_result[$class][$function]);
209
+      return $result;
210
+    }
211
+
212
+    return;
213
+  }
214
+
215
+  /**
216
+   * Add new function to the allowed hooks.
217
+   *
218
+   * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
219
+   */
220
+  function add_hook($definition)
221
+  {
222
+    if (!is_array($definition))
223
+    {
224
+      $definition = array('__global', $definition);
225
+    }
226
+
227
+    $this->hooks[$definition[0]][$definition[1]] = array();
228
+  }
229
+
230
+  /**
231
+   * Remove function from the allowed hooks.
232
+   *
233
+   * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
234
+   */
235
+  function remove_hook($definition)
236
+  {
237
+    $class = (!is_array($definition)) ? '__global' : $definition[0];
238
+    $function = (!is_array($definition)) ? $definition : $definition[1];
239
+
240
+    if (isset($this->hooks[$class][$function]))
241
+    {
242
+      unset($this->hooks[$class][$function]);
243
+
244
+      if (isset($this->hook_result[$class][$function]))
245
+      {
246
+        unset($this->hook_result[$class][$function]);
247
+      }
248
+    }
249
+  }
250 250
 }
Please login to merge, or discard this patch.
Braces   +11 added lines, -22 removed lines patch added patch discarded remove patch
@@ -22,8 +22,7 @@  discard block
 block discarded – undo
22 22
 /**
23 23
 * phpBB Hook Class
24 24
 */
25
-class phpbb_hook
26
-{
25
+class phpbb_hook {
27 26
 	/**
28 27
 	* Registered hooks
29 28
 	*/
@@ -44,8 +43,7 @@  discard block
 block discarded – undo
44 43
 	*
45 44
 	* @param array $valid_hooks array containing the hookable functions/methods
46 45
 	*/
47
-	function phpbb_hook($valid_hooks)
48
-	{
46
+	function phpbb_hook($valid_hooks) {
49 47
 		foreach ($valid_hooks as $_null => $method)
50 48
 		{
51 49
 			$this->add_hook($method);
@@ -65,8 +63,7 @@  discard block
 block discarded – undo
65 63
 	* @param mixed $hook The replacement function/method to be called. Passing function name or array with object/class definition
66 64
 	* @param string $mode Specify the priority/chain mode. 'normal' -> hook gets appended to the chain. 'standalone' -> only the specified hook gets called - later hooks are not able to overwrite this (E_NOTICE is triggered then). 'first' -> hook is called as the first one within the chain. 'last' -> hook is called as the last one within the chain.
67 65
 	*/
68
-	function register($definition, $hook, $mode = 'normal')
69
-	{
66
+	function register($definition, $hook, $mode = 'normal') {
70 67
 		$class = (!is_array($definition)) ? '__global' : $definition[0];
71 68
 		$function = (!is_array($definition)) ? $definition : $definition[1];
72 69
 
@@ -79,8 +76,7 @@  discard block
 block discarded – undo
79 76
 					if (!isset($this->hooks[$class][$function]['standalone']))
80 77
 					{
81 78
 						$this->hooks[$class][$function] = array('standalone' => $hook);
82
-					}
83
-					else
79
+					} else
84 80
 					{
85 81
 						trigger_error('Hook not able to be called standalone, previous hook already standalone.', E_NOTICE);
86 82
 					}
@@ -106,8 +102,7 @@  discard block
 block discarded – undo
106 102
 	* @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
107 103
 	* @return bool False if no hook got executed, true otherwise
108 104
 	*/
109
-	function call_hook($definition)
110
-	{
105
+	function call_hook($definition) {
111 106
 		$class = (!is_array($definition)) ? '__global' : $definition[0];
112 107
 		$function = (!is_array($definition)) ? $definition : $definition[1];
113 108
 
@@ -128,8 +123,7 @@  discard block
 block discarded – undo
128 123
 			if (isset($this->hooks[$class][$function]['standalone']))
129 124
 			{
130 125
 				$this->hook_result[$class][$function] = call_user_func_array($this->hooks[$class][$function]['standalone'], $arguments);
131
-			}
132
-			else
126
+			} else
133 127
 			{
134 128
 				foreach (array('first', 'normal', 'last') as $mode)
135 129
 				{
@@ -159,8 +153,7 @@  discard block
 block discarded – undo
159 153
 	* @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
160 154
 	* @return mixed False if nothing returned if there is no result, else array('result' => ... )
161 155
 	*/
162
-	function previous_hook_result($definition)
163
-	{
156
+	function previous_hook_result($definition) {
164 157
 		$class = (!is_array($definition)) ? '__global' : $definition[0];
165 158
 		$function = (!is_array($definition)) ? $definition : $definition[1];
166 159
 
@@ -178,8 +171,7 @@  discard block
 block discarded – undo
178 171
 	* @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
179 172
 	* @return bool True if results are there, false if not
180 173
 	*/
181
-	function hook_return($definition)
182
-	{
174
+	function hook_return($definition) {
183 175
 		$class = (!is_array($definition)) ? '__global' : $definition[0];
184 176
 		$function = (!is_array($definition)) ? $definition : $definition[1];
185 177
 
@@ -197,8 +189,7 @@  discard block
 block discarded – undo
197 189
 	* @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
198 190
 	* @return mixed The result
199 191
 	*/
200
-	function hook_return_result($definition)
201
-	{
192
+	function hook_return_result($definition) {
202 193
 		$class = (!is_array($definition)) ? '__global' : $definition[0];
203 194
 		$function = (!is_array($definition)) ? $definition : $definition[1];
204 195
 
@@ -217,8 +208,7 @@  discard block
 block discarded – undo
217 208
 	*
218 209
 	* @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
219 210
 	*/
220
-	function add_hook($definition)
221
-	{
211
+	function add_hook($definition) {
222 212
 		if (!is_array($definition))
223 213
 		{
224 214
 			$definition = array('__global', $definition);
@@ -232,8 +222,7 @@  discard block
 block discarded – undo
232 222
 	*
233 223
 	* @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
234 224
 	*/
235
-	function remove_hook($definition)
236
-	{
225
+	function remove_hook($definition) {
237 226
 		$class = (!is_array($definition)) ? '__global' : $definition[0];
238 227
 		$function = (!is_array($definition)) ? $definition : $definition[1];
239 228
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	/**
38 38
 	* internal pointer
39 39
 	*/
40
-	var $current_hook = NULL;
40
+	var $current_hook = null;
41 41
 
42 42
 	/**
43 43
 	* Initialize hook class.
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 		if (!empty($this->hooks[$class][$function]))
115 115
 		{
116 116
 			// Developer tries to call a hooked function within the hooked function...
117
-			if ($this->current_hook !== NULL && $this->current_hook['class'] === $class && $this->current_hook['function'] === $function)
117
+			if ($this->current_hook !== null && $this->current_hook['class'] === $class && $this->current_hook['function'] === $function)
118 118
 			{
119 119
 				return false;
120 120
 			}
@@ -145,11 +145,11 @@  discard block
 block discarded – undo
145 145
 				}
146 146
 			}
147 147
 
148
-			$this->current_hook = NULL;
148
+			$this->current_hook = null;
149 149
 			return true;
150 150
 		}
151 151
 
152
-		$this->current_hook = NULL;
152
+		$this->current_hook = null;
153 153
 		return false;
154 154
 	}
155 155
 
Please login to merge, or discard this patch.
admin/admin_analyze_matter.php 1 patch
Spacing   +8 added lines, -9 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
 
16 16
 $constants = get_defined_constants(true);
17 17
 $rpgConstants = array();
18
-foreach($constants['user'] as $constantName => $constantValue) {
19
-  if(substr($constantName, 0, 4) == 'RPG_') {
18
+foreach ($constants['user'] as $constantName => $constantValue) {
19
+  if (substr($constantName, 0, 4) == 'RPG_') {
20 20
     $rpgConstants[$constantValue] = $constantName;
21 21
   }
22 22
 }
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 GROUP BY log_dark_matter_reason, IF(sign((log_dark_matter_amount)) > 0, 1, -1) ORDER BY sum(log_dark_matter_amount) DESC;
34 34
 ");
35 35
 
36
-while($row = classSupernova::$db->db_fetch($result)) {
36
+while ($row = classSupernova::$db->db_fetch($result)) {
37 37
   $row['CONSTANT'] = $rpgConstants[$row['REASON']];
38 38
 
39 39
   $row['DM_AMOUNT_TEXT'] = HelperString::numberFloorAndFormat($row['DM_AMOUNT']);
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
 GROUP BY reason, if(sign((amount)) > 0, 1, -1) ORDER BY sum(amount) DESC;
56 56
 ");
57 57
 
58
-while($row = classSupernova::$db->db_fetch($result)) {
59
-  if(empty($spent[$row['BALANCE']])) {
58
+while ($row = classSupernova::$db->db_fetch($result)) {
59
+  if (empty($spent[$row['BALANCE']])) {
60 60
     $spent[$row['BALANCE']] = array();
61 61
   }
62 62
 
@@ -66,16 +66,15 @@  discard block
 block discarded – undo
66 66
   $spent[$row['BALANCE']] = array_merge_recursive_numeric($spent[$row['BALANCE']], $row);
67 67
 }
68 68
 
69
-foreach($spent as &$row) {
69
+foreach ($spent as &$row) {
70 70
   @$row['TOTAL_COUNT'] = $row['MM_COUNT'] + $row['DM_COUNT'];
71 71
   @$row['TOTAL_AMOUNT'] = $row['MM_AMOUNT'] + $row['DM_AMOUNT'];
72 72
   @$row['TOTAL_AMOUNT_TEXT'] = HelperString::numberFloorAndFormat($row['TOTAL_AMOUNT']);
73 73
   @$row['TOTAL_COUNT_TEXT'] = HelperString::numberFloorAndFormat($row['TOTAL_COUNT']);
74 74
 }
75 75
 
76
-usort($spent, function ($a, $b) {
77
-  return $a['TOTAL_AMOUNT'] < $b['TOTAL_AMOUNT'] ? -1 :
78
-    ($a['TOTAL_AMOUNT'] > $b['TOTAL_AMOUNT'] ? 1 : 0);
76
+usort($spent, function($a, $b) {
77
+  return $a['TOTAL_AMOUNT'] < $b['TOTAL_AMOUNT'] ? -1 : ($a['TOTAL_AMOUNT'] > $b['TOTAL_AMOUNT'] ? 1 : 0);
79 78
 });
80 79
 
81 80
 
Please login to merge, or discard this patch.
admin/includes/admin_planet_edit.inc.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-function admin_planet_edit_mode(&$template, &$admin_planet_edit_mode_list){return sn_function_call('admin_planet_edit_mode', array(&$template, &$admin_planet_edit_mode_list));}
3
+function admin_planet_edit_mode(&$template, &$admin_planet_edit_mode_list) {return sn_function_call('admin_planet_edit_mode', array(&$template, &$admin_planet_edit_mode_list)); }
4 4
 function sn_admin_planet_edit_mode(&$template, &$admin_planet_edit_mode_list)
5 5
 {
6 6
   global $lang;
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
   return $mode;
20 20
 }
21 21
 
22
-function admin_planet_edit_template(&$template, $edit_planet_row, $mode){return sn_function_call('admin_planet_edit_template', array(&$template, $edit_planet_row, $mode));}
22
+function admin_planet_edit_template(&$template, $edit_planet_row, $mode) {return sn_function_call('admin_planet_edit_template', array(&$template, $edit_planet_row, $mode)); }
23 23
 /**
24 24
  * @param template $template
25 25
  * @param $edit_planet_row
@@ -30,13 +30,13 @@  discard block
 block discarded – undo
30 30
   global $lang;
31 31
 
32 32
   $unit_list = sn_get_groups($mode);
33
-  if(empty($unit_list))
33
+  if (empty($unit_list))
34 34
   {
35 35
     return;
36 36
   }
37 37
   $name_list = $lang['tech'];
38 38
 
39
-  foreach($unit_list as $unit_id)
39
+  foreach ($unit_list as $unit_id)
40 40
   {
41 41
     $template->assign_block_vars('unit', array(
42 42
       'ID'    => $unit_id,
@@ -47,10 +47,10 @@  discard block
 block discarded – undo
47 47
   }
48 48
 }
49 49
 
50
-function admin_planet_edit_query_string($unit_id, $unit_amount, $mode){return sn_function_call('admin_planet_edit_query_string', array($unit_id, $unit_amount, $mode));}
50
+function admin_planet_edit_query_string($unit_id, $unit_amount, $mode) {return sn_function_call('admin_planet_edit_query_string', array($unit_id, $unit_amount, $mode)); }
51 51
 function sn_admin_planet_edit_query_string($unit_id, $unit_amount, $mode)
52 52
 {
53
-  if($unit_amount && in_array($unit_id, sn_get_groups($mode)))
53
+  if ($unit_amount && in_array($unit_id, sn_get_groups($mode)))
54 54
   {
55 55
     $unit_amount = round($unit_amount);
56 56
     $unit_name = get_unit_param($unit_id, P_NAME);
Please login to merge, or discard this patch.
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,8 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 function admin_planet_edit_mode(&$template, &$admin_planet_edit_mode_list){return sn_function_call('admin_planet_edit_mode', array(&$template, &$admin_planet_edit_mode_list));}
4
-function sn_admin_planet_edit_mode(&$template, &$admin_planet_edit_mode_list)
5
-{
4
+function sn_admin_planet_edit_mode(&$template, &$admin_planet_edit_mode_list) {
6 5
   global $lang;
7 6
 
8 7
   $admin_planet_edit_mode_list = array_merge(isset($admin_planet_edit_mode_list) ? $admin_planet_edit_mode_list : array(), array(
@@ -25,8 +24,7 @@  discard block
 block discarded – undo
25 24
  * @param $edit_planet_row
26 25
  * @param $mode
27 26
  */
28
-function sn_admin_planet_edit_template(&$template, $edit_planet_row, $mode)
29
-{
27
+function sn_admin_planet_edit_template(&$template, $edit_planet_row, $mode) {
30 28
   global $lang;
31 29
 
32 30
   $unit_list = sn_get_groups($mode);
@@ -48,15 +46,13 @@  discard block
 block discarded – undo
48 46
 }
49 47
 
50 48
 function admin_planet_edit_query_string($unit_id, $unit_amount, $mode){return sn_function_call('admin_planet_edit_query_string', array($unit_id, $unit_amount, $mode));}
51
-function sn_admin_planet_edit_query_string($unit_id, $unit_amount, $mode)
52
-{
49
+function sn_admin_planet_edit_query_string($unit_id, $unit_amount, $mode) {
53 50
   if($unit_amount && in_array($unit_id, sn_get_groups($mode)))
54 51
   {
55 52
     $unit_amount = round($unit_amount);
56 53
     $unit_name = get_unit_param($unit_id, P_NAME);
57 54
     $result = "{$unit_name} = GREATEST(0, {$unit_name} + ({$unit_amount}))";
58
-  }
59
-  else
55
+  } else
60 56
   {
61 57
     $result = '';
62 58
   }
Please login to merge, or discard this patch.
includes/includes/art_artifact.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 {
5 5
   global $lang;
6 6
 
7
-  if(!in_array($unit_id, sn_get_groups('artifacts')))
7
+  if (!in_array($unit_id, sn_get_groups('artifacts')))
8 8
   {
9 9
     return;
10 10
   }
@@ -13,24 +13,24 @@  discard block
 block discarded – undo
13 13
   $user = db_user_by_id($user['id'], true);
14 14
 
15 15
   $unit_level = $artifact_level_old = mrc_get_level($user, array(), $unit_id, true);
16
-  if($unit_level > 0)
16
+  if ($unit_level > 0)
17 17
   {
18 18
     $db_changeset = array();
19
-    switch($unit_id)
19
+    switch ($unit_id)
20 20
     {
21 21
       case ART_LHC:
22 22
       case ART_HOOK_SMALL:
23 23
       case ART_HOOK_MEDIUM:
24 24
       case ART_HOOK_LARGE:
25 25
         $has_moon = DBStaticPlanet::db_planet_by_parent($planetrow['id'], true, '`id`');
26
-        if($planetrow['planet_type'] == PT_PLANET && !$has_moon['id'])
26
+        if ($planetrow['planet_type'] == PT_PLANET && !$has_moon['id'])
27 27
         {
28 28
           $unit_level--;
29 29
           $moon_chance = $unit_id == ART_LHC ? uni_calculate_moon_chance($planetrow['debris_metal'] + $planetrow['debris_crystal']) : (
30 30
             $unit_id == ART_HOOK_MEDIUM ? mt_rand(1100, 8999) : ($unit_id == ART_HOOK_SMALL ? 1100 : 8999)
31 31
           );
32 32
           $random = $unit_id == ART_LHC ? mt_rand(1, 100) : $moon_chance;
33
-          if($random <= $moon_chance)
33
+          if ($random <= $moon_chance)
34 34
           {
35 35
             $new_moon_row = uni_create_moon($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'], $user['id'], $moon_chance);
36 36
             $message = sprintf($lang['art_moon_create'][$unit_id], $new_moon_row['name'], uni_render_coordinates($planetrow), HelperString::numberFloorAndFormat($moon_chance));
@@ -51,14 +51,14 @@  discard block
 block discarded – undo
51 51
       case ART_RCD_MEDIUM:
52 52
       case ART_RCD_LARGE:
53 53
         $planetrow = DBStaticPlanet::db_planet_by_id($planetrow['id'], true);
54
-        if($planetrow['planet_type'] != PT_PLANET)
54
+        if ($planetrow['planet_type'] != PT_PLANET)
55 55
         {
56 56
           $message = $lang['art_rcd_err_moon'];
57 57
           break;
58 58
         }
59 59
 
60 60
         $que = que_get($user['id'], $planetrow['id'], QUE_STRUCTURES, false);
61
-        if(!empty($que['items']))
61
+        if (!empty($que['items']))
62 62
         {
63 63
           $message = $lang['art_rcd_err_que'];
64 64
           break;
@@ -67,15 +67,15 @@  discard block
 block discarded – undo
67 67
         $artifact_deploy = get_unit_param($unit_id, P_DEPLOY);
68 68
 
69 69
         $sectors_used = 0;
70
-        foreach($artifact_deploy as $deploy_unit_id => $deploy_unit_level)
70
+        foreach ($artifact_deploy as $deploy_unit_id => $deploy_unit_level)
71 71
         {
72
-          if(!($levels_deployed = max(0, $deploy_unit_level - mrc_get_level($user, $planetrow, $deploy_unit_id, true, true))))
72
+          if (!($levels_deployed = max(0, $deploy_unit_level - mrc_get_level($user, $planetrow, $deploy_unit_id, true, true))))
73 73
             continue;
74 74
           $sectors_used += $levels_deployed;
75 75
           $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($deploy_unit_id, $levels_deployed, $user, $planetrow['id']);
76 76
         }
77 77
 
78
-        if($sectors_used == 0)
78
+        if ($sectors_used == 0)
79 79
         {
80 80
           $message = $lang['art_rcd_err_no_sense'];
81 81
           break;
@@ -90,13 +90,13 @@  discard block
 block discarded – undo
90 90
         $que_item = null;
91 91
         $que = que_get($user['id'], $planetrow['id'], QUE_RESEARCH, true);
92 92
         $current_que = &$que['ques'][QUE_RESEARCH][$user['id']][0];
93
-        if(!empty($current_que))
93
+        if (!empty($current_que))
94 94
         {
95 95
           reset($current_que);
96 96
           $que_item = &$que['ques'][QUE_RESEARCH][$user['id']][0][key($current_que)];
97 97
         }
98 98
 
99
-        if(!empty($que_item) && $que_item['que_time_left'] > 60)
99
+        if (!empty($que_item) && $que_item['que_time_left'] > 60)
100 100
         {
101 101
           $unit_level--;
102 102
           $old_time = $que_item['que_time_left'];
@@ -117,13 +117,13 @@  discard block
 block discarded – undo
117 117
         $que = que_get($user['id'], $planetrow['id'], QUE_STRUCTURES, true);
118 118
         $current_que = &$que['ques'][QUE_STRUCTURES][$user['id']][$planetrow['id']];
119 119
         // $que_item = &$que['que'][QUE_STRUCTURES][0];
120
-        if(!empty($current_que))
120
+        if (!empty($current_que))
121 121
         {
122 122
           reset($current_que);
123 123
           $que_item = &$que['ques'][QUE_STRUCTURES][$user['id']][$planetrow['id']][key($current_que)];
124 124
         }
125 125
 
126
-        if(isset($que_item) && $que_item['que_time_left'] > 60)
126
+        if (isset($que_item) && $que_item['que_time_left'] > 60)
127 127
         {
128 128
           $unit_level--;
129 129
           $old_time = $que_item['que_time_left'];
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
       break;
142 142
 
143 143
     }
144
-    if($unit_level != $artifact_level_old)
144
+    if ($unit_level != $artifact_level_old)
145 145
     {
146 146
       $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($unit_id, $unit_level - $artifact_level_old, $user);
147 147
       OldDbChangeSet::db_changeset_apply($db_changeset);
Please login to merge, or discard this patch.
Braces   +9 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,7 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-function art_use(&$user, &$planetrow, $unit_id)
4
-{
3
+function art_use(&$user, &$planetrow, $unit_id) {
5 4
   global $lang;
6 5
 
7 6
   if(!in_array($unit_id, sn_get_groups('artifacts')))
@@ -34,14 +33,12 @@  discard block
 block discarded – undo
34 33
           {
35 34
             $new_moon_row = uni_create_moon($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'], $user['id'], $moon_chance);
36 35
             $message = sprintf($lang['art_moon_create'][$unit_id], $new_moon_row['name'], uni_render_coordinates($planetrow), HelperString::numberFloorAndFormat($moon_chance));
37
-          }
38
-          else
36
+          } else
39 37
           {
40 38
             $message = $lang['art_lhc_moon_fail'];
41 39
           }
42 40
           msg_send_simple_message($user['id'], 0, 0, MSG_TYPE_ADMIN, $lang['art_lhc_from'], $lang['art_lhc_subj'], $message);
43
-        }
44
-        else
41
+        } else
45 42
         {
46 43
           $message = $lang['art_moon_exists'];
47 44
         }
@@ -69,8 +66,9 @@  discard block
 block discarded – undo
69 66
         $sectors_used = 0;
70 67
         foreach($artifact_deploy as $deploy_unit_id => $deploy_unit_level)
71 68
         {
72
-          if(!($levels_deployed = max(0, $deploy_unit_level - mrc_get_level($user, $planetrow, $deploy_unit_id, true, true))))
73
-            continue;
69
+          if(!($levels_deployed = max(0, $deploy_unit_level - mrc_get_level($user, $planetrow, $deploy_unit_id, true, true)))) {
70
+                      continue;
71
+          }
74 72
           $sectors_used += $levels_deployed;
75 73
           $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($deploy_unit_id, $levels_deployed, $user, $planetrow['id']);
76 74
         }
@@ -104,8 +102,7 @@  discard block
 block discarded – undo
104 102
           DBStaticQue::db_que_set_time_left_by_id($que_item['que_id'], $que_item['que_time_left']);
105 103
           $message = sprintf($lang['art_heurestic_chip_ok'], $lang['tech'][$que_item['que_unit_id']], $que_item['que_unit_level'], sys_time_human($old_time - $que_item['que_time_left']));
106 104
           msg_send_simple_message($user['id'], 0, 0, MSG_TYPE_QUE, $lang['art_heurestic_chip_subj'], $lang['art_heurestic_chip_subj'], $message);
107
-        }
108
-        else
105
+        } else
109 106
         {
110 107
           $message = $lang['art_heurestic_chip_no_research'];
111 108
         }
@@ -133,8 +130,7 @@  discard block
 block discarded – undo
133 130
             $lang['tech'][$que_item['que_unit_id']], $que_item['que_unit_level'], $planetrow['name'], uni_render_coordinates($planetrow), sys_time_human($old_time - $que_item['que_time_left'])
134 131
           );
135 132
           msg_send_simple_message($user['id'], 0, 0, MSG_TYPE_QUE, $lang['art_nano_builder_subj'], $lang['art_nano_builder_subj'], $message);
136
-        }
137
-        else
133
+        } else
138 134
         {
139 135
           $message = $lang['art_nano_builder_no_que'];
140 136
         }
@@ -146,8 +142,7 @@  discard block
 block discarded – undo
146 142
       $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($unit_id, $unit_level - $artifact_level_old, $user);
147 143
       OldDbChangeSet::db_changeset_apply($db_changeset);
148 144
     }
149
-  }
150
-  else
145
+  } else
151 146
   {
152 147
     $message = $lang['art_err_no_artifact'];
153 148
   }
Please login to merge, or discard this patch.
includes/includes/market_fleeter.inc 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if(!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) {
3
+if (!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) {
4 4
   $debug->error("Attempt to call market page mode {$mode} directly - not from market.php", 'Forbidden', 403);
5 5
 }
6 6
 
@@ -12,8 +12,8 @@  discard block
 block discarded – undo
12 12
   'rpg_cost' => $rpg_cost,
13 13
 ));
14 14
 
15
-if(is_array($shipList)) {
16
-  if(mrc_get_level($user, null, RES_DARK_MATTER) < $rpg_cost) {
15
+if (is_array($shipList)) {
16
+  if (mrc_get_level($user, null, RES_DARK_MATTER) < $rpg_cost) {
17 17
     $intError = MARKET_NO_DM;
18 18
   }
19 19
 
@@ -30,30 +30,30 @@  discard block
 block discarded – undo
30 30
   $qry = array();
31 31
   $total = array();
32 32
   $db_changeset = array();
33
-  foreach($shipList as $shipID => &$shipCount) {
33
+  foreach ($shipList as $shipID => &$shipCount) {
34 34
     $shipCount = ceil(floatval($shipCount));
35
-    if(!$shipCount) {
35
+    if (!$shipCount) {
36 36
       continue;
37 37
     }
38 38
 
39
-    if($shipCount < 0) {
39
+    if ($shipCount < 0) {
40 40
       $debug->warning('User supplied negative ship count on Black Market page', 'Hack Attempt', 307);
41 41
       $intError = MARKET_NEGATIVE_SHIPS;
42 42
       break;
43 43
     }
44 44
 
45
-    if($mode == MARKET_SCRAPPER) {
45
+    if ($mode == MARKET_SCRAPPER) {
46 46
       $amount = mrc_get_level($user, $planetrow, $shipID, true, true); // $planetrow[get_unit_param($shipID, P_NAME)];
47
-    } elseif($mode == MARKET_STOCKMAN) {
47
+    } elseif ($mode == MARKET_STOCKMAN) {
48 48
       $amount = $stock[$shipID];
49 49
     }
50 50
 
51
-    if($amount < $shipCount) {
51
+    if ($amount < $shipCount) {
52 52
       $intError = $error_no_stock;
53 53
       break;
54 54
     }
55 55
 
56
-    if(!in_array($shipID, sn_get_groups('fleet'))) {
56
+    if (!in_array($shipID, sn_get_groups('fleet'))) {
57 57
       $debug->warning('Hack Attempt', 'User supplied non-ship unit ID on Black Market page', 306);
58 58
       $intError = MARKET_NOT_A_SHIP;
59 59
       break;
@@ -69,16 +69,16 @@  discard block
 block discarded – undo
69 69
     $resTemp[RES_CRYSTAL] = floor($build_data[BUILD_CREATE][RES_CRYSTAL] * $shipCount * $config_rpg_scrape_crystal * (-$multiplier));
70 70
     $resTemp[RES_DEUTERIUM] = floor($build_data[BUILD_CREATE][RES_DEUTERIUM] * $shipCount * $config_rpg_scrape_deuterium * (-$multiplier));
71 71
 
72
-    foreach($resTemp as $resID => $resCount) {
72
+    foreach ($resTemp as $resID => $resCount) {
73 73
       $total[$resID] += $resCount;
74 74
     }
75 75
 
76 76
     $message .= "<li>{$lang['tech'][$shipID]}: " . HelperString::numberFloorAndFormat($shipCount);
77 77
   }
78 78
 
79
-  if($mode == MARKET_STOCKMAN && $intError == MARKET_DEAL) {
80
-    foreach($total as $resID => $resCount) {
81
-      if(mrc_get_level($user, $planetrow, $resID, true, true) < -$resCount) {
79
+  if ($mode == MARKET_STOCKMAN && $intError == MARKET_DEAL) {
80
+    foreach ($total as $resID => $resCount) {
81
+      if (mrc_get_level($user, $planetrow, $resID, true, true) < -$resCount) {
82 82
         $intError = MARKET_NO_RESOURCES;
83 83
         $debug->warning('Trying to use bug in s/h market', 'S/H Ship Market', 301);
84 84
         break;
@@ -88,10 +88,10 @@  discard block
 block discarded – undo
88 88
 
89 89
   $intError = ($intError == MARKET_DEAL) && (array_sum($total) == 0) ? $error_zero_res : $intError;
90 90
 
91
-  if($intError == MARKET_DEAL) {
91
+  if ($intError == MARKET_DEAL) {
92 92
     $message .= '</ul>' . $lang["eco_mrk_{$submode}_res"] . '<ul>';
93
-    foreach($total as $resID => $resCount) {
94
-      if(!$resCount) {
93
+    foreach ($total as $resID => $resCount) {
94
+      if (!$resCount) {
95 95
         continue;
96 96
       }
97 97
 
@@ -125,38 +125,38 @@  discard block
 block discarded – undo
125 125
       'MESSAGE' => $lang['eco_mrk_errors'][$intError],
126 126
     ));
127 127
 
128
-    foreach($shipList as $shipID => $shipCount) {
128
+    foreach ($shipList as $shipID => $shipCount) {
129 129
       $data['ships'][$shipID] = max(0, intval($shipCount));
130 130
     }
131 131
   }
132 132
 }
133 133
 $message = '';
134 134
 
135
-if(!$config->eco_stockman_fleet && $config->eco_stockman_fleet_populate) {
136
-  $config->db_saveItem('eco_stockman_fleet', sys_unit_arr2str(array_map(function($item){return mt_rand(1, 1000);}, sn_get_groups('fleet'))));
135
+if (!$config->eco_stockman_fleet && $config->eco_stockman_fleet_populate) {
136
+  $config->db_saveItem('eco_stockman_fleet', sys_unit_arr2str(array_map(function($item) {return mt_rand(1, 1000); }, sn_get_groups('fleet'))));
137 137
 }
138 138
 
139 139
 tpl_set_resource_info($template, $planetrow, array());
140 140
 
141
-if(!$array) {
141
+if (!$array) {
142 142
   $array = array();
143 143
 }
144 144
 
145 145
 $group_fleet = sn_get_groups('fleet');
146
-foreach($array as $key => $value) {
147
-  if($mode == MARKET_SCRAPPER) {
146
+foreach ($array as $key => $value) {
147
+  if ($mode == MARKET_SCRAPPER) {
148 148
     $shipID = $value;
149 149
     $amount = mrc_get_level($user, $planetrow, $shipID, false, true); // $planetrow[get_unit_param($shipID, P_NAME)];
150
-  } elseif($mode == MARKET_STOCKMAN) {
150
+  } elseif ($mode == MARKET_STOCKMAN) {
151 151
     $shipID = $key;
152 152
     $amount = $value;
153 153
   }
154 154
 
155
-  if(!in_array($shipID, $group_fleet)) {
155
+  if (!in_array($shipID, $group_fleet)) {
156 156
     continue;
157 157
   }
158 158
 
159
-  if($amount > 0) {
159
+  if ($amount > 0) {
160 160
     $build_data = eco_get_build_data($user, $planetrow, $shipID);
161 161
     $template->assign_block_vars('ships', array(
162 162
       'ID'        => $shipID,
Please login to merge, or discard this patch.
includes/pages/imperator.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 //    $same_user = false;
48 48
 //  }
49 49
 
50
-  if(!$user_data) {
50
+  if (!$user_data) {
51 51
     messageBox($lang['imp_imperator_none'], $lang['sys_error'], 'index.php', 10);
52 52
     die();
53 53
   }
@@ -58,8 +58,8 @@  discard block
 block discarded – undo
58 58
   $stat_array = array();
59 59
   $query = doquery("SELECT * FROM {{statpoints}} WHERE `stat_type` = 1 AND `id_owner` = {$user_id} ORDER BY `stat_code` DESC;");
60 60
   $stat_count = classSupernova::$db->db_affected_rows();
61
-  while($row = db_fetch($query)) {
62
-    foreach($stat_fields as $field_db_name => $field_template_name) {
61
+  while ($row = db_fetch($query)) {
62
+    foreach ($stat_fields as $field_db_name => $field_template_name) {
63 63
       // $stat_count - $row['stat_code'] - для реверсирования ID статы в JS
64 64
       $stat_array[$field_template_name]['DATA'][$stat_count - $row['stat_code']] = $row[$field_db_name];
65 65
     }
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 
68 68
   $stat_array_date = $stat_array['STAT_DATE'];
69 69
   empty($stat_array_date['DATA']) ? $stat_array_date['DATA'] = array() : false;
70
-  foreach($stat_array_date['DATA'] as $key => $value) {
70
+  foreach ($stat_array_date['DATA'] as $key => $value) {
71 71
     $template->assign_block_vars('stat_date', array(
72 72
       'ID' => $key,
73 73
       'VALUE' => $value,
@@ -77,21 +77,21 @@  discard block
 block discarded – undo
77 77
 
78 78
   unset($stat_array['STAT_DATE']);
79 79
   $template_data = array();
80
-  foreach($stat_array as $stat_type => &$stat_type_data) {
80
+  foreach ($stat_array as $stat_type => &$stat_type_data) {
81 81
     $reverse_min_max = strpos($stat_type, '_RANK') !== false;
82 82
     $stat_type_data['MIN'] = $reverse_min_max ? max($stat_type_data['DATA']) : min($stat_type_data['DATA']);
83 83
     $stat_type_data['MAX'] = $reverse_min_max ? min($stat_type_data['DATA']) : max($stat_type_data['DATA']);
84 84
     $stat_type_data['AVG'] = average($stat_type_data['DATA']);
85
-    foreach($stat_type_data['DATA'] as $key => $value) {
85
+    foreach ($stat_type_data['DATA'] as $key => $value) {
86 86
       $stat_type_data['PERCENT'][$key] = ($stat_type_data['MAX'] - $value ? ($value - $stat_type_data['MIN']) / ($stat_type_data['MAX'] - $stat_type_data['MIN']) : 1) * 100;
87 87
       $template_data[$stat_type][$key]['ID'] = $key;
88 88
       $template_data[$stat_type][$key]['VALUE'] = $value;
89
-      $template_data[$stat_type][$key]['DELTA'] = ($reverse_min_max ? $stat_type_data['MIN']  - $value : $value - $stat_type_data['MAX']);
89
+      $template_data[$stat_type][$key]['DELTA'] = ($reverse_min_max ? $stat_type_data['MIN'] - $value : $value - $stat_type_data['MAX']);
90 90
       $template_data[$stat_type][$key]['PERCENT'] = $stat_type_data['PERCENT'][$key];
91 91
     }
92 92
   }
93 93
 
94
-  foreach($template_data as $stat_type => $stat_type_data) {
94
+  foreach ($template_data as $stat_type => $stat_type_data) {
95 95
     $template->assign_block_vars('stat', array(
96 96
       'TYPE' => $stat_type,
97 97
       'TEXT' => $lang['imp_stat_types'][$stat_type],
@@ -99,13 +99,13 @@  discard block
 block discarded – undo
99 99
       'MAX' => $stat_array[$stat_type]['MAX'],
100 100
       'AVG' => $stat_array[$stat_type]['AVG'],
101 101
     ));
102
-    foreach($stat_type_data as $stat_entry) {
102
+    foreach ($stat_type_data as $stat_entry) {
103 103
       $template->assign_block_vars('stat.entry', $stat_entry);
104 104
     }
105 105
   }
106 106
 
107 107
 
108
-  if($same_user) {
108
+  if ($same_user) {
109 109
     rpg_level_up($user, RPG_STRUCTURE);
110 110
     rpg_level_up($user, RPG_RAID);
111 111
     rpg_level_up($user, RPG_TECH);
@@ -139,29 +139,29 @@  discard block
 block discarded – undo
139 139
     'builder_xp'           => HelperString::numberFloorAndFormat($user_data['xpminier']),
140 140
     'builder_lvl'          => HelperString::numberFloorAndFormat($user_data['lvl_minier']),
141 141
     'builder_lvl_st'       => HelperString::numberFloorAndFormat(rpg_get_miner_xp($user_data['lvl_minier'])),
142
-    'builder_lvl_up'       => HelperString::numberFloorAndFormat(rpg_get_miner_xp($user_data['lvl_minier']+1)),
142
+    'builder_lvl_up'       => HelperString::numberFloorAndFormat(rpg_get_miner_xp($user_data['lvl_minier'] + 1)),
143 143
     'raid_xp'              => HelperString::numberFloorAndFormat($user_data['xpraid']),
144 144
     'raid_lvl'             => HelperString::numberFloorAndFormat($user_data['lvl_raid']),
145
-    'raid_lvl_up'          => HelperString::numberFloorAndFormat(rpg_get_raider_xp($user_data['lvl_raid']+1)),
145
+    'raid_lvl_up'          => HelperString::numberFloorAndFormat(rpg_get_raider_xp($user_data['lvl_raid'] + 1)),
146 146
     'raids'                => HelperString::numberFloorAndFormat($user_data['raids']),
147 147
     'raidswin'             => HelperString::numberFloorAndFormat($user_data['raidswin']),
148 148
     'raidsloose'           => HelperString::numberFloorAndFormat($user_data['raidsloose']),
149 149
     'tech_xp'              => HelperString::numberFloorAndFormat($user_data['player_rpg_tech_xp']),
150 150
     'tech_lvl'             => HelperString::numberFloorAndFormat($user_data['player_rpg_tech_level']),
151 151
     'tech_lvl_st'          => HelperString::numberFloorAndFormat(rpg_get_tech_xp($user_data['player_rpg_tech_level'])),
152
-    'tech_lvl_up'          => HelperString::numberFloorAndFormat(rpg_get_tech_xp($user_data['player_rpg_tech_level']+1)),
152
+    'tech_lvl_up'          => HelperString::numberFloorAndFormat(rpg_get_tech_xp($user_data['player_rpg_tech_level'] + 1)),
153 153
 
154 154
     'explore_xp'           => HelperString::numberFloorAndFormat($user_data['player_rpg_explore_xp']),
155 155
     'explore_lvl'          => HelperString::numberFloorAndFormat($user_data['player_rpg_explore_level']),
156 156
     'explore_lvl_st'       => HelperString::numberFloorAndFormat(rpg_get_explore_xp($user_data['player_rpg_explore_level'])),
157
-    'explore_lvl_up'       => HelperString::numberFloorAndFormat(rpg_get_explore_xp($user_data['player_rpg_explore_level']+1)),
158
-
159
-    'build_points'         => HelperString::numberFloorAndFormat( $StatRecord['build_points'] ),
160
-    'tech_points'          => HelperString::numberFloorAndFormat( $StatRecord['tech_points'] ),
161
-    'fleet_points'         => HelperString::numberFloorAndFormat( $StatRecord['fleet_points'] ),
162
-    'defs_points'          => HelperString::numberFloorAndFormat( $StatRecord['defs_points'] ),
163
-    'res_points'           => HelperString::numberFloorAndFormat( $StatRecord['res_points'] ),
164
-    'total_points'         => HelperString::numberFloorAndFormat( $StatRecord['total_points'] ),
157
+    'explore_lvl_up'       => HelperString::numberFloorAndFormat(rpg_get_explore_xp($user_data['player_rpg_explore_level'] + 1)),
158
+
159
+    'build_points'         => HelperString::numberFloorAndFormat($StatRecord['build_points']),
160
+    'tech_points'          => HelperString::numberFloorAndFormat($StatRecord['tech_points']),
161
+    'fleet_points'         => HelperString::numberFloorAndFormat($StatRecord['fleet_points']),
162
+    'defs_points'          => HelperString::numberFloorAndFormat($StatRecord['defs_points']),
163
+    'res_points'           => HelperString::numberFloorAndFormat($StatRecord['res_points']),
164
+    'total_points'         => HelperString::numberFloorAndFormat($StatRecord['total_points']),
165 165
     'user_rank'            => $StatRecord['total_rank'],
166 166
     'RANK_DIFF'            => $StatRecord['total_old_rank'] - $StatRecord['total_rank'],
167 167
 
Please login to merge, or discard this patch.
classes/DBAL/DbFieldDescription.php 1 patch
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
     $this->Field = isset($mySqlDescription['Field']) ? $mySqlDescription['Field'] : null;
30 30
     $this->Type = isset($mySqlDescription['Type']) ? $mySqlDescription['Type'] : null;
31 31
     $this->Collation = isset($mySqlDescription['Collation']) ? $mySqlDescription['Collation'] : null;
32
-    $this->Null = isset($mySqlDescription['Null']) ? $mySqlDescription['Null'] : null;
32
+    $this->null = isset($mySqlDescription['Null']) ? $mySqlDescription['Null'] : null;
33 33
     $this->Key = isset($mySqlDescription['Key']) ? $mySqlDescription['Key'] : null;
34 34
     $this->Default = isset($mySqlDescription['Default']) ? $mySqlDescription['Default'] : null;
35 35
     $this->Extra = isset($mySqlDescription['Extra']) ? $mySqlDescription['Extra'] : null;
Please login to merge, or discard this patch.
classes/classCache.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 
151 151
   public function unset_by_prefix($prefix_unset = '') {
152 152
     static $array_clear;
153
-    !$array_clear ? $array_clear = function (&$v, $k, $p) {
153
+    !$array_clear ? $array_clear = function(&$v, $k, $p) {
154 154
       strpos($k, $p) === 0 ? $v = null : false;
155 155
     } : false;
156 156
 
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
     if ($this->$name[0] === null) {
206 206
       for ($i = count($name) - 1; $i > 0; $i--) {
207 207
         $cName = "{$name[$i]}_COUNT";
208
-        $cName1 = "{$name[$i-1]}_COUNT";
208
+        $cName1 = "{$name[$i - 1]}_COUNT";
209 209
         if ($this->$cName1 == null || $i == 1) {
210 210
           $this->$cName++;
211 211
         }
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
     $count = count($name);
252 252
     for ($i = 1; $i < $count; $i++) {
253 253
       $cName = "{$name[$i]}_COUNT";
254
-      $cName1 = "{$name[$i-1]}_COUNT";
254
+      $cName1 = "{$name[$i - 1]}_COUNT";
255 255
 
256 256
       if ($i == 1 || $this->$cName1 === null) {
257 257
         $this->$cName--;
Please login to merge, or discard this patch.