mirror of
https://github.com/postfixadmin/postfixadmin.git
synced 2024-09-19 19:22:14 +02:00
Remove whitespace
This commit is contained in:
parent
0b82dec825
commit
2dea9fadd4
@ -1,16 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
* Postfix Admin
|
||||
*
|
||||
* LICENSE
|
||||
* This source file is subject to the GPL license that is bundled with
|
||||
* this package in the file LICENSE.TXT.
|
||||
*
|
||||
* Further details on the project are available at http://postfixadmin.sf.net
|
||||
*
|
||||
* @version $Id$
|
||||
* @license GNU GPL v2 or later.
|
||||
*
|
||||
/**
|
||||
* Postfix Admin
|
||||
*
|
||||
* LICENSE
|
||||
* This source file is subject to the GPL license that is bundled with
|
||||
* this package in the file LICENSE.TXT.
|
||||
*
|
||||
* Further details on the project are available at http://postfixadmin.sf.net
|
||||
*
|
||||
* @version $Id$
|
||||
* @license GNU GPL v2 or later.
|
||||
*
|
||||
* File: functions.inc.php
|
||||
* Contains re-usable code.
|
||||
*/
|
||||
@ -42,7 +42,7 @@ function authentication_get_username() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of user - either 'user' or 'admin'
|
||||
* Returns the type of user - either 'user' or 'admin'
|
||||
* Returns false if neither (E.g. if not logged in)
|
||||
* @return String admin or user or (boolean) false.
|
||||
*/
|
||||
@ -73,7 +73,7 @@ function authentication_has_role($role) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to enforce that $user has a particular role when
|
||||
* Used to enforce that $user has a particular role when
|
||||
* viewing a page.
|
||||
* If they are lacking a role, redirect them to login.php
|
||||
*
|
||||
@ -92,7 +92,7 @@ function authentication_require_role($role) {
|
||||
|
||||
/**
|
||||
* Add an error message for display on the next page that is rendered.
|
||||
* @param String/Array message(s) to show.
|
||||
* @param String/Array message(s) to show.
|
||||
*
|
||||
* Stores string in session. Flushed through header template.
|
||||
* @see _flash_string()
|
||||
@ -103,7 +103,7 @@ function flash_error($string) {
|
||||
|
||||
/**
|
||||
* Used to display an info message on successful update.
|
||||
* @param String/Array message(s) to show.
|
||||
* @param String/Array message(s) to show.
|
||||
* Stores data in session.
|
||||
* @see _flash_string()
|
||||
*/
|
||||
@ -191,7 +191,7 @@ function language_selector() {
|
||||
|
||||
|
||||
/**
|
||||
* Checks if a domain is valid
|
||||
* Checks if a domain is valid
|
||||
* @param string $domain
|
||||
* @return empty string if the domain is valid, otherwise string with the errormessage
|
||||
*
|
||||
@ -249,7 +249,7 @@ function check_email ($email) {
|
||||
|
||||
//strip the vacation domain out if we are using it
|
||||
//and change from blah#foo.com@autoreply.foo.com to blah@foo.com
|
||||
if (Config::bool('vacation')) {
|
||||
if (Config::bool('vacation')) {
|
||||
$vacation_domain = Config::read('vacation_domain');
|
||||
$ce_email = preg_replace("/@$vacation_domain\$/", '', $ce_email);
|
||||
$ce_email = preg_replace("/#/", '@', $ce_email);
|
||||
@ -337,7 +337,7 @@ function escape_string ($string, $db_conn = null) {
|
||||
*
|
||||
* @param String parameter name.
|
||||
* @param String (optional) - default value if key is not set.
|
||||
* @return String
|
||||
* @return String
|
||||
*/
|
||||
function safeget ($param, $default="") {
|
||||
$retval=$default;
|
||||
@ -362,7 +362,7 @@ function safepost ($param, $default="") {
|
||||
/**
|
||||
* safeserver
|
||||
* @see safeget()
|
||||
* @param String $param
|
||||
* @param String $param
|
||||
* @param String $default (optional)
|
||||
* @return String value from $_SERVER[$param] or $default
|
||||
*/
|
||||
@ -375,7 +375,7 @@ function safeserver ($param, $default="") {
|
||||
/**
|
||||
* safecookie
|
||||
* @see safeget()
|
||||
* @param String $param
|
||||
* @param String $param
|
||||
* @param String $default (optional)
|
||||
* @return String value from $_COOKIE[$param] or $default
|
||||
*/
|
||||
@ -388,7 +388,7 @@ function safecookie ($param, $default="") {
|
||||
/**
|
||||
* safesession
|
||||
* @see safeget()
|
||||
* @param String $param
|
||||
* @param String $param
|
||||
* @param String $default (optional)
|
||||
* @return String value from $_SESSION[$param] or $default
|
||||
*/
|
||||
@ -471,7 +471,7 @@ function get_domain_properties ($domain) {
|
||||
*
|
||||
* @param String idxfield - database field name to use as title
|
||||
* @param String query - core part of the query (starting at "FROM")
|
||||
* @return String
|
||||
* @return String
|
||||
*/
|
||||
function create_page_browser($idxfield, $querypart) {
|
||||
global $CONF;
|
||||
@ -509,16 +509,16 @@ function create_page_browser($idxfield, $querypart) {
|
||||
$page_size_zerobase = $page_size - 1;
|
||||
$query = "
|
||||
SELECT * FROM (
|
||||
SELECT $idxfield AS label, @row := @row + 1 AS row $querypart
|
||||
SELECT $idxfield AS label, @row := @row + 1 AS row $querypart
|
||||
) idx WHERE MOD(idx.row, $page_size) IN (0,$page_size_zerobase) OR idx.row = $count_results
|
||||
";
|
||||
";
|
||||
|
||||
if (db_pgsql()) {
|
||||
$query = "
|
||||
SELECT * FROM (
|
||||
SELECT $idxfield AS label, nextval('rowcount') AS row $querypart
|
||||
SELECT $idxfield AS label, nextval('rowcount') AS row $querypart
|
||||
) idx WHERE MOD(idx.row, $page_size) IN (0,$page_size_zerobase) OR idx.row = $count_results
|
||||
";
|
||||
";
|
||||
}
|
||||
|
||||
if (db_sqlite()) {
|
||||
@ -533,7 +533,7 @@ function create_page_browser($idxfield, $querypart) {
|
||||
|
||||
# TODO: $query is MySQL-specific
|
||||
|
||||
# PostgreSQL:
|
||||
# PostgreSQL:
|
||||
# http://www.postgresql.org/docs/8.1/static/sql-createsequence.html
|
||||
# http://www.postgresonline.com/journal/archives/79-Simulating-Row-Number-in-PostgreSQL-Pre-8.4.html
|
||||
# http://www.pg-forum.de/sql/1518-nummerierung-der-abfrageergebnisse.html
|
||||
@ -604,7 +604,7 @@ function check_owner ($username, $domain) {
|
||||
|
||||
|
||||
/**
|
||||
* List domains for an admin user.
|
||||
* List domains for an admin user.
|
||||
* @param String $username
|
||||
* @return array of domain names.
|
||||
*/
|
||||
@ -863,8 +863,8 @@ function validate_password($password) {
|
||||
|
||||
|
||||
/**
|
||||
* Encrypt a password, using the apparopriate hashing mechanism as defined in
|
||||
* config.inc.php ($CONF['encrypt']).
|
||||
* Encrypt a password, using the apparopriate hashing mechanism as defined in
|
||||
* config.inc.php ($CONF['encrypt']).
|
||||
* When wanting to compare one pw to another, it's necessary to provide the salt used - hence
|
||||
* the second parameter ($pw_db), which is the existing hash from the DB.
|
||||
*
|
||||
@ -914,17 +914,17 @@ function pacrypt ($pw, $pw_db="") {
|
||||
$l = db_row($res["result"]);
|
||||
$password = $l[0];
|
||||
}
|
||||
|
||||
|
||||
elseif ($CONF['encrypt'] == 'authlib') {
|
||||
$flavor = $CONF['authlib_default_flavor'];
|
||||
$salt = substr(create_salt(), 0, 2); # courier-authlib supports only two-character salts
|
||||
if(preg_match('/^{.*}/', $pw_db)) {
|
||||
// we have a flavor in the db -> use it instead of default flavor
|
||||
$result = preg_split('/[{}]/', $pw_db, 3); # split at { and/or }
|
||||
$flavor = $result[1];
|
||||
$flavor = $result[1];
|
||||
$salt = substr($result[2], 0, 2);
|
||||
}
|
||||
|
||||
|
||||
if(stripos($flavor, 'md5raw') === 0) {
|
||||
$password = '{' . $flavor . '}' . md5($pw);
|
||||
} elseif(stripos($flavor, 'md5') === 0) {
|
||||
@ -937,14 +937,14 @@ function pacrypt ($pw, $pw_db="") {
|
||||
die("authlib_default_flavor '" . $flavor . "' unknown. Valid flavors are 'md5raw', 'md5', 'SHA' and 'crypt'");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
elseif (preg_match("/^dovecot:/", $CONF['encrypt'])) {
|
||||
$split_method = preg_split ('/:/', $CONF['encrypt']);
|
||||
$method = strtoupper($split_method[1]);
|
||||
# If $pw_db starts with {method}, change $method accordingly
|
||||
if (!empty($pw_db) && preg_match('/^\{([A-Z0-9.-]+)\}.+/', $pw_db, $method_matches)) { $method = $method_matches[1]; }
|
||||
if (! preg_match("/^[A-Z0-9.-]+$/", $method)) { die("invalid dovecot encryption method"); } # TODO: check against a fixed list?
|
||||
# if (strtolower($method) == 'md5-crypt') die("\$CONF['encrypt'] = 'dovecot:md5-crypt' will not work because dovecotpw generates a random salt each time. Please use \$CONF['encrypt'] = 'md5crypt' instead.");
|
||||
# if (strtolower($method) == 'md5-crypt') die("\$CONF['encrypt'] = 'dovecot:md5-crypt' will not work because dovecotpw generates a random salt each time. Please use \$CONF['encrypt'] = 'md5crypt' instead.");
|
||||
# $crypt_method = preg_match ("/.*-CRYPT$/", $method);
|
||||
|
||||
# digest-md5 and SCRAM-SHA-1 hashes include the username - until someone implements it, let's declare it as unsupported
|
||||
@ -1154,7 +1154,7 @@ function smtp_mail ($to, $from, $data, $body = "") {
|
||||
$timeout = "30";
|
||||
|
||||
if ($body != "") {
|
||||
$maildata =
|
||||
$maildata =
|
||||
"To: " . $to . "\n"
|
||||
. "From: " . $from . "\n"
|
||||
. "Subject: " . encode_header ($data) . "\n"
|
||||
@ -1253,7 +1253,6 @@ function db_connect ($ignore_errors = false) {
|
||||
global $DEBUG_TEXT;
|
||||
if ($ignore_errors != 0) $DEBUG_TEXT = '';
|
||||
$error_text = '';
|
||||
$link = 0;
|
||||
|
||||
if ($CONF['database_type'] == "mysql") {
|
||||
if (function_exists ("mysql_connect")) {
|
||||
@ -1336,12 +1335,12 @@ function db_get_boolean($bool) {
|
||||
// return either true or false (unquoted strings)
|
||||
if($bool) {
|
||||
return 't';
|
||||
}
|
||||
}
|
||||
return 'f';
|
||||
} elseif(Config::Read('database_type') == 'mysql' || Config::Read('database_type') == 'mysqli' || db_sqlite()) {
|
||||
if($bool) {
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
} else {
|
||||
die('Unknown value in $CONF[database_type]');
|
||||
@ -1428,14 +1427,14 @@ function db_query ($query, $ignore_errors = 0) {
|
||||
# mysql and pgsql $link are resources, mysqli $link is an object
|
||||
if (! (is_resource($link) || is_object($link) ) ) $link = db_connect ();
|
||||
|
||||
if ($CONF['database_type'] == "mysql") $result = @mysql_query ($query, $link)
|
||||
if ($CONF['database_type'] == "mysql") $result = @mysql_query ($query, $link)
|
||||
or $error_text = "Invalid query: " . mysql_error($link);
|
||||
if ($CONF['database_type'] == "mysqli") $result = @mysqli_query ($link, $query)
|
||||
if ($CONF['database_type'] == "mysqli") $result = @mysqli_query ($link, $query)
|
||||
or $error_text = "Invalid query: " . mysqli_error($link);
|
||||
if (db_sqlite()) $result = @$link->query($query)
|
||||
or $error_text = "Invalid query: " . $link->lastErrorMsg();
|
||||
if (db_pgsql()) {
|
||||
$result = @pg_query ($link, $query)
|
||||
$result = @pg_query ($link, $query)
|
||||
or $error_text = "Invalid query: " . pg_last_error();
|
||||
}
|
||||
if ($error_text != "" && $ignore_errors == 0) {
|
||||
@ -1700,7 +1699,7 @@ function db_in_clause($field, $values) {
|
||||
* param array $condition: array('field' => 'value', 'field2' => 'value2, ...)
|
||||
* param array $struct - field structure, used for automatic bool conversion
|
||||
* param string $additional_raw_where - raw sniplet to include in the WHERE part - typically needs to start with AND
|
||||
* param array $searchmode - operators to use (=, <, > etc.) - defaults to = if not specified for a field (see
|
||||
* param array $searchmode - operators to use (=, <, > etc.) - defaults to = if not specified for a field (see
|
||||
* $allowed_operators for available operators)
|
||||
* Note: the $searchmode operator will only be used if a $condition for that field is set.
|
||||
* This also means you'll need to set a (dummy) condition for NULL and NOTNULL.
|
||||
@ -1711,7 +1710,7 @@ function db_where_clause($condition, $struct, $additional_raw_where = '', $searc
|
||||
} elseif(!is_array($searchmode)) {
|
||||
die('db_where_cond: parameter $searchmode is not an array!');
|
||||
} elseif (count($condition) == 0 && trim($additional_raw_where) == '') {
|
||||
die("db_where_cond: parameter is an empty array!"); # die() might sound harsh, but can prevent information leaks
|
||||
die("db_where_cond: parameter is an empty array!"); # die() might sound harsh, but can prevent information leaks
|
||||
} elseif(!is_array($struct)) {
|
||||
die('db_where_cond: parameter $struct is not an array!');
|
||||
}
|
||||
@ -1840,9 +1839,9 @@ function alias_domain_postdeletion($alias_domain) {
|
||||
|
||||
//
|
||||
// gen_show_status
|
||||
// Action: Return a string of colored 's that indicate
|
||||
// Action: Return a string of colored 's that indicate
|
||||
// the if an alias goto has an error or is sent to
|
||||
// addresses list in show_custom_domains
|
||||
// addresses list in show_custom_domains
|
||||
// Call: gen_show_status (string alias_address)
|
||||
//
|
||||
function gen_show_status ($show_alias) {
|
||||
@ -1893,7 +1892,7 @@ function gen_show_status ($show_alias) {
|
||||
"'>" . $CONF['show_status_text'] . "</span> ";
|
||||
} else {
|
||||
$stat_string .= $CONF['show_status_text'] . " ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// POP/IMAP CHECK
|
||||
@ -1910,7 +1909,7 @@ function gen_show_status ($show_alias) {
|
||||
"'>" . $CONF['show_status_text'] . "</span> ";
|
||||
} else {
|
||||
$stat_string .= $CONF['show_status_text'] . " ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// CUSTOM DESTINATION CHECK
|
||||
@ -1921,11 +1920,11 @@ function gen_show_status ($show_alias) {
|
||||
"'>" . $CONF['show_status_text'] . "</span> ";
|
||||
} else {
|
||||
$stat_string .= $CONF['show_status_text'] . " ";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$stat_string .= "; ";
|
||||
}
|
||||
}
|
||||
|
||||
// $stat_string .= "<span style='background-color:green'> </span> " .
|
||||
// "<span style='background-color:blue'> </span> ";
|
||||
@ -1934,7 +1933,7 @@ function gen_show_status ($show_alias) {
|
||||
|
||||
function getRemoteAddr() {
|
||||
$REMOTE_ADDR = 'localhost';
|
||||
if (isset($_SERVER['REMOTE_ADDR']))
|
||||
if (isset($_SERVER['REMOTE_ADDR']))
|
||||
$REMOTE_ADDR = $_SERVER['REMOTE_ADDR'];
|
||||
return $REMOTE_ADDR;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user