inc/toolkit.inc.php
author rejo
Tue, 10 Apr 2007 22:40:43 +0000
changeset 1 58094faf794d
child 3 64525a2eb098
permissions -rwxr-xr-x
[feladat @ 2] Creation of initial working branch.
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
// | PowerAdmin                                                         |
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     5
// +--------------------------------------------------------------------+
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     6
// | Copyright (c) 1997-2002 The PowerAdmin Team                        |
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     7
// +--------------------------------------------------------------------+
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     8
// | This source file is subject to the license carried by the overal   |
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     9
// | program PowerAdmin as found on http://poweradmin.sf.net            |
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    10
// | The PowerAdmin program falls under the QPL License:                |
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    11
// | http://www.trolltech.com/developer/licensing/qpl.html              |
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    12
// +--------------------------------------------------------------------+
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    13
// | Authors: Roeland Nieuwenhuis <trancer <AT> trancer <DOT> nl>       |
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    14
// |          Sjeemz <sjeemz <AT> sjeemz <DOT> nl>                      |
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    15
// +--------------------------------------------------------------------+
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    16
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    17
// Filename: toolkit.inc.php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    18
// Startdate: 26-10-2002
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    19
// Description: general functions needed on a large variety of locations.
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    20
// Kills the db.inc.php.
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    21
// If you include this file you include the whole 'backend'
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    22
//
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    23
// $Id: toolkit.inc.php,v 1.13 2003/02/24 01:46:31 azurazu Exp $
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    24
//
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    25
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    26
/*************
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    27
 * Constants  *
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    28
  *************/
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    29
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    30
define(ROWAMOUNT, 500);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    31
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    32
if (isset($_GET["start"])) {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    33
   define(ROWSTART, (($_GET["start"] - 1) * ROWAMOUNT));
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    34
   } else {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    35
   define(ROWSTART, 0);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    36
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    37
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    38
if (isset($_GET["letter"])) {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    39
   define(LETTERSTART, $_GET["letter"]);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    40
   $_SESSION["letter"] = $_GET["letter"];
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    41
} elseif(isset($_SESSION["letter"])) {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    42
   define(LETTERSTART, $_SESSION["letter"]);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    43
} else {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    44
   define(LETTERSTART, "a");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    45
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    46
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    47
if(!@include_once("config.inc.php"))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    48
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    49
	error("You have to create a config.inc.php!");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    50
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    51
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    52
if(is_file( dirname(__FILE__) . '/../install.php'))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    53
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    54
	error("You have to remove install.php before this program will run");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    55
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    56
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    57
if(is_file( dirname(__FILE__) . '/../migrator.php'))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    58
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    59
        error("You have to remove migrator.php before this program will run");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    60
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    61
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    62
/* Database connection */
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    63
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    64
require_once("database.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    65
// Generates $db variable to access database.
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    66
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    67
/*************
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    68
 * Includes  *
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    69
 *************/
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    70
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    71
require_once("error.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    72
require_once("auth.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    73
require_once("users.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    74
require_once("dns.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    75
require_once("record.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    76
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    77
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    78
/*************
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    79
 * Functions *
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
 * Display the page option: [1] [2] .. [n]
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    84
 */
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    85
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    86
function show_pages($amount,$rowamount,$id='')
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    87
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    88
   if ($amount > $rowamount) {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    89
      if (!isset($_GET["start"])) $_GET["start"]=1;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    90
      echo "<br /><br />Show page ";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    91
      for ($i=1;$i<=ceil($amount / $rowamount);$i++) {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    92
         if ($_GET["start"] == $i) {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    93
            echo "[ <b>".$i."</b> ] ";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    94
         } else {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    95
            echo "[ <a href=\"".$_SERVER["PHP_SELF"]."?start=".$i;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    96
	    if ($id!='') echo "&id=".$id;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    97
	    echo "\">".$i."</a> ] ";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    98
         }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    99
      }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   100
      echo "</small>";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   101
   }
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
 * Display the alphabetic option: [0-9] [a] [b] .. [z]
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   106
 */
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   107
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   108
function show_letters($letterstart,$doms)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   109
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   110
   foreach ($doms as $dom) {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   111
      if (is_numeric($dom["name"][0])) {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   112
         $letter_taken["0"] = 1;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   113
      } else {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   114
         $letter_taken[$dom["name"][0]] = 1;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   115
      }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   116
   }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   117
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   118
   echo "Show domains beginning with: <br />";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   119
   if ($letterstart == 1) {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   120
      echo "[ <b>0-9</b> ] ";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   121
   } elseif ($letter_taken["0"] != 1) {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   122
      echo "[ 0-9 ] ";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   123
   } else {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   124
      echo "[ <a href=\"".$_SERVER["PHP_SELF"]."?letter=1\">0-9</a> ] ";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   125
   }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   126
   
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   127
   foreach (range('a','z') as $letter) {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   128
      if ($letterstart === $letter) {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   129
         echo "[ <b>".$letter."</b> ] ";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   130
      } elseif ($letter_taken[$letter] != 1) {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   131
         echo "[ <span style=\"color:#999\">".$letter."</span> ] ";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   132
      } else {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   133
          echo "[ <a href=\"".$_SERVER["PHP_SELF"]."?letter=".$letter."\">".$letter."</a> ] ";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   134
      }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   135
   }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   136
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   137
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   138
/*
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   139
 * Print a nice useraimed error.
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   140
 */
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   141
function error($msg)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   142
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   143
	// General function for printing critical errors.
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   144
	if ($msg)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   145
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   146
		include_once("header.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   147
	?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   148
	<P><TABLE CLASS="error"><TR><TD CLASS="error"><H2>Oops! An error occured!</H2>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   149
	<BR>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   150
	<FONT STYLE="font-weight: Bold"><?= nl2br($msg) ?><BR><BR><a href="javascript:history.go(-1)">&lt;&lt; back</a></FONT><BR></TD></TR></TABLE></P>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   151
	<?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   152
		include_once("footer.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   153
		die();
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   154
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   155
	else
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   156
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   157
		include_once("footer.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   158
		die("No error specified!");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   159
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   160
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   161
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   162
/*
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   163
 * Something has been done nicely, display a message and a back button.
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   164
 */
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   165
function message($msg)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   166
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   167
    include_once("header.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   168
    ?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   169
    <P><TABLE CLASS="messagetable"><TR><TD CLASS="message"><H2>Success!</H2>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   170
    <BR>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   171
	<FONT STYLE="font-weight: Bold">
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   172
	<P>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   173
	<?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   174
    if($msg)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   175
    {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   176
        echo nl2br($msg);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   177
    }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   178
    else
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   179
    {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   180
        echo "Successful!";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   181
    }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   182
    ?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   183
    </P>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   184
    <BR>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   185
    <P>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   186
    <a href="javascript:history.go(-1)">&lt;&lt; back</a></FONT>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   187
    </P>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   188
    </TD></TR></TABLE></P>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   189
    <?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   190
    include_once("footer.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   191
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   192
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   193
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   194
/*
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   195
 * Reroute a user to a cleanpage of (if passed) arg
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   196
 */
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   197
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   198
function clean_page($arg='')
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   199
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   200
	if (!$arg)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   201
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   202
		header("Location: ".$_SERVER["PHP_SELF"]."?time=".time());
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   203
		exit;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   204
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   205
	else
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   206
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   207
		if (preg_match('!\?!si', $arg))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   208
		{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   209
			$add = "&time=";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   210
		}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   211
		else
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   212
		{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   213
			$add = "?time=";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   214
		}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   215
		header("Location: $arg$add".time());
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   216
		exit;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   217
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   218
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   219
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   220
function level($l)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   221
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   222
	if ($_SESSION["level"] >= $l)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   223
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   224
		return 1;
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
		return 0;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   229
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   230
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   231
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   232
function xs($zoneid)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   233
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   234
	global $db;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   235
	if (is_numeric($zoneid) && is_numeric($_SESSION["level"]))
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   236
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   237
		$result = $db->query("SELECT id FROM zones WHERE owner=".$_SESSION["userid"]." AND domain_id=$zoneid");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   238
		$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
   239
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   240
                if ($result->numRows() == 1 || $_SESSION["level"] >= 5)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   241
                {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   242
			$_SESSION[$zoneid."_ispartial"] = 0;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   243
			return true;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   244
		}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   245
		elseif ($result_extra->numRows() == 1)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   246
		{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   247
			$_SESSION[$zoneid."_ispartial"] = 1;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   248
			return true;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   249
		}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   250
		else
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   251
		{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   252
			return false;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   253
		}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   254
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   255
	else
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   256
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   257
        	return false;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   258
        }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   259
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   260
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   261
function get_status($res)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   262
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   263
	if ($res == '0')
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   264
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   265
		return "<FONT CLASS=\"inactive\">Inactive</FONT>";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   266
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   267
	elseif ($res == '1')
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   268
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   269
		return "<FONT CLASS=\"active\">Active</FONT>";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   270
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   271
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   272
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   273
function parse_template_value($val, $domain, $webip, $mailip)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   274
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   275
	$val = str_replace('##DOMAIN##', $domain, $val);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   276
	$val = str_replace('##WEBIP##', $webip, $val);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   277
	$val = str_replace('##MAILIP##', $mailip, $val);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   278
	return $val;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   279
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   280
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   281
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   282
/*
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   283
 * Validates an email address.
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   284
 * 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
   285
 * and maximum of 4 characters.
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   286
 */
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   287
function is_valid_email($email)
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   288
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   289
	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
   290
	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   291
		return false;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   292
	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   293
	return true;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   294
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   295
?>