#5 v1.4 Interface admin avec stats, top user, possibilité de nettoyer, blacklister...
This commit is contained in:
parent
52c627bc3f
commit
1b25026ed2
|
@ -6,3 +6,4 @@ conf.php
|
|||
test*
|
||||
var/database*
|
||||
var/.htaccess
|
||||
devToProd.sh
|
||||
|
|
15
CHANGELOG.md
15
CHANGELOG.md
|
@ -1,11 +1,16 @@
|
|||
## 1.1 (future)
|
||||
## 2 (future)
|
||||
|
||||
- support postfix-mysql (not plain text virtual file)
|
||||
- admin panel page with statistic
|
||||
- limit nb alias / email
|
||||
- javascript checkupgrade in admin page
|
||||
- add second table in database (for domain/checkupdate/intervale cron)
|
||||
- send email for advertisement action ?
|
||||
|
||||
## 1.4 (2018-03-19)
|
||||
|
||||
- Interface admin avec stats, top user, possibilité de nettoyer, blacklister...
|
||||
|
||||
## 1.2 (2018-03-19)
|
||||
|
||||
- Ne pas permettre la création d'un alias depuis un alias
|
||||
- Limiter le nombre d'alias possible
|
||||
|
||||
## 1.0.1 (2014-01-06)
|
||||
|
||||
|
|
|
@ -87,4 +87,13 @@ define('MAINTENANCE_MODE', false);
|
|||
// No maintenance for this ip (admin ip)
|
||||
define('MAINTENANCE_IP', '10.0.0.1');
|
||||
|
||||
|
||||
// Usage de password-hash https://php.net/manual/fr/function.password-hash.php
|
||||
// Vous pouvez crtyper le mot de passe en ligne avec les outils :
|
||||
// http://www.passwordtool.hu/php5-password-hash-generator
|
||||
// https://php-password-hash-online-tool.herokuapp.com/password_hash (PASSWORD_DEFAULT, no auto-generated, no cost 10)
|
||||
// Mot de passe par défaut "admin" :
|
||||
define('ADMIN_PASSWORD', '$2y$10$BncfiLy8VEYtkLVIlL5Ar.TVPY9Q3KbllJrdHNuSU5WCRnKafWM5K');
|
||||
|
||||
|
||||
?>
|
||||
|
|
|
@ -10,16 +10,11 @@
|
|||
// Depend : Postifx (postmap command) php-pdo
|
||||
//-----------------------------------------------------------
|
||||
|
||||
// @todo
|
||||
// form ergonomie
|
||||
// sqlite
|
||||
// disable time
|
||||
|
||||
//////////////////
|
||||
// Init & check
|
||||
//////////////////
|
||||
|
||||
define('VERSION', '1.0');
|
||||
define('VERSION', '1.4');
|
||||
|
||||
if (DEBUG) {
|
||||
error_reporting(E_ALL);
|
||||
|
|
|
@ -0,0 +1,173 @@
|
|||
<?php
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Title : Email Poubelle
|
||||
// Licence : GNU GPL v3 : http://www.gnu.org/licenses/gpl.html
|
||||
// Author : David Mercereau - david [aro] mercereau [.] info
|
||||
// Home : http://poubelle.zici.fr
|
||||
// Date : 08/2013
|
||||
// Version : 1.0
|
||||
// Depend : Postifx (postmap command) php-pdo
|
||||
//-----------------------------------------------------------
|
||||
|
||||
session_start();
|
||||
|
||||
$auth=false;
|
||||
if (isset($_POST['adminPassword'])) {
|
||||
$_SESSION['adminPasswordHash'] = password_hash($_POST['adminPassword'], PASSWORD_DEFAULT);
|
||||
}
|
||||
if (isset($_SESSION['adminPasswordHash'])) {
|
||||
if (password_verify('admin', $_SESSION['adminPasswordHash'])) {
|
||||
$auth=true;
|
||||
} else {
|
||||
$auth=false;
|
||||
}
|
||||
}
|
||||
if (isset($_POST['adminPassword']) && $auth==false) {
|
||||
echo '<div class="highlight-1">Erreur : Mot de passe incorrect</div>';
|
||||
}
|
||||
if (empty($_SESSION['adminPasswordHash']) || $auth == false) {
|
||||
echo '<form action="#" method="post">
|
||||
<label>Le mot de passe admin : </label>
|
||||
<input type="password" name="adminPassword" />
|
||||
<input type="submit" />
|
||||
</form>';
|
||||
}
|
||||
|
||||
// Test connexion, si c'est ok :
|
||||
if ($auth==true) {
|
||||
// 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());
|
||||
}
|
||||
if (isset($_POST['action'])) {
|
||||
if ($_POST['action'] == 'DeleteEmail' && isset($_POST['email'])) {
|
||||
DeleteEmail($_POST['email']);
|
||||
}
|
||||
if ($_POST['action'] == 'AddBlacklistEmail' && isset($_POST['email'])) {
|
||||
AddBlacklistEmail($_POST['email']);
|
||||
}
|
||||
if ($_POST['action'] == 'DeleteAlias' && isset($_POST['id']) && isset($_POST['alias'])) {
|
||||
DeleteAlias($_POST['id'], $_POST['alias']);
|
||||
}
|
||||
if ($_POST['action'] == 'DisableAlias' && isset($_POST['id']) && isset($_POST['alias'])) {
|
||||
DisableAlias($_POST['id'], $_POST['alias'], $_POST['email']);
|
||||
}
|
||||
}
|
||||
?>
|
||||
<script>
|
||||
function confirmation(idForm, idAction, action) {
|
||||
if (confirm(action + " : êtes-vous sûr ?")) {
|
||||
document.getElementById(idAction).value = action;
|
||||
document.getElementById(idForm).submit();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<?php
|
||||
echo '<p>Statistique : </p>';
|
||||
echo '<ul>';
|
||||
echo '<li>Total alias : '.$dbco->query("SELECT COUNT(*) FROM ".DBTABLEPREFIX."alias")->fetchColumn().'</li>';
|
||||
echo '<li>Alias actif : '.$dbco->query("SELECT COUNT(*) FROM ".DBTABLEPREFIX."alias WHERE status = 5")->fetchColumn().'</li>';
|
||||
echo '<li>Alias suspendu : '.$dbco->query("SELECT COUNT(*) FROM ".DBTABLEPREFIX."alias WHERE status = 3")->fetchColumn().'</li>';
|
||||
echo '<li>Alias non vérifié : '.$dbco->query("SELECT COUNT(*) FROM ".DBTABLEPREFIX."alias WHERE status = 0")->fetchColumn().'</li>';
|
||||
//echo '<li>Email différent : '.$dbco->query("SELECT DISTINCT count(email) FROM ".DBTABLEPREFIX."alias WHERE status = 5")->fetchColumn().'</li>';
|
||||
echo '</ul>';
|
||||
|
||||
echo '<h3 id="user">User info</h3>';
|
||||
echo '<form action="#" method="post">
|
||||
<label>Indiquer l\'email de l\'utilisateur : </label>
|
||||
<input type="text" value="'.$_POST['email'].'" name="email" />
|
||||
<input type="submit" />
|
||||
</form>';
|
||||
if (isset($_POST['email'])) {
|
||||
$requestUtilisateur = $dbco->query("SELECT * FROM ".DBTABLEPREFIX."alias WHERE email='".$_POST['email']."' ORDER BY dateCreat DESC")->fetchAll() ;
|
||||
echo '<p>Utilisateur '.$_POST['email'].' : ';
|
||||
if (count($requestUtilisateur) != 0) {
|
||||
echo '<img onclick="confirmation(\'uniqemail_'.$_POST['email'].'\', \'uniqaction_'.$_POST['email'].'\', \'DeleteEmail\')" src="'.URLINC.'/sup.png" alt="sup" />';
|
||||
if (!BlacklistEmail($_POST['email'])) {
|
||||
echo '<img onclick="confirmation(\'uniqemail_'.$_POST['email'].'\', \'uniqaction_'.$_POST['email'].'\', \'AddBlacklistEmail\')" src="'.URLINC.'/blk.png" alt="blk" />';
|
||||
}
|
||||
} else {
|
||||
echo 'N\'existe pas !';
|
||||
}
|
||||
echo '<form style="display: none" method="post" action="#" id="uniqemail_'.$_POST['email'].'">
|
||||
<input type="hidden" name="email" value="'.$_POST['email'].'" />
|
||||
<input type="hidden" id="uniqaction_'.$_POST['email'].'" name="action" value="" />
|
||||
</form>';
|
||||
echo '</p>';
|
||||
if (count($requestUtilisateur) != 0) {
|
||||
echo '<table>';
|
||||
echo '<tr>
|
||||
<th>Status</th>
|
||||
<th>Alias</th>
|
||||
<th>DateCreat</th>
|
||||
<th>DateExpir</th>
|
||||
<th>Comment</th>
|
||||
</tr>';
|
||||
foreach ($requestUtilisateur as $utilisateur) {
|
||||
echo '<tr>
|
||||
<td><img src="'.URLINC.'/status'.$utilisateur['status'].'.png" alt="'.$utilisateur['status'].'" /></td>
|
||||
<td>'.$utilisateur['alias'].'
|
||||
<br /><form style="display: none" method="post" action="#" id="alias'.$utilisateur['id'].'">
|
||||
<input type="hidden" name="id" value="'.$utilisateur['id'].'" />
|
||||
<input type="hidden" name="alias" value="'.$utilisateur['alias'].'" />
|
||||
<input type="hidden" name="email" value="'.$_POST['email'].'" />
|
||||
<input type="hidden" id="action'.$utilisateur['id'].'" name="action" value="" />
|
||||
</form>
|
||||
<img onclick="confirmation(\'alias'.$utilisateur['id'].'\', \'action'.$utilisateur['id'].'\', \'DeleteAlias\')" src="'.URLINC.'/sup.png" alt="sup" />';
|
||||
if ($utilisateur['status'] == 5) {
|
||||
echo '<img onclick="confirmation(\'alias'.$utilisateur['id'].'\', \'action'.$utilisateur['id'].'\', \'DisableAlias\')" src="'.URLINC.'/status3.png" alt="Suspendre" />';
|
||||
}
|
||||
echo '</td>
|
||||
<td>'.$utilisateur['dateCreat'].'</td>
|
||||
<td>'.$utilisateur['dateExpir'].'</td>
|
||||
<td>'.$utilisateur['comment'].'</td>
|
||||
</tr>';
|
||||
}
|
||||
echo '</table>';
|
||||
}
|
||||
}
|
||||
|
||||
echo '<h3 id="top">Top user </h3>';
|
||||
$recordActifs = $dbco->query("SELECT email, count(alias) calias FROM ".DBTABLEPREFIX."alias WHERE status=5 GROUP BY email ORDER BY calias DESC LIMIT 40")->fetchAll();
|
||||
echo '<table>';
|
||||
echo '<tr>
|
||||
<th>Email</th>
|
||||
<th style="text-align: center">Nombre d\'alias</th>
|
||||
<th style="text-align: center">Action</th>
|
||||
</tr>';
|
||||
foreach ($recordActifs as $recordActif) {
|
||||
echo '<tr>
|
||||
<td>';
|
||||
if (BlacklistEmail($recordActif['email'])) {
|
||||
echo '<img src="'.URLINC.'/blk.png" alt="blk" /> ';
|
||||
}
|
||||
echo $recordActif['email'].'</td>
|
||||
<td style="text-align: center">'.$recordActif['calias'].'</td>
|
||||
<td style="text-align: center">
|
||||
<form style="display: none" method="post" action="#" id="email_'.$recordActif['email'].'">
|
||||
<input type="hidden" name="email" value="'.$recordActif['email'].'" />
|
||||
<input type="hidden" id="action_'.$recordActif['email'].'" name="action" value="" />
|
||||
</form>
|
||||
<img onclick="confirmation(\'email_'.$recordActif['email'].'\', \'action_'.$recordActif['email'].'\', \'DeleteEmail\')" src="'.URLINC.'/sup.png" alt="sup" />';
|
||||
if (!BlacklistEmail($recordActif['email'])) {
|
||||
echo '<img onclick="confirmation(\'email_'.$recordActif['email'].'\', \'action_'.$recordActif['email'].'\', \'AddBlacklistEmail\')" src="'.URLINC.'/blk.png" alt="blk" />';
|
||||
}
|
||||
echo '
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
echo '</table>';
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
Binary file not shown.
After Width: | Height: | Size: 944 B |
|
@ -4,6 +4,9 @@
|
|||
// Function
|
||||
//////////////////
|
||||
|
||||
// Status explication :
|
||||
// 0=not verified - 3=disable - 5=active
|
||||
|
||||
// Verification des emails
|
||||
function VerifMXemail($email) {
|
||||
if (CHECKMX) {
|
||||
|
@ -78,6 +81,32 @@ function AjouterAlias($status, $alias,$email, $life, $comment) {
|
|||
return $dbco->lastInsertId();
|
||||
}
|
||||
|
||||
// delete email
|
||||
function DeleteEmail($email) {
|
||||
global $dbco;
|
||||
if ($dbco->query("SELECT COUNT(*) FROM ".DBTABLEPREFIX."alias WHERE email = '".$email."'")->fetchColumn() != 0) {
|
||||
try {
|
||||
$deletecmd = $dbco->prepare("DELETE FROM ".DBTABLEPREFIX."alias WHERE email = :email");
|
||||
$deletecmd->bindParam('email', $email, PDO::PARAM_STR);
|
||||
$deletecmd->execute();
|
||||
echo '<div class="highlight-3">l\'email <b>'.$email.'</b> a bien été supprimé avec tout ces alias.</div>';
|
||||
} catch ( PDOException $e ) {
|
||||
echo "DB error : ", $e->getMessage();
|
||||
die();
|
||||
}
|
||||
} else {
|
||||
echo '<div class="highlight-1">Erreur : email <b>'.$email.'</b> n\'a pas été supprimé.</div>';
|
||||
}
|
||||
UpdateVirtualDB();
|
||||
}
|
||||
|
||||
function AddBlacklistEmail($email) {
|
||||
$contenu = '/^'.$email.'$/';
|
||||
$fichier = fopen(BLACKLIST, 'a');
|
||||
fwrite($fichier, $contenu."\n");
|
||||
fclose($fichier);
|
||||
echo '<div class="highlight-3">La mention '.$contenu.' a été ajouté au fichier de blackliste '.BLACKLIST.'</div>';
|
||||
}
|
||||
// delete alias
|
||||
function DeleteAlias($id, $alias_full) {
|
||||
global $dbco;
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 360 B |
Binary file not shown.
After Width: | Height: | Size: 358 B |
Binary file not shown.
After Width: | Height: | Size: 355 B |
Binary file not shown.
After Width: | Height: | Size: 311 B |
Loading…
Reference in New Issue