functions.inc.php: code cleanups / documentation fixes etc

git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@162 a1433add-5e2c-0410-b055-b7f2511e0802
postfixadmin-2.3
David Goodwin 17 years ago
parent dc73789c56
commit c3ae9dd9db

@ -205,13 +205,13 @@ function check_domain ($domain)
} }
/**
// * check_email
// check_email * Checks if an email is valid - if it is, return true, else false.
// Action: Checks if email is valid and returns TRUE if this is the case. * @param String $email - a string that may be an email address.
// Call: check_email (string email) * @return boolean true if it's an email address, else false.
// * TODO: make check_email able to handle already added domains
// TODO: make check_email able to handle already added domains */
function check_email ($email) function check_email ($email)
{ {
global $CONF; global $CONF;
@ -219,10 +219,12 @@ function check_email ($email)
$ce_email=$email; $ce_email=$email;
//strip the vacation domain out if we are using it //strip the vacation domain out if we are using it
//and change from blah#foo.com@autoreply.foo.com to blah@foo.com
if ($CONF['vacation'] == 'YES') if ($CONF['vacation'] == 'YES')
{ {
$vacation_domain = $CONF['vacation_domain']; $vacation_domain = $CONF['vacation_domain'];
$ce_email = preg_replace("/@$vacation_domain/", '', $ce_email); $ce_email = preg_replace("/@$vacation_domain/", '', $ce_email);
$ce_email = preg_replace("/#/", '@', $ce_email);
} }
if ( if (
@ -328,30 +330,47 @@ function escape_string ($string)
} }
// safeget /**
// Action: get value from $_GET[$param], or $default if $_GET[$param] is not set * safeget
// Call: $param = safeget('param') # replaces $param = $_GET['param'] * Action: get value from $_GET[$param], or $default if $_GET[$param] is not set
// - or - * Call: $param = safeget('param') # replaces $param = $_GET['param']
// $param = safeget('param', 'default') * - or -
* $param = safeget('param', 'default')
*
* @param String parameter name.
* @param String (optional) - default value if key is not set.
* @return String
*/
function safeget ($param, $default="") { function safeget ($param, $default="") {
$retval=$default; $retval=$default;
if (isset($_GET["$param"])) $retval=$_GET["$param"]; if (isset($_GET[$param])) $retval=$_GET[$param];
return $retval; return $retval;
} }
// safepost /**
// same as safeget, but for $_POST * safepost - similar to safeget()
* @see safeget()
* @param String parameter name
* @param String (optional) default value (defaults to "")
* @return String - value in $_POST[$param] or $default
* same as safeget, but for $_POST
*/
function safepost ($param, $default="") { function safepost ($param, $default="") {
$retval=$default; $retval=$default;
if (isset($_POST["$param"])) $retval=$_POST["$param"]; if (isset($_POST[$param])) $retval=$_POST[$param];
return $retval; return $retval;
} }
// safeserver /**
// same as safeget, but for $_SERVER * safeserver
* @see safeget()
* @param String $param
* @param String $default (optional)
* @return String value from $_SERVER[$param] or $default
*/
function safeserver ($param, $default="") { function safeserver ($param, $default="") {
$retval=$default; $retval=$default;
if (isset($_SERVER["$param"])) $retval=$_SERVER["$param"]; if (isset($_SERVER[$param])) $retval=$_SERVER[$param];
return $retval; return $retval;
} }

Loading…
Cancel
Save