Ignore:
Timestamp:
Mar 3, 2006 11:34:35 AM (7 years ago)
Author:
roundcube
Message:

Improved reading of POST and GET values

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/program/include/main.inc

    r156 r159  
    2525 
    2626 
     27// define constannts for input reading 
     28define('RCUBE_INPUT_GET', 0x0101); 
     29define('RCUBE_INPUT_POST', 0x0102); 
     30define('RCUBE_INPUT_GPC', 0x0103); 
     31 
     32 
    2733// register session and connect to server 
    2834function rcmail_startup($task='mail') 
     
    377383    $imap_port = isset($a_host['port']) ? $a_host['port'] : ($imap_ssl ? 993 : $CONFIG['default_port']); 
    378384    } 
     385  else 
     386    $imap_port = $CONFIG['default_port']; 
    379387 
    380388  // query if user already registered 
     
    896904  return $str; 
    897905  } 
     906 
     907 
     908/** 
     909 * Read input value and convert it for internal use 
     910 * Performs stripslashes() and charset conversion if necessary 
     911 *  
     912 * @param  string   Field name to read 
     913 * @param  int      Source to get value from (GPC) 
     914 * @param  boolean  Allow HTML tags in field value 
     915 * @param  string   Charset to convert into 
     916 * @return string   Field value or NULL if not available 
     917 */ 
     918function get_input_value($fname, $source, $allow_html=FALSE, $charset=NULL) 
     919  { 
     920  global $OUTPUT; 
     921  $value = NULL; 
     922   
     923  if ($source==RCUBE_INPUT_GET && isset($_GET[$fname])) 
     924    $value = $_GET[$fname]; 
     925  else if ($source==RCUBE_INPUT_POST && isset($_POST[$fname])) 
     926    $value = $_POST[$fname]; 
     927  else if ($source==RCUBE_INPUT_GPC) 
     928    { 
     929    if (isset($_GET[$fname])) 
     930      $value = $_GET[$fname]; 
     931    else if (isset($_POST[$fname])) 
     932      $value = $_POST[$fname]; 
     933    else if (isset($_COOKIE[$fname])) 
     934      $value = $_COOKIE[$fname]; 
     935    } 
     936   
     937  // strip slashes if magic_quotes enabled 
     938  if ((bool)get_magic_quotes_gpc()) 
     939    $value = stripslashes($value); 
     940 
     941  // remove HTML tags if not allowed     
     942  if (!$allow_html) 
     943    $value = strip_tags($value); 
     944   
     945  // convert to internal charset 
     946  return rcube_charset_convert($value, $OUTPUT->get_charset(), $charset); 
     947  } 
     948 
    898949 
    899950 
     
    14831534     
    14841535  $fields = array(); 
    1485   $fields['user'] = $input_user->show($_POST['_user']); 
     1536  $fields['user'] = $input_user->show(get_input_value('_user', RCUBE_INPUT_POST)); 
    14861537  $fields['pass'] = $input_pass->show(); 
    14871538  $fields['action'] = $input_action->show(); 
Note: See TracChangeset for help on using the changeset viewer.