18
18
19
19
require_login ();
20
20
require_sesskey ();
21
- if (!is_siteadmin ()) {
22
- header ('HTTP/1.0 403 Forbidden ' );
23
- echo '403 Forbidden ' ;
24
- return ;
25
- }
26
- $ starttime = optional_param ('starttime ' , 'NULL ' , PARAM_INT );
27
- $ endtime = optional_param ('endtime ' , 'NULL ' , PARAM_INT );
28
- $ cat = required_param ('category ' , PARAM_INT );
21
+ require_capability ('moodle/site:config ' , context_system::instance ());
29
22
30
- if (!preg_match ('/^[[0-9]*|NULL]$/ ' , strval ($ starttime ))) {
31
- exit ("securtity violation1 " );
32
- }
33
- if (!preg_match ('/^[[0-9]*|NULL]$/ ' , strval ($ endtime ))) {
34
- exit ("security violaion2 " );
35
- }
23
+ $ starttime = optional_param ('starttime ' , null , PARAM_INT );
24
+ $ endtime = optional_param ('endtime ' , null , PARAM_INT );
25
+ $ cat = required_param ('category ' , PARAM_INT );
36
26
37
- // Not safe against SQL-injection. But site admin has access to Database anyway, right?
38
27
global $ DB ;
39
- $ sql = " UPDATE {block_evasys_sync_categories} SET standard_time_start = $ starttime , standard_time_end = $ endtime " .
40
- " WHERE id = ? " ;
41
- $ DB ->execute ($ sql , array ($ cat ));
28
+ $ sql = ' UPDATE {block_evasys_sync_categories} SET standard_time_start = ? , standard_time_end = ? ' .
29
+ ' WHERE id = ? ' ;
30
+ $ DB ->execute ($ sql , array ($ starttime , $ endtime , $ cat ));
0 commit comments