@@ -418,11 +418,11 @@ public static function displayUserReportAnswers($userId, $survey_data, $addMessa
418
418
if ($ row ['type ' ] != 'pagebreak ' ) {
419
419
$ questions [$ row ['sort ' ]]['question_id ' ] = $ row ['question_id ' ];
420
420
$ questions [$ row ['sort ' ]]['survey_id ' ] = $ row ['survey_id ' ];
421
- $ questions [$ row ['sort ' ]]['survey_question ' ] = $ row ['survey_question ' ];
421
+ $ questions [$ row ['sort ' ]]['survey_question ' ] = Security:: remove_XSS ( $ row ['survey_question ' ]) ;
422
422
$ questions [$ row ['sort ' ]]['display ' ] = $ row ['display ' ];
423
423
$ questions [$ row ['sort ' ]]['type ' ] = $ row ['type ' ];
424
424
$ questions [$ row ['sort ' ]]['maximum_score ' ] = $ row ['max_value ' ];
425
- $ questions [$ row ['sort ' ]]['options ' ][$ row ['question_option_id ' ]] = $ row ['option_text ' ];
425
+ $ questions [$ row ['sort ' ]]['options ' ][$ row ['question_option_id ' ]] = Security:: remove_XSS ( $ row ['option_text ' ]) ;
426
426
}
427
427
}
428
428
@@ -615,7 +615,7 @@ public static function display_question_report($survey_data)
615
615
$ row = 0 ;
616
616
foreach ($ data as $ label => $ item ) {
617
617
$ table ->setCellContents ($ row , 0 , $ label );
618
- $ table ->setCellContents ($ row , 1 , $ item );
618
+ $ table ->setCellContents ($ row , 1 , Security:: remove_XSS ( $ item) );
619
619
$ row ++;
620
620
}
621
621
@@ -670,7 +670,7 @@ public static function display_question_report($survey_data)
670
670
$ questionId = (int ) $ question ['question_id ' ];
671
671
672
672
echo '<div class="title-question"> ' ;
673
- echo strip_tags (isset ($ question ['survey_question ' ]) ? $ question ['survey_question ' ] : null );
673
+ echo Security:: remove_XSS ( strip_tags (isset ($ question ['survey_question ' ]) ? $ question ['survey_question ' ] : null ) );
674
674
echo '</div> ' ;
675
675
676
676
if ('score ' === $ question ['type ' ]) {
@@ -729,6 +729,8 @@ public static function display_question_report($survey_data)
729
729
foreach ($ options as $ option ) {
730
730
$ optionText = strip_tags ($ option ['option_text ' ]);
731
731
$ optionText = html_entity_decode ($ optionText );
732
+ $ optionText = Security::remove_XSS ($ optionText );
733
+
732
734
$ votes = 0 ;
733
735
if (isset ($ data [$ option ['question_option_id ' ]]['total ' ])) {
734
736
$ votes = $ data [$ option ['question_option_id ' ]]['total ' ];
@@ -752,7 +754,7 @@ public static function display_question_report($survey_data)
752
754
753
755
// Displaying the table: the content
754
756
if (is_array ($ options )) {
755
- foreach ($ options as $ key => &$ value ) {
757
+ foreach ($ options as &$ value ) {
756
758
if ('multiplechoiceother ' === $ question ['type ' ] && 'other ' === $ value ['option_text ' ]) {
757
759
$ value ['option_text ' ] = get_lang ('SurveyOtherAnswer ' );
758
760
}
@@ -773,7 +775,7 @@ public static function display_question_report($survey_data)
773
775
$ answers_number = $ absolute_number / $ number_of_answers [$ option ['question_id ' ]] * 100 ;
774
776
}
775
777
echo '<tr> ' ;
776
- echo '<td> ' .$ value ['option_text ' ].'</td> ' ;
778
+ echo '<td> ' .Security:: remove_XSS ( $ value ['option_text ' ]) .'</td> ' ;
777
779
echo '<td> ' ;
778
780
if ($ absolute_number != 0 ) {
779
781
echo '<a href=" ' .api_get_path (WEB_CODE_PATH ).'survey/reporting.php?action= ' .$ action
@@ -1120,9 +1122,9 @@ class = "save"
1120
1122
in_array ($ row ['question_id ' ], $ _POST ['questions_filter ' ]))
1121
1123
) {
1122
1124
// We do not show comment and pagebreak question types
1123
- if ('pagebreak ' != $ row ['type ' ]) {
1125
+ if ('pagebreak ' !== $ row ['type ' ]) {
1124
1126
$ content .= ' <th ' ;
1125
- if ($ row ['number_of_options ' ] > 0 && 'percentage ' != $ row ['type ' ]) {
1127
+ if ($ row ['number_of_options ' ] > 0 && 'percentage ' !== $ row ['type ' ]) {
1126
1128
$ content .= ' colspan=" ' .$ row ['number_of_options ' ].'" ' ;
1127
1129
}
1128
1130
$ content .= '> ' ;
@@ -1132,7 +1134,7 @@ class = "save"
1132
1134
type="checkbox"
1133
1135
name="questions_filter[]" value=" ' .$ row ['question_id ' ].'" checked="checked"/> ' ;
1134
1136
}
1135
- $ content .= $ row ['survey_question ' ];
1137
+ $ content .= Security:: remove_XSS ( $ row ['survey_question ' ]) ;
1136
1138
$ content .= '</label> ' ;
1137
1139
$ content .= '</th> ' ;
1138
1140
}
@@ -1189,7 +1191,7 @@ class = "save"
1189
1191
(is_array ($ _POST ['questions_filter ' ]) && in_array ($ row ['question_id ' ], $ _POST ['questions_filter ' ]))
1190
1192
) {
1191
1193
// we do not show comment and pagebreak question types
1192
- if ('open ' == $ row ['type ' ] || 'comment ' == $ row ['type ' ]) {
1194
+ if ('open ' === $ row ['type ' ] || 'comment ' = == $ row ['type ' ]) {
1193
1195
$ content .= '<th> - </th> ' ;
1194
1196
$ possible_answers [$ row ['question_id ' ]][$ row ['question_option_id ' ]] = $ row ['question_option_id ' ];
1195
1197
$ display_percentage_header = 1 ;
@@ -1201,7 +1203,7 @@ class = "save"
1201
1203
$ possible_answers [$ row ['question_id ' ]][$ row ['question_option_id ' ]] = $ row ['question_option_id ' ];
1202
1204
} elseif ($ row ['type ' ] !== 'pagebreak ' && $ row ['type ' ] !== 'percentage ' ) {
1203
1205
$ content .= '<th> ' ;
1204
- $ content .= $ row ['option_text ' ];
1206
+ $ content .= Security:: remove_XSS ( $ row ['option_text ' ]) ;
1205
1207
$ content .= '</th> ' ;
1206
1208
$ possible_answers [$ row ['question_id ' ]][$ row ['question_option_id ' ]] = $ row ['question_option_id ' ];
1207
1209
$ display_percentage_header = 1 ;
@@ -2116,7 +2118,7 @@ public static function display_comparative_report()
2116
2118
$ optionsX = ['---- ' ];
2117
2119
$ optionsY = ['---- ' ];
2118
2120
$ defaults = [];
2119
- foreach ($ questions as $ key => &$ question ) {
2121
+ foreach ($ questions as &$ question ) {
2120
2122
// Ignored tagged questions
2121
2123
if ($ question ) {
2122
2124
if (strpos ($ question ['question ' ], '{{ ' ) !== false ) {
@@ -2133,6 +2135,7 @@ public static function display_comparative_report()
2133
2135
if (isset ($ _GET ['yaxis ' ]) && $ _GET ['yaxis ' ] == $ question ['question_id ' ]) {
2134
2136
$ defaults ['yaxis ' ] = $ question ['question_id ' ];
2135
2137
}
2138
+ $ question ['question ' ] = Security::remove_XSS ($ question ['question ' ]);
2136
2139
2137
2140
$ optionsX [$ question ['question_id ' ]] = api_substr (strip_tags ($ question ['question ' ]), 0 , 90 );
2138
2141
$ optionsY [$ question ['question_id ' ]] = api_substr (strip_tags ($ question ['question ' ]), 0 , 90 );
@@ -2171,16 +2174,17 @@ public static function display_comparative_report()
2171
2174
if ($ ii == 0 ) {
2172
2175
$ tableHtml .= '<th> </th> ' ;
2173
2176
} else {
2174
- if ($ question_x ['type ' ] == 'score ' ) {
2177
+ if ($ question_x ['type ' ] === 'score ' ) {
2175
2178
for ($ x = 1 ; $ x <= $ question_x ['maximum_score ' ]; $ x ++) {
2176
- $ tableHtml .= '<th> ' .$ question_x ['answers ' ][($ ii - 1 )].'<br /> ' .$ x .'</th> ' ;
2179
+ $ tableHtml .= '<th> ' .Security:: remove_XSS ( $ question_x ['answers ' ][($ ii - 1 )]) .'<br /> ' .$ x .'</th> ' ;
2177
2180
}
2178
2181
$ x = '' ;
2179
2182
} else {
2180
- $ tableHtml .= '<th> ' .$ question_x ['answers ' ][($ ii - 1 )].'</th> ' ;
2183
+ $ tableHtml .= '<th> ' .Security:: remove_XSS ( $ question_x ['answers ' ][($ ii - 1 )]) .'</th> ' ;
2181
2184
}
2182
2185
$ optionText = strip_tags ($ question_x ['answers ' ][$ ii - 1 ]);
2183
2186
$ optionText = html_entity_decode ($ optionText );
2187
+ $ optionText = Security::remove_XSS ($ optionText );
2184
2188
array_push ($ xOptions , trim ($ optionText ));
2185
2189
}
2186
2190
}
@@ -2198,7 +2202,7 @@ public static function display_comparative_report()
2198
2202
if ($ question_x ['type ' ] == 'score ' ) {
2199
2203
for ($ x = 1 ; $ x <= $ question_x ['maximum_score ' ]; $ x ++) {
2200
2204
if ($ ii == 0 ) {
2201
- $ tableHtml .= '<th> ' .$ question_y ['answers ' ][($ ij )].' ' .$ y .'</th> ' ;
2205
+ $ tableHtml .= '<th> ' .Security:: remove_XSS ( $ question_y ['answers ' ][($ ij )]) .' ' .$ y .'</th> ' ;
2202
2206
break ;
2203
2207
} else {
2204
2208
$ tableHtml .= '<td align="center"> ' ;
@@ -2224,7 +2228,7 @@ public static function display_comparative_report()
2224
2228
}
2225
2229
} else {
2226
2230
if ($ ii == 0 ) {
2227
- $ tableHtml .= '<th> ' .$ question_y ['answers ' ][$ ij ].' ' .$ y .'</th> ' ;
2231
+ $ tableHtml .= '<th> ' .Security:: remove_XSS ( $ question_y ['answers ' ][$ ij ]) .' ' .$ y .'</th> ' ;
2228
2232
} else {
2229
2233
$ tableHtml .= '<td align="center"> ' ;
2230
2234
$ votes = self ::comparative_check (
@@ -2257,7 +2261,7 @@ public static function display_comparative_report()
2257
2261
if ($ question_x ['type ' ] === 'score ' ) {
2258
2262
for ($ x = 1 ; $ x <= $ question_x ['maximum_score ' ]; $ x ++) {
2259
2263
if ($ ii == 0 ) {
2260
- $ tableHtml .= '<th> ' .$ question_y ['answers ' ][$ ij ].'</th> ' ;
2264
+ $ tableHtml .= '<th> ' .Security:: remove_XSS ( $ question_y ['answers ' ][$ ij ]) .'</th> ' ;
2261
2265
break ;
2262
2266
} else {
2263
2267
$ tableHtml .= '<td align="center"> ' ;
@@ -2283,7 +2287,7 @@ public static function display_comparative_report()
2283
2287
}
2284
2288
} else {
2285
2289
if ($ ii == 0 ) {
2286
- $ tableHtml .= '<th> ' .$ question_y ['answers ' ][($ ij )].'</th> ' ;
2290
+ $ tableHtml .= '<th> ' .Security:: remove_XSS ( $ question_y ['answers ' ][($ ij )]) .'</th> ' ;
2287
2291
} else {
2288
2292
$ tableHtml .= '<td align="center"> ' ;
2289
2293
$ votes = self ::comparative_check (
0 commit comments