inc/toolkit.inc.php
author rejo
Fri, 11 Apr 2008 11:59:33 +0000
changeset 137 79c33038ca14
parent 136 c795dd75a77e
child 138 3e36ebbfe048
permissions -rw-r--r--
[feladat @ 243] Added inclusion of 'config-me.inc.php' to get the defaults.
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
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    50
/* Database connection */
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    51
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    52
require_once("database.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    53
// Generates $db variable to access database.
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    54
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 6
diff changeset
    55
2ff220cfde13 [feladat @ 60]
rejo
parents: 6
diff changeset
    56
// Array of the available zone types
2ff220cfde13 [feladat @ 60]
rejo
parents: 6
diff changeset
    57
$server_types = array("MASTER", "SLAVE", "NATIVE");
2ff220cfde13 [feladat @ 60]
rejo
parents: 6
diff changeset
    58
136
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    59
// $rtypes - array of possible record types
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    60
$rtypes = array('A', 'AAAA', 'CNAME', 'HINFO', 'MX', 'NAPTR', 'NS', 'PTR', 'SOA', 'TXT');
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    61
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    62
// If fancy records is enabled, extend this field.
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    63
if($dns_fancy) {
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    64
        $rtypes[10] = 'URL';
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    65
        $rtypes[11] = 'MBOXFW';
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    66
}
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    67
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    68
// $template - array of records that will be applied when adding a new zone file
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    69
$template = array(
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    70
                array(
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    71
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    72
                                "name"          =>              "##DOMAIN##",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    73
                                "type"          =>              "SOA",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    74
                                "content"       =>              "$dns_ns1 $dns_hostmaster 0",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    75
                                "ttl"           =>              "$dns_ttl",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    76
                                "prio"          =>              ""
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    77
                ),
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    78
                array(
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    79
                                "name"          =>              "##DOMAIN##",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    80
                                "type"          =>              "NS",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    81
                                "content"       =>              "$dns_ns1",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    82
                                "ttl"           =>              "$dns_ttl",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    83
                                "prio"          =>              ""
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    84
                ),
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    85
                array(
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    86
                                "name"          =>              "##DOMAIN##",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    87
                                "type"          =>              "NS",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    88
                                "content"       =>              "$dns_ns2",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    89
                                "ttl"           =>              "$dns_ttl",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    90
                                "prio"          =>              ""
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    91
                ),
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    92
                array(
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    93
                                "name"          =>              "www.##DOMAIN##",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    94
                                "type"          =>              "A",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    95
                                "content"       =>              "##WEBIP##",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    96
                                "ttl"           =>              "$dns_ttl",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    97
                                "prio"          =>              ""
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    98
                ),
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
    99
                array(
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   100
                                "name"          =>              "##DOMAIN##",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   101
                                "type"          =>              "A",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   102
                                "content"       =>              "##WEBIP##",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   103
                                "ttl"           =>              "$dns_ttl",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   104
                                "prio"          =>              ""
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   105
                ),
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   106
                array(
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   107
                                "name"          =>              "mail.##DOMAIN##",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   108
                                "type"          =>              "A",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   109
                                "content"       =>              "##MAILIP##",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   110
                                "ttl"           =>              "$dns_ttl",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   111
                                "prio"          =>              ""
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   112
                ),
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   113
                array(
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   114
                                "name"          =>              "localhost.##DOMAIN##",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   115
                                "type"          =>              "A",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   116
                                "content"       =>              "127.0.0.1",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   117
                                "ttl"           =>              "$dns_ttl",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   118
                                "prio"          =>              ""
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   119
                ),
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   120
                array(
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   121
                                "name"          =>              "##DOMAIN##",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   122
                                "type"          =>              "MX",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   123
                                "content"       =>              "mail.##DOMAIN##",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   124
                                "ttl"           =>              "$dns_ttl",
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   125
                                "prio"          =>              "10"
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   126
                )
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   127
);
c795dd75a77e [feladat @ 242]
rejo
parents: 119
diff changeset
   128
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 6
diff changeset
   129
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   130
/*************
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   131
 * Includes  *
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   132
 *************/
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   133
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   134
require_once("error.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   135
require_once("auth.inc.php");
3
64525a2eb098 [feladat @ 4]
rejo
parents: 1
diff changeset
   136
require_once("i18n.inc.php");
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   137
require_once("users.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   138
require_once("dns.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   139
require_once("record.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   140
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   141
$db = dbConnect();
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   142
doAuthenticate();
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   143
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   144
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   145
/*************
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   146
 * Functions *
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   147
 *************/
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   148
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   149
/*
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   150
 * Display the page option: [1] [2] .. [n]
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   151
 */
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   152
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   153
function show_pages($amount,$rowamount,$id='')
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   154
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   155
   if ($amount > $rowamount) {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   156
      if (!isset($_GET["start"])) $_GET["start"]=1;
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   157
      echo _('Show page') . ":<br>";
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   158
      for ($i=1;$i<=ceil($amount / $rowamount);$i++) {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   159
         if ($_GET["start"] == $i) {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   160
            echo "[ <b>".$i."</b> ] ";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   161
         } else {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   162
            echo "[ <a href=\"".$_SERVER["PHP_SELF"]."?start=".$i;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   163
	    if ($id!='') echo "&id=".$id;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   164
	    echo "\">".$i."</a> ] ";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   165
         }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   166
      }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   167
   }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   168
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   169
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   170
/*
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   171
 * Display the alphabetic option: [0-9] [a] [b] .. [z]
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   172
 */
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   173
29
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   174
function show_letters($letterstart,$userid=true)
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   175
{
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   176
        echo _('Show zones beginning with') . ":<br>";
29
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   177
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   178
	$letter = "[[:digit:]]";
77
e55145eab223 [feladat @ 124]
rejo
parents: 76
diff changeset
   179
	if ($letterstart == "1")
29
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   180
	{
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   181
		echo "[ <span class=\"lettertaken\">0-9</span> ] ";
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   182
	}
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   183
	elseif (zone_letter_start($letter,$userid))
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   184
	{
32
0c2497c1ac01 [feladat @ 79]
rejo
parents: 29
diff changeset
   185
		echo "[ <a href=\"".$_SERVER["PHP_SELF"]."?letter=1\">0-9</a> ] ";
29
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   186
	}
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   187
	else
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   188
	{
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   189
		echo "[ <span class=\"letternotavailble\">0-9</span> ] ";
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   190
	}
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   191
29
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   192
        foreach (range('a','z') as $letter)
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   193
        {
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   194
                if ($letter == $letterstart)
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   195
                {
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   196
                        echo "[ <span class=\"lettertaken\">".$letter."</span> ] ";
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   197
                }
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   198
                elseif (zone_letter_start($letter,$userid))
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   199
                {
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   200
                        echo "[ <a href=\"".$_SERVER["PHP_SELF"]."?letter=".$letter."\">".$letter."</a> ] ";
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   201
                }
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   202
                else
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   203
                {
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   204
                        echo "[ <span class=\"letternotavailble\">".$letter."</span> ] ";
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   205
                }
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   206
        }
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   207
}
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   208
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   209
function zone_letter_start($letter,$userid=true)
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   210
{
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   211
        global $db;
55
a885f557678f [feladat @ 102]
peter
parents: 47
diff changeset
   212
	global $sql_regexp;
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   213
        $query = "SELECT 
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   214
			domains.id AS domain_id,
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   215
			zones.owner,
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   216
			domains.name AS domainname
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   217
			FROM domains
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   218
			LEFT JOIN zones ON domains.id=zones.domain_id 
107
fee925b9bdef [feladat @ 207]
rejo
parents: 91
diff changeset
   219
			WHERE substring(domains.name,1,1) ".$sql_regexp." ".$db->quote("^".$letter);
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   220
	$db->setLimit(1);
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   221
        $result = $db->query($query);
29
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   222
        $numrows = $result->numRows();
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   223
        if ( $numrows == "1" ) {
29
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   224
                return 1;
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   225
        } else {
29
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   226
                return 0;
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   227
        }
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   228
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   229
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   230
function error($msg) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   231
	if ($msg) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   232
		echo "     <div class=\"error\">Error: " . $msg . "</div>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   233
	} else {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   234
		echo "     <div class=\"error\">" . _('An unknown error has occurred.') . "</div>\n"; 
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   235
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   236
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   237
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   238
function success($msg) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   239
	if ($msg) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   240
		echo "     <div class=\"success\">" . $msg . "</div>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   241
	} else {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   242
		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
   243
	}
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   244
}
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   245
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   246
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   247
/*
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   248
 * Something has been done nicely, display a message and a back button.
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   249
 */
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   250
function message($msg)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   251
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   252
    include_once("header.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   253
    ?>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
   254
    <P><TABLE CLASS="messagetable"><TR><TD CLASS="message"><H2><?php echo _('Success!'); ?></H2>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   255
    <BR>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   256
	<FONT STYLE="font-weight: Bold">
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   257
	<P>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
   258
	<?php
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   259
    if($msg)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   260
    {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   261
        echo nl2br($msg);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   262
    }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   263
    else
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   264
    {
4
55ed92aa7cf5 [feladat @ 5]
rejo
parents: 3
diff changeset
   265
        echo _('Successful!');
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   266
    }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   267
    ?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   268
    </P>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   269
    <BR>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   270
    <P>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
   271
    <a href="javascript:history.go(-1)">&lt;&lt; <?php echo _('back'); ?></a></FONT>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   272
    </P>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   273
    </TD></TR></TABLE></P>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
   274
    <?php
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   275
    include_once("footer.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   276
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   277
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   278
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   279
/*
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   280
 * Reroute a user to a cleanpage of (if passed) arg
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   281
 */
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   282
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   283
function clean_page($arg='')
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   284
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   285
	if (!$arg)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   286
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   287
		header("Location: ".$_SERVER["PHP_SELF"]."?time=".time());
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   288
		exit;
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
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   292
		if (preg_match('!\?!si', $arg))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   293
		{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   294
			$add = "&time=";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   295
		}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   296
		else
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   297
		{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   298
			$add = "?time=";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   299
		}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   300
		header("Location: $arg$add".time());
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   301
		exit;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   302
	}
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
function get_status($res)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   307
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   308
	if ($res == '0')
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   309
	{
4
55ed92aa7cf5 [feladat @ 5]
rejo
parents: 3
diff changeset
   310
		return "<FONT CLASS=\"inactive\">" . _('Inactive') . "</FONT>";
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   311
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   312
	elseif ($res == '1')
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   313
	{
4
55ed92aa7cf5 [feladat @ 5]
rejo
parents: 3
diff changeset
   314
		return "<FONT CLASS=\"active\">" . _('Active') . "</FONT>";
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   315
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   316
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   317
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   318
function parse_template_value($val, $domain, $webip, $mailip)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   319
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   320
	$val = str_replace('##DOMAIN##', $domain, $val);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   321
	$val = str_replace('##WEBIP##', $webip, $val);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   322
	$val = str_replace('##MAILIP##', $mailip, $val);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   323
	return $val;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   324
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   325
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   326
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   327
/*
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   328
 * Validates an email address.
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   329
 * 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
   330
 * and maximum of 4 characters.
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   331
 */
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   332
function is_valid_email($email)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   333
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   334
	if(!eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.([a-z]{2,6}$)", $email))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   335
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   336
		return false;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   337
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   338
	return true;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   339
}
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   340
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   341
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   342
function v_num($string) {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   343
	if (!eregi("^[0-9]+$", $string)) { 
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   344
		return false ;
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   345
	} else {
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   346
		return true ;
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   347
	}
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   348
}
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   349
90
d7bee09d98fe [feladat @ 190]
rejo
parents: 82
diff changeset
   350
// Debug print
91
f6c1336dbef8 [feladat @ 191]
rejo
parents: 90
diff changeset
   351
function debug_print($var) {
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   352
	echo "<pre style=\"border: 2px solid blue;\">\n";
91
f6c1336dbef8 [feladat @ 191]
rejo
parents: 90
diff changeset
   353
	if (is_array($var)) { print_r($var) ; } else { echo $var ; } 
82
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   354
	echo "</pre>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   355
}
c255196bc447 [feladat @ 182]
rejo
parents: 79
diff changeset
   356
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   357
?>