inc/toolkit.inc.php
author rejo
Mon, 24 Dec 2007 21:07:38 +0000
changeset 44 f8886b13c495
parent 37 b785e54690ce
child 47 ae140472d97c
permissions -rwxr-xr-x
[feladat @ 91] Fixing some language issues. Translations not working due to wrong file names, see r89 as well. Fixing two broken references in menu and list_zones.php.
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
	{
32
0c2497c1ac01 [feladat @ 79]
rejo
parents: 29
diff changeset
   102
		echo "[ <a href=\"".$_SERVER["PHP_SELF"]."?letter=1\">0-9</a> ] ";
29
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
        {
37
b785e54690ce [feladat @ 84]
rejo
parents: 32
diff changeset
   139
		// First select the zones for which we have ownership on one or more records.
b785e54690ce [feladat @ 84]
rejo
parents: 32
diff changeset
   140
		$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
   141
		$result = $db->query($query);
b785e54690ce [feladat @ 84]
rejo
parents: 32
diff changeset
   142
		$zones = array();
b785e54690ce [feladat @ 84]
rejo
parents: 32
diff changeset
   143
		if (!PEAR::isError($result)) {
b785e54690ce [feladat @ 84]
rejo
parents: 32
diff changeset
   144
			$zones = $result->fetchCol();
b785e54690ce [feladat @ 84]
rejo
parents: 32
diff changeset
   145
		}
b785e54690ce [feladat @ 84]
rejo
parents: 32
diff changeset
   146
	
b785e54690ce [feladat @ 84]
rejo
parents: 32
diff changeset
   147
                $sqlq .= " AND (zones.owner=".$_SESSION["userid"];
b785e54690ce [feladat @ 84]
rejo
parents: 32
diff changeset
   148
		if (count($zones) > 0) {
b785e54690ce [feladat @ 84]
rejo
parents: 32
diff changeset
   149
			$sqlq .= ' OR zones.domain_id IN ('.implode(',', $zones).') '; 
b785e54690ce [feladat @ 84]
rejo
parents: 32
diff changeset
   150
b785e54690ce [feladat @ 84]
rejo
parents: 32
diff changeset
   151
		}
b785e54690ce [feladat @ 84]
rejo
parents: 32
diff changeset
   152
		$sqlq .= ')';
29
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   153
        }
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   154
        $sqlq .= " AND substring(domains.name,1,1) REGEXP '^".$letter."' LIMIT 1";
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   155
        $result = $db->query($sqlq);
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   156
        $numrows = $result->numRows();
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   157
        if ( $numrows == "1" ) 
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   158
        {
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   159
                return 1;
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   160
        }
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   161
        else
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   162
        {
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   163
                return 0;
e1c60f72d494 [feladat @ 76]
rejo
parents: 23
diff changeset
   164
        }
1
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
 * Print a nice useraimed error.
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   169
 */
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   170
function error($msg)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   171
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   172
	// General function for printing critical errors.
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   173
	if ($msg)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   174
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   175
		include_once("header.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   176
	?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 6
diff changeset
   177
	<p><? echo _('Oops! An error occured!'); ?></p>
2ff220cfde13 [feladat @ 60]
rejo
parents: 6
diff changeset
   178
	<p><? echo nl2br($msg) ?></p>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   179
	<?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   180
		include_once("footer.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   181
		die();
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   182
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   183
	else
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   184
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   185
		include_once("footer.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   186
		die("No error specified!");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   187
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   188
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   189
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   190
/*
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   191
 * Something has been done nicely, display a message and a back button.
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   192
 */
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   193
function message($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
    ?>
4
55ed92aa7cf5 [feladat @ 5]
rejo
parents: 3
diff changeset
   197
    <P><TABLE CLASS="messagetable"><TR><TD CLASS="message"><H2><? echo _('Success!'); ?></H2>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   198
    <BR>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   199
	<FONT STYLE="font-weight: Bold">
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   200
	<P>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   201
	<?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   202
    if($msg)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   203
    {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   204
        echo nl2br($msg);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   205
    }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   206
    else
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   207
    {
4
55ed92aa7cf5 [feladat @ 5]
rejo
parents: 3
diff changeset
   208
        echo _('Successful!');
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   209
    }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   210
    ?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   211
    </P>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   212
    <BR>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   213
    <P>
4
55ed92aa7cf5 [feladat @ 5]
rejo
parents: 3
diff changeset
   214
    <a href="javascript:history.go(-1)">&lt;&lt; <? echo _('back'); ?></a></FONT>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   215
    </P>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   216
    </TD></TR></TABLE></P>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   217
    <?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   218
    include_once("footer.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   219
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   220
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   221
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   222
/*
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   223
 * Reroute a user to a cleanpage of (if passed) arg
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   224
 */
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   225
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   226
function clean_page($arg='')
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   227
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   228
	if (!$arg)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   229
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   230
		header("Location: ".$_SERVER["PHP_SELF"]."?time=".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
	else
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   234
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   235
		if (preg_match('!\?!si', $arg))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   236
		{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   237
			$add = "&time=";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   238
		}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   239
		else
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   240
		{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   241
			$add = "?time=";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   242
		}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   243
		header("Location: $arg$add".time());
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   244
		exit;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   245
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   246
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   247
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   248
function level($l)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   249
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   250
	if ($_SESSION["level"] >= $l)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   251
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   252
		return 1;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   253
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   254
	else
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   255
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   256
		return 0;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   257
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   258
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   259
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   260
function xs($zoneid)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   261
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   262
	global $db;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   263
	if (is_numeric($zoneid) && is_numeric($_SESSION["level"]))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   264
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   265
		$result = $db->query("SELECT id FROM zones WHERE owner=".$_SESSION["userid"]." AND domain_id=$zoneid");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   266
		$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
   267
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   268
                if ($result->numRows() == 1 || $_SESSION["level"] >= 5)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   269
                {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   270
			$_SESSION[$zoneid."_ispartial"] = 0;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   271
			return true;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   272
		}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   273
		elseif ($result_extra->numRows() == 1)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   274
		{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   275
			$_SESSION[$zoneid."_ispartial"] = 1;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   276
			return true;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   277
		}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   278
		else
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   279
		{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   280
			return false;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   281
		}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   282
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   283
	else
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   284
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   285
        	return false;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   286
        }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   287
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   288
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   289
function get_status($res)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   290
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   291
	if ($res == '0')
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   292
	{
4
55ed92aa7cf5 [feladat @ 5]
rejo
parents: 3
diff changeset
   293
		return "<FONT CLASS=\"inactive\">" . _('Inactive') . "</FONT>";
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   294
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   295
	elseif ($res == '1')
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   296
	{
4
55ed92aa7cf5 [feladat @ 5]
rejo
parents: 3
diff changeset
   297
		return "<FONT CLASS=\"active\">" . _('Active') . "</FONT>";
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   298
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   299
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   300
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   301
function parse_template_value($val, $domain, $webip, $mailip)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   302
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   303
	$val = str_replace('##DOMAIN##', $domain, $val);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   304
	$val = str_replace('##WEBIP##', $webip, $val);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   305
	$val = str_replace('##MAILIP##', $mailip, $val);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   306
	return $val;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   307
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   308
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   309
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   310
/*
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   311
 * Validates an email address.
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   312
 * 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
   313
 * and maximum of 4 characters.
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   314
 */
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   315
function is_valid_email($email)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   316
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   317
	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
   318
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   319
		return false;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   320
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   321
	return true;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   322
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   323
?>