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