$preferences->backup_messages = optional_param('backup_messages',1,PARAM_INT);
$preferences->backup_blogs = optional_param('backup_blogs',1,PARAM_INT);
$preferences->backup_course = $course->id;
- $preferences->backup_name = required_param('backup_name',PARAM_FILE);
- $preferences->backup_unique_code = required_param('backup_unique_code');
+ $preferences->backup_name = required_param('backup_name', PARAM_FILE);
+ $preferences->backup_unique_code = required_param('backup_unique_code', PARAM_INT);
$roles = get_all_roles();
$preferences->backuproleassignments = array();
$eventid = optional_param('id', 0, PARAM_INT);
$eventtype = optional_param('type', 'select', PARAM_ALPHA);
$urlcourse = optional_param('course', 0, PARAM_INT);
- $cal_y = optional_param('cal_y');
- $cal_m = optional_param('cal_m');
- $cal_d = optional_param('cal_d');
+ $cal_y = optional_param('cal_y', 0, PARAM_INT);
+ $cal_m = optional_param('cal_m', 0, PARAM_INT);
+ $cal_d = optional_param('cal_d', 0, PARAM_INT);
if(isguest()) {
// Guests cannot do anything with events
require_once('../config.php');
require_once($CFG->dirroot.'/calendar/lib.php');
- $from = required_param('from');
- $var = required_param('var');
- $value = optional_param('value');
- $id = optional_param('id');
- $cal_d = optional_param('cal_d');
- $cal_m = optional_param('cal_m');
- $cal_y = optional_param('cal_y');
- $action = optional_param('action');
- $type = optional_param('type');
+ $from = required_param('from', PARAM_ALPHA);
+ $var = required_param('var', PARAM_ALPHA);
+ $id = optional_param('id', 0, PARAM_INT);
+ $cal_d = optional_param('cal_d', 0, PARAM_INT);
+ $cal_m = optional_param('cal_m', 0, PARAM_INT);
+ $cal_y = optional_param('cal_y', 0, PARAM_INT);
+ $action = optional_param('action', '', PARAM_ALPHA);
+ $type = optional_param('type', '', PARAM_ALPHA);
// Initialize the session variables
calendar_session_vars();
// REQUIRED fields;
// an_login
- $loginval = optional_param('an_login', '');
+ $loginval = optional_param('an_login', '', PARAM_RAW);
if (empty($loginval) && empty($mconfig->an_login)) {
return false;
}
set_config('an_login', $loginval, 'enrol/authorize');
// an_tran_key, an_password
- $tranval = optional_param('an_tran_key', '');
+ $tranval = optional_param('an_tran_key', '', PARAM_RAW);
$tranval = !empty($tranval) ? rc4encrypt($tranval) : (isset($mconfig->an_tran_key)?$mconfig->an_tran_key:'');
- $passwordval = optional_param('an_password', '');
+ $passwordval = optional_param('an_password', '', PARAM_RAW);
$passwordval = !empty($passwordval) ? rc4encrypt($passwordval) :(isset($mconfig->an_password)?$mconfig->an_password:'');
$deletecurrent = optional_param('delete_current', '0', PARAM_BOOL);
if (!empty($deletecurrent) and !empty($tranval)) {
}
// course id needs to be passed for auth purposes
- $mform->addElement('hidden', 'id', optional_param('id'));
+ $mform->addElement('hidden', 'id', optional_param('id', 0, PARAM_INT));
$mform->setType('id', PARAM_INT);
$mform->addElement('header', 'general', get_string('importfile', 'grades'));
// file upload
$this->set_upload_manager(new upload_manager('userfile', false, false, null, false, 0, true, true, false));
// course id needs to be passed for auth purposes
- $mform->addElement('hidden', 'id', optional_param('id'));
+ $mform->addElement('hidden', 'id', optional_param('id', 0, PARAM_INT));
$mform->setType('id', PARAM_INT);
$mform->addElement('header', 'general', get_string('importfile', 'grades'));
$mform->disabledIf('url', 'userfile', 'noteq', '');
* This function should be used to initialise all required values
* in a script that are based on parameters. Usually it will be
* used like this:
- * $id = required_param('id');
+ * $id = required_param('id', PARAM_INT);
*
* @param string $parname the name of the page parameter we want,
* default PARAM_CLEAN
* This function should be used to initialise all optional values
* in a script that are based on parameters. Usually it will be
* used like this:
- * $name = optional_param('name', 'Fred');
+ * $name = optional_param('name', 'Fred', PARAM_TEXT);
*
* @param string $parname the name of the page parameter we want
* @param mixed $default the default value to return if nothing is found
{
$_POST['username'] = 'post_user';
$_GET['username'] = 'get_user';
- $this->assertEqual(optional_param('username', 'default_user'), 'post_user');
+ $this->assertEqual(optional_param('username', 'default_user', PARAM_CLEAN), 'post_user');
unset($_POST['username']);
- $this->assertEqual(optional_param('username', 'default_user'), 'get_user');
+ $this->assertEqual(optional_param('username', 'default_user', PARAM_CLEAN), 'get_user');
unset($_GET['username']);
- $this->assertEqual(optional_param('username', 'default_user'), 'default_user');
+ $this->assertEqual(optional_param('username', 'default_user', PARAM_CLEAN), 'default_user');
}
/**
}
/// Optional variables that may be passed in
- $tab = optional_param('tab', 'contacts'); // current tab - default to contacts
+ $tab = optional_param('tab', 'contacts', PARAM_ALPHA); // current tab - default to contacts
$addcontact = optional_param('addcontact', 0, PARAM_INT); // adding a contact
$removecontact = optional_param('removecontact', 0, PARAM_INT); // removing a contact
$blockcontact = optional_param('blockcontact', 0, PARAM_INT); // blocking a contact
$d = optional_param('d', 0, PARAM_INT); // database id
$rid = optional_param('rid', 0, PARAM_INT); //record id
$import = optional_param('import', 0, PARAM_INT); // show import form
- $cancel = optional_param('cancel', ''); // cancel an add
+ $cancel = optional_param('cancel', '', PARAM_RAW); // cancel an add
$mode ='addtemplate'; //define the mode for this page, only 1 mode available
if ($id) {
$mode = optional_param('mode','',PARAM_ALPHA);
$defaultsort = optional_param('defaultsort', 0, PARAM_INT);
$defaultsortdir = optional_param('defaultsortdir', 0, PARAM_INT);
- $cancel = optional_param('cancel', '');
+ $cancel = optional_param('cancel', 0, PARAM_BOOL);
if ($cancel) {
$mode = 'list';
$showall = optional_param('showall', '', PARAM_INT); // show all discussions on one page
$changegroup = optional_param('group', -1, PARAM_INT); // choose the current group
$page = optional_param('page', 0, PARAM_INT); // which page to show
- $search = optional_param('search', ''); // search string
+ $search = optional_param('search', '', PARAM_CLEAN);// search string
$params = array();
if ($id) {
require_once("lib.php");
$id = required_param('id', PARAM_INT);
- $mode = optional_param('mode');
+ $mode = optional_param('mode', '', PARAM_ACTION);
admin_externalpage_setup('managemodules'); // this is hacky, tehre should be a special hidden page for it
$button = '<div style="font-size:0.75em;">'.$button.'</div>';
$loggedinas = '<span class="logininfo">'.user_login_string($course, $USER).'</span>';
$time = time();
- $hppassword = optional_param('hppassword', '');
+ $hppassword = optional_param('hppassword', '', PARAM_RAW);
if (HOTPOT_FIRST_ATTEMPT && !has_capability('mod/hotpot:grade', $context)) {
// check this quiz is available to this student
// error message, if quiz is unavailable
$newpageid = 0;
if (isset($_POST['answer'])) {
- $useranswer = (float) optional_param('answer'); // just doing default PARAM_CLEAN, not doing PARAM_INT because it could be a float
+ $useranswer = (float) optional_param('answer', 0, PARAM_RAW); // just doing default PARAM_RAW, not doing PARAM_INT because it could be a float
} else {
$noanswer = true;
break;
global $ewiki_plugins, $ewiki_config;
$o = "";
- $thanks = optional_param('thankyou', '');
+ $thanks = optional_param('thankyou', '', PARAM_CLEAN);
#-- render requested wiki page <-- goal !!!
$render_args = array(
foreach ($pf_a as $n => $pf) { $pf($o, $id, $data, $action); }
}
- if (!empty($thankyou) && $ewiki_config["edit_thank_you"]) {
+ if (!empty($thanks) && $ewiki_config["edit_thank_you"]) {
$o = ewiki_t("THANKSFORCONTRIBUTION") . $o;
}
global $CFG;
- $q = optional_param('q', '');
+ $q = optional_param('q', '', PARAM_CLEAN);
$o = ewiki_make_title($id, $id, 2, $action);
if ($q == '') {
global $ewiki_links, $ewiki_author, $ewiki_plugins, $ewiki_ring, $ewiki_errmsg;
- $content = optional_param('content', '');
- $version = optional_param('version', '');
- $preview = optional_param('preview', false);
- $save = optional_param('save', false);
+ $content = optional_param('content', '', PARAM_CLEAN);
+ $version = optional_param('version', '', PARAM_CLEAN);
+ $preview = optional_param('preview', false, PARAM_BOOL);
+ $save = optional_param('save', false, PARAM_BOOL);
$hidden_postdata = array();
global $ewiki_plugins;
$abort = optional_param('abort', false);
- $init = optional_param('init', '');
+ $init = optional_param('init', '', PARAM_BOOL);
#-- proceed only if frontpage missing or explicetely requested
if ((strtolower($id)=="wikisetupwizard") || ($id==EWIKI_PAGE_INDEX) && ($action=="edit") && empty($data["version"]) && !($abort)) {
}
if (count($ewiki_upload_sections) > 1) {
if (empty($def_sec)) {
- $def_sec = optional_param('section', '');
+ $def_sec = optional_param('section', '', PARAM_CLEAN);
}
$o .= '<b>'.ewiki_t("UPL_INSECT").'</b><br /><select name="section">';
foreach ($ewiki_upload_sections as $id => $title) {
#-- params (section, orderby)
- $orderby = optional_param('orderby', 'created');
+ $orderby = optional_param('orderby', 'created', PARAM_ALPHA);
if ($def_sec) {
$section = $def_sec;
}
else {
- $section = optional_param('section', '');
+ $section = optional_param('section', '', PARAM_CLEAN);
if (count($ewiki_upload_sections) > 1) {
$oa = array();
$ewiki_upload_sections["*"] = "*";
global $userid, $groupid, $cm, $wikipage, $wiki, $course, $CFG, $OUTPUT;
#-- return legacy page
$cont = true;
- $wikiexport = optional_param('wikiexport', '');
+ $wikiexport = optional_param('wikiexport', '', PARAM_BOOL);
$binaries = optional_param("exportbinaries", null);
$exportformatval = optional_param("exportformats", null);
$withvirtualpages = optional_param("withvirtualpages", null);
global $ewiki_t, $ewiki_plugins;
- $content = optional_param('content', '');
+ $content = optional_param('content', '', PARAM_CLEAN);
$ret_err = 0;
$save = optional_param('save', false);
function ewiki_edit_patch($id, &$data) {
- $version = optional_param('version', null);
- $content = optional_param('content', '');
+ $version = optional_param('version', null, PARAM_CLEAN);
+ $content = optional_param('content', '', PARAM_CLEAN);
$r = false;
$cacheme = optional_param('allowcache', 1, PARAM_INT); // Set this to 0 to try and disable page caching.
// Only want to add edit log entries if we have made some changes ie submitted a form
- $editsave = optional_param('thankyou', '');
+ $editsave = optional_param('thankyou', '', PARAM_RAW);
if($page) {
// Split page command into action and page
if (optional_param('deleteselected', false, PARAM_BOOL)) { // delete selected questions from the category
if (($confirm = optional_param('confirm', '', PARAM_ALPHANUM)) and confirm_sesskey()) { // teacher has already confirmed the action
- $deleteselected = required_param('deleteselected');
+ $deleteselected = required_param('deleteselected', PARAM_RAW);
if ($confirm == md5($deleteselected)) {
if ($questionlist = explode(',', $deleteselected)) {
// for each question either hide it if it is in use or delete it
foreach ($questionlist as $questionid) {
+ $questionid = (int)$questionid;
question_require_capability_on($questionid, 'edit');
if ($DB->record_exists('quiz_question_instances', array('question' => $questionid))) {
if (!$DB->set_field('question', 'hidden', 1, array('id' => $questionid))) {
$id = optional_param('id', 0, PARAM_INT); // user id
$course = optional_param('course', SITEID, PARAM_INT); // course id (defaults to Site)
- $enable = optional_param('enable', ''); // enable email
- $disable = optional_param('disable', ''); // disable email
+ $enable = optional_param('enable', 0, PARAM_BOOL); // enable email
+ $disable = optional_param('disable', 0, PARAM_BOOL); // disable email
if (empty($id)) { // See your own profile by default
require_login();