'._("Debug enabled") .'
';
echo print_r($_REQUEST);
echo '';
}
if (!defined('DOMAIN') || !defined('DATA') || !defined('DEBUG') || !defined('FICHIERALIAS') || !defined('DB')) {
echo '
'._("Error : the configuration file conf.php might not be included because the constants are not declared").'.
';
// check writable work directory
} else if (!is_writable(DATA)) {
echo ''._("Error : the working directory cannot be written. Please contact the admin").'
';
// check alias file is_writable
} else if (!is_writable(FICHIERALIAS)) {
echo ''._("Error : the alias file cannot be written. Please contact the admin").'
';
// check blacklist file is_writable
} else if (defined('BLACKLIST') && !is_readable(BLACKLIST)) {
echo ''._("Error : the blacklist file cannot be read. Please contact the admin").'
';
// check aliasdeny file is_writable
} else if (defined('ALIASDENY') && !is_readable(ALIASDENY)) {
echo ''._("Error : the forbidden aliases file cannot be read. Please contact the admin").'
';
// maintenance mod
} else if (MAINTENANCE_MODE == true && MAINTENANCE_IP != $_SERVER["REMOTE_ADDR"]) {
echo ''._("Service under maintenance").'
';
} else {
if (MAINTENANCE_MODE == true) {
echo ''._("Service under maintenance").'
';
}
// Connect DB
try {
if (preg_match('/^sqlite/', DB)) {
$dbco = new PDO(DB);
} else {
$dbco = new PDO(DB, DBUSER, DBPASS);
}
$dbco->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch ( PDOException $e ) {
die('._("Connexion à la base ").'.$e->getMessage());
}
// Create DB if not exists
try {
// status : 0=not verified - 3=disable - 5=active
if (preg_match('/^sqlite/', DB)) {
$create = $dbco->query("CREATE TABLE IF NOT EXISTS ".DBTABLEPREFIX."alias (
id INTEGER PRIMARY KEY,
status INTEGER(1) NOT NULL,
alias CHAR(150) NOT NULL UNIQUE,
email CHAR(150) NOT NULL,
dateCreat DATETIME NOT NULL,
dateExpir DATETIME,
comment TEXT);");
} else {
$create = $dbco->query("CREATE TABLE IF NOT EXISTS ".DBTABLEPREFIX."alias (
id INTEGER PRIMARY KEY AUTO_INCREMENT,
status INTEGER(1) NOT NULL,
alias CHAR(150) NOT NULL UNIQUE,
email CHAR(150) NOT NULL,
dateCreat DATETIME NOT NULL,
dateExpir DATETIME,
comment TEXT);");
}
} catch ( PDOException $e ) {
echo ''._("Error initializing tables. Please contact the admin");
if (DEBUG) { $e->getMessage(); }
echo '
';
die();
}
//////////////////
// Start program
//////////////////
// get process "act" (action)
$action = isset($_GET['act']) ? $_GET['act'] : '';
switch ($action) {
case "validemail" :
$get_value = urlUnGen($_GET['value']);
if ($dbco->query("SELECT COUNT(*) FROM ".DBTABLEPREFIX."alias WHERE id = '".$get_value['id']."' AND status = 0")->fetchColumn() != 0) {
UpdateStatusAlias($get_value['id'], $get_value['alias_full'], 5);
echo ''._("Your trash email address").' '.$get_value['alias_full'].' '._("is now enabled").'
';
} else {
echo ''._("Error : unknown ID or already validated").'
';
}
break;
case "disable" :
$get_value = urlUnGen($_GET['value']);
DisableAlias($get_value['id'], $get_value['alias_full'], null);
break;
case "enable" :
$get_value = urlUnGen($_GET['value']);
EnableAlias($get_value['id'], $get_value['alias_full'], null);
break;
case "delete" :
$get_value = urlUnGen($_GET['value']);
DeleteAlias($get_value['id'], $get_value['alias_full']);
break;
case "cron" :
if (CRON) {
echo ''._("The scheduled task is running").'
';
LifeExpire();
} else {
echo ''._("You didn't allow the scheduled job").'
';
}
break;
}
// Form
if (isset($_POST['username']) && $_POST['username'] != '') { // minimal anti-spam
echo 'Hello you';
} else if (isset($_POST['list'])) {
$email=strtolower(StripCleanToHtml($_POST['email']));
if (! filter_var($email, FILTER_VALIDATE_EMAIL)) {
echo ''._("Error : email address incorrect").'
';
} else if (! VerifMXemail($email)) {
echo ''._("Error : email address incorrect").' (2)
';
} else if (ListeAlias($email)) {
echo ''._("An email has been sent to you").'
';
} else {
echo ''._("Error : no known active trash email").'
';
}
} else if (isset($_POST['email']) && isset($_POST['alias'])) {
$alias=strtolower(StripCleanToHtml($_POST['alias']));
$email=strtolower(StripCleanToHtml($_POST['email']));
$domain=StripCleanToHtml($_POST['domain']);
$life=$_POST['life'];
$comment=StripCleanToHtml($_POST['comment']);
$alias_full=$alias.'@'.$domain;
// Check form
if (! filter_var($email, FILTER_VALIDATE_EMAIL)) {
echo ''._("Error : email address incorrect").'
';
} else if (! VerifMXemail($email)) {
echo ''._("Error : email address incorrect").' (2)
';
} else if (! preg_match('#^[\w.-]+$#',$alias)) {
echo ''._("Error : trash email address syntax incorrect").'
';
} else if (!domainePresent($domain)) {
echo ''._("Error : this domain cannot be used").'
';
} else if (emailIsAlias($email)) {
echo ''._("Error : Your email can not contain a trash domain").'
';
} else if (AliasDeny($alias)) {
echo ''._("Error : trash email address forbidden").'
';
} else if (BlacklistEmail($email)) {
echo ''._("Error : you have been blacklisted").'
';
// add
} elseif (isset($_POST['add'])) {
if ($dbco->query("SELECT COUNT(*) FROM ".DBTABLEPREFIX."alias WHERE alias = '".$alias_full."'")->fetchColumn() != 0) {
echo ''._("Error : this trash email already exists").'
';
} else if ($dbco->query("SELECT COUNT(*) FROM ".DBTABLEPREFIX."alias WHERE email = '".$email."'")->fetchColumn() > ALIASLIMITBYMAIL) {
echo ''._("Error: You have reached your limit quota on this app. You can
install this script on a personal server if you want more quota").'.
';
} else {
if ($dbco->query("SELECT COUNT(*) FROM ".DBTABLEPREFIX."alias WHERE email = '".$email."' AND status > 0")->fetchColumn() != 0) {
AjouterAlias(5, $alias_full, $email, $life, $comment);
echo ''._("Your trash email address").' '.$alias_full.' > '.$email.' '._("is now enabled").'
';
} else {
$lastId=AjouterAlias(0, $alias_full, $email, $life, $comment);
$message= _("Confirmation of the creation of your trash email :")."\n";
$message= $alias_full.' => '.$email."\n";
$message= _("Click on the link below to validate :")."\n";
$message.= "\t * ".urlGen('validemail',$lastId,$alias_full)."\n";
$message.= "\n";
$message.= _("To delete this trash email, click on the link below :")."\n";
$message.= "\t * ".urlGen('delete',$lastId,$alias_full)."\n";
$message.= "\n";
$message.= _("After confirmation, you will be able to temporary suspend you trash email using the link below :")."\n";
$message.= "\t * ".urlGen('disable',$lastId,$alias_full)."\n";
SendEmail($email,_("Alias confirmation")." ".$alias,$message);
echo ''._("Your email address").' ('.$email.') '._("is unknown, a confirmation has been sent to you.").'
';
}
}
// delete
} else if (isset($_POST['del'])) {
if ($id = $dbco->query("SELECT id FROM ".DBTABLEPREFIX."alias WHERE email = '".$email."' AND alias = '".$alias_full."'")->fetchColumn()) {
$message= _("Confirmation of the removal of your trash email : ")."\n";
$message= $alias_full.' => '.$email."\n";
$message= _("Click on the link below to validate the deletion :")."\n";
$message.= "\t * ".urlGen('delete',$id,$alias_full)."\n\n";
$message.= _("If you would like to temporary suspend this trash email, you can follow the link bellow :")."\n";
$message.= "\t * ".urlGen('disable',$id,$alias_full)."\n";
SendEmail($email,_("Alias deletion")." ".$alias,$message);
echo ''._("An email has been sent to you").'.
';
} else {
echo ''._("Error : unknown trash email").'
';
}
// disable
} else if (isset($_POST['disable'])) {
DisableAlias(null, $alias_full, $email);
// enable
} else if (isset($_POST['enable'])) {
EnableAlias(null, $alias_full, $email);
}
// memory email
if (isset($_POST['memory'])) {
setcookie ("email", StripCleanToHtml($email), time() + 31536000);
} else if (isset($_COOKIE['email'])) {
unset($_COOKIE['email']);
}
}
//////////////////
// Printing form
//////////////////
?>
= VERSION ?> -
emailPoubelle.php