@@ -209,6 +209,10 @@ discard block |
||
209 | 209 | * @return array|bool|resource |
210 | 210 | */ |
211 | 211 | // OK v4.5 |
212 | + |
|
213 | + /** |
|
214 | + * @param string $salt_unsafe |
|
215 | + */ |
|
212 | 216 | public function password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe = null) { |
213 | 217 | $result = parent::password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe); |
214 | 218 | if($result) { |
@@ -218,6 +222,9 @@ discard block |
||
218 | 222 | return $result; |
219 | 223 | } |
220 | 224 | |
225 | + /** |
|
226 | + * @param Account $account_to_impersonate |
|
227 | + */ |
|
221 | 228 | public function impersonate($account_to_impersonate) { |
222 | 229 | $this->cookie_set($account_to_impersonate); |
223 | 230 | } |
@@ -93,12 +93,12 @@ discard block |
||
93 | 93 | $this->prepare(); |
94 | 94 | |
95 | 95 | $this->manifest['active'] = false; |
96 | - if(!empty($this->config) && is_array($this->config['db'])) { |
|
96 | + if (!empty($this->config) && is_array($this->config['db'])) { |
|
97 | 97 | // БД, отличная от стандартной |
98 | 98 | $this->db = new db_mysql(); |
99 | 99 | |
100 | 100 | $this->db->sn_db_connect($this->config['db']); |
101 | - if($this->manifest['active'] = $this->db->connected) { |
|
101 | + if ($this->manifest['active'] = $this->db->connected) { |
|
102 | 102 | $this->provider_id = ACCOUNT_PROVIDER_CENTRAL; |
103 | 103 | |
104 | 104 | $this->domain = $this->config['domain']; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | } |
113 | 113 | |
114 | 114 | // Fallback to local DB |
115 | - if(!$this->manifest['active']) { |
|
115 | + if (!$this->manifest['active']) { |
|
116 | 116 | $this->db = classSupernova::$db; |
117 | 117 | |
118 | 118 | $this->provider_id = ACCOUNT_PROVIDER_LOCAL; |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | $this->manifest['active'] = true; |
126 | 126 | } |
127 | 127 | |
128 | - $this->cookie_name_impersonate = $this->cookie_name . AUTH_COOKIE_IMPERSONATE_SUFFIX; |
|
128 | + $this->cookie_name_impersonate = $this->cookie_name.AUTH_COOKIE_IMPERSONATE_SUFFIX; |
|
129 | 129 | |
130 | 130 | $this->account = new Account($this->db); |
131 | 131 | $this->confirmation = new Confirmation($this->db); |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | // OK v4.5 |
167 | 167 | public function password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe = null) { |
168 | 168 | $result = parent::password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe); |
169 | - if($result) { |
|
169 | + if ($result) { |
|
170 | 170 | $this->cookie_set(); |
171 | 171 | } |
172 | 172 | |
@@ -194,12 +194,12 @@ discard block |
||
194 | 194 | */ |
195 | 195 | // OK v4.6 |
196 | 196 | protected function password_reset_send_code() { |
197 | - if(!$this->is_password_reset) { |
|
197 | + if (!$this->is_password_reset) { |
|
198 | 198 | return $this->account_login_status; |
199 | 199 | } |
200 | 200 | |
201 | 201 | // Проверяем поддержку сброса пароля |
202 | - if(!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) { |
|
202 | + if (!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) { |
|
203 | 203 | return $this->account_login_status; |
204 | 204 | } |
205 | 205 | |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | unset($this->account); |
210 | 210 | $this->account = new Account($this->db); |
211 | 211 | |
212 | - if(!$this->account->db_get_by_email($email_unsafe)) { |
|
212 | + if (!$this->account->db_get_by_email($email_unsafe)) { |
|
213 | 213 | throw new Exception(PASSWORD_RESTORE_ERROR_EMAIL_NOT_EXISTS, ERR_ERROR); |
214 | 214 | // return $this->account_login_status; |
215 | 215 | } |
@@ -219,14 +219,14 @@ discard block |
||
219 | 219 | |
220 | 220 | // TODO - Проверять уровень доступа аккаунта! |
221 | 221 | // Аккаунты с АУТЛЕВЕЛ больше 0 - НЕ СБРАСЫВАЮТ ПАРОЛИ! |
222 | - foreach($user_list as $user_id => $user_data) { |
|
223 | - if($user_data['authlevel'] > AUTH_LEVEL_REGISTERED) { |
|
222 | + foreach ($user_list as $user_id => $user_data) { |
|
223 | + if ($user_data['authlevel'] > AUTH_LEVEL_REGISTERED) { |
|
224 | 224 | throw new Exception(PASSWORD_RESTORE_ERROR_ADMIN_ACCOUNT, ERR_ERROR); |
225 | 225 | } |
226 | 226 | } |
227 | 227 | |
228 | 228 | $confirmation = $this->confirmation->db_confirmation_get_latest_by_type_and_email(CONFIRM_PASSWORD_RESET, $email_unsafe); // OK 4.5 |
229 | - if(isset($confirmation['create_time']) && SN_TIME_NOW - strtotime($confirmation['create_time']) < PERIOD_MINUTE_10) { |
|
229 | + if (isset($confirmation['create_time']) && SN_TIME_NOW - strtotime($confirmation['create_time']) < PERIOD_MINUTE_10) { |
|
230 | 230 | throw new Exception(PASSWORD_RESTORE_ERROR_TOO_OFTEN, ERR_ERROR); |
231 | 231 | } |
232 | 232 | |
@@ -239,11 +239,11 @@ discard block |
||
239 | 239 | |
240 | 240 | @$result = mymail($email_unsafe, |
241 | 241 | sprintf(classLocale::$lang['log_lost_email_title'], classSupernova::$config->game_name), |
242 | - sprintf(classLocale::$lang['log_lost_email_code'], SN_ROOT_VIRTUAL . 'login.php', $confirm_code_unsafe, date(FMT_DATE_TIME, SN_TIME_NOW + AUTH_PASSWORD_RESET_CONFIRMATION_EXPIRE), classSupernova::$config->game_name) |
|
242 | + sprintf(classLocale::$lang['log_lost_email_code'], SN_ROOT_VIRTUAL.'login.php', $confirm_code_unsafe, date(FMT_DATE_TIME, SN_TIME_NOW + AUTH_PASSWORD_RESET_CONFIRMATION_EXPIRE), classSupernova::$config->game_name) |
|
243 | 243 | ); |
244 | 244 | |
245 | 245 | $result = $result ? PASSWORD_RESTORE_SUCCESS_CODE_SENT : PASSWORD_RESTORE_ERROR_SENDING; |
246 | - } catch(Exception $e) { |
|
246 | + } catch (Exception $e) { |
|
247 | 247 | sn_db_transaction_rollback(); |
248 | 248 | $result = $e->getMessage(); |
249 | 249 | } |
@@ -256,46 +256,46 @@ discard block |
||
256 | 256 | * @return int|string |
257 | 257 | */ |
258 | 258 | protected function password_reset_confirm() { |
259 | - if(!$this->is_password_reset_confirm) { |
|
259 | + if (!$this->is_password_reset_confirm) { |
|
260 | 260 | return $this->account_login_status; |
261 | 261 | } |
262 | 262 | |
263 | - if($this->account_login_status != LOGIN_UNDEFINED) { |
|
263 | + if ($this->account_login_status != LOGIN_UNDEFINED) { |
|
264 | 264 | return $this->account_login_status; |
265 | 265 | } |
266 | 266 | |
267 | 267 | // Проверяем поддержку сброса пароля |
268 | - if(!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) { |
|
268 | + if (!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) { |
|
269 | 269 | return $this->account_login_status; |
270 | 270 | } |
271 | 271 | |
272 | 272 | try { |
273 | 273 | $code_unsafe = sys_get_param_str_unsafe('password_reset_code'); |
274 | - if(empty($code_unsafe)) { |
|
274 | + if (empty($code_unsafe)) { |
|
275 | 275 | throw new Exception(PASSWORD_RESTORE_ERROR_CODE_EMPTY, ERR_ERROR); |
276 | 276 | } |
277 | 277 | |
278 | 278 | sn_db_transaction_start(); |
279 | 279 | $confirmation = $this->confirmation->db_confirmation_get_by_type_and_code(CONFIRM_PASSWORD_RESET, $code_unsafe); // OK 4.5 |
280 | 280 | |
281 | - if(empty($confirmation)) { |
|
281 | + if (empty($confirmation)) { |
|
282 | 282 | throw new Exception(PASSWORD_RESTORE_ERROR_CODE_WRONG, ERR_ERROR); |
283 | 283 | } |
284 | 284 | |
285 | - if(SN_TIME_NOW - strtotime($confirmation['create_time']) > AUTH_PASSWORD_RESET_CONFIRMATION_EXPIRE) { |
|
285 | + if (SN_TIME_NOW - strtotime($confirmation['create_time']) > AUTH_PASSWORD_RESET_CONFIRMATION_EXPIRE) { |
|
286 | 286 | throw new Exception(PASSWORD_RESTORE_ERROR_CODE_TOO_OLD, ERR_ERROR); |
287 | 287 | } |
288 | 288 | |
289 | 289 | unset($this->account); |
290 | 290 | $this->account = new Account($this->db); |
291 | 291 | |
292 | - if(!$this->account->db_get_by_email($confirmation['email'])) { |
|
292 | + if (!$this->account->db_get_by_email($confirmation['email'])) { |
|
293 | 293 | throw new Exception(PASSWORD_RESTORE_ERROR_CODE_OK_BUT_NO_ACCOUNT_FOR_EMAIL, ERR_ERROR); |
294 | 294 | } |
295 | 295 | |
296 | 296 | $new_password_unsafe = $this->make_random_password(); |
297 | 297 | $salt_unsafe = $this->password_salt_generate(); |
298 | - if(!$this->account->db_set_password($new_password_unsafe, $salt_unsafe)) { |
|
298 | + if (!$this->account->db_set_password($new_password_unsafe, $salt_unsafe)) { |
|
299 | 299 | // Ошибка смены пароля |
300 | 300 | throw new Exception(AUTH_ERROR_INTERNAL_PASSWORD_CHANGE_ON_RESTORE, ERR_ERROR); |
301 | 301 | } |
@@ -305,14 +305,14 @@ discard block |
||
305 | 305 | $this->cookie_set(); |
306 | 306 | $this->login_cookie(); |
307 | 307 | |
308 | - if($this->account_login_status == LOGIN_SUCCESS) { |
|
308 | + if ($this->account_login_status == LOGIN_SUCCESS) { |
|
309 | 309 | // TODO - НЕ ОБЯЗАТЕЛЬНО ОТПРАВЛЯТЬ ЧЕРЕЗ ЕМЕЙЛ! ЕСЛИ ЭТО ФЕЙСБУЧЕК ИЛИ ВКШЕЧКА - МОЖНО ЧЕРЕЗ ЛС ПИСАТЬ!! |
310 | 310 | $message_header = sprintf(classLocale::$lang['log_lost_email_title'], classSupernova::$config->game_name); |
311 | 311 | $message = sprintf(classLocale::$lang['log_lost_email_pass'], classSupernova::$config->game_name, $this->account->account_name, $new_password_unsafe); |
312 | 312 | @$operation_result = mymail($confirmation['email'], $message_header, htmlspecialchars($message)); |
313 | 313 | |
314 | 314 | $users_translated = PlayerToAccountTranslate::db_translate_get_users_from_account_list($this->provider_id, $this->account->account_id); // OK 4.5 |
315 | - if(!empty($users_translated)) { |
|
315 | + if (!empty($users_translated)) { |
|
316 | 316 | // Отправляем в лички письмо о сбросе пароля |
317 | 317 | |
318 | 318 | // ПО ОПРЕДЕЛЕНИЮ в $users_translated только |
@@ -321,9 +321,9 @@ discard block |
||
321 | 321 | // - игроки, привязанные только к этим аккаунтам |
322 | 322 | // Значит им всем сразу скопом можно отправлять сообщения |
323 | 323 | $message = sprintf(classLocale::$lang['sys_password_reset_message_body'], $new_password_unsafe); |
324 | - $message = sys_bbcodeParse($message) . '<br><br>'; |
|
324 | + $message = sys_bbcodeParse($message).'<br><br>'; |
|
325 | 325 | |
326 | - foreach($users_translated as $user_id => $providers_list) { |
|
326 | + foreach ($users_translated as $user_id => $providers_list) { |
|
327 | 327 | msg_send_simple_message($user_id, 0, SN_TIME_NOW, MSG_TYPE_ADMIN, classLocale::$lang['sys_administration'], classLocale::$lang['sys_login_register_message_title'], $message); |
328 | 328 | } |
329 | 329 | } else { |
@@ -375,10 +375,10 @@ discard block |
||
375 | 375 | // OK v4.5 |
376 | 376 | protected function register() { |
377 | 377 | // TODO РЕГИСТРАЦИЯ ВСЕГДА ДОЛЖНА ЛОГИНИТЬ ПОЛЬЗОВАТЕЛЯ! |
378 | - $this->flog('Регистрация: начинаем. Провайдер ' . $this->provider_id); |
|
378 | + $this->flog('Регистрация: начинаем. Провайдер '.$this->provider_id); |
|
379 | 379 | |
380 | 380 | try { |
381 | - if(!$this->is_register) { |
|
381 | + if (!$this->is_register) { |
|
382 | 382 | $this->flog('Регистрация: не выставлен флаг регистрации - пропускаем'); |
383 | 383 | throw new Exception(LOGIN_UNDEFINED, ERR_ERROR); |
384 | 384 | } |
@@ -388,8 +388,8 @@ discard block |
||
388 | 388 | sn_db_transaction_start(); |
389 | 389 | |
390 | 390 | $this->account->db_get_by_name_or_email($this->input_login_unsafe, $this->input_email_unsafe); |
391 | - if($this->account->is_exists) { |
|
392 | - if($this->account->account_email == $this->input_email_unsafe) { |
|
391 | + if ($this->account->is_exists) { |
|
392 | + if ($this->account->account_email == $this->input_email_unsafe) { |
|
393 | 393 | throw new Exception(REGISTER_ERROR_EMAIL_EXISTS, ERR_ERROR); |
394 | 394 | } else { |
395 | 395 | throw new Exception(REGISTER_ERROR_ACCOUNT_NAME_EXISTS, ERR_ERROR); |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | // А вот это пока не нужно. Трансляцией аккаунтов в юзеров и созданием новых юзеров для новозашедших аккаунтов занимается Auth |
412 | 412 | // $this->register_account(); |
413 | 413 | sn_db_transaction_commit(); |
414 | - } catch(Exception $e) { |
|
414 | + } catch (Exception $e) { |
|
415 | 415 | sn_db_transaction_rollback(); |
416 | 416 | $this->account_login_status == LOGIN_UNDEFINED ? $this->account_login_status = $e->getMessage() : false; |
417 | 417 | } |
@@ -427,19 +427,19 @@ discard block |
||
427 | 427 | */ |
428 | 428 | // OK v4.5 |
429 | 429 | protected function login_cookie() { |
430 | - if($this->account_login_status != LOGIN_UNDEFINED) { |
|
430 | + if ($this->account_login_status != LOGIN_UNDEFINED) { |
|
431 | 431 | return $this->account_login_status; |
432 | 432 | } |
433 | 433 | |
434 | 434 | // Пытаемся войти по куке |
435 | - if(!empty($_COOKIE[$this->cookie_name])) { |
|
436 | - if(count(explode("/%/", $_COOKIE[$this->cookie_name])) < 4) { |
|
435 | + if (!empty($_COOKIE[$this->cookie_name])) { |
|
436 | + if (count(explode("/%/", $_COOKIE[$this->cookie_name])) < 4) { |
|
437 | 437 | list($account_id_unsafe, $cookie_password_hash_salted, $user_remember_me) = explode(AUTH_COOKIE_DELIMETER, $_COOKIE[$this->cookie_name]); |
438 | 438 | } else { |
439 | 439 | list($account_id_unsafe, $user_name, $cookie_password_hash_salted, $user_remember_me) = explode("/%/", $_COOKIE[$this->cookie_name]); |
440 | 440 | } |
441 | 441 | |
442 | - if( |
|
442 | + if ( |
|
443 | 443 | $this->account->db_get_by_id($account_id_unsafe) |
444 | 444 | && ($this->password_encode_for_cookie($this->account->account_password) == $cookie_password_hash_salted) |
445 | 445 | ) { |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | } |
449 | 449 | } |
450 | 450 | |
451 | - if($this->account_login_status != LOGIN_SUCCESS) { |
|
451 | + if ($this->account_login_status != LOGIN_SUCCESS) { |
|
452 | 452 | // Невалидная кука - чистим |
453 | 453 | $this->cookie_clear(); |
454 | 454 | } |
@@ -466,29 +466,29 @@ discard block |
||
466 | 466 | protected function login_username() { |
467 | 467 | // TODO - Логин по старым именам |
468 | 468 | try { |
469 | - if(!$this->is_login) { |
|
469 | + if (!$this->is_login) { |
|
470 | 470 | $this->flog('Логин: не выставлен флаг входа в игру - это не логин'); |
471 | 471 | throw new Exception(LOGIN_UNDEFINED, ERR_ERROR); |
472 | 472 | } |
473 | 473 | |
474 | 474 | // TODO Пустое имя аккаунта |
475 | - if(!$this->input_login_unsafe) { |
|
475 | + if (!$this->input_login_unsafe) { |
|
476 | 476 | throw new Exception(LOGIN_UNDEFINED, ERR_ERROR); |
477 | 477 | } |
478 | 478 | |
479 | 479 | $this->login_validate_input(); |
480 | 480 | |
481 | - if(!$this->account->db_get_by_name($this->input_login_unsafe) && !$this->account->db_get_by_email($this->input_login_unsafe)) { |
|
481 | + if (!$this->account->db_get_by_name($this->input_login_unsafe) && !$this->account->db_get_by_email($this->input_login_unsafe)) { |
|
482 | 482 | throw new Exception(LOGIN_ERROR_USERNAME, ERR_ERROR); |
483 | 483 | } |
484 | 484 | |
485 | - if(!$this->account->password_check($this->input_login_password_raw)) { |
|
485 | + if (!$this->account->password_check($this->input_login_password_raw)) { |
|
486 | 486 | throw new Exception(LOGIN_ERROR_PASSWORD, ERR_ERROR); |
487 | 487 | } |
488 | 488 | |
489 | 489 | $this->cookie_set(); |
490 | 490 | $this->account_login_status = LOGIN_SUCCESS; |
491 | - } catch(Exception $e) { |
|
491 | + } catch (Exception $e) { |
|
492 | 492 | $this->account_login_status == LOGIN_UNDEFINED ? $this->account_login_status = $e->getMessage() : false; |
493 | 493 | } |
494 | 494 | |
@@ -510,18 +510,18 @@ discard block |
||
510 | 510 | protected function cookie_set($account_to_impersonate = null) { |
511 | 511 | $this_account = is_object($account_to_impersonate) ? $account_to_impersonate : $this->account; |
512 | 512 | |
513 | - if(!is_object($this_account) || !$this_account->is_exists) { |
|
513 | + if (!is_object($this_account) || !$this_account->is_exists) { |
|
514 | 514 | throw new Exception(LOGIN_ERROR_NO_ACCOUNT_FOR_COOKIE_SET, ERR_ERROR); |
515 | 515 | } |
516 | 516 | |
517 | - if(is_object($account_to_impersonate) && $account_to_impersonate->is_exists) { |
|
517 | + if (is_object($account_to_impersonate) && $account_to_impersonate->is_exists) { |
|
518 | 518 | sn_setcookie($this->cookie_name_impersonate, $_COOKIE[$this->cookie_name], SN_TIME_NOW + PERIOD_YEAR, $this->sn_root_path, $this->domain); |
519 | 519 | } |
520 | 520 | |
521 | 521 | $expire_time = $this->remember_me ? SN_TIME_NOW + PERIOD_YEAR : 0; |
522 | 522 | |
523 | 523 | $password_encoded = $this->password_encode_for_cookie($this_account->account_password); |
524 | - $cookie = $this_account->account_id . AUTH_COOKIE_DELIMETER . $password_encoded . AUTH_COOKIE_DELIMETER . $this->remember_me; |
|
524 | + $cookie = $this_account->account_id.AUTH_COOKIE_DELIMETER.$password_encoded.AUTH_COOKIE_DELIMETER.$this->remember_me; |
|
525 | 525 | $this->flog("cookie_set() - Устанавливаем куку {$cookie}"); |
526 | 526 | return sn_setcookie($this->cookie_name, $cookie, $expire_time, $this->sn_root_path, $this->domain); |
527 | 527 | } |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | // OK v4.1 |
533 | 533 | protected function cookie_clear() { |
534 | 534 | // Автоматически вообще-то - если установлена кука имперсонатора - то чистим обычную, а куку имперсонатора - копируем в неё |
535 | - if(!empty($_COOKIE[$this->cookie_name_impersonate])) { |
|
535 | + if (!empty($_COOKIE[$this->cookie_name_impersonate])) { |
|
536 | 536 | sn_setcookie($this->cookie_name, $_COOKIE[$this->cookie_name_impersonate], SN_TIME_NOW + PERIOD_YEAR, $this->sn_root_path, $this->domain); |
537 | 537 | sn_setcookie($this->cookie_name_impersonate, '', SN_TIME_NOW - PERIOD_WEEK, $this->sn_root_path, $this->domain); |
538 | 538 | } else { |
@@ -551,10 +551,10 @@ discard block |
||
551 | 551 | protected function login_validate_input() { |
552 | 552 | // Проверяем, что бы в начале и конце не было пустых символов |
553 | 553 | // TODO - при копировании Эксель -> Опера - в конце образуются пустые места. Это не должно быть проблемой! Вынести проверку пароля в регистрацию! |
554 | - if($this->input_login_password_raw != trim($this->input_login_password_raw)) { |
|
554 | + if ($this->input_login_password_raw != trim($this->input_login_password_raw)) { |
|
555 | 555 | throw new Exception(LOGIN_ERROR_PASSWORD_TRIMMED, ERR_ERROR); |
556 | 556 | } |
557 | - if(!$this->input_login_password_raw) { |
|
557 | + if (!$this->input_login_password_raw) { |
|
558 | 558 | throw new Exception(LOGIN_ERROR_PASSWORD_EMPTY, ERR_ERROR); |
559 | 559 | } |
560 | 560 | } |
@@ -570,37 +570,37 @@ discard block |
||
570 | 570 | $this->login_validate_input(); |
571 | 571 | |
572 | 572 | // Если нет имени пользователя - NO GO! |
573 | - if(!$this->input_login_unsafe) { |
|
573 | + if (!$this->input_login_unsafe) { |
|
574 | 574 | throw new Exception(LOGIN_ERROR_USERNAME_EMPTY, ERR_ERROR); |
575 | 575 | } |
576 | 576 | // Если логин имеет запрещенные символы - NO GO! |
577 | - if(strpbrk($this->input_login_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { |
|
577 | + if (strpbrk($this->input_login_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { |
|
578 | 578 | throw new Exception(LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS, ERR_ERROR); |
579 | 579 | } |
580 | 580 | // Если логин меньше минимальной длины - NO GO! |
581 | - if(strlen($this->input_login_unsafe) < LOGIN_LENGTH_MIN) { |
|
581 | + if (strlen($this->input_login_unsafe) < LOGIN_LENGTH_MIN) { |
|
582 | 582 | throw new Exception(REGISTER_ERROR_USERNAME_SHORT, ERR_ERROR); |
583 | 583 | } |
584 | 584 | // Если пароль меньше минимальной длины - NO GO! |
585 | - if(strlen($this->input_login_password_raw) < PASSWORD_LENGTH_MIN) { |
|
585 | + if (strlen($this->input_login_password_raw) < PASSWORD_LENGTH_MIN) { |
|
586 | 586 | throw new Exception(REGISTER_ERROR_PASSWORD_INSECURE, ERR_ERROR); |
587 | 587 | } |
588 | 588 | // Если пароль имеет пробельные символы в начале или конце - NO GO! |
589 | - if($this->input_login_password_raw != trim($this->input_login_password_raw)) { |
|
589 | + if ($this->input_login_password_raw != trim($this->input_login_password_raw)) { |
|
590 | 590 | throw new Exception(LOGIN_ERROR_PASSWORD_TRIMMED, ERR_ERROR); |
591 | 591 | } |
592 | 592 | // Если пароль не совпадает с подтверждением - NO GO! То, что у пароля нет пробельных символов в начале/конце - мы уже проверили выше |
593 | 593 | //Если они есть у повтора - значит пароль и повтор не совпадут |
594 | - if($this->input_login_password_raw <> $this->input_login_password_raw_repeat) { |
|
594 | + if ($this->input_login_password_raw <> $this->input_login_password_raw_repeat) { |
|
595 | 595 | throw new Exception(REGISTER_ERROR_PASSWORD_DIFFERENT, ERR_ERROR); |
596 | 596 | } |
597 | 597 | // Если нет емейла - NO GO! |
598 | 598 | // TODO - регистрация без емейла |
599 | - if(!$this->input_email_unsafe) { |
|
599 | + if (!$this->input_email_unsafe) { |
|
600 | 600 | throw new Exception(REGISTER_ERROR_EMAIL_EMPTY, ERR_ERROR); |
601 | 601 | } |
602 | 602 | // Если емейл не является емейлом - NO GO! |
603 | - if(!is_email($this->input_email_unsafe)) { |
|
603 | + if (!is_email($this->input_email_unsafe)) { |
|
604 | 604 | throw new Exception(REGISTER_ERROR_EMAIL_WRONG, ERR_ERROR); |
605 | 605 | } |
606 | 606 | } |
@@ -609,7 +609,7 @@ discard block |
||
609 | 609 | |
610 | 610 | // OK v4 |
611 | 611 | protected function password_encode_for_cookie($password) { |
612 | - return md5("{$password}--" . $this->secret_word); |
|
612 | + return md5("{$password}--".$this->secret_word); |
|
613 | 613 | } |
614 | 614 | // OK v4 |
615 | 615 | protected function password_encode($password, $salt) { |
@@ -629,22 +629,22 @@ discard block |
||
629 | 629 | return core_auth::make_random_password(); |
630 | 630 | } |
631 | 631 | protected function flog($message, $die = false) { |
632 | - if(!defined('DEBUG_AUTH') || !DEBUG_AUTH) { |
|
632 | + if (!defined('DEBUG_AUTH') || !DEBUG_AUTH) { |
|
633 | 633 | return; |
634 | 634 | } |
635 | 635 | list($called, $caller) = debug_backtrace(false); |
636 | 636 | |
637 | 637 | $caller_name = |
638 | - ((get_called_class()) ? get_called_class() : (!empty($caller['class']) ? $caller['class'] : '')) . |
|
639 | - (!empty($caller['type']) ? $caller['type'] : '') . |
|
640 | - (!empty($caller['function']) ? $caller['function'] : '') . |
|
641 | - (!empty($called['line']) ? ':' . $called['line'] : ''); |
|
638 | + ((get_called_class()) ? get_called_class() : (!empty($caller['class']) ? $caller['class'] : '')). |
|
639 | + (!empty($caller['type']) ? $caller['type'] : ''). |
|
640 | + (!empty($caller['function']) ? $caller['function'] : ''). |
|
641 | + (!empty($called['line']) ? ':'.$called['line'] : ''); |
|
642 | 642 | |
643 | 643 | $_SERVER['SERVER_NAME'] == 'localhost' ? print("<div class='debug'>$message - $caller_name\r\n</div>") : false; |
644 | 644 | |
645 | 645 | classSupernova::log_file("$message - $caller_name"); |
646 | - if($die) { |
|
647 | - $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в " . get_called_class() . " (располагается в " . get_class() . "). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>"); |
|
646 | + if ($die) { |
|
647 | + $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в ".get_called_class()." (располагается в ".get_class()."). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>"); |
|
648 | 648 | } |
649 | 649 | } |
650 | 650 |
@@ -18,6 +18,11 @@ discard block |
||
18 | 18 | |
19 | 19 | // TODO - НЕ ОБЯЗАТЕЛЬНО ОТПРАВЛЯТЬ ЧЕРЕЗ ЕМЕЙЛ! ЕСЛИ ЭТО ФЕЙСБУЧЕК ИЛИ ВКШЕЧКА - МОЖНО ЧЕРЕЗ ЛС ПИСАТЬ!! |
20 | 20 | // TODO - OK 4.6 |
21 | + |
|
22 | + /** |
|
23 | + * @param integer $confirmation_type_safe |
|
24 | + * @param string $email_unsafe |
|
25 | + */ |
|
21 | 26 | public function db_confirmation_get_latest_by_type_and_email($confirmation_type_safe, $email_unsafe) { |
22 | 27 | $email_safe = $this->db->db_escape($email_unsafe); |
23 | 28 | |
@@ -26,12 +31,21 @@ discard block |
||
26 | 31 | `type` = {$confirmation_type_safe} AND `email` = '{$email_safe}' ORDER BY create_time DESC LIMIT 1;", true); |
27 | 32 | } |
28 | 33 | // TODO - OK 4.6 |
34 | + |
|
35 | + /** |
|
36 | + * @param integer $confirmation_type_safe |
|
37 | + */ |
|
29 | 38 | public function db_confirmation_delete_by_type_and_email($confirmation_type_safe, $email_unsafe) { |
30 | 39 | $email_safe = $this->db->db_escape($email_unsafe); |
31 | 40 | |
32 | 41 | return $this->db->doquery("DELETE FROM {{confirmations}} WHERE `type` = {$confirmation_type_safe} AND `email` = '{$email_safe}'"); |
33 | 42 | } |
34 | 43 | // TODO - OK 4.6 |
44 | + |
|
45 | + /** |
|
46 | + * @param integer $confirmation_type_safe |
|
47 | + * @param string $email_unsafe |
|
48 | + */ |
|
35 | 49 | public function db_confirmation_get_unique_code_by_type_and_email($confirmation_type_safe, $email_unsafe) { |
36 | 50 | $email_safe = $this->db->db_escape($email_unsafe); |
37 | 51 | |
@@ -50,6 +64,11 @@ discard block |
||
50 | 64 | return $confirm_code_unsafe; |
51 | 65 | } |
52 | 66 | // TODO - OK 4.6 |
67 | + |
|
68 | + /** |
|
69 | + * @param integer $confirmation_type_safe |
|
70 | + * @param string $confirmation_code_unsafe |
|
71 | + */ |
|
53 | 72 | public function db_confirmation_get_by_type_and_code($confirmation_type_safe, $confirmation_code_unsafe) { |
54 | 73 | $confirmation_code_safe = $this->db->db_escape($confirmation_code_unsafe); |
55 | 74 |
@@ -41,7 +41,7 @@ |
||
41 | 41 | // $query = static::$db->doquery("SELECT `id` FROM {{confirmations}} WHERE `code` = '{$confirm_code_safe}' AND `type` = {$confirmation_type_safe} FOR UPDATE", true); |
42 | 42 | // Тип не нужен для проверки - код подтверждения должен быть уникален от слова "совсем" |
43 | 43 | $query = $this->db->doquery("SELECT `id` FROM {{confirmations}} WHERE `code` = '{$confirm_code_safe}' FOR UPDATE", true); |
44 | - } while($query); |
|
44 | + } while ($query); |
|
45 | 45 | |
46 | 46 | $this->db->doquery( |
47 | 47 | "REPLACE INTO {{confirmations}} |
@@ -55,6 +55,9 @@ |
||
55 | 55 | return true; |
56 | 56 | } |
57 | 57 | |
58 | + /** |
|
59 | + * @param string $query_string |
|
60 | + */ |
|
58 | 61 | function mysql_query($query_string) { |
59 | 62 | return mysql_query($query_string, $this->link); |
60 | 63 | } |
@@ -52,7 +52,7 @@ |
||
52 | 52 | !mysql_select_db($settings['name']) |
53 | 53 | ? classSupernova::$debug->error_fatal('DB error - cannot find DB on server', $this->mysql_error()) |
54 | 54 | : false; |
55 | - !$this->mysql_query('SET SESSION TRANSACTION ISOLATION LEVEL ' . self::DB_MYSQL_TRANSACTION_REPEATABLE_READ . ';') |
|
55 | + !$this->mysql_query('SET SESSION TRANSACTION ISOLATION LEVEL '.self::DB_MYSQL_TRANSACTION_REPEATABLE_READ.';') |
|
56 | 56 | ? classSupernova::$debug->error_fatal('DB error - cannot set desired isolation level', $this->mysql_error()) |
57 | 57 | : false; |
58 | 58 |
@@ -47,6 +47,7 @@ discard block |
||
47 | 47 | |
48 | 48 | /** |
49 | 49 | * constuctor |
50 | + * @param template $template |
|
50 | 51 | */ |
51 | 52 | function template_compile(&$template) |
52 | 53 | { |
@@ -463,6 +464,7 @@ discard block |
||
463 | 464 | * Compile IF tags - much of this is from Smarty with |
464 | 465 | * some adaptions for our block level methods |
465 | 466 | * @access private |
467 | + * @param boolean $elseif |
|
466 | 468 | */ |
467 | 469 | function compile_tag_if($tag_args, $elseif) |
468 | 470 | { |
@@ -620,6 +622,7 @@ discard block |
||
620 | 622 | /** |
621 | 623 | * Compile DEFINE tags |
622 | 624 | * @access private |
625 | + * @param boolean $op |
|
623 | 626 | */ |
624 | 627 | function compile_tag_define($tag_args, $op) |
625 | 628 | { |
@@ -698,6 +701,7 @@ discard block |
||
698 | 701 | * parse expression |
699 | 702 | * This is from Smarty |
700 | 703 | * @access private |
704 | + * @param string $is_arg |
|
701 | 705 | */ |
702 | 706 | function _parse_is_expr($is_arg, $tokens) |
703 | 707 | { |
@@ -794,6 +798,8 @@ discard block |
||
794 | 798 | * If $include_last_iterator is true, then [$_childN_i] will be appended to the form shown above. |
795 | 799 | * NOTE: does not expect a trailing "." on the blockname. |
796 | 800 | * @access private |
801 | + * @param string $blockname |
|
802 | + * @param boolean $include_last_iterator |
|
797 | 803 | */ |
798 | 804 | function generate_block_data_ref($blockname, $include_last_iterator, $defop = false) |
799 | 805 | { |
@@ -832,6 +838,7 @@ discard block |
||
832 | 838 | /** |
833 | 839 | * Write compiled file to cache directory |
834 | 840 | * @access private |
841 | + * @param string $data |
|
835 | 842 | */ |
836 | 843 | function compile_write($handle, $data) |
837 | 844 | { |
@@ -857,6 +864,7 @@ discard block |
||
857 | 864 | /** |
858 | 865 | * Minifies template w/i PHP code by removing extra spaces |
859 | 866 | * @access private |
867 | + * @return string |
|
860 | 868 | */ |
861 | 869 | function minify($html) |
862 | 870 | { |
@@ -66,8 +66,7 @@ discard block |
||
66 | 66 | { |
67 | 67 | return; |
68 | 68 | trigger_error("template->_tpl_load_file(): File {$this->template->files[$handle]} does not exist or is empty", E_USER_ERROR); |
69 | - } |
|
70 | - else |
|
69 | + } else |
|
71 | 70 | { |
72 | 71 | $this->template->files[$handle] = $this->template->files_inherit[$handle]; |
73 | 72 | } |
@@ -225,15 +224,13 @@ discard block |
||
225 | 224 | $var = substr($temp, 2, -1); |
226 | 225 | //$file = $this->template->_tpldata['DEFINE']['.'][$var]; |
227 | 226 | $temp = "\$this->_tpldata['DEFINE']['.']['$var']"; |
228 | - } |
|
229 | - else |
|
227 | + } else |
|
230 | 228 | { |
231 | 229 | $var = substr($temp, 1, -1); |
232 | 230 | //$file = $this->template->_rootref[$var]; |
233 | 231 | $temp = "\$this->_rootref['$var']"; |
234 | 232 | } |
235 | - } |
|
236 | - else |
|
233 | + } else |
|
237 | 234 | { |
238 | 235 | $file = $temp; |
239 | 236 | } |
@@ -381,8 +378,7 @@ discard block |
||
381 | 378 | if ($match[2] < 0) |
382 | 379 | { |
383 | 380 | $loop_start = '($_' . $tag_args . '_count ' . $match[2] . ' < 0 ? 0 : $_' . $tag_args . '_count ' . $match[2] . ')'; |
384 | - } |
|
385 | - else |
|
381 | + } else |
|
386 | 382 | { |
387 | 383 | $loop_start = '($_' . $tag_args . '_count < ' . $match[2] . ' ? $_' . $tag_args . '_count : ' . $match[2] . ')'; |
388 | 384 | } |
@@ -390,17 +386,14 @@ discard block |
||
390 | 386 | if (strlen($match[3]) < 1 || $match[3] == -1) |
391 | 387 | { |
392 | 388 | $loop_end = '$_' . $tag_args . '_count'; |
393 | - } |
|
394 | - else if ($match[3] >= 0) |
|
389 | + } else if ($match[3] >= 0) |
|
395 | 390 | { |
396 | 391 | $loop_end = '(' . ($match[3] + 1) . ' > $_' . $tag_args . '_count ? $_' . $tag_args . '_count : ' . ($match[3] + 1) . ')'; |
397 | - } |
|
398 | - else //if ($match[3] < -1) |
|
392 | + } else //if ($match[3] < -1) |
|
399 | 393 | { |
400 | 394 | $loop_end = '$_' . $tag_args . '_count' . ($match[3] + 1); |
401 | 395 | } |
402 | - } |
|
403 | - else |
|
396 | + } else |
|
404 | 397 | { |
405 | 398 | $loop_start = 0; |
406 | 399 | $loop_end = '$_' . $tag_args . '_count'; |
@@ -413,8 +406,7 @@ discard block |
||
413 | 406 | { |
414 | 407 | // We need to implode $no_nesting times from the end... |
415 | 408 | $block = array_slice($this->block_names, -$no_nesting); |
416 | - } |
|
417 | - else |
|
409 | + } else |
|
418 | 410 | { |
419 | 411 | $block = $this->block_names; |
420 | 412 | } |
@@ -424,8 +416,7 @@ discard block |
||
424 | 416 | // Block is not nested. |
425 | 417 | $tag_template_php = '$_' . $tag_args . "_count = (isset(\$this->_tpldata['$tag_args'])) ? sizeof(\$this->_tpldata['$tag_args']) : 0;"; |
426 | 418 | $varref = "\$this->_tpldata['$tag_args']"; |
427 | - } |
|
428 | - else |
|
419 | + } else |
|
429 | 420 | { |
430 | 421 | // This block is nested. |
431 | 422 | // Generate a namespace string for this block. |
@@ -573,8 +564,7 @@ discard block |
||
573 | 564 | if (preg_match('#^((?:[a-z0-9\-_]+\.)+)?(\$)?(?=[A-Za-z])([A-Za-z0-9\-_]+)#s', $token, $varrefs)) |
574 | 565 | { |
575 | 566 | $token = (!empty($varrefs[1])) ? $this->generate_block_data_ref(substr($varrefs[1], 0, -1), true, $varrefs[2]) . '[\'' . $varrefs[3] . '\']' : (($varrefs[2]) ? '$this->_tpldata[\'DEFINE\'][\'.\'][\'' . $varrefs[3] . '\']' : '$this->_rootref[\'' . $varrefs[3] . '\']'); |
576 | - } |
|
577 | - else if (preg_match('#^\.((?:[a-z0-9\-_]+\.?)+)$#s', $token, $varrefs)) |
|
567 | + } else if (preg_match('#^\.((?:[a-z0-9\-_]+\.?)+)$#s', $token, $varrefs)) |
|
578 | 568 | { |
579 | 569 | // Allow checking if loops are set with .loopname |
580 | 570 | // It is also possible to check the loop count by doing <!-- IF .loopname > 1 --> for example |
@@ -590,8 +580,7 @@ discard block |
||
590 | 580 | |
591 | 581 | // Add the block reference for the last child. |
592 | 582 | $varref .= "['" . $block . "']"; |
593 | - } |
|
594 | - else |
|
583 | + } else |
|
595 | 584 | { |
596 | 585 | $varref = '$this->_tpldata'; |
597 | 586 | |
@@ -599,8 +588,7 @@ discard block |
||
599 | 588 | $varref .= "['" . $blocks[0] . "']"; |
600 | 589 | } |
601 | 590 | $token = "sizeof($varref)"; |
602 | - } |
|
603 | - else if (!empty($token)) |
|
591 | + } else if (!empty($token)) |
|
604 | 592 | { |
605 | 593 | $token = '(' . $token . ')'; |
606 | 594 | } |
@@ -645,8 +633,7 @@ discard block |
||
645 | 633 | |
646 | 634 | // Now replace the php code |
647 | 635 | $match[4] = "'" . str_replace(array('<?php echo ', '; ?>'), array("' . ", " . '"), $match[4]) . "'"; |
648 | - } |
|
649 | - else |
|
636 | + } else |
|
650 | 637 | { |
651 | 638 | preg_match('#true|false|\.#i', $match[4], $type); |
652 | 639 | |
@@ -708,8 +695,7 @@ discard block |
||
708 | 695 | { |
709 | 696 | $negate_expr = true; |
710 | 697 | $expr_type = array_shift($tokens); |
711 | - } |
|
712 | - else |
|
698 | + } else |
|
713 | 699 | { |
714 | 700 | $expr_type = $first_token; |
715 | 701 | } |
@@ -722,8 +708,7 @@ discard block |
||
722 | 708 | $expr_end++; |
723 | 709 | $expr_arg = $tokens[$expr_end++]; |
724 | 710 | $expr = "!(($is_arg / $expr_arg) % $expr_arg)"; |
725 | - } |
|
726 | - else |
|
711 | + } else |
|
727 | 712 | { |
728 | 713 | $expr = "!($is_arg & 1)"; |
729 | 714 | } |
@@ -735,8 +720,7 @@ discard block |
||
735 | 720 | $expr_end++; |
736 | 721 | $expr_arg = $tokens[$expr_end++]; |
737 | 722 | $expr = "(($is_arg / $expr_arg) % $expr_arg)"; |
738 | - } |
|
739 | - else |
|
723 | + } else |
|
740 | 724 | { |
741 | 725 | $expr = "($is_arg & 1)"; |
742 | 726 | } |
@@ -818,12 +802,10 @@ discard block |
||
818 | 802 | $varref .= '[$_' . $blocks[$blockcount] . '_i]'; |
819 | 803 | } |
820 | 804 | return $varref; |
821 | - } |
|
822 | - else if ($include_last_iterator) |
|
805 | + } else if ($include_last_iterator) |
|
823 | 806 | { |
824 | 807 | return '$_'. $blocks[$blockcount] . '_val'; |
825 | - } |
|
826 | - else |
|
808 | + } else |
|
827 | 809 | { |
828 | 810 | return '$_'. $blocks[$blockcount - 1] . '_val[\''. $blocks[$blockcount]. '\']'; |
829 | 811 | } |
@@ -44,17 +44,17 @@ discard block |
||
44 | 44 | var $block_else_level = array(); |
45 | 45 | |
46 | 46 | /** |
47 | - * constuctor |
|
48 | - */ |
|
47 | + * constuctor |
|
48 | + */ |
|
49 | 49 | function template_compile(&$template) |
50 | 50 | { |
51 | 51 | $this->template = &$template; |
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
55 | - * Load template source from file |
|
56 | - * @access private |
|
57 | - */ |
|
55 | + * Load template source from file |
|
56 | + * @access private |
|
57 | + */ |
|
58 | 58 | function _tpl_load_file($handle, $store_in_db = false) |
59 | 59 | { |
60 | 60 | // Try and open template for read |
@@ -97,10 +97,10 @@ discard block |
||
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
100 | - * Remove any PHP tags that do not belong, these regular expressions are derived from |
|
101 | - * the ones that exist in zend_language_scanner.l |
|
102 | - * @access private |
|
103 | - */ |
|
100 | + * Remove any PHP tags that do not belong, these regular expressions are derived from |
|
101 | + * the ones that exist in zend_language_scanner.l |
|
102 | + * @access private |
|
103 | + */ |
|
104 | 104 | function remove_php_tags(&$code) |
105 | 105 | { |
106 | 106 | // This matches the information gathered from the internal PHP lexer |
@@ -114,9 +114,9 @@ discard block |
||
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
117 | - * The all seeing all doing compile method. Parts are inspired by or directly from Smarty |
|
118 | - * @access private |
|
119 | - */ |
|
117 | + * The all seeing all doing compile method. Parts are inspired by or directly from Smarty |
|
118 | + * @access private |
|
119 | + */ |
|
120 | 120 | function compile($code, $no_echo = false, $echo_var = '') |
121 | 121 | { |
122 | 122 | if ($echo_var) |
@@ -285,9 +285,9 @@ discard block |
||
285 | 285 | } |
286 | 286 | |
287 | 287 | /** |
288 | - * Compile variables |
|
289 | - * @access private |
|
290 | - */ |
|
288 | + * Compile variables |
|
289 | + * @access private |
|
290 | + */ |
|
291 | 291 | function compile_var_tags(&$text_blocks) |
292 | 292 | { |
293 | 293 | // change template varrefs into PHP varrefs |
@@ -347,9 +347,9 @@ discard block |
||
347 | 347 | } |
348 | 348 | |
349 | 349 | /** |
350 | - * Compile blocks |
|
351 | - * @access private |
|
352 | - */ |
|
350 | + * Compile blocks |
|
351 | + * @access private |
|
352 | + */ |
|
353 | 353 | function compile_tag_block($tag_args) |
354 | 354 | { |
355 | 355 | $no_nesting = false; |
@@ -435,14 +435,14 @@ discard block |
||
435 | 435 | $tag_template_php .= 'if ($_' . $tag_args . '_count) {'; |
436 | 436 | |
437 | 437 | /** |
438 | - * The following uses foreach for iteration instead of a for loop, foreach is faster but requires PHP to make a copy of the contents of the array which uses more memory |
|
439 | - * <code> |
|
440 | - * if (!$offset) |
|
441 | - * { |
|
442 | - * $tag_template_php .= 'foreach (' . $varref . ' as $_' . $tag_args . '_i => $_' . $tag_args . '_val){'; |
|
443 | - * } |
|
444 | - * </code> |
|
445 | - */ |
|
438 | + * The following uses foreach for iteration instead of a for loop, foreach is faster but requires PHP to make a copy of the contents of the array which uses more memory |
|
439 | + * <code> |
|
440 | + * if (!$offset) |
|
441 | + * { |
|
442 | + * $tag_template_php .= 'foreach (' . $varref . ' as $_' . $tag_args . '_i => $_' . $tag_args . '_val){'; |
|
443 | + * } |
|
444 | + * </code> |
|
445 | + */ |
|
446 | 446 | |
447 | 447 | $tag_template_php .= 'for ($_' . $tag_args . '_i = ' . $loop_start . '; $_' . $tag_args . '_i < ' . $loop_end . '; ++$_' . $tag_args . '_i){'; |
448 | 448 | // $tag_template_php .= '$this->_block_counter["'. $tag_args . '"] = $_' . $tag_args . '_i;'; |
@@ -453,10 +453,10 @@ discard block |
||
453 | 453 | } |
454 | 454 | |
455 | 455 | /** |
456 | - * Compile IF tags - much of this is from Smarty with |
|
457 | - * some adaptions for our block level methods |
|
458 | - * @access private |
|
459 | - */ |
|
456 | + * Compile IF tags - much of this is from Smarty with |
|
457 | + * some adaptions for our block level methods |
|
458 | + * @access private |
|
459 | + */ |
|
460 | 460 | function compile_tag_if($tag_args, $elseif) |
461 | 461 | { |
462 | 462 | // Tokenize args for 'if' tag. |
@@ -611,9 +611,9 @@ discard block |
||
611 | 611 | } |
612 | 612 | |
613 | 613 | /** |
614 | - * Compile DEFINE tags |
|
615 | - * @access private |
|
616 | - */ |
|
614 | + * Compile DEFINE tags |
|
615 | + * @access private |
|
616 | + */ |
|
617 | 617 | function compile_tag_define($tag_args, $op) |
618 | 618 | { |
619 | 619 | preg_match('#^((?:[a-z0-9\-_]+\.)+)?\$(?=[A-Z])([A-Z0-9_\-]*)(?: = (\'?)([^\']*)(\'?))?$#', $tag_args, $match); |
@@ -664,9 +664,9 @@ discard block |
||
664 | 664 | } |
665 | 665 | |
666 | 666 | /** |
667 | - * Compile INCLUDE tag |
|
668 | - * @access private |
|
669 | - */ |
|
667 | + * Compile INCLUDE tag |
|
668 | + * @access private |
|
669 | + */ |
|
670 | 670 | function compile_tag_include($tag_args) |
671 | 671 | { |
672 | 672 | // Process dynamic includes |
@@ -679,19 +679,19 @@ discard block |
||
679 | 679 | } |
680 | 680 | |
681 | 681 | /** |
682 | - * Compile INCLUDE_PHP tag |
|
683 | - * @access private |
|
684 | - */ |
|
682 | + * Compile INCLUDE_PHP tag |
|
683 | + * @access private |
|
684 | + */ |
|
685 | 685 | function compile_tag_include_php($tag_args) |
686 | 686 | { |
687 | 687 | return "\$this->_php_include('$tag_args');"; |
688 | 688 | } |
689 | 689 | |
690 | 690 | /** |
691 | - * parse expression |
|
692 | - * This is from Smarty |
|
693 | - * @access private |
|
694 | - */ |
|
691 | + * parse expression |
|
692 | + * This is from Smarty |
|
693 | + * @access private |
|
694 | + */ |
|
695 | 695 | function _parse_is_expr($is_arg, $tokens) |
696 | 696 | { |
697 | 697 | $expr_end = 0; |
@@ -756,13 +756,13 @@ discard block |
||
756 | 756 | } |
757 | 757 | |
758 | 758 | /** |
759 | - * Generates a reference to the given variable inside the given (possibly nested) |
|
760 | - * block namespace. This is a string of the form: |
|
761 | - * ' . $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['varname'] . ' |
|
762 | - * It's ready to be inserted into an "echo" line in one of the templates. |
|
763 | - * NOTE: expects a trailing "." on the namespace. |
|
764 | - * @access private |
|
765 | - */ |
|
759 | + * Generates a reference to the given variable inside the given (possibly nested) |
|
760 | + * block namespace. This is a string of the form: |
|
761 | + * ' . $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['varname'] . ' |
|
762 | + * It's ready to be inserted into an "echo" line in one of the templates. |
|
763 | + * NOTE: expects a trailing "." on the namespace. |
|
764 | + * @access private |
|
765 | + */ |
|
766 | 766 | function generate_block_varref($namespace, $varname, $echo = true, $defop = false) |
767 | 767 | { |
768 | 768 | // Strip the trailing period. |
@@ -780,14 +780,14 @@ discard block |
||
780 | 780 | } |
781 | 781 | |
782 | 782 | /** |
783 | - * Generates a reference to the array of data values for the given |
|
784 | - * (possibly nested) block namespace. This is a string of the form: |
|
785 | - * $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['$childN'] |
|
786 | - * |
|
787 | - * If $include_last_iterator is true, then [$_childN_i] will be appended to the form shown above. |
|
788 | - * NOTE: does not expect a trailing "." on the blockname. |
|
789 | - * @access private |
|
790 | - */ |
|
783 | + * Generates a reference to the array of data values for the given |
|
784 | + * (possibly nested) block namespace. This is a string of the form: |
|
785 | + * $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['$childN'] |
|
786 | + * |
|
787 | + * If $include_last_iterator is true, then [$_childN_i] will be appended to the form shown above. |
|
788 | + * NOTE: does not expect a trailing "." on the blockname. |
|
789 | + * @access private |
|
790 | + */ |
|
791 | 791 | function generate_block_data_ref($blockname, $include_last_iterator, $defop = false) |
792 | 792 | { |
793 | 793 | // Get an array of the blocks involved. |
@@ -823,9 +823,9 @@ discard block |
||
823 | 823 | } |
824 | 824 | |
825 | 825 | /** |
826 | - * Write compiled file to cache directory |
|
827 | - * @access private |
|
828 | - */ |
|
826 | + * Write compiled file to cache directory |
|
827 | + * @access private |
|
828 | + */ |
|
829 | 829 | function compile_write($handle, $data) |
830 | 830 | { |
831 | 831 | $filename = $this->template->cachepath . str_replace('/', '.', $this->template->filename[$handle]) . DOT_PHP_EX; |
@@ -848,8 +848,8 @@ discard block |
||
848 | 848 | |
849 | 849 | // Gorlum's minifier BOF |
850 | 850 | /** |
851 | - * Minifies template w/i PHP code by removing extra spaces |
|
852 | - */ |
|
851 | + * Minifies template w/i PHP code by removing extra spaces |
|
852 | + */ |
|
853 | 853 | private function minify($html) |
854 | 854 | { |
855 | 855 | if(!classSupernova::$config->tpl_minifier) |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | 'template_data' => trim(@file_get_contents($this->template->files[$handle])), |
92 | 92 | ); |
93 | 93 | |
94 | - $sql = 'INSERT INTO ' . STYLES_TEMPLATE_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); |
|
94 | + $sql = 'INSERT INTO '.STYLES_TEMPLATE_DATA_TABLE.' '.$db->sql_build_array('INSERT', $sql_ary); |
|
95 | 95 | $db->sql_query($sql); |
96 | 96 | } |
97 | 97 | } |
@@ -138,9 +138,9 @@ discard block |
||
138 | 138 | |
139 | 139 | preg_match_all('#<!-- INCLUDE (\{\$?[A-Z0-9\-_]+\}|[a-zA-Z0-9\_\-\+\./]+) -->#', $code, $matches); |
140 | 140 | $include_blocks = $matches[1]; |
141 | - if($include_blocks) |
|
141 | + if ($include_blocks) |
|
142 | 142 | { |
143 | - foreach($include_blocks as &$included_file) |
|
143 | + foreach ($include_blocks as &$included_file) |
|
144 | 144 | { |
145 | 145 | $included_file .= '.tpl.html'; |
146 | 146 | } |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | { |
170 | 170 | case 'BEGIN': |
171 | 171 | $this->block_else_level[] = false; |
172 | - $compile_blocks[] = '<?php ' . $this->compile_tag_block($block_val[2]) . ' ?>'; |
|
172 | + $compile_blocks[] = '<?php '.$this->compile_tag_block($block_val[2]).' ?>'; |
|
173 | 173 | break; |
174 | 174 | |
175 | 175 | case 'BEGINELSE': |
@@ -179,11 +179,11 @@ discard block |
||
179 | 179 | |
180 | 180 | case 'END': |
181 | 181 | array_pop($this->block_names); |
182 | - $compile_blocks[] = '<?php ' . ((array_pop($this->block_else_level)) ? '}' : '}}') . ' ?>'; |
|
182 | + $compile_blocks[] = '<?php '.((array_pop($this->block_else_level)) ? '}' : '}}').' ?>'; |
|
183 | 183 | break; |
184 | 184 | |
185 | 185 | case 'IF': |
186 | - $compile_blocks[] = '<?php ' . $this->compile_tag_if($block_val[2], false) . ' ?>'; |
|
186 | + $compile_blocks[] = '<?php '.$this->compile_tag_if($block_val[2], false).' ?>'; |
|
187 | 187 | break; |
188 | 188 | |
189 | 189 | case 'ELSE': |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | break; |
192 | 192 | |
193 | 193 | case 'ELSEIF': |
194 | - $compile_blocks[] = '<?php ' . $this->compile_tag_if($block_val[2], true) . ' ?>'; |
|
194 | + $compile_blocks[] = '<?php '.$this->compile_tag_if($block_val[2], true).' ?>'; |
|
195 | 195 | break; |
196 | 196 | |
197 | 197 | case 'ENDIF': |
@@ -199,11 +199,11 @@ discard block |
||
199 | 199 | break; |
200 | 200 | |
201 | 201 | case 'DEFINE': |
202 | - $compile_blocks[] = '<?php ' . $this->compile_tag_define($block_val[2], true) . ' ?>'; |
|
202 | + $compile_blocks[] = '<?php '.$this->compile_tag_define($block_val[2], true).' ?>'; |
|
203 | 203 | break; |
204 | 204 | |
205 | 205 | case 'UNDEFINE': |
206 | - $compile_blocks[] = '<?php ' . $this->compile_tag_define($block_val[2], false) . ' ?>'; |
|
206 | + $compile_blocks[] = '<?php '.$this->compile_tag_define($block_val[2], false).' ?>'; |
|
207 | 207 | break; |
208 | 208 | |
209 | 209 | case 'INCLUDE': |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | $file = $temp; |
235 | 235 | } |
236 | 236 | |
237 | - $compile_blocks[] = '<?php ' . $this->compile_tag_include($temp) . ' ?>'; |
|
237 | + $compile_blocks[] = '<?php '.$this->compile_tag_include($temp).' ?>'; |
|
238 | 238 | |
239 | 239 | // No point in checking variable includes |
240 | 240 | if ($file) |
@@ -244,11 +244,11 @@ discard block |
||
244 | 244 | break; |
245 | 245 | |
246 | 246 | case 'INCLUDEPHP': |
247 | - $compile_blocks[] = (classSupernova::$config->tpl_allow_php) ? '<?php ' . $this->compile_tag_include_php(array_shift($includephp_blocks)) . ' ?>' : ''; |
|
247 | + $compile_blocks[] = (classSupernova::$config->tpl_allow_php) ? '<?php '.$this->compile_tag_include_php(array_shift($includephp_blocks)).' ?>' : ''; |
|
248 | 248 | break; |
249 | 249 | |
250 | 250 | case 'PHP': |
251 | - $compile_blocks[] = (classSupernova::$config->tpl_allow_php) ? '<?php ' . array_shift($php_blocks) . ' ?>' : ''; |
|
251 | + $compile_blocks[] = (classSupernova::$config->tpl_allow_php) ? '<?php '.array_shift($php_blocks).' ?>' : ''; |
|
252 | 252 | break; |
253 | 253 | |
254 | 254 | default: |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | for ($i = 0, $size = sizeof($text_blocks); $i < $size; $i++) |
264 | 264 | { |
265 | 265 | $trim_check_text = trim($text_blocks[$i]); |
266 | - $template_php .= (!$no_echo) ? (($trim_check_text != '') ? $text_blocks[$i] : '') . ((isset($compile_blocks[$i])) ? $compile_blocks[$i] : '') : (($trim_check_text != '') ? $text_blocks[$i] : '') . ((isset($compile_blocks[$i])) ? $compile_blocks[$i] : ''); |
|
266 | + $template_php .= (!$no_echo) ? (($trim_check_text != '') ? $text_blocks[$i] : '').((isset($compile_blocks[$i])) ? $compile_blocks[$i] : '') : (($trim_check_text != '') ? $text_blocks[$i] : '').((isset($compile_blocks[$i])) ? $compile_blocks[$i] : ''); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | // Remove unused opening/closing tags |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | // we'll strip out such occurences, minimising such switching |
279 | 279 | if ($no_echo) |
280 | 280 | { |
281 | - return "\$$echo_var .= '" . $template_php . "'"; |
|
281 | + return "\$$echo_var .= '".$template_php."'"; |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | return $template_php; |
@@ -373,30 +373,30 @@ discard block |
||
373 | 373 | |
374 | 374 | if ($match[2] < 0) |
375 | 375 | { |
376 | - $loop_start = '($_' . $tag_args . '_count ' . $match[2] . ' < 0 ? 0 : $_' . $tag_args . '_count ' . $match[2] . ')'; |
|
376 | + $loop_start = '($_'.$tag_args.'_count '.$match[2].' < 0 ? 0 : $_'.$tag_args.'_count '.$match[2].')'; |
|
377 | 377 | } |
378 | 378 | else |
379 | 379 | { |
380 | - $loop_start = '($_' . $tag_args . '_count < ' . $match[2] . ' ? $_' . $tag_args . '_count : ' . $match[2] . ')'; |
|
380 | + $loop_start = '($_'.$tag_args.'_count < '.$match[2].' ? $_'.$tag_args.'_count : '.$match[2].')'; |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | if (strlen($match[3]) < 1 || $match[3] == -1) |
384 | 384 | { |
385 | - $loop_end = '$_' . $tag_args . '_count'; |
|
385 | + $loop_end = '$_'.$tag_args.'_count'; |
|
386 | 386 | } |
387 | 387 | else if ($match[3] >= 0) |
388 | 388 | { |
389 | - $loop_end = '(' . ($match[3] + 1) . ' > $_' . $tag_args . '_count ? $_' . $tag_args . '_count : ' . ($match[3] + 1) . ')'; |
|
389 | + $loop_end = '('.($match[3] + 1).' > $_'.$tag_args.'_count ? $_'.$tag_args.'_count : '.($match[3] + 1).')'; |
|
390 | 390 | } |
391 | 391 | else //if ($match[3] < -1) |
392 | 392 | { |
393 | - $loop_end = '$_' . $tag_args . '_count' . ($match[3] + 1); |
|
393 | + $loop_end = '$_'.$tag_args.'_count'.($match[3] + 1); |
|
394 | 394 | } |
395 | 395 | } |
396 | 396 | else |
397 | 397 | { |
398 | 398 | $loop_start = 0; |
399 | - $loop_end = '$_' . $tag_args . '_count'; |
|
399 | + $loop_end = '$_'.$tag_args.'_count'; |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | $tag_template_php = ''; |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | if (sizeof($block) < 2) |
416 | 416 | { |
417 | 417 | // Block is not nested. |
418 | - $tag_template_php = '$_' . $tag_args . "_count = (isset(\$this->_tpldata['$tag_args'])) ? sizeof(\$this->_tpldata['$tag_args']) : 0;"; |
|
418 | + $tag_template_php = '$_'.$tag_args."_count = (isset(\$this->_tpldata['$tag_args'])) ? sizeof(\$this->_tpldata['$tag_args']) : 0;"; |
|
419 | 419 | $varref = "\$this->_tpldata['$tag_args']"; |
420 | 420 | } |
421 | 421 | else |
@@ -429,10 +429,10 @@ discard block |
||
429 | 429 | $varref = $this->generate_block_data_ref($namespace, false); |
430 | 430 | |
431 | 431 | // Create the for loop code to iterate over this block. |
432 | - $tag_template_php = '$_' . $tag_args . '_count = (isset(' . $varref . ')) ? sizeof(' . $varref . ') : 0;'; |
|
432 | + $tag_template_php = '$_'.$tag_args.'_count = (isset('.$varref.')) ? sizeof('.$varref.') : 0;'; |
|
433 | 433 | } |
434 | 434 | |
435 | - $tag_template_php .= 'if ($_' . $tag_args . '_count) {'; |
|
435 | + $tag_template_php .= 'if ($_'.$tag_args.'_count) {'; |
|
436 | 436 | |
437 | 437 | /** |
438 | 438 | * The following uses foreach for iteration instead of a for loop, foreach is faster but requires PHP to make a copy of the contents of the array which uses more memory |
@@ -444,10 +444,10 @@ discard block |
||
444 | 444 | * </code> |
445 | 445 | */ |
446 | 446 | |
447 | - $tag_template_php .= 'for ($_' . $tag_args . '_i = ' . $loop_start . '; $_' . $tag_args . '_i < ' . $loop_end . '; ++$_' . $tag_args . '_i){'; |
|
447 | + $tag_template_php .= 'for ($_'.$tag_args.'_i = '.$loop_start.'; $_'.$tag_args.'_i < '.$loop_end.'; ++$_'.$tag_args.'_i){'; |
|
448 | 448 | // $tag_template_php .= '$this->_block_counter["'. $tag_args . '"] = $_' . $tag_args . '_i;'; |
449 | - $tag_template_php .= '$_'. $tag_args . '_val = &' . $varref . '[$_'. $tag_args. '_i];'; |
|
450 | - $tag_template_php .= '$this->_block_value["'. $tag_args . '"] = &' . $varref . '[$_'. $tag_args. '_i];'; |
|
449 | + $tag_template_php .= '$_'.$tag_args.'_val = &'.$varref.'[$_'.$tag_args.'_i];'; |
|
450 | + $tag_template_php .= '$this->_block_value["'.$tag_args.'"] = &'.$varref.'[$_'.$tag_args.'_i];'; |
|
451 | 451 | |
452 | 452 | return $tag_template_php; |
453 | 453 | } |
@@ -551,10 +551,10 @@ discard block |
||
551 | 551 | break; |
552 | 552 | |
553 | 553 | case 'is': |
554 | - $is_arg_start = ($tokens[$i-1] == ')') ? array_pop($is_arg_stack) : $i-1; |
|
554 | + $is_arg_start = ($tokens[$i - 1] == ')') ? array_pop($is_arg_stack) : $i - 1; |
|
555 | 555 | $is_arg = implode(' ', array_slice($tokens, $is_arg_start, $i - $is_arg_start)); |
556 | 556 | |
557 | - $new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i+1)); |
|
557 | + $new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i + 1)); |
|
558 | 558 | |
559 | 559 | array_splice($tokens, $is_arg_start, sizeof($tokens), $new_tokens); |
560 | 560 | |
@@ -565,7 +565,7 @@ discard block |
||
565 | 565 | default: |
566 | 566 | if (preg_match('#^((?:[a-z0-9\-_]+\.)+)?(\$)?(?=[A-Za-z])([A-Za-z0-9\-_]+)#s', $token, $varrefs)) |
567 | 567 | { |
568 | - $token = (!empty($varrefs[1])) ? $this->generate_block_data_ref(substr($varrefs[1], 0, -1), true, $varrefs[2]) . '[\'' . $varrefs[3] . '\']' : (($varrefs[2]) ? '$this->_tpldata[\'DEFINE\'][\'.\'][\'' . $varrefs[3] . '\']' : '$this->_rootref[\'' . $varrefs[3] . '\']'); |
|
568 | + $token = (!empty($varrefs[1])) ? $this->generate_block_data_ref(substr($varrefs[1], 0, -1), true, $varrefs[2]).'[\''.$varrefs[3].'\']' : (($varrefs[2]) ? '$this->_tpldata[\'DEFINE\'][\'.\'][\''.$varrefs[3].'\']' : '$this->_rootref[\''.$varrefs[3].'\']'); |
|
569 | 569 | } |
570 | 570 | else if (preg_match('#^\.((?:[a-z0-9\-_]+\.?)+)$#s', $token, $varrefs)) |
571 | 571 | { |
@@ -582,20 +582,20 @@ discard block |
||
582 | 582 | $varref = $this->generate_block_data_ref($namespace, true); |
583 | 583 | |
584 | 584 | // Add the block reference for the last child. |
585 | - $varref .= "['" . $block . "']"; |
|
585 | + $varref .= "['".$block."']"; |
|
586 | 586 | } |
587 | 587 | else |
588 | 588 | { |
589 | 589 | $varref = '$this->_tpldata'; |
590 | 590 | |
591 | 591 | // Add the block reference for the last child. |
592 | - $varref .= "['" . $blocks[0] . "']"; |
|
592 | + $varref .= "['".$blocks[0]."']"; |
|
593 | 593 | } |
594 | 594 | $token = "sizeof($varref)"; |
595 | 595 | } |
596 | 596 | else if (!empty($token)) |
597 | 597 | { |
598 | - $token = '(' . $token . ')'; |
|
598 | + $token = '('.$token.')'; |
|
599 | 599 | } |
600 | 600 | |
601 | 601 | break; |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | { |
608 | 608 | $tokens = array('false'); |
609 | 609 | } |
610 | - return (($elseif) ? '} else if (' : 'if (') . (implode(' ', $tokens) . ') { '); |
|
610 | + return (($elseif) ? '} else if (' : 'if (').(implode(' ', $tokens).') { '); |
|
611 | 611 | } |
612 | 612 | |
613 | 613 | /** |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | |
626 | 626 | if (!$op) |
627 | 627 | { |
628 | - return 'unset(' . (($match[1]) ? $this->generate_block_data_ref(substr($match[1], 0, -1), true, true) . '[\'' . $match[2] . '\']' : '$this->_tpldata[\'DEFINE\'][\'.\'][\'' . $match[2] . '\']') . ');'; |
|
628 | + return 'unset('.(($match[1]) ? $this->generate_block_data_ref(substr($match[1], 0, -1), true, true).'[\''.$match[2].'\']' : '$this->_tpldata[\'DEFINE\'][\'.\'][\''.$match[2].'\']').');'; |
|
629 | 629 | } |
630 | 630 | |
631 | 631 | // Are we a string? |
@@ -637,7 +637,7 @@ discard block |
||
637 | 637 | $match[4] = $this->compile($match[4]); |
638 | 638 | |
639 | 639 | // Now replace the php code |
640 | - $match[4] = "'" . str_replace(array('<?php echo ', '; ?>'), array("' . ", " . '"), $match[4]) . "'"; |
|
640 | + $match[4] = "'".str_replace(array('<?php echo ', '; ?>'), array("' . ", " . '"), $match[4])."'"; |
|
641 | 641 | } |
642 | 642 | else |
643 | 643 | { |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | } |
661 | 661 | } |
662 | 662 | |
663 | - return (($match[1]) ? $this->generate_block_data_ref(substr($match[1], 0, -1), true, true) . '[\'' . $match[2] . '\']' : '$this->_tpldata[\'DEFINE\'][\'.\'][\'' . $match[2] . '\']') . ' = ' . $match[4] . ';'; |
|
663 | + return (($match[1]) ? $this->generate_block_data_ref(substr($match[1], 0, -1), true, true).'[\''.$match[2].'\']' : '$this->_tpldata[\'DEFINE\'][\'.\'][\''.$match[2].'\']').' = '.$match[4].';'; |
|
664 | 664 | } |
665 | 665 | |
666 | 666 | /** |
@@ -801,24 +801,24 @@ discard block |
||
801 | 801 | // Build up the string with everything but the last child. |
802 | 802 | for ($i = 0; $i < $blockcount; $i++) |
803 | 803 | { |
804 | - $varref .= "['" . $blocks[$i] . "'][\$_" . $blocks[$i] . '_i]'; |
|
804 | + $varref .= "['".$blocks[$i]."'][\$_".$blocks[$i].'_i]'; |
|
805 | 805 | } |
806 | 806 | // Add the block reference for the last child. |
807 | - $varref .= "['" . $blocks[$blockcount] . "']"; |
|
807 | + $varref .= "['".$blocks[$blockcount]."']"; |
|
808 | 808 | // Add the iterator for the last child if requried. |
809 | 809 | if ($include_last_iterator) |
810 | 810 | { |
811 | - $varref .= '[$_' . $blocks[$blockcount] . '_i]'; |
|
811 | + $varref .= '[$_'.$blocks[$blockcount].'_i]'; |
|
812 | 812 | } |
813 | 813 | return $varref; |
814 | 814 | } |
815 | 815 | else if ($include_last_iterator) |
816 | 816 | { |
817 | - return '$_'. $blocks[$blockcount] . '_val'; |
|
817 | + return '$_'.$blocks[$blockcount].'_val'; |
|
818 | 818 | } |
819 | 819 | else |
820 | 820 | { |
821 | - return '$_'. $blocks[$blockcount - 1] . '_val[\''. $blocks[$blockcount]. '\']'; |
|
821 | + return '$_'.$blocks[$blockcount - 1].'_val[\''.$blocks[$blockcount].'\']'; |
|
822 | 822 | } |
823 | 823 | } |
824 | 824 | |
@@ -828,14 +828,14 @@ discard block |
||
828 | 828 | */ |
829 | 829 | function compile_write($handle, $data) |
830 | 830 | { |
831 | - $filename = $this->template->cachepath . str_replace('/', '.', $this->template->filename[$handle]) . DOT_PHP_EX; |
|
831 | + $filename = $this->template->cachepath.str_replace('/', '.', $this->template->filename[$handle]).DOT_PHP_EX; |
|
832 | 832 | |
833 | - $data = "<?php if (!defined('INSIDE')) exit;" . ((strpos($data, '<?php') === 0) ? substr($data, 5) : ' ?>' . $data); |
|
833 | + $data = "<?php if (!defined('INSIDE')) exit;".((strpos($data, '<?php') === 0) ? substr($data, 5) : ' ?>'.$data); |
|
834 | 834 | |
835 | 835 | if ($fp = @fopen($filename, 'wb')) |
836 | 836 | { |
837 | 837 | @flock($fp, LOCK_EX); |
838 | - @fwrite ($fp, $data); |
|
838 | + @fwrite($fp, $data); |
|
839 | 839 | @flock($fp, LOCK_UN); |
840 | 840 | @fclose($fp); |
841 | 841 | |
@@ -852,7 +852,7 @@ discard block |
||
852 | 852 | */ |
853 | 853 | private function minify($html) |
854 | 854 | { |
855 | - if(!classSupernova::$config->tpl_minifier) |
|
855 | + if (!classSupernova::$config->tpl_minifier) |
|
856 | 856 | { |
857 | 857 | return $html; |
858 | 858 | } |
@@ -862,14 +862,14 @@ discard block |
||
862 | 862 | $html = preg_replace('/(<script[^>]*?>.*?<\/script>)/si', '#pre#', $html); |
863 | 863 | $html = preg_replace('/>[\s]*</', '><', $html); // Strip spacechars between tags |
864 | 864 | $html = preg_replace('/[\s]+/', ' ', $html); // Replace several spacechars with one space |
865 | - if(!empty($pre[0])) |
|
865 | + if (!empty($pre[0])) |
|
866 | 866 | { |
867 | - foreach($pre[0] as $tag) |
|
867 | + foreach ($pre[0] as $tag) |
|
868 | 868 | { |
869 | 869 | $tag = preg_replace('/^\ *\/\/[^\<]*?$/m', ' ', $tag); // Strips comments - except those that contains HTML comment inside |
870 | 870 | $tag = preg_replace('/[\ \t]{2,}/', ' ', $tag); // Replace several spaces by one |
871 | 871 | $tag = preg_replace('/\s{2,}/', "\r\n", $tag); // Replace several linefeeds by one |
872 | - $html = preg_replace('/#pre#/', $tag, $html,1); |
|
872 | + $html = preg_replace('/#pre#/', $tag, $html, 1); |
|
873 | 873 | } |
874 | 874 | } |
875 | 875 |
@@ -173,6 +173,9 @@ |
||
173 | 173 | } |
174 | 174 | |
175 | 175 | |
176 | + /** |
|
177 | + * @param string $path |
|
178 | + */ |
|
176 | 179 | protected function lng_try_filepath($path, $file_path_relative) { |
177 | 180 | $file_path = SN_ROOT_PHYSICAL . ($path && file_exists(SN_ROOT_PHYSICAL . $path . $file_path_relative) ? $path : '') . $file_path_relative; |
178 | 181 | return file_exists($file_path) ? $file_path : false; |
@@ -35,13 +35,13 @@ discard block |
||
35 | 35 | |
36 | 36 | $this->container = array(); |
37 | 37 | |
38 | - if(classSupernova::$cache->_MODE != CACHER_NO_CACHE && !classSupernova::$config->locale_cache_disable) { |
|
38 | + if (classSupernova::$cache->_MODE != CACHER_NO_CACHE && !classSupernova::$config->locale_cache_disable) { |
|
39 | 39 | $this->cache = classSupernova::$cache; |
40 | 40 | classSupernova::log_file('locale.__constructor: Cache is present'); |
41 | 41 | //$this->cache->unset_by_prefix($this->cache_prefix); // TODO - remove? 'cause debug! |
42 | 42 | } |
43 | 43 | |
44 | - if($enable_stat_usage && empty($this->stat_usage)) { |
|
44 | + if ($enable_stat_usage && empty($this->stat_usage)) { |
|
45 | 45 | $this->enable_stat_usage = $enable_stat_usage; |
46 | 46 | $this->usage_stat_load(); |
47 | 47 | // TODO shutdown function |
@@ -67,18 +67,18 @@ discard block |
||
67 | 67 | unset($fallback[$this->active]); |
68 | 68 | |
69 | 69 | // Проходим по оставшимся локалям |
70 | - foreach($fallback as $try_language) { |
|
70 | + foreach ($fallback as $try_language) { |
|
71 | 71 | // Если нет такой строки - пытаемся вытащить из кэша |
72 | - if(!isset($this->container[$try_language][$offset]) && $this->cache) { |
|
73 | - $this->container[$try_language][$offset] = $this->cache->__get($this->cache_prefix . $try_language . '_' . $offset); |
|
72 | + if (!isset($this->container[$try_language][$offset]) && $this->cache) { |
|
73 | + $this->container[$try_language][$offset] = $this->cache->__get($this->cache_prefix.$try_language.'_'.$offset); |
|
74 | 74 | // Записываем результат работы кэша |
75 | 75 | $locale_cache_statistic['queries']++; |
76 | 76 | isset($this->container[$try_language][$offset]) ? $locale_cache_statistic['hits']++ : $locale_cache_statistic['misses']++; |
77 | -!isset($this->container[$try_language][$offset]) ? $locale_cache_statistic['missed_str'][] = $this->cache_prefix . $try_language . '_' . $offset : false; |
|
77 | +!isset($this->container[$try_language][$offset]) ? $locale_cache_statistic['missed_str'][] = $this->cache_prefix.$try_language.'_'.$offset : false; |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | // Если мы как-то где-то нашли строку... |
81 | - if(isset($this->container[$try_language][$offset])) { |
|
81 | + if (isset($this->container[$try_language][$offset])) { |
|
82 | 82 | // ...значит она получена в результате фоллбэка и записываем её в кэш и контейнер |
83 | 83 | $this[$offset] = $this->container[$try_language][$offset]; |
84 | 84 | $locale_cache_statistic['fallbacks']++; |
@@ -94,16 +94,16 @@ discard block |
||
94 | 94 | $this->container[$this->active][] = $value; |
95 | 95 | } else { |
96 | 96 | $this->container[$this->active][$offset] = $value; |
97 | - if($this->cache) { |
|
98 | - $this->cache->__set($this->cache_prefix_lang . $offset, $value); |
|
97 | + if ($this->cache) { |
|
98 | + $this->cache->__set($this->cache_prefix_lang.$offset, $value); |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 | } |
102 | 102 | public function offsetExists($offset) { |
103 | 103 | // Шорткат если у нас уже есть строка в памяти PHP |
104 | - if(!isset($this->container[$this->active][$offset])) { |
|
104 | + if (!isset($this->container[$this->active][$offset])) { |
|
105 | 105 | // pdump($this->cache_prefix_lang . $offset); |
106 | - if(!$this->cache || !($this->container[$this->active][$offset] = $this->cache->__get($this->cache_prefix_lang . $offset))) { |
|
106 | + if (!$this->cache || !($this->container[$this->active][$offset] = $this->cache->__get($this->cache_prefix_lang.$offset))) { |
|
107 | 107 | // pdump($this->cache_prefix_lang . $offset); |
108 | 108 | // Если нету такой строки - делаем фоллбэк |
109 | 109 | $this->locale_string_fallback($offset); |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | } |
120 | 120 | public function offsetGet($offset) { |
121 | 121 | $value = $this->offsetExists($offset) ? $this->container[$this->active][$offset] : null; |
122 | - if($this->enable_stat_usage) { |
|
122 | + if ($this->enable_stat_usage) { |
|
123 | 123 | $this->usage_stat_log($offset, $value); |
124 | 124 | } |
125 | 125 | return $value; |
@@ -136,26 +136,26 @@ discard block |
||
136 | 136 | public function usage_stat_load() { |
137 | 137 | global $sn_cache; |
138 | 138 | |
139 | - $this->stat_usage = $sn_cache->lng_stat_usage = array(); // TODO for debug |
|
140 | - if(empty($this->stat_usage)) { |
|
139 | + $this->stat_usage = $sn_cache->lng_stat_usage = array(); // TODO for debug |
|
140 | + if (empty($this->stat_usage)) { |
|
141 | 141 | $query = doquery("SELECT * FROM {{lng_usage_stat}}"); |
142 | - while($row = db_fetch($query)) { |
|
143 | - $this->stat_usage[$row['lang_code'] . ':' . $row['string_id'] . ':' . $row['file'] . ':' . $row['line']] = $row['is_empty']; |
|
142 | + while ($row = db_fetch($query)) { |
|
143 | + $this->stat_usage[$row['lang_code'].':'.$row['string_id'].':'.$row['file'].':'.$row['line']] = $row['is_empty']; |
|
144 | 144 | } |
145 | 145 | } |
146 | 146 | } |
147 | 147 | public function usage_stat_save() { |
148 | - if(!empty($this->stat_usage_new)) { |
|
148 | + if (!empty($this->stat_usage_new)) { |
|
149 | 149 | global $sn_cache; |
150 | 150 | $sn_cache->lng_stat_usage = $this->stat_usage; |
151 | 151 | doquery("SELECT 1 FROM {{lng_usage_stat}} LIMIT 1"); |
152 | - foreach($this->stat_usage_new as &$value) { |
|
153 | - foreach($value as &$value2) { |
|
154 | - $value2 = '"' . db_escape($value2) . '"'; |
|
152 | + foreach ($this->stat_usage_new as &$value) { |
|
153 | + foreach ($value as &$value2) { |
|
154 | + $value2 = '"'.db_escape($value2).'"'; |
|
155 | 155 | } |
156 | - $value = '(' . implode(',', $value) .')'; |
|
156 | + $value = '('.implode(',', $value).')'; |
|
157 | 157 | } |
158 | - doquery("REPLACE INTO {{lng_usage_stat}} (lang_code,string_id,`file`,line,is_empty,locale) VALUES " . implode(',', $this->stat_usage_new)); |
|
158 | + doquery("REPLACE INTO {{lng_usage_stat}} (lang_code,string_id,`file`,line,is_empty,locale) VALUES ".implode(',', $this->stat_usage_new)); |
|
159 | 159 | } |
160 | 160 | } |
161 | 161 | public function usage_stat_log(&$offset, &$value) { |
@@ -165,8 +165,8 @@ discard block |
||
165 | 165 | |
166 | 166 | $file = str_replace('\\', '/', substr($trace[1]['file'], strlen(SN_ROOT_PHYSICAL) - 1)); |
167 | 167 | |
168 | - $string_id = $this->active . ':' . $offset . ':' . $file . ':' . $trace[1]['line']; |
|
169 | - if(!isset($this->stat_usage[$string_id]) || $this->stat_usage[$string_id] != empty($value)) { |
|
168 | + $string_id = $this->active.':'.$offset.':'.$file.':'.$trace[1]['line']; |
|
169 | + if (!isset($this->stat_usage[$string_id]) || $this->stat_usage[$string_id] != empty($value)) { |
|
170 | 170 | $this->stat_usage[$string_id] = empty($value); |
171 | 171 | $this->stat_usage_new[] = array( |
172 | 172 | 'lang_code' => $this->active, |
@@ -174,14 +174,14 @@ discard block |
||
174 | 174 | 'file' => $file, |
175 | 175 | 'line' => $trace[1]['line'], |
176 | 176 | 'is_empty' => intval(empty($value)), |
177 | - 'locale' => '' . $value, |
|
177 | + 'locale' => ''.$value, |
|
178 | 178 | ); |
179 | 179 | } |
180 | 180 | } |
181 | 181 | |
182 | 182 | |
183 | 183 | protected function lng_try_filepath($path, $file_path_relative) { |
184 | - $file_path = SN_ROOT_PHYSICAL . ($path && file_exists(SN_ROOT_PHYSICAL . $path . $file_path_relative) ? $path : '') . $file_path_relative; |
|
184 | + $file_path = SN_ROOT_PHYSICAL.($path && file_exists(SN_ROOT_PHYSICAL.$path.$file_path_relative) ? $path : '').$file_path_relative; |
|
185 | 185 | return file_exists($file_path) ? $file_path : false; |
186 | 186 | } |
187 | 187 | |
@@ -203,14 +203,14 @@ discard block |
||
203 | 203 | |
204 | 204 | classSupernova::log_file("locale.include: Loading data from domain '{$filename}'", 1); |
205 | 205 | |
206 | - $cache_file_key = $this->cache_prefix_lang . '__' . $filename; |
|
206 | + $cache_file_key = $this->cache_prefix_lang.'__'.$filename; |
|
207 | 207 | |
208 | 208 | // Подключен ли внешний кэш? |
209 | - if($this->cache) { |
|
209 | + if ($this->cache) { |
|
210 | 210 | // Загружен ли уже данный файл? |
211 | 211 | $cache_file_status = $this->cache->__get($cache_file_key); |
212 | - classSupernova::log_file("locale.include: Cache - '{$filename}' has key '{$cache_file_key}' and is " . ($cache_file_status ? 'already loaded - EXIT' : 'EMPTY'), $cache_file_status ? -1 : 0); |
|
213 | - if($cache_file_status) { |
|
212 | + classSupernova::log_file("locale.include: Cache - '{$filename}' has key '{$cache_file_key}' and is ".($cache_file_status ? 'already loaded - EXIT' : 'EMPTY'), $cache_file_status ? -1 : 0); |
|
213 | + if ($cache_file_status) { |
|
214 | 214 | // Если да - повторять загрузку нет смысла |
215 | 215 | return null; |
216 | 216 | } |
@@ -224,47 +224,47 @@ discard block |
||
224 | 224 | $this->make_fallback($language); |
225 | 225 | |
226 | 226 | $file_path = ''; |
227 | - foreach($this->fallback as $lang_try) { |
|
228 | - if(!$lang_try /* || isset($language_tried[$lang_try]) */) { |
|
227 | + foreach ($this->fallback as $lang_try) { |
|
228 | + if (!$lang_try /* || isset($language_tried[$lang_try]) */) { |
|
229 | 229 | continue; |
230 | 230 | } |
231 | 231 | |
232 | - if($file_path = $this->lng_try_filepath($path, "language/{$lang_try}/{$filename_ext}")) { |
|
232 | + if ($file_path = $this->lng_try_filepath($path, "language/{$lang_try}/{$filename_ext}")) { |
|
233 | 233 | break; |
234 | 234 | } |
235 | 235 | |
236 | - if($file_path = $this->lng_try_filepath($path, "language/{$filename}_{$lang_try}{$ext}")) { |
|
236 | + if ($file_path = $this->lng_try_filepath($path, "language/{$filename}_{$lang_try}{$ext}")) { |
|
237 | 237 | break; |
238 | 238 | } |
239 | 239 | |
240 | 240 | $file_path = ''; |
241 | 241 | } |
242 | 242 | |
243 | - if($file_path) { |
|
243 | + if ($file_path) { |
|
244 | 244 | $a_lang_array = array(); |
245 | 245 | include($file_path); |
246 | 246 | |
247 | - if(!empty($a_lang_array)) { |
|
247 | + if (!empty($a_lang_array)) { |
|
248 | 248 | $this->merge($a_lang_array); |
249 | 249 | |
250 | 250 | // Загрузка данных из файла в кэш |
251 | - if($this->cache) { |
|
251 | + if ($this->cache) { |
|
252 | 252 | classSupernova::log_file("Locale: loading '{$filename}' into cache"); |
253 | - foreach($a_lang_array as $key => $value) { |
|
254 | - $value_cache_key = $this->cache_prefix_lang . $key; |
|
255 | - if($this->cache->__isset($value_cache_key)) { |
|
256 | - if(is_array($value)) { |
|
253 | + foreach ($a_lang_array as $key => $value) { |
|
254 | + $value_cache_key = $this->cache_prefix_lang.$key; |
|
255 | + if ($this->cache->__isset($value_cache_key)) { |
|
256 | + if (is_array($value)) { |
|
257 | 257 | $alt_value = $this->cache->__get($value_cache_key); |
258 | 258 | $value = array_replace_recursive($alt_value, $value); |
259 | 259 | // pdump($alt_value, $alt_value); |
260 | 260 | } |
261 | 261 | } |
262 | - $this->cache->__set($this->cache_prefix_lang . $key, $value); |
|
262 | + $this->cache->__set($this->cache_prefix_lang.$key, $value); |
|
263 | 263 | } |
264 | 264 | } |
265 | 265 | } |
266 | 266 | |
267 | - if($this->cache) { |
|
267 | + if ($this->cache) { |
|
268 | 268 | $this->cache->__set($cache_file_key, true); |
269 | 269 | } |
270 | 270 | |
@@ -277,14 +277,14 @@ discard block |
||
277 | 277 | } |
278 | 278 | |
279 | 279 | public function lng_load_i18n($i18n) { |
280 | - if(!isset($i18n)) { |
|
280 | + if (!isset($i18n)) { |
|
281 | 281 | return; |
282 | 282 | } |
283 | 283 | |
284 | - foreach($i18n as $i18n_data) { |
|
285 | - if(is_string($i18n_data)) { |
|
284 | + foreach ($i18n as $i18n_data) { |
|
285 | + if (is_string($i18n_data)) { |
|
286 | 286 | $this->lng_include($i18n_data); |
287 | - } elseif(is_array($i18n_data)) { |
|
287 | + } elseif (is_array($i18n_data)) { |
|
288 | 288 | $this->lng_include($i18n_data['file'], $i18n_data['path']); |
289 | 289 | } |
290 | 290 | } |
@@ -302,27 +302,27 @@ discard block |
||
302 | 302 | |
303 | 303 | classSupernova::log_file("locale.switch: Trying to switch language to '{$language_new}'"); |
304 | 304 | |
305 | - if($language_new == $this->active) { |
|
305 | + if ($language_new == $this->active) { |
|
306 | 306 | classSupernova::log_file("locale.switch: New language '{$language_new}' is equal to current language '{$this->active}' - EXIT", -1); |
307 | 307 | return false; |
308 | 308 | } |
309 | 309 | |
310 | 310 | $this->active = $language = $language_new; |
311 | - $this->cache_prefix_lang = $this->cache_prefix . $this->active . '_'; |
|
311 | + $this->cache_prefix_lang = $this->cache_prefix.$this->active.'_'; |
|
312 | 312 | |
313 | 313 | $this['LANG_INFO'] = $this->lng_get_info($this->active); |
314 | 314 | $this->make_fallback($this->active); |
315 | 315 | |
316 | - if($this->cache) { |
|
317 | - $cache_lang_init_status = $this->cache->__get($this->cache_prefix_lang . '__INIT'); |
|
318 | - classSupernova::log_file("locale.switch: Cache for '{$this->active}' prefixed '{$this->cache_prefix_lang}' is " . ($cache_lang_init_status ? 'already loaded. Doing nothing - EXIT' : 'EMPTY'), $cache_lang_init_status ? -1 : 0); |
|
319 | - if($cache_lang_init_status) { |
|
316 | + if ($this->cache) { |
|
317 | + $cache_lang_init_status = $this->cache->__get($this->cache_prefix_lang.'__INIT'); |
|
318 | + classSupernova::log_file("locale.switch: Cache for '{$this->active}' prefixed '{$this->cache_prefix_lang}' is ".($cache_lang_init_status ? 'already loaded. Doing nothing - EXIT' : 'EMPTY'), $cache_lang_init_status ? -1 : 0); |
|
319 | + if ($cache_lang_init_status) { |
|
320 | 320 | return false; |
321 | 321 | } |
322 | 322 | |
323 | 323 | // Чистим текущие локализации из кэша. Достаточно почистить только флаги инициализации языкового кэша и загрузки файлов - они начинаются с '__' |
324 | 324 | classSupernova::log_file("locale.switch: Cache - invalidating data"); |
325 | - $this->cache->unset_by_prefix($this->cache_prefix_lang . '__'); |
|
325 | + $this->cache->unset_by_prefix($this->cache_prefix_lang.'__'); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | $this->lng_include('system'); |
@@ -332,9 +332,9 @@ discard block |
||
332 | 332 | // Loading global language files |
333 | 333 | $this->lng_load_i18n(classSupernova::$sn_mvc['i18n']['']); |
334 | 334 | |
335 | - if($this->cache) { |
|
336 | - classSupernova::log_file("locale.switch: Cache - setting flag " . $this->cache_prefix_lang . '__INIT'); |
|
337 | - $this->cache->__set($this->cache_prefix_lang . '__INIT', true); |
|
335 | + if ($this->cache) { |
|
336 | + classSupernova::log_file("locale.switch: Cache - setting flag ".$this->cache_prefix_lang.'__INIT'); |
|
337 | + $this->cache->__set($this->cache_prefix_lang.'__INIT', true); |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | classSupernova::log_file("locale.switch: Complete - EXIT"); |
@@ -344,9 +344,9 @@ discard block |
||
344 | 344 | |
345 | 345 | |
346 | 346 | public function lng_get_info($entry) { |
347 | - $file_name = SN_ROOT_PHYSICAL . 'language/' . $entry . '/language.mo.php'; |
|
347 | + $file_name = SN_ROOT_PHYSICAL.'language/'.$entry.'/language.mo.php'; |
|
348 | 348 | $lang_info = array(); |
349 | - if(file_exists($file_name)) { |
|
349 | + if (file_exists($file_name)) { |
|
350 | 350 | include($file_name); |
351 | 351 | } |
352 | 352 | |
@@ -354,15 +354,15 @@ discard block |
||
354 | 354 | } |
355 | 355 | |
356 | 356 | public function lng_get_list() { |
357 | - if(empty($this->lang_list)) { |
|
357 | + if (empty($this->lang_list)) { |
|
358 | 358 | $this->lang_list = array(); |
359 | 359 | |
360 | - $path = SN_ROOT_PHYSICAL . 'language/'; |
|
360 | + $path = SN_ROOT_PHYSICAL.'language/'; |
|
361 | 361 | $dir = dir($path); |
362 | - while(false !== ($entry = $dir->read())) { |
|
363 | - if(is_dir($path . $entry) && $entry[0] != '.') { |
|
362 | + while (false !== ($entry = $dir->read())) { |
|
363 | + if (is_dir($path.$entry) && $entry[0] != '.') { |
|
364 | 364 | $lang_info = $this->lng_get_info($entry); |
365 | - if($lang_info['LANG_NAME_ISO2'] == $entry) { |
|
365 | + if ($lang_info['LANG_NAME_ISO2'] == $entry) { |
|
366 | 366 | $this->lang_list[$lang_info['LANG_NAME_ISO2']] = $lang_info; |
367 | 367 | } |
368 | 368 | } |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | * Рассчёт бонуса ММ |
703 | 703 | * |
704 | 704 | * @param $dark_matter |
705 | - * @param bool|true $direct |
|
705 | + * @param boolean $direct |
|
706 | 706 | * @param bool|false $return_bonus |
707 | 707 | * |
708 | 708 | * @return float|int |
@@ -738,6 +738,12 @@ discard block |
||
738 | 738 | |
739 | 739 | // Дополнительная ре-трансляция адреса, если в каком-то случае платежная система ожидает нелогичный ответ |
740 | 740 | // Пример: иксолла при неправильно заданном пользователе в ордере ожидает НЕПРАВИЛЬНЫЙ_ОРДЕР, а не НЕПРАВИЛЬНЫЙ_ПОЛЬЗОВАТЕЛЬ |
741 | + |
|
742 | + /** |
|
743 | + * @param integer $error_code |
|
744 | + * |
|
745 | + * @return integer|null |
|
746 | + */ |
|
741 | 747 | function retranslate_error($error_code, $options = array()) { |
742 | 748 | return isset($options['retranslate_error'][$error_code]) ? $options['retranslate_error'][$error_code] : $error_code; |
743 | 749 | } |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | public function compile_request($request) { |
451 | 451 | global $user; |
452 | 452 | |
453 | - if(!(classSupernova::$auth->account instanceof Account)) { |
|
453 | + if (!(classSupernova::$auth->account instanceof Account)) { |
|
454 | 454 | // TODO - throw new Exception(lang['pay_msg_mm_request_amount_invalid'], SN_PAYMENT_REQUEST_ERROR_UNIT_AMOUNT); |
455 | 455 | } |
456 | 456 | $this->account = classSupernova::$auth->account; |
@@ -471,15 +471,15 @@ discard block |
||
471 | 471 | $this->payment_currency = classSupernova::$config->payment_currency_default; |
472 | 472 | $this->payment_amount = self::currency_convert($this->payment_dark_matter_paid, 'MM_', $this->payment_currency); |
473 | 473 | |
474 | - if(empty($this->payment_external_currency) && !empty($this->config['currency'])) { |
|
474 | + if (empty($this->payment_external_currency) && !empty($this->config['currency'])) { |
|
475 | 475 | $this->payment_external_currency = $this->config['currency']; |
476 | 476 | } |
477 | - if(empty($this->payment_external_currency)) { |
|
477 | + if (empty($this->payment_external_currency)) { |
|
478 | 478 | throw new Exception(classLocale::$lang['pay_error_internal_no_external_currency_set'], SN_PAYMENT_ERROR_INTERNAL_NO_EXTERNAL_CURRENCY_SET); |
479 | 479 | } |
480 | 480 | |
481 | 481 | $this->payment_external_amount = self::currency_convert($this->payment_dark_matter_paid, 'MM_', $this->payment_external_currency); |
482 | - if($this->payment_external_amount < 0.01) { |
|
482 | + if ($this->payment_external_amount < 0.01) { |
|
483 | 483 | throw new Exception(classLocale::$lang['pay_msg_mm_request_amount_invalid'], SN_PAYMENT_REQUEST_ERROR_UNIT_AMOUNT); |
484 | 484 | } |
485 | 485 | |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | $this->generate_description(); |
489 | 489 | |
490 | 490 | $this->db_insert(); |
491 | - if(!$this->is_exists) { |
|
491 | + if (!$this->is_exists) { |
|
492 | 492 | throw new Exception(classLocale::$lang['pay_msg_request_error_db_payment_create'], SN_PAYMENT_REQUEST_DB_ERROR_PAYMENT_CREATE); |
493 | 493 | } |
494 | 494 | } |
@@ -500,26 +500,26 @@ discard block |
||
500 | 500 | * @throws Exception |
501 | 501 | */ |
502 | 502 | protected function payment_request_process($options = array()) { |
503 | - if(!$this->manifest['active']) { |
|
503 | + if (!$this->manifest['active']) { |
|
504 | 504 | throw new Exception(classLocale::$lang['pay_msg_module_disabled'], SN_MODULE_DISABLED); |
505 | 505 | } |
506 | 506 | |
507 | 507 | // Если есть payment_id - загружаем под него данные |
508 | - if(!empty($this->payment_params['payment_id'])) { |
|
508 | + if (!empty($this->payment_params['payment_id'])) { |
|
509 | 509 | $this->request_payment_id = sys_get_param_id($this->payment_params['payment_id']); |
510 | - if(!$this->request_payment_id) { |
|
510 | + if (!$this->request_payment_id) { |
|
511 | 511 | throw new Exception(classLocale::$lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_INTERNAL_ID_WRONG); |
512 | 512 | } |
513 | 513 | |
514 | - if(!$this->db_get_by_id($this->request_payment_id)) { |
|
514 | + if (!$this->db_get_by_id($this->request_payment_id)) { |
|
515 | 515 | throw new Exception(classLocale::$lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_INTERNAL_ID_WRONG); |
516 | 516 | } |
517 | 517 | |
518 | 518 | // Проверяем - был ли этот платеж обработан? |
519 | 519 | // TODO - Статусы бывают разные. Нужен спецфлаг payment_processed |
520 | - if($this->payment_status != PAYMENT_STATUS_NONE) { |
|
520 | + if ($this->payment_status != PAYMENT_STATUS_NONE) { |
|
521 | 521 | sn_db_transaction_rollback(); |
522 | - sys_redirect(SN_ROOT_VIRTUAL . 'metamatter.php?payment_id=' . $this->payment_id); |
|
522 | + sys_redirect(SN_ROOT_VIRTUAL.'metamatter.php?payment_id='.$this->payment_id); |
|
523 | 523 | die(); |
524 | 524 | } |
525 | 525 | } |
@@ -527,89 +527,89 @@ discard block |
||
527 | 527 | // Пытаемся получить из запроса ИД аккаунта |
528 | 528 | $request_account_id = !empty($this->payment_params['account_id']) ? sys_get_param_id($this->payment_params['account_id']) : 0; |
529 | 529 | // Если в запросе нет ИД аккаунта - пытаемся использовать payment_account_id |
530 | - if(empty($request_account_id) && !empty($this->payment_account_id)) { |
|
530 | + if (empty($request_account_id) && !empty($this->payment_account_id)) { |
|
531 | 531 | $request_account_id = $this->payment_account_id; |
532 | 532 | } |
533 | 533 | // Если теперь у нас нету ИД аккаунта ни в запросе, ни в записи таблицы - можно паниковать |
534 | - if(empty($request_account_id)) { |
|
534 | + if (empty($request_account_id)) { |
|
535 | 535 | // TODO - аккаунт |
536 | 536 | throw new Exception(classLocale::$lang['pay_msg_request_user_invalid'], $this->retranslate_error(SN_PAYMENT_REQUEST_USER_NOT_FOUND, $options)); |
537 | 537 | } |
538 | 538 | // Если нет записи в таблице - тогда берем payment_account_id из запроса |
539 | - if(empty($this->payment_account_id)) { |
|
539 | + if (empty($this->payment_account_id)) { |
|
540 | 540 | $this->payment_account_id = $request_account_id; |
541 | 541 | } |
542 | 542 | // Если у нас отличаются ИД аккаунта в запросе и ИД аккаунта в записи - тоже можно паниковать |
543 | - if($this->payment_account_id != $request_account_id) { |
|
543 | + if ($this->payment_account_id != $request_account_id) { |
|
544 | 544 | // TODO - Поменять сообщение об ошибке |
545 | 545 | throw new Exception(classLocale::$lang['pay_msg_request_user_invalid'], $this->retranslate_error(SN_PAYMENT_REQUEST_USER_NOT_FOUND, $options)); |
546 | 546 | } |
547 | 547 | // Проверяем существование аккаунта с данным ИД |
548 | - if(!$this->account->db_get_by_id($this->payment_account_id)) { |
|
549 | - throw new Exception(classLocale::$lang['pay_msg_request_user_invalid'] . ' ID ' . $this->payment_account_id, $this->retranslate_error(SN_PAYMENT_REQUEST_USER_NOT_FOUND, $options)); |
|
548 | + if (!$this->account->db_get_by_id($this->payment_account_id)) { |
|
549 | + throw new Exception(classLocale::$lang['pay_msg_request_user_invalid'].' ID '.$this->payment_account_id, $this->retranslate_error(SN_PAYMENT_REQUEST_USER_NOT_FOUND, $options)); |
|
550 | 550 | } |
551 | 551 | |
552 | 552 | // TODO Проверка на сервер_ид - как бы и не нужна, наверное? |
553 | - if(!empty($this->payment_params['server_id'])) { |
|
553 | + if (!empty($this->payment_params['server_id'])) { |
|
554 | 554 | $this->request_server_id = sys_get_param_str($this->payment_params['server_id']); |
555 | - if(SN_ROOT_VIRTUAL != $this->request_server_id) { |
|
556 | - throw new Exception(classLocale::$lang['pay_msg_request_server_wrong'] . " {$this->request_server_id} вместо " . SN_ROOT_VIRTUAL, SN_PAYMENT_REQUEST_SERVER_WRONG); |
|
555 | + if (SN_ROOT_VIRTUAL != $this->request_server_id) { |
|
556 | + throw new Exception(classLocale::$lang['pay_msg_request_server_wrong']." {$this->request_server_id} вместо ".SN_ROOT_VIRTUAL, SN_PAYMENT_REQUEST_SERVER_WRONG); |
|
557 | 557 | } |
558 | 558 | } |
559 | 559 | |
560 | 560 | // Сверка количества оплаченной ММ с учётом бонусов |
561 | - if(!empty($this->payment_params['payment_dark_matter_gained'])) { |
|
561 | + if (!empty($this->payment_params['payment_dark_matter_gained'])) { |
|
562 | 562 | $request_mm_amount = sys_get_param_id($this->payment_params['payment_dark_matter_gained']); |
563 | - if($request_mm_amount != $this->payment_dark_matter_gained && $this->is_loaded) { |
|
564 | - throw new Exception(classLocale::$lang['pay_msg_mm_request_amount_invalid'] . " пришло {$request_mm_amount} ММ вместо {$this->payment_dark_matter_gained} ММ", SN_PAYMENT_REQUEST_MM_AMOUNT_INVALID); |
|
563 | + if ($request_mm_amount != $this->payment_dark_matter_gained && $this->is_loaded) { |
|
564 | + throw new Exception(classLocale::$lang['pay_msg_mm_request_amount_invalid']." пришло {$request_mm_amount} ММ вместо {$this->payment_dark_matter_gained} ММ", SN_PAYMENT_REQUEST_MM_AMOUNT_INVALID); |
|
565 | 565 | } |
566 | 566 | empty($this->payment_dark_matter_gained) ? $this->payment_dark_matter_gained = $request_mm_amount : false; |
567 | 567 | } |
568 | - if(empty($this->payment_dark_matter_paid)) { |
|
568 | + if (empty($this->payment_dark_matter_paid)) { |
|
569 | 569 | // TODO - обратный расчёт из gained |
570 | 570 | } |
571 | 571 | |
572 | 572 | // Проверка наличия внешнего ИД платежа |
573 | - if(!empty($this->payment_params['payment_external_id'])) { |
|
573 | + if (!empty($this->payment_params['payment_external_id'])) { |
|
574 | 574 | $request_payment_external_id = sys_get_param_id($this->payment_params['payment_external_id']); |
575 | - if(empty($request_payment_external_id)) { |
|
575 | + if (empty($request_payment_external_id)) { |
|
576 | 576 | throw new exception(classLocale::$lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_EXTERNAL_ID_WRONG); |
577 | - } elseif(!empty($this->payment_external_id) && $this->payment_external_id != $request_payment_external_id) { |
|
577 | + } elseif (!empty($this->payment_external_id) && $this->payment_external_id != $request_payment_external_id) { |
|
578 | 578 | // TODO - Может быть поменять сообщение |
579 | 579 | throw new exception(classLocale::$lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_EXTERNAL_ID_WRONG); |
580 | 580 | } |
581 | 581 | $this->payment_external_id = $request_payment_external_id; |
582 | 582 | } |
583 | 583 | // Сверка суммы, запрошенной СН к оплате |
584 | - if(!empty($this->payment_params['payment_external_money'])) { |
|
584 | + if (!empty($this->payment_params['payment_external_money'])) { |
|
585 | 585 | $request_money_out = sys_get_param_float($this->payment_params['payment_external_money']); |
586 | - if($request_money_out != $this->payment_external_amount && $this->is_loaded) { |
|
587 | - throw new Exception(classLocale::$lang['pay_msg_request_payment_amount_invalid'] . " пришло {$request_money_out} денег вместо {$this->payment_external_amount} денег", SN_PAYMENT_REQUEST_CURRENCY_AMOUNT_INVALID); |
|
586 | + if ($request_money_out != $this->payment_external_amount && $this->is_loaded) { |
|
587 | + throw new Exception(classLocale::$lang['pay_msg_request_payment_amount_invalid']." пришло {$request_money_out} денег вместо {$this->payment_external_amount} денег", SN_PAYMENT_REQUEST_CURRENCY_AMOUNT_INVALID); |
|
588 | 588 | } |
589 | 589 | empty($this->payment_external_amount) ? $this->payment_external_amount = $request_money_out : false; |
590 | 590 | } |
591 | 591 | // Заполняем поле валюты платёжной системы |
592 | - if(!empty($this->payment_params['payment_external_currency'])) { |
|
592 | + if (!empty($this->payment_params['payment_external_currency'])) { |
|
593 | 593 | $this->payment_external_currency = sys_get_param_str($this->payment_params['payment_external_currency']); |
594 | - if(empty($this->payment_external_currency)) { |
|
594 | + if (empty($this->payment_external_currency)) { |
|
595 | 595 | // TODO - поменять сообщение |
596 | - throw new Exception(classLocale::$lang['pay_msg_request_payment_amount_invalid'] . " {$this->payment_external_currency}", SN_PAYMENT_REQUEST_CURRENCY_AMOUNT_INVALID); |
|
596 | + throw new Exception(classLocale::$lang['pay_msg_request_payment_amount_invalid']." {$this->payment_external_currency}", SN_PAYMENT_REQUEST_CURRENCY_AMOUNT_INVALID); |
|
597 | 597 | } |
598 | 598 | } |
599 | - if(empty($this->payment_external_currency)) { |
|
599 | + if (empty($this->payment_external_currency)) { |
|
600 | 600 | $this->payment_external_currency = $this->config['currency']; |
601 | 601 | } |
602 | 602 | |
603 | 603 | // Заполнение внутренней суммы и валюты из внешних данных |
604 | - if(empty($this->payment_currency)) { |
|
604 | + if (empty($this->payment_currency)) { |
|
605 | 605 | $this->payment_currency = classSupernova::$config->payment_currency_default; |
606 | 606 | } |
607 | - if(empty($this->payment_amount) && !empty($this->payment_external_currency)) { |
|
607 | + if (empty($this->payment_amount) && !empty($this->payment_external_currency)) { |
|
608 | 608 | $this->payment_amount = self::currency_convert($this->payment_external_amount, $this->payment_external_currency, $this->payment_currency); |
609 | 609 | } |
610 | 610 | |
611 | 611 | // TODO - Тестовый режим |
612 | - if(!empty($this->payment_params['test'])) { |
|
612 | + if (!empty($this->payment_params['test'])) { |
|
613 | 613 | $this->payment_test = $this->config['test'] || sys_get_param_int($this->payment_params['test']); |
614 | 614 | } |
615 | 615 | |
@@ -636,21 +636,21 @@ discard block |
||
636 | 636 | sn_db_transaction_start(); |
637 | 637 | try { |
638 | 638 | $response = $this->payment_request_process(); |
639 | - } catch(Exception $e) { |
|
639 | + } catch (Exception $e) { |
|
640 | 640 | $response['result'] = $e->getCode(); |
641 | 641 | $response['message'] = $e->getMessage(); |
642 | 642 | } |
643 | 643 | |
644 | - if($response['result'] == SN_PAYMENT_REQUEST_OK) { |
|
644 | + if ($response['result'] == SN_PAYMENT_REQUEST_OK) { |
|
645 | 645 | sn_db_transaction_commit(); |
646 | - classSupernova::$debug->warning('Результат операции: код ' . $response['result'] . ' сообщение "' . $response['message'] . '"', 'Успешный платёж', LOG_INFO_PAYMENT); |
|
646 | + classSupernova::$debug->warning('Результат операции: код '.$response['result'].' сообщение "'.$response['message'].'"', 'Успешный платёж', LOG_INFO_PAYMENT); |
|
647 | 647 | } else { |
648 | 648 | sn_db_transaction_rollback(); |
649 | - classSupernova::$debug->warning('Результат операции: код ' . $response['result'] . ' сообщение "' . $response['message'] . '"', 'Ошибка платежа', LOG_INFO_PAYMENT, true); |
|
649 | + classSupernova::$debug->warning('Результат операции: код '.$response['result'].' сообщение "'.$response['message'].'"', 'Ошибка платежа', LOG_INFO_PAYMENT, true); |
|
650 | 650 | } |
651 | 651 | |
652 | 652 | // Переводим код результата из СН в код платежной системы |
653 | - if(is_array($this->result_translations) && !empty($this->result_translations)) { |
|
653 | + if (is_array($this->result_translations) && !empty($this->result_translations)) { |
|
654 | 654 | $response['result'] = isset($this->result_translations[$response['result']]) ? $this->result_translations[$response['result']] : $this->result_translations[SN_PAYMENT_REQUEST_UNDEFINED_ERROR]; |
655 | 655 | } |
656 | 656 | |
@@ -673,7 +673,7 @@ discard block |
||
673 | 673 | $currency_from = strtolower($currency_from); |
674 | 674 | $currency_to = strtolower($currency_to); |
675 | 675 | |
676 | - if($currency_from != $currency_to) { |
|
676 | + if ($currency_from != $currency_to) { |
|
677 | 677 | $exchange_from = get_exchange_rate($currency_from); |
678 | 678 | $exchange_to = get_exchange_rate($currency_to); |
679 | 679 | |
@@ -697,10 +697,10 @@ discard block |
||
697 | 697 | public static function bonus_calculate($dark_matter, $direct = true, $return_bonus = false) { |
698 | 698 | $bonus = 0; |
699 | 699 | $dark_matter_new = $dark_matter; |
700 | - if(!empty(self::$bonus_table) && $dark_matter >= self::$bonus_table[0]) { |
|
701 | - if($direct) { |
|
702 | - foreach(self::$bonus_table as $dm_for_bonus => $multiplier) { |
|
703 | - if($dm_for_bonus <= $dark_matter) { |
|
700 | + if (!empty(self::$bonus_table) && $dark_matter >= self::$bonus_table[0]) { |
|
701 | + if ($direct) { |
|
702 | + foreach (self::$bonus_table as $dm_for_bonus => $multiplier) { |
|
703 | + if ($dm_for_bonus <= $dark_matter) { |
|
704 | 704 | $dark_matter_new = $dark_matter * (1 + $multiplier); |
705 | 705 | $bonus = $multiplier; |
706 | 706 | } else { |
@@ -708,9 +708,9 @@ discard block |
||
708 | 708 | } |
709 | 709 | } |
710 | 710 | } else { |
711 | - foreach(self::$bonus_table as $dm_for_bonus => $multiplier) { |
|
711 | + foreach (self::$bonus_table as $dm_for_bonus => $multiplier) { |
|
712 | 712 | $temp = $dm_for_bonus * (1 + $multiplier); |
713 | - if($dark_matter >= $temp) { |
|
713 | + if ($dark_matter >= $temp) { |
|
714 | 714 | $dark_matter_new = round($dark_matter / (1 + $multiplier)); |
715 | 715 | $bonus = $multiplier; |
716 | 716 | } else { |
@@ -764,30 +764,30 @@ discard block |
||
764 | 764 | ); |
765 | 765 | |
766 | 766 | $replace = false; |
767 | - if($this->payment_id) { |
|
767 | + if ($this->payment_id) { |
|
768 | 768 | $payment['payment_id'] = $this->payment_id; |
769 | 769 | $replace = true; |
770 | 770 | } |
771 | 771 | |
772 | 772 | $query = array(); |
773 | - foreach($payment as $key => $value) { |
|
774 | - $value = is_string($value) ? '"' . db_escape($value) . '"' : $value; |
|
773 | + foreach ($payment as $key => $value) { |
|
774 | + $value = is_string($value) ? '"'.db_escape($value).'"' : $value; |
|
775 | 775 | $query[] = "`{$key}` = {$value}"; |
776 | 776 | } |
777 | 777 | |
778 | - $this->db->doquery(($replace ? 'REPLACE' : 'INSERT') . ' INTO `{{payment}}` SET ' . implode(',', $query) . ';'); |
|
778 | + $this->db->doquery(($replace ? 'REPLACE' : 'INSERT').' INTO `{{payment}}` SET '.implode(',', $query).';'); |
|
779 | 779 | |
780 | 780 | return $this->db_get_by_id($this->db->db_insert_id()); |
781 | 781 | } |
782 | 782 | |
783 | 783 | |
784 | 784 | function payment_adjust_mm_new() { |
785 | - if(!$this->payment_test) { |
|
785 | + if (!$this->payment_test) { |
|
786 | 786 | // Not a test payment. Adding DM to account |
787 | 787 | $this->account = new Account($this->db); |
788 | 788 | $this->account->db_get_by_id($this->payment_account_id); |
789 | 789 | $result = $this->account->metamatter_change(RPG_PURCHASE, $this->payment_dark_matter_gained, $this->payment_comment); |
790 | - if(!$result) { |
|
790 | + if (!$result) { |
|
791 | 791 | throw new Exception('Ошибка начисления ММ', SN_METAMATTER_ERROR_ADJUST); |
792 | 792 | } |
793 | 793 | } |
@@ -796,25 +796,25 @@ discard block |
||
796 | 796 | function payment_cancel(&$payment) { |
797 | 797 | die('{НЕ РАБОТАЕТ! СООБЩИТЕ АДМИНИСТРАЦИИ!}'); |
798 | 798 | |
799 | - if(!isset($payment['payment_status'])) { |
|
799 | + if (!isset($payment['payment_status'])) { |
|
800 | 800 | throw new exception(classLocale::$lang['pay_msg_request_payment_not_found'], SN_PAYMENT_REQUEST_ORDER_NOT_FOUND); |
801 | 801 | } |
802 | 802 | |
803 | - if($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) { |
|
804 | - $safe_comment = db_escape($payment['payment_comment'] = classLocale::$lang['pay_msg_request_payment_cancelled'] .' ' . $payment['payment_comment']); |
|
803 | + if ($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) { |
|
804 | + $safe_comment = db_escape($payment['payment_comment'] = classLocale::$lang['pay_msg_request_payment_cancelled'].' '.$payment['payment_comment']); |
|
805 | 805 | |
806 | - if(!$payment['payment_test']) { |
|
806 | + if (!$payment['payment_test']) { |
|
807 | 807 | $result = $this->account->metamatter_change(RPG_PURCHASE_CANCEL, -$payment['payment_dark_matter_gained'], $payment['payment_comment']); |
808 | - if(!$result) { |
|
808 | + if (!$result) { |
|
809 | 809 | throw new exception('Ошибка начисления ММ', SN_METAMATTER_ERROR_ADJUST); |
810 | 810 | } |
811 | 811 | } |
812 | 812 | $payment['payment_status'] = PAYMENT_STATUS_CANCELED; |
813 | 813 | db_payment_update($payment, $safe_comment); |
814 | 814 | throw new exception(classLocale::$lang['pay_msg_request_payment_cancel_complete'], SN_PAYMENT_REQUEST_OK); |
815 | - } elseif($payment['payment_status'] == PAYMENT_STATUS_CANCELED) { |
|
815 | + } elseif ($payment['payment_status'] == PAYMENT_STATUS_CANCELED) { |
|
816 | 816 | throw new exception(classLocale::$lang['pay_msg_request_payment_cancelled_already'], SN_PAYMENT_REQUEST_OK); |
817 | - } elseif($payment['payment_status'] == PAYMENT_STATUS_NONE) { |
|
817 | + } elseif ($payment['payment_status'] == PAYMENT_STATUS_NONE) { |
|
818 | 818 | throw new exception(classLocale::$lang['pay_msg_request_payment_cancel_not_complete'], SN_PAYMENT_REQUEST_PAYMENT_NOT_COMPLETE); |
819 | 819 | } |
820 | 820 | } |
@@ -828,8 +828,8 @@ discard block |
||
828 | 828 | |
829 | 829 | protected function db_complete_payment() { |
830 | 830 | // TODO - поле payment_processed |
831 | - if($this->payment_status == PAYMENT_STATUS_NONE) { |
|
832 | - if(!defined('PAYMENT_EXPIRE_TIME') || PAYMENT_EXPIRE_TIME == 0 || empty($this->payment_date) || strtotime($this->payment_date) + PAYMENT_EXPIRE_TIME <= SN_TIME_NOW) { |
|
831 | + if ($this->payment_status == PAYMENT_STATUS_NONE) { |
|
832 | + if (!defined('PAYMENT_EXPIRE_TIME') || PAYMENT_EXPIRE_TIME == 0 || empty($this->payment_date) || strtotime($this->payment_date) + PAYMENT_EXPIRE_TIME <= SN_TIME_NOW) { |
|
833 | 833 | $this->payment_adjust_mm_new(); |
834 | 834 | $this->payment_status = PAYMENT_STATUS_COMPLETE; |
835 | 835 | } else { |
@@ -876,7 +876,7 @@ discard block |
||
876 | 876 | protected function db_assign_payment($payment = null) { |
877 | 877 | $this->payment_reset(); |
878 | 878 | |
879 | - if(is_array($payment) && isset($payment['payment_id'])) { |
|
879 | + if (is_array($payment) && isset($payment['payment_id'])) { |
|
880 | 880 | $this->payment_id = $payment['payment_id']; |
881 | 881 | $this->payment_status = $payment['payment_status']; |
882 | 882 | $this->payment_date = $payment['payment_date']; |
@@ -918,11 +918,11 @@ discard block |
||
918 | 918 | protected function generate_description() { |
919 | 919 | // TODO - системная локализация |
920 | 920 | $this->description_generated = array( |
921 | - PAYMENT_DESCRIPTION_100 => substr("{$this->payment_dark_matter_gained} ММ аккаунт [{$this->account->account_name}] ID {$this->account->account_id} на " . SN_ROOT_VIRTUAL, 0, 100), |
|
922 | - PAYMENT_DESCRIPTION_250 => substr("Оплата {$this->payment_dark_matter_gained} ММ для аккаунта [{$this->payment_user_name}] ID {$this->payment_user_id} на сервере " . SN_ROOT_VIRTUAL, 0, 250), |
|
923 | - PAYMENT_DESCRIPTION_MAX => ($this->payment_test ? "ТЕСТОВЫЙ ПЛАТЕЖ! " : '') . |
|
924 | - "Платеж от аккаунта '{$this->payment_account_name}' ID {$this->payment_account_id} игрока '{$this->payment_user_name}' ID {$this->payment_user_id} на сервере " . SN_ROOT_VIRTUAL . |
|
925 | - " сумма {$this->payment_amount} {$this->payment_currency} за {$this->payment_dark_matter_paid} ММ (начислено {$this->payment_dark_matter_gained} ММ)" . |
|
921 | + PAYMENT_DESCRIPTION_100 => substr("{$this->payment_dark_matter_gained} ММ аккаунт [{$this->account->account_name}] ID {$this->account->account_id} на ".SN_ROOT_VIRTUAL, 0, 100), |
|
922 | + PAYMENT_DESCRIPTION_250 => substr("Оплата {$this->payment_dark_matter_gained} ММ для аккаунта [{$this->payment_user_name}] ID {$this->payment_user_id} на сервере ".SN_ROOT_VIRTUAL, 0, 250), |
|
923 | + PAYMENT_DESCRIPTION_MAX => ($this->payment_test ? "ТЕСТОВЫЙ ПЛАТЕЖ! " : ''). |
|
924 | + "Платеж от аккаунта '{$this->payment_account_name}' ID {$this->payment_account_id} игрока '{$this->payment_user_name}' ID {$this->payment_user_id} на сервере ".SN_ROOT_VIRTUAL. |
|
925 | + " сумма {$this->payment_amount} {$this->payment_currency} за {$this->payment_dark_matter_paid} ММ (начислено {$this->payment_dark_matter_gained} ММ)". |
|
926 | 926 | " через '{$this->manifest['name']}' сумма {$this->payment_external_amount} {$this->payment_external_currency}", |
927 | 927 | ); |
928 | 928 | } |
@@ -103,6 +103,7 @@ |
||
103 | 103 | /** |
104 | 104 | * Set custom template location (able to use directory outside of phpBB) |
105 | 105 | * @access public |
106 | + * @param string $template_path |
|
106 | 107 | */ |
107 | 108 | function set_custom_template($template_path, $template_name, $fallback_template_path = false) |
108 | 109 | { |
@@ -25,11 +25,11 @@ discard block |
||
25 | 25 | class template |
26 | 26 | { |
27 | 27 | /** variable that holds all the data we'll be substituting into |
28 | - * the compiled templates. Takes form: |
|
29 | - * --> $this->_tpldata[block][iteration#][child][iteration#][child2][iteration#][variablename] == value |
|
30 | - * if it's a root-level variable, it'll be like this: |
|
31 | - * --> $this->_tpldata[.][0][varname] == value |
|
32 | - */ |
|
28 | + * the compiled templates. Takes form: |
|
29 | + * --> $this->_tpldata[block][iteration#][child][iteration#][child2][iteration#][variablename] == value |
|
30 | + * if it's a root-level variable, it'll be like this: |
|
31 | + * --> $this->_tpldata[.][0][varname] == value |
|
32 | + */ |
|
33 | 33 | var $_tpldata = array('.' => array(0 => array())); |
34 | 34 | var $_rootref; |
35 | 35 | // var $_block_counter = array(); |
@@ -60,9 +60,9 @@ discard block |
||
60 | 60 | var $parsed = false; |
61 | 61 | |
62 | 62 | /** |
63 | - * Set template location |
|
64 | - * @access public |
|
65 | - */ |
|
63 | + * Set template location |
|
64 | + * @access public |
|
65 | + */ |
|
66 | 66 | function set_template() |
67 | 67 | { |
68 | 68 | global $phpbb_root_path, $user; |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
104 | - * Set custom template location (able to use directory outside of phpBB) |
|
105 | - * @access public |
|
106 | - */ |
|
104 | + * Set custom template location (able to use directory outside of phpBB) |
|
105 | + * @access public |
|
106 | + */ |
|
107 | 107 | function set_custom_template($template_path, $template_name, $fallback_template_path = false) |
108 | 108 | { |
109 | 109 | global $phpbb_root_path, $user; |
@@ -142,10 +142,10 @@ discard block |
||
142 | 142 | } |
143 | 143 | |
144 | 144 | /** |
145 | - * Sets the template filenames for handles. $filename_array |
|
146 | - * should be a hash of handle => filename pairs. |
|
147 | - * @access public |
|
148 | - */ |
|
145 | + * Sets the template filenames for handles. $filename_array |
|
146 | + * should be a hash of handle => filename pairs. |
|
147 | + * @access public |
|
148 | + */ |
|
149 | 149 | function set_filenames($filename_array) |
150 | 150 | { |
151 | 151 | if (!is_array($filename_array)) |
@@ -172,9 +172,9 @@ discard block |
||
172 | 172 | } |
173 | 173 | |
174 | 174 | /** |
175 | - * Destroy template data set |
|
176 | - * @access public |
|
177 | - */ |
|
175 | + * Destroy template data set |
|
176 | + * @access public |
|
177 | + */ |
|
178 | 178 | function destroy() |
179 | 179 | { |
180 | 180 | $this->_tpldata = array('.' => array(0 => array())); |
@@ -182,9 +182,9 @@ discard block |
||
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
185 | - * Reset/empty complete block |
|
186 | - * @access public |
|
187 | - */ |
|
185 | + * Reset/empty complete block |
|
186 | + * @access public |
|
187 | + */ |
|
188 | 188 | function destroy_block_vars($blockname) |
189 | 189 | { |
190 | 190 | if (strpos($blockname, '.') !== false) |
@@ -212,9 +212,9 @@ discard block |
||
212 | 212 | } |
213 | 213 | |
214 | 214 | /** |
215 | - * Display handle |
|
216 | - * @access public |
|
217 | - */ |
|
215 | + * Display handle |
|
216 | + * @access public |
|
217 | + */ |
|
218 | 218 | function display($handle, $include_once = true) |
219 | 219 | { |
220 | 220 | global $user, $phpbb_hook, $lang, $config; |
@@ -248,9 +248,9 @@ discard block |
||
248 | 248 | } |
249 | 249 | |
250 | 250 | /** |
251 | - * Display the handle and assign the output to a template variable or return the compiled result. |
|
252 | - * @access public |
|
253 | - */ |
|
251 | + * Display the handle and assign the output to a template variable or return the compiled result. |
|
252 | + * @access public |
|
253 | + */ |
|
254 | 254 | function assign_display($handle, $template_var = '', $return_content = true, $include_once = false) |
255 | 255 | { |
256 | 256 | ob_start(); |
@@ -268,9 +268,9 @@ discard block |
||
268 | 268 | } |
269 | 269 | |
270 | 270 | /** |
271 | - * Load a compiled template if possible, if not, recompile it |
|
272 | - * @access private |
|
273 | - */ |
|
271 | + * Load a compiled template if possible, if not, recompile it |
|
272 | + * @access private |
|
273 | + */ |
|
274 | 274 | function _tpl_load(&$handle) |
275 | 275 | { |
276 | 276 | global $user, $config; |
@@ -453,9 +453,9 @@ discard block |
||
453 | 453 | } |
454 | 454 | |
455 | 455 | /** |
456 | - * Assign key variable pairs from an array |
|
457 | - * @access public |
|
458 | - */ |
|
456 | + * Assign key variable pairs from an array |
|
457 | + * @access public |
|
458 | + */ |
|
459 | 459 | function assign_vars($vararray) |
460 | 460 | { |
461 | 461 | foreach ($vararray as $key => $val) |
@@ -467,9 +467,9 @@ discard block |
||
467 | 467 | } |
468 | 468 | |
469 | 469 | /** |
470 | - * Assign a single variable to a single key |
|
471 | - * @access public |
|
472 | - */ |
|
470 | + * Assign a single variable to a single key |
|
471 | + * @access public |
|
472 | + */ |
|
473 | 473 | function assign_var($varname, $varval) |
474 | 474 | { |
475 | 475 | $this->_rootref[$varname] = $varval; |
@@ -478,9 +478,9 @@ discard block |
||
478 | 478 | } |
479 | 479 | |
480 | 480 | /** |
481 | - * Assign key variable pairs from an array to a specified block |
|
482 | - * @access public |
|
483 | - */ |
|
481 | + * Assign key variable pairs from an array to a specified block |
|
482 | + * @access public |
|
483 | + */ |
|
484 | 484 | function assign_block_vars($blockname, $vararray) |
485 | 485 | { |
486 | 486 | if (strpos($blockname, '.') !== false) |
@@ -545,33 +545,33 @@ discard block |
||
545 | 545 | } |
546 | 546 | |
547 | 547 | /** |
548 | - * Change already assigned key variable pair (one-dimensional - single loop entry) |
|
549 | - * |
|
550 | - * An example of how to use this function: |
|
551 | - * {@example alter_block_array.php} |
|
552 | - * |
|
553 | - * @param string $blockname the blockname, for example 'loop' |
|
554 | - * @param array $vararray the var array to insert/add or merge |
|
555 | - * @param mixed $key Key to search for |
|
556 | - * |
|
557 | - * array: KEY => VALUE [the key/value pair to search for within the loop to determine the correct position] |
|
558 | - * |
|
559 | - * int: Position [the position to change or insert at directly given] |
|
560 | - * |
|
561 | - * If key is false the position is set to 0 |
|
562 | - * If key is true the position is set to the last entry |
|
563 | - * |
|
564 | - * @param string $mode Mode to execute (valid modes are 'insert' and 'change') |
|
565 | - * |
|
566 | - * If insert, the vararray is inserted at the given position (position counting from zero). |
|
567 | - * If change, the current block gets merged with the vararray (resulting in new key/value pairs be added and existing keys be replaced by the new value). |
|
568 | - * |
|
569 | - * Since counting begins by zero, inserting at the last position will result in this array: array(vararray, last positioned array) |
|
570 | - * and inserting at position 1 will result in this array: array(first positioned array, vararray, following vars) |
|
571 | - * |
|
572 | - * @return bool false on error, true on success |
|
573 | - * @access public |
|
574 | - */ |
|
548 | + * Change already assigned key variable pair (one-dimensional - single loop entry) |
|
549 | + * |
|
550 | + * An example of how to use this function: |
|
551 | + * {@example alter_block_array.php} |
|
552 | + * |
|
553 | + * @param string $blockname the blockname, for example 'loop' |
|
554 | + * @param array $vararray the var array to insert/add or merge |
|
555 | + * @param mixed $key Key to search for |
|
556 | + * |
|
557 | + * array: KEY => VALUE [the key/value pair to search for within the loop to determine the correct position] |
|
558 | + * |
|
559 | + * int: Position [the position to change or insert at directly given] |
|
560 | + * |
|
561 | + * If key is false the position is set to 0 |
|
562 | + * If key is true the position is set to the last entry |
|
563 | + * |
|
564 | + * @param string $mode Mode to execute (valid modes are 'insert' and 'change') |
|
565 | + * |
|
566 | + * If insert, the vararray is inserted at the given position (position counting from zero). |
|
567 | + * If change, the current block gets merged with the vararray (resulting in new key/value pairs be added and existing keys be replaced by the new value). |
|
568 | + * |
|
569 | + * Since counting begins by zero, inserting at the last position will result in this array: array(vararray, last positioned array) |
|
570 | + * and inserting at position 1 will result in this array: array(first positioned array, vararray, following vars) |
|
571 | + * |
|
572 | + * @return bool false on error, true on success |
|
573 | + * @access public |
|
574 | + */ |
|
575 | 575 | function alter_block_array($blockname, $vararray, $key = false, $mode = 'insert') |
576 | 576 | { |
577 | 577 | if (strpos($blockname, '.') !== false) |
@@ -655,9 +655,9 @@ discard block |
||
655 | 655 | } |
656 | 656 | |
657 | 657 | /** |
658 | - * Include a separate template |
|
659 | - * @access private |
|
660 | - */ |
|
658 | + * Include a separate template |
|
659 | + * @access private |
|
660 | + */ |
|
661 | 661 | function _tpl_include($filename, $include = true) |
662 | 662 | { |
663 | 663 | global $lang, $config; |
@@ -686,9 +686,9 @@ discard block |
||
686 | 686 | } |
687 | 687 | |
688 | 688 | /** |
689 | - * Include a php-file |
|
690 | - * @access private |
|
691 | - */ |
|
689 | + * Include a php-file |
|
690 | + * @access private |
|
691 | + */ |
|
692 | 692 | function _php_include($filename) |
693 | 693 | { |
694 | 694 | global $phpbb_root_path; |
@@ -705,9 +705,9 @@ discard block |
||
705 | 705 | } |
706 | 706 | |
707 | 707 | /** |
708 | - * Assign key variable pairs from an array with block support |
|
709 | - * @access public |
|
710 | - */ |
|
708 | + * Assign key variable pairs from an array with block support |
|
709 | + * @access public |
|
710 | + */ |
|
711 | 711 | function assign_recursive($values, $name = '') |
712 | 712 | { |
713 | 713 | if(isset($values['.'])) |
@@ -83,8 +83,7 @@ discard block |
||
83 | 83 | { |
84 | 84 | $this->inherit_root = $phpbb_root_path . 'styles/' . $user->theme['template_inherit_path'] . '/template'; |
85 | 85 | } |
86 | - } |
|
87 | - else |
|
86 | + } else |
|
88 | 87 | { |
89 | 88 | trigger_error('Template path could not be found: styles/' . $user->theme['template_path'] . '/template', E_USER_ERROR); |
90 | 89 | } |
@@ -120,8 +119,7 @@ discard block |
||
120 | 119 | |
121 | 120 | $this->inherit_root = $fallback_template_path; |
122 | 121 | $this->orig_tpl_inherits_id = true; |
123 | - } |
|
124 | - else |
|
122 | + } else |
|
125 | 123 | { |
126 | 124 | $this->orig_tpl_inherits_id = false; |
127 | 125 | } |
@@ -195,8 +193,7 @@ discard block |
||
195 | 193 | } |
196 | 194 | |
197 | 195 | unset($str[$blocks[$blockcount]]); |
198 | - } |
|
199 | - else |
|
196 | + } else |
|
200 | 197 | { |
201 | 198 | // Top-level block. |
202 | 199 | unset($this->_tpldata[$blockname]); |
@@ -232,8 +229,7 @@ discard block |
||
232 | 229 | if ($filename = $this->_tpl_load($handle)) |
233 | 230 | { |
234 | 231 | ($include_once) ? include_once($filename) : include($filename); |
235 | - } |
|
236 | - else |
|
232 | + } else |
|
237 | 233 | { |
238 | 234 | eval(' ?>' . $this->compiled_code[$handle] . '<?php '); |
239 | 235 | } |
@@ -287,8 +283,7 @@ discard block |
||
287 | 283 | if (!file_exists($filename) || @filesize($filename) === 0) |
288 | 284 | { |
289 | 285 | $recompile = true; |
290 | - } |
|
291 | - else if (classSupernova::$config->load_tplcompile) |
|
286 | + } else if (classSupernova::$config->load_tplcompile) |
|
292 | 287 | { |
293 | 288 | // No way around it: we need to check inheritance here |
294 | 289 | if ($user->theme['template_inherits_id'] && !file_exists($this->files[$handle])) |
@@ -376,15 +371,13 @@ discard block |
||
376 | 371 | $this->files[$row['template_filename']] = $file; |
377 | 372 | $this->files_inherit[$row['template_filename']] = $file; |
378 | 373 | $this->files_template[$row['template_filename']] = $user->theme['template_inherits_id']; |
379 | - } |
|
380 | - else if (isset($user->theme['template_inherits_id']) && $user->theme['template_inherits_id']) |
|
374 | + } else if (isset($user->theme['template_inherits_id']) && $user->theme['template_inherits_id']) |
|
381 | 375 | { |
382 | 376 | // Ok, we have a situation. There is a file in the subtemplate, but nothing in the DB. We have to fix that. |
383 | 377 | $force_reload = true; |
384 | 378 | $this->files_template[$row['template_filename']] = $user->theme['template_inherits_id']; |
385 | 379 | } |
386 | - } |
|
387 | - else |
|
380 | + } else |
|
388 | 381 | { |
389 | 382 | $this->files_template[$row['template_filename']] = $user->theme['template_id']; |
390 | 383 | } |
@@ -394,8 +387,7 @@ discard block |
||
394 | 387 | if ($row['template_filename'] == $this->filename[$handle]) |
395 | 388 | { |
396 | 389 | $compile->_tpl_load_file($handle, true); |
397 | - } |
|
398 | - else |
|
390 | + } else |
|
399 | 391 | { |
400 | 392 | $this->files[$row['template_filename']] = $file; |
401 | 393 | $this->filename[$row['template_filename']] = $row['template_filename']; |
@@ -410,8 +402,7 @@ discard block |
||
410 | 402 | { |
411 | 403 | $this->compiled_code[$handle] = $compile->compile(trim($row['template_data'])); |
412 | 404 | $compile->compile_write($handle, $this->compiled_code[$handle]); |
413 | - } |
|
414 | - else |
|
405 | + } else |
|
415 | 406 | { |
416 | 407 | // Only bother compiling if it doesn't already exist |
417 | 408 | if (!file_exists($this->cachepath . str_replace('/', '.', $row['template_filename']) . DOT_PHP_EX)) |
@@ -422,8 +413,7 @@ discard block |
||
422 | 413 | } |
423 | 414 | } |
424 | 415 | } |
425 | - } |
|
426 | - else |
|
416 | + } else |
|
427 | 417 | { |
428 | 418 | $file = $this->root . '/' . $row['template_filename']; |
429 | 419 | |
@@ -511,8 +501,7 @@ discard block |
||
511 | 501 | // We're adding a new iteration to this block with the given |
512 | 502 | // variable assignments. |
513 | 503 | $str[$blocks[$blockcount]][] = $vararray; |
514 | - } |
|
515 | - else |
|
504 | + } else |
|
516 | 505 | { |
517 | 506 | // Top-level block. |
518 | 507 | $s_row_count = (isset($this->_tpldata[$blockname])) ? sizeof($this->_tpldata[$blockname]) : 0; |
@@ -612,8 +601,7 @@ discard block |
||
612 | 601 | $key = sizeof($this->_tpldata[$blockname]); |
613 | 602 | unset($this->_tpldata[$blockname][($key - 1)]['S_LAST_ROW']); |
614 | 603 | $vararray['S_LAST_ROW'] = true; |
615 | - } |
|
616 | - else if ($key === 0) |
|
604 | + } else if ($key === 0) |
|
617 | 605 | { |
618 | 606 | unset($this->_tpldata[$blockname][0]['S_FIRST_ROW']); |
619 | 607 | $vararray['S_FIRST_ROW'] = true; |
@@ -711,8 +699,7 @@ discard block |
||
711 | 699 | if(!$name) |
712 | 700 | { |
713 | 701 | $this->assign_vars($values); |
714 | - } |
|
715 | - else |
|
702 | + } else |
|
716 | 703 | { |
717 | 704 | $this->assign_block_vars($name, $values); |
718 | 705 | } |
@@ -61,10 +61,10 @@ discard block |
||
61 | 61 | { |
62 | 62 | global $phpbb_root_path, $user; |
63 | 63 | |
64 | - if (file_exists($phpbb_root_path . 'styles/' . $user->theme['template_path'] . '/template')) |
|
64 | + if (file_exists($phpbb_root_path.'styles/'.$user->theme['template_path'].'/template')) |
|
65 | 65 | { |
66 | - $this->root = $phpbb_root_path . 'styles/' . $user->theme['template_path'] . '/template'; |
|
67 | - $this->cachepath = $phpbb_root_path . 'cache/tpl_' . str_replace('_', '-', $user->theme['template_path']) . '_'; |
|
66 | + $this->root = $phpbb_root_path.'styles/'.$user->theme['template_path'].'/template'; |
|
67 | + $this->cachepath = $phpbb_root_path.'cache/tpl_'.str_replace('_', '-', $user->theme['template_path']).'_'; |
|
68 | 68 | |
69 | 69 | if ($this->orig_tpl_storedb === null) |
70 | 70 | { |
@@ -81,12 +81,12 @@ discard block |
||
81 | 81 | |
82 | 82 | if ($user->theme['template_inherits_id']) |
83 | 83 | { |
84 | - $this->inherit_root = $phpbb_root_path . 'styles/' . $user->theme['template_inherit_path'] . '/template'; |
|
84 | + $this->inherit_root = $phpbb_root_path.'styles/'.$user->theme['template_inherit_path'].'/template'; |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | else |
88 | 88 | { |
89 | - trigger_error('Template path could not be found: styles/' . $user->theme['template_path'] . '/template', E_USER_ERROR); |
|
89 | + trigger_error('Template path could not be found: styles/'.$user->theme['template_path'].'/template', E_USER_ERROR); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | $this->_rootref = &$this->_tpldata['.'][0]; |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | } |
110 | 110 | |
111 | 111 | $this->root = $template_path; |
112 | - $this->cachepath = $phpbb_root_path . 'cache/ctpl_' . str_replace('_', '-', $template_name) . '_'; |
|
112 | + $this->cachepath = $phpbb_root_path.'cache/ctpl_'.str_replace('_', '-', $template_name).'_'; |
|
113 | 113 | |
114 | 114 | if ($fallback_template_path !== false) |
115 | 115 | { |
@@ -154,11 +154,11 @@ discard block |
||
154 | 154 | } |
155 | 155 | |
156 | 156 | $this->filename[$handle] = $filename; |
157 | - $this->files[$handle] = $this->root . '/' . $filename; |
|
157 | + $this->files[$handle] = $this->root.'/'.$filename; |
|
158 | 158 | |
159 | 159 | if ($this->inherit_root) |
160 | 160 | { |
161 | - $this->files_inherit[$handle] = $this->inherit_root . '/' . $filename; |
|
161 | + $this->files_inherit[$handle] = $this->inherit_root.'/'.$filename; |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | } |
236 | 236 | else |
237 | 237 | { |
238 | - eval(' ?>' . $this->compiled_code[$handle] . '<?php '); |
|
238 | + eval(' ?>'.$this->compiled_code[$handle].'<?php '); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | return true; |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | //$user->theme['template_storedb'] = $this->orig_tpl_storedb; |
281 | 281 | //$user->theme['template_inherits_id'] = $this->orig_tpl_inherits_id; |
282 | 282 | |
283 | - $filename = $this->cachepath . str_replace('/', '.', $this->filename[$handle]) . DOT_PHP_EX; |
|
283 | + $filename = $this->cachepath.str_replace('/', '.', $this->filename[$handle]).DOT_PHP_EX; |
|
284 | 284 | //$this->files_template[$handle] = (isset($user->theme['template_id'])) ? $user->theme['template_id'] : 0; |
285 | 285 | |
286 | 286 | $recompile = false; |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | |
310 | 310 | if (!class_exists('template_compile')) |
311 | 311 | { |
312 | - include($phpbb_root_path . 'includes/functions_template' . DOT_PHP_EX); |
|
312 | + include($phpbb_root_path.'includes/functions_template'.DOT_PHP_EX); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | // Inheritance - we point to another template file for this one. Equality is also used for store_db |
@@ -348,10 +348,10 @@ discard block |
||
348 | 348 | foreach ($ids as $id) |
349 | 349 | { |
350 | 350 | $sql = 'SELECT * |
351 | - FROM ' . STYLES_TEMPLATE_DATA_TABLE . ' |
|
352 | - WHERE template_id = ' . $id . " |
|
353 | - AND (template_filename = '" . $db->sql_escape($this->filename[$handle]) . "' |
|
354 | - OR template_included " . $db->sql_like_expression($db->any_char . $this->filename[$handle] . ':' . $db->any_char) . ')'; |
|
351 | + FROM ' . STYLES_TEMPLATE_DATA_TABLE.' |
|
352 | + WHERE template_id = ' . $id." |
|
353 | + AND (template_filename = '" . $db->sql_escape($this->filename[$handle])."' |
|
354 | + OR template_included " . $db->sql_like_expression($db->any_char.$this->filename[$handle].':'.$db->any_char).')'; |
|
355 | 355 | |
356 | 356 | $result = $db->sql_query($sql); |
357 | 357 | while ($row = $db->sql_fetchrow($result)) |
@@ -365,14 +365,14 @@ discard block |
||
365 | 365 | { |
366 | 366 | foreach ($rows as $row) |
367 | 367 | { |
368 | - $file = $this->root . '/' . $row['template_filename']; |
|
368 | + $file = $this->root.'/'.$row['template_filename']; |
|
369 | 369 | $force_reload = false; |
370 | 370 | if ($row['template_id'] != $user->theme['template_id']) |
371 | 371 | { |
372 | 372 | // make sure that we are not overlooking a file not in the db yet |
373 | 373 | if (isset($user->theme['template_inherits_id']) && $user->theme['template_inherits_id'] && !file_exists($file)) |
374 | 374 | { |
375 | - $file = $this->inherit_root . '/' . $row['template_filename']; |
|
375 | + $file = $this->inherit_root.'/'.$row['template_filename']; |
|
376 | 376 | $this->files[$row['template_filename']] = $file; |
377 | 377 | $this->files_inherit[$row['template_filename']] = $file; |
378 | 378 | $this->files_template[$row['template_filename']] = $user->theme['template_inherits_id']; |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | else |
415 | 415 | { |
416 | 416 | // Only bother compiling if it doesn't already exist |
417 | - if (!file_exists($this->cachepath . str_replace('/', '.', $row['template_filename']) . DOT_PHP_EX)) |
|
417 | + if (!file_exists($this->cachepath.str_replace('/', '.', $row['template_filename']).DOT_PHP_EX)) |
|
418 | 418 | { |
419 | 419 | $this->filename[$row['template_filename']] = $row['template_filename']; |
420 | 420 | $compile->compile_write($row['template_filename'], $compile->compile(trim($row['template_data']))); |
@@ -425,11 +425,11 @@ discard block |
||
425 | 425 | } |
426 | 426 | else |
427 | 427 | { |
428 | - $file = $this->root . '/' . $row['template_filename']; |
|
428 | + $file = $this->root.'/'.$row['template_filename']; |
|
429 | 429 | |
430 | 430 | if (isset($user->theme['template_inherits_id']) && $user->theme['template_inherits_id'] && !file_exists($file)) |
431 | 431 | { |
432 | - $file = $this->inherit_root . '/' . $row['template_filename']; |
|
432 | + $file = $this->inherit_root.'/'.$row['template_filename']; |
|
433 | 433 | $this->files[$row['template_filename']] = $file; |
434 | 434 | $this->files_inherit[$row['template_filename']] = $file; |
435 | 435 | $this->files_template[$row['template_filename']] = $user->theme['template_inherits_id']; |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | // Re-position template blocks |
623 | 623 | for ($i = sizeof($this->_tpldata[$blockname]); $i > $key; $i--) |
624 | 624 | { |
625 | - $this->_tpldata[$blockname][$i] = $this->_tpldata[$blockname][$i-1]; |
|
625 | + $this->_tpldata[$blockname][$i] = $this->_tpldata[$blockname][$i - 1]; |
|
626 | 626 | $this->_tpldata[$blockname][$i]['S_ROW_COUNT'] = $i; |
627 | 627 | } |
628 | 628 | |
@@ -656,10 +656,10 @@ discard block |
||
656 | 656 | { |
657 | 657 | $handle = $filename; |
658 | 658 | $this->filename[$handle] = $filename; |
659 | - $this->files[$handle] = $this->root . '/' . $filename; |
|
659 | + $this->files[$handle] = $this->root.'/'.$filename; |
|
660 | 660 | if ($this->inherit_root) |
661 | 661 | { |
662 | - $this->files_inherit[$handle] = $this->inherit_root . '/' . $filename; |
|
662 | + $this->files_inherit[$handle] = $this->inherit_root.'/'.$filename; |
|
663 | 663 | } |
664 | 664 | |
665 | 665 | $filename = $this->_tpl_load($handle); |
@@ -673,7 +673,7 @@ discard block |
||
673 | 673 | include($filename); |
674 | 674 | return; |
675 | 675 | } |
676 | - eval(' ?>' . $this->compiled_code[$handle] . '<?php '); |
|
676 | + eval(' ?>'.$this->compiled_code[$handle].'<?php '); |
|
677 | 677 | } |
678 | 678 | } |
679 | 679 | |
@@ -685,12 +685,12 @@ discard block |
||
685 | 685 | { |
686 | 686 | global $phpbb_root_path; |
687 | 687 | |
688 | - $file = $phpbb_root_path . $filename; |
|
688 | + $file = $phpbb_root_path.$filename; |
|
689 | 689 | |
690 | 690 | if (!file_exists($file)) |
691 | 691 | { |
692 | 692 | // trigger_error cannot be used here, as the output already started |
693 | - echo 'template->_php_include(): File ' . htmlspecialchars($file) . ' does not exist or is empty'; |
|
693 | + echo 'template->_php_include(): File '.htmlspecialchars($file).' does not exist or is empty'; |
|
694 | 694 | return; |
695 | 695 | } |
696 | 696 | include($file); |
@@ -702,13 +702,13 @@ discard block |
||
702 | 702 | */ |
703 | 703 | function assign_recursive($values, $name = '') |
704 | 704 | { |
705 | - if(isset($values['.'])) |
|
705 | + if (isset($values['.'])) |
|
706 | 706 | { |
707 | 707 | $values_extra = $values['.']; |
708 | 708 | unset($values['.']); |
709 | 709 | } |
710 | 710 | |
711 | - if(!$name) |
|
711 | + if (!$name) |
|
712 | 712 | { |
713 | 713 | $this->assign_vars($values); |
714 | 714 | } |
@@ -717,12 +717,12 @@ discard block |
||
717 | 717 | $this->assign_block_vars($name, $values); |
718 | 718 | } |
719 | 719 | |
720 | - if(isset($values_extra)) |
|
720 | + if (isset($values_extra)) |
|
721 | 721 | { |
722 | - foreach($values_extra as $sub_array_name => $sub_array) |
|
722 | + foreach ($values_extra as $sub_array_name => $sub_array) |
|
723 | 723 | { |
724 | - $new_name = $name . ($name ? '.' : '') . $sub_array_name; |
|
725 | - foreach($sub_array as $sub_element) |
|
724 | + $new_name = $name.($name ? '.' : '').$sub_array_name; |
|
725 | + foreach ($sub_array as $sub_element) |
|
726 | 726 | { |
727 | 727 | $this->assign_recursive($sub_element, $new_name); |
728 | 728 | } |
@@ -151,6 +151,9 @@ |
||
151 | 151 | } |
152 | 152 | |
153 | 153 | |
154 | + /** |
|
155 | + * @param integer $user_id |
|
156 | + */ |
|
154 | 157 | public function __construct($user_id) { |
155 | 158 | $this->user_change($user_id); |
156 | 159 | } |
@@ -122,31 +122,31 @@ discard block |
||
122 | 122 | |
123 | 123 | $update_cache = false; |
124 | 124 | |
125 | - if(!empty($this->to_write)) { |
|
126 | - foreach($this->to_write as $key => $cork) { |
|
125 | + if (!empty($this->to_write)) { |
|
126 | + foreach ($this->to_write as $key => $cork) { |
|
127 | 127 | $value = is_array($this->data[$key]) ? serialize($this->data[$key]) : $this->data[$key]; // Сериализация для массивов при сохранении в БД |
128 | - $this->to_write[$key] = "({$this->user_id}, '" . db_escape($key) . "', '" . db_escape($value) . "')"; |
|
128 | + $this->to_write[$key] = "({$this->user_id}, '".db_escape($key)."', '".db_escape($value)."')"; |
|
129 | 129 | } |
130 | 130 | |
131 | - doquery("REPLACE INTO {{player_options}} (`player_id`, `option_id`, `value`) VALUES " . implode(',', $this->to_write)); |
|
131 | + doquery("REPLACE INTO {{player_options}} (`player_id`, `option_id`, `value`) VALUES ".implode(',', $this->to_write)); |
|
132 | 132 | |
133 | 133 | $this->to_write = array(); |
134 | 134 | $update_cache = true; |
135 | 135 | } |
136 | 136 | |
137 | - if(!empty($this->to_delete)) { |
|
138 | - foreach($this->to_delete as $key => &$value) { |
|
139 | - $value = is_string($key) ? "'". db_escape($key) . "'" : $key; |
|
137 | + if (!empty($this->to_delete)) { |
|
138 | + foreach ($this->to_delete as $key => &$value) { |
|
139 | + $value = is_string($key) ? "'".db_escape($key)."'" : $key; |
|
140 | 140 | } |
141 | 141 | |
142 | - doquery("DELETE FROM {{player_options}} WHERE `player_id` = {$this->user_id} AND `option_id` IN (". implode(',', $this->to_delete) . ") "); |
|
142 | + doquery("DELETE FROM {{player_options}} WHERE `player_id` = {$this->user_id} AND `option_id` IN (".implode(',', $this->to_delete).") "); |
|
143 | 143 | // pdump("DELETE FROM {{player_options}} WHERE `player_id` = {$this->user_id} AND `option_id` IN (". implode(',', $this->to_delete) . ") "); |
144 | 144 | |
145 | 145 | $this->to_delete = array(); |
146 | 146 | $update_cache = true; |
147 | 147 | } |
148 | 148 | |
149 | - if($update_cache) { |
|
149 | + if ($update_cache) { |
|
150 | 150 | global $sn_cache; |
151 | 151 | |
152 | 152 | $field_name = $this->cached_name(); |
@@ -167,13 +167,13 @@ discard block |
||
167 | 167 | $this->load(); |
168 | 168 | } |
169 | 169 | protected function cached_name() { |
170 | - return 'options_' . $this->user_id; |
|
170 | + return 'options_'.$this->user_id; |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | protected function load() { |
174 | 174 | global $sn_cache; |
175 | 175 | |
176 | - if($this->loaded) { |
|
176 | + if ($this->loaded) { |
|
177 | 177 | return; |
178 | 178 | } |
179 | 179 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | $this->to_write = array(); |
182 | 182 | $this->to_delete = array(); |
183 | 183 | |
184 | - if(!$this->user_id) { |
|
184 | + if (!$this->user_id) { |
|
185 | 185 | $this->loaded = true; |
186 | 186 | return; |
187 | 187 | } |
@@ -189,13 +189,13 @@ discard block |
||
189 | 189 | $field_name = $this->cached_name(); |
190 | 190 | $a_data = $sn_cache->$field_name; |
191 | 191 | |
192 | - if(!empty($a_data)) { |
|
192 | + if (!empty($a_data)) { |
|
193 | 193 | $this->data = array_replace_recursive($this->data, $a_data); |
194 | 194 | return; |
195 | 195 | } |
196 | 196 | |
197 | 197 | $query = doquery("SELECT * FROM `{{player_options}}` WHERE `player_id` = {$this->user_id} FOR UPDATE"); |
198 | - while($row = db_fetch($query)) { |
|
198 | + while ($row = db_fetch($query)) { |
|
199 | 199 | // $this->data[$row['option_id']] = $row['value']; |
200 | 200 | $this->data[$row['option_id']] = is_string($row['value']) && ($temp = unserialize($row['value'])) !== false ? $temp : $row['value']; // Десериализация |
201 | 201 | } |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | } |
273 | 273 | |
274 | 274 | protected function cached_name() { |
275 | - return 'options_' . $this->user_id; |
|
275 | + return 'options_'.$this->user_id; |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | // TODO - serialize/unserialize options |
@@ -280,14 +280,14 @@ discard block |
||
280 | 280 | // Если в массиве индекса только один элемент - значит это просто индекс |
281 | 281 | is_array($option_id) && count($option_id) == 1 ? $option_id = reset($option_id) : false; |
282 | 282 | |
283 | - if(!isset($this->data[is_array($option_id) ? reset($option_id) : $option_id])) { |
|
283 | + if (!isset($this->data[is_array($option_id) ? reset($option_id) : $option_id])) { |
|
284 | 284 | $this->load(); |
285 | 285 | } |
286 | 286 | |
287 | - if(is_array($option_id)) { |
|
287 | + if (is_array($option_id)) { |
|
288 | 288 | $result = $this->data; |
289 | - foreach($option_id as $sub_key) { |
|
290 | - if(!isset($result) || !isset($result[$sub_key])) { |
|
289 | + foreach ($option_id as $sub_key) { |
|
290 | + if (!isset($result) || !isset($result[$sub_key])) { |
|
291 | 291 | $result = null; |
292 | 292 | break; |
293 | 293 | } |
@@ -307,12 +307,12 @@ discard block |
||
307 | 307 | public function __set($option, $value = null) { |
308 | 308 | global $sn_cache; |
309 | 309 | |
310 | - if(empty($option) || !$this->user_id) { |
|
310 | + if (empty($option) || !$this->user_id) { |
|
311 | 311 | return; |
312 | 312 | } |
313 | 313 | |
314 | 314 | // Если в массиве индекса только один элемент - значит это просто индекс |
315 | - if(is_array($option) && count($option) == 1) { |
|
315 | + if (is_array($option) && count($option) == 1) { |
|
316 | 316 | // Разворачиваем его в индекс |
317 | 317 | $option = array(reset($option) => $value); |
318 | 318 | unset($value); |
@@ -321,13 +321,13 @@ discard block |
||
321 | 321 | |
322 | 322 | $to_write = array(); |
323 | 323 | // Адресация многомерного массива через массив индексов в $option |
324 | - if(is_array($option) && isset($value)) { |
|
324 | + if (is_array($option) && isset($value)) { |
|
325 | 325 | $a_data = &$this->data; |
326 | - foreach($option as $option_id) { |
|
326 | + foreach ($option as $option_id) { |
|
327 | 327 | !is_array($a_data[$option_id]) ? $a_data[$option_id] = array() : false; |
328 | 328 | $a_data = &$a_data[$option_id]; |
329 | 329 | } |
330 | - if($a_data != $value) { |
|
330 | + if ($a_data != $value) { |
|
331 | 331 | $a_data = $value; |
332 | 332 | $to_write[reset($option)] = null; |
333 | 333 | } |
@@ -335,11 +335,11 @@ discard block |
||
335 | 335 | // Пакетная запись из массива ключ -> значение |
336 | 336 | !is_array($option) ? $option = array($option => $value) : false; |
337 | 337 | |
338 | - foreach($option as $option_id => $option_value) { |
|
339 | - if($this->data[$option_id] !== $option_value) { |
|
338 | + foreach ($option as $option_id => $option_value) { |
|
339 | + if ($this->data[$option_id] !== $option_value) { |
|
340 | 340 | // TODO - вынести отдельно в обработчик |
341 | - if($option_id == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON && $option_value == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON_HIDDEN) { |
|
342 | - sn_setcookie(SN_COOKIE . '_menu_hidden', '0', time() - PERIOD_WEEK, SN_ROOT_RELATIVE); |
|
341 | + if ($option_id == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON && $option_value == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON_HIDDEN) { |
|
342 | + sn_setcookie(SN_COOKIE.'_menu_hidden', '0', time() - PERIOD_WEEK, SN_ROOT_RELATIVE); |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | $this->data[$option_id] = $option_value; |
@@ -348,42 +348,42 @@ discard block |
||
348 | 348 | } |
349 | 349 | } |
350 | 350 | |
351 | - if(!empty($to_write)) { |
|
351 | + if (!empty($to_write)) { |
|
352 | 352 | $field_name = $this->cached_name(); |
353 | 353 | $sn_cache->$field_name = $this->data; |
354 | 354 | |
355 | - foreach($to_write as $option_id => &$option_value) { |
|
355 | + foreach ($to_write as $option_id => &$option_value) { |
|
356 | 356 | $option_value = is_array($this->data[$option_id]) ? serialize($this->data[$option_id]) : $this->data[$option_id]; // Сериализация для массивов при сохранении в БД |
357 | - $to_write[$option_id] = "({$this->user_id}, '" . db_escape($option_id) . "', '" . db_escape($option_value) . "')"; |
|
357 | + $to_write[$option_id] = "({$this->user_id}, '".db_escape($option_id)."', '".db_escape($option_value)."')"; |
|
358 | 358 | } |
359 | 359 | |
360 | - doquery("REPLACE INTO {{player_options}} (`player_id`, `option_id`, `value`) VALUES " . implode(',', $to_write)); |
|
360 | + doquery("REPLACE INTO {{player_options}} (`player_id`, `option_id`, `value`) VALUES ".implode(',', $to_write)); |
|
361 | 361 | } |
362 | 362 | } |
363 | 363 | |
364 | 364 | protected function load() { |
365 | 365 | global $sn_cache; |
366 | 366 | |
367 | - if($this->loaded) { |
|
367 | + if ($this->loaded) { |
|
368 | 368 | return; |
369 | 369 | } |
370 | 370 | |
371 | 371 | $this->data = $this->defaults; |
372 | 372 | |
373 | - if(!$this->user_id) { |
|
373 | + if (!$this->user_id) { |
|
374 | 374 | return; |
375 | 375 | } |
376 | 376 | |
377 | 377 | $field_name = $this->cached_name(); |
378 | 378 | $a_data = $sn_cache->$field_name; |
379 | 379 | |
380 | - if(!empty($a_data)) { |
|
380 | + if (!empty($a_data)) { |
|
381 | 381 | $this->data = array_replace($this->data, $a_data); |
382 | 382 | return; |
383 | 383 | } |
384 | 384 | |
385 | 385 | $query = doquery("SELECT * FROM `{{player_options}}` WHERE `player_id` = {$this->user_id} FOR UPDATE"); |
386 | - while($row = db_fetch($query)) { |
|
386 | + while ($row = db_fetch($query)) { |
|
387 | 387 | // $this->data[$row['option_id']] = $row['value']; |
388 | 388 | $this->data[$row['option_id']] = is_string($row['value']) && ($temp = unserialize($row['value'])) !== false ? $temp : $row['value']; // Десериализация |
389 | 389 | } |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | return $this->__get($offset); |
400 | 400 | } |
401 | 401 | public function offsetSet($offset, $value) { |
402 | - if(!is_null($offset)) { |
|
402 | + if (!is_null($offset)) { |
|
403 | 403 | // $this->data[$offset] = $value; |
404 | 404 | $this->__set($offset, $value); |
405 | 405 | } else { |
@@ -11,6 +11,9 @@ discard block |
||
11 | 11 | |
12 | 12 | require_once('db/db_queries.php'); |
13 | 13 | |
14 | +/** |
|
15 | + * @param string $tablename |
|
16 | + */ |
|
14 | 17 | function db_change_units_perform($query, $tablename, $object_id) { |
15 | 18 | $query = implode(',', $query); |
16 | 19 | if($query && $object_id) { |
@@ -63,6 +66,9 @@ discard block |
||
63 | 66 | db_change_units_perform($query[LOC_USER], 'users', $user['id']); |
64 | 67 | db_change_units_perform($query[LOC_PLANET], 'planets', $planet['id']); |
65 | 68 | } |
69 | +/** |
|
70 | + * @param string $table |
|
71 | + */ |
|
66 | 72 | function sn_db_perform($table, $values, $type = 'insert', $options = false) { |
67 | 73 | $mass_perform = false; |
68 | 74 | |
@@ -171,11 +177,8 @@ discard block |
||
171 | 177 | /** |
172 | 178 | * Функция проверяет статус транзакции |
173 | 179 | * |
174 | - * @param null|true|false $status Должна ли быть запущена транзакция в момент проверки |
|
175 | - * <p>null - транзакция НЕ должна быть запущена</p> |
|
176 | - * <p>true - транзакция должна быть запущена - для совместимости с $for_update</p> |
|
177 | - * <p>false - всё равно - для совместимости с $for_update</p> |
|
178 | - * @return bool Текущий статус транзакции |
|
180 | + * @param boolean $transaction_should_be_started |
|
181 | + * @return null|boolean Текущий статус транзакции |
|
179 | 182 | */ |
180 | 183 | function sn_db_transaction_check($transaction_should_be_started = null) { |
181 | 184 | return classSupernova::db_transaction_check($transaction_should_be_started); |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | function db_change_units_perform($query, $tablename, $object_id) { |
13 | 13 | $query = implode(',', $query); |
14 | - if($query && $object_id) { |
|
14 | + if ($query && $object_id) { |
|
15 | 15 | return classSupernova::db_upd_record_by_id($tablename == 'users' ? LOC_USER : LOC_PLANET, $object_id, $query); |
16 | 16 | // return doquery("UPDATE {{{$tablename}}} SET {$query} WHERE `id` = '{$object_id}' LIMIT 1;"); |
17 | 17 | } |
@@ -28,15 +28,15 @@ discard block |
||
28 | 28 | |
29 | 29 | $group = sn_get_groups('resources_loot'); |
30 | 30 | |
31 | - foreach($unit_list as $unit_id => $unit_amount) { |
|
32 | - if(!in_array($unit_id, $group)) { |
|
31 | + foreach ($unit_list as $unit_id => $unit_amount) { |
|
32 | + if (!in_array($unit_id, $group)) { |
|
33 | 33 | // TODO - remove later |
34 | 34 | print('<h1>СООБЩИТЕ ЭТО АДМИНУ: db_change_units() вызван для не-ресурсов!</h1>'); |
35 | 35 | pdump(debug_backtrace()); |
36 | 36 | die('db_change_units() вызван для не-ресурсов!'); |
37 | 37 | } |
38 | 38 | |
39 | - if(!$unit_amount) { |
|
39 | + if (!$unit_amount) { |
|
40 | 40 | continue; |
41 | 41 | } |
42 | 42 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | $unit_location = sys_get_unit_location($user, $planet, $unit_id); |
46 | 46 | |
47 | 47 | // Changing value in object |
48 | - switch($unit_location) { |
|
48 | + switch ($unit_location) { |
|
49 | 49 | case LOC_USER: |
50 | 50 | $user[$unit_db_name] += $unit_amount; |
51 | 51 | break; |
@@ -67,30 +67,30 @@ discard block |
||
67 | 67 | $field_set = ''; |
68 | 68 | $value_set = ''; |
69 | 69 | |
70 | - switch($type) { |
|
70 | + switch ($type) { |
|
71 | 71 | case 'delete': |
72 | 72 | $query = 'DELETE FROM'; |
73 | 73 | break; |
74 | 74 | |
75 | 75 | case 'insert': |
76 | 76 | $query = 'INSERT INTO'; |
77 | - if(isset($options['__multi'])) { |
|
77 | + if (isset($options['__multi'])) { |
|
78 | 78 | // Here we generate mass-insert set |
79 | 79 | break; |
80 | 80 | } |
81 | 81 | case 'update': |
82 | - if(!$query) { |
|
82 | + if (!$query) { |
|
83 | 83 | $query = 'UPDATE'; |
84 | 84 | } |
85 | 85 | |
86 | - foreach($values as $field => &$value) { |
|
86 | + foreach ($values as $field => &$value) { |
|
87 | 87 | $value_type = gettype($value); |
88 | 88 | if ($value_type == 'string') { |
89 | - $value = "'" . db_escape($value) . "'"; |
|
89 | + $value = "'".db_escape($value)."'"; |
|
90 | 90 | } |
91 | 91 | $value = "`{$field}` = {$value}"; |
92 | 92 | } |
93 | - $field_set = 'SET ' . implode(', ', $values); |
|
93 | + $field_set = 'SET '.implode(', ', $values); |
|
94 | 94 | break; |
95 | 95 | |
96 | 96 | }; |
@@ -111,12 +111,12 @@ discard block |
||
111 | 111 | $field_set['__IS_SAFE'] = true; |
112 | 112 | } |
113 | 113 | function sn_db_field_set_make_safe($field_set, $serialize = false) { |
114 | - if(!is_array($field_set)) { |
|
114 | + if (!is_array($field_set)) { |
|
115 | 115 | die('$field_set is not an array!'); |
116 | 116 | } |
117 | 117 | |
118 | 118 | $result = array(); |
119 | - foreach($field_set as $field => $value) { |
|
119 | + foreach ($field_set as $field => $value) { |
|
120 | 120 | $field = db_escape(trim($field)); |
121 | 121 | switch (true) { |
122 | 122 | case is_int($value): |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | $serialize ? $value = serialize($value) : die('$value is object or array with no $serialize'); |
133 | 133 | |
134 | 134 | case is_string($value): |
135 | - $value = '"' . db_escape($value) . '"'; |
|
135 | + $value = '"'.db_escape($value).'"'; |
|
136 | 136 | break; |
137 | 137 | |
138 | 138 | case is_null($value): |