1,102 → 1,28 |
<?php |
/* written by K@M3L & joss_p & Rexy */ |
# $Id: mail.php 2853 2020-07-19 21:50:07Z joss_p $ |
|
// partie $_POST du service mail |
$php_self = htmlspecialchars($_SERVER['PHP_SELF']); |
if(!empty($_POST)){ |
var_dump($_POST); |
// contient les options et les arguments au configurateur |
$optArg = ""; |
|
if(!empty($_POST['testConf'])){ |
$optArg .= " -".trim($_POST['testConf']); |
} |
if(!empty($_POST['smtp'])){ |
$optArg .= " -s \"".trim($_POST['smtp'])."\""; |
} |
if(!empty($_POST['port'])){ |
$optArg .= " -p \"".trim($_POST['port'])."\""; |
} |
if(!empty($_POST['smtpPort'])){ |
$smtpPort = explode(" ", $_POST['smtpPort']); |
$optArg .= " -s \"".trim($smtpPort[0])."\" -p \"".trim($smtpPort[1])."\""; |
} |
if(!empty($_POST['smtpIP'])){ |
$optArg .= " -r \"".trim($_POST['smtpIP'])."\""; |
} |
if(!empty($_POST['mailAddr'])){ |
$optArg .= " -m \"".trim($_POST['mailAddr'])."\""; |
} |
if(!empty($_POST['pswd1']) && !empty($_POST['pswd2'])){ |
if (trim($_POST['pswd1']) == trim($_POST['pswd2'])){ |
$optArg .= " -o \"".trim($_POST['pswd2'])."\""; |
} else { |
echo "<script> alert(\"Les deux mots de passe sont différents\"); window.location.href=\"services.php\";</script>"; |
} |
} |
if(!empty($_POST['adminMail'])){ |
$optArg .= " -a \"".$_POST['adminMail']."\""; |
} |
if(!empty($_POST['wld'])){ |
$optArg .= " -w \"".str_replace("\r"," ",trim($_POST['wld']))."\""; |
} |
/* written by Joss_p & Rexy */ |
/**************************************************************** |
* GLOBAL FILE PATHS * |
*****************************************************************/ |
define('CONF_FILE', '/usr/local/etc/alcasar-mail.conf'); |
|
// Supprimer la WLD ou l'email de l'admin |
if(!empty($_POST['unset'])){ |
exec("sudo sed -i '/". $_POST['unset']."/d' /usr/local/etc/alcasar-mail.conf", $output, $retval); |
|
var_dump($output); |
echo "<br>\$retval : " . $retval; |
/**************************************************************** |
* FILE reading test * |
*****************************************************************/ |
$conf_files = array(CONF_FILE); |
foreach ($conf_files as $file) { |
if (!file_exists($file)) { |
exit("Fichier $file non présent"); |
} |
|
// Supprimer toute la configuration actuelle |
if(!empty($_POST['uninstall'])){ |
// echo "sudo /usr/local/bin/alcasar-mail-uninstall.sh <br>"; |
exec("sudo /usr/local/bin/alcasar-mail-uninstall.sh", $output, $retval); |
|
var_dump($output); |
echo "<br>\$retval : " . $retval; |
if (!is_readable($file)) { |
exit("Vous n'avez pas les droits de lecture sur le fichier $file"); |
} |
|
if(!empty($optArg)){ |
echo "sudo /usr/local/bin/alcasar-mail-install.sh".$optArg; |
exec("sudo /usr/local/bin/alcasar-mail-install.sh".escapeshellcmd($optArg), $output, $retval); |
var_dump($output); |
echo "<br>\$retval : " . $retval; |
} |
// à décommenté une fois tests et debugs réalisé pour recharger la page sans le $_POST |
// header("Location:services.php"); |
|
}// Fin de la partie $_POST du service mail |
|
|
# Choice of language |
$Language = 'en'; |
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){ |
$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']); |
$Language = strtolower(substr(chop($Langue[0]),0,2)); } |
if($Language == 'fr') { |
$l_reboot = "Relancer le système"; |
} else if($Language == 'es') { |
$l_reboot = "Reiniciar el sistema"; |
} else { |
$l_reboot = "Restart the system"; |
} |
|
/**************************************************************** |
* CONST * |
* Read CONF_FILE * |
*****************************************************************/ |
define ("CONF_FILE", "/usr/local/etc/alcasar.conf"); |
|
/******************************************************** |
* CONF FILE test * |
*********************************************************/ |
if (!file_exists(CONF_FILE)){ |
exit("Fichier de configuration ".CONF_FILE." non présent"); |
} |
if (!is_readable(CONF_FILE)){ |
exit("Vous n'avez pas les droits de lecture sur le fichier ".CONF_FILE); |
} |
$file_conf = fopen(CONF_FILE, 'r'); |
if (!$file_conf) { |
exit('Error opening the file '.CONF_FILE); |
110,398 → 36,372 |
} |
fclose($file_conf); |
|
/**************** |
* MAIN * |
*****************/ |
/**************************************** |
* Choice of language * |
*****************************************/ |
$Language = 'en'; |
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { |
$Langue = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']); |
$Language = strtolower(substr(chop($Langue[0]), 0, 2)); |
} |
if ($Language === 'fr') { |
$l_mail_title = "Authentification externe : Adresse mail"; |
$l_mail_auth_enable_label = "Activer l'authentification par mail :"; |
$l_mail_YES = "OUI"; |
$l_mail_NO = "NON"; |
} else { |
$l_mail_title = "External authentication : Address mail"; |
$l_mail_auth_enable_label = "Enable email authentication :"; |
$l_mail_YES = "YES"; |
$l_mail_NO = "NO"; |
} |
|
?><!DOCTYPE HTML> |
<html> |
<head> |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
<title><?php echo $l_services_title; ?></title> |
<link rel="stylesheet" href="/css/acc.css" type="text/css"> |
<script type="text/javascript" src="/js/jquery.min.js"></script> |
</head> |
<body> |
<?php |
// Mail configuration params |
$mail_status = $conf['MAIL']; |
$mail_type = $conf['TYPE_MAIL']; |
$mail_address_mail = $conf['mailAddr']; |
$mail_smtp = $conf['smtp']; |
$mail_port = $conf['port']; |
$mail_address_ip = $conf['mailIP']; |
$mail_server = ""; |
$mail_password_mail = ""; |
$mail_password_mail_2 = ""; |
$admin_address = $conf['adminMail']; |
$mail_whitelist = $conf['whiteDomain']; |
|
echo <<<EOT |
|
<div class="panel"> |
<div class="panel-header">POSTFIX actuelle Configuration</div> |
<div class="panel-row"> |
<table width="100%" border=0 cellspacing=0 cellpadding=0><br> |
if(isset($_POST['submit'])){ |
if($_POST['auth_enable'] === '1') |
{ |
exec("systemctl start postfix"); |
|
EOT; |
$mail_status = $_POST['auth_enable']; |
$mail_type = $_POST['mail_type']; |
$mail_address = $_POST['mail_address']; |
$mail_ip = $_POST['mail_ip']; |
$mail_server = $_POST['mail_server']; |
$mail_mdp = $_POST['mail_mdp']; |
$mail_mdp2 = $_POST['mail_mdp2']; |
$admin_enable = $_POST['admin_enable']; |
$admin_address = $_POST['admin_address']; |
$mail_whitelist = $_POST['mail_whitelist']; |
|
// exec("cp /var/www/mail/header.php /var/www/html"); |
// exec("cp /var/www/mail/inscription.php /var/www/html"); |
// exec("cp /var/www/mail/inscription_traitement.php /var/www/html"); |
// exec("cp /var/www/html/acc/admin/services.php /var/www/html/acc/admin/services.php.origin"); |
// exec("cp /var/www/mail/services.php /var/www/html/acc/admin"); |
|
// la conf actuelle, si le fichier alcasar-mail.conf est présent |
$alcasarMailConf = "/usr/local/etc/alcasar-mail.conf"; |
if (is_file ($alcasarMailConf)){ |
|
$tab=file($alcasarMailConf); |
|
if ($tab){ |
foreach ($tab as $line) { |
|
$field=explode("=", $line); |
|
switch ($field[0]) { |
|
case 'smtp': |
$smtp = trim($field[1]); |
echo <<<EOT |
<tr align="center"> |
<td><b>SMTP : </b>$smtp</td> |
</tr> |
EOT; |
break; |
case 'port': |
$port = trim($field[1]); |
echo <<<EOT |
<tr align="center"> |
<td><b>Port : </b>$port</td> |
</tr> |
EOT; |
break; |
case 'smtpIP': |
$smtpIP = trim($field[1]); |
echo <<<EOT |
<tr align="center"> |
<td><b>SMTP ip : </b>$smtpIP</td> |
</tr> |
EOT; |
break; |
case 'mailAddr': |
$mailAddr = trim($field[1]); |
echo <<<EOT |
<tr align="center"> |
<td><b>Email Addr : </b>$mailAddr</td> |
</tr> |
EOT; |
break; |
case 'adminMail': |
$adminMail = trim($field[1]); |
echo <<<EOT |
<tr align="center"> |
<td><b>Admin email : </b>$adminMail</td> |
</tr> |
EOT; |
break; |
case 'whiteDomain': |
$whiteDomain = explode(" ", trim($field[1])); |
break; |
} |
if ($mail_mdp == $mail_mdp2) { |
switch ($mail_server) { |
case '1': |
$mail_smtp = "smtp.orange.fr"; |
$mail_port = 465; |
break; |
case '2': |
$mail_smtp = "smtp.live.com"; |
$mail_port = 587; |
break; |
case '3': |
$mail_smtp = "smtp.office365.com"; |
$mail_port = 587; |
break; |
case '4': |
$mail_smtp = "smtp.sfr.fr"; |
$mail_port = 465; |
break; |
case '5': |
$mail_smtp = "smtp.free.fr"; |
$mail_port = 465; |
break; |
case '6': |
$mail_smtp = "smtp.gmail.com"; |
$mail_port = 587; |
break; |
case '7': |
$mail_smtp = "smtp.laposte.net"; |
$mail_port = 465; |
break; |
case '8': |
$mail_smtp = "smtp.bbox.fr"; |
$mail_port = 587; |
break; |
default: |
echo "Erreur dans la saisie !"; |
break; |
} |
file_put_contents(CONF_FILE, str_replace('MAIL='.$conf['MAIL'],'MAIL='.$mail_status,file_get_contents(CONF_FILE))); |
file_put_contents(CONF_FILE, str_replace('TYPE_MAIL='.$conf['TYPE_MAIL'],'TYPE_MAIL='.$mail_type,file_get_contents(CONF_FILE))); |
file_put_contents(CONF_FILE, str_replace('mailAddr='.$conf['mailAddr'],'mailAddr='.$mail_address,file_get_contents(CONF_FILE))); |
file_put_contents(CONF_FILE, str_replace('mailIP='.$conf['mailIP'],'mailIP='.$mail_ip,file_get_contents(CONF_FILE))); |
file_put_contents(CONF_FILE, str_replace('smtp='.$conf['smtp'],'smtp='.$mail_smtp,file_get_contents(CONF_FILE))); |
file_put_contents(CONF_FILE, str_replace('port='.$conf['port'],'port='.$mail_port,file_get_contents(CONF_FILE))); |
file_put_contents(CONF_FILE, str_replace('whiteDomain='.$conf['mail_whitelist'],'whiteDomain='.$mail_whitelist,file_get_contents(CONF_FILE))); |
if (isset($admin_address)) { |
file_put_contents(CONF_FILE, str_replace('adminMail='.$conf['admin_address'],'adminMail='.$admin_address,file_get_contents(CONF_FILE))); |
} |
switch ($mail_type) { |
case '1': |
$mail_port = 25; |
file_put_contents(CONF_FILE, str_replace('port='.$conf['port'],'port='.$mail_port,file_get_contents(CONF_FILE))); |
if(isset($mail_admin)){ |
exec("sudo /usr/bin/bash /usr/local/bin/alcasar-mail-install-V2.sh -1 -a $admin_address -w $mail_whitelist"); |
} |
} |
echo <<<EOT |
<form action="$php_self" method="post"> |
<tr align="center"> |
<td colspan="2"> |
<input type="hidden" name="uninstall" value="uninstall"> |
<br><input type="submit" class="btn btn-default" name="submit" value="Supprimer toute la configuration"> |
</td> |
</tr> |
</form> |
<tr align="center"> |
<td colspan="2"><font color=red>ATTENTION : la suppression enlève toute la configuration du SERVICE MAIL</font> |
|
</td> |
</tr> |
EOT; |
// si le fichier alcasar-mail.conf n'existe pas |
} else { |
|
echo <<<EOT |
<tr align="center"> |
<td><b>POSTFIX n'est pas configuré par ALCASAR.</b></td> |
</tr> |
EOT; |
|
else { |
exec("sudo /usr/bin/bash /usr/local/bin/alcasar-mail-install-V2.sh -1 -w $mail_whitelist"); |
} |
break; |
case '2': |
if(isset($mail_admin)){ |
exec("sudo /usr/bin/bash /usr/local/bin/alcasar-mail-install-V2.sh -2 -s $mail_smtp -p $mail_port -r $mail_ip -a $admin_address -w $mail_whitelist"); |
} |
else { |
exec("sudo /usr/bin/bash /usr/local/bin/alcasar-mail-install-V2.sh -2 -s $mail_smtp -p $mail_port -r $mail_ip -w $mail_whitelist"); |
} |
break; |
case '3': |
if(isset($mail_admin)){ |
exec("sudo /usr/bin/bash /usr/local/bin/alcasar-mail-install-V2.sh -3 -s $mail_smtp -p $mail_port -m $mail_address -o $mail_mdp -a $admin_address -w $mail_whitelist"); |
} |
else { |
exec("sudo /usr/bin/bash /usr/local/bin/alcasar-mail-install-V2.sh -3 -s $mail_smtp -p $mail_port -m $mail_address -o $mail_mdp -w $mail_whitelist"); |
} |
break; |
default: |
echo "Erreur dans la saisie !"; |
break; |
} |
|
// Partie de paramétrage de la configuration |
|
// Configuration de l'adresse email de l'administrateur |
echo <<<EOT |
</table><br> |
</div> |
</div><br> |
<div class="panel"> |
<div class="panel-header">POSTFIX Configuration</div> |
<div class="panel-row conf" id="conf"> |
<table width="100%" border=0 cellspacing=0 cellpadding=0><br> |
<tr align="center"> |
<td><input type="radio" name="conf" class="mail" value="One"/><b>Service autonome</b></td> |
<td><input type="radio" name="conf" class="mail" value="Two"/><b>Service relay</b></td> |
<td><input type="radio" name="conf" class="mail" value="Three"/> <b>Adresse mail</b></td> |
</tr> |
</table><br> |
</div> |
<div class="myDiv hide" id="showOne"> |
<table width="100%" border=0 cellspacing=0 cellpadding=0><br> |
<tr align="center"> |
<td><b>Serveur mail est autonome :</b></td> |
</tr> |
<tr align="center"> |
<td> |
<form action="$php_self" method="post"> |
<input type="hidden" name="testConf" value="1"> |
<input type="submit" class="btn btn-default" name="submit" value="Configurer"><br> |
</form> |
</td> |
</tr> |
</table> |
</div> |
|
<div class="myDiv hide" id="showTwo"> |
<table width="100%" border=0 cellspacing=0 cellpadding=0><br> |
<form action="$php_self" method="post"> |
<tr align="center"> |
<td colspan="2"><b>SMTP Relais :</b></td> |
</tr> |
<tr align="center"> |
<td colspan="2">Postfix envois, ralaye les emails sorants à un autre serveur SMTP.</td> |
</tr> |
<tr> |
<td><label>Enterez le serveur SMTP relai en FQDN ou IP</label></td> |
<td><input type="text" name="smtp" placeholder="SMTP" required/></td> |
</tr> |
<tr> |
<td><label>Enterez le port SMTP</label></td> |
<td><input type="text" name="port" placeholder="port" required/></td> |
</tr> |
<tr> |
<td><label>Enterez l'IP du serveur SMTP relais (0.0.0.0/0 si c'est dynamique/par défaut si vide)</label></td> |
<td><input type="text" name="smtpIP" placeholder="IP du SMTP relais" required/></td> |
</tr> |
<tr align="center"> |
<td colspan="2"> |
<input type="hidden" name="testConf" value="2"> |
<input type="submit" class="btn btn-default" name="submit" value="Valider"><br> |
</td> |
</tr> |
</form> |
</table><br> |
</div> |
|
<div class="myDiv hide" id="showThree"> |
<table width="100%" border=0 cellspacing=0 cellpadding=0><br> |
<form method="post" action="$php_self"> |
<tr colspan="2" align="center"> |
<td><b>Configuration de serveur mail via un compte email :</b></td> |
</tr> |
<tr align="center"> |
<td> |
<table class="table table-striped"> |
<tr> |
<td><label>Entez votre email</label></td> |
<td><input type="email" name="mailAddr" placeholder="Enter your email" required/></td> |
</tr> |
<tr> |
<td><label>Entez le mot de passe</label></td> |
<td><input type="password" id="pswd1" name="pswd1" required/></td> |
</tr> |
<tr> |
<td><label>Confirmer le mot de passe</label></td> |
<td><input type="password" id="pswd2" name="pswd2" required/></td> |
</tr> |
|
</table> |
<table class="table table-striped"> |
<thead> |
<tr> |
<th scope="col">#</th> |
<th scope="col">compte de messagerie</th> |
<th scope="col">adresse de messagerie</th> |
<th scope="col">serveur sortant</th> |
<th scope="col">port sortant</th> |
</tr> |
</thead> |
<tbody> |
EOT; |
$smtpsConf = [ |
["Orange", "Orange/Wanadoo", "orange.fr /wanadoo.fr", "smtp.orange.fr", 465], |
["Hotmail", "Hotmail", "hotmail.com/.fr / live.com/.fr / msn.com", "smtp.live.com", 587], |
["Outlook", "Outlook", "hotmail.xx/live.xx/msn.com/outlook/office365", "smtp.office365.com", 587], |
["SFR", "SFR", "sfr.fr", "smtp.sfr.fr", 465], |
["Free", "Free", "free.fr", "smtp.free.fr", 465], |
["Gmail", "Gmail", "gmail.com", "smtp.gmail.com", 587], |
["Laposte", "Laposte", "laposte.net", "smtp.laposte.net", 465], |
["Bouygues", "Bouygues Telecom", "bbox.fr", "smtp.bbox.fr", 587] |
]; |
|
foreach( $smtpsConf as $smtpConf ) { |
echo <<< EOT |
<tr> |
<th scope="row"><input class="form-check-input blur" type="radio" name="smtpPort" value="$smtpConf[3] $smtpConf[4]"/></th> |
|
<td>$smtpConf[1]</td> |
<td>$smtpConf[2]</td> |
<td>$smtpConf[3]</td> |
<td align="center">$smtpConf[4]</td> |
</tr> |
EOT; |
} |
echo<<<EOT |
<tr> |
<th scope="row"><input id="perso" class="form-check-input" type="radio" name="smtpPort"/></th> |
<td>Personalisez votre smtp</td> |
<td><input type="text" id="smtpPerso" name="smtpPerso" class="perso" oninput="valPerso()" placeholder="Entrez le serveur SMTP" disabled/></td> |
<td>Personalisez le port</td> |
<td><input type="text" id="portPerso" name="portPerso" class="perso" oninput="valPerso()" placeholder="Entrez le serveur Port" disabled/></td> |
</tr> |
</tbody> |
</table> |
</td> |
</tr> |
<tr align="center"> |
<td class="testConf3"> |
</td> |
</tr> |
<tr align="center"> |
<td> |
<input type="hidden" name="testConf" value="3"> |
<input type="submit" class="btn btn-default" name="submit" value="Valider" id="testConf3"><br> |
</td> |
</tr> |
</form> |
</table><br> |
</div> |
</div><br> |
<div class="panel"> |
<div class="panel-header">Mail admin</div> |
<div class="panel-row conf" id="conf"> |
<table width="100%" border=0 cellspacing=0 cellpadding=0><br> |
<form action="$php_self" method="post"> |
<tr align="center"> |
<td colspan="2"><b>Mail admin</b></td> |
</tr> |
<tr align="center"> |
<td colspan="2">L'adresse email de l'administrateur pour recevoir les alertes des nouvelles inscriptions, et l'archive hebdomadaire des logs</td> |
</tr> |
<tr> |
EOT; |
if (empty($adminMail)){ |
echo "<td><label>Enterez l'adresse email</label></td>"; |
} else { |
echo "<td>L'email configuré actuellement est : " . $adminMail . "</td>"; |
} |
echo <<<EOT |
<td><input type="email" name="adminMail" placeholder="Enter your email" required/></td> |
</tr> |
|
<tr align="center"> |
<td colspan="2"> |
<input type="submit" class="btn btn-default" name="submit" value="Valider"><br> |
</td> |
</tr> |
</form> |
<form action="$php_self" method="post"> |
<tr align="center"> |
<td colspan="2"> |
<input type="hidden" name="unset" value="adminMail"> |
<input type="submit" class="btn btn-default" name="submit" value="Supprimer l'admin email"><br> |
</td> |
</tr> |
</form> |
</table><br> |
</div> |
</div><br> |
<div class="panel"> |
<div class="panel-header">WhiteList Domains Configuration</div> |
<div class="panel-row conf" id="conf"> |
<table width="100%" border=0 cellspacing=0 cellpadding=0><br> |
<tr align="center"> |
<td>La liste blanche limite les inscriptions utilisateurs à un, ou plusieurs domaines.</td> |
</tr> |
<form method="post" action="$php_self"> |
<tr align="center"> |
<td width="50%" align="center">Mettez vos domaines à configurer. Un par ligne</td> |
</tr> |
<tr align="center"> |
<td> |
<br><textarea name='wld' rows=5 cols=50 placeholder="Aucune WLD configurée actuellement""> |
EOT; |
if(!empty($whiteDomain)){ |
foreach ($whiteDomain as $domain){ |
echo "$domain\n"; |
} |
else { |
echo "Erreur"; |
} |
} |
else { |
exec("cp -f /etc/postfix/main.cf.origin /etc/postfix/main.cf"); |
exec("rm -rf /etc/postfix/sasl/"); |
exec("cp -f /var/www/mail/alcasar-mail.conf /usr/local/etc/"); |
exec("systemctl restart postfix"); |
exec("systemctl stop postfix"); |
exec("sed -i '/SMTP_IP=/ s/^/#/g' /usr/local/etc/alcasar-iptables-local.sh"); |
exec("sed -i '/SMTP_PORT=/ s/^/#/g' /usr/local/etc/alcasar-iptables-local.sh"); |
exec("rm -f /var/www/html/header.php"); |
exec("rm -f /var/www/html/inscription.php"); |
exec("rm -f /var/www/html/inscription_traitement.php"); |
exec("cp -f /var/www/html/acc/admin/services.php.origin /var/www/html/acc/admin/services.php"); |
exec("sudo /usr/bin/bash /usr/local/bin/alcasar-iptables.sh"); |
} |
header("Refresh:0"); |
exit; |
} |
echo<<<EOT |
</textarea> |
</td> |
</tr> |
<tr align="center"> |
<td colspan="2"> |
<br><input type="submit" class="btn btn-default" name="submit" value="Valider"><br> |
</td> |
</tr> |
</form> |
<form action="$php_self" method="post"> |
<tr align="center"> |
<td colspan="2"> |
<input type="hidden" name="unset" value="whiteDomain"> |
<input type="submit" class="btn btn-default" name="submit" value="Supprimer la WLD"><br> |
</td> |
</tr> |
</form> |
</table><br> |
</div> |
</div><br> |
|
EOT; |
|
?> |
|
<script> |
$(document).ready(function(){ |
$("div.hide").hide(); |
|
$('#conf input[type="radio"]').click(function(){ |
var value = $(this).val(); |
$("div.myDiv").hide(); |
$("#show"+value).show(); |
}); |
|
//On vérifie si le mot de passe est ok |
$("#pswd2").keyup(function(){ |
if($("#pswd1").val() != "" && $("#pswd2").val() != "" && $("#pswd1").val() != $("#pswd2").val()){ |
$(".testConf3").html("<br>Les deux mots de passe sont différents"); |
$("#testConf3").attr("disabled", true); |
} else { |
$("#testConf3").attr("disabled", false); |
$(".testConf3").fadeOut(800); |
<!DOCTYPE html> |
<html> |
<head> |
<meta charset="UTF-8"> |
<title><?= $l_mail_title ?></title> |
<link type="text/css" href="/css/acc.css" rel="stylesheet"> |
<link type="text/css" href="/css/mail.css" rel="stylesheet"> |
<script> |
function onMailStatusChange() { |
var listToDisables1 = ['mail_type','admin_enable','admin_address','mail_whitelist']; |
var listToDisables2 = ['mail_server','mail_type','admin_enable','admin_address','mail_whitelist','mail_ip']; |
var listToDisables3 = ['mail_server','mail_mdp2','mail_mdp','mail_address','mail_type','admin_enable','admin_address','mail_whitelist']; |
var formSubmit = document.querySelector('form input[type="submit"]'); |
var btn_checkConf = document.getElementById('btn-checkconf'); |
var isChecked = false; |
if (document.getElementById('auth_enable').value === '1') { |
for (var i=0; i<listToDisables1.length; i++) { |
document.getElementById(listToDisables1[i]).style.backgroundColor = '#c0c0c0'; |
document.getElementById(listToDisables1[i]).disabled = true; |
} |
}) |
}); |
|
$('#perso').click(function(){ |
|
$(".perso").attr("disabled", false); |
}); |
|
$('.blur').click(function(){ |
|
$(".perso").attr("disabled", true); |
}); |
|
function valPerso(){ |
var valSmtpPerso = document.getElementById("smtpPerso").value; |
var valPortPerso = document.getElementById("portPerso").value; |
document.getElementById("perso").value = valSmtpPerso + " " + valPortPerso; |
}; |
|
function hideShow(x){ |
$("div." + x).toggle(); |
var value = $("input." + x).val(); |
var elem = document.getElementById("btn-" + x); |
if (elem.value=="Configurer"){ |
elem.value = "Annuler"; |
} else{ |
elem.value = "Configurer"; |
for (var i=0; i<listToDisables2.length; i++) { |
document.getElementById(listToDisables2[i]).style.backgroundColor = '#c0c0c0'; |
document.getElementById(listToDisables2[i]).disabled = true; |
} |
for (var i=0; i<listToDisables3.length; i++) { |
document.getElementById(listToDisables3[i]).style.backgroundColor = '#c0c0c0'; |
document.getElementById(listToDisables3[i]).disabled = true; |
} |
document.getElementById('mail_type').style.backgroundColor = null; |
document.getElementById('mail_type').disabled = false; |
if (document.getElementById('mail_type').value === '1') { |
for (var i=0; i<listToDisables1.length; i++) { |
document.getElementById(listToDisables1[i]).style.backgroundColor = null; |
document.getElementById(listToDisables1[i]).disabled = false; |
} |
if (document.getElementById('admin_enable').value === '0') { |
document.getElementById('admin_address').style.backgroundColor = '#c0c0c0'; |
document.getElementById('admin_address').disabled = true; |
} |
} |
else if (document.getElementById('mail_type').value === '2') { |
for (var i=0; i<listToDisables2.length; i++) { |
document.getElementById(listToDisables2[i]).style.backgroundColor = null; |
document.getElementById(listToDisables2[i]).disabled = false; |
} |
if (document.getElementById('admin_enable').value === '0') { |
document.getElementById('admin_address').style.backgroundColor = '#c0c0c0'; |
document.getElementById('admin_address').disabled = true; |
} |
} |
else if (document.getElementById('mail_type').value === '3') { |
for (var i=0; i<listToDisables3.length; i++) { |
document.getElementById(listToDisables3[i]).style.backgroundColor = null; |
document.getElementById(listToDisables3[i]).disabled = false; |
} |
if (document.getElementById('admin_enable').value === '0') { |
document.getElementById('admin_address').style.backgroundColor = '#c0c0c0'; |
document.getElementById('admin_address').disabled = true; |
} |
} |
formSubmit.style.display = null; |
btn_checkConf.style.display = 'none'; |
} else { |
for (var i=0; i<listToDisables1.length; i++) { |
document.getElementById(listToDisables1[i]).style.backgroundColor = '#c0c0c0'; |
document.getElementById(listToDisables1[i]).disabled = true; |
} |
for (var i=0; i<listToDisables2.length; i++) { |
document.getElementById(listToDisables2[i]).style.backgroundColor = '#c0c0c0'; |
document.getElementById(listToDisables2[i]).disabled = true; |
} |
for (var i=0; i<listToDisables3.length; i++) { |
document.getElementById(listToDisables3[i]).style.backgroundColor = '#c0c0c0'; |
document.getElementById(listToDisables3[i]).disabled = true; |
} |
formSubmit.style.display = null; |
btn_checkConf.style.display = 'none'; |
} |
}; |
|
</script> |
} |
</script> |
</head> |
<body onLoad="onMailStatusChange();"> |
<div class="panel"> |
<div class="panel-header"><?= "Authentication Mail" ?></div> |
<div class="panel-body"> |
<form id="form-config_mail" name="config_mail" method="POST" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" enctype="multipart/form-data"> |
<fieldset> |
<legend> |
<br> |
<div style="text-align: center"> |
</div> |
</legend> |
<dl> |
<dt> |
<label for="auth_enable"><?= "Activer l'authentification par mail :" ?></label> |
</dt> |
<dd> |
<select id="auth_enable" name="auth_enable" onchange="onMailStatusChange();"> |
<option value="1"<?= ($mail_status) ? ' selected="selected"' : '' ?>><?= $l_mail_YES ?></option> |
<option value="0"<?= (!$mail_status) ? ' selected="selected"' : '' ?>><?= $l_mail_NO ?></option> |
</select> |
</dd> |
</dl> |
<dl> |
<dt> |
<label for="mail_type"><?= "Type Messagerie" ?></label><br> |
<?= "Choississez le type de messagerie a utiliser" ?><br> |
</dt> |
<dd> |
<select id="mail_type" name="mail_type" onchange="onMailStatusChange();"> |
<option value=1>Nom de domaine</option> |
<option value=2>Serveur mail ou serveur SMTP</option> |
<option value=3>Adresse de messagerie</option> |
</select> |
</dd> |
</dl> |
<dl> |
<dt> |
<label for="mail_address"><?= "Adresse Messagerie"?></label><br> |
<?= "Adresse de messagerie utilisé pour l'envoi" ?> |
</dt> |
<dd> |
<input type="text" id="mail_address" size="40" name="mail_address" value="<?= $mail_address_mail ?>" oninput="onMailStatusChange();"> |
</dd> |
</dl> |
<dl> |
<dt> |
<label for="mail_mdp"><?= "Mot de passe Messagerie"?></label><br> |
<?= "Mot de passe de la messagerie utilisé pour l'envoi" ?> |
</dt> |
<dd> |
<input type="text" id="mail_mdp" size="40" name="mail_mdp" value="<?= $mail_password_mail ?>" oninput="onMailStatusChange();"> |
</dd> |
</dl> |
<dl> |
<dt> |
<label for="mail_mdp2"><?= "Confirmer Mot de passe Messagerie"?></label><br> |
<?= "Confirmer le mot de passe de la messagerie utilisé pour l'envoi" ?> |
</dt> |
<dd> |
<input type="text" id="mail_mdp2" size="40" name="mail_mdp2" value="<?= $mail_password_mail_2 ?>" oninput="onMailStatusChange();"> |
</dd> |
</dl> |
<dl> |
<dt> |
<label for="mail_server"><?= "CHoix Serveur SMTP" ?></label><br> |
<?= "Choissisiez le serveur SMTP correspondant à l'adress de messagerie" ?><br> |
</dt> |
<dd> |
<select id="mail_server" name="mail_server" onchange="onMailStatusChange();"> |
<option value=1>Orange/Wanadoo</option> |
<option value=2>Hotmail</option> |
<option value=3>Outlook</option> |
<option value=4>SFR</option> |
<option value=5>Free</option> |
<option value=6>Gmail</option> |
<option value=7>Laposte</option> |
<option value=8>Bouygues</option> |
<option value=9>Personnalisé</option> |
</select> |
</dd> |
</dl> |
<dl> |
<dt> |
<label for="mail_ip"><?= "IP du serveur SMTP"?></label><br> |
<?= "Adresse IP du serveur SMTP utilisé" ?> |
</dt> |
<dd> |
<input type="text" id="mail_ip" size="40" name="mail_ip" value="<?= $mail_address_ip ?>" oninput="onMailStatusChange();"> |
</dd> |
</dl> |
<dl> |
<dt> |
<label for="admin_enable"><?= "Activer l'adresse admin :" ?></label> |
</dt> |
<dd> |
<select id="admin_enable" name="admin_enable" onchange="onMailStatusChange();"> |
<option value="1"<?= ($mail_status) ? ' selected="selected"' : '' ?>><?= $l_mail_YES ?></option> |
<option value="0"<?= (!$mail_status) ? ' selected="selected"' : '' ?>><?= $l_mail_NO ?></option> |
</select> |
</dd> |
</dl> |
<dl> |
<dt> |
<label for="admin_address"><?= "Adresse Messagerie admin"?></label><br> |
<?= "Adresse de messagerie utilisé pour l'envoi" ?> |
</dt> |
<dd> |
<input type="text" id="admin_address" size="40" name="admin_address" value="<?= $admin_address ?>" oninput="onMailStatusChange();"> |
</dd> |
</dl> |
<dl> |
<dt> |
<label for="mail_whitelist"><?= "whitelist domaine"?></label><br> |
<?= "Adresse de messagerie utilisé pour l'envoi" ?> |
</dt> |
<dd> |
<input type="text" id="mail_whitelist" size="40" name="mail_whitelist" value="<?= $mail_whitelist ?>" oninput="onMailStatusChange();"> |
</dd> |
</dl> |
<p> |
<!--<button id="btn-checkconf" onclick="checkConfig(); return false;"><?= $l_check ?></button>--> |
<input id="submit" type="submit" value="<?= $l_mail_submit ?>" name="submit"> |
</p> |
</fieldset> |
</form> |
</div> |
</div> |
</body> |
</html> |