0
0
mirror of https://github.com/postfixadmin/postfixadmin.git synced 2024-09-19 19:22:14 +02:00
Commit Graph

451 Commits

Author SHA1 Message Date
David Goodwin
590c80f0bc add more unit tests; re-enable random_int warning in functions.inc.php for old php versions etc etc 2018-12-29 20:54:25 +00:00
David Goodwin
e8acb609c2 reformat 2018-12-28 19:59:35 +00:00
David Goodwin
20b1eb842e fix sqlite display of password expired check for mailboxes 2018-12-28 19:57:21 +00:00
David Goodwin
1dfb03ea32 fix sqlite query for mailbox password_expiry 2018-12-28 19:54:25 +00:00
David Goodwin
4fcdba9cf4 run php-cs-fixer (code reforamt) 2018-12-28 19:31:43 +00:00
David Goodwin
19cda31849 remove psalm warnings from code; fix password_expiry behaviour when enabled/disabled on MySQL 2018-12-28 19:27:33 +00:00
David Goodwin
74002bbf57 psalm fixes 2018-12-27 21:43:11 +00:00
David Goodwin
7408a3b30a fix safepost doc 2018-12-27 13:55:21 +00:00
David Goodwin
69e234f668
Merge pull request #200 from doktoil-makresh/master
Support for password expiration, managed in PostFix Admin
2018-11-27 09:14:36 +00:00
David Goodwin
87472af5ba add Date header into smtp_from(...) function - see #203 2018-09-21 21:56:35 +01:00
David Goodwin
b1795ab596 phpdoc 2018-09-07 11:09:34 +01:00
David Goodwin
1e158245d6 try and fix #30 - cope with timestamp and numeric field number comparison better for PostgreSQL. 2018-09-07 11:04:19 +01:00
David Goodwin
a8b02cfc05 Default to default values 2018-09-07 11:01:18 +01:00
David Goodwin
77d1b6c2e7 rename sql fields to just have mailbox.password_expiry and domain.password_expiry 2018-08-28 21:19:56 +01:00
Damien Martins
8115d8d047 Reverting unexpected changes 2018-08-22 14:32:16 +02:00
Damien Martins
84533224ba Adds colored indicators for password expired, account disabled and vacation enabled accounts 2018-08-21 16:04:28 +02:00
Damien Martins
b33d79125c Merge branch 'master' of github.com:doktoil-makresh/postfixadmin 2018-08-21 16:02:02 +02:00
Damien Martins
d809e0fbf7 Adds colored indicators for password expired, account disabled and vacation enabled accounts 2018-08-21 15:57:06 +02:00
Damien Martins
72dddbc93b Adds colored indicators for password expired, account disabled and vacation enabled accounts 2018-08-21 15:49:40 +02:00
Damien Martins
ce60b9fa59 Now password expiration is managed through Postfix Admin GUI 2018-08-20 15:32:53 +02:00
Damien Martins
e786609aa9 Adding support for password expiration. Please read README.password_expiration for more details 2018-08-17 16:07:14 +02:00
David Goodwin
563b8c7636 phpdoc fixes (psalm) 2018-06-18 21:54:05 +01:00
David Goodwin
318ac048d5 psalm fixes 2018-06-10 21:24:12 +01:00
Aleksi Kinnunen
2df4348f09
Typo fix 2018-05-29 02:37:38 +02:00
Aleksi Kinnunen
48c19a1cbd
Combine encrypt CONF-keys
Went through the old PR #25, updated the encrypt rounds/cost setting to be in the encrypt -configuration key as per suggestion from @cboltz
2018-05-29 02:36:08 +02:00
Aleksi Kinnunen
c1b5e66e27
Add missing global
... you should never edit with the GitHub web GUI, lazy me.
2018-05-29 01:34:46 +02:00
Aleksi Kinnunen
b676e8337f
Allow empty $CONF['encrypt_difficulty'] for defaults 2018-05-29 01:29:50 +02:00
Aleksi Kinnunen
9c2161a549
Added support for password generation cost/rounds
$CONF["php_crypt_difficulty"], only for php_crypt:BLOWFISH, php_crypt:SHA256 and php_crypt:SHA512
2018-05-29 01:14:38 +02:00
David Goodwin
3754381f0e
Merge pull request #175 from racerxdl/master
'row' is a reserved word in MySQL 8.0
2018-05-18 08:38:20 +01:00
Lucas Teske
11f9680963
'row' is a reserved word in MySQL 8.0 2018-05-17 20:45:35 -03:00
Christian Boltz
2eb5a7ed60
simplify function_exists() checks for random_int()
It's easier to define a compat function than to have function_exists()
checks all over the code.
2018-05-04 22:36:05 +02:00
David Goodwin
b4849b8431 bump minimum db version 2018-05-02 21:25:36 +01:00
David Goodwin
4c6bcdbc39 update version 2018-05-02 21:25:06 +01:00
David Goodwin
5b7f4cda48 add phpdoc comments, default php_crypt hash to use SHA512 rather than MD5 2018-05-02 21:21:25 +01:00
David Goodwin
7282928e6d update generate_password() to allow length to be specified; update test 2018-05-02 21:19:47 +01:00
Christian Boltz
a3feba7c73
change default for php_crypt to SHA512
(+ a few whitespace changes)
2018-05-02 22:18:24 +02:00
David Goodwin
b48f99d4c6 reformat (phpcs) 2018-05-02 12:54:17 +01:00
David Goodwin
e7f9d536d9 change default salt method with php_crypt 2018-05-02 12:49:47 +01:00
David Goodwin
f543c7d403 use random_int() if available 2018-04-29 21:53:38 +01:00
David Goodwin
7c0cb82be8 use random_int if it is available 2018-04-29 20:51:48 +01:00
snuggeman
11f0ceb615 added php_crypt scheme 2018-04-29 15:39:58 +02:00
David Goodwin
9a07772626 remove commented out echo 2018-04-23 09:14:45 +01:00
Christian Boltz
30c61e81b3
better comment for pacol() parameter 2018-04-22 20:09:13 +02:00
Lucas Teske
50ac4c7597
Fixed "Incorrect integer value: 'Array' for column" error in updates. 2018-02-21 22:50:02 -03:00
David Goodwin
d57aa46eb5 remove explode() 2018-02-21 19:48:17 +00:00
David Goodwin
2a1d8daeba remove unused variables 2018-02-21 19:48:17 +00:00
David Goodwin
b79ad2ae28 composer format ... 2018-02-19 21:01:23 +00:00
David Goodwin
6446f3f6cc split up pacrypt() into different functions; add some minimal test coverage 2018-02-19 20:59:52 +00:00
David Goodwin
6ed1527497 fix phpdoc 2018-02-18 20:32:34 +00:00
David Goodwin
cb34da4f46 phpcs reformat 2018-02-18 19:59:37 +00:00
David Goodwin
43a2493876 remove unused code. 2018-02-10 21:07:33 +00:00
David Goodwin
4dec9cd24e refactor (reduce nesting) 2018-02-10 21:07:10 +00:00
David Goodwin
d088651fd6 Drop db_commit(), db_rollback(), db_begin() functions (unused). 2018-02-10 21:05:57 +00:00
David Goodwin
0b66cd6bd2 Do not try to db_escape() an SQL field. 2018-02-10 21:04:29 +00:00
David Goodwin
4e9d166765 use db_assoc() rather than db_array() as we're depending on an assoc array afterall. 2018-02-10 21:02:52 +00:00
David Goodwin
45a1073b97 change to use foreach($a as $k => $v) { ... } 2018-02-10 21:02:09 +00:00
David Goodwin
8ac94394cb improve phpdoc 2018-02-10 21:00:58 +00:00
David Goodwin
e2b1233269 Use filter_var($x, FILTER_VALIDATE_EMAIL) as an extra check if we can in check_email(...) 2018-02-10 20:56:56 +00:00
David Goodwin
5e1855632a allow local aliases - see #134 2018-02-09 21:19:45 +00:00
Adrien Crivelli
15df6c1d7b
Reformat everything with PHP-Cs-Fixer 2018-01-26 23:54:37 +09:00
David Goodwin
a320b67508 possible fix for issue in #112 - PostgreSQL does not like backticks (only do them for MySQL) 2018-01-03 16:05:46 +00:00
Christian Boltz
977f335a0f
Fix quoting in table_by_key()
This fixes a regression introduced by
https://github.com/postfixadmin/postfixadmin/pull/112
which became only visible when using a $CONF['database_prefix']
2017-12-30 13:42:47 +01:00
er1cs
7b8626ca81
Update functions.inc.php
I found that Mysql 8 don't like table names without `` in requests. So i make changes in function table_by_key in functions.inc.php and in upgrade.php . Now it works.  FreeBSD 11.1 Apache/2.4.29 (FreeBSD) PHP/7.1.11 Mysql 8
2017-12-24 16:32:06 +02:00
Lee Clemens
ebbd9025e4 Add support for MySQL connections over SSL 2017-11-14 19:53:59 -05:00
Sylvain Tissot
ffb84283c2
Harden password reset process
The improvements are:

- Die with an explicit message when a user is trying to reset his lost password and the option is disabled in config
- Redirect user to main page after password change using relative URL
- Don't leak info whether user exists or has recovery info defined
- Throttle password reset requests to prevent brute force attacks
- Show phone/alt email fields in mailbox/admin edit form only when the password reset option is enabled
- Make database upgrade code compatible with other databases types
- Use the existing password generator to generate OTP. It is now stored in database, unique to each user, valid only for 1 hour and can only by used once.
2017-10-09 11:45:51 +09:00
David Goodwin
4b999b3f6b improve mysqli connection settings - see https://github.com/postfixadmin/postfixadmin/issues/73 2017-09-05 10:09:36 +01:00
Sylvain Tissot
9c9ba64a7f Allows a user or admin to reset his/her forgotten password with a code sent by email/SMS #18 2017-08-21 13:05:25 +02:00
Christian Boltz
be5fafa9fb
changelog update etc. for 3.1 release 2017-06-25 16:37:42 +02:00
Christian Boltz
64f1593818
revert "support unicode domain names - see #47"
Unicode support is a much bigger can of worms (see the discussion in #47),
and having just a little part of unicode support in is a bad idea.

You can of course use the xn--whatever notation for unicode domains ;-)
2017-06-22 20:48:07 +02:00
David Goodwin
a09a3fa3b0 support unicode domain names - see #47 2017-06-02 12:54:34 +01:00
Christian Boltz
88bd9bfd19
drop $db_conn parameter from escape_string()
Connection caching is now done in db_connect() which is a much better
place.

This reverts most of c253ef7dbd
2017-04-17 12:39:04 +02:00
Christian Schrötter
846dcb756c
Remove unnecessary code 2017-03-27 18:15:11 +02:00
Christian Schrötter
e28f3f5959
Fix for mysqli_connect() 2017-03-21 18:05:33 +01:00
Christian Schrötter
2dea9fadd4
Remove whitespace 2017-03-21 17:43:27 +01:00
David Goodwin
c253ef7dbd allow escape_string() to take a db connection as a parameter; should improve performance when there are a large number of things to escape 2017-02-24 10:59:45 +00:00
Christian Boltz
28703935b3 3.0.2 release
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1894 a1433add-5e2c-0410-b055-b7f2511e0802
2017-02-09 05:21:12 +00:00
Christian Boltz
16e1407621 db_where_clause(): allow NULL and NOTNULL searchmodes
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1878 a1433add-5e2c-0410-b055-b7f2511e0802
2016-11-01 15:45:45 +00:00
Christian Boltz
bbec3e9f0e pacrypt(): allow switching between dovecot:* password schemes
Dovecot password hashes include a {SCHEME} prefix, so it's possible to
switch the scheme while still accepting passwords hashed using the
previous dovecot:* scheme.

This patch adds the code needed to find out the used hashing scheme
from the hash and ensures it gets used to validate the password.

Patch by Aaron Lindsay <aaron AT aclindsay com> (sent to the ML)



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1875 a1433add-5e2c-0410-b055-b7f2511e0802
2016-10-20 20:15:15 +00:00
Christian Boltz
6eda18fcde prepare PostfixAdmin 3.0 release
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1861 a1433add-5e2c-0410-b055-b7f2511e0802
2016-09-10 20:02:33 +00:00
Christian Boltz
2a6247a6d9 db_connect(): drop unused variable $succes(s)
One of the variable names had a typo [1], and since those variables are
unused, the best way is to drop them.

[1] reported by tfarina, https://github.com/postfixadmin/postfixadmin/issues/15


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1858 a1433add-5e2c-0410-b055-b7f2511e0802
2016-09-09 19:43:18 +00:00
Christian Boltz
13cdd50d0a Add checks to login.php and cli to ensure database layout is up to date
- add check_db_version() to functions.inc.php
- add $min_db_version (needs to be updated at least before the release)
- call check_db_version in login.php, users/login.php and CLI - they'll
  error out if the database layout is outdated
- change setup.php to use check_db_version()



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1853 a1433add-5e2c-0410-b055-b7f2511e0802
2016-05-22 19:58:54 +00:00
Christian Boltz
a00e8a811d functions.inc.php:
- check_domain(): someone had the great idea to allow punicode
  even in TLDs, so we better allow it.
  https://sourceforge.net/p/postfixadmin/feature-requests/93/


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1839 a1433add-5e2c-0410-b055-b7f2511e0802
2016-05-16 09:27:36 +00:00
Christian Boltz
a0151bd5a1 functions.inc.php:
- pacrypt(): don't stripslashes($pw) because this breaks passwords with
  backslashes. This stripslashes() existed since forever, but probably
  became harmful with all the rewrites in the last years.
  https://sourceforge.net/p/postfixadmin/bugs/349/


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1838 a1433add-5e2c-0410-b055-b7f2511e0802
2016-05-15 21:14:01 +00:00
Christian Boltz
9335232024 functions.inc.php:
- fix db_quota_text() for postgresql (concat() vs. ||)
  https://sourceforge.net/p/postfixadmin/bugs/370/


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1834 a1433add-5e2c-0410-b055-b7f2511e0802
2016-04-25 11:23:35 +00:00
David Goodwin
d3ca74af0d merge github pull request into svn manually - 3e62d3975a - adding configurable smtp helo (CONF["smtp_client"])
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1832 a1433add-5e2c-0410-b055-b7f2511e0802
2016-03-28 18:28:40 +00:00
Christian Boltz
b261db86c7 Merge pull request #9 from phyrog/master
Add sqlite backend option (thank you @phyrog for doing this)

(imported from github)


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1824 a1433add-5e2c-0410-b055-b7f2511e0802
2016-02-04 22:30:06 +00:00
Christian Boltz
129a65b8c5 functions.inc.php:
- gen_show_status(): escape mail addresses in query.
  Fixes https://sourceforge.net/p/postfixadmin/bugs/356/
  (mostly - the edit/delete/... links in list-virtual are double-escaped)
  In theory this could allow SQL injection, in practise the mail address
  regex limits this issue to a DOS (creating a mail address with ' caused
  an invalid query that broke list-virtual)


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1809 a1433add-5e2c-0410-b055-b7f2511e0802
2015-10-02 17:45:16 +00:00
Christian Boltz
9636fe9de3 3.0 beta3 (= 2.93) release - update $version and changelog
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1799 a1433add-5e2c-0410-b055-b7f2511e0802
2015-09-26 10:39:05 +00:00
Christian Boltz
5307cfe48a functions.inc.php check_domain():
Measure time needed for the nameserver queries, and error_log a warning
if the queries need more than 2 seconds in total.

Inspired by a question from t-ask on IRC, who suffered from a slow
nameserver and had some "fun" to debug it ;-)


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1790 a1433add-5e2c-0410-b055-b7f2511e0802
2015-06-13 19:56:26 +00:00
Christian Boltz
3a72203de4 AliasHandler:
- initStruct(): replace (wrong) 'editable' with '_can_edit' and '_can_delete'
- read_from_db_postprocess(): disable _can_edit and _can_delete for
  default aliases if special_alias_control is off and not superadmin

list.tpl:
- use $item._can_edit instead of $check_alias_owner

list-virtual.php:
- drop $check_alias_owner variable and check_alias_owner() call
  (replaced by the code added in AliasHandler)
- drop unused $sql_domain

functions.inc.php:
- delete no longer used check_alias_owner() function



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1774 a1433add-5e2c-0410-b055-b7f2511e0802
2015-04-06 20:35:19 +00:00
Christian Boltz
cc598d0f3f PFAHandler:
- build_select_query(): add support for $search['_'] (searching if one
  of the $this->searchfields contains the search text)
- getList(): make sure '_' is kept in the search parameters

functions.inc.php:
- db_where_clause(): slightly relax checks - if $condition is empty,
  only error out if $additional_raw_where is also empty


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1772 a1433add-5e2c-0410-b055-b7f2511e0802
2015-04-06 13:39:21 +00:00
Christian Boltz
5605561ca8 functions.inc.php:
- better formatting in db_quota_text() and db_quota_percent() results
  (for example, infinity sign instead of / 0 for unlimited)


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1744 a1433add-5e2c-0410-b055-b7f2511e0802
2015-02-28 22:30:21 +00:00
Christian Boltz
13f1a28b6e PFAHandler:
- read_from_db(), getList(): 
  - add $searchmode parameter (_before_ $limit and $offset!) to be able to 
    use query different query modes, not only "="
  - add a warning that $condition will be changed to array only in the future
- getList(): filter $condition for fields that are available to the user
  to avoid information leaks by using search parameters
  (filter is only applied if $condition is an array!)

functions.inc.php: 
- db_where_clause():
  - add $additional_raw_where parameter for additional query parameters
  - add $searchmode parameter to be able to use query different
    query modes, not only "=" (see $allowed_operators)
  - check for allowed operators in $searchmode
  - split query into WHERE and HAVING (if a parameter has
    $struct[select] set, HAVING is used)

list-virtual.php:
- adopt getList() call to the new syntax

AliasHandler:
- adopt getList() definition and call to the new syntax

 


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1731 a1433add-5e2c-0410-b055-b7f2511e0802
2014-11-02 22:45:22 +00:00
Christian Boltz
786a7d665e functions.inc.php:
- pacol():
  - add $linkto parameter (if list mode should link to something)
  - replace $not_in_db with $multiopt - the remaining parameters can
    now be specified as associated array (backwards-compatible)



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1719 a1433add-5e2c-0410-b055-b7f2511e0802
2014-11-01 21:11:33 +00:00
Christian Boltz
9093a946b4 functions.inc.php:
- add functions db_quota_text() and db_quota_percent() to generate
  queries for used quota ("x/y" and percentage)



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1712 a1433add-5e2c-0410-b055-b7f2511e0802
2014-11-01 19:19:00 +00:00
Christian Boltz
e8b0198512 2.92 (aka 3.0 beta2) release
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1706 a1433add-5e2c-0410-b055-b7f2511e0802
2014-10-28 20:05:46 +00:00
Christian Boltz
d3964f600e functions.inc.php
- db_get_boolean: error_log invalid values


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1672 a1433add-5e2c-0410-b055-b7f2511e0802
2014-05-11 23:09:18 +00:00
Christian Boltz
0b116c1605 version 2.91 aka 3.0 beta1
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1670 a1433add-5e2c-0410-b055-b7f2511e0802
2014-05-06 19:46:27 +00:00
Christian Boltz
8e04104b20 functions.inc.php:
- db_log():
  - replace $action_list with $LANG["pViewlog_action_$action"]
  - drop unused $table_log variable


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1658 a1433add-5e2c-0410-b055-b7f2511e0802
2014-03-16 21:52:26 +00:00
David Goodwin
b3074644ff alias can contain a ' - as in email.o'connor - need to therefore escape this...
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1639 a1433add-5e2c-0410-b055-b7f2511e0802
2014-02-17 13:43:47 +00:00
Christian Boltz
e7fe6e16ef functions.inc.php:
- check_domains(): raise TLD limit to 13 chars - even if I seriously
  doubt someone wants to use such a long TLD ;-)
  ( https://sourceforge.net/p/postfixadmin/bugs/310/ again)


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1637 a1433add-5e2c-0410-b055-b7f2511e0802
2014-02-13 20:11:05 +00:00
Christian Boltz
9bcc57cd88 functions.inc.php
- check_domain(): update regex for new, longer TLDs like .photography
  https://sourceforge.net/p/postfixadmin/bugs/310/
 


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1635 a1433add-5e2c-0410-b055-b7f2511e0802
2014-02-13 19:34:24 +00:00
Christian Boltz
252ae047d5 various files:
- get rid of global $table_* variables, use table_by_key() instead



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1601 a1433add-5e2c-0410-b055-b7f2511e0802
2013-12-08 19:41:01 +00:00
Christian Boltz
57f4ad0b75 functions.inc.php pacrypt():
- for 'system' encryption, use full hashed password as salt 
  https://sourceforge.net/p/postfixadmin/bugs/2/


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1595 a1433add-5e2c-0410-b055-b7f2511e0802
2013-12-01 21:48:14 +00:00
Christian Boltz
1a35cccf5e list-virtual.php:
- remember domain and page browser offset in $_SESSION
  (fixes 50% of http://sourceforge.net/p/postfixadmin/bugs/298/ )
- various cleanups

functions.inc.php:
- add safesession() (like safeget(), but for $_SESSION)



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1593 a1433add-5e2c-0410-b055-b7f2511e0802
2013-12-01 19:05:14 +00:00
Christian Boltz
c349420210 functions.inc.php
- db_query(): do not print out the failed query, error_log() it instead
  to avoid information leaks.
- update SF forum URL


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1592 a1433add-5e2c-0410-b055-b7f2511e0802
2013-11-18 22:57:37 +00:00
Christian Boltz
20d1ffcafc functions.inc.php:
- new function db_pgsql() to replace lots of
  "if ($CONF[database_type] == 'pgsql')) checks
- delete unused function boolconf()

several files:
- use db_pgsql() instead of checking $CONF[database_type]



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1582 a1433add-5e2c-0410-b055-b7f2511e0802
2013-11-16 00:00:53 +00:00
Christian Boltz
2bf5df92ea functions.inc.php, DomainHandler, MailboxHandler:
- move mailbox_postdeletion() to MailboxHandler
- move domain_postcreation() and domain_postdeletion() to
  DomainHandler
- adopt those functions for usage inside the *Handler (replace
  print with $this->errormsg etc.)



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1579 a1433add-5e2c-0410-b055-b7f2511e0802
2013-11-14 22:10:05 +00:00
Christian Boltz
6e2e132bac remove "postfixadmin.com" in comments in lots of files
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1558 a1433add-5e2c-0410-b055-b7f2511e0802
2013-11-10 15:57:32 +00:00
Christian Boltz
d900835997 functions.inc.php:
- pacrypt(): fix dovecot:* to work with "old" passwords that don't have 
  the {method} prefix


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1554 a1433add-5e2c-0410-b055-b7f2511e0802
2013-11-01 19:54:25 +00:00
Christian Boltz
b137e774f6 functions.inc.php:
- check_language(): remove things like ";q=0.8" before checking if 
  a language exists


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1547 a1433add-5e2c-0410-b055-b7f2511e0802
2013-10-31 20:38:14 +00:00
Christian Boltz
4d9a338eb2 After hunting an "undefined index transport" error in list-domain, I
found out that the 'Config' class is too static - it shares its static
data with the 'Lang' child class. 

This caused a conflict because we have $CONF[transport] and 
$PALANG[transport], and Config::read('transport') returned the $PALANG 
text.

To fix this, all texts are now stored as $CONF[__LANG].
I also dropped the 'Lang' class.


model/Config.php:
- mark the 'Config' class as final to ensure we don't trap into the 
  "too static" problem again.
- bool(): display and log an error message if a $CONF option does not
  contain YES or NO (that would have uncovered this bug much earlier)
- add lang() and lang_f() wrapper functions to get $PALANG texts
- remove unused $__cache and $__objects

model/Lang.php:
- deleted

common.php:
- store $PALANG as $CONF[__LANG]

lots of files:
- replace Lang::read() and Lang::read_f() calls with Config::lang()
  and Config::lang_f()




git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1536 a1433add-5e2c-0410-b055-b7f2511e0802
2013-10-13 18:11:18 +00:00
Christian Boltz
f2c2b554ac model/PFAHandler.php:
- getList: change return value to be always true (even if the database 
  result is an empty array), and die() if the database result is not an 
  array.
  This avoids some if blocks in various files to implement a fallback
  to array() on empty results.

functions.inc.php:
- list_admins(): simplify after the *Handler->getList() change
- get_domain_properties(): change a forgotten $handler->return to 
  $handler->result() (follow-up for r1534)

list-domain, list-virtual.php:
- simplify after the *Handler->getList() change



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1535 a1433add-5e2c-0410-b055-b7f2511e0802
2013-10-13 16:11:15 +00:00
Christian Boltz
43f2591d93 functions.inc.php:
- smtp_get_admin_email(), domain_postcreation(), domain_postdeletion(): 
  use Config::read instead of $CONF
- smtp_get_response(): whitespace fixes



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1532 a1433add-5e2c-0410-b055-b7f2511e0802
2013-10-08 19:30:28 +00:00
Christian Boltz
f444de402b functions.inc.php:
- pacrypt(), dovecot:* method:
  - allow "." in dovecot method (to allow a suffix like ".b64")
  - blacklist SCRAM-SHA-1 (needs -u)
  - check against list of non-salted methods to be backward compatible
    with dovecot < 2.1 again
  Thanks to Szilagyi Jozsef <szjozsef AT yahoo DOT com> for providing
  the list of non-salted methods etc.

functions.inc.php, scripts/postfixadmin-cli.php:
- drop unused global variables $table_admin and $table_alias_domain



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1529 a1433add-5e2c-0410-b055-b7f2511e0802
2013-10-07 18:42:59 +00:00
Christian Boltz
5d4240ce52 functions.inc.php:
- pacrypt: digest-md5 hashes include the username - until someone 
  implements it, let's declare it as unsupported and error out


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1525 a1433add-5e2c-0410-b055-b7f2511e0802
2013-10-03 20:29:54 +00:00
Christian Boltz
0d6f9ff99f functions.inc.php:
- pacrypt(): some small changes after Szilagyi Jozsef's patch:
  - comment out unused $crypt_method
  - change $dovecotpw default to "doveadm pw" (unrelated to the patch)
  - set $dovepasstest to "-t $pw_db" instead of having two similar
    command lines, and also shellescapearg() $pw_db
  - use "if (empty($dovepasstest))" instead of "if (empty($pw_db))"



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1524 a1433add-5e2c-0410-b055-b7f2511e0802
2013-10-03 20:01:31 +00:00
Christian Boltz
161d387485 - pacrypt(): add support for dovecot *-CRYPT passwords
doveadmin pw now has an option "-t $hash" which allows to verify 
  salted passwords (added in dovecot 2.1 AFAIK)
  Also, the {METHOD} part is no longer removed.

  Patch by Szilagyi Jozsef <szjozsef [at] yahoo.com> - thanks!

  (The schemes which requires also the username -u option is still not supported)


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1523 a1433add-5e2c-0410-b055-b7f2511e0802
2013-10-03 18:53:34 +00:00
Christian Boltz
c2ccffb76c functions.inc.php:
- mailbox_postdeletion(): use Config::read instead of global $CONF


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1522 a1433add-5e2c-0410-b055-b7f2511e0802
2013-10-03 18:35:30 +00:00
Christian Boltz
73a793433e moved the following functions from functions.inc.php to MailboxHandler.php:
- check_quota ()
- allowed_quota()
- mailbox_postcreation()
- mailbox_postedit()
- create_mailbox_subfolders()

The code was moved without any changes, except
- added leading whitespace
- removed "TODO: move to MailboxHandler" ;-)


MailboxHandler:
- change function calls for moved functions


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1515 a1433add-5e2c-0410-b055-b7f2511e0802
2013-08-07 20:05:18 +00:00
Christian Boltz
ecc84a1486 functions.inc.php:
check_quota()
  mailbox_postcreation()
  mailbox_postedit()
  create_mailbox_subfolders()
  - use Config::read() / Config::bool() instead of $CONF
  - update comment header
  - some minor changes to make the code better readable



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1514 a1433add-5e2c-0410-b055-b7f2511e0802
2013-08-07 19:34:17 +00:00
Christian Boltz
414c05e678 functions.inc.php:
- db_where_clause(): wrap condition in "(...)"


model/PFAHandler.php:
- read_from_db(): wrap condition in "(...)"


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1493 a1433add-5e2c-0410-b055-b7f2511e0802
2013-06-23 20:02:05 +00:00
Christian Boltz
a07b822906 functions.inc.php:
- remove unused functions:
  - authentication_is_admin()
  - authentication_is_user()
  - check_string()
  - admin_exist()
  - domain_exist()
- add various TODO notes


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1482 a1433add-5e2c-0410-b055-b7f2511e0802
2013-06-23 14:59:55 +00:00
Christian Boltz
79403ad709 functions.inc.php:
- delete unused function get_mailbox_properties()


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1481 a1433add-5e2c-0410-b055-b7f2511e0802
2013-06-23 14:38:22 +00:00
Christian Boltz
2cbbac134f functions.inc.php:
- replace boolconf() calls with Config::bool()


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1474 a1433add-5e2c-0410-b055-b7f2511e0802
2013-06-06 20:53:37 +00:00
Christian Boltz
71200c1049 functions.inc.php:
- check_email: mention the invalid mail address in errormessage
  (needs text change)


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1470 a1433add-5e2c-0410-b055-b7f2511e0802
2013-06-05 23:03:03 +00:00
Christian Boltz
b15319c21a functions.inc.php, model/Config.php:
- move boolconf() to Config::bool()
  boolconf() will stay for backwards compability, but new code
  should use Config::bool()


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1467 a1433add-5e2c-0410-b055-b7f2511e0802
2013-06-05 20:35:30 +00:00
Christian Boltz
66ab8fb290 functions.inc.php:
- db_log(): allow delete_admin action


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1455 a1433add-5e2c-0410-b055-b7f2511e0802
2013-04-27 19:53:09 +00:00
Christian Boltz
9c92eef2ff functions.inc.php:
- remove some unused "global $CONF"
- replace some $CONF usage with Config::read() or boolconf()


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1453 a1433add-5e2c-0410-b055-b7f2511e0802
2013-04-01 21:59:56 +00:00
Christian Boltz
70978e09a4 functions.inc.php:
- check_domain(), check_email(): 
  use Lang::read and Config::read instead of global variables 
  (global variables, at least $PALANG, don't seem to work with CLI)
- boolconf(): 
  - use Config::read instead of global $CONF
  - drop isset() check - doesn't make sense when using Config::read


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1452 a1433add-5e2c-0410-b055-b7f2511e0802
2013-04-01 21:51:29 +00:00
Christian Boltz
871bcbbe2f functions.inc.php:
- check_domain(), check_email(): instead of calling flash_error(),
  return string with error message - or empty string if everything is ok

model/AdminHandler.php, model/AliasHandler.php,
model/DomainHandler.php, model/MailboxHandler.php,
sendmail.php, users/edit-alias.php:
- adopt to changed check_domain() and check_email() return value


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1451 a1433add-5e2c-0410-b055-b7f2511e0802
2013-04-01 21:22:30 +00:00
Christian Boltz
68390b0201 functions.inc.php
- allowed_quota: if $CONF[quota] == NO, just return 0 (unlimited)

list-virtual.php:
- only eval_size($limit['maxquota']) if $CONF[quota] == YES
  ($limit['maxquota'] is not set if $CONF[quota] == NO)

Both issues (which caused PHP warnings) were found by TigerP on IRC


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1445 a1433add-5e2c-0410-b055-b7f2511e0802
2013-03-23 19:32:48 +00:00
Christian Boltz
74deef8221 functions.inc.php:
- validate_password(): use Config::read and Lang::read instead of 
  $CONF and $PALANG


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1439 a1433add-5e2c-0410-b055-b7f2511e0802
2013-03-03 00:34:53 +00:00
Christian Boltz
b4823b9e04 Finally replace create-mailbox.php with edit.php?table=mailbox :-)
configs/menu.conf:
- change url_create_mailbox to edit.php?table=mailbox

templates/list-virtual.tpl:
- replace hardcoded create-mailbox.php with {#url_create_mailbox#}

functions.inc.php:
- delete functions that are now part of MailboxHandler:
  - check_mailbox()
  - multiply_quota()
- add some TODO notes

config.inc.php:
- rewrite a comment that referenced create-mailbox.php

create-mailbox.php:
- delete - no longer needed


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1433 a1433add-5e2c-0410-b055-b7f2511e0802
2013-02-19 23:08:01 +00:00
Christian Boltz
8d2e570c03 functions.inc.php:
- _flash_string(): move return outside the foreach so that multiple
  messages can be displayed


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1430 a1433add-5e2c-0410-b055-b7f2511e0802
2013-02-19 22:22:59 +00:00
Christian Boltz
7a7403aa76 functions.inc.php:
- check_quota(): first check if enforcing quotas is disabled via $CONF[quota]


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1413 a1433add-5e2c-0410-b055-b7f2511e0802
2012-12-28 22:34:13 +00:00
Christian Boltz
ae61ee180f functions.inc.php:
- check_owner(): with AdminHandler, we can get 2 results (ALL + a domain).
  Relax the check to accept this case.



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1399 a1433add-5e2c-0410-b055-b7f2511e0802
2012-06-02 22:13:27 +00:00
Christian Boltz
17911b75d2 functions.inc.php:
- pacrypt(): no longer escape_string() the result. This fixes
  https://sourceforge.net/tracker/index.php?func=detail&aid=3094804&group_id=191583&atid=937964

create-mailbox.php, password.php:
- escape_string() the pacrypt() result

login.php:
- simplify code to require one query less (this also removes the need 
  to escape_string() the password)

I also checked the other files using pacrypt() - they don't need 
escaping or already do it.



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1397 a1433add-5e2c-0410-b055-b7f2511e0802
2012-05-28 20:05:48 +00:00
Christian Boltz
57b28f1ae2 config.inc.php:
- remove the (now superfluous) $CONF['postfix_admin_url'] config option

debian/patches/db_credentials:
- remove the section that sets $CONF['postfix_admin_url']

functions.inc.php - authentication_require_role():
- also remove $CONF['postfix_admin_url'] from comments
- remove the './' part from the redirect

Combined with the previous two commits, this fixes
https://sourceforge.net/tracker/?func=detail&aid=3039042&group_id=191583&atid=937964


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1396 a1433add-5e2c-0410-b055-b7f2511e0802
2012-05-28 18:07:33 +00:00
Christian Boltz
40011a1a98 functions.inc.php:
- authentication_require_role(): no longer use $CONF['postfix_admin_url']
  https://sourceforge.net/tracker/?func=detail&aid=3039042&group_id=191583&atid=937964


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1394 a1433add-5e2c-0410-b055-b7f2511e0802
2012-05-28 17:43:39 +00:00
Christian Boltz
a6a3483569 Some things are easier than you might think...
functions.inc.php:
- create_page_browser(): Fix count() query for pgsql. Fixes
  https://sourceforge.net/tracker/?func=detail&aid=3292648&group_id=191583&atid=937964
- surprise: the query to actually generate the pagebrowser already works 
  with pgsql :-)


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1392 a1433add-5e2c-0410-b055-b7f2511e0802
2012-05-28 17:27:17 +00:00
Christian Boltz
a211a95c39 functions.inc.php:
- check_email(): don't trim() mail address to avoid that aliases
  starting with a space are allowed. This fixes
  https://sourceforge.net/tracker/?func=detail&aid=3066059&group_id=191583&atid=937964


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1390 a1433add-5e2c-0410-b055-b7f2511e0802
2012-05-27 19:06:37 +00:00
Christian Boltz
954b18c169 functions.inc.php
- create_page_browser(): revert r1387 and...
- db_query(): ...replace it with the correct fix ;-) (avoid mysqli 
  reconnects)

The problem was that db_query() used is_resource() to check if we
already have a database connection, but a mysqli connection is an
object, not a resource.
This resulted in a new database connection for each query. Therefore
mysqli "forgot" the value of SET @row before executing the following
SELECT query (which used a new mysqli connection).

The fix is to also check with is_object() to avoid mysqli reconnects.


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1388 a1433add-5e2c-0410-b055-b7f2511e0802
2012-05-13 21:09:03 +00:00
Christian Boltz
182c67e1cd functions.inc.php:
- create_page_browser(): include MOD(idx.row, $page_size) in outer SELECT.
  This is needed on some MySQL setups which otherwise return an empty set.

Thanks to f-dens_ on IRC for helping to debug it.



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1387 a1433add-5e2c-0410-b055-b7f2511e0802
2012-05-11 23:12:03 +00:00
Christian Boltz
102cb4ed50 functions.inc.php:
- change list_admins() to use AdminHandler (code from list-admin.php)
  Note: this changes the return value format to include all details, 
  not only the usernames. Use array_keys(list_admins()) if you need
  the previous return format.
 
list-admin.php:
- replace code with a list_admins() call

list-domain.php:
- adopt to new list_admins() return value



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1386 a1433add-5e2c-0410-b055-b7f2511e0802
2012-05-07 22:53:04 +00:00
Christian Boltz
b3cdbfe88a functions.inc.php:
- _flash_string(): also accept an array of messages, not only a string
- comment updates for _flash_info() and flash_error() to reflect this change


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1378 a1433add-5e2c-0410-b055-b7f2511e0802
2012-04-29 14:39:41 +00:00
Christian Boltz
a9f252baea functions.inc.php:
- delete unused function db_boolean_to_int()


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1377 a1433add-5e2c-0410-b055-b7f2511e0802
2012-04-29 13:34:59 +00:00
Christian Boltz
3b920fc442 functions.inc.php:
- remove_from_array() was accidently wrapped by 
  if (!function_exists('hex2bin'))


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1369 a1433add-5e2c-0410-b055-b7f2511e0802
2012-04-15 20:46:29 +00:00
Christian Boltz
31b94156c4 functions.inc.php:
- delete leftover comment from (long time deleted) function create_admin()


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1368 a1433add-5e2c-0410-b055-b7f2511e0802
2012-04-15 18:58:18 +00:00
Christian Boltz
b0277b6c03 functions.inc.php
- new function remove_from_array()


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1343 a1433add-5e2c-0410-b055-b7f2511e0802
2012-02-03 23:43:45 +00:00
Christian Boltz
4e5bd47183 functions.inc.php:
- pacrypt(): escape_string() $salt for mysql_encrypt to be on the safe side


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1332 a1433add-5e2c-0410-b055-b7f2511e0802
2012-01-15 11:22:01 +00:00
Christian Boltz
19b9535e43 functions.inc.php:
- PHP around 5.3.8 includes hex2bin as native function - http://php.net/hex2bin
  therefore we have to wrap our function (which fortunately gives the same
  results) with function_exists().
  Reported by MadOtis on #postfixadmin



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1328 a1433add-5e2c-0410-b055-b7f2511e0802
2012-01-11 18:40:58 +00:00
David Goodwin
cb640c87c1 fix sql injection in pacrypt() when mysql_crypt is in use; see previous commits etc esp in the 2.3 branch
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1327 a1433add-5e2c-0410-b055-b7f2511e0802
2012-01-10 23:03:38 +00:00
Christian Boltz
e719c6c4dd create-alias.php:
- deleted, obsoleted by edit.php?table=alias

