Permalink
Browse files

Eloy's detect_unchecked_vars patch, slightly modified. See SC#184.

  • Loading branch information...
1 parent a7db9eb commit def35d35d7058c802986c1186ce21400e2009df4 defacer committed Nov 14, 2005
Showing with 41 additions and 0 deletions.
  1. +14 −0 lib/moodlelib.php
  2. +15 −0 lib/setup.php
  3. +12 −0 lib/weblib.php
View
@@ -134,6 +134,13 @@
*/
function required_param($varname, $options=PARAM_CLEAN) {
+ // detect_unchecked_vars addition
+ global $CFG;
+ if (!empty($CFG->detect_unchecked_vars)) {
+ global $UNCHECKED_VARS;
+ unset ($UNCHECKED_VARS->vars[$varname]);
+ }
+
if (isset($_POST[$varname])) { // POST has precedence
$param = $_POST[$varname];
} else if (isset($_GET[$varname])) {
@@ -161,6 +168,13 @@ function required_param($varname, $options=PARAM_CLEAN) {
*/
function optional_param($varname, $default=NULL, $options=PARAM_CLEAN) {
+ // detect_unchecked_vars addition
+ global $CFG;
+ if (!empty($CFG->detect_unchecked_vars)) {
+ global $UNCHECKED_VARS;
+ unset ($UNCHECKED_VARS->vars[$varname]);
+ }
+
if (isset($_POST[$varname])) { // POST has precedence
$param = $_POST[$varname];
} else if (isset($_GET[$varname])) {
View
@@ -269,11 +269,26 @@ function addslashes_deep($value) {
/// that have "register_globals" turned off (default since PHP 4.1.0).
/// Eventually I'll go through and upgrade all the code to make this unnecessary
+ if (!empty($CFG->detect_unchecked_vars)) {
+ global $UNCHECKED_VARS;
+ $UNCHECKED_VARS->url = $_SERVER['PHP_SELF'];
+ }
+
if (isset($_GET)) {
extract($_GET, EXTR_SKIP); // Skip existing variables, ie CFG
+ if (!empty($CFG->detect_unchecked_vars)) {
+ foreach ($_GET as $key => $val) {
+ $UNCHECKED_VARS->vars[$key]=$val;
+ }
+ }
}
if (isset($_POST)) {
extract($_POST, EXTR_SKIP); // Skip existing variables, ie CFG
+ if (!empty($CFG->detect_unchecked_vars)) {
+ foreach ($_POST as $key => $val) {
+ $UNCHECKED_VARS->vars[$key]=$val;
+ }
+ }
}
if (isset($_SERVER)) {
extract($_SERVER);
View
@@ -1924,6 +1924,18 @@ function print_header_simple($title='', $heading='', $navigation='', $focus='',
function print_footer($course=NULL, $usercourse=NULL) {
global $USER, $CFG, $THEME;
+ if (!empty($CFG->detect_unchecked_vars)) {
+ global $UNCHECKED_VARS;
+ if (!empty($UNCHECKED_VARS->vars)) {
+ foreach($UNCHECKED_VARS->vars as $key => $value) {
+ if(!empty($CFG->detect_unchecked_vars_to_mdl_log)) {
+ add_to_log(SITEID, 'dev', 'unchecked vars', $UNCHECKED_VARS->url, $key);
+ }
+ }
+ error_log('unchecked vars ['.$UNCHECKED_VARS->url.'] : ' . join(' ', array_keys($UNCHECKED_VARS->vars));
+ }
+ }
+
/// Course links
if ($course) {
if ($course == 'none') { // Don't print any links etc

0 comments on commit def35d3

Please sign in to comment.