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.

128 lines
3.8 KiB

  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: edit-domain.php
  16. * Updates the properties of a domain.
  17. * Template File: admin_edit-domain.tpl
  18. *
  19. * Template Variables:
  20. *
  21. * tDescription
  22. * tAliases
  23. * tMailboxes
  24. * tMaxquota
  25. * tActive
  26. *
  27. * Form POST \ GET Variables:
  28. *
  29. * fDescription
  30. * fAliases
  31. * fMailboxes
  32. * fMaxquota
  33. * fActive
  34. */
  35. require_once('common.php');
  36. authentication_require_role('global-admin');
  37. if ($_SERVER['REQUEST_METHOD'] == "GET")
  38. {
  39. if (isset ($_GET['domain']))
  40. {
  41. $domain = escape_string ($_GET['domain']);
  42. $domain_properties = get_domain_properties ($domain);
  43. $tDescription = $domain_properties['description'];
  44. $tAliases = $domain_properties['aliases'];
  45. $tMailboxes = $domain_properties['mailboxes'];
  46. $tMaxquota = $domain_properties['maxquota'];
  47. $tTransport = $domain_properties['transport'];
  48. $tBackupmx = $domain_properties['backupmx'];
  49. $tActive = $domain_properties['active'];
  50. }
  51. }
  52. if ($_SERVER['REQUEST_METHOD'] == "POST")
  53. {
  54. if (isset ($_GET['domain'])) $domain = escape_string ($_GET['domain']);
  55. if (isset ($_POST['fDescription'])) $fDescription = escape_string ($_POST['fDescription']);
  56. if (isset ($_POST['fAliases'])) $fAliases = intval($_POST['fAliases']);
  57. if (isset ($_POST['fMailboxes'])) $fMailboxes = intval($_POST['fMailboxes']);
  58. if (isset ($_POST['fMaxquota'])) {
  59. $fMaxquota = intval($_POST['fMaxquota']);
  60. } else {
  61. $fMaxquota = 0;
  62. }
  63. $fTransport = $CONF['transport_default'];
  64. if($CONF['transport'] != 'NO' && isset ($_POST['fTransport'])) {
  65. $fTransport = escape_string($_POST['fTransport']);
  66. if(!in_array($fTransport, $CONF['transport_options'])) {
  67. die("Invalid transport option given; check config.inc.php");
  68. }
  69. }
  70. if (isset ($_POST['fBackupmx'])) $fBackupmx = escape_string ($_POST['fBackupmx']);
  71. if (isset ($_POST['fActive'])) $fActive = escape_string ($_POST['fActive']);
  72. if ($fBackupmx == "on")
  73. {
  74. $fBackupmx = 1;
  75. $sqlBackupmx = db_get_boolean(True);
  76. }
  77. else
  78. {
  79. $fBackupmx = 0;
  80. $sqlBackupmx = db_get_boolean(False);
  81. }
  82. if ($fActive == "on") {
  83. $sqlActive = db_get_boolean(True);
  84. }
  85. else {
  86. $sqlActive = db_get_boolean(False);
  87. }
  88. $sqltransport = "";
  89. if($CONF['transport'] != 'NO') { # only change transport if it is allowed in config. Otherwise, keep the old value.
  90. $sqltransport = "transport='$fTransport',";
  91. }
  92. $result = db_query ("UPDATE $table_domain SET description='$fDescription',aliases=$fAliases,mailboxes=$fMailboxes,maxquota=$fMaxquota,$sqltransport backupmx='$sqlBackupmx',active='$sqlActive',modified=NOW() WHERE domain='$domain'");
  93. if ($result['rows'] == 1)
  94. {
  95. header ("Location: list-domain.php");
  96. exit;
  97. }
  98. else
  99. {
  100. $tMessage = $PALANG['pAdminEdit_domain_result_error'];
  101. }
  102. }
  103. $smarty->assign ('domain', $domain);
  104. $smarty->assign ('tDescription', $tDescription);
  105. $smarty->assign ('tAliases', $tAliases);
  106. $smarty->assign ('tMailboxes', $tMailboxes);
  107. $smarty->assign ('tMaxquota', $tMaxquota);
  108. $smarty->assign ('select_options', select_options($CONF['transport_options'], array($tTransport)), false);
  109. if ($tBackupmx) $smarty->assign ('tBackupmx', ' checked="checked"');
  110. if ($tActive) $smarty->assign ('tActive', ' checked="checked"');
  111. $smarty->assign ('tMessage', $tMessage,false);
  112. $smarty->assign ('smarty_template', 'admin_edit-domain');
  113. $smarty->display ('index.tpl');
  114. /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */