Admun's NUDN

admun

  • San Francisco, CA

Navigation

Navigation

Categories

Getting a Dose of Parameters

I know, this is mostly HTTP stuff, but it is improtant for a plugin writer to understand this because this is how a plugin received inputs from external. And I found this useful information here and thought to make a note to it to remind myself.

Steal shamelessly directly from the wiki:

Instead of using $_POST of $HTTP_POST_VARS to get request variables, it's suggested to use one of the following methods, making sure you get the same data under different PHP configurations:

$var = getVar('name');  // $_GET
$var = postVar('name');  // $_POST
$var = cookieVar('name'); // $_COOKIES
$var = serverVar('name'); // $_SERVER
$var = requestVar('name'); // $_REQUEST (=GET/POST or COOKIE)
$var = intPostVar('name'); // same as postVar, but 
                           // parses data into an integer (intval)
$var = intGetVar('name'); // =intval(getVar(..))
$var = intRequestVar('name');
$var = intCookieVar('name'); 

All of these methods make sure that no magic quotes are present (the magic_quotes_gpc PHP option automagically replaces ' by \', when enabled), and work on all PHP versions on which Nucleus runs (> 4.0.6)

There are also many server-side global variables directly available:

$GATEWAY_INTERFACE
$SERVER_NAME
$SERVER_SOFTWARE
$SERVER_PROTOCOL
$REQUEST_METHOD
$QUERY_STRING
$DOCUMENT_ROOT
$HTTP_ACCEPT
$HTTP_ACCEPT_CHARSET
$HTTP_ACCEPT_ENCODING
$HTTP_ACCEPT_LANGUAGE
$HTTP_CONNECTION
$HTTP_HOST
$HTTP_REFERER
$HTTP_USER_AGENT
$REMOTE_ADDR
$REMOTE_PORT
$SCRIPT_FILENAME
$SERVER_ADMIN
$SERVER_PORT
$SERVER_SIGNATURE
$PATH_TRANSLATED
$SCRIPT_NAME
$REQUEST_URI
$argv
$argc
$PHP_SELF
$HTTP_COOKIE_VARS
$HTTP_GET_VARS
$HTTP_POST_VARS
$HTTP_POST_FILES
$HTTP_ENV_VARS
$HTTP_SERVER_VARS
$HTTP_SESSION_VARS
$PATH_INFO
$HTTPS
$HTTP_RAW_POST_DATA
$HTTP_X_FORWARDED_FOR

15:32:04 on 07/05/04 by Admun - Category: Developer Notes - tags: none - print

Comments

No comments yet

Add Comments