| [ Index ] |
PHP Cross Reference of Nucleus CMS 3.32 |
[Summary view] [Print] [Text view]
1 <?php 2 3 /* 4 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/) 5 * Copyright (C) 2002-2007 The Nucleus Group 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * (see nucleus/documentation/index.html#license for more info) 12 */ 13 /** 14 * @license http://nucleuscms.org/license.txt GNU General Public License 15 * @copyright Copyright (C) 2002-2007 The Nucleus Group 16 * @version $Id: vars4.0.6.php 1153 2007-05-20 23:18:22Z kaigreve $ 17 */ 18 19 /** 20 * The purpose of the functions below is to avoid declaring HTTP_ vars to be global 21 * everywhere, plus to offer support for php versions before 4.1.0, that do not 22 * have the _GET etc vars 23 */ 24 function getVar($name) { 25 global $HTTP_GET_VARS; 26 27 if (!isset($HTTP_GET_VARS[$name])) { 28 return; 29 } 30 31 return undoMagic($HTTP_GET_VARS[$name]); 32 } 33 34 function postVar($name) { 35 global $HTTP_POST_VARS; 36 37 if (!isset($HTTP_POST_VARS[$name])) { 38 return; 39 } 40 41 return undoMagic($HTTP_POST_VARS[$name]); 42 } 43 44 function cookieVar($name) { 45 global $HTTP_COOKIE_VARS; 46 47 if (!isset($HTTP_COOKIE_VARS[$name])) { 48 return; 49 } 50 51 return undoMagic($HTTP_COOKIE_VARS[$name]); 52 } 53 54 // request: either POST or GET 55 function requestVar($name) { 56 return (postVar($name)) ? postVar($name) : getVar($name); 57 } 58 59 function serverVar($name) { 60 global $HTTP_SERVER_VARS; 61 62 if (!isset($HTTP_SERVER_VARS[$name])) { 63 return; 64 } 65 66 return $HTTP_SERVER_VARS[$name]; 67 } 68 69 // removes magic quotes if that option is enabled 70 function undoMagic($data) { 71 if (!get_magic_quotes_gpc()) 72 return $data; 73 if (ini_get('magic_quotes_sybase') != 1) 74 return stripslashes_array($data); 75 else 76 return undoSybaseQuotes_array($data); 77 } 78 79 function stripslashes_array($data) { 80 return is_array($data) ? array_map('stripslashes_array', $data) : stripslashes($data); 81 } 82 83 function undoSybaseQuotes_array($data) { 84 return is_array($data) ? array_map('undoSybaseQuotes', $data) : stripslashes($data); 85 } 86 87 function undoSybaseQuotes($data) { 88 return str_replace("''", "'", $data); 89 } 90 91 // integer array from request 92 function requestIntArray($name) { 93 global $HTTP_POST_VARS; 94 95 if (!isset($HTTP_POST_VARS[$name])) { 96 return; 97 } 98 99 return $HTTP_POST_VARS[$name]; 100 } 101 102 // array from request. Be sure to call undoMagic on the strings inside 103 function requestArray($name) { 104 global $HTTP_POST_VARS; 105 106 if (!isset($HTTP_POST_VARS[$name])) { 107 return; 108 } 109 110 return $HTTP_POST_VARS[$name]; 111 } 112 113 114 // add all the variables from the request as hidden input field 115 // @see globalfunctions.php#passVar 116 function passRequestVars() { 117 global $HTTP_POST_VARS, $HTTP_GET_VARS; 118 foreach ($HTTP_POST_VARS as $key => $value) { 119 if (($key == 'action') && ($value != requestVar('nextaction'))) 120 $key = 'nextaction'; 121 // a nextaction of 'showlogin' makes no sense 122 if (($key == 'nextaction') && ($value == 'showlogin')) 123 continue; 124 if (($key != 'login') && ($key != 'password')) 125 passVar($key, $value); 126 } 127 foreach ($HTTP_GET_VARS as $key => $value) { 128 if (($key == 'action') && ($value != requestVar('nextaction'))) 129 $key = 'nextaction'; 130 // a nextaction of 'showlogin' makes no sense 131 if (($key == 'nextaction') && ($value == 'showlogin')) 132 continue; 133 if (($key != 'login') && ($key != 'password')) 134 passVar($key, $value); 135 } 136 } 137 138 function postFileInfo($name) { 139 global $HTTP_POST_FILES; 140 141 if (!isset($HTTP_POST_FILES[$name])) { 142 return; 143 } 144 145 return $HTTP_POST_FILES[$name]; 146 } 147 148 function setOldAction($value) { 149 global $HTTP_POST_VARS; 150 $HTTP_POST_VARS['oldaction'] = $value; 151 } 152 153 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Tue Feb 12 15:34:36 2008 | Cross-referenced by PHPXref 0.7 |