Location: PHPKode > projects > Replex > replex-0.9.0/admin/domain10.php
<?php
/*************************************************************
$Id: domain10.php,v 1.2 2001/05/20 00:21:51 jimir Exp $
 
 ***************************************************************/

include("include/config.php"); 
include("lib/user.php");
include("lib/account.php");
include("lib/domain.php");
include("lib/alias.php");
include("db/class_mysql.php");

# Authenticate current user
$USER = new User;
if (!$USER->HTTPauthenticate($DBCONN)) {
  $USER->http_refuse();
}

$ALIAS = new Alias; 
$ACCOUNT = new Account;  

//we store the existing alias in oldalias
if(empty($oldalias) && !empty($alias)) {
   $oldalias=$alias;
   if($ACCOUNT->strRemoveDomain($oldalias)=="")
     $alias="*";
   else
     $alias=$ACCOUNT->strRemoveDomain($oldalias);
}

if(!empty($deletedest)) {
  //first lets check for dependencies
  if($ALIAS->checkDestDependencies($DBCONN,$oldalias,$deletedest)) {
    //lets delete a destination
    if($ALIAS->deleteDestination($DBCONN,$oldalias,$deletedest)) {
	//SUCCESS
    }
    else {
	//DB-ERROR in deleting destination
	$error="error5";
    }
  }
  else {
    $error="error10";
  }
}

$ALIAS->retrieveAlias($DBCONN,$oldalias,1);
$domain=$ALIAS->strRemoveAlias($ALIAS->getAlias());
$ACCOUNT->retrieveDomainInfo($DBCONN,$domain);


if(!empty($error)) {
  if($error=="error1") {
    $errormsg="<h3>Required fields are missing</h3>";	
  }
  else if($error=="error2") {
    $errormsg="<h3>Alias already exists - try another!</h3>";	
  }
  else if($error=="error3") {
    $errormsg="<h3>Error occured in creating the alias!</h3>";	
  }
  else if($error=="error4") {
    $errormsg="<h3>No account chosen!</h3>";
  }
  else if($error=="error5") {
    $errormsg="<h3>DB-ERROR</h3>";	
  }
  else if($error=="error6") {
    $errormsg="<h3>Domain name could not be found!</h3>";	
  }
  else if($error=="error7") {
    $errormsg="<h3>Email is not valid!</h3>";
  }
  else if($error=="error8") {
    $errormsg="<H3>Alias is not valid!</H3>";
  }
  else if($error=="error9") {
    $errormsg="<H3>Alias can not be deleted, accounts has this as its only alias!</H3>";
  }  
  else if($error=="error10") {
    $errormsg="<H3>Destination can not be deleted because the account has this as its only alias!</H3>";
  }
}


$activetab=5;
$showtabs=7;
include("domains4_menu.php");
?>
<span class="headline">Edit alias</span><br><br>
<%=$errormsg%>

<form action="alias_update.php" type="post">
<table border=0>
       <tr>
       <td>Alias:</td>
       <td colspan="2"><input type="text" name="alias" value="<% if($alias=="") echo "*"; else echo $alias;%>" size="20" maxlength="100">@<%=$domain%></td>
       </tr>
      <tr>
       <td>Destination(s):*</td>
       <td><%=$ALIAS->getDest(0)%></td><td><% if(count($ALIAS->dest)>=2):%><a href="domain10.php?alias=<%=$ALIAS->getAlias(0)%>&deletedest=<%=$ALIAS->getDest(0)%>">delete</a><% endif %></td>
      </tr>
       <% for($a=1;$a<count($ALIAS->dest);$a++):%>
       <tr>
       <td></td>
       <td><%=$ALIAS->getDest($a)%></td><td><a href="domain10.php?alias=<%=$ALIAS->getAlias(0)%>&deletedest=<%=$ALIAS->getDest($a)%>">delete</a></td>
      </tr>
      <% endfor %>
       <tr><td>&nbsp;<br></td></tr>
       <tr>
       <td>Add destination:</td>
       <td><input type="radio" name="dest" value="email" <% if($dest=="email" || $dest!="account") echo "CHECKED";%>>Email:</td><td colspan="2"><input type="text" name="email" value="<%=$email%>" size="40" maxlength="100" onfocus="this.form.dest[0].click();"></td>
       </tr>
       <tr><td>
      </td><td><input type="radio" name="dest" value="account"  <% if($dest=="account") echo "CHECKED";%>>Account:</td>
        <td colspan="2"><select name="accounts" onfocus="this.form.dest[1].click();"><option value="none" <%if($accounts=="none") echo "SELECTED"%>>-->> select one <<--</option>
         <% for($a=0;$a<count($ACCOUNT->username);$a++): %>
            <option value="<%=$ACCOUNT->getUserName($a)%>" <% if($accounts==$ACCOUNT->getUserName($a)) echo "SELECTED"%>><%=$ACCOUNT->getUserName($a)%></option> 
         <% endfor %>
         </select></td>
       </tr>
       <tr>
       <td></td>
       <td colspan="2">Required fields are marked with *</td>
       </tr>
       <tr>
       <td>&nbsp;</td>
       <td></td>
       </tr>
       <tr>
       <td></td>
       <td><input type="submit" name="updatealias" value="Update" CLASS="button" ONMOUSEOVER="this.className='buttonhover'" ONMOUSEOUT="this.className='button'">&nbsp;<input type="submit" name="deletealias" value="Delete" CLASS="button" ONMOUSEOVER="this.className='buttonhover'" ONMOUSEOUT="this.className='button'"></td>
       </tr>
       </table>
       <input type="hidden" name="oldalias" value="<%=$oldalias%>">
       <input type="hidden" name="caller" value="domain">  
       <input type="hidden" name="domain" value="<%=$domain%>"> 
	</form>
<% menu_html_trail() %>
Return current item: Replex