inc/toolkit.inc.php
author rejo
Thu, 24 Apr 2008 22:33:28 +0000
changeset 141 1ede5203910d
parent 138 3e36ebbfe048
child 148 362a952b0a12
permissions -rw-r--r--
[feladat @ 247] If the user was listing the details of a zone that did not exist, all kinds of error messages were given. Now we first determine if the ID is valid and if not, immediately return the correct error message.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
     1
<?php
47
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
     2
119
f74e4f88b680 [feladat @ 222]
rejo
parents: 111
diff changeset
     3
/*  Poweradmin, a friendly web-based admin tool for PowerDNS.
47
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
     4
 *  See <https://rejo.zenger.nl/poweradmin> for more details.
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
     5
 *
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
     6
 *  Copyright 2007, 2008  Rejo Zenger <rejo@zenger.nl>
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
     7
 *
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
     8
 *  This program is free software: you can redistribute it and/or modify
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
     9
 *  it under the terms of the GNU General Public License as published by
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    10
 *  the Free Software Foundation, either version 3 of the License, or
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    11
 *  (at your option) any later version.
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    12
 *
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    13
 *  This program is distributed in the hope that it will be useful,
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    16
 *  GNU General Public License for more details.
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    17
 *
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    18
 *  You should have received a copy of the GNU General Public License
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    19
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    20
 */
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
    21
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    22
session_start();
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    23
137
79c33038ca14 [feladat @ 243]
rejo
parents: 136
diff changeset
    24
include_once("config-me.inc.php");
74
43c31dc98305 [feladat @ 121]
peter
parents: 71
diff changeset
    25
43c31dc98305 [feladat @ 121]
peter
parents: 71
diff changeset
    26
