Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function chk_glob($identifiers, $super, $db_escape = 1)
- {
- /*
- Using $_GET, $_POST, $_COOKIE, $_SERVER arrays are annoying
- because before you use them you have the check that the value
- exists. Then you have to escape it so there is a lot of code
- duplication and it's boring. There is also no succinct way of
- knowing whether the allocation was successful. This function
- solves that . . . and to stop duplication further it works on
- a list of idenitifers.
- */
- $identifiers = explode(",", $identifiers);
- $status = 1;
- foreach($identifiers as $identifier)
- {
- global $$identifier;
- /*
- Variable variables cannot be used with super globals hence
- we copy it to a non-super global variable and free it.
- */
- if($db_escape)
- {
- $$identifier = empty($super["$identifier"]) ? "" : mysql_escape_string(urldecode($super["$identifier"]));
- }
- else
- {
- $$identifier = empty($super["$identifier"]) ? "" : urldecode($super["$identifier"]);
- }
- if(empty($$identifier))
- {
- $status = 0;
- }
- }
- return $status;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement