10 Commits
v1.1 ... v1.3

8 changed files with 83 additions and 14 deletions

View File

@@ -13,7 +13,9 @@ A light PHP web interface for managing [mlmmj](http://mlmmj.org/) mailing lists.
### For users
- Authentication via LDAP
- List all available mailinglists on the server
- Display owners and listdescription of the respective mailing lists on the index page
- Only show the edit function for mailing lists where the user is set as owner
- Edit functions per mailing list: subscribers, moderators, prefix and listdescription
### For admins
- Error handling regarding invalid user input
@@ -69,7 +71,9 @@ Check if the values from `init.php` are still valid or need to be adapted.
## Changelog
v1.0 - Initial release (08/13/2021)
[v1.2](https://git.ecogood.org/services/mlmmj-light-web-ecg/releases/tag/v1.2) - Version 1.2 (2022-02-01)
[v1.1](https://git.ecogood.org/services/mlmmj-light-web-ecg/releases/tag/v1.1) - Version 1.1 (2021-11-25)
[v1.0](https://git.ecogood.org/services/mlmmj-light-web-ecg/releases/tag/v1.0) - Initial release (2021-08-13)
## Roadmap

View File

@@ -13,23 +13,24 @@ if (!isset($_SESSION["auth"]) || $_SESSION["auth"] != 1)
exit();
}
// We do not print any error in the next three cases, because a legitimate
// user will never produce such results, even with disabled javascript
if ( preg_match("/[^a-z0-9_-]/", $list_name) )
{
$_SESSION["error_code"] = 14;
header("Location: error.php");
exit();
}
if ( strlen($list_name) > 30 )
if ( strlen($list_name) > 50 )
{
$_SESSION["error_code"] = 13;
header("Location: error.php");
exit();
}
// Test list existence
if( !is_dir("$lists_path/$domain/$list_name") )
if( !is_dir("$lists_path/$domain/$list_name") || $list_name == "" )
{
$_SESSION["error_code"] = 12;
header("Location: error.php");
exit();
}

View File

@@ -1,5 +1,8 @@
<?php
# Scan loading time
$time_start = microtime(true);
require("init.php");
if (!isset($_SESSION["auth"]) || $_SESSION["auth"] != 1)
@@ -27,16 +30,40 @@ if (isset($lists))
}
$lists_new = [];
# Iterate through all lists
foreach($lists as $list)
{
# If list is in array of owned lists
if (!in_array($list, $_SESSION["array_lists_owned"]))
{
$lists_new[$list] = 0;
$lists_new[$list]["iamowner"] = 0;
}
else
{
$lists_new[$list] = 1;
$lists_new[$list]["iamowner"] = 1;
}
# Get the owners of the list and put them into the array
$owners = explode("\n", trim(shell_exec("/usr/bin/mlmmj-list -o -L $lists_path/$domain/$list")));
$lists_new[$list]["owners"] = $owners;
# Check whether there is a listdescription file
if (file_exists("$lists_path/$domain/$list/control/listdescription") && @file_get_contents("$lists_path/$domain/$list/control/listdescription") != "")
{
// Get list description
$listdescription = file_get_contents("$lists_path/$domain/$list/control/listdescription");
// Remove trailing empty symbols
$listdescription = trim($listdescription);
}
else
{
# Set listdescription to none
$listdescription = "none";
}
# Add the listdescription to the array
$lists_new[$list]["description"] = $listdescription;
}
}
else
@@ -44,11 +71,18 @@ else
$lists = NULL;
}
# Scan loading time
$time_end = microtime(true);
# Calculate loading time
$loadingtime = round(($time_end - $time_start), 2);
$smarty->assign("headline", $headline);
$smarty->assign("web_url", $web_url);
$smarty->assign("lists", $lists_new);
$smarty->assign("domain", $domain);
$smarty->assign("username", $_SESSION["username"]);
$smarty->assign("loadingtime", $loadingtime);
$smarty->display("index.tpl");
?>

