Example #1
0
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 * IN THE SOFTWARE.
 */
require dirname(dirname(__FILE__)) . "/conf/config.php";
require dirname(__FILE__) . "/class.rFastTemplate.php";
$tpl = new rFastTemplate($templatedir);
$tpl->define(array("main" => "index.html"));
$lists = "";
// get top directories (domains)
$domains = array_diff(scandir($topdir), array('..', '.'));
// get second level dirs (lists)
foreach ($domains as $domain) {
    // top-level domain dir
    $domaindir = $topdir . '/' . $domain;
    if (is_dir($domaindir)) {
        $lists .= "<h2>{$domain}</h2>\n<ul>";
        foreach (array_diff(scandir($domaindir), array('..', '.')) as $list) {
            $listurl = urlencode($domain . '/' . $list);
            $lists .= "\n\t<li><strong>" . htmlentities($list) . ':</strong>&nbsp;&nbsp;' . '<a href="edit.php?list=' . $listurl . '">config</a> - <a href="subscribers.php?list=' . $listurl . '">subscribers</a>' . "\n</li>";
        }
        $lists .= "\n</ul>";
    }
}
$tpl->assign(array("LISTS" => $lists));
$tpl->parse("MAIN", "main");
$tpl->FastPrint("MAIN");
}
$subscribers = "";
# get subscribers from mlmmj
$cmd = "/usr/bin/mlmmj-list -L " . escapeshellarg("{$topdir}/{$list}") . " 2>&1";
unset($out);
exec($cmd, $out, $ret);
if ($ret !== 0) {
    $message .= "* Error: Could not get subscribers list.\n";
} else {
    foreach ($out as $email) {
        $email = trim($email);
        $form = "<form action=\"subscribers.php?list=" . htmlspecialchars($list) . "\" method=\"post\" style=\"margin: 0; margin-left: 1em\">";
        $form .= "<input type=\"hidden\" name=\"email\" value=\"" . htmlspecialchars($email) . "\" />";
        $form .= "<input type=\"submit\" name=\"delete\" value=\"Remove\" />";
        $form .= "</form>";
        $subscribers .= "<tr><td>" . htmlspecialchars($email) . "</td><td>{$form}</td></tr>\n";
    }
    if ($subscribers === "") {
        $subscribers = "<tr><td>This list is empty.</td></tr>\n";
    }
}
# get subscribers count from mlmmj
$count = "/usr/bin/mlmmj-list -L " . escapeshellarg("{$topdir}/{$list}") . " -c 2>&1";
# set template vars
$tpl->define(array("main" => "subscribers.html"));
$tpl->assign(array("LIST" => htmlspecialchars($list)));
$tpl->assign(array("MESSAGE" => "<pre>" . htmlspecialchars($message) . "</pre>"));
$tpl->assign(array("SUBS" => $subscribers));
$tpl->assign(array("COUNT" => exec($count)));
$tpl->parse("MAIN", "main");
$tpl->FastPrint("MAIN");
Example #3
0
    if (is_file($file)) {
        $value = file_get_contents($file);
    }
    // the last \n would result in an extra empty line in the list box,
    // so we remove it
    $value = preg_replace('/\\n$/', "", $value);
    $tpl->assign(array("NAME" => htmlentities($name), "NICENAME" => htmlentities($nicename), "TEXT" => htmlentities($text), "VALUE" => htmlentities($value)));
    $tpl->parse("ROWS", ".list");
}
// Perl's encode_entities (to be able to use tunables.pl)
function encode_entities($str)
{
    return htmlentities($str);
}
$tpl = new rFastTemplate($templatedir);
$list = $_GET["list"];
if (!isset($list)) {
    die("no list specified");
}
if (dirname(dirname(realpath($topdir . "/" . $list))) != realpath($topdir)) {
    die("list outside topdir");
}
if (!is_dir($topdir . "/" . $list)) {
    die("non-existent list");
}
$tpl->define(array("main" => "edit.html", "boolean" => "edit_boolean.html", "string" => "edit_string.html", "list" => "edit_list.html"));
$tpl->assign(array("LIST" => htmlentities($list)));
$tunables = file_get_contents($confdir . '/tunables.pl');
eval($tunables);
$tpl->parse("MAIN", "main");
$tpl->FastPrint("MAIN");