1010// Include markdown library
1111use \Michelf \Markdown ;
1212
13- if (@$ _REQUEST ['do ' ] == 'toggle_active ' )
14- if ($ news ->toggleActive ($ _REQUEST ['id ' ]))
15- $ _SESSION ['POPUP ' ][] = array ('CONTENT ' => 'News entry changed ' , 'TYPE ' => 'alert alert-success ' );
13+ if (@$ _REQUEST ['do ' ] == 'toggle_active ' ) {
14+ if (!$ config ['csrf ' ]['enabled ' ] || $ config ['csrf ' ]['enabled ' ] && $ csrftoken ->valid ) {
15+ if ($ news ->toggleActive ($ _REQUEST ['id ' ])) {
16+ $ _SESSION ['POPUP ' ][] = array ('CONTENT ' => 'News entry changed ' , 'TYPE ' => 'alert alert-success ' );
17+ }
18+ }
19+ }
1620
1721if (@$ _REQUEST ['do ' ] == 'add ' ) {
18- if ($ news ->addNews ($ _SESSION ['USERDATA ' ]['id ' ], $ _POST ['data ' ])) {
19- $ _SESSION ['POPUP ' ][] = array ('CONTENT ' => 'News entry added ' , 'TYPE ' => 'alert alert-success ' );
20- } else {
21- $ _SESSION ['POPUP ' ][] = array ('CONTENT ' => 'Failed to add new entry: ' . $ news ->getError (), 'TYPE ' => 'alert alert-danger ' );
22+ if (!$ config ['csrf ' ]['enabled ' ] || $ config ['csrf ' ]['enabled ' ] && $ csrftoken ->valid ) {
23+ if ($ news ->addNews ($ _SESSION ['USERDATA ' ]['id ' ], $ _POST ['data ' ])) {
24+ $ _SESSION ['POPUP ' ][] = array ('CONTENT ' => 'News entry added ' , 'TYPE ' => 'alert alert-success ' );
25+ } else {
26+ $ _SESSION ['POPUP ' ][] = array ('CONTENT ' => 'Failed to add new entry: ' . $ news ->getError (), 'TYPE ' => 'alert alert-danger ' );
27+ }
2228 }
2329}
2430
2531if (@$ _REQUEST ['do ' ] == 'delete ' ) {
26- if ($ news ->deleteNews ((int )$ _REQUEST ['id ' ])) {
27- $ _SESSION ['POPUP ' ][] = array ('CONTENT ' => 'Succesfully removed news entry ' , 'TYPE ' => 'alert alert-success ' );
28- } else {
29- $ _SESSION ['POPUP ' ][] = array ('CONTENT ' => 'Failed to delete entry: ' . $ news ->getError (), 'TYPE ' => 'alert alert-danger ' );
32+ if (!$ config ['csrf ' ]['enabled ' ] || $ config ['csrf ' ]['enabled ' ] && $ csrftoken ->valid ) {
33+ if ($ news ->deleteNews ((int )$ _REQUEST ['id ' ])) {
34+ $ _SESSION ['POPUP ' ][] = array ('CONTENT ' => 'Succesfully removed news entry ' , 'TYPE ' => 'alert alert-success ' );
35+ } else {
36+ $ _SESSION ['POPUP ' ][] = array ('CONTENT ' => 'Failed to delete entry: ' . $ news ->getError (), 'TYPE ' => 'alert alert-danger ' );
37+ }
3038 }
3139}
3240
3846}
3947$ smarty ->assign ("NEWS " , $ aNews );
4048$ smarty ->assign ("CONTENT " , "default.tpl " );
41- ?>
49+ ?>
0 commit comments