@@ -40,6 +40,7 @@ discard block |
||
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
43 | + * @param string $fields |
|
43 | 44 | * @return DbResultIterator |
44 | 45 | */ |
45 | 46 | protected static function playerSelectIterator($fields, $orderBy = '', $forUpdate = false, $groupHaving = '', $where = '', $limit = '') { |
@@ -134,6 +135,9 @@ discard block |
||
134 | 135 | return $result; |
135 | 136 | } |
136 | 137 | |
138 | + /** |
|
139 | + * @param integer $config_user_birthday_range |
|
140 | + */ |
|
137 | 141 | public static function db_user_list_to_celebrate($config_user_birthday_range) { |
138 | 142 | $query = "SELECT |
139 | 143 | `id`, `username`, `user_birthday`, `user_birthday_celebrated`, |
@@ -213,6 +217,9 @@ discard block |
||
213 | 217 | return $user_list; |
214 | 218 | } |
215 | 219 | |
220 | + /** |
|
221 | + * @param string $username_unsafe |
|
222 | + */ |
|
216 | 223 | public static function db_user_by_username($username_unsafe, $for_update = false, $fields = '*', $player = null, $like = false) { |
217 | 224 | // TODO Проверить, кстати - а везде ли нужно выбирать юзеров или где-то все-таки ищутся Альянсы ? |
218 | 225 | if (!($username_unsafe = trim($username_unsafe))) { |
@@ -266,7 +273,6 @@ discard block |
||
266 | 273 | |
267 | 274 | /** |
268 | 275 | * @param $user_id |
269 | - * @param array $set |
|
270 | 276 | * @param array $adjust |
271 | 277 | * |
272 | 278 | * @return array|bool|mysqli_result|null |
@@ -283,8 +289,8 @@ discard block |
||
283 | 289 | * <p>array - запись пользователя с установленным полем ['id']</p> |
284 | 290 | * @param bool $for_update @deprecated |
285 | 291 | * @param string $fields @deprecated список полей или '*'/'' для всех полей |
286 | - * @param null $player |
|
287 | - * @param bool|null $player Признак выбора записи пользователь типа "игрок" |
|
292 | + * @param boolean $player |
|
293 | + * @param boolean $player Признак выбора записи пользователь типа "игрок" |
|
288 | 294 | * <p>null - Можно выбрать запись любого типа</p> |
289 | 295 | * <p>true - Выбирается только запись типа "игрок"</p> |
290 | 296 | * <p>false - Выбирается только запись типа "альянс"</p> |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | // TODO - remove or use something else |
40 | 40 | public static function renderNameAndCoordinates($playerArray) { |
41 | - return "{$playerArray['username']} " . uni_render_coordinates($playerArray); |
|
41 | + return "{$playerArray['username']} ".uni_render_coordinates($playerArray); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * @return int |
116 | 116 | */ |
117 | 117 | public static function db_user_count($online = false) { |
118 | - $iterator = static::playerSelectIterator('COUNT(`id`)', '', false, '', ($online ? '`onlinetime` > ' . (SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : '')); |
|
118 | + $iterator = static::playerSelectIterator('COUNT(`id`)', '', false, '', ($online ? '`onlinetime` > '.(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : '')); |
|
119 | 119 | |
120 | 120 | return intval(classSupernova::$db->getDbIteratorFirstValue($iterator)); |
121 | 121 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | LEFT JOIN |
129 | 129 | {{referrals}} as r on r.id_partner = u.id |
130 | 130 | WHERE " . |
131 | - ($online ? "`onlinetime` >= " . intval(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : 'user_as_ally IS NULL') . |
|
131 | + ($online ? "`onlinetime` >= ".intval(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : 'user_as_ally IS NULL'). |
|
132 | 132 | " GROUP BY u.id |
133 | 133 | ORDER BY user_as_ally, {$sort} ASC"; |
134 | 134 | $result = classSupernova::$db->doSelectIterator($query); |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | `{{users}}` |
146 | 146 | WHERE |
147 | 147 | `user_as_ally` IS NULL |
148 | - AND `user_bot` = " . USER_BOT_PLAYER . " |
|
148 | + AND `user_bot` = " . USER_BOT_PLAYER." |
|
149 | 149 | AND `user_birthday` IS NOT NULL |
150 | 150 | AND (`user_birthday_celebrated` IS NULL OR DATE_ADD(`user_birthday_celebrated`, INTERVAL 1 YEAR) < CURRENT_DATE) |
151 | 151 | HAVING |
@@ -166,8 +166,8 @@ discard block |
||
166 | 166 | $query = |
167 | 167 | "SELECT 1 |
168 | 168 | FROM `{{users}}` |
169 | - WHERE `id` = " . idval($user['id']) . |
|
170 | - (!empty($planet['id_owner']) ? ' OR `id` = ' . idval($planet['id_owner']) : '') . |
|
169 | + WHERE `id` = " . idval($user['id']). |
|
170 | + (!empty($planet['id_owner']) ? ' OR `id` = '.idval($planet['id_owner']) : ''). |
|
171 | 171 | " FOR UPDATE"; |
172 | 172 | |
173 | 173 | classSupernova::$db->doSelect($query); |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | $username_safe = db_escape($like ? strtolower($username_unsafe) : $username_unsafe); // тут на самом деле strtolower() лишняя, но пусть будет |
244 | 244 | |
245 | 245 | $user = classSupernova::$db->doSelectFetch( |
246 | - "SELECT * FROM {{users}} WHERE `username` " . ($like ? 'LIKE' : '=') . " '{$username_safe}'" |
|
246 | + "SELECT * FROM {{users}} WHERE `username` ".($like ? 'LIKE' : '=')." '{$username_safe}'" |
|
247 | 247 | . " FOR UPDATE" |
248 | 248 | ); |
249 | 249 | classSupernova::$gc->snCache->cache_set(LOC_USER, $user); // В кэш-юзер так же заполнять индексы |
@@ -187,6 +187,9 @@ |
||
187 | 187 | return $error_backtrace; |
188 | 188 | } |
189 | 189 | |
190 | + /** |
|
191 | + * @param string $die_message |
|
192 | + */ |
|
190 | 193 | public function error_fatal($die_message, $details = 'There is a fatal error on page') { |
191 | 194 | // TODO - Записывать детали ошибки в лог-файл |
192 | 195 | die($die_message); |
@@ -32,10 +32,10 @@ discard block |
||
32 | 32 | |
33 | 33 | defined('INSIDE') || die(); |
34 | 34 | |
35 | -if(php_sapi_name() == "cli") { |
|
35 | +if (php_sapi_name() == "cli") { |
|
36 | 36 | // In cli-mode |
37 | 37 | define('__DEBUG_CRLF', "\r\n"); |
38 | - define('__DEBUG_LINE', '-------------------------------------------------' . __DEBUG_CRLF); |
|
38 | + define('__DEBUG_LINE', '-------------------------------------------------'.__DEBUG_CRLF); |
|
39 | 39 | } else { |
40 | 40 | // Not in cli-mode |
41 | 41 | define('__DEBUG_CRLF', '<br />'); |
@@ -52,17 +52,17 @@ discard block |
||
52 | 52 | public function log_file($message, $ident_change = 0) { |
53 | 53 | static $ident = 0; |
54 | 54 | |
55 | - if(!defined('SN_DEBUG_LOG')) { |
|
55 | + if (!defined('SN_DEBUG_LOG')) { |
|
56 | 56 | return; |
57 | 57 | } |
58 | 58 | |
59 | - if($this->log_file_handler === null) { |
|
60 | - $this->log_file_handler = @fopen(SN_ROOT_PHYSICAL . '/.logs/supernova.log', 'a+'); |
|
59 | + if ($this->log_file_handler === null) { |
|
60 | + $this->log_file_handler = @fopen(SN_ROOT_PHYSICAL.'/.logs/supernova.log', 'a+'); |
|
61 | 61 | @fwrite($this->log_file_handler, "\r\n\r\n"); |
62 | 62 | } |
63 | 63 | $ident_change < 0 ? $ident += $ident_change * 2 : false; |
64 | - if($this->log_file_handler) { |
|
65 | - @fwrite($this->log_file_handler, date(FMT_DATE_TIME_SQL, time()) . str_repeat(' ', $ident + 1) . $message . "\r\n"); |
|
64 | + if ($this->log_file_handler) { |
|
65 | + @fwrite($this->log_file_handler, date(FMT_DATE_TIME_SQL, time()).str_repeat(' ', $ident + 1).$message."\r\n"); |
|
66 | 66 | } |
67 | 67 | $ident_change > 0 ? $ident += $ident_change * 2 : false; |
68 | 68 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | } |
83 | 83 | |
84 | 84 | public function echo_log() { |
85 | - echo '<br><table><tr><td class=k colspan=4><a href="' . SN_ROOT_PHYSICAL . "admin/settings.php\">Debug Log</a>:</td></tr>{$this->log}</table>"; |
|
85 | + echo '<br><table><tr><td class=k colspan=4><a href="'.SN_ROOT_PHYSICAL."admin/settings.php\">Debug Log</a>:</td></tr>{$this->log}</table>"; |
|
86 | 86 | die(); |
87 | 87 | } |
88 | 88 | |
@@ -92,25 +92,25 @@ discard block |
||
92 | 92 | $result = array(); |
93 | 93 | $transaction_id = classSupernova::$db->getTransaction()->getNextQueryTransactionId(); |
94 | 94 | $result[] = "tID {$transaction_id}"; |
95 | - foreach($backtrace as $a_trace) { |
|
96 | - if(in_array($a_trace['function'], $exclude_functions)) { |
|
95 | + foreach ($backtrace as $a_trace) { |
|
96 | + if (in_array($a_trace['function'], $exclude_functions)) { |
|
97 | 97 | continue; |
98 | 98 | } |
99 | 99 | $function = |
100 | 100 | ($a_trace['type'] |
101 | 101 | ? ($a_trace['type'] == '->' |
102 | - ? "({$a_trace['class']})" . get_class($a_trace['object']) |
|
102 | + ? "({$a_trace['class']})".get_class($a_trace['object']) |
|
103 | 103 | : $a_trace['class'] |
104 | - ) . $a_trace['type'] |
|
104 | + ).$a_trace['type'] |
|
105 | 105 | : '' |
106 | - ) . $a_trace['function'] . '()'; |
|
106 | + ).$a_trace['function'].'()'; |
|
107 | 107 | |
108 | 108 | $file = str_replace(SN_ROOT_PHYSICAL, '', str_replace('\\', '/', $a_trace['file'])); |
109 | 109 | |
110 | 110 | // $result[] = "{$function} ({$a_trace['line']})'{$file}'"; |
111 | 111 | $result[] = "{$function} - '{$file}' Line {$a_trace['line']}"; |
112 | 112 | |
113 | - if(!$long_comment) { |
|
113 | + if (!$long_comment) { |
|
114 | 114 | break; |
115 | 115 | } |
116 | 116 | } |
@@ -124,26 +124,26 @@ discard block |
||
124 | 124 | public function dump($dump = false, $force_base = false, $deadlock = false) { |
125 | 125 | global $user, $planetrow; |
126 | 126 | |
127 | - if($dump === false) { |
|
127 | + if ($dump === false) { |
|
128 | 128 | return; |
129 | 129 | } |
130 | 130 | |
131 | 131 | $error_backtrace = array(); |
132 | 132 | $base_dump = false; |
133 | 133 | |
134 | - if($force_base === true) { |
|
134 | + if ($force_base === true) { |
|
135 | 135 | $base_dump = true; |
136 | 136 | } |
137 | 137 | |
138 | - if($dump === true) { |
|
138 | + if ($dump === true) { |
|
139 | 139 | $base_dump = true; |
140 | 140 | } else { |
141 | - if(!is_array($dump)) { |
|
141 | + if (!is_array($dump)) { |
|
142 | 142 | $dump = array('var' => $dump); |
143 | 143 | } |
144 | 144 | |
145 | - foreach($dump as $dump_var_name => $dump_var) { |
|
146 | - if($dump_var_name == 'base_dump') { |
|
145 | + foreach ($dump as $dump_var_name => $dump_var) { |
|
146 | + if ($dump_var_name == 'base_dump') { |
|
147 | 147 | $base_dump = $dump_var; |
148 | 148 | } else { |
149 | 149 | $error_backtrace[$dump_var_name] = $dump_var; |
@@ -151,22 +151,21 @@ discard block |
||
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
154 | - if($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) { |
|
154 | + if ($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) { |
|
155 | 155 | $error_backtrace['deadlock'] = explode("\n", $q['Status']); |
156 | 156 | $error_backtrace['locks'] = classSupernova::$gc->snCache->getLocks(); |
157 | 157 | $error_backtrace['cSN_data'] = classSupernova::$gc->snCache->getData(); |
158 | - foreach($error_backtrace['cSN_data'] as &$location) { |
|
159 | - foreach($location as $location_id => &$location_data) { |
|
160 | - $location_data = isset($location_data['username']) ? $location_data['username'] : |
|
161 | - (isset($location_data['name']) ? $location_data['name'] : $location_id); |
|
158 | + foreach ($error_backtrace['cSN_data'] as &$location) { |
|
159 | + foreach ($location as $location_id => &$location_data) { |
|
160 | + $location_data = isset($location_data['username']) ? $location_data['username'] : (isset($location_data['name']) ? $location_data['name'] : $location_id); |
|
162 | 161 | } |
163 | 162 | } |
164 | 163 | $error_backtrace['cSN_queries'] = classSupernova::$gc->snCache->getQueries(); |
165 | 164 | } |
166 | 165 | |
167 | - if($base_dump) { |
|
168 | - if(is_array($this->log_array) && count($this->log_array) > 0) { |
|
169 | - foreach($this->log_array as $log) { |
|
166 | + if ($base_dump) { |
|
167 | + if (is_array($this->log_array) && count($this->log_array) > 0) { |
|
168 | + foreach ($this->log_array as $log) { |
|
170 | 169 | $error_backtrace['queries'][] = $log; |
171 | 170 | } |
172 | 171 | } |
@@ -195,14 +194,14 @@ discard block |
||
195 | 194 | public function error($message = 'There is a error on page', $title = 'Internal Error', $error_code = 500, $dump = true) { |
196 | 195 | global $sys_stop_log_hit, $sys_log_disabled, $user; |
197 | 196 | |
198 | - if(empty(classSupernova::$db->connected)) { |
|
197 | + if (empty(classSupernova::$db->connected)) { |
|
199 | 198 | // TODO - писать ошибку в файл |
200 | 199 | die('SQL server currently unavailable. Please contact Administration...'); |
201 | 200 | } |
202 | 201 | |
203 | 202 | sn_db_transaction_rollback(); |
204 | 203 | |
205 | - if(classSupernova::$config->debug == 1) { |
|
204 | + if (classSupernova::$config->debug == 1) { |
|
206 | 205 | echo "<h2>{$title}</h2><br><font color=red>{$message}</font><br><hr>"; |
207 | 206 | echo "<table>{$this->log}</table>"; |
208 | 207 | } |
@@ -214,16 +213,16 @@ discard block |
||
214 | 213 | |
215 | 214 | $userId = empty($user['id']) ? 0 : $user['id']; |
216 | 215 | |
217 | - if(!$sys_log_disabled) { |
|
216 | + if (!$sys_log_disabled) { |
|
218 | 217 | $query = "INSERT INTO `{{logs}}` SET |
219 | - `log_time` = '" . time() . "', `log_code` = '" . db_escape($error_code) . "', `log_sender` = '" . db_escape($userId) . "', |
|
220 | - `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "', `log_text` = '" . db_escape($message) . "', |
|
221 | - `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE))) . "'" . |
|
218 | + `log_time` = '" . time()."', `log_code` = '".db_escape($error_code)."', `log_sender` = '".db_escape($userId)."', |
|
219 | + `log_username` = '" . db_escape($user['user_name'])."', `log_title` = '".db_escape($title)."', `log_text` = '".db_escape($message)."', |
|
220 | + `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE)))."'". |
|
222 | 221 | // ($error_backtrace ? ", `log_dump` = '" . db_escape(serialize($error_backtrace)) . "'" : '') . ";"; |
223 | - ", `log_dump` = '" . ($error_backtrace ? db_escape(serialize($error_backtrace)) : '') . "'" . ";"; |
|
224 | - classSupernova::$db->doSql($query, true) or die($fatal_error . classSupernova::$db->db_error()); |
|
222 | + ", `log_dump` = '".($error_backtrace ? db_escape(serialize($error_backtrace)) : '')."'".";"; |
|
223 | + classSupernova::$db->doSql($query, true) or die($fatal_error.classSupernova::$db->db_error()); |
|
225 | 224 | |
226 | - $message = "Пожалуйста, свяжитесь с админом, если ошибка повторится. Ошибка №: <b>" . classSupernova::$db->db_insert_id() . "</b>"; |
|
225 | + $message = "Пожалуйста, свяжитесь с админом, если ошибка повторится. Ошибка №: <b>".classSupernova::$db->db_insert_id()."</b>"; |
|
227 | 226 | |
228 | 227 | $sys_stop_log_hit = true; |
229 | 228 | $sys_log_disabled = true; |
@@ -233,7 +232,7 @@ discard block |
||
233 | 232 | ob_start(); |
234 | 233 | print("<hr>User ID {$user['id']} raised error code {$error_code} titled '{$title}' with text '{$error_text}' on page {$_SERVER['SCRIPT_NAME']}"); |
235 | 234 | |
236 | - foreach($error_backtrace as $name => $value) { |
|
235 | + foreach ($error_backtrace as $name => $value) { |
|
237 | 236 | print(__DEBUG_LINE); |
238 | 237 | pdump($value, $name); |
239 | 238 | } |
@@ -245,7 +244,7 @@ discard block |
||
245 | 244 | public function warning($message, $title = 'System Message', $log_code = 300, $dump = false) { |
246 | 245 | global $user, $sys_log_disabled; |
247 | 246 | |
248 | - if(empty(classSupernova::$db->connected)) { |
|
247 | + if (empty(classSupernova::$db->connected)) { |
|
249 | 248 | // TODO - писать ошибку в файл |
250 | 249 | die('SQL server currently unavailable. Please contact Administration...'); |
251 | 250 | } |
@@ -254,12 +253,12 @@ discard block |
||
254 | 253 | |
255 | 254 | $userId = empty($user['id']) ? 0 : $user['id']; |
256 | 255 | |
257 | - if(!$sys_log_disabled) { |
|
256 | + if (!$sys_log_disabled) { |
|
258 | 257 | $query = "INSERT INTO `{{logs}}` SET |
259 | - `log_time` = '" . time() . "', `log_code` = '" . db_escape($log_code) . "', `log_sender` = '" . db_escape($userId) . "', |
|
260 | - `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "', `log_text` = '" . db_escape($message) . "', |
|
261 | - `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE))) . "'" . |
|
262 | - ", `log_dump` = '" . ($error_backtrace ? db_escape(serialize($error_backtrace)) : '') . "'" . ";"; |
|
258 | + `log_time` = '" . time()."', `log_code` = '".db_escape($log_code)."', `log_sender` = '".db_escape($userId)."', |
|
259 | + `log_username` = '" . db_escape($user['user_name'])."', `log_title` = '".db_escape($title)."', `log_text` = '".db_escape($message)."', |
|
260 | + `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE)))."'". |
|
261 | + ", `log_dump` = '".($error_backtrace ? db_escape(serialize($error_backtrace)) : '')."'".";"; |
|
263 | 262 | classSupernova::$db->doSql($query, true); |
264 | 263 | } else { |
265 | 264 | // // TODO Здесь надо писать в файло |
@@ -272,11 +271,11 @@ discard block |
||
272 | 271 | // Dump variables nicer then var_dump() |
273 | 272 | |
274 | 273 | function dump($value, $varname = null, $level = 0, $dumper = '') { |
275 | - if(isset($varname)) { |
|
274 | + if (isset($varname)) { |
|
276 | 275 | $varname .= " = "; |
277 | 276 | } |
278 | 277 | |
279 | - if($level == -1) { |
|
278 | + if ($level == -1) { |
|
280 | 279 | $trans[' '] = '∴'; |
281 | 280 | $trans["\t"] = '⇒'; |
282 | 281 | $trans["\n"] = '¶;'; |
@@ -285,31 +284,31 @@ discard block |
||
285 | 284 | |
286 | 285 | return strtr(htmlspecialchars($value), $trans); |
287 | 286 | } |
288 | - if($level == 0) { |
|
287 | + if ($level == 0) { |
|
289 | 288 | // $dumper = '<pre>' . mt_rand(10, 99) . '|' . $varname; |
290 | - $dumper = mt_rand(10, 99) . '|' . $varname; |
|
289 | + $dumper = mt_rand(10, 99).'|'.$varname; |
|
291 | 290 | } |
292 | 291 | |
293 | 292 | $type = gettype($value); |
294 | 293 | $dumper .= $type; |
295 | 294 | |
296 | - if($type == TYPE_STRING) { |
|
297 | - $dumper .= '(' . strlen($value) . ')'; |
|
295 | + if ($type == TYPE_STRING) { |
|
296 | + $dumper .= '('.strlen($value).')'; |
|
298 | 297 | $value = dump($value, '', -1); |
299 | - } elseif($type == TYPE_BOOLEAN) { |
|
298 | + } elseif ($type == TYPE_BOOLEAN) { |
|
300 | 299 | $value = ($value ? 'true' : 'false'); |
301 | - } elseif($type == 'object') { |
|
300 | + } elseif ($type == 'object') { |
|
302 | 301 | $props = get_class_vars(get_class($value)); |
303 | - $dumper .= '(' . count($props) . ') <u>' . get_class($value) . '</u>'; |
|
304 | - foreach($props as $key => $val) { |
|
305 | - $dumper .= "\n" . str_repeat("\t", $level + 1) . $key . ' => '; |
|
302 | + $dumper .= '('.count($props).') <u>'.get_class($value).'</u>'; |
|
303 | + foreach ($props as $key => $val) { |
|
304 | + $dumper .= "\n".str_repeat("\t", $level + 1).$key.' => '; |
|
306 | 305 | $dumper .= dump($value->$key, '', $level + 1); |
307 | 306 | } |
308 | 307 | $value = ''; |
309 | - } elseif($type == TYPE_ARRAY) { |
|
310 | - $dumper .= '(' . count($value) . ')'; |
|
311 | - foreach($value as $key => $val) { |
|
312 | - $dumper .= "\n" . str_repeat("\t", $level + 1) . dump($key, '', -1) . ' => '; |
|
308 | + } elseif ($type == TYPE_ARRAY) { |
|
309 | + $dumper .= '('.count($value).')'; |
|
310 | + foreach ($value as $key => $val) { |
|
311 | + $dumper .= "\n".str_repeat("\t", $level + 1).dump($key, '', -1).' => '; |
|
313 | 312 | $dumper .= dump($val, '', $level + 1); |
314 | 313 | } |
315 | 314 | $value = ''; |
@@ -328,24 +327,24 @@ discard block |
||
328 | 327 | // $backtrace = $backtrace[1]; |
329 | 328 | |
330 | 329 | $caller = ''; |
331 | - if(defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) { |
|
332 | - $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : '') . |
|
333 | - (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : '') . |
|
334 | - $backtrace[1]['function'] . |
|
330 | + if (defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) { |
|
331 | + $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : ''). |
|
332 | + (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : ''). |
|
333 | + $backtrace[1]['function']. |
|
335 | 334 | (!empty($backtrace[0]['file']) |
336 | 335 | ? ( |
337 | - ' (' . substr($backtrace[0]['file'], SN_ROOT_PHYSICAL_STR_LEN) . |
|
338 | - (!empty($backtrace[0]['line']) ? ':' . $backtrace[0]['line'] : '') . |
|
336 | + ' ('.substr($backtrace[0]['file'], SN_ROOT_PHYSICAL_STR_LEN). |
|
337 | + (!empty($backtrace[0]['line']) ? ':'.$backtrace[0]['line'] : ''). |
|
339 | 338 | ')' |
340 | 339 | ) |
341 | 340 | : '' |
342 | 341 | ); |
343 | - $caller = "\r\n" . $caller; |
|
342 | + $caller = "\r\n".$caller; |
|
344 | 343 | } |
345 | 344 | |
346 | - print('<pre style="text-align: left; background-color: #111111; color: #0A0; font-family: Courier, monospace !important; padding: 1em 0; font-weight: 800; font-size: 14px;">' . |
|
347 | - dump($value, $varname) . |
|
348 | - $caller . |
|
345 | + print('<pre style="text-align: left; background-color: #111111; color: #0A0; font-family: Courier, monospace !important; padding: 1em 0; font-weight: 800; font-size: 14px;">'. |
|
346 | + dump($value, $varname). |
|
347 | + $caller. |
|
349 | 348 | '</pre>' |
350 | 349 | ); |
351 | 350 | } |
@@ -355,24 +354,24 @@ discard block |
||
355 | 354 | } |
356 | 355 | |
357 | 356 | function pr($prePrint = false) { |
358 | - if($prePrint) { |
|
357 | + if ($prePrint) { |
|
359 | 358 | print(__DEBUG_CRLF); |
360 | 359 | } |
361 | - print(mt_rand() . __DEBUG_CRLF); |
|
360 | + print(mt_rand().__DEBUG_CRLF); |
|
362 | 361 | } |
363 | 362 | |
364 | 363 | function pc($prePrint = false) { |
365 | 364 | global $_PRINT_COUNT_VALUE; |
366 | 365 | $_PRINT_COUNT_VALUE++; |
367 | 366 | |
368 | - if($prePrint) { |
|
367 | + if ($prePrint) { |
|
369 | 368 | print(__DEBUG_CRLF); |
370 | 369 | } |
371 | - print($_PRINT_COUNT_VALUE . __DEBUG_CRLF); |
|
370 | + print($_PRINT_COUNT_VALUE.__DEBUG_CRLF); |
|
372 | 371 | } |
373 | 372 | |
374 | 373 | function prep($message) { |
375 | - print('<pre>' . $message . '</pre>'); |
|
374 | + print('<pre>'.$message.'</pre>'); |
|
376 | 375 | } |
377 | 376 | |
378 | 377 | function backtrace_no_arg() { |
@@ -396,9 +395,9 @@ discard block |
||
396 | 395 | */ |
397 | 396 | function pdie($message = '', $level = 0) { |
398 | 397 | $backtrace = debug_backtrace(); |
399 | - for($i = 0; $i < $level; $i++) { |
|
398 | + for ($i = 0; $i < $level; $i++) { |
|
400 | 399 | array_pop($backtrace); |
401 | 400 | } |
402 | 401 | |
403 | - die(__DEBUG_LINE . ($message ? $message . ' @ ' : '') . $backtrace[0]['file'] . ':' . $backtrace[0]['line']); |
|
402 | + die(__DEBUG_LINE.($message ? $message.' @ ' : '').$backtrace[0]['file'].':'.$backtrace[0]['line']); |
|
404 | 403 | } |
@@ -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 | } |
@@ -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 | - $comment_unsafe = $payment['payment_comment'] = classLocale::$lang['pay_msg_request_payment_cancelled'] .' ' . $payment['payment_comment']; |
|
794 | + if ($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) { |
|
795 | + $comment_unsafe = $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['payment_id'], $payment['payment_status'], $comment_unsafe); |
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 | } |
@@ -121,6 +121,9 @@ discard block |
||
121 | 121 | } |
122 | 122 | } |
123 | 123 | |
124 | + /** |
|
125 | + * @param string $filter |
|
126 | + */ |
|
124 | 127 | public static function queryCacheSetByFilter($location_type, $filter, $record_id) { |
125 | 128 | SnCache::$queries[$location_type][$filter][$record_id] = &SnCache::getDataRefByLocationAndId($location_type, $record_id); |
126 | 129 | } |
@@ -160,14 +163,23 @@ discard block |
||
160 | 163 | return true; // Не всегда - от результата |
161 | 164 | } |
162 | 165 | |
166 | + /** |
|
167 | + * @param integer $locationType |
|
168 | + */ |
|
163 | 169 | public static function getData($locationType = LOC_NONE) { |
164 | 170 | return $locationType == LOC_NONE ? static::$data : static::$data[$locationType]; |
165 | 171 | } |
166 | 172 | |
173 | + /** |
|
174 | + * @param integer $locationType |
|
175 | + */ |
|
167 | 176 | public static function cacheUnsetElement($locationType, $recordId) { |
168 | 177 | static::$data[$locationType][$recordId] = null; |
169 | 178 | } |
170 | 179 | |
180 | + /** |
|
181 | + * @param integer $locationType |
|
182 | + */ |
|
171 | 183 | public static function isArrayLocation($locationType) { |
172 | 184 | return is_array(static::$data[$locationType]); |
173 | 185 | } |
@@ -190,6 +202,9 @@ discard block |
||
190 | 202 | } |
191 | 203 | } |
192 | 204 | |
205 | + /** |
|
206 | + * @param integer $unit_snid |
|
207 | + */ |
|
193 | 208 | public static function getUnitLocator($location_type, $location_id, $unit_snid) { |
194 | 209 | return $unit_snid ? static::$locator[LOC_UNIT][$location_type][$location_id][$unit_snid] : static::$locator[LOC_UNIT][$location_type][$location_id]; |
195 | 210 | } |
@@ -222,14 +237,23 @@ discard block |
||
222 | 237 | return static::$locks; |
223 | 238 | } |
224 | 239 | |
240 | + /** |
|
241 | + * @param string $filter |
|
242 | + */ |
|
225 | 243 | public static function getQueriesByLocationAndFilter($locationType, $filter) { |
226 | 244 | return !empty(static::$queries[$locationType][$filter]) && is_array(static::$queries[$locationType][$filter]) ? static::$queries[$locationType][$filter] : array(); |
227 | 245 | } |
228 | 246 | |
247 | + /** |
|
248 | + * @param string $filter |
|
249 | + */ |
|
229 | 250 | public static function isQueryCacheByLocationAndFilterEmpty($locationType, $filter) { |
230 | 251 | return !isset(SnCache::$queries[$locationType][$filter]) || SnCache::$queries[$locationType][$filter] === null; |
231 | 252 | } |
232 | 253 | |
254 | + /** |
|
255 | + * @param string $filter |
|
256 | + */ |
|
233 | 257 | public static function queryCacheResetByLocationAndFilter($locationType, $filter) { |
234 | 258 | SnCache::$queries[$locationType][$filter] = array(); |
235 | 259 | } |
@@ -314,6 +314,9 @@ discard block |
||
314 | 314 | return $result; |
315 | 315 | } |
316 | 316 | |
317 | + /** |
|
318 | + * @param integer $location_type |
|
319 | + */ |
|
317 | 320 | public static function db_ins_field_set($location_type, $field_set, $serialize = false) { |
318 | 321 | // TODO multiinsert |
319 | 322 | !sn_db_field_set_is_safe($field_set) ? $field_set = sn_db_field_set_make_safe($field_set, $serialize) : false; |
@@ -350,7 +353,7 @@ discard block |
||
350 | 353 | /** |
351 | 354 | * Блокирует указанные таблицу/список таблиц |
352 | 355 | * |
353 | - * @param string|array $tables Таблица/список таблиц для блокировки. Названия таблиц - без префиксов |
|
356 | + * @param string $tables Таблица/список таблиц для блокировки. Названия таблиц - без префиксов |
|
354 | 357 | * <p>string - название таблицы для блокировки</p> |
355 | 358 | * <p>array - массив, где ключ - имя таблицы, а значение - условия блокировки элементов</p> |
356 | 359 | */ |
@@ -230,7 +230,7 @@ |
||
230 | 230 | array("distinct({{{$location_info[P_TABLE_NAME]}}}.{$owner_data[P_OWNER_FIELD]}) AS parent_id"), |
231 | 231 | $filter, |
232 | 232 | // Always selecting all records for correctly perform FILTER locks |
233 | - $fetch ? DB_RECORD_ONE : DB_RECORDS_ALL, |
|
233 | + $fetch ? DB_RECORD_ONE : DB_RECORDS_ALL, |
|
234 | 234 | // DB_RECORDS_ALL, |
235 | 235 | DB_SELECT_PLAIN |
236 | 236 | ); |
@@ -193,13 +193,13 @@ discard block |
||
193 | 193 | */ |
194 | 194 | // TODO - Change $filter to only array class |
195 | 195 | public function db_get_record_list($location_type, $filter = '', $fetch = false, $no_return = false) { |
196 | - if(is_array($filter)) { |
|
196 | + if (is_array($filter)) { |
|
197 | 197 | // TODO - TEMPORARY |
198 | 198 | $filterString = array(); |
199 | - if(!empty($filter)) { |
|
199 | + if (!empty($filter)) { |
|
200 | 200 | foreach ($filter as $key => $value) { |
201 | - if(!is_int($key)) { |
|
202 | - $value = "`$key` = '" . $this->db->db_escape($value). "'"; |
|
201 | + if (!is_int($key)) { |
|
202 | + $value = "`$key` = '".$this->db->db_escape($value)."'"; |
|
203 | 203 | } |
204 | 204 | $filterString[$key] = $value; |
205 | 205 | } |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | |
208 | 208 | $filterString = implode(',', $filterString); |
209 | 209 | } else { |
210 | - $filterString = $filter; |
|
210 | + $filterString = $filter; |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | |
@@ -238,8 +238,8 @@ discard block |
||
238 | 238 | $query = $this->db->doSelect( |
239 | 239 | "SELECT |
240 | 240 | distinct({{{$location_info[P_TABLE_NAME]}}}.{$owner_data[P_OWNER_FIELD]}) AS parent_id |
241 | - FROM {{{$location_info[P_TABLE_NAME]}}}" . |
|
242 | - ($filter ? ' WHERE ' . $filter : '') . |
|
241 | + FROM {{{$location_info[P_TABLE_NAME]}}}". |
|
242 | + ($filter ? ' WHERE '.$filter : ''). |
|
243 | 243 | ($fetch ? ' LIMIT 1' : '')); |
244 | 244 | } |
245 | 245 | while ($row = db_fetch($query)) { |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | $indexes_str = implode(',', $parent_id_list); |
255 | 255 | $parent_id_field = static::$location_info[$owner_location_type][P_ID]; |
256 | 256 | $this->db_get_record_list($owner_location_type, |
257 | - $parent_id_field . ( |
|
257 | + $parent_id_field.( |
|
258 | 258 | count($parent_id_list) > 1 |
259 | 259 | ? " IN ({$indexes_str})" |
260 | 260 | : " = {$indexes_str}" |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | ); |
278 | 278 | } else { |
279 | 279 | $query = $this->db->doSelect( |
280 | - "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}" . |
|
280 | + "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}". |
|
281 | 281 | (($filter = trim($filter)) ? " WHERE {$filter}" : '') |
282 | 282 | . " FOR UPDATE" |
283 | 283 | ); |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | public function db_lock_tables($tables) { |
456 | 456 | $tables = is_array($tables) ? $tables : array($tables => ''); |
457 | 457 | foreach ($tables as $table_name => $condition) { |
458 | - $this->db->doSelect("SELECT 1 FROM {{{$table_name}}}" . ($condition ? ' WHERE ' . $condition : '')); |
|
458 | + $this->db->doSelect("SELECT 1 FROM {{{$table_name}}}".($condition ? ' WHERE '.$condition : '')); |
|
459 | 459 | } |
460 | 460 | } |
461 | 461 | } |
@@ -298,9 +298,11 @@ |
||
298 | 298 | $set = trim($set); |
299 | 299 | $table_name = static::$location_info[$location_type][P_TABLE_NAME]; |
300 | 300 | if ($result = $this->db->doInsert("INSERT INTO `{{{$table_name}}}` SET {$set}")) { |
301 | - if ($this->db->db_affected_rows()) // Обновляем данные только если ряд был затронут |
|
301 | + if ($this->db->db_affected_rows()) { |
|
302 | + // Обновляем данные только если ряд был затронут |
|
302 | 303 | { |
303 | 304 | $record_id = $this->db->db_insert_id(); |
305 | + } |
|
304 | 306 | // Вытаскиваем запись целиком, потому что в $set могли быть "данные по умолчанию" |
305 | 307 | $result = $this->db_get_record_by_id($location_type, $record_id); |
306 | 308 | // Очищаем второстепенные кэши - потому что вставленная запись могла повлиять на результаты запросов или локация или еще чего |
@@ -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['.'])) |
@@ -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 | } |
@@ -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 | } |
@@ -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 | { |
@@ -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 |
@@ -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 | } |
@@ -118,7 +118,7 @@ |
||
118 | 118 | * @param mixed $offset <p> |
119 | 119 | * The offset to assign the value to. |
120 | 120 | * </p> |
121 | - * @param mixed $value <p> |
|
121 | + * @param Unit $value <p> |
|
122 | 122 | * The value to set. |
123 | 123 | * </p> |
124 | 124 | * |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | * Преобразовывает данные симулятора в данные для расчета боя |
460 | 460 | * |
461 | 461 | * @param $side_info |
462 | - * @param $attacker |
|
462 | + * @param boolean $attacker |
|
463 | 463 | * @param int $player_id |
464 | 464 | * |
465 | 465 | */ |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | } |
522 | 522 | |
523 | 523 | /** |
524 | - * @return int |
|
524 | + * @return double |
|
525 | 525 | */ |
526 | 526 | public function get_time_spent() { |
527 | 527 | return $this->time_spent; |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | } |
565 | 565 | |
566 | 566 | /** |
567 | - * @param $template |
|
567 | + * @param null|template $template |
|
568 | 568 | * |
569 | 569 | * @return template |
570 | 570 | */ |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | $this->players->db_load_player_by_id($player_id, UBE_PLAYER_IS_DEFENDER); |
148 | 148 | |
149 | 149 | $player_db_row = $this->players[$player_id]->getDbRow(); |
150 | - if($fortifier_level = mrc_get_level($player_db_row, $this->combatMission->dst_planet, MRC_FORTIFIER)) { |
|
150 | + if ($fortifier_level = mrc_get_level($player_db_row, $this->combatMission->dst_planet, MRC_FORTIFIER)) { |
|
151 | 151 | $this->planet_bonus->add_unit_by_snid(MRC_FORTIFIER, $fortifier_level); |
152 | 152 | } |
153 | 153 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | $this->rounds[0] = new UBERound(0); |
179 | 179 | $this->rounds[0]->make_snapshot($this->fleet_list); |
180 | 180 | |
181 | - for($round = 1; $round <= 10; $round++) { |
|
181 | + for ($round = 1; $round <= 10; $round++) { |
|
182 | 182 | // Проводим раунд |
183 | 183 | defined('DEBUG_UBE') ? print("Round {$round}<br>") : false; |
184 | 184 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | |
192 | 192 | // Анализируем итоги текущего раунда и готовим данные для следующего |
193 | 193 | $this->combat_result = $this->fleet_list->ubeAnalyzeFleetOutcome($round); |
194 | - if($this->combat_result != UBE_COMBAT_RESULT_DRAW) { |
|
194 | + if ($this->combat_result != UBE_COMBAT_RESULT_DRAW) { |
|
195 | 195 | break; |
196 | 196 | } |
197 | 197 | |
@@ -220,11 +220,11 @@ discard block |
||
220 | 220 | // Генерируем результат боя |
221 | 221 | $this->fleet_list->ube_analyze_fleets($this->is_simulator, $this->debris, $this->resource_exchange_rates); |
222 | 222 | |
223 | - if(!$this->is_ube_loaded) { |
|
223 | + if (!$this->is_ube_loaded) { |
|
224 | 224 | $this->moon_calculator->calculate_moon($this); |
225 | 225 | |
226 | 226 | // Лутаем ресурсы - если аттакер выиграл |
227 | - if($this->combat_result == UBE_COMBAT_RESULT_WIN) { |
|
227 | + if ($this->combat_result == UBE_COMBAT_RESULT_WIN) { |
|
228 | 228 | $this->sn_ube_combat_analyze_loot(); |
229 | 229 | } |
230 | 230 | } |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | RES_DEUTERIUM => 0, |
245 | 245 | ); |
246 | 246 | |
247 | - if( |
|
247 | + if ( |
|
248 | 248 | (($planet_resource_total = $this->fleet_list[0]->get_resources_amount()) > 0) |
249 | 249 | && |
250 | 250 | (($total_capacity = $this->fleet_list->ube_get_capacity_attackers()) > 0) |
@@ -256,9 +256,9 @@ discard block |
||
256 | 256 | $planet_lootable_percent = $planet_lootable / $planet_resource_total; |
257 | 257 | |
258 | 258 | // Вычисляем сколько ресурсов вывезено |
259 | - foreach($this->fleet_list->_container as $fleet_id => $fleet) { |
|
259 | + foreach ($this->fleet_list->_container as $fleet_id => $fleet) { |
|
260 | 260 | $looted_in_metal = 0; |
261 | - foreach($this->fleet_list[0]->resource_list as $resource_id => $resource_amount) { |
|
261 | + foreach ($this->fleet_list[0]->resource_list as $resource_id => $resource_amount) { |
|
262 | 262 | // Вычисляем какой процент общей емкости трюмов атакующих будет задействован |
263 | 263 | $fleet_lootable_percent = $fleet->fleet_capacity / $total_capacity; |
264 | 264 | $looted = floor($resource_amount * $planet_lootable_percent * $fleet_lootable_percent); |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | $destination_user_id = $this->fleet_list[0]->owner_id; |
324 | 324 | |
325 | 325 | // Обновляем поле обломков на планете |
326 | - if(!$this->is_admin_in_combat && $this->debris->debris_total() > 0) { |
|
326 | + if (!$this->is_admin_in_combat && $this->debris->debris_total() > 0) { |
|
327 | 327 | DBStaticPlanet::db_planet_update_by_gspt( |
328 | 328 | $this->ube_planet_info[PLANET_GALAXY], $this->ube_planet_info[PLANET_SYSTEM], $this->ube_planet_info[PLANET_PLANET], PT_PLANET, |
329 | 329 | array(), |
@@ -334,10 +334,10 @@ discard block |
||
334 | 334 | ); |
335 | 335 | } |
336 | 336 | |
337 | - foreach($this->fleet_list->_container as $fleet_id => $UBEFleet) { |
|
337 | + foreach ($this->fleet_list->_container as $fleet_id => $UBEFleet) { |
|
338 | 338 | $ship_count_lost = $UBEFleet->unit_list->unitCountLost(); |
339 | 339 | |
340 | - if($fleet_id) { |
|
340 | + if ($fleet_id) { |
|
341 | 341 | // Флот |
342 | 342 | $UBEFleet->db_save_combat_result_fleet($this->is_small_fleet_recce, $this->moon_calculator->get_reapers_status()); |
343 | 343 | } else { |
@@ -345,18 +345,18 @@ discard block |
||
345 | 345 | |
346 | 346 | // Сохраняем изменения ресурсов - если они есть |
347 | 347 | $resource_delta = $UBEFleet->ube_combat_result_calculate_resources(); |
348 | - if(!empty($resource_delta)) { |
|
348 | + if (!empty($resource_delta)) { |
|
349 | 349 | $temp = array(); |
350 | - foreach($resource_delta as $resource_id => $resource_amount) { |
|
350 | + foreach ($resource_delta as $resource_id => $resource_amount) { |
|
351 | 351 | $resource_db_name = pname_resource_name($resource_id); |
352 | 352 | $temp[] = "`{$resource_db_name}` = `{$resource_db_name}` + ({$resource_amount})"; |
353 | 353 | } |
354 | 354 | DBStaticPlanet::db_planet_update_set_by_id_DEPRECATED($this->ube_planet_info[PLANET_ID], implode(',', $temp)); |
355 | 355 | } |
356 | 356 | |
357 | - if($ship_count_lost) { |
|
357 | + if ($ship_count_lost) { |
|
358 | 358 | $planet_row_cache = $this->players[$destination_user_id]->getDbRow(); |
359 | - foreach($UBEFleet->unit_list->_container as $UBEUnit) { |
|
359 | + foreach ($UBEFleet->unit_list->_container as $UBEUnit) { |
|
360 | 360 | DBStaticUnit::dbUpdateOrInsertUnit($UBEUnit->unitId, -$UBEUnit->units_lost, $planet_row_cache, $this->ube_planet_info[PLANET_ID]); |
361 | 361 | } |
362 | 362 | } |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | // TODO: Связать сабы с флотами констраинтами ON DELETE SET NULL |
367 | 367 | // Для САБов |
368 | 368 | $fleet_group_id_list = $this->fleet_list->ube_get_groups(); |
369 | - if(!empty($fleet_group_id_list)) { |
|
369 | + if (!empty($fleet_group_id_list)) { |
|
370 | 370 | $fleet_group_id_list = implode(',', $fleet_group_id_list); |
371 | 371 | DBStaticFleetACS::db_acs_delete_by_list($fleet_group_id_list); |
372 | 372 | } |
@@ -375,19 +375,19 @@ discard block |
||
375 | 375 | |
376 | 376 | $bashing_list = array(); |
377 | 377 | $players_sides = $this->players->get_player_sides(); |
378 | - foreach($players_sides as $player_id => $player_side) { |
|
379 | - if($player_side != UBE_PLAYER_IS_ATTACKER) { |
|
378 | + foreach ($players_sides as $player_id => $player_side) { |
|
379 | + if ($player_side != UBE_PLAYER_IS_ATTACKER) { |
|
380 | 380 | continue; |
381 | 381 | } |
382 | - if($this->moon_calculator->get_status() != UBE_MOON_DESTROY_SUCCESS) { |
|
382 | + if ($this->moon_calculator->get_status() != UBE_MOON_DESTROY_SUCCESS) { |
|
383 | 383 | $bashing_list[] = "({$player_id}, {$this->ube_planet_info[PLANET_ID]}, {$this->combat_timestamp})"; |
384 | 384 | } |
385 | - if($this->mission_type_id == MT_ATTACK && $this->is_defender_active_player) { |
|
385 | + if ($this->mission_type_id == MT_ATTACK && $this->is_defender_active_player) { |
|
386 | 386 | $str_loose_or_win = $this->combat_result == UBE_COMBAT_RESULT_WIN ? 'raidswin' : 'raidsloose'; |
387 | 387 | DBStaticUser::db_user_set_by_id_DEPRECATED($player_id, "`xpraid` = `xpraid` + 1, `raids` = `raids` + 1, `{$str_loose_or_win}` = `{$str_loose_or_win}` + 1"); |
388 | 388 | } |
389 | 389 | } |
390 | - if(!empty($bashing_list)) { |
|
390 | + if (!empty($bashing_list)) { |
|
391 | 391 | DBStaticFleetBashing::db_bashing_insert($bashing_list); |
392 | 392 | } |
393 | 393 | |
@@ -413,20 +413,19 @@ discard block |
||
413 | 413 | $planet_info[PLANET_SYSTEM], |
414 | 414 | $planet_info[PLANET_PLANET], |
415 | 415 | htmlentities($planet_info[PLANET_NAME], ENT_COMPAT, 'UTF-8'), |
416 | - classLocale::$lang[$this->combat_result == UBE_COMBAT_RESULT_WIN ? 'ube_report_info_outcome_win' : |
|
417 | - ($this->combat_result == UBE_COMBAT_RESULT_DRAW ? 'ube_report_info_outcome_draw' : 'ube_report_info_outcome_loss')] |
|
416 | + classLocale::$lang[$this->combat_result == UBE_COMBAT_RESULT_WIN ? 'ube_report_info_outcome_win' : ($this->combat_result == UBE_COMBAT_RESULT_DRAW ? 'ube_report_info_outcome_draw' : 'ube_report_info_outcome_loss')] |
|
418 | 417 | ); |
419 | 418 | |
420 | 419 | $text_defender = ''; |
421 | 420 | $debris = $this->debris->get_debris(); |
422 | - foreach($debris as $resource_id => $resource_amount) { |
|
423 | - if($resource_id == RES_DEUTERIUM) { |
|
421 | + foreach ($debris as $resource_id => $resource_amount) { |
|
422 | + if ($resource_id == RES_DEUTERIUM) { |
|
424 | 423 | continue; |
425 | 424 | } |
426 | 425 | |
427 | - $text_defender .= "{$classLocale['tech'][$resource_id]}: " . pretty_number($resource_amount) . '<br />'; |
|
426 | + $text_defender .= "{$classLocale['tech'][$resource_id]}: ".pretty_number($resource_amount).'<br />'; |
|
428 | 427 | } |
429 | - if($text_defender) { |
|
428 | + if ($text_defender) { |
|
430 | 429 | $text_defender = "{$classLocale['ube_report_msg_body_debris']}{$text_defender}<br />"; |
431 | 430 | } |
432 | 431 | |
@@ -436,8 +435,8 @@ discard block |
||
436 | 435 | |
437 | 436 | // TODO: Оптимизировать отсылку сообщений - отсылать пакетами |
438 | 437 | $player_sides = $this->players->get_player_sides(); |
439 | - foreach($player_sides as $player_id => $player_side) { |
|
440 | - $message = $text_common . ($this->is_small_fleet_recce && ($player_side == UBE_PLAYER_IS_ATTACKER) ? classLocale::$lang['ube_report_msg_body_sfr'] : $text_defender); |
|
438 | + foreach ($player_sides as $player_id => $player_side) { |
|
439 | + $message = $text_common.($this->is_small_fleet_recce && ($player_side == UBE_PLAYER_IS_ATTACKER) ? classLocale::$lang['ube_report_msg_body_sfr'] : $text_defender); |
|
441 | 440 | DBStaticMessages::msg_send_simple_message($player_id, '', $this->combat_timestamp, MSG_TYPE_COMBAT, classLocale::$lang['sys_mess_tower'], classLocale::$lang['sys_mess_attack_report'], $message); |
442 | 441 | } |
443 | 442 | |
@@ -472,11 +471,11 @@ discard block |
||
472 | 471 | $player_id = $player_id == -1 ? $this->players->count() : $player_id; |
473 | 472 | $fleet_id = $player_id; // FOR SIMULATOR! |
474 | 473 | |
475 | - if(empty($this->players[$player_id])) { |
|
474 | + if (empty($this->players[$player_id])) { |
|
476 | 475 | $this->players[$player_id] = new UBEPlayer(); |
477 | 476 | } |
478 | 477 | |
479 | - foreach($side_info as $fleet_data) { |
|
478 | + foreach ($side_info as $fleet_data) { |
|
480 | 479 | $this->players[$player_id]->name = $player_id; |
481 | 480 | $this->players[$player_id]->setSide($attacker); |
482 | 481 | |
@@ -484,32 +483,32 @@ discard block |
||
484 | 483 | $this->fleet_list[$fleet_id] = $objFleet; |
485 | 484 | |
486 | 485 | $this->fleet_list[$fleet_id]->owner_id = $player_id; |
487 | - foreach($fleet_data as $unit_id => $unit_count) { |
|
488 | - if(!$unit_count) { |
|
486 | + foreach ($fleet_data as $unit_id => $unit_count) { |
|
487 | + if (!$unit_count) { |
|
489 | 488 | continue; |
490 | 489 | } |
491 | 490 | |
492 | 491 | $unit_type = get_unit_param($unit_id, P_UNIT_TYPE); |
493 | 492 | |
494 | - if($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) { |
|
493 | + if ($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) { |
|
495 | 494 | $this->fleet_list[$fleet_id]->unit_list->unitAdjustCount($unit_id, $unit_count); |
496 | - } elseif($unit_type == UNIT_RESOURCES) { |
|
495 | + } elseif ($unit_type == UNIT_RESOURCES) { |
|
497 | 496 | $this->fleet_list[$fleet_id]->resource_list[$unit_id] = $unit_count; |
498 | - } elseif($unit_type == UNIT_TECHNOLOGIES) { |
|
499 | - if($unit_id == TECH_WEAPON) { |
|
497 | + } elseif ($unit_type == UNIT_TECHNOLOGIES) { |
|
498 | + if ($unit_id == TECH_WEAPON) { |
|
500 | 499 | $this->players[$player_id]->player_bonus->add_unit_by_snid(TECH_WEAPON, $unit_count); |
501 | - } elseif($unit_id == TECH_SHIELD) { |
|
500 | + } elseif ($unit_id == TECH_SHIELD) { |
|
502 | 501 | $this->players[$player_id]->player_bonus->add_unit_by_snid(TECH_SHIELD, $unit_count); |
503 | - } elseif($unit_id == TECH_ARMOR) { |
|
502 | + } elseif ($unit_id == TECH_ARMOR) { |
|
504 | 503 | $this->players[$player_id]->player_bonus->add_unit_by_snid(TECH_ARMOR, $unit_count); |
505 | 504 | } |
506 | - } elseif($unit_type == UNIT_GOVERNORS) { |
|
507 | - if($unit_id == MRC_FORTIFIER) { |
|
505 | + } elseif ($unit_type == UNIT_GOVERNORS) { |
|
506 | + if ($unit_id == MRC_FORTIFIER) { |
|
508 | 507 | // Фортифаер даёт бонус ко всему |
509 | 508 | $this->planet_bonus->add_unit_by_snid(MRC_FORTIFIER, $unit_count); |
510 | 509 | } |
511 | - } elseif($unit_type == UNIT_MERCENARIES) { |
|
512 | - if($unit_id == MRC_ADMIRAL) { |
|
510 | + } elseif ($unit_type == UNIT_MERCENARIES) { |
|
511 | + if ($unit_id == MRC_ADMIRAL) { |
|
513 | 512 | $this->players[$player_id]->player_bonus->add_unit_by_snid(MRC_ADMIRAL, $unit_count); |
514 | 513 | } |
515 | 514 | } |
@@ -563,7 +562,7 @@ discard block |
||
563 | 562 | |
564 | 563 | $ube->sn_ube_message_send(); |
565 | 564 | |
566 | - defined('DEBUG_UBE') ? die('DIE at ' . __FILE__ . ' ' . __LINE__) : false; |
|
565 | + defined('DEBUG_UBE') ? die('DIE at '.__FILE__.' '.__LINE__) : false; |
|
567 | 566 | |
568 | 567 | return false; |
569 | 568 | } |
@@ -578,7 +577,7 @@ discard block |
||
578 | 577 | |
579 | 578 | $ube_report = new UBEReport(); |
580 | 579 | $ube = $ube_report->sn_ube_report_load(sys_get_param_str('cypher')); |
581 | - if($ube != UBE_REPORT_NOT_FOUND) { |
|
580 | + if ($ube != UBE_REPORT_NOT_FOUND) { |
|
582 | 581 | $ube_report->sn_ube_report_generate($ube, $template_result); |
583 | 582 | |
584 | 583 | $template = gettemplate('ube_combat_report', $template); |
@@ -606,9 +605,9 @@ discard block |
||
606 | 605 | $ube->sn_ube_combat(); |
607 | 606 | $ube_report = new UBEReport(); |
608 | 607 | |
609 | - if(sys_get_param_str('reload')) { |
|
608 | + if (sys_get_param_str('reload')) { |
|
610 | 609 | $ube_new = $ube_report->sn_ube_report_load($ube->get_cypher()); // $combat_data = sn_ube_report_load($combat_data[UBE_REPORT_CYPHER]); |
611 | - if($ube_new != UBE_REPORT_NOT_FOUND && is_object($ube_new)) { |
|
610 | + if ($ube_new != UBE_REPORT_NOT_FOUND && is_object($ube_new)) { |
|
612 | 611 | $ube = $ube_new; |
613 | 612 | } |
614 | 613 | } |
@@ -656,7 +655,7 @@ discard block |
||
656 | 655 | $this->debris->load_from_report_row($report_row); |
657 | 656 | |
658 | 657 | $query = classSupernova::$db->doSelect("SELECT * FROM {{ube_report_player}} WHERE `ube_report_id` = {$report_row['ube_report_id']}"); |
659 | - while($player_row = db_fetch($query)) { |
|
658 | + while ($player_row = db_fetch($query)) { |
|
660 | 659 | $this->players->init_player_from_report_info($player_row); |
661 | 660 | } |
662 | 661 |