These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /** |
||
4 | * announce.php |
||
5 | * |
||
6 | * @v4 Security checks by Gorlum for http://supernova.ws |
||
7 | * @v2 (c) copyright 2010 by Gorlum for http://supernova.ws |
||
8 | * based on admin/activeplanet.php (c) 2008 for XNova |
||
9 | */ |
||
10 | |||
11 | use DBStatic\DBStaticMessages; |
||
12 | use DBStatic\DBStaticNews; |
||
13 | use DBStatic\DBStaticSurvey; |
||
14 | use DBStatic\DBStaticSurveyAnswer; |
||
15 | |||
16 | $allow_anonymous = true; |
||
17 | include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
||
18 | |||
19 | nws_mark_read($user); |
||
20 | $template = gettemplate('announce', true); |
||
21 | |||
22 | $announce_id = sys_get_param_id('id'); |
||
23 | $text = sys_get_param_str('text'); |
||
24 | $text_unsafe = sys_get_param_str_unsafe('text'); |
||
25 | $announce_time = sys_get_param_str('dtDateTime'); |
||
26 | $detail_url = sys_get_param_str('detail_url'); |
||
27 | $detail_url_unsafe = sys_get_param_str_unsafe('detail_url'); |
||
28 | $mode = sys_get_param_str('mode'); |
||
29 | |||
30 | $announce = array(); |
||
31 | if($user['authlevel'] >= 3) { |
||
32 | if(!empty($text)) { |
||
33 | $announce_time = strtotime($announce_time, SN_TIME_NOW); |
||
34 | $announce_time = $announce_time ? $announce_time : SN_TIME_NOW; |
||
35 | |||
36 | if($mode == 'edit') { |
||
37 | DBStaticNews::db_news_update_set($announce_time, $text_unsafe, $detail_url_unsafe, $announce_id); |
||
38 | DBStaticSurvey::db_survey_delete_by_id($announce_id); |
||
39 | } else { |
||
40 | DBStaticNews::db_news_insert_set($announce_time, $text_unsafe, $detail_url_unsafe, $user['id'], $user['username']); |
||
41 | $announce_id = classSupernova::$db->db_insert_id(); |
||
42 | } |
||
43 | if(($survey_question = sys_get_param_str('survey_question')) && ($survey_answers = sys_get_param('survey_answers'))) { |
||
44 | $survey_answers = explode("\r\n", $survey_answers); |
||
45 | $survey_until = strtotime($survey_until = sys_get_param_str('survey_until'), SN_TIME_NOW); |
||
46 | $survey_until = date(FMT_DATE_TIME_SQL, $survey_until ? $survey_until : SN_TIME_NOW + PERIOD_DAY * 1); |
||
47 | $survey_question_unsafe = sys_get_param_str_unsafe('survey_question'); |
||
48 | DBStaticSurvey::db_survey_insert($announce_id, $survey_question_unsafe, $survey_until); |
||
49 | $survey_id = classSupernova::$db->db_insert_id(); |
||
50 | foreach($survey_answers as $survey_answer) { |
||
51 | $survey_answer_unsafe = trim($survey_answer); |
||
52 | if(empty($survey_answer_unsafe)) { |
||
53 | continue; |
||
54 | } |
||
55 | DBStaticSurveyAnswer::db_survey_answer_insert($survey_id, $survey_answer_unsafe); |
||
56 | } |
||
57 | } |
||
58 | |||
59 | if($announce_time <= SN_TIME_NOW) { |
||
60 | if($announce_time > classSupernova::$config->var_news_last && $announce_time == SN_TIME_NOW) { |
||
61 | classSupernova::$config->db_saveItem('var_news_last', $announce_time); |
||
62 | } |
||
63 | |||
64 | if(sys_get_param_int('news_mass_mail')) { |
||
65 | $lang_news_more = classLocale::$lang['news_more']; |
||
66 | $text = sys_get_param('text') . ($detail_url ? " <a href=\"{$detail_url}\"><span class=\"positive\">{$lang_news_more}</span></a>" : ''); |
||
67 | DBStaticMessages::msgSendFromAdmin('*', classLocale::$lang['news_title'], $text); |
||
68 | } |
||
69 | } |
||
70 | |||
71 | $mode = ''; |
||
72 | $announce_id = 0; |
||
73 | } |
||
74 | |||
75 | $survey_answers = ''; |
||
76 | switch($mode) { |
||
77 | case 'del': |
||
78 | DBStaticNews::db_news_delete_by_id($announce_id); |
||
79 | $mode = ''; |
||
80 | break; |
||
81 | |||
82 | /** @noinspection PhpMissingBreakStatementInspection */ |
||
83 | case 'edit': |
||
84 | $template->assign_var('ID', $announce_id); |
||
85 | case 'copy': |
||
86 | $announce = DBStaticNews::db_news_with_survey_select_by_id($announce_id); |
||
87 | if($announce['survey_id']) { |
||
88 | $query = DBStaticSurveyAnswer::db_survey_answer_text_select_by_news($announce); |
||
89 | while($row = db_fetch($query)) { |
||
90 | $survey_answers[] = $row['survey_answer_text']; |
||
91 | } |
||
92 | $survey_answers = implode("\r\n", $survey_answers); |
||
93 | } |
||
94 | break; |
||
95 | } |
||
96 | } else { |
||
97 | $annQuery = 'WHERE UNIX_TIMESTAMP(`tsTimeStamp`) <= ' . SN_TIME_NOW; |
||
98 | } |
||
99 | |||
100 | nws_render($template, $annQuery, 20); |
||
101 | |||
102 | $template->assign_vars(array( |
||
103 | 'AUTHLEVEL' => $user['authlevel'], |
||
104 | // 'total' => db_num_rows($allAnnounces), |
||
0 ignored issues
–
show
|
|||
105 | 'MODE' => $mode, |
||
106 | 'tsTimeStamp' => $announce['tsTimeStamp'], |
||
107 | 'strAnnounce' => $announce['strAnnounce'], |
||
108 | 'DETAIL_URL' => $announce['detail_url'], |
||
109 | 'SURVEY_QUESTION' => $announce['survey_question'], |
||
110 | 'SURVEY_UNTIL' => $announce['survey_until'], |
||
111 | 'SURVEY_ANSWERS' => $survey_answers, |
||
112 | )); |
||
113 | |||
114 | display($template, classLocale::$lang['news_title']); |
||
115 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.