File: edit-domain.php

package info (click to toggle)
postfixadmin 2.3.5-2+deb7u1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 6,200 kB
  • sloc: php: 25,767; xml: 14,485; perl: 964; sh: 664; python: 169; makefile: 84
file content (122 lines) | stat: -rw-r--r-- 3,552 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?php
/** 
 * Postfix Admin 
 * 
 * LICENSE 
 * This source file is subject to the GPL license that is bundled with  
 * this package in the file LICENSE.TXT. 
 * 
 * Further details on the project are available at : 
 *     http://www.postfixadmin.com or http://postfixadmin.sf.net 
 * 
 * @version $Id: edit-domain.php 571 2009-02-26 22:57:11Z christian_boltz $ 
 * @license GNU GPL v2 or later. 
 * 
 * File: edit-domain.php 
 * Updates the properties of a domain.
 * Template File: admin_edit-domain.php
 *
 * Template Variables:
 *
 * tDescription
 * tAliases
 * tMailboxes
 * tMaxquota
 * tActive
 *
 * Form POST \ GET Variables:
 *
 * fDescription
 * fAliases
 * fMailboxes
 * fMaxquota
 * fActive
 */

require_once('common.php');

authentication_require_role('global-admin');

if ($_SERVER['REQUEST_METHOD'] == "GET")
{
    if (isset ($_GET['domain']))
    {
        $domain = escape_string ($_GET['domain']);
        $domain_properties = get_domain_properties ($domain);

        $tDescription = $domain_properties['description'];
        $tAliases = $domain_properties['aliases'];
        $tMailboxes = $domain_properties['mailboxes'];
        $tMaxquota = $domain_properties['maxquota'];
        $tTransport = $domain_properties['transport'];
        $tBackupmx = $domain_properties['backupmx'];
        $tActive = $domain_properties['active'];
    }
}

if ($_SERVER['REQUEST_METHOD'] == "POST")
{
    if (isset ($_GET['domain'])) $domain = escape_string ($_GET['domain']);

    if (isset ($_POST['fDescription'])) $fDescription = escape_string ($_POST['fDescription']);
    if (isset ($_POST['fAliases'])) $fAliases = intval($_POST['fAliases']);
    if (isset ($_POST['fMailboxes'])) $fMailboxes = intval($_POST['fMailboxes']);
    if (isset ($_POST['fMaxquota'])) {
        $fMaxquota = intval($_POST['fMaxquota']);
    } else {
        $fMaxquota = 0;
    }

    $fTransport = $CONF['transport_default'];
    if($CONF['transport'] != 'NO' && isset ($_POST['fTransport'])) {
        $fTransport = escape_string($_POST['fTransport']);
        if(!in_array($fTransport, $CONF['transport_options'])) {
            die("Invalid transport option given; check config.inc.php");
        }
    }

    if (isset ($_POST['fBackupmx'])) $fBackupmx = escape_string ($_POST['fBackupmx']);
    if (isset ($_POST['fActive'])) $fActive = escape_string ($_POST['fActive']);

    if ($fBackupmx == "on")
    {
        $fBackupmx = 1;
        $sqlBackupmx = db_get_boolean(True);
    }
    else
    {
        $fBackupmx = 0;
        $sqlBackupmx = db_get_boolean(False);
    }

    if ($fActive == "on") { 
        $sqlActive = db_get_boolean(True);
    }
    else {
        $sqlActive = db_get_boolean(False);
    }

    $sqltransport = "";
    if($CONF['transport'] != 'NO') { # only change transport if it is allowed in config. Otherwise, keep the old value.
       $sqltransport = "transport='$fTransport',";
    }

    $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'");
    if ($result['rows'] == 1)
    {
        header ("Location: list-domain.php");
        exit;
    }
    else
    {
        $tMessage = $PALANG['pAdminEdit_domain_result_error'];
    }
}

include ("templates/header.php");
include ("templates/menu.php");
include ("templates/admin_edit-domain.php");
include ("templates/footer.php");

/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
?>