| 1 |
<? |
|---|
| 2 |
require_once("common.php"); |
|---|
| 3 |
|
|---|
| 4 |
if($_SESSION['_config']['access'] <= 0) |
|---|
| 5 |
{ |
|---|
| 6 |
header("location: login.php"); |
|---|
| 7 |
exit; |
|---|
| 8 |
} else if($_SESSION['_config']['access'] < 90) { |
|---|
| 9 |
$user = $_SESSION['_config']['username']; |
|---|
| 10 |
} else { |
|---|
| 11 |
$user = trim($_REQUEST['user']); |
|---|
| 12 |
} |
|---|
| 13 |
|
|---|
| 14 |
if($_POST['process']) |
|---|
| 15 |
{ |
|---|
| 16 |
$fp = @fsockopen($hostname, $hostport); |
|---|
| 17 |
if(!$fp) |
|---|
| 18 |
die("Please contact your system administrator as the server has gone missing."); |
|---|
| 19 |
list($alias) = explode("@", trim($_POST['alias'])); |
|---|
| 20 |
$alias .= '@'.trim($_POST['realm']); |
|---|
| 21 |
fputs($fp, "addalias|$user|$alias\n"); |
|---|
| 22 |
fclose($fp); |
|---|
| 23 |
if($_SESSION['_config']['access'] < 90) |
|---|
| 24 |
header("location: aliases.php"); |
|---|
| 25 |
else |
|---|
| 26 |
header("location: aliases.php?user=$user"); |
|---|
| 27 |
exit; |
|---|
| 28 |
} |
|---|
| 29 |
|
|---|
| 30 |
$realms = "@<select name='realm'>"; |
|---|
| 31 |
$fp = @fsockopen($hostname, $hostport); |
|---|
| 32 |
if(!$fp) |
|---|
| 33 |
die("Please contact your system administrator as the server has gone missing."); |
|---|
| 34 |
fputs($fp, "getrealms\n"); |
|---|
| 35 |
$rc = 0; |
|---|
| 36 |
while(!feof($fp)) |
|---|
| 37 |
{ |
|---|
| 38 |
list($realm) = explode('|', trim(fgets($fp, 4096))); |
|---|
| 39 |
if($realm != "" && $realm != "LOCAL") |
|---|
| 40 |
{ |
|---|
| 41 |
$rc++; |
|---|
| 42 |
$realms .= "<option value='$realm'>$realm</option>"; |
|---|
| 43 |
} |
|---|
| 44 |
} |
|---|
| 45 |
$realms .= "</select>"; |
|---|
| 46 |
|
|---|
| 47 |
include_once("header.php"); |
|---|
| 48 |
?> |
|---|
| 49 |
<div class="bodytext" style="padding:12px;" align="justify"> |
|---|
| 50 |
<? if($rc > 0) { ?> |
|---|
| 51 |
<p>Please enter the new alias for <?=$user?>.</p> |
|---|
| 52 |
<form method="post" action="<?=$_SERVER['REQUEST_URI']?>"> |
|---|
| 53 |
<label for="alias" style="width:75px;float:left;clear:left;">Alias:</label> <input type="text" name="alias" value="<?=$_POST['alias']?>"><?=$realms?><br /> |
|---|
| 54 |
<label for="process" style="width:75px;float:left;clear:left;"> </label> <input type="submit" value="Add"><br /> |
|---|
| 55 |
<? if($_SESSION['_config']['access'] >= 90) { ?> |
|---|
| 56 |
<input type="hidden" name="user" value="<?=$user?>"> |
|---|
| 57 |
<? } ?> |
|---|
| 58 |
<input type="hidden" name="process" value="1"> |
|---|
| 59 |
</form> |
|---|
| 60 |
<? } else { ?> |
|---|
| 61 |
<p>There are no realms listed in the database, please create one or more realms before trying to add aliases.</p> |
|---|
| 62 |
<? } ?> |
|---|
| 63 |
</div> |
|---|
| 64 |
<? include_once("footer.php"); ?> |
|---|
| 65 |
|
|---|