Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- UserSpice 4
- An Open Source PHP User Management System
- by the UserSpice Team at http://UserSpice.com
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- class Input {
- public static function exists($type = 'post'){
- switch ($type) {
- case 'post':
- return (!empty($_POST)) ? true : false;
- break;
- case 'get':
- return (!empty($_GET)) ? true : false;
- default:
- return false;
- break;
- }
- }
- public static function get($item){
- #echo "DEBUG: Input::get($item): Entering<br />\n";
- if (isset($_POST[$item])) {
- $myItem = $_POST[$item];
- } elseif(isset($_GET[$item])){
- $myItem = $_GET[$item];
- } else {
- return '';
- }
- #echo "DEBUG: Input::get($item): myItem=<pre>".print_r($myItem,true)."</pre><br />\n";
- /*
- If the item is an array, process each item independently, and return array of sanitized items.
- */
- if (is_array($myItem)){
- $myItems=array();
- foreach ($myItem as $k => $elem){
- $myItems[$k]=self::sanitize($elem);
- }
- #echo "DEBUG: Input::get($item): returning myItems=<pre>".print_r($myItems,true)."</pre><br />\n";
- return $myItems;
- }else{
- #echo "DEBUG: Input::get($item): returning myItem=$myItem<br />\n";
- return self::sanitize($myItem);
- }
- }
- public static function sanitize($string){
- return trim(htmlentities($string, ENT_QUOTES, 'UTF-8'));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement