Cleaning up and format code

Rebuild all forms and lists, also changes on css.
Adding user and redirect count on domain page (so you can figure out which domain might still be used easier.
Adding count at table foot of all lists.
Make length of generated password depend on MIN_PASS_LENGTH
This commit is contained in:
ohartl 2016-02-17 23:16:31 +01:00
parent b5b3ed244c
commit 5fc9a7de91
21 changed files with 837 additions and 672 deletions

View file

@ -1,255 +1,331 @@
body{
font-family:Arial;
font-size:12px;
margin:0px;
background-color:white;
body {
font-family: arial, serif;
font-size: 12px;
margin: 0;
background-color: white;
}
/*
* Main Layout
*/
#header{
position:relative;
height:50px;
width:100%;
background-color:rgba(15, 15, 15, 1);
#header {
position: relative;
height: 50px;
width: 100%;
background-color: rgba(15, 15, 15, 1);
background: linear-gradient(rgba(63, 63, 63, 1), rgba(15, 15, 15, 1));
color:white;
line-height:50px;
box-sizing:border-box;
padding-left:20px;
padding-right:20px;
color: white;
line-height: 50px;
box-sizing: border-box;
padding-left: 20px;
padding-right: 20px;
}
#header div.title{
float:left;
height:50px;
width:auto;
#header div.title {
float: left;
height: 50px;
width: auto;
}
#header div.title a{
font-size:15px;
color:white;
text-decoration:none;
}
#header div.title a:hover{
text-decoration:underline;
}
#header div.header-menu{
float:left;
padding-left:100px;
}
#header div.header-button{
float:left;
height:50px;
margin-right:30px;
color:white;
}
#header div.header-button a{
color:white;
text-decoration:none;
}
#header div.header-button a:hover{
text-decoration:underline;
#header div.title a {
font-size: 15px;
color: white;
text-decoration: none;
}
#content{
height:auto;
min-height:calc(100vh - 150px);
padding:20px;
background-color:white;
#header div.title a:hover {
text-decoration: underline;
}
#header div.header-menu {
float: left;
padding-left: 100px;
}
#header div.header-button {
float: left;
height: 50px;
margin-right: 30px;
color: white;
}
#header div.header-button a {
color: white;
text-decoration: none;
}
#header div.header-button a:hover {
text-decoration: underline;
}
#content {
height: auto;
min-height: calc(100vh - 150px);
padding: 20px;
background-color: white;
}
#content h1{
color:rgba(62, 59, 59, 1);
#content h1 {
color: rgba(62, 59, 59, 1);
}
#content a{
#content a {
color: blue;
text-decoration: none;
}
#content a:hover{
text-decoration:underline;
#content a:hover {
text-decoration: underline;
}
/*
* Buttons
*/
#content .form {
margin: 25px 0;
}
#content .button{
background:none;
background: linear-gradient(white, rgba(237, 237, 237, 1));
border: 1px solid rgba(200, 200, 200, 1);
border-radius:3px;
font-family:arial;
min-width:200px;
margin-bottom:10px;
height:auto;
transition: box-shadow 0.2s;
#content .form .input-group, #content .form .buttons {
padding-bottom: 10px;
}
#content .form .input-group > label {
font-weight: bold;
line-height: 22px;
font-size: 13px;
}
#content .form .input-group > .input-info {
padding-bottom: 5px;
color: #999;
}
#content .form .input {
}
#content .form .input input, #content .form .input textarea, #content .form .input select {
background: #fefefe;
border: 1px solid rgba(200, 200, 200, 1);
border-radius: 3px;
margin-bottom: 5px;
padding: 0 10px;
box-shadow: inset 1px 1px 3px rgba(230, 230, 230, 1);
}
#content .form .input input:focus, #content .form .input input:focus, #content .form .input select:focus {
border: 1px solid rgba(137, 137, 137, 1);
}
#content .form .input input {
min-width: 180px;
}
#content .form .input input[type="number"] {
padding-right: 0;
min-width: 190px;
}
#content .form .input textarea {
min-height: 150px;
min-width: 400px;
line-height: 18px !important;
padding-top: 8px;
padding-bottom: 8px;
}
#content .form .input input,
#content .form .input textarea,
#content .form .input.input-labeled.input-labeled-left > *:first-child,
#content .form .input.input-labeled.input-labeled-right > *:last-child {
line-height: 33px;
}
#content .form .input select {
padding: 8px 10px 9px;
min-width: 200px;
}
#content .form .input select option[value=""] {
color: #ccc;
}
#content .form .input.input-labeled.input-labeled-left > *:first-child,
#content .form .input.input-labeled.input-labeled-right > *:last-child {
background: #eee;
border: 1px solid rgba(200, 200, 200, 1);
border-radius: 3px;
display: inline-block;
margin: 0 0 0 3px;
padding: 0 10px;
position: absolute;
}
#content .form .input.input-action > *:first-child,
#content .form .input.input-labeled > *:first-child {
border-top-right-radius: 0 !important;
border-bottom-right-radius: 0 !important;
margin-right: -4px;
}
#content .form .input.input-action > *:last-child,
#content .form .input.input-labeled > *:last-child {
border-top-left-radius: 0 !important;
border-bottom-left-radius: 0 !important;
}
#content .buttons {
margin: 15px 0;
}
#content a.button{
display:block;
#content .form .buttons {
margin: 0;
}
#content .buttons.buttons-horizontal .button {
display: block;
margin-top: 10px;
}
#content .button:hover{
box-shadow: 1px 1px 4px #DBDBDB;
text-decoration:none;
cursor:pointer;
transition: box-shadow 0.2s;
#content .buttons.buttons-horizontal .button:first-child {
margin-top: 0;
}
#content .button-big{
width:300px;
font-size:18px;
line-height:45px;
padding-left:20px;
padding-right:20px;
color:rgba(57, 57, 57, 1);
text-decoration:none;
}
#content .button-small{
width:200px;
font-size:13px;
line-height:30px;
padding-left:10px;
padding-right:10px;
color:rgba(57, 57, 57, 1);
text-decoration:none;
}
#content .button a{
}
#content div.button-big a{
}
/****** Tables ******/
#content table{
#content .button {
background: #dddddd;
background: linear-gradient(#ffffff, #eaeaea);
border: 1px solid rgba(200, 200, 200, 1);
border-radius: 3px;
font-family: arial, serif;
transition: all 0.2s;
height: auto;
min-width: 200px;
width: 200px;
line-height: 31px;
font-size: 13px;
text-align: center;
color: rgba(57, 57, 57, 1);
text-decoration: none;
}
#content a.button {
display: inline-block;
}
#content .button:hover {
box-shadow: 1px 1px 4px #dbdbdb;
text-decoration: none;
cursor: pointer;
}
#content .button.button-large,
#content .buttons.button-large .button {
min-width: 300px;
width: 300px;
font-size: 15px;
line-height: 45px;
color: rgba(57, 57, 57, 1);
}
#content .button.button-primary,
#content .buttons.button-primary .button {
background: #666;
background: linear-gradient(#999, #666);
border-color: #444;
color: #fff;
}
#content .button.button-primary:hover,
#content .button.button-primary:active,
#content .buttons.button-primary .button:hover,
#content .buttons.button-primary .button:active {
background: #777;
background: linear-gradient(#777777, #444);
border-color: #333;
color: #fff;
}
#content .table {
margin: 25px 0;
border-collapse: collapse;
border:none;
border: none;
}
#content table tr th{
padding-bottom:10px;
padding-left:15px;
padding-right:15px;
}
#content table tr td{
padding:10px;
border:1px solid rgba(179, 176, 176, 1);
}
#content table.list{
margin-top:40px;
}
#content table.list tr:hover{
background-color:rgba(234, 234, 234, 1);
}
#content table.list tr.head:hover{
background:none;
}
#content table.list tr:hover a{
color:blue;
}
#content table.list a {
color:rgba(148, 148, 255, 1);
}
/****** Tables END ******/
#content .table thead th {
line-height: 38px;
padding: 2px 15px 0;
border: 1px solid rgba(179, 176, 176, 1);
background: #eeeeee;
background: linear-gradient(#ffffff, #eaeaea);
font-size: 13px;
}
#content .table tfoot th {
line-height: 33px;
text-align: left;
padding: 0 10px;
font-weight: normal;
color: #999;
}
#content .table tbody td {
line-height: 33px;
padding: 0 10px;
border: 1px solid rgba(179, 176, 176, 1);
}
#content .table tbody > tr:hover {
background-color: rgba(234, 234, 234, 1);
}
#content .table a {
color: rgb(148, 148, 255);
}
#content .table tbody > tr:hover a {
color: blue;
}
#content input.textinput, textarea.textinput, select{
background: none repeat scroll 0% 0% transparent;
border: 1px solid rgba(200, 200, 200, 1);
border-radius: 3px;
margin-bottom: 5px;
padding: 3px;
box-shadow: inset 1px 1px 3px rgba(230, 230, 230, 1);
}
#content input.textinput:focus, textarea.textinput:focus{
border: 1px solid rgba(137, 137, 137, 1);
}
#content textarea.textinput{
min-height:150px;
min-width:400px;
}
/*
* Footer
*/
*/
#footer{
position:relative;
height:20px;
width:100%;
background-color:white;
padding:20px;
box-sizing:border-box;
color:grey;
#footer {
position: relative;
height: 20px;
width: 100%;
background-color: white;
padding: 20px;
box-sizing: border-box;
color: grey;
}
#footer a{
text-decoration:none;
color:grey;
#footer a {
text-decoration: none;
color: grey;
}
/*
* Notifications
*/
div.notification{
height:auto;
width:100%;
margin-top:15px;
text-align:center;
border-style:solid;
border-width:1px;
border-radius:3px;
padding:10px;
box-sizing:border-box;
margin-bottom:40px;
#content .notification {
height: auto;
width: 100%;
margin: 15px 0;
text-align: center;
border-style: solid;
border-width: 1px;
border-radius: 3px;
padding: 15px 10px;
box-sizing: border-box;
}
div.notification-fail{
background-color:#FCACAC;
border-color:red;
#content .notification.notification-fail {
background-color: #fcacac;
border-color: red;
}
div.notification-success{
background-color:rgba(182, 255, 183, 1);
border-color:green;
}
/*
* Headlines
*/
#content h1{
font-size:
}
#content .notification.notification-success {
background-color: rgba(182, 255, 183, 1);
border-color: green;
}

