@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | */ |
10 | 10 | |
11 | 11 | $allow_anonymous = true; |
12 | -include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
|
12 | +include('common.'.substr(strrchr(__FILE__, '.'), 1)); |
|
13 | 13 | |
14 | 14 | global $config; |
15 | 15 | |
@@ -23,40 +23,40 @@ discard block |
||
23 | 23 | $mode = sys_get_param_str('mode'); |
24 | 24 | |
25 | 25 | $announce = array(); |
26 | -if($user['authlevel'] >= 3) { |
|
27 | - if(!empty($text)) { |
|
26 | +if ($user['authlevel'] >= 3) { |
|
27 | + if (!empty($text)) { |
|
28 | 28 | $announce_time = strtotime($announce_time, SN_TIME_NOW); |
29 | 29 | $announce_time = $announce_time ? $announce_time : SN_TIME_NOW; |
30 | 30 | |
31 | - if($mode == 'edit') { |
|
31 | + if ($mode == 'edit') { |
|
32 | 32 | DBStaticNews::db_news_update_set($announce_time, $text, $detail_url, $announce_id); |
33 | 33 | DBStaticSurvey::db_survey_delete_by_id($announce_id); |
34 | 34 | } else { |
35 | 35 | DBStaticNews::db_news_insert_set($announce_time, $text, $detail_url, $user); |
36 | 36 | $announce_id = db_insert_id(); |
37 | 37 | } |
38 | - if(($survey_question = sys_get_param_str('survey_question')) && ($survey_answers = sys_get_param('survey_answers'))) { |
|
38 | + if (($survey_question = sys_get_param_str('survey_question')) && ($survey_answers = sys_get_param('survey_answers'))) { |
|
39 | 39 | $survey_answers = explode("\r\n", $survey_answers); |
40 | 40 | $survey_until = strtotime($survey_until = sys_get_param_str('survey_until'), SN_TIME_NOW); |
41 | 41 | $survey_until = date(FMT_DATE_TIME_SQL, $survey_until ? $survey_until : SN_TIME_NOW + PERIOD_DAY * 1); |
42 | 42 | DBStaticSurvey::db_survey_insert($announce_id, $survey_question, $survey_until); |
43 | 43 | $survey_id = db_insert_id(); |
44 | - foreach($survey_answers as $survey_answer) { |
|
44 | + foreach ($survey_answers as $survey_answer) { |
|
45 | 45 | $survey_answer = db_escape(trim($survey_answer)); |
46 | - if(empty($survey_answer)) { |
|
46 | + if (empty($survey_answer)) { |
|
47 | 47 | continue; |
48 | 48 | } |
49 | 49 | DBStaticSurveyAnswer::db_survey_answer_insert($survey_id, $survey_answer); |
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
53 | - if($announce_time <= SN_TIME_NOW) { |
|
54 | - if($announce_time > $config->var_news_last && $announce_time == SN_TIME_NOW) { |
|
53 | + if ($announce_time <= SN_TIME_NOW) { |
|
54 | + if ($announce_time > $config->var_news_last && $announce_time == SN_TIME_NOW) { |
|
55 | 55 | $config->db_saveItem('var_news_last', $announce_time); |
56 | 56 | } |
57 | 57 | |
58 | - if(sys_get_param_int('news_mass_mail')) { |
|
59 | - $text = sys_get_param('text') . ($detail_url ? " <a href=\"{$detail_url}\"><span class=\"positive\">{$lang['news_more']}</span></a>" : ''); |
|
58 | + if (sys_get_param_int('news_mass_mail')) { |
|
59 | + $text = sys_get_param('text').($detail_url ? " <a href=\"{$detail_url}\"><span class=\"positive\">{$lang['news_more']}</span></a>" : ''); |
|
60 | 60 | msg_send_simple_message('*', 0, 0, MSG_TYPE_ADMIN, $lang['sys_administration'], $lang['news_title'], $text); |
61 | 61 | } |
62 | 62 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | } |
67 | 67 | |
68 | 68 | $survey_answers = ''; |
69 | - switch($mode) { |
|
69 | + switch ($mode) { |
|
70 | 70 | case 'del': |
71 | 71 | DBStaticNews::db_news_delete_by_id($announce_id); |
72 | 72 | $mode = ''; |
@@ -76,9 +76,9 @@ discard block |
||
76 | 76 | $template->assign_var('ID', $announce_id); |
77 | 77 | case 'copy': |
78 | 78 | $announce = DBStaticNews::db_news_with_survey_select_by_id($announce_id); |
79 | - if($announce['survey_id']) { |
|
79 | + if ($announce['survey_id']) { |
|
80 | 80 | $query = DBStaticSurveyAnswer::db_survey_answer_text_select_by_news($announce); |
81 | - while($row = db_fetch($query)) { |
|
81 | + while ($row = db_fetch($query)) { |
|
82 | 82 | $survey_answers[] = $row['survey_answer_text']; |
83 | 83 | } |
84 | 84 | $survey_answers = implode("\r\n", $survey_answers); |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | break; |
87 | 87 | } |
88 | 88 | } else { |
89 | - $annQuery = 'WHERE UNIX_TIMESTAMP(`tsTimeStamp`) <= ' . SN_TIME_NOW; |
|
89 | + $annQuery = 'WHERE UNIX_TIMESTAMP(`tsTimeStamp`) <= '.SN_TIME_NOW; |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | nws_render($template, $annQuery, 20); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
94 | - * @param array $where |
|
94 | + * @param string[] $where |
|
95 | 95 | * @param mixed|array $fieldList |
96 | 96 | * Field list can be scalar - it would be converted to array and used as field name |
97 | 97 | * @param bool $for_update |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
132 | - * @param int|string $recordId |
|
133 | - * @param mixed|array $fieldList |
|
132 | + * @param integer $recordId |
|
133 | + * @param string[] $fieldList |
|
134 | 134 | * @param bool $forUpdate |
135 | 135 | * |
136 | 136 | * @return array|null |
@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | $result[] = 'NULL'; |
46 | 46 | break; |
47 | 47 | default: |
48 | - $string = (string)$fieldName; |
|
48 | + $string = (string) $fieldName; |
|
49 | 49 | if ($string == '') { |
50 | 50 | throw new ExceptionDBFieldEmpty(); |
51 | 51 | } |
52 | - $result[] = '`' . $string . '`'; |
|
52 | + $result[] = '`'.$string.'`'; |
|
53 | 53 | } |
54 | 54 | } |
55 | 55 | } else { |
@@ -77,10 +77,10 @@ discard block |
||
77 | 77 | if (!empty($fieldList)) { |
78 | 78 | $user_record = self::$dbStatic->doquery( |
79 | 79 | ( |
80 | - "SELECT {$fieldList}" . |
|
81 | - " FROM {{" . self::$_table . "}}" . |
|
82 | - (!empty($where) ? " WHERE {$where}" : '') . |
|
83 | - (!empty($for_update) ? " FOR UPDATE" : '') . |
|
80 | + "SELECT {$fieldList}". |
|
81 | + " FROM {{".self::$_table."}}". |
|
82 | + (!empty($where) ? " WHERE {$where}" : ''). |
|
83 | + (!empty($for_update) ? " FOR UPDATE" : ''). |
|
84 | 84 | ($returnFirst ? ' LIMIT 1' : '') |
85 | 85 | ), |
86 | 86 | $returnFirst |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | */ |
138 | 138 | public static function getRecordById($recordId, $fieldList = '*', $forUpdate = false) { |
139 | 139 | // return static::getRecord(array(static::$_idField => $recordId), $fieldList, $forUpdate); |
140 | - return static::getRecord(array(static::$_idField . '=' . $recordId), $fieldList, $forUpdate); |
|
140 | + return static::getRecord(array(static::$_idField.'='.$recordId), $fieldList, $forUpdate); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | public static function queryExistsIdInList($idList) { |
150 | 150 | $query = null; |
151 | 151 | if (!empty($idList)) { |
152 | - $query = self::$dbStatic->doquery("SELECT `" . static::$_idField . "` FROM `{{" . static::$_table . "}}` WHERE `" . static::$_idField . "` IN (" . implode(',', $idList) . ")"); |
|
152 | + $query = self::$dbStatic->doquery("SELECT `".static::$_idField."` FROM `{{".static::$_table."}}` WHERE `".static::$_idField."` IN (".implode(',', $idList).")"); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | return !empty($query) ? $query : null; |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * @param $note_id_edit |
37 | 37 | */ |
38 | 38 | public static function db_note_update_by_id($note_priority, $note_title, $note_text, $note_galaxy, $note_system, $note_planet, $note_planet_type, $note_sticky, $note_id_edit) { |
39 | - doquery("UPDATE {{notes}} SET `time` = " . SN_TIME_NOW . ", `priority` = {$note_priority}, `title` = '{$note_title}', `text` = '{$note_text}', |
|
39 | + doquery("UPDATE {{notes}} SET `time` = ".SN_TIME_NOW.", `priority` = {$note_priority}, `title` = '{$note_title}', `text` = '{$note_text}', |
|
40 | 40 | `galaxy` = {$note_galaxy}, `system` = {$note_system}, `planet` = {$note_planet}, `planet_type` = {$note_planet_type}, `sticky` = {$note_sticky} |
41 | 41 | WHERE `id` = {$note_id_edit} LIMIT 1;"); |
42 | 42 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * @param $note_sticky |
54 | 54 | */ |
55 | 55 | public static function db_note_insert($user, $note_priority, $note_title, $note_text, $note_galaxy, $note_system, $note_planet, $note_planet_type, $note_sticky) { |
56 | - doquery("INSERT INTO {{notes}} SET `owner` = {$user['id']}, `time` = " . SN_TIME_NOW . ", `priority` = {$note_priority}, `title` = '{$note_title}', `text` = '{$note_text}', |
|
56 | + doquery("INSERT INTO {{notes}} SET `owner` = {$user['id']}, `time` = ".SN_TIME_NOW.", `priority` = {$note_priority}, `title` = '{$note_title}', `text` = '{$note_text}', |
|
57 | 57 | `galaxy` = {$note_galaxy}, `system` = {$note_system}, `planet` = {$note_planet}, `planet_type` = {$note_planet_type}, `sticky` = {$note_sticky};"); |
58 | 58 | } |
59 | 59 |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public static function build($db = null, $className = '') { |
46 | 46 | $result = new self($db); |
47 | - if(!empty($className) && is_string($className)) { |
|
47 | + if (!empty($className) && is_string($className)) { |
|
48 | 48 | $result->getParamsFromStaticClass($className); |
49 | 49 | } |
50 | 50 | return $result; |
@@ -186,23 +186,23 @@ discard block |
||
186 | 186 | $result = ''; |
187 | 187 | $result .= $this->stringEscape($this->operation); |
188 | 188 | |
189 | - $result .= ' ' . $this->selectFieldsToString($this->fields); |
|
189 | + $result .= ' '.$this->selectFieldsToString($this->fields); |
|
190 | 190 | |
191 | 191 | $result .= ' FROM'; |
192 | - $result .= ' `{{' . $this->stringEscape($this->table) . '}}`'; |
|
193 | - $result .= !empty($this->alias) ? ' AS `' . $this->stringEscape($this->alias) . '`' : ''; |
|
192 | + $result .= ' `{{'.$this->stringEscape($this->table).'}}`'; |
|
193 | + $result .= !empty($this->alias) ? ' AS `'.$this->stringEscape($this->alias).'`' : ''; |
|
194 | 194 | |
195 | 195 | // TODO - fields should be escaped !! |
196 | - $result .= !empty($this->where) ? ' WHERE ' . implode(' AND ', $this->where) : ''; |
|
196 | + $result .= !empty($this->where) ? ' WHERE '.implode(' AND ', $this->where) : ''; |
|
197 | 197 | |
198 | 198 | // TODO - fields should be escaped !! |
199 | - $result .= !empty($this->group) ? ' GROUP BY ' . implode(',', $this->group) : ''; |
|
199 | + $result .= !empty($this->group) ? ' GROUP BY '.implode(',', $this->group) : ''; |
|
200 | 200 | |
201 | 201 | // TODO - fields should be escaped !! |
202 | - $result .= !empty($this->order) ? ' ORDER BY ' . implode(',', $this->order) : ''; |
|
202 | + $result .= !empty($this->order) ? ' ORDER BY '.implode(',', $this->order) : ''; |
|
203 | 203 | |
204 | 204 | // TODO - fields should be escaped !! |
205 | - $result .= !empty($this->limit) ? ' LIMIT ' . implode(',', $this->limit) : ''; |
|
205 | + $result .= !empty($this->limit) ? ' LIMIT '.implode(',', $this->limit) : ''; |
|
206 | 206 | |
207 | 207 | // TODO - protect from double escape! |
208 | 208 | |
@@ -240,17 +240,17 @@ discard block |
||
240 | 240 | break; |
241 | 241 | |
242 | 242 | default: |
243 | - $string = (string)$fieldName; |
|
243 | + $string = (string) $fieldName; |
|
244 | 244 | if ($string == '') { |
245 | 245 | continue; |
246 | 246 | } |
247 | 247 | |
248 | - if($fieldName instanceof DbSqlLiteral) { |
|
248 | + if ($fieldName instanceof DbSqlLiteral) { |
|
249 | 249 | // Literals plays as they are - they do properly format by itself |
250 | 250 | $result[] = $string; |
251 | 251 | } else { |
252 | 252 | // Other should be formatted |
253 | - $result[] = '`' . $this->stringEscape($string) . '`'; |
|
253 | + $result[] = '`'.$this->stringEscape($string).'`'; |
|
254 | 254 | } |
255 | 255 | } |
256 | 256 | } |