if(!@include_once("config.inc.php"))
43c31dc98305 [feladat @ 121]
peter
parents: 71
diff changeset
    27
{
43c31dc98305 [feladat @ 121]
peter
parents: 71
diff changeset
    28
	error( _('You have to create a config.inc.php!') );
43c31dc98305 [feladat @ 121]
peter
parents: 71
diff changeset
    29
}
43c31dc98305 [feladat @ 121]
peter
parents: 71
diff changeset
    30
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    31
/*************
74
43c31dc98305 [feladat @ 121]
peter
parents: 71
diff changeset
    32
 * Constants *
43c31dc98305 [feladat @ 121]
peter
parents: 71
diff changeset
    33
 *************/
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    34
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    35
if (isset($_GET["start"])) {
136
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    36
   define('ROWSTART', (($_GET["start"] - 1) * $iface_rowamount));
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    37
   } else {
79
0c0aa144356a [feladat @ 156]
peter
parents: 77
diff changeset
    38
   define('ROWSTART', 0);
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    39
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    40
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    41
if (isset($_GET["letter"])) {
79
0c0aa144356a [feladat @ 156]
peter
parents: 77
diff changeset
    42
   define('LETTERSTART', $_GET["letter"]);
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    43
   $_SESSION["letter"] = $_GET["letter"];
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    44
} elseif(isset($_SESSION["letter"])) {
79
0c0aa144356a [feladat @ 156]
peter
parents: 77
diff changeset
    45
   define('LETTERSTART', $_SESSION["letter"]);
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    46
} else {
79
0c0aa144356a [feladat @ 156]
peter
parents: 77
diff changeset
    47
   define('LETTERSTART', "a");
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    48
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    49
138
3e36ebbfe048 [feladat @ 244]
rejo
parents: 137
diff changeset
    50
$valid_tlds = array(
3e36ebbfe048 [feladat @ 244]
rejo
parents: 137
diff changeset
    51
  "ac", "ad", "ae", "aero", "af", "ag", "ai", "al", "am", "an", "ao", "aq", "ar",
3e36ebbfe048 [feladat @ 244]
rejo
parents: 137
diff changeset
    52
  "arpa", "as", "asia", "at", "au", "aw", "ax", "az", "ba", "bb", "bd", "be",
3e36ebbfe048 [feladat @ 244]
rejo
parents: 137
diff changeset
    53
  "bf", "bg", "bh", "bi", "biz", "bj", "bm", "bn", "bo", "br", "bs", "bt", "bv",
3e36ebbfe048 [feladat @ 244]
rejo
parents: 137
diff changeset
    54
  "bw", "by", "bz", "ca", "cat", "cc", "cd", "cf", "cg", "ch", "ci", "ck", "cl",
3e36ebbfe048 [feladat @ 244]
rejo
parents: 137
diff changeset
    55
  "cm", "cn", "co", "com", "coop", "cr", "cu", "cv", "cx", "cy", "cz", "de", "dj",
3e36ebbfe048 [feladat @ 244]
rejo
parents: 137
diff changeset
    56
  "dk", "dm", "do", "dz", "ec", "edu", "ee", "eg", "er", "es", "et", "eu", "fi",
3e36ebbfe048 [feladat @ 244]
rejo
parents: 137
diff changeset
    57
  "fj", "fk", "fm", "fo", "fr", "ga", "gb", "gd", "ge", "gf", "gg", "gh", "gi",
3e36ebbfe048 [feladat @ 244]
rejo
parents: 137
diff changeset
    58
  "gl", "gm", "gn", "gov", "gp", "gq", "gr", "gs", "gt", "gu", "gw", "gy", "hk",
3e36ebbfe048 [feladat @ 244]
rejo
parents: 137
diff changeset
    59
  "hm", "hn", "hr", "ht", "hu", "id", "ie", "il", "im", "in", "info", "int", "io",
3e36ebbfe048 [feladat @ 244]
rejo
parents: 137
diff changeset
    60
  "iq", "ir", "is", "it", "je", "jm", "jo", "jobs", "jp", "ke", "kg", "kh", "ki",
3e36ebbfe048 [feladat @ 244]
rejo
parents: 137
diff changeset
    61
  "km", "kn", "kp", "kr", "kw", "ky", "kz", "la", "lb", "lc", "li", "lk", "lr",
3e36ebbfe048 [feladat @ 244]
rejo
parents: 137
diff changeset
    62
  "ls", "lt", "lu", "lv", "ly", "ma", "mc", "md", "me", "mg", "mh", "mil", "mk",
3e36ebbfe048 [feladat @ 244]
rejo
parents: 137
diff changeset
    63
  "ml", "mm", "mn", "mo", "mobi", "mp", "mq", "mr", "ms", "mt", "mu", "museum",
3e36ebbfe048 [feladat @ 244]
rejo
parents: 137
diff changeset
    64
  "mv", "mw", "mx", "my", "mz", "na", "name", "nc", "ne", "net", "nf", "ng", "ni",
3e36ebbfe048 [feladat @ 244]
rejo
parents: 137
diff changeset
    65
  "nl", "no", "np", "nr", "nu", "nz", "om", "org", "pa", "pe", "pf", "pg", "ph",
3e36ebbfe048 [feladat @ 244]
rejo
parents: 137
diff changeset
    66
  "pk", "pl", "pm", "pn", "pr", "pro", "ps", "pt", "pw", "py", "qa", "re", "ro",
3e36ebbfe048 [feladat @ 244]
rejo
parents: 137
diff changeset
    67
  "rs", "ru", "rw", "sa", "sb", "sc", "sd", "se", "sg", "sh", "si", "sj", "sk",
3e36ebbfe048 [feladat @ 244]
rejo
parents: 137
diff changeset
    68
  "sl", "sm", "sn", "so", "sr", "st", "su", "sv", "sy", "sz", "tc", "td", "tel",
3e36ebbfe048 [feladat @ 244]
rejo
parents: 137
diff changeset
    69
  "tf", "tg", "th", "tj", "tk", "tl", "tm", "tn", "to", "tp", "tr", "travel",
3e36ebbfe048 [feladat @ 244]
rejo
parents: 137
diff changeset
    70
  "tt", "tv", "tw", "tz", "ua", "ug", "uk", "um", "us", "uy", "uz", "va", "vc",
3e36ebbfe048 [feladat @ 244]
rejo
parents: 137
diff changeset
    71
  "ve", "vg", "vi", "vn", "vu", "wf", "ws", "xn--0zwm56d", "xn--11b5bs3a9aj6g",
3e36ebbfe048 [feladat @ 244]
rejo
parents: 137
diff changeset
    72
  "xn--80akhbyknj4f", "xn--9t4b11yi5a", "xn--deba0ad", "xn--g6w251d",
3e36ebbfe048 [feladat @ 244]
rejo
parents: 137
diff changeset
    73
  "xn--hgbk6aj7f53bba", "xn--hlcj6aya9esc7a", "xn--jxalpdlp", "xn--kgbechtv",
3e36ebbfe048 [feladat @ 244]
rejo
parents: 137
diff changeset
    74
  "xn--zckzah", "ye", "yt", "yu", "za", "zm", "zw");
3e36ebbfe048 [feladat @ 244]
rejo
parents: 137
diff changeset
    75
3e36ebbfe048 [feladat @ 244]
rejo
parents: 137
diff changeset
    76
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    77
/* Database connection */
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    78
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    79
require_once("database.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    80
// Generates $db variable to access database.
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    81
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 6
diff changeset
    82
2ff220cfde13 [feladat @ 60]
rejo
parents: 6
diff changeset
    83
// Array of the available zone types
2ff220cfde13 [feladat @ 60]
rejo
parents: 6
diff changeset
    84
$server_types = array("MASTER", "SLAVE", "NATIVE");
2ff220cfde13 [feladat @ 60]
rejo
parents: 6
diff changeset
    85
136
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    86
// $rtypes - array of possible record types
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    87
$rtypes = array('A', 'AAAA', 'CNAME', 'HINFO', 'MX', 'NAPTR', 'NS', 'PTR', 'SOA', 'TXT');
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    88
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    89
// If fancy records is enabled, extend this field.
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    90
if($dns_fancy) {
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    91
        $rtypes[10] = 'URL';
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    92
        $rtypes[11] = 'MBOXFW';
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    93
}
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    94
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    95
// $template - array of records that will be applied when adding a new zone file
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    96
$template = array(
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    97
                array(
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    98
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    99
                                "name"          =>              "##DOMAIN##",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   100
                                "type"          =>              "SOA",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   101
                                "content"       =>              "$dns_ns1 $dns_hostmaster 0",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   102
                                "ttl"           =>              "$dns_ttl",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   103
                                "prio"          =>              ""
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   104
                ),
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   105
                array(
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   106
                                "name"          =>              "##DOMAIN##",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   107
                                "type"          =>              "NS",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   108
                                "content"       =>              "$dns_ns1",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   109
                                "ttl"           =>              "$dns_ttl",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   110
                                "prio"          =>              ""
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   111
                ),
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   112
                array(
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   113
                                "name"          =>              "##DOMAIN##",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   114
                                "type"          =>              "NS",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   115
                                "content"       =>              "$dns_ns2",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   116
                                "ttl"           =>              "$dns_ttl",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   117
                                "prio"          =>              ""
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   118
                ),
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   119
                array(
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   120
                                "name"          =>              "www.##DOMAIN##",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   121
                                "type"          =>              "A",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   122
                                "content"       =>              "##WEBIP##",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   123
                                "ttl"           =>              "$dns_ttl",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   124
                                "prio"          =>              ""
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   125
                ),
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   126
                array(
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   127
                                "name"          =>              "##DOMAIN##",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   128
                                "type"          =>              "A",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   129
                                "content"       =>              "##WEBIP##",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   130
                                "ttl"           =>              "$dns_ttl",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   131
                                "prio"          =>              ""
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   132
                ),
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   133
                array(
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   134
                                "name"          =>              "mail.##DOMAIN##",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   135
                                "type"          =>              "A",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   136
                                "content"       =>              "##MAILIP##",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   137
                                "ttl"           =>              "$dns_ttl",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   138
                                "prio"          =>              ""
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   139
                ),
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   140
                array(
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   141
                                "name"          =>              "localhost.##DOMAIN##",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   142
                                "type"          =>              "A",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   143
                                "content"       =>              "127.0.0.1",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   144
                                "ttl"           =>              "$dns_ttl",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   145
                                "prio"          =>              ""
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   146
                ),
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   147
                array(
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   148
                                "name"          =>              "##DOMAIN##",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   149
                                "type"          =>              "MX",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   150
                                "content"       =>              "mail.##DOMAIN##",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   151
                                "ttl"           =>              "$dns_ttl",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   152
                                "prio"          =>              "10"
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   153
                )
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   154
);
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   155
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 6
diff changeset
   156
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   157
/*************
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   158
 * Includes  *
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   159
 *************/
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   160
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   161
require_once("error.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   162
require_once("auth.inc.php");
3
64525a2eb098 [feladat @ 4]
rejo
parents: 1
diff changeset
   163
require_once("i18n.inc.php");
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   164
require_once("users.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   165
require_once("dns.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   166
require_once("record.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   167
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   168
$db = dbConnect();
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   169
doAuthenticate();
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   170
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   171
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   172
/*************
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   173
 * Functions *
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   174
 *************/
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   175
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   176
/*
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   177
 * Display the page option: [1] [2] .. [n]
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   178
 */
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   179
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   180
function show_pages($amount,$rowamount,$id='')
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   181
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   182
   if ($amount > $rowamount) {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   183
      if (!isset($_GET["start"])) $_GET["start"]=1;
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   184
      echo _('Show page') . ":<br>";
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   185
      for ($i=1;$i<=ceil($amount / $rowamount);$i++) {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   186
         if ($_GET["start"] == $i) {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   187
            echo "[ <b>".$i."</b> ] ";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   188
         } else {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   189
            echo "[ <a href=\"".$_SERVER["PHP_SELF"]."?start=".$i;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   190
	    if ($id!='') echo "&id=".$id;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   191
	    echo "\">".$i."</a> ] ";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   192
         }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   193
      }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   194
   }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   195
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   196
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   197
/*
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   198
 * Display the alphabetic option: [0-9] [a] [b] .. [z]
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   199
 */
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   200
29
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   201
function show_letters($letterstart,$userid=true)
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   202
{
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   203
        echo _('Show zones beginning with') . ":<br>";
29
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   204
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   205
	$letter = "[[:digit:]]";
77
e55145eab223 [feladat @ 124]
rejo
parents: 76
diff changeset
   206
	if ($letterstart == "1")
29
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   207
	{
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   208
		echo "[ <span class=\"lettertaken\">0-9</span> ] ";
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   209
	}
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   210
	elseif (zone_letter_start($letter,$userid))
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   211
	{
32
0c2497c1ac01 [feladat @ 79]
rejo
parents: 29
diff changeset
   212
		echo "[ <a href=\"".$_SERVER["PHP_SELF"]."?letter=1\">0-9</a> ] ";
29
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   213
	}
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   214
	else
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   215
	{
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   216
		echo "[ <span class=\"letternotavailble\">0-9</span> ] ";
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   217
	}
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   218
29
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   219
        foreach (range('a','z') as $letter)
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   220
        {
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   221
                if ($letter == $letterstart)
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   222
                {
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   223
                        echo "[ <span class=\"lettertaken\">".$letter."</span> ] ";
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   224
                }
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   225
                elseif (zone_letter_start($letter,$userid))
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   226
                {
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   227
                        echo "[ <a href=\"".$_SERVER["PHP_SELF"]."?letter=".$letter."\">".$letter."</a> ] ";
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   228
                }
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   229
                else
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   230
                {
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   231
                        echo "[ <span class=\"letternotavailble\">".$letter."</span> ] ";
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   232
                }
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   233
        }
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   234
}
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   235
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   236
function zone_letter_start($letter,$userid=true)
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   237
{
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   238
        global $db;
55
a885f557678f [feladat @ 102]
peter
parents: 47
diff changeset
   239
	global $sql_regexp;
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   240
        $query = "SELECT 
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   241
			domains.id AS domain_id,
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   242
			zones.owner,
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   243
			domains.name AS domainname
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   244
			FROM domains
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   245
			LEFT JOIN zones ON domains.id=zones.domain_id 
107
fee925b9bdef [feladat @ 207]
rejo
parents: 91
diff changeset
   246
			WHERE substring(domains.name,1,1) ".$sql_regexp." ".$db->quote("^".$letter);
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   247
	$db->setLimit(1);
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   248
        $result = $db->query($query);
29
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   249
        $numrows = $result->numRows();
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   250
        if ( $numrows == "1" ) {
29
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   251
                return 1;
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   252
        } else {
29
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   253
                return 0;
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   254
        }
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   255
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   256
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   257
function error($msg) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   258
	if ($msg) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   259
		echo "     <div class=\"error\">Error: " . $msg . "</div>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   260
	} else {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   261
		echo "     <div class=\"error\">" . _('An unknown error has occurred.') . "</div>\n"; 
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   262
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   263
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   264
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   265
function success($msg) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   266
	if ($msg) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   267
		echo "     <div class=\"success\">" . $msg . "</div>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   268
	} else {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   269
		echo "     <div class=\"success\">" . _('Something has been successfully performed. What exactly, however, will remain a mystery.') . "</div>\n"; 
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   270
	}
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   271
}
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   272
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   273
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   274
/*
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   275
 * Something has been done nicely, display a message and a back button.
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   276
 */
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   277
function message($msg)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   278
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   279
    include_once("header.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   280
    ?>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
   281
    <P><TABLE CLASS="messagetable"><TR><TD CLASS="message"><H2><?php echo _('Success!'); ?></H2>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   282
    <BR>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   283
	<FONT STYLE="font-weight: Bold">
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   284
	<P>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
   285
	<?php
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   286
    if($msg)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   287
    {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   288
        echo nl2br($msg);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   289
    }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   290
    else
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   291
    {
4
55ed92aa7cf5 [feladat @ 5]
rejo
parents: 3
diff changeset
   292
        echo _('Successful!');
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   293
    }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   294
    ?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   295
    </P>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   296
    <BR>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   297
    <P>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
   298
    <a href="javascript:history.go(-1)">&lt;&lt; <?php echo _('back'); ?></a></FONT>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   299
    </P>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   300
    </TD></TR></TABLE></P>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
   301
    <?php
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   302
    include_once("footer.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   303
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   304
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   305
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   306
/*
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   307
 * Reroute a user to a cleanpage of (if passed) arg
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   308
 */
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   309
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   310
function clean_page($arg='')
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   311
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   312
	if (!$arg)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   313
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   314
		header("Location: ".$_SERVER["PHP_SELF"]."?time=".time());
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   315
		exit;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   316
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   317
	else
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   318
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   319
		if (preg_match('!\?!si', $arg))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   320
		{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   321
			$add = "&time=";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   322
		}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   323
		else
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   324
		{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   325
			$add = "?time=";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   326
		}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   327
		header("Location: $arg$add".time());
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   328
		exit;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   329
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   330
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   331
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   332
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   333
function get_status($res)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   334
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   335
	if ($res == '0')
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   336
	{
4
55ed92aa7cf5 [feladat @ 5]
rejo
parents: 3
diff changeset
   337
		return "<FONT CLASS=\"inactive\">" . _('Inactive') . "</FONT>";
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   338
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   339
	elseif ($res == '1')
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   340
	{
4
55ed92aa7cf5 [feladat @ 5]
rejo
parents: 3
diff changeset
   341
		return "<FONT CLASS=\"active\">" . _('Active') . "</FONT>";
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   342
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   343
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   344
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   345
function parse_template_value($val, $domain, $webip, $mailip)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   346
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   347
	$val = str_replace('##DOMAIN##', $domain, $val);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   348
	$val = str_replace('##WEBIP##', $webip, $val);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   349
	$val = str_replace('##MAILIP##', $mailip, $val);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   350
	return $val;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   351
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   352
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   353
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   354
/*
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   355
 * Validates an email address.
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   356
 * Checks if there is something before the at '@' sign and its followed by a domain and a tld of minimum 2
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   357
 * and maximum of 4 characters.
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   358
 */
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   359
function is_valid_email($email)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   360
{
138
3e36ebbfe048 [feladat @ 244]
rejo
parents: 137
diff changeset
   361
	if(!eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.([a-z]{2,6}$)", $email)) {
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   362
		return false;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   363
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   364
	return true;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   365
}
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   366
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   367
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   368
function v_num($string) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   369
	if (!eregi("^[0-9]+$", $string)) { 
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   370
		return false ;
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   371
	} else {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   372
		return true ;
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   373
	}
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   374
}
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   375
90
d7bee09d98fe [feladat @ 190]
rejo
parents: 82
diff changeset
   376
// Debug print
91
f6c1336dbef8 [feladat @ 191]
rejo
parents: 90
diff changeset
   377
function debug_print($var) {
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   378
	echo "<pre style=\"border: 2px solid blue;\">\n";
91
f6c1336dbef8 [feladat @ 191]
rejo
parents: 90
diff changeset
   379
	if (is_array($var)) { print_r($var) ; } else { echo $var ; } 
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   380
	echo "</pre>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   381
}
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   382
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   383
?>