Created
February 6, 2011 17:04
-
-
Save zaigham/813512 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** <?php | |
* getReqParam | |
* | |
* Copyright 2010 by Shaun McCormick <[email protected]> | |
* | |
* getReqParam 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 2 of the License, or (at your option) any later | |
* version. | |
* | |
* getReqParam 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 | |
* getReqParam; if not, write to the Free Software Foundation, Inc., 59 Temple | |
* Place, Suite 330, Boston, MA 02111-1307 USA | |
* | |
* @package getreqparam | |
*/ | |
/** | |
* Returns a parameter from the php request object or other globals. | |
* | |
* @author Shaun McCormick <[email protected]> | |
* @license GPLv2 | |
* @param string $name The name of the variable. | |
* @param string $type The type of request. Defaults to GET. | |
* @package getreqparam | |
* | |
* Works with Revolution 2.0.0. | |
*/ | |
if (empty($modx) || empty($scriptProperties['name']) || empty($scriptProperties['type'])) return null; | |
$name = $scriptProperties['name']; | |
$type = !empty($scriptProperties['type']) ? $scriptProperties['type'] : 'GET'; | |
switch ($type) { | |
case 'SERVER': | |
return isset($_SERVER[$name]) ? $_SERVER[$name] : null; | |
break; | |
case 'POST': | |
return isset($_POST[$name]) ? $_POST[$name] : null; | |
break; | |
case 'FILES': | |
return isset($_FILES[$name]) ? $_FILES[$name] : null; | |
break; | |
case 'COOKIE': | |
return isset($_COOKIE[$name]) ? $_COOKIE[$name] : null; | |
break; | |
case 'SESSION': | |
return isset($_SESSION[$name]) ? $_SESSION[$name] : null; | |
break; | |
case 'REQUEST': | |
return isset($_REQUEST[$name]) ? $_REQUEST[$name] : null; | |
break; | |
case 'GET': | |
default: | |
return isset($_GET[$name]) ? $_GET[$name] : null; | |
break; | |
} | |
return null; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment