PostfixAdmin - web based virtual user administration interface for Postfix mail servers https://postfixadmin.github.io/postfixadmin/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

241 lines
8.0 KiB

The work of two nights causes a long changelog. Here we go: fetchmail.php: - IMPORTANT: fixed typo in database column name. If you have created the fetchmail database already, you have to rename the "pool_time" column to "poll_time" - fixed adding of new entries - don't display status fields (last poll date and result) in edit mode - validate and quote the GET and POST variables - show POSTed data again if invalid values were entered (data to display in the edit form is passed to fetchmail.tpl in $formvars) - check results of database operations and display error/success messages - check owner of target mailbox on all operations - changed password handling: empty means no change (instead of sending "******" around) - reworked and moved around large code portions - added some TODO notes fetchmail.tpl: - use data from $formvars in edit mode instead of parsing the full array - moved "new entry" below the table - replaced delete button with delete links - Note: the boolean fields need testing with PgSQL. Especially test if they are displayed as active correctly in list and edit mode! *.lang: - added several fetchmail-related strings, more to follow - added $PALANG['please_keep_this_as_last_entry'] which always has to be the last entry in the language files. This solves the problem that language-check.sh mixes up the string order when adding strings at the end of the language files. - added vim:ft=php git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@163 a1433add-5e2c-0410-b055-b7f2511e0802
19 years ago
The work of two nights causes a long changelog. Here we go: fetchmail.php: - IMPORTANT: fixed typo in database column name. If you have created the fetchmail database already, you have to rename the "pool_time" column to "poll_time" - fixed adding of new entries - don't display status fields (last poll date and result) in edit mode - validate and quote the GET and POST variables - show POSTed data again if invalid values were entered (data to display in the edit form is passed to fetchmail.tpl in $formvars) - check results of database operations and display error/success messages - check owner of target mailbox on all operations - changed password handling: empty means no change (instead of sending "******" around) - reworked and moved around large code portions - added some TODO notes fetchmail.tpl: - use data from $formvars in edit mode instead of parsing the full array - moved "new entry" below the table - replaced delete button with delete links - Note: the boolean fields need testing with PgSQL. Especially test if they are displayed as active correctly in list and edit mode! *.lang: - added several fetchmail-related strings, more to follow - added $PALANG['please_keep_this_as_last_entry'] which always has to be the last entry in the language files. This solves the problem that language-check.sh mixes up the string order when adding strings at the end of the language files. - added vim:ft=php git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@163 a1433add-5e2c-0410-b055-b7f2511e0802
19 years ago
The work of two nights causes a long changelog. Here we go: fetchmail.php: - IMPORTANT: fixed typo in database column name. If you have created the fetchmail database already, you have to rename the "pool_time" column to "poll_time" - fixed adding of new entries - don't display status fields (last poll date and result) in edit mode - validate and quote the GET and POST variables - show POSTed data again if invalid values were entered (data to display in the edit form is passed to fetchmail.tpl in $formvars) - check results of database operations and display error/success messages - check owner of target mailbox on all operations - changed password handling: empty means no change (instead of sending "******" around) - reworked and moved around large code portions - added some TODO notes fetchmail.tpl: - use data from $formvars in edit mode instead of parsing the full array - moved "new entry" below the table - replaced delete button with delete links - Note: the boolean fields need testing with PgSQL. Especially test if they are displayed as active correctly in list and edit mode! *.lang: - added several fetchmail-related strings, more to follow - added $PALANG['please_keep_this_as_last_entry'] which always has to be the last entry in the language files. This solves the problem that language-check.sh mixes up the string order when adding strings at the end of the language files. - added vim:ft=php git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@163 a1433add-5e2c-0410-b055-b7f2511e0802
19 years ago
The work of two nights causes a long changelog. Here we go: fetchmail.php: - IMPORTANT: fixed typo in database column name. If you have created the fetchmail database already, you have to rename the "pool_time" column to "poll_time" - fixed adding of new entries - don't display status fields (last poll date and result) in edit mode - validate and quote the GET and POST variables - show POSTed data again if invalid values were entered (data to display in the edit form is passed to fetchmail.tpl in $formvars) - check results of database operations and display error/success messages - check owner of target mailbox on all operations - changed password handling: empty means no change (instead of sending "******" around) - reworked and moved around large code portions - added some TODO notes fetchmail.tpl: - use data from $formvars in edit mode instead of parsing the full array - moved "new entry" below the table - replaced delete button with delete links - Note: the boolean fields need testing with PgSQL. Especially test if they are displayed as active correctly in list and edit mode! *.lang: - added several fetchmail-related strings, more to follow - added $PALANG['please_keep_this_as_last_entry'] which always has to be the last entry in the language files. This solves the problem that language-check.sh mixes up the string order when adding strings at the end of the language files. - added vim:ft=php git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@163 a1433add-5e2c-0410-b055-b7f2511e0802
19 years ago
The work of two nights causes a long changelog. Here we go: fetchmail.php: - IMPORTANT: fixed typo in database column name. If you have created the fetchmail database already, you have to rename the "pool_time" column to "poll_time" - fixed adding of new entries - don't display status fields (last poll date and result) in edit mode - validate and quote the GET and POST variables - show POSTed data again if invalid values were entered (data to display in the edit form is passed to fetchmail.tpl in $formvars) - check results of database operations and display error/success messages - check owner of target mailbox on all operations - changed password handling: empty means no change (instead of sending "******" around) - reworked and moved around large code portions - added some TODO notes fetchmail.tpl: - use data from $formvars in edit mode instead of parsing the full array - moved "new entry" below the table - replaced delete button with delete links - Note: the boolean fields need testing with PgSQL. Especially test if they are displayed as active correctly in list and edit mode! *.lang: - added several fetchmail-related strings, more to follow - added $PALANG['please_keep_this_as_last_entry'] which always has to be the last entry in the language files. This solves the problem that language-check.sh mixes up the string order when adding strings at the end of the language files. - added vim:ft=php git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@163 a1433add-5e2c-0410-b055-b7f2511e0802
19 years ago
The work of two nights causes a long changelog. Here we go: fetchmail.php: - IMPORTANT: fixed typo in database column name. If you have created the fetchmail database already, you have to rename the "pool_time" column to "poll_time" - fixed adding of new entries - don't display status fields (last poll date and result) in edit mode - validate and quote the GET and POST variables - show POSTed data again if invalid values were entered (data to display in the edit form is passed to fetchmail.tpl in $formvars) - check results of database operations and display error/success messages - check owner of target mailbox on all operations - changed password handling: empty means no change (instead of sending "******" around) - reworked and moved around large code portions - added some TODO notes fetchmail.tpl: - use data from $formvars in edit mode instead of parsing the full array - moved "new entry" below the table - replaced delete button with delete links - Note: the boolean fields need testing with PgSQL. Especially test if they are displayed as active correctly in list and edit mode! *.lang: - added several fetchmail-related strings, more to follow - added $PALANG['please_keep_this_as_last_entry'] which always has to be the last entry in the language files. This solves the problem that language-check.sh mixes up the string order when adding strings at the end of the language files. - added vim:ft=php git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@163 a1433add-5e2c-0410-b055-b7f2511e0802
19 years ago
The work of two nights causes a long changelog. Here we go: fetchmail.php: - IMPORTANT: fixed typo in database column name. If you have created the fetchmail database already, you have to rename the "pool_time" column to "poll_time" - fixed adding of new entries - don't display status fields (last poll date and result) in edit mode - validate and quote the GET and POST variables - show POSTed data again if invalid values were entered (data to display in the edit form is passed to fetchmail.tpl in $formvars) - check results of database operations and display error/success messages - check owner of target mailbox on all operations - changed password handling: empty means no change (instead of sending "******" around) - reworked and moved around large code portions - added some TODO notes fetchmail.tpl: - use data from $formvars in edit mode instead of parsing the full array - moved "new entry" below the table - replaced delete button with delete links - Note: the boolean fields need testing with PgSQL. Especially test if they are displayed as active correctly in list and edit mode! *.lang: - added several fetchmail-related strings, more to follow - added $PALANG['please_keep_this_as_last_entry'] which always has to be the last entry in the language files. This solves the problem that language-check.sh mixes up the string order when adding strings at the end of the language files. - added vim:ft=php git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@163 a1433add-5e2c-0410-b055-b7f2511e0802
19 years ago
The work of two nights causes a long changelog. Here we go: fetchmail.php: - IMPORTANT: fixed typo in database column name. If you have created the fetchmail database already, you have to rename the "pool_time" column to "poll_time" - fixed adding of new entries - don't display status fields (last poll date and result) in edit mode - validate and quote the GET and POST variables - show POSTed data again if invalid values were entered (data to display in the edit form is passed to fetchmail.tpl in $formvars) - check results of database operations and display error/success messages - check owner of target mailbox on all operations - changed password handling: empty means no change (instead of sending "******" around) - reworked and moved around large code portions - added some TODO notes fetchmail.tpl: - use data from $formvars in edit mode instead of parsing the full array - moved "new entry" below the table - replaced delete button with delete links - Note: the boolean fields need testing with PgSQL. Especially test if they are displayed as active correctly in list and edit mode! *.lang: - added several fetchmail-related strings, more to follow - added $PALANG['please_keep_this_as_last_entry'] which always has to be the last entry in the language files. This solves the problem that language-check.sh mixes up the string order when adding strings at the end of the language files. - added vim:ft=php git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@163 a1433add-5e2c-0410-b055-b7f2511e0802
19 years ago
The work of two nights causes a long changelog. Here we go: fetchmail.php: - IMPORTANT: fixed typo in database column name. If you have created the fetchmail database already, you have to rename the "pool_time" column to "poll_time" - fixed adding of new entries - don't display status fields (last poll date and result) in edit mode - validate and quote the GET and POST variables - show POSTed data again if invalid values were entered (data to display in the edit form is passed to fetchmail.tpl in $formvars) - check results of database operations and display error/success messages - check owner of target mailbox on all operations - changed password handling: empty means no change (instead of sending "******" around) - reworked and moved around large code portions - added some TODO notes fetchmail.tpl: - use data from $formvars in edit mode instead of parsing the full array - moved "new entry" below the table - replaced delete button with delete links - Note: the boolean fields need testing with PgSQL. Especially test if they are displayed as active correctly in list and edit mode! *.lang: - added several fetchmail-related strings, more to follow - added $PALANG['please_keep_this_as_last_entry'] which always has to be the last entry in the language files. This solves the problem that language-check.sh mixes up the string order when adding strings at the end of the language files. - added vim:ft=php git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@163 a1433add-5e2c-0410-b055-b7f2511e0802
19 years ago
The work of two nights causes a long changelog. Here we go: fetchmail.php: - IMPORTANT: fixed typo in database column name. If you have created the fetchmail database already, you have to rename the "pool_time" column to "poll_time" - fixed adding of new entries - don't display status fields (last poll date and result) in edit mode - validate and quote the GET and POST variables - show POSTed data again if invalid values were entered (data to display in the edit form is passed to fetchmail.tpl in $formvars) - check results of database operations and display error/success messages - check owner of target mailbox on all operations - changed password handling: empty means no change (instead of sending "******" around) - reworked and moved around large code portions - added some TODO notes fetchmail.tpl: - use data from $formvars in edit mode instead of parsing the full array - moved "new entry" below the table - replaced delete button with delete links - Note: the boolean fields need testing with PgSQL. Especially test if they are displayed as active correctly in list and edit mode! *.lang: - added several fetchmail-related strings, more to follow - added $PALANG['please_keep_this_as_last_entry'] which always has to be the last entry in the language files. This solves the problem that language-check.sh mixes up the string order when adding strings at the end of the language files. - added vim:ft=php git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@163 a1433add-5e2c-0410-b055-b7f2511e0802
19 years ago
The work of two nights causes a long changelog. Here we go: fetchmail.php: - IMPORTANT: fixed typo in database column name. If you have created the fetchmail database already, you have to rename the "pool_time" column to "poll_time" - fixed adding of new entries - don't display status fields (last poll date and result) in edit mode - validate and quote the GET and POST variables - show POSTed data again if invalid values were entered (data to display in the edit form is passed to fetchmail.tpl in $formvars) - check results of database operations and display error/success messages - check owner of target mailbox on all operations - changed password handling: empty means no change (instead of sending "******" around) - reworked and moved around large code portions - added some TODO notes fetchmail.tpl: - use data from $formvars in edit mode instead of parsing the full array - moved "new entry" below the table - replaced delete button with delete links - Note: the boolean fields need testing with PgSQL. Especially test if they are displayed as active correctly in list and edit mode! *.lang: - added several fetchmail-related strings, more to follow - added $PALANG['please_keep_this_as_last_entry'] which always has to be the last entry in the language files. This solves the problem that language-check.sh mixes up the string order when adding strings at the end of the language files. - added vim:ft=php git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@163 a1433add-5e2c-0410-b055-b7f2511e0802
19 years ago
The work of two nights causes a long changelog. Here we go: fetchmail.php: - IMPORTANT: fixed typo in database column name. If you have created the fetchmail database already, you have to rename the "pool_time" column to "poll_time" - fixed adding of new entries - don't display status fields (last poll date and result) in edit mode - validate and quote the GET and POST variables - show POSTed data again if invalid values were entered (data to display in the edit form is passed to fetchmail.tpl in $formvars) - check results of database operations and display error/success messages - check owner of target mailbox on all operations - changed password handling: empty means no change (instead of sending "******" around) - reworked and moved around large code portions - added some TODO notes fetchmail.tpl: - use data from $formvars in edit mode instead of parsing the full array - moved "new entry" below the table - replaced delete button with delete links - Note: the boolean fields need testing with PgSQL. Especially test if they are displayed as active correctly in list and edit mode! *.lang: - added several fetchmail-related strings, more to follow - added $PALANG['please_keep_this_as_last_entry'] which always has to be the last entry in the language files. This solves the problem that language-check.sh mixes up the string order when adding strings at the end of the language files. - added vim:ft=php git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@163 a1433add-5e2c-0410-b055-b7f2511e0802
19 years ago
The work of two nights causes a long changelog. Here we go: fetchmail.php: - IMPORTANT: fixed typo in database column name. If you have created the fetchmail database already, you have to rename the "pool_time" column to "poll_time" - fixed adding of new entries - don't display status fields (last poll date and result) in edit mode - validate and quote the GET and POST variables - show POSTed data again if invalid values were entered (data to display in the edit form is passed to fetchmail.tpl in $formvars) - check results of database operations and display error/success messages - check owner of target mailbox on all operations - changed password handling: empty means no change (instead of sending "******" around) - reworked and moved around large code portions - added some TODO notes fetchmail.tpl: - use data from $formvars in edit mode instead of parsing the full array - moved "new entry" below the table - replaced delete button with delete links - Note: the boolean fields need testing with PgSQL. Especially test if they are displayed as active correctly in list and edit mode! *.lang: - added several fetchmail-related strings, more to follow - added $PALANG['please_keep_this_as_last_entry'] which always has to be the last entry in the language files. This solves the problem that language-check.sh mixes up the string order when adding strings at the end of the language files. - added vim:ft=php git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@163 a1433add-5e2c-0410-b055-b7f2511e0802
19 years ago
The work of two nights causes a long changelog. Here we go: fetchmail.php: - IMPORTANT: fixed typo in database column name. If you have created the fetchmail database already, you have to rename the "pool_time" column to "poll_time" - fixed adding of new entries - don't display status fields (last poll date and result) in edit mode - validate and quote the GET and POST variables - show POSTed data again if invalid values were entered (data to display in the edit form is passed to fetchmail.tpl in $formvars) - check results of database operations and display error/success messages - check owner of target mailbox on all operations - changed password handling: empty means no change (instead of sending "******" around) - reworked and moved around large code portions - added some TODO notes fetchmail.tpl: - use data from $formvars in edit mode instead of parsing the full array - moved "new entry" below the table - replaced delete button with delete links - Note: the boolean fields need testing with PgSQL. Especially test if they are displayed as active correctly in list and edit mode! *.lang: - added several fetchmail-related strings, more to follow - added $PALANG['please_keep_this_as_last_entry'] which always has to be the last entry in the language files. This solves the problem that language-check.sh mixes up the string order when adding strings at the end of the language files. - added vim:ft=php git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@163 a1433add-5e2c-0410-b055-b7f2511e0802
19 years ago
The work of two nights causes a long changelog. Here we go: fetchmail.php: - IMPORTANT: fixed typo in database column name. If you have created the fetchmail database already, you have to rename the "pool_time" column to "poll_time" - fixed adding of new entries - don't display status fields (last poll date and result) in edit mode - validate and quote the GET and POST variables - show POSTed data again if invalid values were entered (data to display in the edit form is passed to fetchmail.tpl in $formvars) - check results of database operations and display error/success messages - check owner of target mailbox on all operations - changed password handling: empty means no change (instead of sending "******" around) - reworked and moved around large code portions - added some TODO notes fetchmail.tpl: - use data from $formvars in edit mode instead of parsing the full array - moved "new entry" below the table - replaced delete button with delete links - Note: the boolean fields need testing with PgSQL. Especially test if they are displayed as active correctly in list and edit mode! *.lang: - added several fetchmail-related strings, more to follow - added $PALANG['please_keep_this_as_last_entry'] which always has to be the last entry in the language files. This solves the problem that language-check.sh mixes up the string order when adding strings at the end of the language files. - added vim:ft=php git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@163 a1433add-5e2c-0410-b055-b7f2511e0802
19 years ago
The work of two nights causes a long changelog. Here we go: fetchmail.php: - IMPORTANT: fixed typo in database column name. If you have created the fetchmail database already, you have to rename the "pool_time" column to "poll_time" - fixed adding of new entries - don't display status fields (last poll date and result) in edit mode - validate and quote the GET and POST variables - show POSTed data again if invalid values were entered (data to display in the edit form is passed to fetchmail.tpl in $formvars) - check results of database operations and display error/success messages - check owner of target mailbox on all operations - changed password handling: empty means no change (instead of sending "******" around) - reworked and moved around large code portions - added some TODO notes fetchmail.tpl: - use data from $formvars in edit mode instead of parsing the full array - moved "new entry" below the table - replaced delete button with delete links - Note: the boolean fields need testing with PgSQL. Especially test if they are displayed as active correctly in list and edit mode! *.lang: - added several fetchmail-related strings, more to follow - added $PALANG['please_keep_this_as_last_entry'] which always has to be the last entry in the language files. This solves the problem that language-check.sh mixes up the string order when adding strings at the end of the language files. - added vim:ft=php git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@163 a1433add-5e2c-0410-b055-b7f2511e0802
19 years ago
The work of two nights causes a long changelog. Here we go: fetchmail.php: - IMPORTANT: fixed typo in database column name. If you have created the fetchmail database already, you have to rename the "pool_time" column to "poll_time" - fixed adding of new entries - don't display status fields (last poll date and result) in edit mode - validate and quote the GET and POST variables - show POSTed data again if invalid values were entered (data to display in the edit form is passed to fetchmail.tpl in $formvars) - check results of database operations and display error/success messages - check owner of target mailbox on all operations - changed password handling: empty means no change (instead of sending "******" around) - reworked and moved around large code portions - added some TODO notes fetchmail.tpl: - use data from $formvars in edit mode instead of parsing the full array - moved "new entry" below the table - replaced delete button with delete links - Note: the boolean fields need testing with PgSQL. Especially test if they are displayed as active correctly in list and edit mode! *.lang: - added several fetchmail-related strings, more to follow - added $PALANG['please_keep_this_as_last_entry'] which always has to be the last entry in the language files. This solves the problem that language-check.sh mixes up the string order when adding strings at the end of the language files. - added vim:ft=php git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@163 a1433add-5e2c-0410-b055-b7f2511e0802
19 years ago
The work of two nights causes a long changelog. Here we go: fetchmail.php: - IMPORTANT: fixed typo in database column name. If you have created the fetchmail database already, you have to rename the "pool_time" column to "poll_time" - fixed adding of new entries - don't display status fields (last poll date and result) in edit mode - validate and quote the GET and POST variables - show POSTed data again if invalid values were entered (data to display in the edit form is passed to fetchmail.tpl in $formvars) - check results of database operations and display error/success messages - check owner of target mailbox on all operations - changed password handling: empty means no change (instead of sending "******" around) - reworked and moved around large code portions - added some TODO notes fetchmail.tpl: - use data from $formvars in edit mode instead of parsing the full array - moved "new entry" below the table - replaced delete button with delete links - Note: the boolean fields need testing with PgSQL. Especially test if they are displayed as active correctly in list and edit mode! *.lang: - added several fetchmail-related strings, more to follow - added $PALANG['please_keep_this_as_last_entry'] which always has to be the last entry in the language files. This solves the problem that language-check.sh mixes up the string order when adding strings at the end of the language files. - added vim:ft=php git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@163 a1433add-5e2c-0410-b055-b7f2511e0802
19 years ago
The work of two nights causes a long changelog. Here we go: fetchmail.php: - IMPORTANT: fixed typo in database column name. If you have created the fetchmail database already, you have to rename the "pool_time" column to "poll_time" - fixed adding of new entries - don't display status fields (last poll date and result) in edit mode - validate and quote the GET and POST variables - show POSTed data again if invalid values were entered (data to display in the edit form is passed to fetchmail.tpl in $formvars) - check results of database operations and display error/success messages - check owner of target mailbox on all operations - changed password handling: empty means no change (instead of sending "******" around) - reworked and moved around large code portions - added some TODO notes fetchmail.tpl: - use data from $formvars in edit mode instead of parsing the full array - moved "new entry" below the table - replaced delete button with delete links - Note: the boolean fields need testing with PgSQL. Especially test if they are displayed as active correctly in list and edit mode! *.lang: - added several fetchmail-related strings, more to follow - added $PALANG['please_keep_this_as_last_entry'] which always has to be the last entry in the language files. This solves the problem that language-check.sh mixes up the string order when adding strings at the end of the language files. - added vim:ft=php git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@163 a1433add-5e2c-0410-b055-b7f2511e0802
19 years ago
  1. <?php
  2. /**
  3. * Postfix Admin
  4. *
  5. * LICENSE
  6. * This source file is subject to the GPL license that is bundled with
  7. * this package in the file LICENSE.TXT.
  8. *
  9. * Further details on the project are available at :
  10. * http://www.postfixadmin.com or http://postfixadmin.sf.net
  11. *
  12. * @version $Id$
  13. * @license GNU GPL v2 or later.
  14. *
  15. * File: fetchmail.php
  16. * Responsible for setting up fetchmail
  17. *
  18. * @version $Id$
  19. * @license GNU GPL v2 or later.
  20. *
  21. * Template Variables:
  22. *
  23. * Form POST \ GET Variables:
  24. *
  25. * GET:
  26. * - edit
  27. * - delete
  28. * - new
  29. *
  30. * POST:
  31. * - save
  32. * - cancel
  33. * - all editable form values, see $fm_struct
  34. */
  35. require_once('common.php');
  36. authentication_require_role('admin');
  37. $extra_options = 0;
  38. if ($CONF['fetchmail_extra_options'] == 'YES') $extra_options = 1;
  39. # import control GET/POST variables. Form values are imported below.
  40. $new = (int) safeget ("new") == 1 ? 1:0;
  41. $edit = (int) safeget ("edit");
  42. $delete = (int) safeget ("delete");
  43. $save = safepost("save") != "" ? 1:0;
  44. $cancel = safepost("cancel") != "" ? 1:0;
  45. $display_status = 1;
  46. if ($new || $edit) $display_status = 0;
  47. $fm_struct=array( // list($editible,$view,$type)
  48. # field name allow editing? display field? type
  49. "id" => array(0, 0, 'id' ),
  50. "mailbox" => array(1, 1, 'enum' ),
  51. "src_server" => array(1, 1, 'text' ),
  52. "src_auth" => array(1, 1, 'enum' ),
  53. "src_user" => array(1, 1, 'text' ),
  54. "src_password" => array(1, 0, 'password' ),
  55. "src_folder" => array(1, 1, 'text' ),
  56. "poll_time" => array(1, 1, 'num' ),
  57. "fetchall" => array(1, 1, 'bool' ),
  58. "keep" => array(1, 1, 'bool' ),
  59. "protocol" => array(1, 1, 'enum' ),
  60. "extra_options" => array($extra_options, $extra_options, 'longtext' ),
  61. "mda" => array($extra_options, $extra_options, 'longtext' ),
  62. "date" => array(0, $display_status, 'text' ),
  63. "returned_text" => array(0, $display_status, 'longtext' ),
  64. );
  65. # labels and descriptions are taken from $PALANG['pFetchmail_field_xxx'] and $PALANG['pFetchmail_desc_xxx']
  66. # TODO: After pressing save or cancel in edit form, date and returned text are not displayed in list view.
  67. # TODO: Reason: $display_status is set before $new and $edit are reset to 0.
  68. # TODO: Fix: split the "display field?" column into "display in list" and "display in edit mode".
  69. $SESSID_USERNAME = authentication_get_username();
  70. if (!$SESSID_USERNAME )
  71. exit;
  72. $fm_defaults=array(
  73. "id" =>0,
  74. "mailbox" => array($SESSID_USERNAME),
  75. "poll_time" => 10,
  76. "src_auth" =>
  77. array('password','kerberos_v5','kerberos','kerberos_v4','gssapi','cram-md5','otp','ntlm','msn','ssh','any'),
  78. "protocol" =>
  79. array('POP3','IMAP','POP2','ETRN','AUTO'),
  80. );
  81. $list_domains = list_domains_for_admin ($SESSID_USERNAME);
  82. $user_domains=implode(", ",array_values($list_domains)); # for displaying
  83. $user_domains_sql=implode("','",escape_string(array_values($list_domains))); # for SQL
  84. $sql="SELECT username FROM mailbox WHERE domain in ('".$user_domains_sql."')"; # TODO: replace with domain selection dropdown
  85. $res = db_query ($sql);
  86. if ($res['rows'] > 0){
  87. $fm_defaults["mailbox"]=array();
  88. while ($name = db_array ($res['result'])){
  89. $fm_defaults["mailbox"][] = $name["username"];
  90. }
  91. }
  92. else{
  93. $fm_defaults["mailbox"]=array();
  94. $fm_defaults["mailbox"][]=$SESSID_USERNAME; # TODO: Does this really make sense? Or should we display a message "please create a mailbox first!"?
  95. }
  96. $row_id = 0;
  97. if ($delete) {
  98. $row_id = $delete;
  99. } elseif ($edit) {
  100. $row_id = $edit;
  101. }
  102. if ($row_id) {
  103. $result = db_query ("SELECT ".implode(",",escape_string(array_keys($fm_struct)))." FROM fetchmail WHERE id=" . $row_id);
  104. if ($result['rows'] > 0) {
  105. $edit_row = db_array ($result['result']);
  106. $account = $edit_row['src_user'] . " @ " . $edit_row['src_server'];
  107. }
  108. $edit_row_domain = explode('@', $edit_row['mailbox']);
  109. if ($result['rows'] <= 0 || !check_owner($SESSID_USERNAME, $edit_row_domain[1])) { # owner check for $edit and $delete
  110. flash_error(sprintf($PALANG['pFetchmail_error_invalid_id'], $row_id));
  111. $edit = 0; $delete = 0;
  112. }
  113. }
  114. if ($cancel) { # cancel $new or $edit
  115. $edit=0;
  116. $new=0;
  117. } elseif ($delete) { # delete an entry
  118. $result = db_query ("delete from fetchmail WHERE id=".$delete);
  119. if ($result['rows'] != 1)
  120. {
  121. flash_error($PALANG['pDelete_delete_error']) . '</span>';
  122. } else {
  123. flash_info(sprintf($PALANG['pDelete_delete_success'],$account));
  124. }
  125. $delete=0;
  126. } elseif ( ($edit || $new) && $save) { # $edit or $new AND save button pressed
  127. $formvars=array();
  128. foreach($fm_struct as $key=>$row){
  129. list($editible,$view,$type)=$row;
  130. if ($editible != 0){
  131. $func="_inp_".$type;
  132. $val=safepost($key);
  133. if ($type!="password" || strlen($val) > 0) { # skip on empty (aka unchanged) password
  134. $formvars[$key]= escape_string( function_exists($func) ?$func($val) :$val);
  135. }
  136. }
  137. }
  138. $formvars['id'] = $edit; # results in 0 on $new
  139. if($CONF['database_type'] == 'pgsql' && $new) {
  140. // skip - shouldn't need to specify this as it will default to the next available value anyway.
  141. unset($formvars['id']);
  142. }
  143. if (!in_array($formvars['mailbox'], $fm_defaults['mailbox'])) {
  144. flash_error($PALANG['pFetchmail_invalid_mailbox']);
  145. $save = 0;
  146. }
  147. if ($formvars['src_server'] == '') {
  148. flash_error($PALANG['pFetchmail_server_missing']);
  149. # TODO: validate domain name
  150. $save = 0;
  151. }
  152. if (empty($formvars['src_user']) ) {
  153. flash_error($PALANG['pFetchmail_user_missing']);
  154. $save = 0;
  155. }
  156. if ($new && empty($formvars['src_password']) ) {
  157. flash_error($PALANG['pFetchmail_password_missing']);
  158. $save = 0;
  159. }
  160. if ($save) {
  161. if ($new) {
  162. $sql="INSERT INTO fetchmail (".implode(",",escape_string(array_keys($formvars))).") VALUES ('".implode("','",escape_string($formvars))."')";
  163. } else { # $edit
  164. foreach(array_keys($formvars) as $key) {
  165. $formvars[$key] = escape_string($key) . "='" . escape_string($formvars[$key]) . "'";
  166. }
  167. $sql="UPDATE fetchmail SET ".implode(",",$formvars).",returned_text='', date=NOW() WHERE id=".$edit;
  168. }
  169. $result = db_query ($sql);
  170. if ($result['rows'] != 1)
  171. {
  172. flash_error($PALANG['pFetchmail_database_save_error']);
  173. } else {
  174. flash_info($PALANG['pFetchmail_database_save_success']);
  175. $edit = 0; $new = 0; # display list after saving
  176. }
  177. } else {
  178. $formvars['src_password'] = ''; # never display password
  179. }
  180. } elseif ($edit) { # edit entry form
  181. $formvars = $edit_row;
  182. $formvars['src_password'] = '';
  183. } elseif ($new) { # create entry form
  184. foreach (array_keys($fm_struct) as $value) {
  185. if (isset($fm_defaults[$value])) {
  186. $formvars[$value] = $fm_defaults[$value];
  187. } else {
  188. $formvars[$value] = '';
  189. }
  190. }
  191. }
  192. $tFmail = array();
  193. if ($edit + $new == 0) { # display list
  194. $res = db_query ("SELECT ".implode(",",escape_string(array_keys($fm_struct)))." FROM fetchmail order by id desc");
  195. if ($res['rows'] > 0) {
  196. while ($row = db_array ($res['result'])) {
  197. $tFmail[] = $row;
  198. }
  199. }
  200. }
  201. function _inp_num($val){
  202. return (int)($val);
  203. }
  204. function _inp_bool($val){
  205. return $val ? db_get_boolean(true): db_get_boolean(false);
  206. }
  207. function _inp_password($val){
  208. return base64_encode($val);
  209. }
  210. include ("./templates/header.php");
  211. include ("./templates/menu.php");
  212. include ("./templates/fetchmail.php");
  213. include ("./templates/footer.php");
  214. /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */
  215. ?>