functions.inc.php:
- drop function check_alias() - it was only used by create-alias.php
  (AliasHandler has a similar function create_allowed(), which is a
  copy of check_alias() with superfluous {...} removed)

configs/menu.conf
- replace create-alias.php with edit.php?table=alias
- append "?" to url_create_mailbox to avoid temporary change in menu.tpl
  (create-mailbox is the only one which still needs ? instead of &)

templates/list-virtual.tpl:
- use {#url_create_alias#} instead of hardcoded create-alias.php

templates/menu.tpl:
- $url_domain: url-escape domain, use & instead of ?



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1317 a1433add-5e2c-0410-b055-b7f2511e0802
2012-01-10 00:30:01 +00:00
Christian Boltz
ee33647232 setup.php
- add rewritten function create_admin() (now using AdminHandler, 
  which means 25 instead of 80 lines)
- various follow-up changes to match the rewritten function create_admin()

functions.inc.php:
- delete function create_admin() - setup.php was the last file calling it
- honor POSTFIXADMIN_SETUP in authentification_get_username() to avoid
  a redirect to login.php after creating an admin with setup.php and to
  get "SETUP.PHP" for db_log()

model/AdminHandler.php:
- add TODO: implement generate_password


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1301 a1433add-5e2c-0410-b055-b7f2511e0802
2011-12-20 01:06:49 +00:00
Christian Boltz
b335abf02e functions.inc.php - db_log():
- allow log actions create_admin and edit_admin
- add edit_admin_state and delete_admin as comment/reminder that they 
  should also be logged

*.lang:
- add text for the new "create admin" and "edit admin" log actions


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1298 a1433add-5e2c-0410-b055-b7f2511e0802
2011-12-19 23:40:34 +00:00
Christian Boltz
3baf1a61c9 functions.inc.php:
- db_delete(): allow to specify additional conditions for the WHERE clause


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1285 a1433add-5e2c-0410-b055-b7f2511e0802
2011-11-27 21:24:29 +00:00
Christian Boltz
6f9d520262 list-admin.php:
- use AdminHandler
- move displaying the superadmin flag to the template

templates/adminlistadmin.tpl:
- update to the fieldnames provided by AdminHandler (name->username)
- move displaying the superadmin flag to the template

functions.inc.php:
- delete function get_admin_properties() (was only used by list-admin
  and is not needed anymore) -> 48 lines less :-)
- add TODO to list_admins() to use AdminHandler


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1282 a1433add-5e2c-0410-b055-b7f2511e0802
2011-11-26 01:09:38 +00:00
Christian Boltz
dd21f03616 functions.inc.php - db_log():
- add log action 'edit_alias_domain'
- update outdated comment to point to $action_list instead of 
  maintaining the list as comment _and_ variable

languages/*.lang
- add $PALANG['pViewlog_action_edit_alias_domain']


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1278 a1433add-5e2c-0410-b055-b7f2511e0802
2011-11-13 23:11:35 +00:00
Christian Boltz
410de7229d functions.inc.php - list_domains_for_admin():
- rewrite to work for superadmins also (will list all domains now
  instead of "ALL"), which means we can drop the admin vs. superadmin
  check at various places
- escape_string $username


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1265 a1433add-5e2c-0410-b055-b7f2511e0802
2011-11-12 20:44:35 +00:00
Christian Boltz
a4e2e9101b functions.inc.php:
- get_admin_properties(): escape_string $username instead of relying on
  the calling code to pre-escape it


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1264 a1433add-5e2c-0410-b055-b7f2511e0802
2011-11-12 19:48:27 +00:00
Christian Boltz
eba59ffd73 functions.inc.php:
- get_domain_properties(): use DomainHandler (function result mostly 
  unchanged, only difference: instead of quota_sum in bytes it now
  returns total_quota in MB)
- allowed_quota(): adopt to slightly changed return value of
  get_domain_properties()


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1248 a1433add-5e2c-0410-b055-b7f2511e0802
2011-10-29 22:58:08 +00:00
Christian Boltz
a8e626fe7f functions.inc.php:
- pacol(): new parameter $dont_write_to_db - needed to skip JOINt in 
  columns which (of course) aren't available on INSERT or UPDATE

model/DomainHandler.php:
- initStruct(): mark JOINt in columns with the dont_write_to_db flag
- store(): skip columns with the dont_write_to_db flag set (not_in_db
  columns are also/still skipped)

In non-technical terms: create-domain works now :-)


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1244 a1433add-5e2c-0410-b055-b7f2511e0802
2011-10-25 21:28:55 +00:00
David Goodwin
3c880aa0c6 if we are going to write out an sql error message we might as well include the full query
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1241 a1433add-5e2c-0410-b055-b7f2511e0802
2011-10-24 23:09:08 +00:00
Christian Boltz
7b15c4b47d functions.inc.php:
- pacol(): use Lang::read instead of global $PALANG (which is undefined
  when called from a *Handler class)


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1234 a1433add-5e2c-0410-b055-b7f2511e0802
2011-10-24 22:06:44 +00:00
Christian Boltz
7f9d947e8f model/DomainHandler.php:
- use a new SELECT query syntax (sub-SELECTs) that gets all needed
  information (including alias count, mailbox count and total quota)
  in one query and is fast as light.
  Better don't ask how long it took me to write this query, and I
  seriously hope it works with postgresql. Otherwise...!
- add alias_count, mailbox_count and total_quota (including the required
  SQL magic) to $struct
- add support for funny[tm] query tricks in $struct:
  - replacement for field name in SELECT statement
  - additional SQL after the FROM xy clause - useful for JOINs
- new function getList($condition) to get a list of domains
- order SELECT results by $this->id_field (needed for getList)
- add comment about the values used in $struct[*][type]

functions.inc.php:
- add two more optional parameters to pacrypt(): $select and $extrafrom

scripts/shells/domain.php:
- display number of existing aliases and mailboxes
- display quota sum



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1230 a1433add-5e2c-0410-b055-b7f2511e0802
2011-10-22 22:49:01 +00:00
Christian Boltz
429ef27031 functions.inc.php:
- new function db_where_clause($condition, $struct) to create a WHERE clause.
  bool values are converted with db_get_boolean() based on $struct

model/DomainHandler.php - view():
- build WHERE clause with db_where_clause()
- new array $colformat for columns which need special handling in the field list
  (that's more readable than tons of elseif on the long term, and allows easier
  customization (hook/$CONF value?))



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1228 a1433add-5e2c-0410-b055-b7f2511e0802
2011-10-22 11:12:03 +00:00
Christian Boltz
7ed7c67fbe functions.inc.php - smtp_mail():
- error_log() the error message if fsockopen() fails


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1227 a1433add-5e2c-0410-b055-b7f2511e0802
2011-10-20 12:13:39 +00:00
Christian Boltz
53d720a569 functions.inc.php:
- db_get_boolean(): allow 0 and 1 as parameters, not only boolean true/false


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1222 a1433add-5e2c-0410-b055-b7f2511e0802
2011-10-19 15:25:33 +00:00
Christian Boltz
da21a4cae2 functions.inc.php:
- new function db_boolean_to_int() to convert boolean values from the 
  database to integer (0 or 1)
- db_get_boolean(): error out on unknown $CONF[database_type]


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1208 a1433add-5e2c-0410-b055-b7f2511e0802
2011-10-16 22:19:55 +00:00
Christian Boltz
d6d4fb4748 functions.inc.php - create_admin()
- check password with validate_password()
- cleanup the handling of the success message

This fixes 50% of
https://sourceforge.net/tracker/?func=detail&aid=1951979&group_id=191583&atid=937964


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1193 a1433add-5e2c-0410-b055-b7f2511e0802
2011-09-25 18:53:58 +00:00
Christian Boltz
69b3df10e4 config.inc.php
- new config option $CONF['password_validation'] - array with regular
  expressions to check if a password is valid/good enough.
  The default configuration enforces:
  - minimum length 5 characters/digits/whatever
  - at least 2 characters
  - at least 2 digits
- removed $CONF['min_password_length'] - it's now handled in /.{5}/ in
  $CONF['password_validation']

functions.inc.php
- new function validate_password to check a given password against
  $CONF['password_validation']
- generate_password: generated password is always 8 chars long
  (instead of $CONF['min_password_length'])

edit-admin.php, users/password.php, edit-mailbox.php, setup.php:
- use validate_password instead of $CONF['min_password_length']

This implements
https://sourceforge.net/tracker/?func=detail&aid=1785513&group_id=191583&atid=937967


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1192 a1433add-5e2c-0410-b055-b7f2511e0802
2011-09-25 18:39:20 +00:00
Christian Boltz
9f2a0db106 create_admin() cleanup
functions.inc.php:
- create_admin(): use db_insert instead of INSERT queries
  (this includes automatic escaping of all values)

create-admin.php:
- use safepost instead of isset($_POST[...])
- don't escape_string post values - it's done inside create_admin now
- remove superfluous emptying of empty $tDomains for GET
- allow htmlentities-escaping for pAdminCreate_admin_username_text
- some whitespace / linebreak changes

setup.php:
- load config.inc.php only once (loading it twice will break if custom
  hook functions exist in config.*.php - "can't redefine function ...")
- use safepost instead of isset($_POST[...])
- don't escape_string post values - it's done inside create_admin now
- escape $tUsername with htmlentities() instead of escape_string



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1190 a1433add-5e2c-0410-b055-b7f2511e0802
2011-09-24 17:04:15 +00:00
Christian Boltz
bd4889a7c2 functions.inc.php - check_email():
- replace $CONF[vacation_domain] only at the end of the mail address


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1188 a1433add-5e2c-0410-b055-b7f2511e0802
2011-09-24 11:49:14 +00:00
Christian Boltz
0403a0a55a functions.inc.php - check_owner():
- escape_string() $username and $domain to prevent SQL injections
- add a TODO


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1171 a1433add-5e2c-0410-b055-b7f2511e0802
2011-08-21 20:58:20 +00:00
Christian Boltz
0656852d4e functions.inc.php:
- new function allowed_quota to get the allowed maximum quota for a mailbox.
  Based on a patch by wvolz (wvolz@SF), but with several enhancements/changes.
  https://sourceforge.net/tracker/index.php?func=detail&aid=2856577&group_id=191583&atid=937966
- added a TODO note

edit-mailbox.php:
- get maximum allowed quota via allowed_quota() instead of just using
  the maxquota of the domain


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1156 a1433add-5e2c-0410-b055-b7f2511e0802
2011-07-31 20:33:46 +00:00
Christian Boltz
d09ae9e360 model/DomainHandler.php:
- integrate $defaults in $struct to have everything in one place
- integrate field labels, descriptions etc. in $struct
- $struct now has named keys and is filled with the new pacal() helper function
- replaced TODO comments with new ones ;-)

functions.inc.php:
- new function pacol() to fill $struct with an associative array


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1145 a1433add-5e2c-0410-b055-b7f2511e0802
2011-07-29 22:06:52 +00:00
Christian Boltz
d660270ef9 functions.inc.php
- changed array item name in comment for create_admin()

This commit is part of the huge cleanup patch by Dale Blount (lnxus@SF),
https://sourceforge.net/tracker/?func=detail&atid=937966&aid=3370510&group_id=191583


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1106 a1433add-5e2c-0410-b055-b7f2511e0802
2011-07-22 20:17:17 +00:00
Christian Boltz
0bc0c29a77 functions.inc.php:
- create_admin():
  - renamed some internal variables
  - removed a variable setting that was always overwritten in the next line
  - disabled setting a var to $PALANG['pAdminCreate_admin_username_text']

This commit is part of the huge cleanup patch by Dale Blount (lnxus@SF),
https://sourceforge.net/tracker/?func=detail&atid=937966&aid=3370510&group_id=191583


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1103 a1433add-5e2c-0410-b055-b7f2511e0802
2011-07-21 22:47:53 +00:00
Christian Boltz
28cce0ca37 config.inc.php
- change default of $CONF['admin_email'] to '' and updated the comment.
  IMPORTANT: If set, this will be used as mail sender for all mails
  (2.3.x used the currently logged admin's username in most cases).
  $CONF['admin_email'] = '' will match the 2.3.x behaviour.

functions.inc.php:
- new function smtp_get_admin_email() to get mail sender address
  ($CONF[admin_email] or currently logged in admin if not set)
- changes compared to Dale's patch: 
  - added @return in comment
  - switched to /** comment style

This commit is part of the huge cleanup patch by Dale Blount (lnxus@SF),
https://sourceforge.net/tracker/?func=detail&atid=937966&aid=3370510&group_id=191583


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1093 a1433add-5e2c-0410-b055-b7f2511e0802
2011-07-19 21:12:25 +00:00
Christian Boltz
43bde95b57 functions.inc.php - pacrypt():
- if dovecotpw does not give the expected output, read stderr and write
  it to error_log()

This would have made the debugging session I just had with makomi on IRC
about an hour shorter ;-)


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1071 a1433add-5e2c-0410-b055-b7f2511e0802
2011-06-05 20:23:04 +00:00
Christian Boltz
3330e20b81 functions.inc.php - gen_show_status()
- do not leave the while loop with break - this could hide some
  undeliverable alias targets from being flagged if another alias
  target points to a domain in $CONF[show_undeliverable_exceptions]
- do not add a blank $CONF[show_status_text] if 
  $CONF[show_undeliverable] is disabled - it only wastes space ;-)


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1069 a1433add-5e2c-0410-b055-b7f2511e0802
2011-06-02 23:13:34 +00:00
Christian Boltz
b6cf638b4e functions.inc.php - gen_show_status():
don't show vacation_domain as undeliverable + various code cleanup

- don't show the vacation domain as undeliverable
  In theory this should already have worked already, but $stat_vacdomain
  missed the first letter of the domain ("xample.com" instead of
  "example.com") which broke it.
  Fixed by using $stat_domain, which has the same content anyway.
  This fixes part (2) of
  https://sourceforge.net/tracker/?func=detail&aid=1951926&group_id=191583&atid=937967
- generate the regex for $CONF[recipient_delimiter] at the start of the
  function. Besides saving some CPU cycles, this makes the code more
  readable.
- generate $stat_domain earlier and in a regex-free way
- drop $stat_catchall - it's nothing else than @ + $stat_domain
- use in_array() to check $CONF[show_undeliverable_exceptions] instead
  of a while loop



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1068 a1433add-5e2c-0410-b055-b7f2511e0802
2011-06-02 22:53:40 +00:00
Christian Boltz
b323c8d25c functions.inc.php:
- lots of whitespace changes

old:
    foo
    {

new:
	foo {


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1067 a1433add-5e2c-0410-b055-b7f2511e0802
2011-06-02 20:51:12 +00:00
Christian Boltz
9a1317edc9 functions.inc.php:
- check_quota(): whitespace changes only


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1066 a1433add-5e2c-0410-b055-b7f2511e0802
2011-05-31 22:52:51 +00:00
Christian Boltz
62261f54ae functions.inc.php: fix check_quota() to handle unlimited maxquota
- explicitely check for unlimited maxquota when checking if 
  $quota > $limit[maxquota]. Without this, $quota was always
  considered as being too big (not surprising, everything is >0 ;-)
  This fixes https://sourceforge.net/tracker/?func=detail&aid=3306926&group_id=191583&atid=937964
  (caused by domain quota patch, therefore not affecting 2.3.x)
- replaced setting $rval with return in some cases if the decision is
  final without needing to check domain quota
- added lots of comments to make understanding the function easier



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1065 a1433add-5e2c-0410-b055-b7f2511e0802
2011-05-31 22:50:22 +00:00
Christian Boltz
af6a1b6626 Add support for domain-level quota (total quota for a domain)
Based on a patch from W. Rossmann (W. Rossmann@SF),
https://sourceforge.net/tracker/index.php?func=detail&aid=2974928&group_id=191583&atid=937966
with some modifications, cleanup and adoptions to trunk (especially templates)

config.inc.php:
- new config option $CONF['domain_quota'] to enable/disable domain-level
  quota (default: enabled)
- new config option $CONF['domain_quota_default'] (default: 2 GB)

functions.inc.php - check_quota():
- add code to check the quota sum on a domain
- add optional parameter $username (to exclude that username from quota
  calculation, used by edit-mailbox)

edit-domain.php, create-domain.php,
admin_edit-domain.tpl, admin_create-domain.tpl:
- add input field and handling for domain-level quota

list-domain.php, overview-get.tpl, adminlistdomain.tpl:
- display allocated and allowed domain quota
- beautify quota and max_quota fields - display "unlimited" instead of "-1"

edit-mailbox.php:
- hand over username to check_quota()



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1042 a1433add-5e2c-0410-b055-b7f2511e0802
2011-04-19 20:18:46 +00:00
Christian Boltz
f503ba1098 functions.inc.php,
- db_delete(): if no row was deleted, return 0 (not true)
  This should not affect any existing code, but makes more sense
  for future usage.
- whitespace changes in db_delete()


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1035 a1433add-5e2c-0410-b055-b7f2511e0802
2011-04-10 22:12:56 +00:00
Christian Boltz
736074ec12 list-virtual.php: use create_page_browser().
This will speed up pagebrowser creation by about 300 times.

This fixes 
https://sourceforge.net/tracker/?func=detail&aid=2967410&group_id=191583&atid=937964

It also brings back the pagebrowser in search mode and therefore fixes
https://sourceforge.net/tracker/?func=detail&aid=2782818&group_id=191583&atid=937964

Detailed changes:
- create separate query parts for pagebrowser creation
  (without SELECT $fieldlist and LIMIT clause)
- create pagebrowser arrays with create_page_browser()
- cNav_bar class: parameter cleanup in constructor: use count() instead of 
  relying on external counting
- change cNav_bar calls accordingly


functions.inc.php:
- remove pagebrowser generation from get_domain_properties()
  (no longer needed, obsoleted by create_page_browser)


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1034 a1433add-5e2c-0410-b055-b7f2511e0802
2011-04-10 20:19:17 +00:00
Christian Boltz
799cd9c2f3 functions.inc.php:
- create_page_browser(): added queries for PgSQL (untested!)


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1033 a1433add-5e2c-0410-b055-b7f2511e0802
2011-04-10 19:20:31 +00:00
Christian Boltz
cfd1be04b2 functions.inc.php:
fully working MySQL version of create_page_browser()

- force $page_size to int and die() if it is < 2
- dropped $item_count parameter - the function now counts itsself
- include last row in the query
- return empty array (= no pagebrowser) if all rows fit in one page
- PgSQL queries are still on my TODO list


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1030 a1433add-5e2c-0410-b055-b7f2511e0802
2011-04-10 16:30:49 +00:00
Christian Boltz
63146720d4 functions.inc.php:
- generate_password(): generate more secure random password

Based on a patch from Pierre Fagrell (mrfrenzy@SF),
https://sourceforge.net/tracker/?func=detail&aid=2958698&group_id=191583&atid=937964
(with some modifications)


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1026 a1433add-5e2c-0410-b055-b7f2511e0802
2011-04-10 14:16:17 +00:00
Christian Boltz
67069e07f8 functions.inc.php:
- new function create_page_browser()

Function to create the page browser index ("a-c, d-h, ...") with light
speed (at least when compared with the current code that can take several
minutes(!) for people with lots of mailboxes or aliases).

At the moment, it only works with MySQL, has several big TODO notes 
(including notices how to implement the PostgreSQL query) and is not
yet actively used.


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1022 a1433add-5e2c-0410-b055-b7f2511e0802
2011-04-09 22:37:11 +00:00
Christian Boltz
d66262f00e Remove usage of $CONF['postfix_admin_url'] in various Location: headers
to avoid problems with wrong values of $CONF['postfix_admin_url'].

https://sourceforge.net/tracker/?func=detail&atid=937964&aid=3039042&group_id=191583
contains the technical details and reasons.

Note: $CONF['postfix_admin_url'] is still used at some places that are
a bit harder to change.


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1021 a1433add-5e2c-0410-b055-b7f2511e0802
2011-04-09 22:09:37 +00:00
Valkum
179f195bf1 *fixed db_insert - duplicate $timestamp
*fixed VacationHandler.php
*changed edit-vacation to us VacationHandler
*added todopoint to upgrade.php
*fixed problem in AliasHandler


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@981 a1433add-5e2c-0410-b055-b7f2511e0802
2011-03-06 02:14:10 +00:00
Christian Boltz
c97e5224dc Remove $username parameter from db_log()
functions.inc.php:
- remove $username parameter from function db_log()
  (now auto-detected with authentication_get_username())

various files:
- remove hardcoded username ('CONSOLE', $username etc.) in db_log() calls


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@966 a1433add-5e2c-0410-b055-b7f2511e0802
2011-02-15 22:20:27 +00:00
Christian Boltz
ba8fc89347 Preparation for removing the $username parameter from db_log()
(will be detected by authentication_get_username() instead)

scripts/postfixadmin-cli.php:
- define ("POSTFIXADMIN_CLI", 1) (we have no session running and need a
  way to tell authentication_get_username() that this is a CLI access)

functions.inc.php:
- authentication_get_username(): check for POSTFIXADMIN_CLI constant,
  return 'CLI' if set
  (hmmm, do we need a similar thing for XMLRPC?)
- db_log(): override $username parameter with authentication_get_username()
  (removing it from function parameters will be my next big commit)


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@965 a1433add-5e2c-0410-b055-b7f2511e0802
2011-02-15 21:59:03 +00:00
Christian Boltz
4a2b40e100 changed db_update parameters for the most common usecase "WHERE col=value" -
column and value are separate parameters now

functions.inc.php:
- changed function db_update() parameters - column name and value for the WHERE
  condition are now two separate parameters. This means we don't need to
  escape_string(), add quotes etc. for most UPDATE queries.
  Example call: db_update('alias', 'address', $this->username, $values_array)
- the previous db_update() is now called db_update_q()

model/UserHandler.php:
- changed db_update call to the new parameters
- removed now unused variables
- renamed $username to $E_username
- call pacrypt directly when setting the $set array, no need for $new_db_password

model/AliasHandler.php
- changed db_update call to the new parameters

edit-mailbox.php
- switched to db_update_q()


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@931 a1433add-5e2c-0410-b055-b7f2511e0802
2010-12-31 20:13:53 +00:00
Christian Boltz
93d80797ea functions.inc.php: last commit missed some changes to db_log():
- sorted $action_list to make it more readable
- cleanup


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@910 a1433add-5e2c-0410-b055-b7f2511e0802
2010-12-25 22:59:11 +00:00
Christian Boltz
900615a5ec functions.inc.php: various improvements while working on UserHandler.php
- smtp_mail(): added another (currently optional) parameter.
  It can now be called with subject and body, no need to build the mail
  header in every script that needs to send a mail.
- db_delete() did not use table_by_key. Fixed, backport queued for 
  2.3 branch
- db_insert() now has array(created,modified) as default for timestamp 
  columns so that most calls can be done without that parameter
- db_update() now has array(modified) as default for timestamp column
  so that most calls can be done without that parameter
- new functions db_begin / db_commit / db_rollback - BEGIN / COMMIT / 
  ROLLBACK wrapped in a check for $CONF['database_type'] == "pgsql".
  One more step to get rid of database-specific code in all files.
- db_log(): 
  - migrated to db_insert. This should also fix some missing quoting.
  - sorted $action_list to make it more readable
  - backport queued for 2.3 branch for both changes


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@907 a1433add-5e2c-0410-b055-b7f2511e0802
2010-12-25 22:04:16 +00:00