1
info.svg Normal file
View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" enable-background="new 0 0 64 64"><path d="m32 2c-16.568 0-30 13.432-30 30s13.432 30 30 30 30-13.432 30-30-13.432-30-30-30m5 49.75h-10v-24h10v24m-5-29.5c-2.761 0-5-2.238-5-5s2.239-5 5-5c2.762 0 5 2.238 5 5s-2.238 5-5 5" fill="#dddddd"/></svg>

After

Width:  |  Height:  |  Size: 303 B

View File

@@ -22,7 +22,7 @@ $domain_global = "mlmmj";
$rc_webhook = "";
# No need to change this values
$current_version = "v1.1";
$current_version = "v1.2";
$headline = "Manage your ECG mailing lists " . $current_version;
$debug = false;

View File

@@ -36,6 +36,12 @@
There is an incorrect email in the moderators list.
{elseif $error_code == 11}
You do not own this list.
{elseif $error_code == 12}
The list does not exist within the mlmmj working folder.
{elseif $error_code == 13}
The list name exceeds the maximum length of 50 chars.
{elseif $error_code == 14}
The list name contains chars which are not allowed.
{else}
Unknown error.
{/if}

View File

@@ -58,13 +58,19 @@
</tr>
{foreach $lists as $list}
{if $list == 1}
{if $list.iamowner == 1}
<tr>
<td>
&check;
</td>
<td>
<a href="edit_list.php?list_name={$list@key}">{$list@key}</a>
<div class="tooltip">
<img src="info.svg" width=15 height=15>
<span class="help_add_list">
<strong>Description</strong><br />{$list.description}<br /><br /><strong>List owner(s)</strong><br />{foreach $list.owners as $owner}{$owner}<br />{/foreach}
</span>
</div>
</td>
</tr>
{/if}
@@ -94,18 +100,26 @@
</tr>
{foreach $lists as $list}
{if $list == 0}
{if $list.iamowner == 0}
<tr>
<td>
&cross;
</td>
<td>
{$list@key}
<div class="tooltip">
<img src="info.svg" width=15 height=15>
<span class="help_add_list">
<strong>Description</strong><br />{$list.description}<br /><br /><strong>List owner(s)</strong><br />{foreach $list.owners as $owner}{$owner}<br />{/foreach}
</span>
</div>
</td>
</tr>
{/if}
{/foreach}
</table>
<br />
<span>Loading time: {$loadingtime} seconds</span>
</div>
</body>
</html>

View File

@@ -19,6 +19,7 @@ function trim_array($arr)
$list_name = isset( $_POST["list_name"] ) ? $_POST["list_name"] : NULL;
$prefix = isset ( $_POST["prefix"] ) ? $_POST["prefix"] : NULL;
$listdescription = isset ( $_POST["listdescription"] ) ? $_POST["listdescription"] : NULL;
$new_subscribers = isset ( $_POST["subscribers"] ) ? $_POST["subscribers"] : NULL;
$moderators = isset ( $_POST["moderators"] ) ? $_POST["moderators"] : NULL;
@@ -31,23 +32,24 @@ if ( !isset($_SESSION["auth"]) || $_SESSION["auth"] != 1 )
$domain = $_SESSION["domain"];
// We do not print any error in the next four cases, because a legitimate
// user will never produce such results, even with disabled javascript
if ( preg_match("/[^a-z0-9_-]/", $list_name) )
{
$_SESSION["error_code"] = 14;
header("Location: error.php");
exit();
}
if ( strlen($list_name) > 30 )
if ( strlen($list_name) > 50 )
{
$_SESSION["error_code"] = 13;
header("Location: error.php");
exit();
}
// Test list existence
if( !is_dir("$lists_path/$domain/$list_name") )
if( !is_dir("$lists_path/$domain/$list_name") || $list_name == "" )
{
$_SESSION["error_code"] = 12;
header("Location: error.php");
exit();
}
@@ -158,11 +160,18 @@ if ($moderators !== NULL)
}
}
# Add prefix to the respective file
if ($prefix !== NULL)
{
file_put_contents("$lists_path/$domain/$list_name/control/prefix", "$prefix");
}
# Add listdescription to the respective file
if ($listdescription !== NULL)
{
file_put_contents("$lists_path/$domain/$list_name/control/listdescription", "$listdescription");
}
# The following code section is for audit log only
# -------------------------------------------------------------