@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | use Vector\Vector; |
8 | 8 | |
9 | 9 | function sys_user_vacation($user) { |
10 | - if(sys_get_param_str('vacation') == 'leave') { |
|
10 | + if (sys_get_param_str('vacation') == 'leave') { |
|
11 | 11 | if ($user['vacation'] < SN_TIME_NOW) { |
12 | 12 | $user['vacation'] = 0; |
13 | 13 | $user['vacation_next'] = SN_TIME_NOW + classSupernova::$config->player_vacation_timeout; |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | } |
16 | 16 | } |
17 | 17 | |
18 | - if($user['vacation']) { |
|
18 | + if ($user['vacation']) { |
|
19 | 19 | // sn_sys_logout(false, true); |
20 | 20 | // core_auth::logout(false, true); |
21 | 21 | |
@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | // TODO: Full rewrite |
46 | 46 | sn_db_transaction_start(); |
47 | 47 | $TheUser = DBStaticUser::db_user_by_id($UserID); |
48 | - if ( $TheUser['ally_id'] != 0 ) { |
|
49 | - $TheAlly = classSupernova::$db->doSelectFetch("SELECT * FROM `{{alliance}}` WHERE `id` = '" . $TheUser['ally_id'] . "';"); |
|
48 | + if ($TheUser['ally_id'] != 0) { |
|
49 | + $TheAlly = classSupernova::$db->doSelectFetch("SELECT * FROM `{{alliance}}` WHERE `id` = '".$TheUser['ally_id']."';"); |
|
50 | 50 | $TheAlly['ally_members'] -= 1; |
51 | - if ( $TheAlly['ally_members'] > 0 ) { |
|
52 | - classSupernova::$db->doUpdate( "UPDATE `{{alliance}}` SET `ally_members` = '" . $TheAlly['ally_members'] . "' WHERE `id` = '" . $TheAlly['id'] . "';"); |
|
51 | + if ($TheAlly['ally_members'] > 0) { |
|
52 | + classSupernova::$db->doUpdate("UPDATE `{{alliance}}` SET `ally_members` = '".$TheAlly['ally_members']."' WHERE `id` = '".$TheAlly['id']."';"); |
|
53 | 53 | } else { |
54 | 54 | classSupernova::$gc->db->doDeleteRowWhere(TABLE_ALLIANCE, array('id' => $TheAlly['id'],)); |
55 | 55 | classSupernova::$gc->db->doDeleteWhere(TABLE_STAT_POINTS, array('stat_type' => STAT_TYPE_ALLY, 'id_owner' => $TheAlly['id'],)); |
@@ -61,10 +61,10 @@ discard block |
||
61 | 61 | |
62 | 62 | classSupernova::$gc->db->doDeleteWhere(TABLE_MESSAGES, array('message_owner' => $UserID,)); |
63 | 63 | classSupernova::$gc->db->doDeleteWhere(TABLE_MESSAGES, array('message_sender' => $UserID,)); |
64 | - classSupernova::$gc->db->doDeleteWhere(TABLE_NOTES, array('owner' => $UserID ,)); |
|
64 | + classSupernova::$gc->db->doDeleteWhere(TABLE_NOTES, array('owner' => $UserID,)); |
|
65 | 65 | FleetList::db_fleet_list_delete_by_owner($UserID); |
66 | - classSupernova::$gc->db->doDeleteWhere(TABLE_BUDDY, array('BUDDY_SENDER_ID' => $UserID ,)); |
|
67 | - classSupernova::$gc->db->doDeleteWhere(TABLE_BUDDY, array('BUDDY_OWNER_ID' => $UserID ,)); |
|
66 | + classSupernova::$gc->db->doDeleteWhere(TABLE_BUDDY, array('BUDDY_SENDER_ID' => $UserID,)); |
|
67 | + classSupernova::$gc->db->doDeleteWhere(TABLE_BUDDY, array('BUDDY_OWNER_ID' => $UserID,)); |
|
68 | 68 | |
69 | 69 | |
70 | 70 | classSupernova::$gc->cacheOperator->db_del_record_by_id(LOC_USER, $UserID); |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | $ban_current = DBStaticUser::db_user_by_id($banned['id'], false, 'banaday'); |
86 | 86 | $ban_until = ($ban_current['banaday'] ? $ban_current['banaday'] : SN_TIME_NOW) + $term; |
87 | 87 | |
88 | - DBStaticUser::db_user_set_by_id($banned['id'], "`banaday` = {$ban_until} " . ($is_vacation ? ", `vacation` = '{$ban_until}' " : '')); |
|
88 | + DBStaticUser::db_user_set_by_id($banned['id'], "`banaday` = {$ban_until} ".($is_vacation ? ", `vacation` = '{$ban_until}' " : '')); |
|
89 | 89 | |
90 | 90 | $banned['username'] = db_escape($banned['username']); |
91 | 91 | $banner['username'] = db_escape($banner['username']); |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * @param string $reason |
104 | 104 | */ |
105 | 105 | function sys_admin_player_ban_unset($banner, $banned, $reason = '') { |
106 | - DBStaticUser::db_user_set_by_id($banned['id'], "`banaday` = 0, `vacation` = " . SN_TIME_NOW . ""); |
|
106 | + DBStaticUser::db_user_set_by_id($banned['id'], "`banaday` = 0, `vacation` = ".SN_TIME_NOW.""); |
|
107 | 107 | |
108 | 108 | $banned['username'] = db_escape($banned['username']); |
109 | 109 | $banner['username'] = db_escape($banner['username']); |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | |
133 | 133 | 'total_points' => $options['total_points'] = empty($options['total_points']) ? 0 : $options['total_points'], |
134 | 134 | |
135 | - 'options' => (empty($options['options']) ? $player_options_string : $options['options']) . (empty($options['options_extra']) ? '' : $options['options_extra']), |
|
135 | + 'options' => (empty($options['options']) ? $player_options_string : $options['options']).(empty($options['options_extra']) ? '' : $options['options_extra']), |
|
136 | 136 | |
137 | 137 | 'galaxy' => $options['galaxy'] = intval($options['galaxy'] ? $options['galaxy'] : 0), |
138 | 138 | 'system' => $options['system'] = intval($options['system'] ? $options['system'] : 0), |
@@ -143,28 +143,28 @@ discard block |
||
143 | 143 | !empty($options['password_encoded_unsafe']) ? $field_set['password'] = $options['password_encoded_unsafe'] : false; |
144 | 144 | |
145 | 145 | $user_new = classSupernova::$gc->cacheOperator->db_ins_field_set(LOC_USER, $field_set); |
146 | - if(!($options['galaxy'] && $options['system'] && $options['planet'])) { |
|
146 | + if (!($options['galaxy'] && $options['system'] && $options['planet'])) { |
|
147 | 147 | $options['galaxy'] = classSupernova::$config->LastSettedGalaxyPos; |
148 | 148 | $options['system'] = classSupernova::$config->LastSettedSystemPos; |
149 | - $segment_size = floor(Vector::$knownPlanets/ 3); |
|
149 | + $segment_size = floor(Vector::$knownPlanets / 3); |
|
150 | 150 | $segment = floor(classSupernova::$config->LastSettedPlanetPos / $segment_size); |
151 | 151 | $segment++; |
152 | 152 | $options['planet'] = mt_rand(1 + $segment * $segment_size, ($segment + 1) * $segment_size); |
153 | 153 | |
154 | 154 | // $new_planet_id = 0; |
155 | - while(true) { |
|
156 | - if($options['planet'] > Vector::$knownPlanets) { |
|
155 | + while (true) { |
|
156 | + if ($options['planet'] > Vector::$knownPlanets) { |
|
157 | 157 | $options['planet'] = mt_rand(0, $segment_size - 1) + 1; |
158 | 158 | $options['system']++; |
159 | 159 | } |
160 | - if($options['system'] > Vector::$knownSystems) { |
|
160 | + if ($options['system'] > Vector::$knownSystems) { |
|
161 | 161 | $options['system'] = 1; |
162 | 162 | $options['galaxy']++; |
163 | 163 | } |
164 | - $options['galaxy'] > Vector::$knownGalaxies? $options['galaxy'] = 1 : false; |
|
164 | + $options['galaxy'] > Vector::$knownGalaxies ? $options['galaxy'] = 1 : false; |
|
165 | 165 | |
166 | 166 | $galaxy_row = DBStaticPlanet::db_planet_by_gspt($options['galaxy'], $options['system'], $options['planet'], PT_PLANET, true, 'id'); |
167 | - if(!$galaxy_row['id']) { |
|
167 | + if (!$galaxy_row['id']) { |
|
168 | 168 | classSupernova::$config->db_saveItem(array( |
169 | 169 | 'LastSettedGalaxyPos' => $options['galaxy'], |
170 | 170 | 'LastSettedSystemPos' => $options['system'], |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | |
187 | 187 | db_player_name_history_replace($user_new['id'], $username_unsafe); |
188 | 188 | |
189 | - if(!empty($options['partner_id']) && ($referral_row = DBStaticUser::db_user_by_id($options['partner_id'], true))) { |
|
189 | + if (!empty($options['partner_id']) && ($referral_row = DBStaticUser::db_user_by_id($options['partner_id'], true))) { |
|
190 | 190 | db_referral_insert($options, $user_new); |
191 | 191 | } |
192 | 192 |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | public function load_db_settings($configFile = '') { |
90 | 90 | $dbsettings = array(); |
91 | 91 | |
92 | - empty($configFile) ? $configFile = SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX : false; |
|
92 | + empty($configFile) ? $configFile = SN_ROOT_PHYSICAL."config".DOT_PHP_EX : false; |
|
93 | 93 | |
94 | 94 | require $configFile; |
95 | 95 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | } |
110 | 110 | |
111 | 111 | if (empty($this->dbsettings)) { |
112 | - $this->load_db_settings(SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX); |
|
112 | + $this->load_db_settings(SN_ROOT_PHYSICAL."config".DOT_PHP_EX); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | // TODO - фатальные (?) ошибки на каждом шагу. Хотя - скорее Эксепшны |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | $sql = $query; |
162 | 162 | if (strpos($sql, '{{') !== false) { |
163 | 163 | foreach ($this->table_list as $tableName) { |
164 | - $sql = str_replace("{{{$tableName}}}", $this->db_prefix . $tableName, $sql); |
|
164 | + $sql = str_replace("{{{$tableName}}}", $this->db_prefix.$tableName, $sql); |
|
165 | 165 | } |
166 | 166 | } |
167 | 167 | |
@@ -234,12 +234,12 @@ discard block |
||
234 | 234 | |
235 | 235 | $queryResult = null; |
236 | 236 | try { |
237 | - $queryResult = $this->db_sql_query($stringQuery . DbSqlHelper::quoteComment($queryTrace)); |
|
237 | + $queryResult = $this->db_sql_query($stringQuery.DbSqlHelper::quoteComment($queryTrace)); |
|
238 | 238 | if (!$queryResult) { |
239 | 239 | throw new Exception(); |
240 | 240 | } |
241 | 241 | } catch (Exception $e) { |
242 | - classSupernova::$debug->error($this->db_error() . "<br />{$query}<br />", 'SQL Error'); |
|
242 | + classSupernova::$debug->error($this->db_error()."<br />{$query}<br />", 'SQL Error'); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | return $queryResult; |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | case TYPE_EMPTY: |
463 | 463 | // No-type defaults to string |
464 | 464 | default: |
465 | - $value = "'" . $this->db_escape((string)$value) . "'"; |
|
465 | + $value = "'".$this->db_escape((string) $value)."'"; |
|
466 | 466 | break; |
467 | 467 | } |
468 | 468 | |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | if (is_int($fieldName)) { |
491 | 491 | $result[$fieldName] = $fieldValue; |
492 | 492 | } else { |
493 | - $result[$fieldName] = "`{$fieldName}` = " . $this->castAsDbValue($fieldValue); |
|
493 | + $result[$fieldName] = "`{$fieldName}` = ".$this->castAsDbValue($fieldValue); |
|
494 | 494 | } |
495 | 495 | } |
496 | 496 | |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | } |
522 | 522 | |
523 | 523 | foreach ($fields as $key => $value) { |
524 | - $result[$key] = "`" . $this->db_escape($value) . "`"; |
|
524 | + $result[$key] = "`".$this->db_escape($value)."`"; |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | return $result; |
@@ -577,10 +577,10 @@ discard block |
||
577 | 577 | $this->isWatching = true; |
578 | 578 | $msg = "\$query = \"{$query}\"\n\r"; |
579 | 579 | if (!empty($_POST)) { |
580 | - $msg .= "\n\r" . dump($_POST, '$_POST'); |
|
580 | + $msg .= "\n\r".dump($_POST, '$_POST'); |
|
581 | 581 | } |
582 | 582 | if (!empty($_GET)) { |
583 | - $msg .= "\n\r" . dump($_GET, '$_GET'); |
|
583 | + $msg .= "\n\r".dump($_GET, '$_GET'); |
|
584 | 584 | } |
585 | 585 | classSupernova::$debug->warning($msg, "Watching user {$user['id']}", 399, array('base_dump' => true)); |
586 | 586 | $this->isWatching = false; |
@@ -606,37 +606,37 @@ discard block |
||
606 | 606 | case stripos($query, 'RPG_POINTS') != false && stripos(trim($query), 'UPDATE ') === 0 && !$dm_change_legit: |
607 | 607 | case stripos($query, 'METAMATTER') != false && stripos(trim($query), 'UPDATE ') === 0 && !$mm_change_legit: |
608 | 608 | case stripos($query, 'AUTHLEVEL') != false && $user['authlevel'] < 3 && stripos($query, 'SELECT') !== 0: |
609 | - $report = "Hacking attempt (" . date("d.m.Y H:i:s") . " - [" . time() . "]):\n"; |
|
609 | + $report = "Hacking attempt (".date("d.m.Y H:i:s")." - [".time()."]):\n"; |
|
610 | 610 | $report .= ">Database Inforamation\n"; |
611 | - $report .= "\tID - " . $user['id'] . "\n"; |
|
612 | - $report .= "\tUser - " . $user['username'] . "\n"; |
|
613 | - $report .= "\tAuth level - " . $user['authlevel'] . "\n"; |
|
614 | - $report .= "\tAdmin Notes - " . $user['adminNotes'] . "\n"; |
|
615 | - $report .= "\tCurrent Planet - " . $user['current_planet'] . "\n"; |
|
616 | - $report .= "\tUser IP - " . $user['user_lastip'] . "\n"; |
|
617 | - $report .= "\tUser IP at Reg - " . $user['ip_at_reg'] . "\n"; |
|
618 | - $report .= "\tUser Agent- " . $_SERVER['HTTP_USER_AGENT'] . "\n"; |
|
619 | - $report .= "\tCurrent Page - " . $user['current_page'] . "\n"; |
|
620 | - $report .= "\tRegister Time - " . $user['register_time'] . "\n"; |
|
611 | + $report .= "\tID - ".$user['id']."\n"; |
|
612 | + $report .= "\tUser - ".$user['username']."\n"; |
|
613 | + $report .= "\tAuth level - ".$user['authlevel']."\n"; |
|
614 | + $report .= "\tAdmin Notes - ".$user['adminNotes']."\n"; |
|
615 | + $report .= "\tCurrent Planet - ".$user['current_planet']."\n"; |
|
616 | + $report .= "\tUser IP - ".$user['user_lastip']."\n"; |
|
617 | + $report .= "\tUser IP at Reg - ".$user['ip_at_reg']."\n"; |
|
618 | + $report .= "\tUser Agent- ".$_SERVER['HTTP_USER_AGENT']."\n"; |
|
619 | + $report .= "\tCurrent Page - ".$user['current_page']."\n"; |
|
620 | + $report .= "\tRegister Time - ".$user['register_time']."\n"; |
|
621 | 621 | $report .= "\n"; |
622 | 622 | |
623 | 623 | $report .= ">Query Information\n"; |
624 | - $report .= "\tQuery - " . $query . "\n"; |
|
624 | + $report .= "\tQuery - ".$query."\n"; |
|
625 | 625 | $report .= "\n"; |
626 | 626 | |
627 | 627 | $report .= ">\$_SERVER Information\n"; |
628 | - $report .= "\tIP - " . $_SERVER['REMOTE_ADDR'] . "\n"; |
|
629 | - $report .= "\tHost Name - " . $_SERVER['HTTP_HOST'] . "\n"; |
|
630 | - $report .= "\tUser Agent - " . $_SERVER['HTTP_USER_AGENT'] . "\n"; |
|
631 | - $report .= "\tRequest Method - " . $_SERVER['REQUEST_METHOD'] . "\n"; |
|
632 | - $report .= "\tCame From - " . $_SERVER['HTTP_REFERER'] . "\n"; |
|
633 | - $report .= "\tPage is - " . $_SERVER['SCRIPT_NAME'] . "\n"; |
|
634 | - $report .= "\tUses Port - " . $_SERVER['REMOTE_PORT'] . "\n"; |
|
635 | - $report .= "\tServer Protocol - " . $_SERVER['SERVER_PROTOCOL'] . "\n"; |
|
628 | + $report .= "\tIP - ".$_SERVER['REMOTE_ADDR']."\n"; |
|
629 | + $report .= "\tHost Name - ".$_SERVER['HTTP_HOST']."\n"; |
|
630 | + $report .= "\tUser Agent - ".$_SERVER['HTTP_USER_AGENT']."\n"; |
|
631 | + $report .= "\tRequest Method - ".$_SERVER['REQUEST_METHOD']."\n"; |
|
632 | + $report .= "\tCame From - ".$_SERVER['HTTP_REFERER']."\n"; |
|
633 | + $report .= "\tPage is - ".$_SERVER['SCRIPT_NAME']."\n"; |
|
634 | + $report .= "\tUses Port - ".$_SERVER['REMOTE_PORT']."\n"; |
|
635 | + $report .= "\tServer Protocol - ".$_SERVER['SERVER_PROTOCOL']."\n"; |
|
636 | 636 | |
637 | 637 | $report .= "\n--------------------------------------------------------------------------------------------------\n"; |
638 | 638 | |
639 | - $fp = fopen(SN_ROOT_PHYSICAL . 'badqrys.txt', 'a'); |
|
639 | + $fp = fopen(SN_ROOT_PHYSICAL.'badqrys.txt', 'a'); |
|
640 | 640 | fwrite($fp, $report); |
641 | 641 | fclose($fp); |
642 | 642 |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | $owners = array(); |
115 | 115 | } else { |
116 | 116 | $insert_values = array(); |
117 | - $insert_template = "('%u'," . str_replace('%', '%%', " '{$sender}', '{$timestamp}', '{$message_type}', '{$from}', '{$subject}', '{$text}')"); |
|
117 | + $insert_template = "('%u',".str_replace('%', '%%', " '{$sender}', '{$timestamp}', '{$message_type}', '{$from}', '{$subject}', '{$text}')"); |
|
118 | 118 | |
119 | 119 | foreach ($owners as $owner) { |
120 | 120 | if ($user['id'] != $owner) { |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | $sendList = array(); |
156 | 156 | $list = ''; |
157 | 157 | $query = DBStaticUser::db_user_list( |
158 | - "ally_id = '{$ally_id}'" . ($ally_rank_id >= 0 ? " AND ally_rank_id = {$ally_rank_id}" : ''), |
|
158 | + "ally_id = '{$ally_id}'".($ally_rank_id >= 0 ? " AND ally_rank_id = {$ally_rank_id}" : ''), |
|
159 | 159 | false, 'id, username'); |
160 | 160 | foreach ($query as $u) { |
161 | 161 | $sendList[] = $u['id']; |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | $subject_unsafe = substr($subject_unsafe, strlen(classLocale::$lang['msg_answer_prefix'])); |
254 | 254 | $re++; |
255 | 255 | } |
256 | - $re ? $subject_unsafe = classLocale::$lang['msg_answer_prefix'] . $subject_unsafe : false; |
|
256 | + $re ? $subject_unsafe = classLocale::$lang['msg_answer_prefix'].$subject_unsafe : false; |
|
257 | 257 | |
258 | 258 | $subject_unsafe = $subject_unsafe ? $subject_unsafe : classLocale::$lang['msg_subject_default']; |
259 | 259 | |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | return classSupernova::$db->doSelect( |
422 | 422 | "SELECT * FROM {{messages}} |
423 | 423 | WHERE |
424 | - `message_type` = '" . MSG_TYPE_PLAYER . "' AND |
|
424 | + `message_type` = '" . MSG_TYPE_PLAYER."' AND |
|
425 | 425 | ((`message_owner` = '{$user['id']}' AND `message_sender` = '{$recipient_id}') |
426 | 426 | OR |
427 | 427 | (`message_sender` = '{$user['id']}' AND `message_owner` = '{$recipient_id}')) ORDER BY `message_time` DESC LIMIT 20;"); |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | FROM |
466 | 466 | {{messages}} AS m |
467 | 467 | LEFT JOIN {{users}} AS u ON u.id = m.message_owner " . |
468 | - ($int_type_selected >= 0 ? "WHERE `message_type` = {$int_type_selected} " : '') . |
|
468 | + ($int_type_selected >= 0 ? "WHERE `message_type` = {$int_type_selected} " : ''). |
|
469 | 469 | "ORDER BY |
470 | 470 | `message_id` DESC |
471 | 471 | LIMIT |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | } |
474 | 474 | |
475 | 475 | public static function db_message_insert_all($message_type, $from, $subject, $text) { |
476 | - return classSupernova::$db->doInsert('INSERT INTO {{messages}} (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) ' . |
|
476 | + return classSupernova::$db->doInsert('INSERT INTO {{messages}} (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) '. |
|
477 | 477 | "SELECT `id`, 0, unix_timestamp(now()), {$message_type}, '{$from}', '{$subject}', '{$text}' FROM {{users}}"); |
478 | 478 | } |
479 | 479 | |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | * @return array|bool|mysqli_result|null |
484 | 484 | */ |
485 | 485 | public static function db_message_count_by_type($int_type_selected) { |
486 | - $page_max = classSupernova::$db->doSelectFetch('SELECT COUNT(*) AS `max` FROM `{{messages}}`' . ($int_type_selected >= 0 ? " WHERE `message_type` = {$int_type_selected};" : '')); |
|
486 | + $page_max = classSupernova::$db->doSelectFetch('SELECT COUNT(*) AS `max` FROM `{{messages}}`'.($int_type_selected >= 0 ? " WHERE `message_type` = {$int_type_selected};" : '')); |
|
487 | 487 | |
488 | 488 | return $page_max; |
489 | 489 | } |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | */ |
508 | 508 | public static function db_message_list_delete_by_date($delete_date, $int_type_selected) { |
509 | 509 | $where[] = "message_time <= UNIX_TIMESTAMP('{$delete_date}')"; |
510 | - if($int_type_selected >= 0) { |
|
510 | + if ($int_type_selected >= 0) { |
|
511 | 511 | $where['message_type'] = $int_type_selected; |
512 | 512 | } |
513 | 513 | classSupernova::$db->doDeleteDeprecated(TABLE_MESSAGES, $where); |
@@ -517,8 +517,8 @@ discard block |
||
517 | 517 | * @param $insert_values |
518 | 518 | */ |
519 | 519 | public static function db_message_insert($insert_values) { |
520 | - classSupernova::$db->doInsert('INSERT INTO `{{messages}}` (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) ' . |
|
521 | - 'VALUES ' . implode(',', $insert_values)); |
|
520 | + classSupernova::$db->doInsert('INSERT INTO `{{messages}}` (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) '. |
|
521 | + 'VALUES '.implode(',', $insert_values)); |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | } |
@@ -122,10 +122,10 @@ 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 | 131 | classSupernova::$gc->db->doReplaceValuesDeprecated( |
@@ -143,21 +143,21 @@ discard block |
||
143 | 143 | $update_cache = true; |
144 | 144 | } |
145 | 145 | |
146 | - if(!empty($this->to_delete)) { |
|
147 | - foreach($this->to_delete as $key => &$value) { |
|
148 | - $value = is_string($key) ? "'". db_escape($key) . "'" : $key; |
|
146 | + if (!empty($this->to_delete)) { |
|
147 | + foreach ($this->to_delete as $key => &$value) { |
|
148 | + $value = is_string($key) ? "'".db_escape($key)."'" : $key; |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | classSupernova::$db->doDeleteDeprecated(TABLE_PLAYER_OPTIONS, array( |
152 | 152 | 'player_id' => $this->user_id, |
153 | - "`option_id` IN (". implode(',', $this->to_delete) . ")", |
|
153 | + "`option_id` IN (".implode(',', $this->to_delete).")", |
|
154 | 154 | )); |
155 | 155 | |
156 | 156 | $this->to_delete = array(); |
157 | 157 | $update_cache = true; |
158 | 158 | } |
159 | 159 | |
160 | - if($update_cache) { |
|
160 | + if ($update_cache) { |
|
161 | 161 | $field_name = $this->cached_name(); |
162 | 162 | classSupernova::$cache->$field_name = $this->data; |
163 | 163 | } |
@@ -176,11 +176,11 @@ discard block |
||
176 | 176 | $this->load(); |
177 | 177 | } |
178 | 178 | protected function cached_name() { |
179 | - return 'options_' . $this->user_id; |
|
179 | + return 'options_'.$this->user_id; |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | protected function load() { |
183 | - if($this->loaded) { |
|
183 | + if ($this->loaded) { |
|
184 | 184 | return; |
185 | 185 | } |
186 | 186 | |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | $this->to_write = array(); |
189 | 189 | $this->to_delete = array(); |
190 | 190 | |
191 | - if(!$this->user_id) { |
|
191 | + if (!$this->user_id) { |
|
192 | 192 | $this->loaded = true; |
193 | 193 | return; |
194 | 194 | } |
@@ -196,13 +196,13 @@ discard block |
||
196 | 196 | $field_name = $this->cached_name(); |
197 | 197 | $a_data = classSupernova::$cache->$field_name; |
198 | 198 | |
199 | - if(!empty($a_data)) { |
|
199 | + if (!empty($a_data)) { |
|
200 | 200 | $this->data = array_replace_recursive($this->data, $a_data); |
201 | 201 | return; |
202 | 202 | } |
203 | 203 | |
204 | 204 | $query = classSupernova::$db->doSelect("SELECT * FROM `{{player_options}}` WHERE `player_id` = {$this->user_id} FOR UPDATE"); |
205 | - while($row = db_fetch($query)) { |
|
205 | + while ($row = db_fetch($query)) { |
|
206 | 206 | // $this->data[$row['option_id']] = $row['value']; |
207 | 207 | $this->data[$row['option_id']] = is_string($row['value']) && ($temp = unserialize($row['value'])) !== false ? $temp : $row['value']; // Десериализация |
208 | 208 | } |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | } |
280 | 280 | |
281 | 281 | protected function cached_name() { |
282 | - return 'options_' . $this->user_id; |
|
282 | + return 'options_'.$this->user_id; |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | // TODO - serialize/unserialize options |
@@ -287,14 +287,14 @@ discard block |
||
287 | 287 | // Если в массиве индекса только один элемент - значит это просто индекс |
288 | 288 | is_array($option_id) && count($option_id) == 1 ? $option_id = reset($option_id) : false; |
289 | 289 | |
290 | - if(!isset($this->data[is_array($option_id) ? reset($option_id) : $option_id])) { |
|
290 | + if (!isset($this->data[is_array($option_id) ? reset($option_id) : $option_id])) { |
|
291 | 291 | $this->load(); |
292 | 292 | } |
293 | 293 | |
294 | - if(is_array($option_id)) { |
|
294 | + if (is_array($option_id)) { |
|
295 | 295 | $result = $this->data; |
296 | - foreach($option_id as $sub_key) { |
|
297 | - if(!isset($result) || !isset($result[$sub_key])) { |
|
296 | + foreach ($option_id as $sub_key) { |
|
297 | + if (!isset($result) || !isset($result[$sub_key])) { |
|
298 | 298 | $result = null; |
299 | 299 | break; |
300 | 300 | } |
@@ -312,12 +312,12 @@ discard block |
||
312 | 312 | * @param null|mixed $value |
313 | 313 | */ |
314 | 314 | public function __set($option, $value = null) { |
315 | - if(empty($option) || !$this->user_id) { |
|
315 | + if (empty($option) || !$this->user_id) { |
|
316 | 316 | return; |
317 | 317 | } |
318 | 318 | |
319 | 319 | // Если в массиве индекса только один элемент - значит это просто индекс |
320 | - if(is_array($option) && count($option) == 1) { |
|
320 | + if (is_array($option) && count($option) == 1) { |
|
321 | 321 | // Разворачиваем его в индекс |
322 | 322 | $option = array(reset($option) => $value); |
323 | 323 | unset($value); |
@@ -326,13 +326,13 @@ discard block |
||
326 | 326 | |
327 | 327 | $to_write = array(); |
328 | 328 | // Адресация многомерного массива через массив индексов в $option |
329 | - if(is_array($option) && isset($value)) { |
|
329 | + if (is_array($option) && isset($value)) { |
|
330 | 330 | $a_data = &$this->data; |
331 | - foreach($option as $option_id) { |
|
331 | + foreach ($option as $option_id) { |
|
332 | 332 | !is_array($a_data[$option_id]) ? $a_data[$option_id] = array() : false; |
333 | 333 | $a_data = &$a_data[$option_id]; |
334 | 334 | } |
335 | - if($a_data != $value) { |
|
335 | + if ($a_data != $value) { |
|
336 | 336 | $a_data = $value; |
337 | 337 | $to_write[reset($option)] = null; |
338 | 338 | } |
@@ -340,11 +340,11 @@ discard block |
||
340 | 340 | // Пакетная запись из массива ключ -> значение |
341 | 341 | !is_array($option) ? $option = array($option => $value) : false; |
342 | 342 | |
343 | - foreach($option as $option_id => $option_value) { |
|
344 | - if($this->data[$option_id] !== $option_value) { |
|
343 | + foreach ($option as $option_id => $option_value) { |
|
344 | + if ($this->data[$option_id] !== $option_value) { |
|
345 | 345 | // TODO - вынести отдельно в обработчик |
346 | - if($option_id == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON && $option_value == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON_HIDDEN) { |
|
347 | - sn_setcookie(SN_COOKIE . '_menu_hidden', '0', time() - PERIOD_WEEK, SN_ROOT_RELATIVE); |
|
346 | + if ($option_id == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON && $option_value == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON_HIDDEN) { |
|
347 | + sn_setcookie(SN_COOKIE.'_menu_hidden', '0', time() - PERIOD_WEEK, SN_ROOT_RELATIVE); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | $this->data[$option_id] = $option_value; |
@@ -353,13 +353,13 @@ discard block |
||
353 | 353 | } |
354 | 354 | } |
355 | 355 | |
356 | - if(!empty($to_write)) { |
|
356 | + if (!empty($to_write)) { |
|
357 | 357 | $field_name = $this->cached_name(); |
358 | 358 | classSupernova::$cache->$field_name = $this->data; |
359 | 359 | |
360 | - foreach($to_write as $option_id => &$option_value) { |
|
360 | + foreach ($to_write as $option_id => &$option_value) { |
|
361 | 361 | $option_value = is_array($this->data[$option_id]) ? serialize($this->data[$option_id]) : $this->data[$option_id]; // Сериализация для массивов при сохранении в БД |
362 | - $to_write[$option_id] = "({$this->user_id}, '" . db_escape($option_id) . "', '" . db_escape($option_value) . "')"; |
|
362 | + $to_write[$option_id] = "({$this->user_id}, '".db_escape($option_id)."', '".db_escape($option_value)."')"; |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | classSupernova::$gc->db->doReplaceValuesDeprecated( |
@@ -375,26 +375,26 @@ discard block |
||
375 | 375 | } |
376 | 376 | |
377 | 377 | protected function load() { |
378 | - if($this->loaded) { |
|
378 | + if ($this->loaded) { |
|
379 | 379 | return; |
380 | 380 | } |
381 | 381 | |
382 | 382 | $this->data = $this->defaults; |
383 | 383 | |
384 | - if(!$this->user_id) { |
|
384 | + if (!$this->user_id) { |
|
385 | 385 | return; |
386 | 386 | } |
387 | 387 | |
388 | 388 | $field_name = $this->cached_name(); |
389 | 389 | $a_data = classSupernova::$cache->$field_name; |
390 | 390 | |
391 | - if(!empty($a_data)) { |
|
391 | + if (!empty($a_data)) { |
|
392 | 392 | $this->data = array_replace($this->data, $a_data); |
393 | 393 | return; |
394 | 394 | } |
395 | 395 | |
396 | 396 | $query = classSupernova::$db->doSelect("SELECT * FROM `{{player_options}}` WHERE `player_id` = {$this->user_id} FOR UPDATE"); |
397 | - while($row = db_fetch($query)) { |
|
397 | + while ($row = db_fetch($query)) { |
|
398 | 398 | // $this->data[$row['option_id']] = $row['value']; |
399 | 399 | $this->data[$row['option_id']] = is_string($row['value']) && ($temp = unserialize($row['value'])) !== false ? $temp : $row['value']; // Десериализация |
400 | 400 | } |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | return $this->__get($offset); |
411 | 411 | } |
412 | 412 | public function offsetSet($offset, $value) { |
413 | - if(!is_null($offset)) { |
|
413 | + if (!is_null($offset)) { |
|
414 | 414 | // $this->data[$offset] = $value; |
415 | 415 | $this->__set($offset, $value); |
416 | 416 | } else { |
@@ -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; |
@@ -134,23 +134,23 @@ discard block |
||
134 | 134 | |
135 | 135 | |
136 | 136 | public function usage_stat_load() { |
137 | - $this->stat_usage = classSupernova::$cache->lng_stat_usage = array(); // TODO for debug |
|
138 | - if(empty($this->stat_usage)) { |
|
137 | + $this->stat_usage = classSupernova::$cache->lng_stat_usage = array(); // TODO for debug |
|
138 | + if (empty($this->stat_usage)) { |
|
139 | 139 | $query = classSupernova::$db->doSelect("SELECT * FROM `{{lng_usage_stat}}`"); |
140 | - while($row = db_fetch($query)) { |
|
141 | - $this->stat_usage[$row['lang_code'] . ':' . $row['string_id'] . ':' . $row['file'] . ':' . $row['line']] = $row['is_empty']; |
|
140 | + while ($row = db_fetch($query)) { |
|
141 | + $this->stat_usage[$row['lang_code'].':'.$row['string_id'].':'.$row['file'].':'.$row['line']] = $row['is_empty']; |
|
142 | 142 | } |
143 | 143 | } |
144 | 144 | } |
145 | 145 | public function usage_stat_save() { |
146 | - if(!empty($this->stat_usage_new)) { |
|
146 | + if (!empty($this->stat_usage_new)) { |
|
147 | 147 | classSupernova::$cache->lng_stat_usage = $this->stat_usage; |
148 | 148 | classSupernova::$db->doSelect("SELECT 1 FROM `{{lng_usage_stat}}` LIMIT 1"); |
149 | - foreach($this->stat_usage_new as &$value) { |
|
150 | - foreach($value as &$value2) { |
|
151 | - $value2 = '"' . db_escape($value2) . '"'; |
|
149 | + foreach ($this->stat_usage_new as &$value) { |
|
150 | + foreach ($value as &$value2) { |
|
151 | + $value2 = '"'.db_escape($value2).'"'; |
|
152 | 152 | } |
153 | - $value = '(' . implode(',', $value) .')'; |
|
153 | + $value = '('.implode(',', $value).')'; |
|
154 | 154 | } |
155 | 155 | classSupernova::$gc->db->doReplaceValuesDeprecated( |
156 | 156 | 'lng_usage_stat', |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | |
174 | 174 | $file = str_replace('\\', '/', substr($trace[1]['file'], strlen(SN_ROOT_PHYSICAL) - 1)); |
175 | 175 | |
176 | - $string_id = $this->active . ':' . $offset . ':' . $file . ':' . $trace[1]['line']; |
|
177 | - if(!isset($this->stat_usage[$string_id]) || $this->stat_usage[$string_id] != empty($value)) { |
|
176 | + $string_id = $this->active.':'.$offset.':'.$file.':'.$trace[1]['line']; |
|
177 | + if (!isset($this->stat_usage[$string_id]) || $this->stat_usage[$string_id] != empty($value)) { |
|
178 | 178 | $this->stat_usage[$string_id] = empty($value); |
179 | 179 | $this->stat_usage_new[] = array( |
180 | 180 | 'lang_code' => $this->active, |
@@ -182,14 +182,14 @@ discard block |
||
182 | 182 | 'file' => $file, |
183 | 183 | 'line' => $trace[1]['line'], |
184 | 184 | 'is_empty' => intval(empty($value)), |
185 | - 'locale' => '' . $value, |
|
185 | + 'locale' => ''.$value, |
|
186 | 186 | ); |
187 | 187 | } |
188 | 188 | } |
189 | 189 | |
190 | 190 | |
191 | 191 | protected function lng_try_filepath($path, $file_path_relative) { |
192 | - $file_path = SN_ROOT_PHYSICAL . ($path && file_exists(SN_ROOT_PHYSICAL . $path . $file_path_relative) ? $path : '') . $file_path_relative; |
|
192 | + $file_path = SN_ROOT_PHYSICAL.($path && file_exists(SN_ROOT_PHYSICAL.$path.$file_path_relative) ? $path : '').$file_path_relative; |
|
193 | 193 | return file_exists($file_path) ? $file_path : false; |
194 | 194 | } |
195 | 195 | |
@@ -211,14 +211,14 @@ discard block |
||
211 | 211 | |
212 | 212 | classSupernova::log_file("locale.include: Loading data from domain '{$filename}'", 1); |
213 | 213 | |
214 | - $cache_file_key = $this->cache_prefix_lang . '__' . $filename; |
|
214 | + $cache_file_key = $this->cache_prefix_lang.'__'.$filename; |
|
215 | 215 | |
216 | 216 | // Подключен ли внешний кэш? |
217 | - if($this->cache) { |
|
217 | + if ($this->cache) { |
|
218 | 218 | // Загружен ли уже данный файл? |
219 | 219 | $cache_file_status = $this->cache->__get($cache_file_key); |
220 | - 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); |
|
221 | - if($cache_file_status) { |
|
220 | + 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); |
|
221 | + if ($cache_file_status) { |
|
222 | 222 | // Если да - повторять загрузку нет смысла |
223 | 223 | return null; |
224 | 224 | } |
@@ -232,47 +232,47 @@ discard block |
||
232 | 232 | $this->make_fallback($language); |
233 | 233 | |
234 | 234 | $file_path = ''; |
235 | - foreach($this->fallback as $lang_try) { |
|
236 | - if(!$lang_try /* || isset($language_tried[$lang_try]) */) { |
|
235 | + foreach ($this->fallback as $lang_try) { |
|
236 | + if (!$lang_try /* || isset($language_tried[$lang_try]) */) { |
|
237 | 237 | continue; |
238 | 238 | } |
239 | 239 | |
240 | - if($file_path = $this->lng_try_filepath($path, "language/{$lang_try}/{$filename_ext}")) { |
|
240 | + if ($file_path = $this->lng_try_filepath($path, "language/{$lang_try}/{$filename_ext}")) { |
|
241 | 241 | break; |
242 | 242 | } |
243 | 243 | |
244 | - if($file_path = $this->lng_try_filepath($path, "language/{$filename}_{$lang_try}{$ext}")) { |
|
244 | + if ($file_path = $this->lng_try_filepath($path, "language/{$filename}_{$lang_try}{$ext}")) { |
|
245 | 245 | break; |
246 | 246 | } |
247 | 247 | |
248 | 248 | $file_path = ''; |
249 | 249 | } |
250 | 250 | |
251 | - if($file_path) { |
|
251 | + if ($file_path) { |
|
252 | 252 | $a_lang_array = array(); |
253 | 253 | include($file_path); |
254 | 254 | |
255 | - if(!empty($a_lang_array)) { |
|
255 | + if (!empty($a_lang_array)) { |
|
256 | 256 | $this->merge($a_lang_array); |
257 | 257 | |
258 | 258 | // Загрузка данных из файла в кэш |
259 | - if($this->cache) { |
|
259 | + if ($this->cache) { |
|
260 | 260 | classSupernova::log_file("Locale: loading '{$filename}' into cache"); |
261 | - foreach($a_lang_array as $key => $value) { |
|
262 | - $value_cache_key = $this->cache_prefix_lang . $key; |
|
263 | - if($this->cache->__isset($value_cache_key)) { |
|
264 | - if(is_array($value)) { |
|
261 | + foreach ($a_lang_array as $key => $value) { |
|
262 | + $value_cache_key = $this->cache_prefix_lang.$key; |
|
263 | + if ($this->cache->__isset($value_cache_key)) { |
|
264 | + if (is_array($value)) { |
|
265 | 265 | $alt_value = $this->cache->__get($value_cache_key); |
266 | 266 | $value = array_replace_recursive($alt_value, $value); |
267 | 267 | // pdump($alt_value, $alt_value); |
268 | 268 | } |
269 | 269 | } |
270 | - $this->cache->__set($this->cache_prefix_lang . $key, $value); |
|
270 | + $this->cache->__set($this->cache_prefix_lang.$key, $value); |
|
271 | 271 | } |
272 | 272 | } |
273 | 273 | } |
274 | 274 | |
275 | - if($this->cache) { |
|
275 | + if ($this->cache) { |
|
276 | 276 | $this->cache->__set($cache_file_key, true); |
277 | 277 | } |
278 | 278 | |
@@ -285,14 +285,14 @@ discard block |
||
285 | 285 | } |
286 | 286 | |
287 | 287 | public function lng_load_i18n($i18n) { |
288 | - if(!isset($i18n)) { |
|
288 | + if (!isset($i18n)) { |
|
289 | 289 | return; |
290 | 290 | } |
291 | 291 | |
292 | - foreach($i18n as $i18n_data) { |
|
293 | - if(is_string($i18n_data)) { |
|
292 | + foreach ($i18n as $i18n_data) { |
|
293 | + if (is_string($i18n_data)) { |
|
294 | 294 | $this->lng_include($i18n_data); |
295 | - } elseif(is_array($i18n_data)) { |
|
295 | + } elseif (is_array($i18n_data)) { |
|
296 | 296 | $this->lng_include($i18n_data['file'], $i18n_data['path']); |
297 | 297 | } |
298 | 298 | } |
@@ -310,27 +310,27 @@ discard block |
||
310 | 310 | |
311 | 311 | classSupernova::log_file("locale.switch: Trying to switch language to '{$language_new}'"); |
312 | 312 | |
313 | - if($language_new == $this->active) { |
|
313 | + if ($language_new == $this->active) { |
|
314 | 314 | classSupernova::log_file("locale.switch: New language '{$language_new}' is equal to current language '{$this->active}' - EXIT", -1); |
315 | 315 | return false; |
316 | 316 | } |
317 | 317 | |
318 | 318 | $this->active = $language = $language_new; |
319 | - $this->cache_prefix_lang = $this->cache_prefix . $this->active . '_'; |
|
319 | + $this->cache_prefix_lang = $this->cache_prefix.$this->active.'_'; |
|
320 | 320 | |
321 | 321 | $this['LANG_INFO'] = $this->lng_get_info($this->active); |
322 | 322 | $this->make_fallback($this->active); |
323 | 323 | |
324 | - if($this->cache) { |
|
325 | - $cache_lang_init_status = $this->cache->__get($this->cache_prefix_lang . '__INIT'); |
|
326 | - 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); |
|
327 | - if($cache_lang_init_status) { |
|
324 | + if ($this->cache) { |
|
325 | + $cache_lang_init_status = $this->cache->__get($this->cache_prefix_lang.'__INIT'); |
|
326 | + 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); |
|
327 | + if ($cache_lang_init_status) { |
|
328 | 328 | return false; |
329 | 329 | } |
330 | 330 | |
331 | 331 | // Чистим текущие локализации из кэша. Достаточно почистить только флаги инициализации языкового кэша и загрузки файлов - они начинаются с '__' |
332 | 332 | classSupernova::log_file("locale.switch: Cache - invalidating data"); |
333 | - $this->cache->unset_by_prefix($this->cache_prefix_lang . '__'); |
|
333 | + $this->cache->unset_by_prefix($this->cache_prefix_lang.'__'); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | $this->lng_include('system'); |
@@ -340,9 +340,9 @@ discard block |
||
340 | 340 | // Loading global language files |
341 | 341 | $this->lng_load_i18n(classSupernova::$sn_mvc['i18n']['']); |
342 | 342 | |
343 | - if($this->cache) { |
|
344 | - classSupernova::log_file("locale.switch: Cache - setting flag " . $this->cache_prefix_lang . '__INIT'); |
|
345 | - $this->cache->__set($this->cache_prefix_lang . '__INIT', true); |
|
343 | + if ($this->cache) { |
|
344 | + classSupernova::log_file("locale.switch: Cache - setting flag ".$this->cache_prefix_lang.'__INIT'); |
|
345 | + $this->cache->__set($this->cache_prefix_lang.'__INIT', true); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | classSupernova::log_file("locale.switch: Complete - EXIT"); |
@@ -352,9 +352,9 @@ discard block |
||
352 | 352 | |
353 | 353 | |
354 | 354 | public function lng_get_info($entry) { |
355 | - $file_name = SN_ROOT_PHYSICAL . 'language/' . $entry . '/language.mo.php'; |
|
355 | + $file_name = SN_ROOT_PHYSICAL.'language/'.$entry.'/language.mo.php'; |
|
356 | 356 | $lang_info = array(); |
357 | - if(file_exists($file_name)) { |
|
357 | + if (file_exists($file_name)) { |
|
358 | 358 | include($file_name); |
359 | 359 | } |
360 | 360 | |
@@ -362,15 +362,15 @@ discard block |
||
362 | 362 | } |
363 | 363 | |
364 | 364 | public function lng_get_list() { |
365 | - if(empty($this->lang_list)) { |
|
365 | + if (empty($this->lang_list)) { |
|
366 | 366 | $this->lang_list = array(); |
367 | 367 | |
368 | - $path = SN_ROOT_PHYSICAL . 'language/'; |
|
368 | + $path = SN_ROOT_PHYSICAL.'language/'; |
|
369 | 369 | $dir = dir($path); |
370 | - while(false !== ($entry = $dir->read())) { |
|
371 | - if(is_dir($path . $entry) && $entry[0] != '.') { |
|
370 | + while (false !== ($entry = $dir->read())) { |
|
371 | + if (is_dir($path.$entry) && $entry[0] != '.') { |
|
372 | 372 | $lang_info = $this->lng_get_info($entry); |
373 | - if($lang_info['LANG_NAME_ISO2'] == $entry) { |
|
373 | + if ($lang_info['LANG_NAME_ISO2'] == $entry) { |
|
374 | 374 | $this->lang_list[$lang_info['LANG_NAME_ISO2']] = $lang_info; |
375 | 375 | } |
376 | 376 | } |
@@ -55,11 +55,10 @@ discard block |
||
55 | 55 | } |
56 | 56 | |
57 | 57 | public static function db_planet_by_vector($vector, $prefix = '', $for_update = false, $fields = '*') { |
58 | - $galaxy = isset($vector[$prefix . 'galaxy']) ? intval($vector[$prefix . 'galaxy']) : 0; |
|
59 | - $system = isset($vector[$prefix . 'system']) ? intval($vector[$prefix . 'system']) : 0; |
|
60 | - $planet = isset($vector[$prefix . 'planet']) ? intval($vector[$prefix . 'planet']) : 0; |
|
61 | - $planet_type = isset($vector[$prefix . 'planet_type']) ? intval($vector[$prefix . 'planet_type']) : |
|
62 | - (isset($vector[$prefix . 'type']) ? intval($vector[$prefix . 'type']) : 0); |
|
58 | + $galaxy = isset($vector[$prefix.'galaxy']) ? intval($vector[$prefix.'galaxy']) : 0; |
|
59 | + $system = isset($vector[$prefix.'system']) ? intval($vector[$prefix.'system']) : 0; |
|
60 | + $planet = isset($vector[$prefix.'planet']) ? intval($vector[$prefix.'planet']) : 0; |
|
61 | + $planet_type = isset($vector[$prefix.'planet_type']) ? intval($vector[$prefix.'planet_type']) : (isset($vector[$prefix.'type']) ? intval($vector[$prefix.'type']) : 0); |
|
63 | 62 | $planet_type = $planet_type == PT_DEBRIS ? PT_PLANET : $planet_type; |
64 | 63 | |
65 | 64 | return DBStaticPlanet::db_planet_by_gspt_safe($galaxy, $system, $planet, $planet_type, $for_update, $fields); |
@@ -85,7 +84,7 @@ discard block |
||
85 | 84 | } |
86 | 85 | |
87 | 86 | return classSupernova::$gc->cacheOperator->db_get_record_list(LOC_PLANET, |
88 | - "`parent_planet` = {$parent_id} AND `planet_type` = " . PT_MOON, true); |
|
87 | + "`parent_planet` = {$parent_id} AND `planet_type` = ".PT_MOON, true); |
|
89 | 88 | } |
90 | 89 | |
91 | 90 | public static function db_planet_by_id_and_owner($planet_id, $owner_id, $for_update = false, $fields = '*') { |
@@ -106,7 +105,7 @@ discard block |
||
106 | 105 | } |
107 | 106 | |
108 | 107 | return classSupernova::$gc->cacheOperator->db_get_record_list(LOC_PLANET, |
109 | - "`planet_type` = " . PT_MOON . " AND `id_owner` = {$user_id} AND `id` != {$this_moon_id}"); |
|
108 | + "`planet_type` = ".PT_MOON." AND `id_owner` = {$user_id} AND `id` != {$this_moon_id}"); |
|
110 | 109 | } |
111 | 110 | |
112 | 111 | public static function db_planet_list_in_system($galaxy, $system) { |
@@ -132,7 +131,7 @@ discard block |
||
132 | 131 | ); |
133 | 132 | $order_by = classSupernova::$user_options[PLAYER_OPTION_PLANET_SORT]; |
134 | 133 | empty($sort_orders[$order_by]) ? $order_by = SORT_ID : false; |
135 | - $order_by = $sort_orders[$order_by] . ' ' . (classSupernova::$user_options[PLAYER_OPTION_PLANET_SORT_INVERSE] == SORT_ASCENDING ? 'ASC' : 'DESC'); |
|
134 | + $order_by = $sort_orders[$order_by].' '.(classSupernova::$user_options[PLAYER_OPTION_PLANET_SORT_INVERSE] == SORT_ASCENDING ? 'ASC' : 'DESC'); |
|
136 | 135 | |
137 | 136 | // Compilating query |
138 | 137 | return classSupernova::$gc->cacheOperator->db_get_record_list(LOC_PLANET, |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | } |
25 | 25 | |
26 | 26 | if (classSupernova::$gc->snCache->isUnitLocatorNotSet($location_type, $location_id)) { |
27 | - $got_data = classSupernova::$gc->cacheOperator->db_get_record_list(LOC_UNIT, "unit_location_type = {$location_type} AND unit_location_id = {$location_id} AND " . DBStaticUnit::db_unit_time_restrictions()); |
|
27 | + $got_data = classSupernova::$gc->cacheOperator->db_get_record_list(LOC_UNIT, "unit_location_type = {$location_type} AND unit_location_id = {$location_id} AND ".DBStaticUnit::db_unit_time_restrictions()); |
|
28 | 28 | if (!empty($got_data) && is_array($got_data)) { |
29 | 29 | foreach ($got_data as $unit_id => $unit_data) { |
30 | 30 | classSupernova::$gc->snCache->setUnitLocatorByLocationAndIDs($location_type, $location_id, $unit_data); |
@@ -59,9 +59,9 @@ discard block |
||
59 | 59 | |
60 | 60 | public static function db_unit_count_by_user_and_type_and_snid($user_id, $unit_type = 0, $unit_snid = 0) { |
61 | 61 | $query = classSupernova::$db->doSelect( |
62 | - "SELECT unit_snid, sum(unit_level) as `qty` FROM {{unit}} WHERE `unit_player_id` = {$user_id} " . |
|
63 | - ($unit_type ? "AND `unit_type` = {$unit_type} " : '') . |
|
64 | - ($unit_snid ? "AND `unit_snid` = {$unit_snid} " : '') . |
|
62 | + "SELECT unit_snid, sum(unit_level) as `qty` FROM {{unit}} WHERE `unit_player_id` = {$user_id} ". |
|
63 | + ($unit_type ? "AND `unit_type` = {$unit_type} " : ''). |
|
64 | + ($unit_snid ? "AND `unit_snid` = {$unit_snid} " : ''). |
|
65 | 65 | 'GROUP BY `unit_snid`' |
66 | 66 | ); |
67 | 67 | $result = array(); |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | WHERE |
82 | 82 | f.fleet_owner = {$user_id} AND |
83 | 83 | (f.fleet_start_planet_id = {$location_id} OR f.fleet_end_planet_id = {$location_id}) |
84 | - AND u.unit_snid = {$unit_snid} AND u.`unit_location_type` = " . LOC_FLEET . " AND " . self::db_unit_time_restrictions() . |
|
85 | - " LIMIT 1" . |
|
84 | + AND u.unit_snid = {$unit_snid} AND u.`unit_location_type` = ".LOC_FLEET." AND ".self::db_unit_time_restrictions(). |
|
85 | + " LIMIT 1". |
|
86 | 86 | ($for_update ? ' FOR UPDATE' : '')); |
87 | 87 | } |
88 | 88 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | public static function db_unit_list_laboratories($user_id) { |
91 | 91 | return classSupernova::$db->doSelect("SELECT DISTINCT unit_location_id AS `id` |
92 | 92 | FROM {{unit}} |
93 | - WHERE unit_player_id = {$user_id} AND unit_location_type = " . LOC_PLANET . " AND unit_level > 0 AND unit_snid IN (" . STRUC_LABORATORY . ", " . STRUC_LABORATORY_NANO . ");"); |
|
93 | + WHERE unit_player_id = {$user_id} AND unit_location_type = ".LOC_PLANET." AND unit_level > 0 AND unit_snid IN (".STRUC_LABORATORY.", ".STRUC_LABORATORY_NANO.");"); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | public static function db_unit_set_by_id($unit_id, $set) { |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | return classSupernova::$db->doSelect( |
125 | 125 | "SELECT unit_player_id, unit_type, unit_snid, unit_level, count(*) AS unit_amount |
126 | 126 | FROM `{{unit}}` |
127 | - WHERE unit_level > 0 AND " . self::db_unit_time_restrictions() . |
|
127 | + WHERE unit_level > 0 AND " . self::db_unit_time_restrictions(). |
|
128 | 128 | " GROUP BY unit_player_id, unit_type, unit_snid, unit_level" |
129 | 129 | ); |
130 | 130 | } |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | public static function db_unit_list_admin_delete_mercenaries_finished() { |
139 | 139 | return classSupernova::$db->doDeleteDeprecated(TABLE_UNIT, array( |
140 | 140 | 'unit_time_finish IS NOT NULL', |
141 | - "unit_time_finish < FROM_UNIXTIME(" . SN_TIME_NOW . ")", |
|
141 | + "unit_time_finish < FROM_UNIXTIME(".SN_TIME_NOW.")", |
|
142 | 142 | 'unit_type' => UNIT_MERCENARIES, |
143 | 143 | )); |
144 | 144 | } |
@@ -147,8 +147,8 @@ discard block |
||
147 | 147 | return classSupernova::$db->doUpdate( |
148 | 148 | "UPDATE `{{unit}}` |
149 | 149 | SET |
150 | - unit_time_start = FROM_UNIXTIME(" . SN_TIME_NOW . "), |
|
151 | - unit_time_finish = FROM_UNIXTIME(" . (SN_TIME_NOW + $default_length) . ") |
|
150 | + unit_time_start = FROM_UNIXTIME(" . SN_TIME_NOW."), |
|
151 | + unit_time_finish = FROM_UNIXTIME(" . (SN_TIME_NOW + $default_length).") |
|
152 | 152 | WHERE unit_type = " . UNIT_MERCENARIES |
153 | 153 | ); |
154 | 154 | } |
@@ -173,13 +173,13 @@ discard block |
||
173 | 173 | |
174 | 174 | $temp = DBStaticUnit::db_get_unit_by_location($user['id'], $unit_location, $location_id, $unit_id, true, 'unit_id'); |
175 | 175 | if (!empty($temp['unit_id'])) { |
176 | - $result = (bool)classSupernova::$gc->cacheOperator->db_upd_record_list( |
|
176 | + $result = (bool) classSupernova::$gc->cacheOperator->db_upd_record_list( |
|
177 | 177 | LOC_UNIT, "`unit_level` = `unit_level` + ($unit_value)", "`unit_id` = {$temp['unit_id']}" |
178 | 178 | ); |
179 | 179 | } else { |
180 | 180 | $locationIdRendered = $unit_location == LOC_USER ? $user['id'] : $planet_id; |
181 | 181 | $unitType = get_unit_param($unit_id, P_UNIT_TYPE); |
182 | - $result = (bool)classSupernova::$gc->cacheOperator->db_ins_record( |
|
182 | + $result = (bool) classSupernova::$gc->cacheOperator->db_ins_record( |
|
183 | 183 | LOC_UNIT, |
184 | 184 | "unit_player_id = {$user['id']}, |
185 | 185 | unit_location_type = {$unit_location}, |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | public function compile_request($request) { |
449 | 449 | global $user; |
450 | 450 | |
451 | - if(!(classSupernova::$auth->account instanceof Account)) { |
|
451 | + if (!(classSupernova::$auth->account instanceof Account)) { |
|
452 | 452 | // TODO - throw new Exception(lang['pay_msg_mm_request_amount_invalid'], SN_PAYMENT_REQUEST_ERROR_UNIT_AMOUNT); |
453 | 453 | } |
454 | 454 | $this->account = classSupernova::$auth->account; |
@@ -469,15 +469,15 @@ discard block |
||
469 | 469 | $this->payment_currency = classSupernova::$config->payment_currency_default; |
470 | 470 | $this->payment_amount = self::currency_convert($this->payment_dark_matter_paid, 'MM_', $this->payment_currency); |
471 | 471 | |
472 | - if(empty($this->payment_external_currency) && !empty($this->config['currency'])) { |
|
472 | + if (empty($this->payment_external_currency) && !empty($this->config['currency'])) { |
|
473 | 473 | $this->payment_external_currency = $this->config['currency']; |
474 | 474 | } |
475 | - if(empty($this->payment_external_currency)) { |
|
475 | + if (empty($this->payment_external_currency)) { |
|
476 | 476 | throw new Exception(classLocale::$lang['pay_error_internal_no_external_currency_set'], SN_PAYMENT_ERROR_INTERNAL_NO_EXTERNAL_CURRENCY_SET); |
477 | 477 | } |
478 | 478 | |
479 | 479 | $this->payment_external_amount = self::currency_convert($this->payment_dark_matter_paid, 'MM_', $this->payment_external_currency); |
480 | - if($this->payment_external_amount < 0.01) { |
|
480 | + if ($this->payment_external_amount < 0.01) { |
|
481 | 481 | throw new Exception(classLocale::$lang['pay_msg_mm_request_amount_invalid'], SN_PAYMENT_REQUEST_ERROR_UNIT_AMOUNT); |
482 | 482 | } |
483 | 483 | |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | $this->generate_description(); |
487 | 487 | |
488 | 488 | $this->db_insert(); |
489 | - if(!$this->is_exists) { |
|
489 | + if (!$this->is_exists) { |
|
490 | 490 | throw new Exception(classLocale::$lang['pay_msg_request_error_db_payment_create'], SN_PAYMENT_REQUEST_DB_ERROR_PAYMENT_CREATE); |
491 | 491 | } |
492 | 492 | } |
@@ -498,26 +498,26 @@ discard block |
||
498 | 498 | * @throws Exception |
499 | 499 | */ |
500 | 500 | protected function payment_request_process($options = array()) { |
501 | - if(!$this->manifest['active']) { |
|
501 | + if (!$this->manifest['active']) { |
|
502 | 502 | throw new Exception(classLocale::$lang['pay_msg_module_disabled'], SN_MODULE_DISABLED); |
503 | 503 | } |
504 | 504 | |
505 | 505 | // Если есть payment_id - загружаем под него данные |
506 | - if(!empty($this->payment_params['payment_id'])) { |
|
506 | + if (!empty($this->payment_params['payment_id'])) { |
|
507 | 507 | $this->request_payment_id = sys_get_param_id($this->payment_params['payment_id']); |
508 | - if(!$this->request_payment_id) { |
|
508 | + if (!$this->request_payment_id) { |
|
509 | 509 | throw new Exception(classLocale::$lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_INTERNAL_ID_WRONG); |
510 | 510 | } |
511 | 511 | |
512 | - if(!$this->db_get_by_id($this->request_payment_id)) { |
|
512 | + if (!$this->db_get_by_id($this->request_payment_id)) { |
|
513 | 513 | throw new Exception(classLocale::$lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_INTERNAL_ID_WRONG); |
514 | 514 | } |
515 | 515 | |
516 | 516 | // Проверяем - был ли этот платеж обработан? |
517 | 517 | // TODO - Статусы бывают разные. Нужен спецфлаг payment_processed |
518 | - if($this->payment_status != PAYMENT_STATUS_NONE) { |
|
518 | + if ($this->payment_status != PAYMENT_STATUS_NONE) { |
|
519 | 519 | sn_db_transaction_rollback(); |
520 | - sys_redirect(SN_ROOT_VIRTUAL . 'metamatter.php?payment_id=' . $this->payment_id); |
|
520 | + sys_redirect(SN_ROOT_VIRTUAL.'metamatter.php?payment_id='.$this->payment_id); |
|
521 | 521 | die(); |
522 | 522 | } |
523 | 523 | } |
@@ -525,89 +525,89 @@ discard block |
||
525 | 525 | // Пытаемся получить из запроса ИД аккаунта |
526 | 526 | $request_account_id = !empty($this->payment_params['account_id']) ? sys_get_param_id($this->payment_params['account_id']) : 0; |
527 | 527 | // Если в запросе нет ИД аккаунта - пытаемся использовать payment_account_id |
528 | - if(empty($request_account_id) && !empty($this->payment_account_id)) { |
|
528 | + if (empty($request_account_id) && !empty($this->payment_account_id)) { |
|
529 | 529 | $request_account_id = $this->payment_account_id; |
530 | 530 | } |
531 | 531 | // Если теперь у нас нету ИД аккаунта ни в запросе, ни в записи таблицы - можно паниковать |
532 | - if(empty($request_account_id)) { |
|
532 | + if (empty($request_account_id)) { |
|
533 | 533 | // TODO - аккаунт |
534 | 534 | throw new Exception(classLocale::$lang['pay_msg_request_user_invalid'], $this->retranslate_error(SN_PAYMENT_REQUEST_USER_NOT_FOUND, $options)); |
535 | 535 | } |
536 | 536 | // Если нет записи в таблице - тогда берем payment_account_id из запроса |
537 | - if(empty($this->payment_account_id)) { |
|
537 | + if (empty($this->payment_account_id)) { |
|
538 | 538 | $this->payment_account_id = $request_account_id; |
539 | 539 | } |
540 | 540 | // Если у нас отличаются ИД аккаунта в запросе и ИД аккаунта в записи - тоже можно паниковать |
541 | - if($this->payment_account_id != $request_account_id) { |
|
541 | + if ($this->payment_account_id != $request_account_id) { |
|
542 | 542 | // TODO - Поменять сообщение об ошибке |
543 | 543 | throw new Exception(classLocale::$lang['pay_msg_request_user_invalid'], $this->retranslate_error(SN_PAYMENT_REQUEST_USER_NOT_FOUND, $options)); |
544 | 544 | } |
545 | 545 | // Проверяем существование аккаунта с данным ИД |
546 | - if(!$this->account->db_get_by_id($this->payment_account_id)) { |
|
547 | - 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)); |
|
546 | + if (!$this->account->db_get_by_id($this->payment_account_id)) { |
|
547 | + 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 | 548 | } |
549 | 549 | |
550 | 550 | // TODO Проверка на сервер_ид - как бы и не нужна, наверное? |
551 | - if(!empty($this->payment_params['server_id'])) { |
|
551 | + if (!empty($this->payment_params['server_id'])) { |
|
552 | 552 | $this->request_server_id = sys_get_param_str($this->payment_params['server_id']); |
553 | - if(SN_ROOT_VIRTUAL != $this->request_server_id) { |
|
554 | - throw new Exception(classLocale::$lang['pay_msg_request_server_wrong'] . " {$this->request_server_id} вместо " . SN_ROOT_VIRTUAL, SN_PAYMENT_REQUEST_SERVER_WRONG); |
|
553 | + if (SN_ROOT_VIRTUAL != $this->request_server_id) { |
|
554 | + throw new Exception(classLocale::$lang['pay_msg_request_server_wrong']." {$this->request_server_id} вместо ".SN_ROOT_VIRTUAL, SN_PAYMENT_REQUEST_SERVER_WRONG); |
|
555 | 555 | } |
556 | 556 | } |
557 | 557 | |
558 | 558 | // Сверка количества оплаченной ММ с учётом бонусов |
559 | - if(!empty($this->payment_params['payment_dark_matter_gained'])) { |
|
559 | + if (!empty($this->payment_params['payment_dark_matter_gained'])) { |
|
560 | 560 | $request_mm_amount = sys_get_param_id($this->payment_params['payment_dark_matter_gained']); |
561 | - if($request_mm_amount != $this->payment_dark_matter_gained && $this->is_loaded) { |
|
562 | - 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); |
|
561 | + if ($request_mm_amount != $this->payment_dark_matter_gained && $this->is_loaded) { |
|
562 | + 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 | 563 | } |
564 | 564 | empty($this->payment_dark_matter_gained) ? $this->payment_dark_matter_gained = $request_mm_amount : false; |
565 | 565 | } |
566 | - if(empty($this->payment_dark_matter_paid)) { |
|
566 | + if (empty($this->payment_dark_matter_paid)) { |
|
567 | 567 | // TODO - обратный расчёт из gained |
568 | 568 | } |
569 | 569 | |
570 | 570 | // Проверка наличия внешнего ИД платежа |
571 | - if(!empty($this->payment_params['payment_external_id'])) { |
|
571 | + if (!empty($this->payment_params['payment_external_id'])) { |
|
572 | 572 | $request_payment_external_id = sys_get_param_id($this->payment_params['payment_external_id']); |
573 | - if(empty($request_payment_external_id)) { |
|
573 | + if (empty($request_payment_external_id)) { |
|
574 | 574 | throw new exception(classLocale::$lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_EXTERNAL_ID_WRONG); |
575 | - } elseif(!empty($this->payment_external_id) && $this->payment_external_id != $request_payment_external_id) { |
|
575 | + } elseif (!empty($this->payment_external_id) && $this->payment_external_id != $request_payment_external_id) { |
|
576 | 576 | // TODO - Может быть поменять сообщение |
577 | 577 | throw new exception(classLocale::$lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_EXTERNAL_ID_WRONG); |
578 | 578 | } |
579 | 579 | $this->payment_external_id = $request_payment_external_id; |
580 | 580 | } |
581 | 581 | // Сверка суммы, запрошенной СН к оплате |
582 | - if(!empty($this->payment_params['payment_external_money'])) { |
|
582 | + if (!empty($this->payment_params['payment_external_money'])) { |
|
583 | 583 | $request_money_out = sys_get_param_float($this->payment_params['payment_external_money']); |
584 | - if($request_money_out != $this->payment_external_amount && $this->is_loaded) { |
|
585 | - throw new Exception(classLocale::$lang['pay_msg_request_payment_amount_invalid'] . " пришло {$request_money_out} денег вместо {$this->payment_external_amount} денег", SN_PAYMENT_REQUEST_CURRENCY_AMOUNT_INVALID); |
|
584 | + if ($request_money_out != $this->payment_external_amount && $this->is_loaded) { |
|
585 | + 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 | 586 | } |
587 | 587 | empty($this->payment_external_amount) ? $this->payment_external_amount = $request_money_out : false; |
588 | 588 | } |
589 | 589 | // Заполняем поле валюты платёжной системы |
590 | - if(!empty($this->payment_params['payment_external_currency'])) { |
|
590 | + if (!empty($this->payment_params['payment_external_currency'])) { |
|
591 | 591 | $this->payment_external_currency = sys_get_param_str($this->payment_params['payment_external_currency']); |
592 | - if(empty($this->payment_external_currency)) { |
|
592 | + if (empty($this->payment_external_currency)) { |
|
593 | 593 | // TODO - поменять сообщение |
594 | - throw new Exception(classLocale::$lang['pay_msg_request_payment_amount_invalid'] . " {$this->payment_external_currency}", SN_PAYMENT_REQUEST_CURRENCY_AMOUNT_INVALID); |
|
594 | + throw new Exception(classLocale::$lang['pay_msg_request_payment_amount_invalid']." {$this->payment_external_currency}", SN_PAYMENT_REQUEST_CURRENCY_AMOUNT_INVALID); |
|
595 | 595 | } |
596 | 596 | } |
597 | - if(empty($this->payment_external_currency)) { |
|
597 | + if (empty($this->payment_external_currency)) { |
|
598 | 598 | $this->payment_external_currency = $this->config['currency']; |
599 | 599 | } |
600 | 600 | |
601 | 601 | // Заполнение внутренней суммы и валюты из внешних данных |
602 | - if(empty($this->payment_currency)) { |
|
602 | + if (empty($this->payment_currency)) { |
|
603 | 603 | $this->payment_currency = classSupernova::$config->payment_currency_default; |
604 | 604 | } |
605 | - if(empty($this->payment_amount) && !empty($this->payment_external_currency)) { |
|
605 | + if (empty($this->payment_amount) && !empty($this->payment_external_currency)) { |
|
606 | 606 | $this->payment_amount = self::currency_convert($this->payment_external_amount, $this->payment_external_currency, $this->payment_currency); |
607 | 607 | } |
608 | 608 | |
609 | 609 | // TODO - Тестовый режим |
610 | - if(!empty($this->payment_params['test'])) { |
|
610 | + if (!empty($this->payment_params['test'])) { |
|
611 | 611 | $this->payment_test = $this->config['test'] || sys_get_param_int($this->payment_params['test']); |
612 | 612 | } |
613 | 613 | |
@@ -634,21 +634,21 @@ discard block |
||
634 | 634 | sn_db_transaction_start(); |
635 | 635 | try { |
636 | 636 | $response = $this->payment_request_process(); |
637 | - } catch(Exception $e) { |
|
637 | + } catch (Exception $e) { |
|
638 | 638 | $response['result'] = $e->getCode(); |
639 | 639 | $response['message'] = $e->getMessage(); |
640 | 640 | } |
641 | 641 | |
642 | - if($response['result'] == SN_PAYMENT_REQUEST_OK) { |
|
642 | + if ($response['result'] == SN_PAYMENT_REQUEST_OK) { |
|
643 | 643 | sn_db_transaction_commit(); |
644 | - classSupernova::$debug->warning('Результат операции: код ' . $response['result'] . ' сообщение "' . $response['message'] . '"', 'Успешный платёж', LOG_INFO_PAYMENT); |
|
644 | + classSupernova::$debug->warning('Результат операции: код '.$response['result'].' сообщение "'.$response['message'].'"', 'Успешный платёж', LOG_INFO_PAYMENT); |
|
645 | 645 | } else { |
646 | 646 | sn_db_transaction_rollback(); |
647 | - classSupernova::$debug->warning('Результат операции: код ' . $response['result'] . ' сообщение "' . $response['message'] . '"', 'Ошибка платежа', LOG_INFO_PAYMENT, true); |
|
647 | + classSupernova::$debug->warning('Результат операции: код '.$response['result'].' сообщение "'.$response['message'].'"', 'Ошибка платежа', LOG_INFO_PAYMENT, true); |
|
648 | 648 | } |
649 | 649 | |
650 | 650 | // Переводим код результата из СН в код платежной системы |
651 | - if(is_array($this->result_translations) && !empty($this->result_translations)) { |
|
651 | + if (is_array($this->result_translations) && !empty($this->result_translations)) { |
|
652 | 652 | $response['result'] = isset($this->result_translations[$response['result']]) ? $this->result_translations[$response['result']] : $this->result_translations[SN_PAYMENT_REQUEST_UNDEFINED_ERROR]; |
653 | 653 | } |
654 | 654 | |
@@ -671,7 +671,7 @@ discard block |
||
671 | 671 | $currency_from = strtolower($currency_from); |
672 | 672 | $currency_to = strtolower($currency_to); |
673 | 673 | |
674 | - if($currency_from != $currency_to) { |
|
674 | + if ($currency_from != $currency_to) { |
|
675 | 675 | $exchange_from = get_exchange_rate($currency_from); |
676 | 676 | $exchange_to = get_exchange_rate($currency_to); |
677 | 677 | |
@@ -695,10 +695,10 @@ discard block |
||
695 | 695 | public static function bonus_calculate($dark_matter, $direct = true, $return_bonus = false) { |
696 | 696 | $bonus = 0; |
697 | 697 | $dark_matter_new = $dark_matter; |
698 | - if(!empty(self::$bonus_table) && $dark_matter >= self::$bonus_table[0]) { |
|
699 | - if($direct) { |
|
700 | - foreach(self::$bonus_table as $dm_for_bonus => $multiplier) { |
|
701 | - if($dm_for_bonus <= $dark_matter) { |
|
698 | + if (!empty(self::$bonus_table) && $dark_matter >= self::$bonus_table[0]) { |
|
699 | + if ($direct) { |
|
700 | + foreach (self::$bonus_table as $dm_for_bonus => $multiplier) { |
|
701 | + if ($dm_for_bonus <= $dark_matter) { |
|
702 | 702 | $dark_matter_new = $dark_matter * (1 + $multiplier); |
703 | 703 | $bonus = $multiplier; |
704 | 704 | } else { |
@@ -706,9 +706,9 @@ discard block |
||
706 | 706 | } |
707 | 707 | } |
708 | 708 | } else { |
709 | - foreach(self::$bonus_table as $dm_for_bonus => $multiplier) { |
|
709 | + foreach (self::$bonus_table as $dm_for_bonus => $multiplier) { |
|
710 | 710 | $temp = $dm_for_bonus * (1 + $multiplier); |
711 | - if($dark_matter >= $temp) { |
|
711 | + if ($dark_matter >= $temp) { |
|
712 | 712 | $dark_matter_new = round($dark_matter / (1 + $multiplier)); |
713 | 713 | $bonus = $multiplier; |
714 | 714 | } else { |
@@ -761,7 +761,7 @@ discard block |
||
761 | 761 | 'payment_external_lots' => $this->payment_dark_matter_paid / get_mm_cost(), |
762 | 762 | ); |
763 | 763 | |
764 | - if($this->payment_id) { |
|
764 | + if ($this->payment_id) { |
|
765 | 765 | $payment['payment_id'] = $this->payment_id; |
766 | 766 | classSupernova::$gc->db->doReplaceSet('payment', $payment); |
767 | 767 | } else { |
@@ -773,12 +773,12 @@ discard block |
||
773 | 773 | |
774 | 774 | |
775 | 775 | public function payment_adjust_mm_new() { |
776 | - if(!$this->payment_test) { |
|
776 | + if (!$this->payment_test) { |
|
777 | 777 | // Not a test payment. Adding DM to account |
778 | 778 | $this->account = new Account($this->db); |
779 | 779 | $this->account->db_get_by_id($this->payment_account_id); |
780 | 780 | $result = $this->account->metamatter_change(RPG_PURCHASE, $this->payment_dark_matter_gained, $this->payment_comment); |
781 | - if(!$result) { |
|
781 | + if (!$result) { |
|
782 | 782 | throw new Exception('Ошибка начисления ММ', SN_METAMATTER_ERROR_ADJUST); |
783 | 783 | } |
784 | 784 | } |
@@ -787,25 +787,25 @@ discard block |
||
787 | 787 | public function payment_cancel(&$payment) { |
788 | 788 | die('{НЕ РАБОТАЕТ! СООБЩИТЕ АДМИНИСТРАЦИИ!}'); |
789 | 789 | |
790 | - if(!isset($payment['payment_status'])) { |
|
790 | + if (!isset($payment['payment_status'])) { |
|
791 | 791 | throw new exception(classLocale::$lang['pay_msg_request_payment_not_found'], SN_PAYMENT_REQUEST_ORDER_NOT_FOUND); |
792 | 792 | } |
793 | 793 | |
794 | - if($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) { |
|
795 | - $safe_comment = db_escape($payment['payment_comment'] = classLocale::$lang['pay_msg_request_payment_cancelled'] .' ' . $payment['payment_comment']); |
|
794 | + if ($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) { |
|
795 | + $safe_comment = db_escape($payment['payment_comment'] = classLocale::$lang['pay_msg_request_payment_cancelled'].' '.$payment['payment_comment']); |
|
796 | 796 | |
797 | - if(!$payment['payment_test']) { |
|
797 | + if (!$payment['payment_test']) { |
|
798 | 798 | $result = $this->account->metamatter_change(RPG_PURCHASE_CANCEL, -$payment['payment_dark_matter_gained'], $payment['payment_comment']); |
799 | - if(!$result) { |
|
799 | + if (!$result) { |
|
800 | 800 | throw new exception('Ошибка начисления ММ', SN_METAMATTER_ERROR_ADJUST); |
801 | 801 | } |
802 | 802 | } |
803 | 803 | $payment['payment_status'] = PAYMENT_STATUS_CANCELED; |
804 | 804 | db_payment_update($payment, $safe_comment); |
805 | 805 | throw new exception(classLocale::$lang['pay_msg_request_payment_cancel_complete'], SN_PAYMENT_REQUEST_OK); |
806 | - } elseif($payment['payment_status'] == PAYMENT_STATUS_CANCELED) { |
|
806 | + } elseif ($payment['payment_status'] == PAYMENT_STATUS_CANCELED) { |
|
807 | 807 | throw new exception(classLocale::$lang['pay_msg_request_payment_cancelled_already'], SN_PAYMENT_REQUEST_OK); |
808 | - } elseif($payment['payment_status'] == PAYMENT_STATUS_NONE) { |
|
808 | + } elseif ($payment['payment_status'] == PAYMENT_STATUS_NONE) { |
|
809 | 809 | throw new exception(classLocale::$lang['pay_msg_request_payment_cancel_not_complete'], SN_PAYMENT_REQUEST_PAYMENT_NOT_COMPLETE); |
810 | 810 | } |
811 | 811 | } |
@@ -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 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @param db_mysql|null $db |
87 | 87 | */ |
88 | 88 | public static function setDb($db = null) { |
89 | - if(empty($db) || !($db instanceof db_mysql)) { |
|
89 | + if (empty($db) || !($db instanceof db_mysql)) { |
|
90 | 90 | $db = null; |
91 | 91 | } |
92 | 92 | static::$db = !empty($db) || !class_exists('classSupernova', false) ? $db : classSupernova::$db; |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | public function dbLoad($dbId, $lockSkip = false) { |
150 | 150 | $dbId = idval($dbId); |
151 | 151 | if ($dbId <= 0) { |
152 | - classSupernova::$debug->error(get_called_class() . '::' . __METHOD__ . ' $dbId not positive = ' . $dbId); |
|
152 | + classSupernova::$debug->error(get_called_class().'::'.__METHOD__.' $dbId not positive = '.$dbId); |
|
153 | 153 | |
154 | 154 | return; |
155 | 155 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | $this->dbGetLockById($this->_dbId); |
162 | 162 | } |
163 | 163 | |
164 | - $db_row = classSupernova::$db->doSelectFetch("SELECT * FROM `{{" . static::$_table . "}}` WHERE `" . static::$_dbIdFieldName . "` = " . $this->_dbId . " LIMIT 1 FOR UPDATE;"); |
|
164 | + $db_row = classSupernova::$db->doSelectFetch("SELECT * FROM `{{".static::$_table."}}` WHERE `".static::$_dbIdFieldName."` = ".$this->_dbId." LIMIT 1 FOR UPDATE;"); |
|
165 | 165 | if (empty($db_row)) { |
166 | 166 | return; |
167 | 167 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | if ($this->isNew()) { |
194 | 194 | // No DB_ID - new unit |
195 | 195 | if ($this->isEmpty()) { |
196 | - classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - object is empty on ' . get_called_class() . '::dbSave'); |
|
196 | + classSupernova::$debug->error(__FILE__.':'.__LINE__.' - object is empty on '.get_called_class().'::dbSave'); |
|
197 | 197 | } |
198 | 198 | $this->dbInsert(); |
199 | 199 | } else { |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | $this->dbDelete(); |
203 | 203 | } else { |
204 | 204 | if (!sn_db_transaction_check(false)) { |
205 | - classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - transaction should always be started on ' . get_called_class() . '::dbUpdate'); |
|
205 | + classSupernova::$debug->error(__FILE__.':'.__LINE__.' - transaction should always be started on '.get_called_class().'::dbUpdate'); |
|
206 | 206 | } |
207 | 207 | $this->dbUpdate(); |
208 | 208 | } |
@@ -230,12 +230,12 @@ discard block |
||
230 | 230 | // TODO - protected |
231 | 231 | public function dbInsert() { |
232 | 232 | if (!$this->isNew()) { |
233 | - classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - record db_id is not empty on ' . get_called_class() . '::dbInsert'); |
|
233 | + classSupernova::$debug->error(__FILE__.':'.__LINE__.' - record db_id is not empty on '.get_called_class().'::dbInsert'); |
|
234 | 234 | } |
235 | 235 | $this->_dbId = $this->db_field_set_create($this->dbMakeFieldSet()); |
236 | 236 | |
237 | 237 | if (empty($this->_dbId)) { |
238 | - classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - error saving record ' . get_called_class() . '::dbInsert'); |
|
238 | + classSupernova::$debug->error(__FILE__.':'.__LINE__.' - error saving record '.get_called_class().'::dbInsert'); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | return $this->_dbId; |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | public function dbUpdate() { |
249 | 249 | // TODO - Update |
250 | 250 | if ($this->isNew()) { |
251 | - classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - unit db_id is empty on dbUpdate'); |
|
251 | + classSupernova::$debug->error(__FILE__.':'.__LINE__.' - unit db_id is empty on dbUpdate'); |
|
252 | 252 | } |
253 | 253 | $this->db_field_update($this->dbMakeFieldSet(true)); |
254 | 254 | } |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | // TODO - protected |
260 | 260 | public function dbDelete() { |
261 | 261 | if ($this->isNew()) { |
262 | - classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - unit db_id is empty on dbDelete'); |
|
262 | + classSupernova::$debug->error(__FILE__.':'.__LINE__.' - unit db_id is empty on dbDelete'); |
|
263 | 263 | } |
264 | 264 | classSupernova::$gc->db->doDeleteRowWhere(static::$_table, array(static::$_dbIdFieldName => $this->_dbId)); |
265 | 265 | $this->_dbId = 0; |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | $fields = implode(',', array_keys($field_set)); |
415 | 415 | |
416 | 416 | $result = 0; |
417 | - if (classSupernova::$db->doInsert("INSERT INTO `{{" . static::$_table . "}}` ({$fields}) VALUES ({$values});")) { |
|
417 | + if (classSupernova::$db->doInsert("INSERT INTO `{{".static::$_table."}}` ({$fields}) VALUES ({$values});")) { |
|
418 | 418 | $result = classSupernova::$db->db_insert_id(); |
419 | 419 | } |
420 | 420 | |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | |
451 | 451 | return empty($set_string) |
452 | 452 | ? true |
453 | - : classSupernova::$db->doUpdate("UPDATE `{{" . static::$_table . "}}` SET {$set_string} WHERE `" . static::$_dbIdFieldName . "` = " . $this->_dbId); |
|
453 | + : classSupernova::$db->doUpdate("UPDATE `{{".static::$_table."}}` SET {$set_string} WHERE `".static::$_dbIdFieldName."` = ".$this->_dbId); |
|
454 | 454 | } |
455 | 455 | |
456 | 456 | } |