index.php
changeset 13 2ff220cfde13
parent 8 47dd15d8bb8c
child 47 ae140472d97c
equal deleted inserted replaced
12:7be4525290cc 13:2ff220cfde13
     1 <?php
     1 <?php
     2 session_start();
     2 session_start();
     3 // +--------------------------------------------------------------------+
       
     4 // | PowerAdmin								|
       
     5 // +--------------------------------------------------------------------+
       
     6 // | Copyright (c) 1997-2002 The PowerAdmin Team			|
       
     7 // +--------------------------------------------------------------------+
       
     8 // | This source file is subject to the license carried by the overal	|
       
     9 // | program PowerAdmin as found on http://poweradmin.sf.net		|
       
    10 // | The PowerAdmin program falls under the QPL License:		|
       
    11 // | http://www.trolltech.com/developer/licensing/qpl.html		|
       
    12 // +--------------------------------------------------------------------+
       
    13 // | Authors: Roeland Nieuwenhuis <trancer <AT> trancer <DOT> nl>	|
       
    14 // |          Sjeemz <sjeemz <AT> sjeemz <DOT> nl>			|
       
    15 // +--------------------------------------------------------------------+
       
    16 
       
    17 //
       
    18 // $Id: index.php,v 1.13 2003/05/10 20:20:05 azurazu Exp $
       
    19 //
       
    20 
       
    21 require_once("inc/i18n.inc.php");
     3 require_once("inc/i18n.inc.php");
    22 require_once("inc/toolkit.inc.php");
     4 require_once("inc/toolkit.inc.php");
    23 
       
    24 if ($_POST["submit"])
       
    25 {
       
    26 	$domain = trim($_POST["domain"]);
       
    27 	$owner = $_POST["owner"];
       
    28 	$webip = $_POST["webip"];
       
    29 	$mailip = $_POST["mailip"];
       
    30 	$empty = $_POST["empty"];
       
    31 	$dom_type = isset($_POST["dom_type"]) ? $_POST["dom_type"] : "NATIVE";
       
    32 	if(!$empty)
       
    33 	{
       
    34 		$empty = 0;
       
    35 		if(!eregi('in-addr.arpa', $domain) && (!is_valid_ip($webip) || !is_valid_ip($mailip)) )
       
    36 		{
       
    37 			$error = "Web or Mail ip is invalid!";
       
    38 		}
       
    39 	}
       
    40 	if (!$error)
       
    41 	{
       
    42 		if (!is_valid_domain($domain))
       
    43 		{
       
    44 			$error = "Domain name is invalid!";
       
    45 		}
       
    46 		elseif (domain_exists($domain))
       
    47 		{
       
    48 			$error = "Domain already exists!";
       
    49 		}
       
    50 		//elseif (isset($mailip) && is_valid_ip(
       
    51 		else
       
    52 		{
       
    53 			add_domain($domain, $owner, $webip, $mailip, $empty, $dom_type);
       
    54 			clean_page();
       
    55 		}
       
    56 	}
       
    57 }
       
    58 
       
    59 if($_POST["passchange"])
       
    60 {
       
    61     if(strlen($_POST["newpass"]) < 4)
       
    62     {
       
    63         error('Length of the pass should be at least 4');
       
    64     }
       
    65     else
       
    66     {
       
    67 	   change_user_pass($_POST["currentpass"], $_POST["newpass"], $_POST["newpass2"]);
       
    68 	}
       
    69 }
       
    70 
       
    71 include_once("inc/header.inc.php");
     5 include_once("inc/header.inc.php");
    72 ?>
     6 ?>
    73 <H2><? echo _('DNS Admin'); ?></H2>
     7    <h3><? echo _('Welcome'); ?>, <? echo $_SESSION["name"] ?></h3>
    74 
     8    <ul>
    75 <P FONT CLASS="nav">
     9     <li><a href="search.php"><? echo _('Search zones or records'); ?></a></li>
       
    10     <li><a href="list_zones.php"><? echo _('List all zones'); ?></a></li>
       
    11 <?
       
    12 if (level(5))
       
    13 {
       
    14 ?>
       
    15     <li><a href="list_supermasters.php"><? echo _('List all supermasters'); ?></a></li>
       
    16     <li><a href="add_zone_master.php"><? echo _('Add master zone'); ?></a></li>
       
    17     <li><a href="add_zone_slave.php"><? echo _('Add slave zone'); ?></a></li>
       
    18     <li><a href="add_supermaster.php"><? echo _('Add supermaster'); ?></a></li>
       
    19 <?
       
    20 }
       
    21 ?>
       
    22     <li><a href="change_password.php"><? echo _('Change password'); ?></a></li>
    76 <?
    23 <?
    77 if (level(10))
    24 if (level(10))
    78 {
    25 {
    79 	?><A HREF="users.php"><? echo _('User admin'); ?></A> <?
       
    80 }
       
    81 ?>
    26 ?>
    82  <A HREF="search.php"><? echo _('Search records'); ?></A>
    27     <li><a href="users.php"><? echo _('User administration'); ?></a></li>
    83 </P>
       
    84 
       
    85 <BR>
       
    86 <? echo _('Welcome'); ?>, <?= $_SESSION["name"] ?>.
       
    87 <BR>
       
    88 
       
    89 <? echo _('Your userlevel is'); ?>: <?= $_SESSION["level"] ?> (<?= leveldescription($_SESSION["level"]) ?>)
       
    90 <BR><BR>
       
    91 
       
    92 <?
       
    93 if ($error != "")
       
    94 {
       
    95 	?><H3><FONT COLOR="red"><? echo _('Error'); ?>: <?= $error ?></FONT></H3><?
       
    96 }
       
    97 ?>
       
    98 
       
    99 <B><? echo _('Current domains in DNS (click to view or edit)'); ?>:</B>
       
   100 <BR>
       
   101 
       
   102 <?
       
   103 $doms = get_domains(0);
       
   104 $num_domains = count($doms);
       
   105 echo "<br /><small><b>" . _('Number of domains') . ": </b>".$num_domains."<br />";
       
   106 
       
   107 if ($num_domains > ROWAMOUNT) {
       
   108    show_letters(LETTERSTART,$doms);
       
   109    echo "<br />";
       
   110 }
       
   111 
       
   112 $doms = get_domains(0,LETTERSTART);
       
   113 show_pages(count($doms),ROWAMOUNT);
       
   114 
       
   115 ?>
       
   116 
       
   117 <br />
       
   118 <TABLE BORDER="0" CELLSPACING="4">
       
   119 <TR STYLE="font-weight: Bold;"><TD CLASS="tdbg">&nbsp;</TD><TD CLASS="tdbg"><? echo _('Name'); ?></TD><TD CLASS="tdbg"><? echo _('Records'); ?></TD><TD CLASS="tdbg"><? echo _('Owner'); ?></TD></TR>
       
   120 <?
       
   121 
       
   122 if ($num_domains < ROWAMOUNT) {
       
   123    $doms = get_domains(0,"all",ROWSTART,ROWAMOUNT);
       
   124 } else {
       
   125    $doms = get_domains(0,LETTERSTART,ROWSTART,ROWAMOUNT);
       
   126 }
       
   127 
       
   128 // If the user doesnt have any domains print a message saying so
       
   129 if ($doms < 0)
       
   130 {
       
   131 	?><TR><TD CLASS="tdbg">&nbsp;</TD><TD CLASS="tdbg" COLSPAN="4"><b><? echo _('No domains in this listing, sorry.'); ?></b></FONT></TD></TR><?
       
   132 }
       
   133 
       
   134 // If he has domains, dump them (duh)
       
   135 else
       
   136 {
       
   137 	foreach ($doms as $c)
       
   138 	{
       
   139 		?><TR><TD CLASS="tdbg">
       
   140 		<? if (level(5))
       
   141 		{
       
   142 			?>
       
   143 			<A HREF="delete_domain.php?id=<?= $c["id"] ?>"><IMG SRC="images/delete.gif" ALT="[ <? echo _('Delete zone'); ?> ]" BORDER="0"></A><?
       
   144 		}
       
   145 		else
       
   146 		{
       
   147 			print "&nbsp;";
       
   148 		}
       
   149 		?>
       
   150 		</TD><TD CLASS="tdbg"><A HREF="edit.php?id=<?= $c["id"] ?>"><?= $c["name"] ?></A></TD><TD CLASS="tdbg"><?= $c["numrec"] ?></TD><TD CLASS="tdbg"><?= get_owner_from_id($c["owner"]) ?></TD></TR><?
       
   151 		print "\n";
       
   152 	}
       
   153 }
       
   154 
       
   155 ?>
       
   156 </TABLE>
       
   157 
       
   158 <small><? echo _('You only administer some records of domains marked with an (*).'); ?></small>
       
   159 
       
   160 <?
       
   161 if (level(5))
       
   162 {
       
   163 	// Get some data.
       
   164 	$server_types = array("MASTER", "SLAVE", "NATIVE");
       
   165 	$users = show_users();
       
   166 	?>
       
   167 	<BR><BR>
       
   168 	<FORM METHOD="post" ACTION="index.php">
       
   169 	<B><? echo _('Create new domain'); ?>:</B><BR>
       
   170 	<TABLE BORDER="0" CELLSPACING="4">
       
   171 	<TR><TD CLASS="tdbg"><? echo _('Domain name'); ?>:</TD><TD WIDTH="510" CLASS="tdbg"><INPUT TYPE="text" CLASS="input" NAME="domain" VALUE="<? if ($error) print $_POST["domain"]; ?>"></TD></TR>
       
   172 	<TR><TD CLASS="tdbg"><? echo _('Web IP'); ?>:</TD><TD CLASS="tdbg"><INPUT TYPE="text" CLASS="input" NAME="webip" VALUE="<? if ($error) print $_POST["webip"]; ?>"></TD></TR>
       
   173 	<TR><TD CLASS="tdbg"><? echo _('Mail IP'); ?>:</TD><TD CLASS="tdbg"><INPUT TYPE="text" CLASS="input" NAME="mailip" VALUE="<? if ($error) print $_POST["mailip"]; ?>"></TD></TR>
       
   174 	<TR><TD CLASS="tdbg"><? echo _('Owner'); ?>:</TD><TD CLASS="tdbg">
       
   175 	<SELECT NAME="owner">
       
   176 	<?
       
   177 	foreach ($users as $u)
       
   178 	{
       
   179         	?><OPTION VALUE="<?= $u['id'] ?>"><?= $u['fullname'] ?></OPTION><?
       
   180 	}
       
   181 	?>
       
   182 	</SELECT>
       
   183 	</TD></TR>
       
   184 	<?
       
   185 	if($MASTER_SLAVE_FUNCTIONS == true)
       
   186 	{
       
   187 	?>
       
   188 	<TR><TD CLASS="tdbg"><? echo _('Domain type'); ?>:</TD><TD CLASS="tdbg">
       
   189 	<SELECT NAME="dom_type">
       
   190 	<?
       
   191 	foreach($server_types as $s)
       
   192 	{
       
   193 		?><OPTION VALUE="<?=$s?>"><?=$s ?></OPTION><?
       
   194 	}
       
   195 	?>
       
   196 	</SELECT>
       
   197 	</TD></TR>
       
   198 	<? } ?>
       
   199 	<TR><TD CLASS="tdbg"><? echo _('Create zone without'); ?><BR><? echo _('applying records-template'); ?>:</TD><TD CLASS="tdbg"><INPUT TYPE="checkbox" NAME="empty" VALUE="1"></TD></TR>
       
   200 	<TR><TD CLASS="tdbg">&nbsp;</TD><TD CLASS="tdbg"><INPUT TYPE="submit" CLASS="button" NAME="submit" VALUE="<? echo _('Add domain'); ?>"></TD></TR>
       
   201 	</TABLE>
       
   202 	</FORM>
       
   203 <?
    28 <?
   204 }
    29 }
   205 ?>
    30 ?>
       
    31     <li><a href="index.php?logout"><? echo _('Logout'); ?></a></li>
       
    32    </ul>
   206 
    33 
   207 <BR><BR>
       
   208 <FORM METHOD="post" ACTION="index.php">
       
   209 <B><? echo _('Change password'); ?>:</B><BR>
       
   210 <TABLE BORDER="0" CELLSPACING="4">
       
   211 <TR><TD CLASS="tdbg"><? echo _('Current password'); ?>:</TD><TD WIDTH="510" CLASS="tdbg"><INPUT TYPE="password" CLASS="input" NAME="currentpass" VALUE=""></TD></TR>
       
   212 <TR><TD CLASS="tdbg"><? echo _('New password'); ?>:</TD><TD WIDTH="510" CLASS="tdbg"><INPUT TYPE="password" CLASS="input" NAME="newpass" VALUE=""></TD></TR>
       
   213 <TR><TD CLASS="tdbg"><? echo _('New password'); ?>:</TD><TD WIDTH="510" CLASS="tdbg"><INPUT TYPE="password" CLASS="input" NAME="newpass2" VALUE=""></TD></TR>
       
   214 <TR><TD CLASS="tdbg">&nbsp;</TD><TD CLASS="tdbg"><INPUT TYPE="submit" CLASS="button" NAME="passchange" VALUE="<? echo _('Change password'); ?>"></TD></TR>
       
   215 </TABLE>
       
   216 </FORM>
       
   217 <?
    34 <?
   218 include_once("inc/footer.inc.php");
    35 include_once("inc/footer.inc.php");
   219 ?>
    36 ?>