inc/toolkit.inc.php
author rejo
Tue, 25 Dec 2007 14:57:43 +0000
changeset 49 58911245e817
parent 47 ae140472d97c
child 55 a885f557678f
permissions -rwxr-xr-x
[feladat @ 96] Changed list of credits to an online version.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     1
<?
47
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
     2
ae140472d97c [feladat @ 94]
rejo
parents: 37
diff changeset
     3
/*  PowerAdmin, a friendly web-based admin tool for PowerDNS.
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
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    24
/*************
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    25
 * Constants  *
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    26
  *************/
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    27
23
4abaed69febd [feladat @ 70]
rejo
parents: 13
diff changeset
    28
define(ROWAMOUNT, 50);
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    29
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    30
if (isset($_GET["start"])) {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    31
   define(ROWSTART, (($_GET["start"] - 1) * ROWAMOUNT));
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    32
   } else {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    33
   define(ROWSTART, 0);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    34
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    35
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    36
if (isset($_GET["letter"])) {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    37
   define(LETTERSTART, $_GET["letter"]);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    38
   $_SESSION["letter"] = $_GET["letter"];
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    39
} elseif(isset($_SESSION["letter"])) {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    40
   define(LETTERSTART, $_SESSION["letter"]);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    41
} else {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    42
   define(LETTERSTART, "a");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    43
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    44
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    45
if(!@include_once("config.inc.php"))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    46
{
6
9fcac40c1b0e [feladat @ 7]
rejo
parents: 4
diff changeset
    47
	error( _('You have to create a config.inc.php!') );
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
if(is_file( dirname(__FILE__) . '/../install.php'))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    51
{
6
9fcac40c1b0e [feladat @ 7]
rejo
parents: 4
diff changeset
    52
	error( _('You have to remove install.php before this program will run') );
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    53
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    54
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    55
if(is_file( dirname(__FILE__) . '/../migrator.php'))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    56
{
6
9fcac40c1b0e [feladat @ 7]
rejo
parents: 4
diff changeset
    57
        error( _('You have to remove migrator.php before this program will run') );
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    58
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    59
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    60
/* Database connection */
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    61
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    62
require_once("database.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    63
// Generates $db variable to access database.
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    64
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 6
diff changeset
    65
2ff220cfde13 [feladat @ 60]
rejo
parents: 6
diff changeset
    66
// Array of the available zone types
2ff220cfde13 [feladat @ 60]
rejo
parents: 6
diff changeset
    67
$server_types = array("MASTER", "SLAVE", "NATIVE");
2ff220cfde13 [feladat @ 60]
rejo
parents: 6
diff changeset
    68
2ff220cfde13 [feladat @ 60]
rejo
parents: 6
diff changeset
    69
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    70
/*************
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    71
 * Includes  *
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    72
 *************/
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    73
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    74
require_once("error.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    75
require_once("auth.inc.php");
3
64525a2eb098 [feladat @ 4]
rejo
parents: 1
diff changeset
    76
require_once("i18n.inc.php");
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    77
require_once("users.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    78
require_once("dns.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    79
require_once("record.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    80
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    81
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    82
/*************
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    83
 * Functions *
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    84
 *************/
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    85
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    86
/*
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    87
 * Display the page option: [1] [2] .. [n]
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    88
 */
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    89
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    90
function show_pages($amount,$rowamount,$id='')
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    91
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    92
   if ($amount > $rowamount) {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    93
      if (!isset($_GET["start"])) $_GET["start"]=1;
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 6
diff changeset
    94
      echo _('Show page') . "<br>";
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    95
      for ($i=1;$i<=ceil($amount / $rowamount);$i++) {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    96
         if ($_GET["start"] == $i) {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    97
            echo "[ <b>".$i."</b> ] ";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    98
         } else {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    99
            echo "[ <a href=\"".$_SERVER["PHP_SELF"]."?start=".$i;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   100
	    if ($id!='') echo "&id=".$id;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   101
	    echo "\">".$i."</a> ] ";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   102
         }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   103
      }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   104
   }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   105
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   106
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   107
/*
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   108
 * Display the alphabetic option: [0-9] [a] [b] .. [z]
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   109
 */
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   110
29
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   111
function show_letters($letterstart,$userid=true)
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   112
{
29
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   113
        echo _('Show zones beginning with:') . "<br>";
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   114
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   115
	$letter = "[[:digit:]]";
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   116
	if ($letterstart == "0")
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   117
	{
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   118
		echo "[ <span class=\"lettertaken\">0-9</span> ] ";
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   119
	}
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   120
	elseif (zone_letter_start($letter,$userid))
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   121
	{
32
0c2497c1ac01 [feladat @ 79]
rejo
parents: 29
diff changeset
   122
		echo "[ <a href=\"".$_SERVER["PHP_SELF"]."?letter=1\">0-9</a> ] ";
29
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   123
	}
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   124
	else
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   125
	{
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   126
		echo "[ <span class=\"letternotavailble\">0-9</span> ] ";
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   127
	}
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   128
29
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   129
        foreach (range('a','z') as $letter)
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   130
        {
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   131
                if ($letter == $letterstart)
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   132
                {
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   133
                        echo "[ <span class=\"lettertaken\">".$letter."</span> ] ";
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   134
                }
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   135
                elseif (zone_letter_start($letter,$userid))
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   136
                {
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   137
                        echo "[ <a href=\"".$_SERVER["PHP_SELF"]."?letter=".$letter."\">".$letter."</a> ] ";
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   138
                }
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   139
                else
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   140
                {
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   141
                        echo "[ <span class=\"letternotavailble\">".$letter."</span> ] ";
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   142
                }
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   143
        }
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   144
}
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   145
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   146
function zone_letter_start($letter,$userid=true)
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   147
{
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   148
        global $db;
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   149
        $sqlq = "SELECT domains.id AS domain_id,
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   150
        zones.owner,
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   151
        records.id,
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   152
        domains.name AS domainname
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   153
        FROM domains
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   154
        LEFT JOIN zones ON domains.id=zones.domain_id 
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   155
        LEFT JOIN records ON records.domain_id=domains.id
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   156
        WHERE 1";
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   157
        if((!level(5) || !$userid) && !level(10) && !level(5))
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   158
        {
37
b785e54690ce [feladat @ 84]
rejo
parents: 32
diff changeset
   159
		// First select the zones for which we have ownership on one or more records.
b785e54690ce [feladat @ 84]
rejo
parents: 32
diff changeset
   160
		$query = 'SELECT records.domain_id FROM records, record_owners WHERE user_id = '.$_SESSION['userid'].' AND records.id = record_owners.record_id';
b785e54690ce [feladat @ 84]
rejo
parents: 32
diff changeset
   161
		$result = $db->query($query);
b785e54690ce [feladat @ 84]
rejo
parents: 32
diff changeset
   162
		$zones = array();
b785e54690ce [feladat @ 84]
rejo
parents: 32
diff changeset
   163
		if (!PEAR::isError($result)) {
b785e54690ce [feladat @ 84]
rejo
parents: 32
diff changeset
   164
			$zones = $result->fetchCol();
b785e54690ce [feladat @ 84]
rejo
parents: 32
diff changeset
   165
		}
b785e54690ce [feladat @ 84]
rejo
parents: 32
diff changeset
   166
	
b785e54690ce [feladat @ 84]
rejo
parents: 32
diff changeset
   167
                $sqlq .= " AND (zones.owner=".$_SESSION["userid"];
b785e54690ce [feladat @ 84]
rejo
parents: 32
diff changeset
   168
		if (count($zones) > 0) {
b785e54690ce [feladat @ 84]
rejo
parents: 32
diff changeset
   169
			$sqlq .= ' OR zones.domain_id IN ('.implode(',', $zones).') '; 
b785e54690ce [feladat @ 84]
rejo
parents: 32
diff changeset
   170
b785e54690ce [feladat @ 84]
rejo
parents: 32
diff changeset
   171
		}
b785e54690ce [feladat @ 84]
rejo
parents: 32
diff changeset
   172
		$sqlq .= ')';
29
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   173
        }
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   174
        $sqlq .= " AND substring(domains.name,1,1) REGEXP '^".$letter."' LIMIT 1";
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   175
        $result = $db->query($sqlq);
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   176
        $numrows = $result->numRows();
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   177
        if ( $numrows == "1" ) 
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   178
        {
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   179
                return 1;
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   180
        }
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   181
        else
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   182
        {
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   183
                return 0;
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   184
        }
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   185
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   186
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   187
/*
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   188
 * Print a nice useraimed error.
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   189
 */
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   190
function error($msg)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   191
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   192
	// General function for printing critical errors.
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   193
	if ($msg)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   194
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   195
		include_once("header.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   196
	?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 6
diff changeset
   197
	<p><? echo _('Oops! An error occured!'); ?></p>
2ff220cfde13 [feladat @ 60]
rejo
parents: 6
diff changeset
   198
	<p><? echo nl2br($msg) ?></p>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   199
	<?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   200
		include_once("footer.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   201
		die();
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   202
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   203
	else
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   204
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   205
		include_once("footer.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   206
		die("No error specified!");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   207
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   208
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   209
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   210
/*
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   211
 * Something has been done nicely, display a message and a back button.
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   212
 */
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   213
function message($msg)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   214
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   215
    include_once("header.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   216
    ?>
4
55ed92aa7cf5 [feladat @ 5]
rejo
parents: 3
diff changeset
   217
    <P><TABLE CLASS="messagetable"><TR><TD CLASS="message"><H2><? echo _('Success!'); ?></H2>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   218
    <BR>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   219
	<FONT STYLE="font-weight: Bold">
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   220
	<P>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   221
	<?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   222
    if($msg)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   223
    {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   224
        echo nl2br($msg);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   225
    }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   226
    else
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   227
    {
4
55ed92aa7cf5 [feladat @ 5]
rejo
parents: 3
diff changeset
   228
        echo _('Successful!');
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   229
    }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   230
    ?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   231
    </P>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   232
    <BR>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   233
    <P>
4
55ed92aa7cf5 [feladat @ 5]
rejo
parents: 3
diff changeset
   234
    <a href="javascript:history.go(-1)">&lt;&lt; <? echo _('back'); ?></a></FONT>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   235
    </P>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   236
    </TD></TR></TABLE></P>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   237
    <?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   238
    include_once("footer.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   239
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   240
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   241
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   242
/*
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   243
 * Reroute a user to a cleanpage of (if passed) arg
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   244
 */
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   245
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   246
function clean_page($arg='')
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   247
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   248
	if (!$arg)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   249
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   250
		header("Location: ".$_SERVER["PHP_SELF"]."?time=".time());
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   251
		exit;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   252
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   253
	else
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   254
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   255
		if (preg_match('!\?!si', $arg))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   256
		{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   257
			$add = "&time=";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   258
		}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   259
		else
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   260
		{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   261
			$add = "?time=";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   262
		}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   263
		header("Location: $arg$add".time());
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   264
		exit;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   265
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   266
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   267
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   268
function level($l)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   269
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   270
	if ($_SESSION["level"] >= $l)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   271
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   272
		return 1;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   273
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   274
	else
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   275
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   276
		return 0;
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
function xs($zoneid)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   281
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   282
	global $db;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   283
	if (is_numeric($zoneid) && is_numeric($_SESSION["level"]))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   284
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   285
		$result = $db->query("SELECT id FROM zones WHERE owner=".$_SESSION["userid"]." AND domain_id=$zoneid");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   286
		$result_extra = $db->query("SELECT record_owners.id FROM record_owners,records WHERE record_owners.user_id=".$_SESSION["userid"]." AND records.domain_id = $zoneid AND records.id = record_owners.record_id LIMIT 1");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   287
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   288
                if ($result->numRows() == 1 || $_SESSION["level"] >= 5)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   289
                {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   290
			$_SESSION[$zoneid."_ispartial"] = 0;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   291
			return true;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   292
		}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   293
		elseif ($result_extra->numRows() == 1)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   294
		{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   295
			$_SESSION[$zoneid."_ispartial"] = 1;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   296
			return true;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   297
		}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   298
		else
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   299
		{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   300
			return false;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   301
		}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   302
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   303
	else
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   304
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   305
        	return false;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   306
        }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   307
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   308
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   309
function get_status($res)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   310
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   311
	if ($res == '0')
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   312
	{
4
55ed92aa7cf5 [feladat @ 5]
rejo
parents: 3
diff changeset
   313
		return "<FONT CLASS=\"inactive\">" . _('Inactive') . "</FONT>";
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   314
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   315
	elseif ($res == '1')
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   316
	{
4
55ed92aa7cf5 [feladat @ 5]
rejo
parents: 3
diff changeset
   317
		return "<FONT CLASS=\"active\">" . _('Active') . "</FONT>";
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   318
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   319
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   320
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   321
function parse_template_value($val, $domain, $webip, $mailip)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   322
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   323
	$val = str_replace('##DOMAIN##', $domain, $val);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   324
	$val = str_replace('##WEBIP##', $webip, $val);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   325
	$val = str_replace('##MAILIP##', $mailip, $val);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   326
	return $val;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   327
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   328
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   329
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   330
/*
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   331
 * Validates an email address.
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   332
 * 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
   333
 * and maximum of 4 characters.
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   334
 */
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   335
function is_valid_email($email)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   336
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   337
	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
   338
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   339
		return false;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   340
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   341
	return true;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   342
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   343
?>