GitBucket
4.21.2
Toggle navigation
Snippets
Sign in
Files
Branches
1
Releases
Issues
Pull requests
Labels
Priorities
Milestones
Wiki
Forks
nigel.stanger
/
Digital_Repository
Browse code
- Bug fix to doCheck() function so that it works under PHP 5.
master
1 parent
602aee6
commit
f61540be3ce5088163a33004bc5354cb377fbf0c
nstanger
authored
on 13 Dec 2006
Patch
Showing
1 changed file
Repositories/statistics/includes/inc.class.input_check.es.php
Ignore Space
Show notes
View
Repositories/statistics/includes/inc.class.input_check.es.php
<?php /** * Project: ePrints Statistics * File: inc.class.input_check.es.php * Description: Gross input checks for POST and GET via this object. * Sql object does it's own checking based on the schema. */ class checkit { var $_config = array(); var $_response; var $_clean; function checkit() { } function doCheck($value) { # NJS 2006-12-13 # PHP 5 appears to not like accessing $this->_config["type"] directly # as a method call. We now store it in a local variable first. # Tested OK under both PHP 4 and 5. $thetype = $this->_config["type"]; if (method_exists($this, $thetype)) { checkit::$thetype($value); } else { /* Could do something meaningful here. */ } } function getResponse() { return $this->_response; } function setConfig($config) { $this->_config = $config; } function cookie($value) { if (strlen($value)>$this->_config["maxlength"]) { $this->_response = $this->_config["action"]; } } function string($value) { /* More restrictive here than freetext Use could be for the form actions. If they don't match a certain type we have to reset the request otherwise we don't know what will happen. */ if (strlen($value)>$this->_config["maxlength"]) { $this->_response = $this->_config["action"]; } if (isset($this->_config["pattern"])) { $pattern = $this->_config["pattern"]; if ( preg_match($pattern, $value) ) { $this->_response = $this->_config["action"]; } } if (isset($this->_config["values"])) { if (!in_array($value, $this->_config["values"])) { $this->_response = $this->_config["action"]; } } return; } function integer($value) { /* Check that value is numeric and does not exceed maxlength. */ if (!is_numeric($value)) { $this->_response = $this->_config["action"]; } $test = (int) $value; if ($test > $this->_config["maxlength"]) { $this->_response = $this->_config["action"]; } } function ignore($value) { return; } function freetext($value) { if (strlen($value)>$this->_config["maxlength"]) { return 1; } if (isset($this->_config["pattern"])) { $pattern = $this->_config["pattern"]; $replacement = $this->_config["replacement"]; $this->_clean = preg_replace($pattern, $replacement, $value); return 2; } } } ?>
<?php /** * Project: ePrints Statistics * File: inc.class.input_check.es.php * Description: Gross input checks for POST and GET via this object. * Sql object does it's own checking based on the schema. */ class checkit { var $_config = array(); var $_response; var $_clean; function checkit() { } function doCheck($value) { if (method_exists($this, $this->_config["type"])) { checkit::$this->_config["type"]($value); } else { /* Could do something meaningful here. */ } } function getResponse() { return $this->_response; } function setConfig($config) { $this->_config = $config; } function cookie($value) { if (strlen($value)>$this->_config["maxlength"]) { $this->_response = $this->_config["action"]; } } function string($value) { /* More restrictive here than freetext Use could be for the form actions. If they don't match a certain type we have to reset the request otherwise we don't know what will happen. */ if (strlen($value)>$this->_config["maxlength"]) { $this->_response = $this->_config["action"]; } if (isset($this->_config["pattern"])) { $pattern = $this->_config["pattern"]; if ( preg_match($pattern, $value) ) { $this->_response = $this->_config["action"]; } } if (isset($this->_config["values"])) { if (!in_array($value, $this->_config["values"])) { $this->_response = $this->_config["action"]; } } return; } function integer($value) { /* Check that value is numeric and does not exceed maxlength. */ if (!is_numeric($value)) { $this->_response = $this->_config["action"]; } $test = (int) $value; if ($test > $this->_config["maxlength"]) { $this->_response = $this->_config["action"]; } } function ignore($value) { return; } function freetext($value) { if (strlen($value)>$this->_config["maxlength"]) { return 1; } if (isset($this->_config["pattern"])) { $pattern = $this->_config["pattern"]; $replacement = $this->_config["replacement"]; $this->_clean = preg_replace($pattern, $replacement, $value); return 2; } } } ?>
Show line notes below