<?php
/*
 * A advanced subscribe/unsubscibe form for mlmmj mailing list software
 * 2020 by leinelab members https://leinelab.org
 */
 
define('SMARTY_DIR', './libs/');
require_once(SMARTY_DIR . 'Smarty.class.php');

$smarty = new Smarty();
$smarty->setTemplateDir('./templates/');
$smarty->setCompileDir('./templates_c/');
$smarty->setConfigDir('./configs/');
$smarty->setCacheDir('./cache/');
$smarty->debugging = true;

// uses the value of $smarty->cacheLifetime() to determine
// the number of seconds a cache is good for
if (!$smarty->debugging) {
    $smarty->setCaching(Smarty::CACHING_LIFETIME_CURRENT);
}

// get informations from Server, Path and GET-Parameter
// eg. https://lists.leinelab.org/subscribe/listname?email=yourname@example.com

$smarty->assign('server', $_SERVER['SERVER_NAME']);

if ($_GET['email']) {
    $smarty->assign('email', $_GET['email']);    
}

// get listname 
if ($_GET['listname']) {
    $smarty->assign('listname', $_GET['listname']);    
} 

// get action
if ($_GET['action']) {
    $smarty->assign('action', $_GET['action']);    
} else {
    $smarty->assign('action', "subscribe");
}

$smarty->display('tpl-form.tpl');

?>