It will then ask you for a password for the given username.
-6) That is it, you are ready to use the interface.
+6) Use 2 extra configs to limit per list the people who can access the php admin itf and/or who can manage the subscribers
+ To limit who can access the php admin interface per list, create for the list in question the control file admin_users
+ and put in it the userids of the people allowed to manage just that list (one per line)
+ To limit who can manage subscribers per list, create for the list in question the control file subsadmin_users
+ and put in it the userids of the people allowed to manage subscribers just that list (one per line)
+ If subsadmin_users does not exist and admin_users exists, the content of that file will be used.
+
+7) That is it, you are ready to use the interface.
// Description
// Constructor.
//
- function rFastTemplate ($pathToTemplates = '') {
+ //function rFastTemplate ($pathToTemplates = '') {
+ public function __construct ($pathToTemplates = '') {
// $pathToTemplates can also be an array of template roots, handled in set_root
global $php_errormsg;
$this->ROOT[] = $root;
} else {
reset($root);
- while(list($k, $v) = each($root)) {
+ foreach ($root as $k=>$v) {
if (is_dir($v)) {
$trailer = substr ($v,-1);
if ($trailer != ($this->WIN32 ? '\\' : '/'))
//
function define ($fileList, $dynamic = 0) {
reset ($fileList);
- while (list ($tpl, $file) = each ($fileList)) {
+ foreach ($fileList as $tpl=>$file) {
$this->TEMPLATE[$tpl] = array ('file' => $file, 'dynamic' => $dynamic);
}
return true;
function define_dynamic ($tplList, $parent='') {
if (is_array($tplList)) {
reset ($tplList);
- while (list ($tpl, $parent) = each ($tplList)) {
+ foreach ($tplList as $tpl=>$parent) {
$this->TEMPLATE[$tpl]['parent'] = $parent;
$this->TEMPLATE[$tpl]['dynamic'] = true;
}
//
function define_raw ($stringList, $dynamic = 0) {
reset ($stringList);
- while (list ($tpl, $string) = each ($stringList)) {
+ foreach ($stringList as $tpl=>$string) {
$this->TEMPLATE[$tpl] = array ('string' => $string, 'dynamic' => $dynamic, 'loaded' => 1);
}
return true;
// search path for a matching file
reset($this->ROOT);
- while(list($k, $v) = each($this->ROOT)) {
+ foreach ($this->ROOT as $k=>$v) {
$f = $v . $file;
if (file_exists($f)) {
return $f;
// whitespace. If so, we delete the entire line.
$okay = false;
for ($offbeg = $pos - 1; $offbeg >= 0; $offbeg--) {
- $c = $rest{$offbeg};
+ $c = $rest[$offbeg];
if ($c == "\n") {
$okay = true;
$offbeg++;
} else {
$l = strlen ($rest);
for ($offend = $pos + strlen($dynbeg[1]); $offend < $l; $offend++) {
- $c = $rest{$offend};
+ $c = $rest[$offend];
if ($c == "\n") {
$offend++;
break;
// only whitespace. If so, we delete the entire line.
$okay = false;
for ($offbeg = $pos - 1; $offbeg >= 0; $offbeg--) {
- $c = $rest{$offbeg};
+ $c = $rest[$offbeg];
if ($c == "\n") {
$offbeg++;
$okay = true;
} else {
$l = strlen ($rest);
for ($offend = $pos + strlen($dynend[1]); $offend < $l; $offend++) {
- $c = $rest{$offend};
+ $c = $rest[$offend];
if ($c == "\n") {
$offend++;
break;
// Because we treat VAR and HANDLE separately (unlike
// class.FastTemplate.php3), we have to iterate over both or we
// miss some substitutions and are not 100% compatible.
- while (list($key,$val) = each ($this->VAR)) {
+ foreach ($this->VAR as $key=>$val) {
if ($debug)
$this->logwrite ("subst: substituting VAR $key = $val in $tag");
$key = '{'.$key.'}';
$tmp = str_replace ($key, $val, $tmp);
}
reset ($this->HANDLE);
- while (list($key,$val) = each ($this->HANDLE)) {
+ foreach ($this->HANDLE as $key=>$val) {
if ($debug)
$this->logwrite ("subst: substituting HANDLE $key = $val in $tag");
$key = '{'.$key.'}';
function setkey ($tplkey, $rest = '') {
if (gettype ($tplkey) == 'array') {
reset ($tplkey);
- while (list($key,$val) = each ($tplkey)) {
+ foreach ($tplkey as $key=>$val) {
if (!empty($key)) {
$this->VAR[$key] = $val;
}
function append ($tplkey, $rest = '') {
if (gettype ($tplkey) == 'array') {
reset ($tplkey);
- while (list($key,$val) = each ($tplkey)) {
+ foreach ($tplkey as $key=>$val) {
if (!empty($key)) {
$this->VAR[$key] .= $val;
}
<?php
/* mlmmj/php-admin:
+ * Copyright (C) 2023 Franky Van Liedekerke <franky at e-dynamics dot be>
* Copyright (C) 2004 Christoph Thiel <ct at kki dot org>
*
* mlmmj/php-perl:
$tpl->assign(array("NAME" => htmlentities($name),
"NICENAME" => htmlentities($nicename),
- "TEXT" => htmlentities($text)));
+ "TEXT" => nl2br(htmlentities($text))));
$tpl->assign(array("CHECKED" => $checked ? " checked" : ""));
$tpl->parse("ROWS",".boolean");
$tpl->assign(array("NAME" => htmlentities($name),
"NICENAME" => htmlentities($nicename),
- "TEXT" => htmlentities($text),
+ "TEXT" => nl2br(htmlentities($text)),
"VALUE" => htmlentities($value)));
$tpl->parse("ROWS",".string");
$tpl->assign(array("NAME" => htmlentities($name),
"NICENAME" => htmlentities($nicename),
- "TEXT" => htmlentities($text),
+ "TEXT" => nl2br(htmlentities($text)),
"VALUE" => htmlentities($value)));
$tpl->parse("ROWS",".list");
$tpl = new rFastTemplate($templatedir);
-$list = $_GET["list"];
-
-if(!isset($list))
-die("no list specified");
+if(empty($_GET['list']))
+ die("no list specified");
+$list = $_GET['list'];
if (dirname(realpath($topdir."/".$list)) != realpath($topdir))
die("list outside topdir");
if(!is_dir($topdir."/".$list))
die("non-existent list");
+$userfile = "$topdir/$list/control/admin_users";
+if (is_file($userfile)) {
+ // read users into array
+ $admin_users = array_map('trim',file($userfile));
+ // remove empty values from array
+ $admin_users = array_filter($admin_users);
+ if (!isset($_SERVER['PHP_AUTH_USER']) || !in_array($_SERVER['PHP_AUTH_USER'],$admin_users)) {
+ header("WWW-Authenticate: " .
+ "Basic realm=\"Mlmmj Protected Area\"");
+ header("HTTP/1.0 401 Unauthorized");
+ //Show failure text, which browsers usually
+ //show only after several failed attempts
+ print("This page is protected by HTTP " .
+ "Authentication.<br>\n");
+ exit;
+ }
+}
+
$tpl->define(array("main" => "edit.html",
"boolean" => "edit_boolean.html",
"string" => "edit_string.html",
<?php
/* mlmmj/php-admin:
+ * Copyright (C) 2023 Franky Van Liedekerke <franky at e-dynamics dot be>
* Copyright (C) 2004 Christoph Thiel <ct at kki dot org>
*
* mlmmj/php-perl:
$lists = "";
# use scandir to have alphabetical order
-foreach (scandir($topdir) as $file) {
- if (!ereg("^\.",$file))
- {
- $lists .= "<p>".htmlentities($file)."<br/>\n";
- $lists .= "<a href=\"edit.php?list=".urlencode($file)."\">Config</a> - <a href=\"subscribers.php?list=".urlencode($file)."\">Subscribers</a>\n";
- $lists .= "</p>\n";
+foreach (scandir($topdir) as $mlmmj_list) {
+ if (substr($mlmmj_list,0,1) != '.' && file_exists("$topdir/$mlmmj_list/control")) {
+ $admin_userfile = "$topdir/$mlmmj_list/control/admin_users";
+ $subs_userfile = "$topdir/$mlmmj_list/control/subsadmin_users";
+ if (!is_file($subs_userfile)) {
+ $subs_userfile = "$topdir/$mlmmj_list/control/admin_users";
+ }
+
+ if (isset($_SERVER['PHP_AUTH_USER']) && is_file($admin_userfile)) {
+ // read users into array
+ $admin_users = array_map('trim',file($admin_userfile));
+ // remove empty values from array
+ $admin_users = array_filter($admin_users);
+ if (in_array($_SERVER['PHP_AUTH_USER'],$admin_users)) {
+ $print_config=1;
+ } else {
+ $print_config=0;
+ }
+ } else {
+ $print_config=1;
+ }
+ if (isset($_SERVER['PHP_AUTH_USER']) && is_file($subs_userfile)) {
+ // read users into array
+ $subs_users = array_map('trim',file($subs_userfile));
+ // remove empty values from array
+ $subs_users = array_filter($subs_users);
+ if (in_array($_SERVER['PHP_AUTH_USER'],$subs_users)) {
+ $print_sub=1;
+ } else {
+ $print_sub=0;
+ }
+ } else {
+ $print_sub=1;
+ }
+
+ if ($print_config || $print_sub) {
+ $lists .= "<p>".htmlentities($mlmmj_list)."<br/>\n";
+
+ if ($print_config) {
+ $lists .= "<a href=\"edit.php?list=".urlencode($mlmmj_list)."\">Config</a> - ";
+ $lists .= "<a href=\"texts.php?list=".urlencode($mlmmj_list)."\">Text files</a>";
+ }
+ if ($print_config && $print_sub)
+ $lists .= " - ";
+ if ($print_sub)
+ $lists .= "<a href=\"subscribers.php?list=".urlencode($mlmmj_list)."\">Subscribers</a>\n";
+
+ if ($print_config)
+ $lists .= " - <a href=\"logs.php?list=".urlencode($mlmmj_list)."\">Log</a>";
+
+ $lists .= "</p>\n";
+ }
}
}
<?php
/* mlmmj/php-admin:
+ * Copyright (C) 2023 Franky Van Liedekerke <franky at e-dynamics dot be>
* Copyright (C) 2004 Christoph Thiel <ct at kki dot org>
*
* mlmmj/php-perl:
{
if(!touch($file))
die("Couldn't open ".$file." for writing");
- if (!chmod($file, 0644))
- die("Couldn't chmod ".$file);
+ //if (!chmod($file, 0644))
+ // die("Couldn't chmod ".$file);
+ // don't error on chmod, if the owner of the file is different it won't work
+ @chmod($file, 0664);
}
else {
if (file_exists($file)) {
fwrite($fp, $_POST[$name]);
fclose($fp);
- if (!chmod($file, 0644))
- die("Couldn't chmod ".$file);
+ //if (!chmod($file, 0644))
+ // die("Couldn't chmod ".$file);
+ // don't error on chmod, if the owner of the file is different it won't work
+ @chmod($file, 0664);
}
else {
if (file_exists($file)) {
$tpl = new rFastTemplate($templatedir);
-$list = $_POST["list"];
-
-if(!isset($list))
-die("no list specified");
+if(empty($_POST['list']))
+ die("no list specified");
+$list = $_POST['list'];
if (dirname(realpath($topdir."/".$list)) != realpath($topdir))
die("list outside topdir");
if(!is_dir($topdir."/".$list))
die("non-existent list");
+$userfile = "$topdir/$list/control/admin_users";
+$admin_user = "";
+if(is_file($userfile)) {
+ // read users into array
+ $admin_users = array_map('trim',file($userfile));
+ // remove empty values from array
+ $admin_users = array_filter($admin_users);
+ if (!isset($_SERVER['PHP_AUTH_USER']) || !in_array($_SERVER['PHP_AUTH_USER'],$admin_users)) {
+ header("WWW-Authenticate: " .
+ "Basic realm=\"Mlmmj Protected Area\"");
+ header("HTTP/1.0 401 Unauthorized");
+ //Show failure text, which browsers usually
+ //show only after several failed attempts
+ print("This page is protected by HTTP " .
+ "Authentication.<br>\n");
+ exit;
+ }
+}
+
$tpl->define(array("main" => "save.html"));
$tpl->assign(array("LIST" => htmlentities($list)));
<?php
-/* Copyright (C) 2012 Marc MAURICE <marc-mlmmj at pub dot positon dot org>
+/* mlmmj/php-admin:
+ * Copyright (C) 2023 Franky Van Liedekerke <franky at e-dynamics dot be>
+ * Copyright (C) 2004 Christoph Thiel <ct at kki dot org>
+ *
+ * mlmmj/php-perl:
+ * Copyright (C) 2004 Morten K. Poulsen <morten at afdelingp.dk>
+ * Copyright (C) 2004 Christian Laursen <christian@pil.dk>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
$tpl = new rFastTemplate($templatedir);
# get the list parameter and check that list exists
-$list = $_GET["list"];
-
-if(!isset($list))
-die("no list specified");
+if(empty($_GET['list']))
+ die("no list specified");
+$list = $_GET['list'];
if (dirname(realpath($topdir."/".$list)) != realpath($topdir))
die("list outside topdir");
if(!is_dir($topdir."/".$list))
die("non-existent list");
-# this will be displayed on the top of the page
+$userfile = "$topdir/$list/control/subsadmin_users";
+if (!is_file($userfile)) {
+ $userfile = "$topdir/$list/control/admin_users";
+}
+$admin_user = "";
+if (is_file($userfile)) {
+ // read users into array
+ $admin_users = array_map('trim',file($userfile));
+ // remove empty values from array
+ $admin_users = array_filter($admin_users);
+ if (!isset($_SERVER['PHP_AUTH_USER']) || !in_array($_SERVER['PHP_AUTH_USER'],$admin_users)) {
+ header("WWW-Authenticate: " .
+ "Basic realm=\"Mlmmj Protected Area\"");
+ header("HTTP/1.0 401 Unauthorized");
+ //Show failure text, which browsers usually
+ //show only after several failed attempts
+ print("This page is protected by HTTP " .
+ "Authentication.<br>\n");
+ exit;
+ }
+}
+
$message = "";
# subscribe some people if tosubscribe is set
$email = trim($line);
if ($email != "") {
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
- $cmd = "/usr/bin/mlmmj-sub -L ".escapeshellarg("$topdir/$list")." -a ".escapeshellarg($email)." 2>&1";
+ $cmd = "/usr/bin/mlmmj-sub -f -q -s -L ".escapeshellarg("$topdir/$list")." -a ".escapeshellarg($email)." 2>&1";
unset($out);
exec($cmd, $out, $ret);
if ($ret !== 0) {
$email = $_POST["email"];
if (! filter_var($email, FILTER_VALIDATE_EMAIL)) die("Email address not valid");
- $cmd = "/usr/bin/mlmmj-unsub -L ".escapeshellarg("$topdir/$list")." -a ".escapeshellarg($email)." 2>&1";
+ $cmd = "/usr/bin/mlmmj-unsub -q -s -L ".escapeshellarg("$topdir/$list")." -a ".escapeshellarg($email)." 2>&1";
unset($out);
exec($cmd, $out, $ret);
if ($ret !== 0) {
$subscribers="";
# get subscribers from mlmmj
-$cmd = "/usr/bin/mlmmj-list -L ".escapeshellarg("$topdir/$list")." 2>&1";
+$cmd = "/usr/bin/mlmmj-list -L ".escapeshellarg("$topdir/$list")." |sort";
unset($out);
exec($cmd, $out, $ret);
if ($ret !== 0) {
$subscribers.= "<tr><td>".htmlspecialchars($email)."</td><td>$form</td></tr>\n";
}
- if ($subscribers === "") {
- $subscribers = "<tr><td>This list is empty.</td></tr>\n";
+ if (empty($subscribers)) {
+ $subscribers = "<tr><td>This list is empty or the permissions are not set correctly to get the subscribers.</td></tr>\n";
}
}