1 | <?php |
||||
2 | /** @noinspection PhpUnnecessaryCurlyVarSyntaxInspection */ |
||||
3 | |||||
4 | /** |
||||
5 | * announce.php |
||||
6 | * |
||||
7 | * @copyright (c) 2010-2016 Gorlum for http://supernova.ws |
||||
8 | */ |
||||
9 | |||||
10 | $allow_anonymous = true; |
||||
11 | include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
||||
12 | |||||
13 | global $config, $lang; |
||||
14 | |||||
15 | nws_mark_read($user); |
||||
16 | $template = SnTemplate::gettemplate('announce', true); |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
17 | |||||
18 | $announce_id = sys_get_param_id('id'); |
||||
19 | $text = sys_get_param_str('text'); |
||||
20 | $announce_time = sys_get_param_str('dtDateTime'); |
||||
21 | $detail_url = sys_get_param_str('detail_url'); |
||||
22 | $mode = sys_get_param_str('mode'); |
||||
23 | |||||
24 | $survey_answers = sys_get_param('survey_answers'); |
||||
25 | $annQuery = ''; |
||||
26 | |||||
27 | $announce = array(); |
||||
28 | if ($user['authlevel'] >= 3) { |
||||
29 | if (!empty($text)) { |
||||
30 | $announce_time = strtotime($announce_time, SN_TIME_NOW); |
||||
31 | $announce_time = $announce_time ?: SN_TIME_NOW; |
||||
32 | |||||
33 | if ($mode == 'edit') { |
||||
34 | /** @noinspection SqlResolve */ |
||||
35 | doquery("UPDATE `{{announce}}` SET `tsTimeStamp` = FROM_UNIXTIME({$announce_time}), `strAnnounce`='{$text}', detail_url = '{$detail_url}' WHERE `idAnnounce`={$announce_id};"); |
||||
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
36 | /** @noinspection SqlResolve */ |
||||
37 | doquery("DELETE FROM `{{survey}}` WHERE `survey_announce_id` = {$announce_id};"); |
||||
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
38 | } else { |
||||
39 | /** @noinspection SqlResolve */ |
||||
40 | doquery("INSERT INTO `{{announce}}` |
||||
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
41 | SET `tsTimeStamp` = FROM_UNIXTIME({$announce_time}), `strAnnounce`='{$text}', detail_url = '{$detail_url}', |
||||
42 | `user_id` = {$user['id']}, `user_name` = '" . SN::$db->db_escape($user['username']) . "'"); |
||||
43 | $announce_id = SN::$db->db_insert_id(); |
||||
44 | } |
||||
45 | if (($survey_question = sys_get_param_str('survey_question')) && $survey_answers) { |
||||
46 | $survey_until = strtotime($survey_until = sys_get_param_str('survey_until'), SN_TIME_NOW); |
||||
47 | /** @noinspection PhpIdempotentOperationInspection */ |
||||
48 | $survey_until = date(FMT_DATE_TIME_SQL, $survey_until ?: SN_TIME_NOW + PERIOD_DAY * 1); |
||||
49 | /** @noinspection SqlResolve */ |
||||
50 | doquery("INSERT INTO `{{survey}}` SET `survey_announce_id` = {$announce_id}, `survey_question` = '{$survey_question}', `survey_until` = '{$survey_until}'"); |
||||
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
51 | $survey_id = SN::$db->db_insert_id(); |
||||
52 | |||||
53 | // To remove difference between Linux/Windows/OsX/etc. browsers |
||||
54 | $survey_answers = nl2br($survey_answers); |
||||
0 ignored issues
–
show
It seems like
$survey_answers can also be of type array ; however, parameter $string of nl2br() does only seem to accept string , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
55 | $survey_answers = explode('<br />', $survey_answers); |
||||
56 | foreach ($survey_answers as $survey_answer) { |
||||
57 | $survey_answer = SN::$db->db_escape(trim($survey_answer)); |
||||
58 | if ($survey_answer) { |
||||
59 | /** @noinspection SqlResolve */ |
||||
60 | doquery("INSERT INTO `{{survey_answers}}` SET `survey_parent_id` = {$survey_id}, `survey_answer_text` = '{$survey_answer}'"); |
||||
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
61 | } |
||||
62 | } |
||||
63 | } |
||||
64 | |||||
65 | if ($announce_time <= SN_TIME_NOW) { |
||||
66 | if ($announce_time > SN::$config->var_news_last && $announce_time == SN_TIME_NOW) { |
||||
67 | SN::$config->db_saveItem('var_news_last', $announce_time); |
||||
68 | } |
||||
69 | |||||
70 | if (sys_get_param_int('news_mass_mail')) { |
||||
71 | $text = sys_get_param('text') . ($detail_url ? " <a href=\"{$detail_url}\"><span class=\"positive\">{$lang['news_more']}</span></a>" : ''); |
||||
0 ignored issues
–
show
Are you sure
sys_get_param('text') of type array|string can be used in concatenation ?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
72 | msg_send_simple_message('*', 0, 0, MSG_TYPE_ADMIN, $lang['sys_administration'], $lang['news_title'], $text); |
||||
73 | } |
||||
74 | } |
||||
75 | |||||
76 | $mode = ''; |
||||
77 | $announce_id = 0; |
||||
78 | } |
||||
79 | |||||
80 | $survey_answers = ''; |
||||
81 | switch ($mode) { |
||||
82 | case 'del': |
||||
83 | /** @noinspection SqlResolve */ |
||||
84 | doquery("DELETE FROM `{{announce}}` WHERE `idAnnounce` = {$announce_id} LIMIT 1;"); |
||||
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
85 | $mode = ''; |
||||
86 | break; |
||||
87 | |||||
88 | /** @noinspection PhpMissingBreakStatementInspection */ |
||||
89 | case 'edit': |
||||
90 | $template->assign_var('ID', $announce_id); |
||||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
|
|||||
91 | case 'copy': |
||||
92 | /** @noinspection SqlResolve */ |
||||
93 | $announce = doquery( |
||||
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
94 | "SELECT a.*, s.survey_id, s.survey_question, s.survey_until |
||||
95 | FROM `{{announce}}` AS a |
||||
96 | LEFT JOIN `{{survey}}` AS s ON s.survey_announce_id = a.idAnnounce |
||||
97 | WHERE `idAnnounce` = {$announce_id} LIMIT 1;", true); |
||||
0 ignored issues
–
show
true of type true is incompatible with the type string expected by parameter $table of doquery() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
98 | if ($announce['survey_id']) { |
||||
99 | /** @noinspection SqlResolve */ |
||||
100 | $query = doquery("SELECT survey_answer_text FROM `{{survey_answers}}` WHERE survey_parent_id = {$announce['survey_id']};"); |
||||
0 ignored issues
–
show
The function
doquery() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
101 | $survey_answers_array = []; |
||||
102 | while ($row = db_fetch($query)) { |
||||
0 ignored issues
–
show
The function
db_fetch() has been deprecated.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
103 | $survey_answers_array[] = $row['survey_answer_text']; |
||||
104 | } |
||||
105 | $survey_answers = implode("\n", $survey_answers_array); |
||||
106 | } |
||||
107 | break; |
||||
108 | |||||
109 | default: |
||||
110 | if ($announce_id) { |
||||
111 | $annQuery = "AND `idAnnounce` = {$announce_id} "; |
||||
112 | } |
||||
113 | break; |
||||
114 | } |
||||
115 | } else { |
||||
116 | $annQuery = 'AND UNIX_TIMESTAMP(`tsTimeStamp`) <= ' . SN_TIME_NOW . ' '; |
||||
117 | |||||
118 | if ($announce_id) { |
||||
119 | $annQuery .= "AND `idAnnounce` = {$announce_id} "; |
||||
120 | } |
||||
121 | } |
||||
122 | |||||
123 | /** @noinspection PhpRedundantOptionalArgumentInspection */ |
||||
124 | nws_render($user, $template, $annQuery, 20); |
||||
125 | |||||
126 | $template->assign_vars([ |
||||
127 | 'PAGE_HEADER' => $lang['news_title'], |
||||
128 | 'AUTHLEVEL' => $user['authlevel'], |
||||
129 | 'MODE' => $mode, |
||||
130 | 'ANNOUNCE_ID' => $announce_id, |
||||
131 | 'tsTimeStamp' => $announce['tsTimeStamp'], |
||||
132 | 'strAnnounce' => $announce['strAnnounce'], // Obsolete ? |
||||
133 | 'strAnnounceJS' => json_encode($announce['strAnnounce']), |
||||
134 | 'DETAIL_URL' => $announce['detail_url'], |
||||
135 | 'SURVEY_QUESTION' => $announce['survey_question'], |
||||
136 | 'SURVEY_UNTIL' => $announce['survey_until'], |
||||
137 | 'SURVEY_ANSWERS' => $survey_answers, |
||||
138 | ]); |
||||
139 | |||||
140 | SnTemplate::display($template, $lang['news_title']); |
||||
141 |