View file

@ -22,12 +22,14 @@ function add_message($type, $message)
function output_messages()
{
echo "<div class=\"messages\">";
global $MESSAGES;
foreach($MESSAGES as $message){
echo "<div class=\"notification notification-".$message['type']."\">".$message['message']."</div>";
if(count($MESSAGES) > 0) {
echo '<div class="messages">';
foreach($MESSAGES as $message){
echo '<div class="notification notification-'.$message['type'].'">'.$message['message'].'</div>';
}
echo '</div>';
}
echo "</div>";
}
@ -132,12 +134,28 @@ function writeLog($text)
}
/**
* @param string $url
* @return string
*/
function url($url)
{
$base = FRONTEND_BASE_PATH;
if (substr($base, -1) === '/') {
$base = substr($base, 0, -1);
}
if (strlen($url) > 0 && $url[0] === '/') {
$url = substr($url, 1);
}
return $base.'/'.$url;
}
/**
* @param string $url
*/
function redirect($url)
{
header("Location: ".FRONTEND_BASE_PATH.$url);
header("Location: ".url($url));
exit;
}

View file

@ -1,7 +1,3 @@
<?php
?>
<h1>This page does not exist.</h1>
<p>

View file

@ -33,11 +33,19 @@ if(isset($_POST['domain'])){
<?php output_messages(); ?>
<p>
<a class="button button-small" href="<?php echo FRONTEND_BASE_PATH; ?>admin/listdomains/">&#10092; Back to domain list</a>
</p>
<div class="buttons">
<a class="button" href="<?php echo url('admin/listdomains'); ?>">&#10092; Back to domain list</a>
</div>
<form action="" method="post">
<p><input name="domain" class="textinput" type="text" placeholder="domain.tld" autofocus/></p>
<p><input type="submit" class="button button-small" value="Create domain"/>
<form class="form" action="" method="post" autocomplete="off">
<div class="input-group">
<label>Domain</label>
<div class="input">
<input type="text" name="domain" placeholder="domain.tld" autofocus required/>
</div>
</div>
<div class="buttons">
<button type="submit" class="button button-primary">Create domain</button>
</div>
</form>

View file

@ -2,7 +2,7 @@
if(!isset($_GET['id'])){
// Domain id not set, redirect to overview
redirect("admin/listdomains/");
redirect("admin/listdomains");
}
$id = $db->escape_string($_GET['id']);
@ -16,7 +16,7 @@ if(!$result = $db->query($sql)){
if($result->num_rows !== 1){
// Domain does not exist, redirect to overview
redirect("admin/listdomains/");
redirect("admin/listdomains");
}
$row = $result->fetch_assoc();
@ -61,23 +61,34 @@ if(isset($_POST['confirm'])){
else{
// Choose to not delete domain, redirect to overview
redirect("admin/listdomains/");
redirect("admin/listdomains");
}
}
?>
<h1>Delete domain "<?php echo $domain ?>"?</h1>
<p>
<strong>All mailboxes matching the domain will be deleted from the user database!</strong><br>
Mailbox directories in the filesystem won't be affected.
</p>
<div class="buttons">
<a class="button" href="<?php echo url('admin/listdomains'); ?>">&#10092; Back to domain list</a>
</div>
<form action="" method="post">
<select name="confirm" autofocus>
<option value="no">No!</option>
<option value="yes">Yes!</option>
</select>
<input type="submit" class="button button-small" value="Okay"/>
<form class="form" action="" method="post">
<div class="input-group">
<label>All mailboxes matching the domain will be deleted from the user database!</label>
<div class="input-info">Mailbox directories in the filesystem won't be affected.</div>
</div>
<div class="input-group">
<label>Do you realy want to delete this domain?</label>
<div class="input">
<select name="confirm" autofocus required>
<option value="no">No!</option>
<option value="yes">Yes!</option>
</select>
</div>
</div>
<div class="buttons">
<button type="submit" class="button button-primary">Delete</button>
</div>
</form>

View file

@ -2,7 +2,7 @@
if(!isset($_GET['id'])){
// Redirect id not set, redirect to overview
redirect("admin/listredirects/");
redirect("admin/listredirects");
}
$id = $db->escape_string($_GET['id']);
@ -38,7 +38,7 @@ if(!$result = $db->query($sql)){
if($result->num_rows !== 1){
// Redirect does not exist, redirect to overview
redirect("admin/listredirects/");
redirect("admin/listredirects");
}
$redirect = $result->fetch_assoc();
@ -66,7 +66,7 @@ if(isset($_POST['confirm'])){
}
else{
// Choose to not delete redirect, redirect to overview
redirect("admin/listredirects/");
redirect("admin/listredirects");
}
}
@ -74,26 +74,37 @@ else{
$source = $redirect[DBC_ALIASES_SOURCE];
$destination = $redirect[DBC_ALIASES_DESTINATION];
?>
<h1>Delete redirection?</h1>
<table>
<tr>
<th>Source</th>
<th>Destination</th>
</tr>
<tr>
<td><?php echo strip_tags(formatEmails($source, FRONTEND_EMAIL_SEPARATOR_TEXT)); ?></td>
<td><?php echo strip_tags(formatEmails($destination, FRONTEND_EMAIL_SEPARATOR_TEXT)); ?></td>
</tr>
</table>
<div class="buttons">
<a class="button" href="<?php echo url('admin/listredirects'); ?>">&#10092; Back to redirect list</a>
</div>
<form action="" method="post">
<select name="confirm">
<option value="no">No!</option>
<option value="yes">Yes!</option>
</select>
<form class="form" action="" method="post">
<div class="input-group">
<label>Source</label>
<div class="input-info"><?php echo strip_tags(formatEmails($source, FRONTEND_EMAIL_SEPARATOR_TEXT)); ?></div>
</div>
<input type="submit" class="button button-small" value="Okay"/>
<div class="input-group">
<label>Destination</label>
<div class="input-info"><?php echo strip_tags(formatEmails($destination, FRONTEND_EMAIL_SEPARATOR_TEXT)); ?></div>
</div>
<div class="input-group">
<label>Do you realy want to delete this redirect?</label>
<div class="input">
<select name="confirm" autofocus required>
<option value="no">No!</option>
<option value="yes">Yes!</option>
</select>
</div>
</div>
<div class="buttons">
<button type="submit" class="button button-primary">Delete</button>
</div>
</form>
<?php
}

View file

@ -9,13 +9,12 @@ if(!$result = $db->query($sql)){
dbError($db->error);
}
while($row = $result->fetch_assoc()){
$username = $row[DBC_USERS_USERNAME];
$domain = $row[DBC_USERS_DOMAIN];
}
$row = $result->fetch_assoc();
$mailaddress = $username."@".$domain;
$username = $row[DBC_USERS_USERNAME];
$domain = $row[DBC_USERS_DOMAIN];
$mailAddress = $username."@".$domain;
// Delete user
if(isset($_POST['confirm'])){
@ -23,7 +22,7 @@ if(isset($_POST['confirm'])){
if($confirm === "yes"){
// Check if admin is affected
if (!in_array($mailaddress, $admins)) {
if (!in_array($mailAddress, $admins)) {
$sql = "DELETE FROM `".DBT_USERS."` WHERE `".DBC_USERS_ID."` = '$id'";
if(!$result = $db->query($sql)){
@ -41,24 +40,35 @@ if(isset($_POST['confirm'])){
}
else{
// Choose to not delete user, redirect to overview
redirect("admin/listusers/");
redirect("admin/listusers");
}
}
?>
<h1>Delete user "<?php echo $mailaddress ?>"?</h1>
<h1>Delete user "<?php echo strip_tags($mailAddress) ?>"?</h1>
<p>
<strong>The user's mailbox will be deleted from the database!</strong><br>
The mailbox in the filesystem won't be affected.
</p>
<div class="buttons">
<a class="button" href="<?php echo url('admin/listusers'); ?>">&#10092; Back to user list</a>
</div>
<form action="" method="post">
<select name="confirm" autofocus>
<option value="no">No!</option>
<option value="yes">Yes!</option>
</select>
<input type="submit" class="button button-small" value="Okay"/>
<form class="form" action="" method="post">
<div class="input-group">
<label>The user's mailbox will be deleted from the database only!</label>
<div class="input-info">The mailbox in the filesystem won't be affected.</div>
</div>
<div class="input-group">
<label>Do you realy want to delete this user?</label>
<div class="input">
<select name="confirm" autofocus required>
<option value="no">No!</option>
<option value="yes">Yes!</option>
</select>
</div>
</div>
<div class="buttons">
<button type="submit" class="button button-primary">Delete</button>
</div>
</form>

View file

@ -37,7 +37,7 @@ if(isset($_GET['id'])){
if($result->num_rows !== 1){
// Redirect does not exist, redirect to overview
redirect("admin/listredirects/");
redirect("admin/listredirects");
}
$redirect = $result->fetch_assoc();
@ -225,39 +225,38 @@ if(isset($_GET['id'])){
<h1><?php echo ($mode === "create") ? 'Create' : 'Edit'; ?> Redirect</h1>
<div class="buttons">
<a class="button" href="<?php echo url('admin/listredirects'); ?>">&#10092; Back to redirects list</a>
</div>
<?php output_messages(); ?>
<p>
<a class="button button-small" href="<?php echo FRONTEND_BASE_PATH; ?>admin/listredirects/">&#10092; Back to redirects list</a>
</p>
<form action="" method="post">
<form class="form" action="" method="post" autocomplete="off">
<input name="savemode" type="hidden" value="<?php echo isset($mode) ? $mode : ''; ?>"/>
<p>
Enter single or multiple addresses separated by comma, semicolon or newline.
</p>
<div class="input-group">
<div class="input-info">Enter single or multiple addresses separated by comma, semicolon or newline.</div>
</div>
<table>
<tr>
<th>Source</th>
<th>Destination</th>
</tr>
<tr>
<td>
<?php if(defined('DBC_ALIASES_MULTI_SOURCE')): ?>
<textarea name="source" class="textinput" placeholder="Source" required="required" autofocus><?php echo isset($sources) ? strip_tags(emailsToString($sources, FRONTEND_EMAIL_SEPARATOR_FORM)) : ''; ?></textarea>
<?php else: ?>
<input type="text" name="source" class="textinput" placeholder="Source (single address)" required="required" autofocus value="<?php echo isset($sources) ? strip_tags(emailsToString($sources, FRONTEND_EMAIL_SEPARATOR_FORM)) : ''; ?>"/>
<?php endif; ?>
</td>
<td>
<textarea name="destination" class="textinput" placeholder="Destination" required="required"><?php echo isset($destinations) ? strip_tags(emailsToString($destinations, FRONTEND_EMAIL_SEPARATOR_FORM)) : ''; ?></textarea>
</td>
</tr>
</table>
<div class="input-group">
<label for="source">Source</label>
<div class="input">
<?php if(defined('DBC_ALIASES_MULTI_SOURCE')): ?>
<textarea name="source" placeholder="Source" required autofocus><?php echo isset($sources) ? strip_tags(emailsToString($sources, FRONTEND_EMAIL_SEPARATOR_FORM)) : ''; ?></textarea>
<?php else: ?>
<input type="text" name="source" placeholder="Source (single address)" required autofocus value="<?php echo isset($sources) ? strip_tags(emailsToString($sources, FRONTEND_EMAIL_SEPARATOR_FORM)) : ''; ?>"/>
<?php endif; ?>
</div>
</div>
<p>
<input type="submit" class="button button-small" value="Save settings">
</p>
<div class="input-group">
<label for="destination">Destination</label>
<div class="input">
<textarea name="destination" placeholder="Destination" required><?php echo isset($destinations) ? strip_tags(emailsToString($destinations, FRONTEND_EMAIL_SEPARATOR_FORM)) : ''; ?></textarea>
</div>
</div>
<div class="buttons">
<button type="submit" class="button button-primary">Save settings</button>
</div>
</form>

View file

@ -1,240 +1,239 @@
<?php
// If mailbox_limit is supported in the MySQL database
$mailbox_limit_default = 0;
if(defined('DBC_USERS_MAILBOXLIMIT')){
// Get mailbox_limit default value from DB
$sql = "SELECT DEFAULT(".DBC_USERS_MAILBOXLIMIT.") AS `".DBC_USERS_MAILBOXLIMIT."` FROM `".DBT_USERS."` LIMIT 1;";
if(!$result = $db->query($sql)){
dbError($db->error);
}
else{
while($row = $result->fetch_assoc()){
$mailbox_limit_default = $row[DBC_USERS_MAILBOXLIMIT];
}
// If mailbox_limit is supported in the MySQL database
$mailbox_limit_default = 0;
if(defined('DBC_USERS_MAILBOXLIMIT')){
// Get mailbox_limit default value from DB
$sql = "SELECT DEFAULT(".DBC_USERS_MAILBOXLIMIT.") AS `".DBC_USERS_MAILBOXLIMIT."` FROM `".DBT_USERS."` LIMIT 1;";
if(!$result = $db->query($sql)){
dbError($db->error);
}
else{
while($row = $result->fetch_assoc()){
$mailbox_limit_default = $row[DBC_USERS_MAILBOXLIMIT];
}
}
if(isset($_POST['savemode'])){
$savemode = $_POST['savemode'];
if($savemode === "edit"){
// Edit mode entered
}
if(!isset($_POST['id'])){
// User id not set, redirect to overview
redirect("admin/listusers/");
$username = isset($_POST['username']) ? $db->escape_string(strtolower($_POST['username'])) : '';
$domain = isset($_POST['domain']) ? $db->escape_string(strtolower($_POST['domain'])) : '';
if(isset($_POST['savemode'])){
$savemode = $_POST['savemode'];
if($savemode === "edit"){
// Edit mode entered
if(!isset($_POST['id'])){
// User id not set, redirect to overview
redirect("admin/listusers");
}
$id = $db->escape_string($_POST['id']);
$sql = "SELECT `".DBC_USERS_ID."` FROM `".DBT_USERS."` WHERE `".DBC_USERS_ID."` = '$id' LIMIT 1;";
if(!$resultExists = $db->query($sql)){
dbError($db->error);
}
if($resultExists->num_rows !== 1){
// User does not exist, redirect to overview
redirect("admin/listusers");
}
if(defined('DBC_USERS_MAILBOXLIMIT')){
$mailbox_limit = $db->escape_string($_POST['mailbox_limit']);
if($mailbox_limit == ""){
$mailbox_limit = $mailbox_limit_default;
}
$id = $db->escape_string($_POST['id']);
$sql = "SELECT `".DBC_USERS_ID."` FROM `".DBT_USERS."` WHERE `".DBC_USERS_ID."` = '$id' LIMIT 1;";
if(!$resultExists = $db->query($sql)){
$sql = "UPDATE `".DBT_USERS."` SET `".DBC_USERS_MAILBOXLIMIT."` = '$mailbox_limit' WHERE `".DBC_USERS_ID."` = '$id';";
if(!$result = $db->query($sql)){
dbError($db->error);
}
}
if($resultExists->num_rows !== 1){
// User does not exist, redirect to overview
redirect("admin/listusers/");
// Is there a changed password?
if($_POST['password'] !== ""){
$pass_ok = check_new_pass($_POST['password'], $_POST['password_repeat']);
if($pass_ok === true){
// Password is okay and can be set
$pass_hash = gen_pass_hash($_POST['password']);
write_pass_hash_to_db($pass_hash, $id);
// Edit user password successfull, redirect to overview
redirect("admin/listusers/?edited=1");
}
if(defined('DBC_USERS_MAILBOXLIMIT')){
$mailbox_limit = $db->escape_string($_POST['mailbox_limit']);
if($mailbox_limit == ""){
$mailbox_limit = $mailbox_limit_default;
}
$sql = "UPDATE `".DBT_USERS."` SET `".DBC_USERS_MAILBOXLIMIT."` = '$mailbox_limit' WHERE `".DBC_USERS_ID."` = '$id';";
if(!$result = $db->query($sql)){
dbError($db->error);
}
else{
// Password is not okay
// $editsuccessful = 2;
add_message("fail", $PASS_ERR_MSG);
}
}
else{
// Edit user successfull, redirect to overview
redirect("admin/listusers/?edited=1");
}
}
// Is there a changed password?
if($_POST['password'] !== ""){
$pass_ok = check_new_pass($_POST['password'], $_POST['password_rep']);
else if($savemode === "create"){
// Create mode entered
if(defined('DBC_USERS_MAILBOXLIMIT')){
$mailbox_limit = $db->escape_string($_POST['mailbox_limit']);
}
else{
// make mailbox_limit dummy for "if"
$mailbox_limit = 0;
}
$pass = $_POST['password'];
$pass_rep = $_POST['password_repeat'];
if(!empty($username) && !empty($domain) && !empty($mailbox_limit)){
// Check if user already exists
$user_exists = $db->query("SELECT `".DBC_USERS_USERNAME."`, `".DBC_USERS_DOMAIN."` FROM `".DBT_USERS."` WHERE `".DBC_USERS_USERNAME."` = '$username' AND `".DBC_USERS_DOMAIN."` = '$domain';");
if($user_exists->num_rows == 0){
// All fields filled with content
// Check passwords
$pass_ok = check_new_pass($pass, $pass_rep);
if($pass_ok === true){
// Password is okay and can be set
$pass_hash = gen_pass_hash($_POST['password']);
write_pass_hash_to_db($pass_hash, $id);
// Password is okay ... continue
$pass_hash = gen_pass_hash($pass);
// Edit user password successfull, redirect to overview
redirect("admin/listusers/?edited=1");
// Differ between version with mailbox_limit and version without
if(defined('DBC_USERS_MAILBOXLIMIT')){
$sql = "INSERT INTO `".DBT_USERS."` (`".DBC_USERS_USERNAME."`, `".DBC_USERS_DOMAIN."`, `".DBC_USERS_PASSWORD."`, `".DBC_USERS_MAILBOXLIMIT."`) VALUES ('$username', '$domain', '$pass_hash', '$mailbox_limit')";
}
else{
$sql = "INSERT INTO `".DBT_USERS."` (`".DBC_USERS_USERNAME."`, `".DBC_USERS_DOMAIN."`, `".DBC_USERS_PASSWORD."`) VALUES ('$username', '$domain', '$pass_hash')";
}
if(!$result = $db->query($sql)){
dbError($db->error);
}
// Redirect user to user list
redirect("admin/listusers/?created=1");
}
else{
// Password is not okay
// $editsuccessful = 2;
// Password not okay
add_message("fail", $PASS_ERR_MSG);
}
}
else{
// Edit user successfull, redirect to overview
redirect("admin/listusers/?edited=1");
add_message("fail", "User already exists in database.");
}
}
else if($savemode === "create"){
// Create mode entered
$username = $db->escape_string($_POST['username']);
$username = strtolower($username);
$domain = $db->escape_string($_POST['domain']);
$domain = strtolower($domain);
if(defined('DBC_USERS_MAILBOXLIMIT')){
$mailbox_limit = $db->escape_string($_POST['mailbox_limit']);
}
else{
// make mailbox_limit dummy for "if"
$mailbox_limit = 0;
}
$pass = $_POST['password'];
$pass_rep = $_POST['password_rep'];
if($username !== "" && $domain !== "" && $mailbox_limit !== ""){
// Check if user already exists
$user_exists = $db->query("SELECT `".DBC_USERS_USERNAME."`, `".DBC_USERS_DOMAIN."` FROM `".DBT_USERS."` WHERE `".DBC_USERS_USERNAME."` = '$username' AND `".DBC_USERS_DOMAIN."` = '$domain';");
if($user_exists->num_rows == 0){
// All fields filled with content
// Check passwords
$pass_ok = check_new_pass($pass, $pass_rep);
if($pass_ok === true){
// Password is okay ... continue
$pass_hash = gen_pass_hash($pass);
// Differ between version with mailbox_limit and version without
if(defined('DBC_USERS_MAILBOXLIMIT')){
$sql = "INSERT INTO `".DBT_USERS."` (`".DBC_USERS_USERNAME."`, `".DBC_USERS_DOMAIN."`, `".DBC_USERS_PASSWORD."`, `".DBC_USERS_MAILBOXLIMIT."`) VALUES ('$username', '$domain', '$pass_hash', '$mailbox_limit')";
}
else{
$sql = "INSERT INTO `".DBT_USERS."` (`".DBC_USERS_USERNAME."`, `".DBC_USERS_DOMAIN."`, `".DBC_USERS_PASSWORD."`) VALUES ('$username', '$domain', '$pass_hash')";
}
if(!$result = $db->query($sql)){
dbError($db->error);
}
// Redirect user to user list
redirect("admin/listusers/?created=1");
}
else{
// Password not okay
add_message("fail", $PASS_ERR_MSG);
}
}
else{
add_message("fail", "User already exists in database.");
}
}
else{
// Fields missing
add_message("fail", "Not all fields were filled out.");
}
else{
// Fields missing
add_message("fail", "Not all fields were filled out.");
}
}
// Select mode
$mode = "create";
if(isset($_GET['id'])){
$mode = "edit";
$id = $db->escape_string($_GET['id']);
}
if($mode === "edit"){
//Load user data from DB
$sql = "SELECT * from `".DBT_USERS."` WHERE `".DBC_USERS_ID."` = '$id' LIMIT 1;";
if(!$result = $db->query($sql)){
dbError($db->error);
}
}
if($result->num_rows !== 1){
// User does not exist, redirect to overview
redirect("admin/listusers/");
}
$row = $result->fetch_assoc();
// Select mode
$mode = "create";
if(isset($_GET['id'])){
$mode = "edit";
$id = $db->escape_string($_GET['id']);
$username = $row[DBC_USERS_USERNAME];
$domain = $row[DBC_USERS_DOMAIN];
if(defined('DBC_USERS_MAILBOXLIMIT')){
$mailbox_limit = $row[DBC_USERS_MAILBOXLIMIT];
}
//Load user data from DB
$sql = "SELECT * from `".DBT_USERS."` WHERE `".DBC_USERS_ID."` = '$id' LIMIT 1;";
if(!$result = $db->query($sql)){
dbError($db->error);
}
if($result->num_rows !== 1){
// User does not exist, redirect to overview
redirect("admin/listusers");
}
$row = $result->fetch_assoc();
$username = $row[DBC_USERS_USERNAME];
$domain = $row[DBC_USERS_DOMAIN];
if(defined('DBC_USERS_MAILBOXLIMIT')){
$mailbox_limit = $row[DBC_USERS_MAILBOXLIMIT];
}
}
//Load user data from DB
$sql = "SELECT `".DBC_DOMAINS_DOMAIN."` FROM `".DBT_DOMAINS."`;";
if(!$resultDomains = $db->query($sql)){
dbError($db->error);
}
?>
<h1><?php echo ($mode === "create") ? 'Create User' : 'Edit user "'.$username.'@'.$domain.'"'; ?></h1>
<div class="buttons">
<a class="button" href="<?php echo url('admin/listusers'); ?>">&#10092; Back to user list</a>
</div>
<h1><?php echo ($mode === "create") ? 'Create' : 'Edit'; ?> User</h1>
<?php output_messages(); ?>
<p>
<a class="button button-small" href="<?php echo FRONTEND_BASE_PATH; ?>admin/listusers/">&#10092; Back to user list</a>
</p>
<?php if($mode === "edit"): ?>
<p>
<strong>Username and domain cannot be edited.</strong><br>
To rename or move a mailbox, you have to move in the filesystem first and create a new user here after.
</p>
<form class="form" action="" method="post">
<input type="hidden" name="savemode" value="<?php echo $mode; ?>"/>
<?php if($mode === "edit" && isset($id)): ?>
<input type="hidden" name="id" value="<?php echo $id; ?>"/>
<?php endif; ?>
<form action="" method="post">
<table>
<tr> <th>Username</th> <th>Domain</th> <th>Password</th> <?php if(defined('DBC_USERS_MAILBOXLIMIT')){ ?><th>Mailbox limit (in MB)</th> <?php } ?> </tr>
<tr>
<td>
<input name="username" class="textinput" type="text" autofocus <?php echo ($mode === "edit") ? ' disabled' : '';?> value="<?php if(isset($username)){echo strtolower(strip_tags($username));} ?>" placeholder="Username" required="required"/>
</td>
<td>
@
<select name="domain" <?php echo ($mode === "edit") ? ' disabled' : '';?> >
<?php
//Load user data from DB
$sql = "SELECT `".DBC_DOMAINS_DOMAIN."` FROM `".DBT_DOMAINS."`;";
if(!$result = $db->query($sql)){
dbError($db->error);
}
while($row = $result->fetch_assoc()){
$selected = "";
if(isset($domain) && $row[DBC_DOMAINS_DOMAIN] === $domain){$selected = "selected=\"selected\"";}
echo "<option value=\"".strip_tags($row[DBC_DOMAINS_DOMAIN])."\" ".$selected." >".strip_tags($row[DBC_DOMAINS_DOMAIN])."</option>";
}
?>
<?php output_messages(); ?>
<?php if($mode === "edit"): ?>
<div class="input-group">
<label>Username and Group cannot be edited</label>
<div class="input-info">To rename or move a mailbox, you have to move in the filesystem first and create a new user here after.</div>
</div>
<?php else: ?>
<div class="input-group">
<label for="username">Username</label>
<div class="input">
<input type="text" name="username" placeholder="Username" value="<?php echo isset($username) ? strip_tags($username) : ''; ?>" autofocus required/>
</div>
</div>
<div class="input-group">
<label for="domain">Domain</label>
<div class="input">
<select name="domain" required>
<option value="">-- Select a domain --</option>
<?php while($row = $resultDomains->fetch_assoc()): ?>
<option value="<?php echo strip_tags($row[DBC_DOMAINS_DOMAIN]); ?>" <?php echo (isset($domain) && $row[DBC_DOMAINS_DOMAIN] == $domain) ? 'selected' : ''; ?>>
<?php echo strip_tags($row[DBC_DOMAINS_DOMAIN]); ?>
</option>
<?php endwhile; ?>
</select>
</td>
<td>
<input name="password" class="textinput" type="password" placeholder="New password"/></br>
<input name="password_rep" class="textinput" type="password" placeholder="New password (repeat)"/>
<p>
<input type="button" class="button button-small" name="Text 1" value="Generate password"
onclick="pass=generatePassword();this.form.password.value=pass;this.form.password_rep.value=pass;this.form.password.type='text';this.form.password_rep.type='text'">
</p>
</td>
<?php if(defined('DBC_USERS_MAILBOXLIMIT')){ ?>
<td>
<input name="mailbox_limit" class="textinput" type="number" value="<?php if(isset($mailbox_limit)){echo strip_tags($mailbox_limit);} else{echo strip_tags($mailbox_limit_default);} ?>" placeholder="Mailbox size (MB)" required="required"/>
</td>
<?php } ?>
</tr>
</table>
<input name="savemode" type="hidden" value="<?php if(isset($mode)){echo $mode;} ?>"/>
<input name="id" class="sendbutton" type="hidden" value="<?php if(isset($id)){echo $id;} ?>"/>
<p>
<input type="submit" class="button button-small" value="Save settings">
</p>
</div>
</div>
<?php endif; ?>
<div class="input-group">
<label for="password">Password</label>
<div class="input-info">The new password must be at least <?php echo MIN_PASS_LENGTH; ?> characters long.</div>
<div class="input input-action">
<input type="password" name="password" placeholder="New password" <?php echo ($mode === "create") ? 'required' : ''; ?> minlength="<?php echo MIN_PASS_LENGTH; ?>"/>
<button type="button" class="button" onclick="pass=generatePassword();this.form.password.value=pass;this.form.password_repeat.value=pass;this.form.password.type='text';this.form.password_repeat.type='text'">Generate password</button>
</div>
<div class="input">
<input type="password" name="password_repeat" placeholder="Repeat password" <?php echo ($mode === "create") ? 'required' : ''; ?> minlength="<?php echo MIN_PASS_LENGTH; ?>"/>
</div>
</div>
<?php if(defined('DBC_USERS_MAILBOXLIMIT')): ?>
<div class="input-group">
<label>Mailbox limit</label>
<div class="input-info">The default limit is <?php echo $mailbox_limit_default; ?> MB. Limit set to 0 means no limit in size.</div>
<div class="input input-labeled input-labeled-right">
<input name="mailbox_limit" type="number" value="<?php echo strip_tags(isset($mailbox_limit) ? $mailbox_limit : $mailbox_limit_default); ?>" placeholder="Mailbox limit in MB" min="0" required/>
<span class="input-label">MB</span>
</div>
</div>
<?php endif; ?>
<div class="buttons">
<button type="submit" class="button button-primary">Save settings</button>
</div>
</form>

View file

@ -1,44 +1,61 @@
<?php
if(isset($_GET['deleted']) && $_GET['deleted'] == "1"){
add_message("success", "Domain deleted successfully.");
}
else if(isset($_GET['created']) && $_GET['created'] == "1"){
add_message("success", "Domain created successfully.");
}
else if(isset($_GET['adm_del']) && $_GET['adm_del'] == "1"){
add_message("fail", "Domain could not be deleted because admin account would be affected.");
}
?>
if(isset($_GET['deleted']) && $_GET['deleted'] == "1"){
add_message("success", "Domain deleted successfully.");
}
else if(isset($_GET['created']) && $_GET['created'] == "1"){
add_message("success", "Domain created successfully.");
}
else if(isset($_GET['adm_del']) && $_GET['adm_del'] == "1"){
add_message("fail", "Domain could not be deleted because admin account would be affected.");
}
$sql = "SELECT d.*, COUNT(DISTINCT u.`".DBC_USERS_ID."`) AS `user_count`, COUNT(DISTINCT r.`".DBC_ALIASES_ID."`) AS `redirect_count`
FROM `".DBT_DOMAINS."` AS d
LEFT JOIN `".DBT_USERS."` AS u ON (u.`".DBC_USERS_DOMAIN."` = d.`".DBC_DOMAINS_DOMAIN."`)
LEFT JOIN `".DBT_ALIASES."` AS r ON (r.`".DBC_ALIASES_SOURCE."` LIKE CONCAT('%@', d.`".DBC_DOMAINS_DOMAIN."`))
GROUP BY d.`".DBC_DOMAINS_DOMAIN."`
ORDER BY `".DBC_DOMAINS_DOMAIN."` ASC;";
if(!$result = $db->query($sql)){
dbError($db->error);
}
?>
<h1>Domains</h1>
<div class="buttons">
<a class="button" href="<?php echo url('admin/createdomain'); ?>">Create new domain</a>
</div>
<?php output_messages(); ?>
<p>
Add or delete domains.
</p>
<?php
$sql = "SELECT * FROM `".DBT_DOMAINS."` ORDER BY `".DBC_DOMAINS_DOMAIN."` ASC;";
if(!$result = $db->query($sql)){
dbError($db->error);
}
?>
<p>
<a class="button button-small" href="<?php echo FRONTEND_BASE_PATH; ?>admin/createdomain/">Create new domain</a>
</p>
<table class="list">
<tr class="head"><th>Domain</th> <th></th><tr>
<?php
while($row = $result->fetch_assoc()){
echo "<tr><td>".strip_tags($row[DBC_DOMAINS_DOMAIN])."</td> <td><a href=\"".FRONTEND_BASE_PATH."admin/deletedomain/?id=".$row[DBC_DOMAINS_ID]."\">[Delete]</a></td> </tr>";
}
?>
<table class="table">
<thead>
<tr>
<th>Domain</th>
<th>User count</th>
<th>Redirect count</th>
<th></th>
<tr>
</thead>
<tbody>
<?php while($row = $result->fetch_assoc()): ?>
<tr>
<td><?php echo strip_tags($row[DBC_DOMAINS_DOMAIN]); ?></td>
<td><?php echo strip_tags($row['user_count']); ?></td>
<td><?php echo strip_tags($row['redirect_count']); ?></td>
<td>
<a href="<?php echo url('admin/deletedomain/?id='.$row[DBC_DOMAINS_ID]); ?>">[Delete]</a>
</td>
</tr>
<?php endwhile; ?>
</tbody>
<?php if ($result->num_rows > 0): ?>
<tfoot>
<tr>
<th><?php echo $result->num_rows;?> Domains</th>
</tr>
</tfoot>
<?php endif; ?>
</table>

View file

@ -45,27 +45,30 @@ if(!$result = $db->query($sql)){
<?php output_messages(); ?>
<p>
<a class="button button-small" href="<?php echo FRONTEND_BASE_PATH; ?>admin/editredirect/">Create new redirect</a>
</p>
<div class="buttons">
<a class="button" href="<?php echo url('admin/editredirect'); ?>">Create new redirect</a>
</div>
<table class="list">
<tr class="head">
<th>Source</th>
<th>Destination</th>
<th></th>
<th></th>
<tr>
<?php while($row = $result->fetch_assoc()): ?>
<tr>
<td><?php echo strip_tags(formatEmails($row[DBC_ALIASES_SOURCE], FRONTEND_EMAIL_SEPARATOR_TEXT)); ?></td>
<td><?php echo strip_tags(formatEmails($row[DBC_ALIASES_DESTINATION], FRONTEND_EMAIL_SEPARATOR_TEXT)); ?></td>
<td>
<a href="<?php echo FRONTEND_BASE_PATH; ?>admin/editredirect/?id=<?php echo $row[DBC_ALIASES_ID]; ?>">[Edit]</a>
</td>
<td>
<a href="<?php echo FRONTEND_BASE_PATH; ?>admin/deleteredirect/?id=<?php echo $row[DBC_ALIASES_ID]; ?>">[Delete]</a>
</td>
</tr>
<?php endwhile; ?>
<table class="table">
<thead>
<tr>
<th>Source</th>
<th>Destination</th>
<th></th>
<th></th>
<tr>
</thead>
<tbody>
<?php while($row = $result->fetch_assoc()): ?>
<tr>
<td><?php echo strip_tags(formatEmails($row[DBC_ALIASES_SOURCE], FRONTEND_EMAIL_SEPARATOR_TEXT)); ?></td>
<td><?php echo strip_tags(formatEmails($row[DBC_ALIASES_DESTINATION], FRONTEND_EMAIL_SEPARATOR_TEXT)); ?></td>
<td>
<a href="<?php echo url('admin/editredirect/?id='.$row[DBC_ALIASES_ID]); ?>">[Edit]</a>
</td>
<td>
<a href="<?php echo url('admin/deleteredirect/?id='.$row[DBC_ALIASES_ID]); ?>">[Delete]</a>
</td>
</tr>
<?php endwhile; ?>
</table>

View file

@ -12,18 +12,6 @@ else if(isset($_GET['edited']) && $_GET['edited'] == "1"){
else if(isset($_GET['adm_del']) && $_GET['adm_del'] == "1"){
add_message("fail", "Admin user cannot be deleted.");
}
?>
<h1>List of all mailbox accounts</h1>
<?php output_messages(); ?>
<?php
$sql = "SELECT * FROM `".DBT_USERS."` ORDER BY `".DBC_USERS_DOMAIN."`, `".DBC_USERS_USERNAME."` ASC;";
@ -33,23 +21,52 @@ if(!$result = $db->query($sql)){
?>
<p>
<a class="button button-small" href="<?php echo FRONTEND_BASE_PATH; ?>admin/edituser/">Create new user</a>
</p>
<h1>List of all mailbox accounts</h1>
<table class="list">
<tr class="head"><th>Username</th> <th>Domain</th> <?php if(defined('DBC_USERS_MAILBOXLIMIT')){ ?><th>Mailbox Limit (MB)</th> <?php } ?><th></th> <th></th><tr>
<div class="buttons">
<a class="button button-small" href="<?php echo url('admin/edituser'); ?>">Create new user</a>
</div>
<?php
while($row = $result->fetch_assoc()){
if(defined('DBC_USERS_MAILBOXLIMIT')){
$mailbox_limit_column = '<td>'.strip_tags($row[DBC_USERS_MAILBOXLIMIT]).'</td>';
}
else{
$mailbox_limit_column = '';
}
<?php output_messages(); ?>
echo "<tr> <td>".strip_tags($row[DBC_USERS_USERNAME])."</td><td>".strip_tags($row[DBC_USERS_DOMAIN])."</td>".$mailbox_limit_column."<td><a href=\"".FRONTEND_BASE_PATH."admin/edituser/?id=".$row[DBC_USERS_ID]."\">[Edit]</a></td> <td><a href=\"".FRONTEND_BASE_PATH."admin/deleteuser/?id=".$row[DBC_USERS_ID]."\">[Delete]</a></td> </tr>";
}
?>
<table class="table">
<thead>
<tr>
<th>Username</th>
<th>Domain</th>
<?php if(defined('DBC_USERS_MAILBOXLIMIT')): ?>
<th>Mailbox Limit</th>
<?php endif; ?>
<th>Role</th>
<th></th>
<th></th>
<tr>
</thead>
<tbody>
<?php while($row = $result->fetch_assoc()): ?>
<tr>
<td><?php echo strip_tags($row[DBC_USERS_USERNAME]); ?></td>
<td><?php echo strip_tags($row[DBC_USERS_DOMAIN]); ?></td>
<?php if(defined('DBC_USERS_MAILBOXLIMIT')):
$limit = strip_tags($row[DBC_USERS_MAILBOXLIMIT]);
?>
<td style="text-align: right"><?php echo ($limit > 0) ? $limit.' MB' : 'No limit'; ?></td>
<?php endif;?>
<td><?php echo in_array($row[DBC_USERS_USERNAME].'@'.$row[DBC_USERS_DOMAIN], $admins) ? 'Admin' : 'User'; ?></td>
<td>
<a href="<?php echo url('admin/edituser/?id='.$row[DBC_USERS_ID]); ?>">[Edit]</a>
</td>
<td>
<a href="<?php echo url('admin/deleteuser/?id='.$row[DBC_USERS_ID]); ?>">[Delete]</a>
</td>
</tr>
<?php endwhile; ?>
</tbody>
<?php if ($result->num_rows > 0): ?>
<tfoot>
<tr>
<th><?php echo $result->num_rows;?> User</th>
</tr>
</tfoot>
<?php endif; ?>
</table>

View file

@ -1,13 +1,9 @@
<?php
?>
<h1>Admin Dashboard</h1>
<p style="margin-top:50px;">
<a class="button button-big" href="<?php echo FRONTEND_BASE_PATH; ?>admin/listusers/">Manage users</a>
<div class="buttons buttons-horizontal button-large">
<a class="button" href="<?php echo url('admin/listusers'); ?>">Manage users</a>
<a class="button button-big" href="<?php echo FRONTEND_BASE_PATH; ?>admin/listdomains/">Manage domains</a>
<a class="button" href="<?php echo url('admin/listdomains'); ?>">Manage domains</a>
<a class="button button-big" href="<?php echo FRONTEND_BASE_PATH; ?>admin/listredirects/">Manage redirects</a>
</p>
<a class="button" href="<?php echo url('admin/listredirects'); ?>">Manage redirects</a>
</div>

View file

@ -4,7 +4,7 @@ if(isset($_POST['email']) && isset($_POST['password'])){
// Start login
$login_success = $user->login($_POST['email'], $_POST['password']);
if($login_success){
redirect("private/");
redirect("private");
}
// If login is not successful
else{
@ -16,7 +16,7 @@ if(isset($_POST['email']) && isset($_POST['password'])){
// If user is already logged in, redirect to start.
if($user->isLoggedIn()){
redirect("private/");
redirect("private");
}
?>

View file

@ -2,5 +2,5 @@
require_once 'include/php/default.inc.php';
session_destroy();
redirect('');
redirect('/');
?>

View file

@ -1,7 +1,3 @@
<?php
?>
<h1>Not allowed!</h1>
<p>

View file

@ -1,6 +1,6 @@
<?php
if(isset($_POST['sent'])){
if(isset($_POST['password']) && isset($_POST['password_repeat'])){
// User tries to change password
$change_pass_success = $user->change_password($_POST['password'], $_POST['password_repeat']);
@ -14,29 +14,28 @@ if(isset($_POST['sent'])){
?>
<h1>Change password</h1>
<div class="buttons">
<a class="button" href="<?php echo url('private'); ?>">&#10092; Back to personal dashboard</a>
</div>
<?php output_messages(); ?>
<p>
<a class="button button-small" href="<?php echo FRONTEND_BASE_PATH; ?>private/">&#10092; Back to personal dashboard</a>
</p>
<form class="form" action="" method="post" autocomplete="off">
<div class="input-group">
<label for="password">Password</label>
<div class="input-info">Your new password must be at least <?php echo MIN_PASS_LENGTH; ?> characters long.</div>
<div class="input input-action">
<input type="password" name="password" placeholder="New password" required minlength="<?php echo MIN_PASS_LENGTH; ?>" autofocus/>
<button type="button" class="button" onclick="pass=generatePassword();this.form.password.value=pass;this.form.password_repeat.value=pass;this.form.password.type='text';this.form.password_repeat.type='text'">Generate password</button>
</div>
<div class="input">
<input type="password" name="password_repeat" placeholder="Repeat password" required minlength="<?php echo MIN_PASS_LENGTH; ?>"/>
</div>
</div>
<p>
Your new password must contain <?php echo MIN_PASS_LENGTH; ?> characters or more.
</p>
<form action="" method="post">
<p>
<input name="password" class="textinput" type="password" placeholder="New password" autofocus/><br/>
<input name="password_repeat" class="textinput" type="password" placeholder="New password (repeat)"/>
<input name="sent" type="hidden" value="1"/>
</p>
<p>
<input type="submit" class="button button-small" value="Change password"/>
</p>
<div class="buttons">
<button type="submit" class="button button-primary">Change password</button>
</div>
</form>

View file

@ -1,13 +1,9 @@
<?php
?>
<h1>Welcome to your dashboard!</h1>
<p>
Please choose an action.
</p>
<p>
<a class="button button-big" href="<?php echo FRONTEND_BASE_PATH; ?>private/changepass/">Change e-mail account password</a>
</p>
<div class="buttons buttons-horizontal button-large">
<a class="button" href="<?php echo url('private/changepass'); ?>">Change e-mail account password</a>
</div>

View file

@ -12,6 +12,6 @@ Users of your server can log in here to change their passwords.
</p>
<p style="margin-top:30px;">
<a class="button button-small" href="<?php echo FRONTEND_BASE_PATH; ?>login/">Log in</a>
<a class="button button-small" href="<?php echo url('login'); ?>">Log in</a>
</p>

View file

@ -1,7 +1,8 @@
</div> <!-- Closing content -->
</div> <!-- Closing content -->
<div id="footer">
Software by Thomas Leister, 2015<br/> WebMUM on GitHub: <a href="https://github.com/ThomasLeister/webmum/">https://github.com/ThomasLeister/webmum/</a> | License: GNU-GPL 3.0
</div>
</body>
<div id="footer">
Software by Thomas Leister and contributors, 2015<br/> WebMUM on GitHub:
<a href="https://github.com/ThomasLeister/webmum">https://github.com/ThomasLeister/webmum</a> | License: GNU-GPL 3.0
</div>
</body>
</html>

View file

@ -1,28 +1,40 @@
<!doctype html>
<html>
<head>
<title>WebMUM</title>
<link rel=stylesheet href="<?php echo FRONTEND_BASE_PATH; ?>include/css/style.css" type="text/css" media=screen>
<script type="text/javascript">
<head>
<title>WebMUM</title>
<link rel=stylesheet href="<?php echo url('include/css/style.css'); ?>" type="text/css" media=screen>
<script type="text/javascript">
function generatePassword() {
var length = 9,
charset = "abcdefghijklnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!#",
retVal = "";
for (var i = 0, n = charset.length; i < length; ++i) {
retVal += charset.charAt(Math.floor(Math.random() * n));
}
return retVal;
var length = <?php echo MIN_PASS_LENGTH + 1; ?>,
charset = "abcdefghijklnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!#",
retVal = "";
for (var i = 0, n = charset.length; i < length; ++i) {
retVal += charset.charAt(Math.floor(Math.random() * n));
}
return retVal;
}
</script>
</head>
<body>
<div id="header">
<div class="title"><a href="<?php echo FRONTEND_BASE_PATH; ?>">WebMUM - Web Mailserver User Manager</a></div>
<div class="header-menu">
<?php if(user_has_permission("admin")){ ?><div class="header-button"> <a href="<?php echo FRONTEND_BASE_PATH ?>admin/">[Admin Dashboard]</a> </div> <div class="header-button"> <a href="<?php echo FRONTEND_BASE_PATH ?>private/">[Personal Dashboard]</a> </div><?php } ?>
<?php if($user->isLoggedIn()){?><div class="header-button">Logged in as <?php echo $_SESSION['email']; ?> <a href="<?php echo FRONTEND_BASE_PATH ?>logout/">[Logout]</a></div><?php }?>
</div>
</script>
</head>
<body>
<div id="header">
<div class="title"><a href="<?php echo url('/'); ?>">WebMUM - Web Mailserver User Manager</a></div>
<div class="header-menu">
<?php if(user_has_permission("admin")): ?>
<div class="header-button">
<a href="<?php echo url('admin'); ?>">[Admin Dashboard]</a>
</div>
<div class="header-button">
<a href="<?php echo url('private'); ?>">[Personal Dashboard]</a>
</div>
<?php endif; ?>
<?php if($user->isLoggedIn()): ?>
<div class="header-button">
Logged in as <?php echo $_SESSION['email']; ?>
<a href="<?php echo url('logout'); ?>">[Logout]</a>
</div>
<?php endif; ?>
</div>
<div id="content"> <!-- Opening content -->
</div>
<div id="content"> <!-- Opening content -->