Hello friends, here is a small class to encrypt the mails in the BDD with a key that you define.
I hope I have not forgotten anything, thanks for rewinding the info if it misses something or bugs in case
You are obligated to change your mail in your account once installed so that it is encrypted in the BDD as well as all members (and yes sorry we can not have the butter, the money of the butter and the... smile of the Crèmière lol)
BACKUP of your files before any changes
Create a class folder at the root of your site
In this folder create a file: Encryption. PHP and paste this code:
Open backend/config. php and add before the end:
Open account. php
Search:
Add below:
Search:
Open account. php
Search:
Add below:
Search:
Replace with:
Search:
Replace with
Open account-CE. php
Search:
Add under:
Search:
Add below:
Open account-Details. php
Search:
Add below:
Search:
Replace with:
Open account-Recover. php
Search:
Add under:
Search:
Replace with:
Search:
Replace with:
Open Account-Signup. php
Search:
Add below:
Search:
Replace with:
Search:
Replace with:
Search:
Replace with:
Open ADMINCP. php
(Be careful to search for mail it will take the full mail as it is encrypted... you know: butter...)
Search:
Add below:
Search:
Replace with:
Search:
Replace with:
Search:
Add under:
Search 2x:
(in manual record, prompt pending)
Replace with:
Search:
Replace with:
Search:
Replace with:
Search 2x
(Simple Etprivacite member search for levels)
Replace with:
Search:
Replace with:
Search:
Replace with:
Search:
Replace with:
Open admin-modtasks. php
Search:
Add below:
It's functional now:
I hope I have not forgotten anything, thanks for rewinding the info if it misses something or bugs in case
You are obligated to change your mail in your account once installed so that it is encrypted in the BDD as well as all members (and yes sorry we can not have the butter, the money of the butter and the... smile of the Crèmière lol)
BACKUP of your files before any changes
Create a class folder at the root of your site
In this folder create a file: Encryption. PHP and paste this code:
<?php
class Cryptage {
function encode($chaine, $clef) {
$encode = "";
$total = strlen($chaine);
$chaine = (string)$chaine;
$clefCompte = strlen($clef);
for ($i = 0, $j = 0; $i < $total; $i++) {
$char = ord($chaine[$i]);
$clefChar = is_numeric($clef[$j]) ? $clef[$j] : ord($clef[$j]);
$encodeChar = $char + $clefChar;
$encode .= chr($encodeChar);
$j++;
if ($j == $clefCompte) {
$j = 0;
}
}
return $encode;
}
function decode($chaine, $clef) {
$decode = "";
$total = strlen($chaine);
$chaine = (string)$chaine;
$clefCompte = strlen($clef);
for ($i = 0, $j = 0; $i < $total; $i++) {
$char = ord($chaine[$i]);
$clefChar = is_numeric($clef[$j]) ? $clef[$j] : ord($clef[$j]);
$decodeChar = $char - $clefChar;
$decode .= chr($decodeChar);
$j++;
if ($j == $clefCompte) {
$j = 0;
}
}
return $decode;
}
function b64encode($chaine, $clef) {
return base64_encode($this->encode($chaine, $clef));
}
function b64decode($chaine, $clef) {
return $this->decode(base64_decode($chaine), $clef);
}
}
Open backend/config. php and add before the end:
$site_config["clef"] = 'AHIJKLMNOPQRSTUVWXYZabcde,;:!§#)nopqrstuvwxyz0123456789+@=';Put the key of your choice it will avoid the same encryptions and not accentOpen account. php
Search:
loggedinonly();Add below:
require_once("class/cryptage.php");
$crypt = new Cryptage();
$clef = $site_config["clef"];
$mail = $crypt->b64decode($CURUSER["email"], $clef);Search:
value=\"" . htmlspecialchars($CURUSER["email"]) . "\"Open account. php
Search:
loggedinonly();Add below:
require_once("class/cryptage.php");
$crypt = new Cryptage();
$clef = $site_config["clef"];
$mail = $crypt->b64decode($CURUSER["email"], $clef);Search:
value=\"" . htmlspecialchars($CURUSER["email"]) . "\"Replace with:
value=\"" . $mail . "\"Search:
if ($email != $CURUSER["email"]) {Replace with
if ($email != $mail) {Open account-CE. php
Search:
$id = (int) $_GET["id"];
$md5 = $_GET["secret"];
$email = $_GET["email"];Add under:
require_once("class/cryptage.php");
$crypt = new Cryptage();
$clef = $site_config["clef"];Search:
if ($md5 != md5($sec . $email . $sec))
show_error_msg(T_("ERROR"), T_("NOTHING_FOUND"), 1);Add below:
$email = $crypt->b64encode($email, $clef);Open account-Details. php
Search:
$forumbanned = $user["forumbanned"] == 'yes';
$modcomment = htmlspecialchars($user["modcomment"]);Add below:
require_once("class/cryptage.php");
$crypt = new Cryptage();
$clef = $site_config["clef"];
$mail = $crypt->b64decode($user[email], $clef);Search:
name='email' value=\"$user[email]\"Replace with:
name='email' value=\"$mail\"Open account-Recover. php
Search:
dbconn();Add under:
require_once("class/cryptage.php");
$crypt = new Cryptage();
$clef = $site_config["clef"];Search:
$res = SQL_Query_exec("SELECT id, username, email FROM users WHERE email=" . sqlesc($email) . " LIMIT 1");Replace with:
$mail = $crypt->b64encode($email, $clef);
$res = SQL_Query_exec("SELECT id, username, email FROM users WHERE email=" . sqlesc($mail) . " LIMIT 1");Search:
$res2 = SQL_Query_exec("UPDATE `users` SET `secret` = ".sqlesc($sec)." WHERE `email`= ". sqlesc($email) ." LIMIT 1");Replace with:
$res2 = SQL_Query_exec("UPDATE `users` SET `secret` = ".sqlesc($sec)." WHERE `email`= ". sqlesc($mail) ." LIMIT 1");Open Account-Signup. php
Search:
dbconn();Add below:
require_once("class/cryptage.php");
$crypt = new Cryptage();
$clef = $site_config["clef"];Search:
$maildomain = (substr($email, strpos($email, "@") + 1));
$a = (@mysql_fetch_row(@SQL_Query_exec("select count(*) from email_bans where mail_domain='$email'")));Replace with:
$maildomain = (substr($email, strpos($email, "@") + 1));
$mail = $crypt->b64encode($email, $clef);
$maildomain = $crypt->b64encode($maildomain, $clef);
$a = (@mysql_fetch_row(@SQL_Query_exec("select count(*) from email_bans where mail_domain='$mail'")));Search:
// check if email addy is already in use
$a = (@mysql_fetch_row(@SQL_Query_exec("select count(*) from users where email='$email'")));Replace with:
// check if email addy is already in use
$a = (@mysql_fetch_row(@SQL_Query_exec("select count(*) from users where email='$mail'")));Search:
implode(",", array_map("sqlesc", array($wantusername, $wantpassword, $secret, $email, $status, get_date_time(), get_date_time(), $age, $country, $gender, $client, $site_config["default_theme"], $site_config["default_language"], $signupclass, getip()))).")");Replace with:
implode(",", array_map("sqlesc", array($wantusername, $wantpassword, $secret, $mail, $status, get_date_time(), get_date_time(), $age, $country, $gender, $client, $site_config["default_theme"], $site_config["default_language"], $signupclass, getip()))).")");Open ADMINCP. php
(Be careful to search for mail it will take the full mail as it is encrypted... you know: butter...)
Search:
require_once("backend/functions.php");
require_once("backend/bbcode.php");Add below:
require_once("class/cryptage.php");
$crypt = new Cryptage();
$clef = $site_config["clef"];Search:
$mail_domain= sqlesc($mail_domain);Replace with:
$mail = $crypt->b64encode($mail_domain, $clef);
$mail = sqlesc($mail);Search:
SQL_Query_exec("INSERT INTO email_bans (added, addedby, mail_domain, comment) VALUES($added, $CURUSER[id], $mail_domain, $comment)");
write_log(sprintf(T_("EMAIL_BANS_ADD"), $mail_domain, $CURUSER["username"]))Replace with:
SQL_Query_exec("INSERT INTO email_bans (added, addedby, mail_domain, comment) VALUES($added, $CURUSER[id], $mail, $comment)");
write_log(sprintf(T_("EMAIL_BANS_ADD"), sqlesc($mail_domain), $CURUSER["username"]));Search:
<!-- TorrentTable -->Add under:
<tr>
<td>Clef cryptage:</td>
<td><input type="text" name="" value="<?php echo $site_config["clef"]; ?>" size="80" /></td>
</tr>Search 2x:
(in manual record, prompt pending)
<?php while ($row = mysql_fetch_assoc($res)): ?>
<tr>
<td class="table_col1" align="center"><?php echo $row["username"]; ?></td>
<td class="table_col2" align="center"><?php echo $row["email"]; ?></td>Replace with:
<?php while ($row = mysql_fetch_assoc($res)):
$email = $crypt->b64decode($row["email"], $clef);
?>
<tr>
<td class="table_col1" align="center"><?php echo $row["username"]; ?></td>
<td class="table_col2" align="center"><?php echo $email; ?></td>Search:
<?php while ($row = mysql_fetch_assoc($res)): ?>
<tr>
<td class="table_col1" align="center"><a href="account-details.php?id=<?php echo $row["id"]; ?>"><?php echo $row["username"]; ?></a></td>
<td class="table_col2" align="center"><?php echo $row["email"]; ?></td>Replace with:
<?php while ($row = mysql_fetch_assoc($res)):
$email = $crypt->b64decode($row[email], $clef);
?>
<tr>
<td class="table_col1" align="center"><a href="account-details.php?id=<?php echo $row["id"]; ?>"><?php echo $row["username"]; ?></a></td>
<td class="table_col2" align="center"><?php echo $email; ?></td>Search:
if ( !empty( $_GET['search'] ) )
{
$search = sqlesc('%' . $_GET['search'] . '%');
$where = "AND username LIKE " . $search . " OR email LIKE " . $search . "
OR ip LIKE " . $search;
}Replace with:
if ( !empty( $_GET['search'] ) )
{
$email = $crypt->b64encode($_GET['search'], $clef);
$search = sqlesc('%' . $_GET['search'] . '%');
$email = sqlesc('%' . $email . '%');
$where = "AND username LIKE " . $search . " OR email LIKE " . $email . "
OR ip LIKE " . $search;
}Search 2x
(Simple Etprivacite member search for levels)
<?php while ($row = mysql_fetch_assoc($res)): ?>
<tr>
<td class="table_col1" align="center"><a href="account-details.php?id=<?php echo $row["id"]; ?>"><?php echo $row["username"]; ?></a></td>
<td class="table_col2" align="center"><?php echo get_user_class_name($row["class"]); ?></td>
<td class="table_col1" align="center"><?php echo $row["email"]; ?></tReplace with:
<?php while ($row = mysql_fetch_assoc($res)):
$email = $crypt->b64decode($row[email], $clef);
?>
<tr>
<td class="table_col1" align="center"><a href="account-details.php?id=<?php echo $row["id"]; ?>"><?php echo $row["username"]; ?></a></td>
<td class="table_col2" align="center"><?php echo get_user_class_name($row["class"]); ?></td>
<td class="table_col1" align="center"><?php echo $email; ?></td>Search:
// email
$emaila = explode(' ', trim($_GET['em']));
if ($emaila[0] !== "") {
$where_is .= isset($where_is)?" AND (":"(";
foreach($emaila as $email) {
if (strpos($email,'*') === False && strpos($email,'?') === False && strpos($email,'%') === False) {
if (!validemail($email)) {
show_error_msg(T_("ERROR"), "Bad email.");
}
$email_is .= (isset($email_is)?" OR ":"")."u.email =".sqlesc($email);
} else {
$sql_email = str_replace(array('?','*'), array('_','%'), $email);
$email_is .= (isset($email_is)?" OR ":"")."u.email LIKE ".sqlesc($sql_email);
}
}
$where_is .= $email_is.")";
$q .= ($q ? "&" : "") . "em=".urlencode(trim($_GET['em']));
}Replace with:
// email
$emaila = explode(' ', trim($_GET['em']));
if ($emaila[0] !== "") {
$where_is .= isset($where_is)?" AND (":"(";
foreach($emaila as $email) {
$mail = $email;
$email = $crypt->b64encode($email, $clef);
if (strpos($email,'*') === False && strpos($email,'?') === False && strpos($email,'%') === False) {
if (!validemail($mail)) {
show_error_msg(T_("ERROR"), "Bad email.");
}
$email_is .= (isset($email_is)?" OR ":"")."u.email =".sqlesc($email);
} else {
$sql_email = str_replace(array('?','*'), array('_','%'), $email);
$email_is .= (isset($email_is)?" OR ":"")."u.email LIKE ".sqlesc($sql_email);
}
}
$where_is .= $email_is.")";
$q .= ($q ? "&" : "") . "em=".urlencode(trim($_GET['em']));
}Search:
while ($user = mysql_fetch_array($res)) {
if ($user['added'] == '0000-00-00 00:00:00')Replace with:
while ($user = mysql_fetch_array($res)) {
$email = $crypt->b64decode($user[email], $clef);
if ($user['added'] == '0000-00-00 00:00:00')Search:
<td class='table_col2' align='center'>" . $ipstr . "</td><td class='table_col1' align='center'>" . $user['email'] . "</td>Replace with:
<td class='table_col2' align='center'>" . $ipstr . "</td><td class='table_col1' align='center'>" . $email . "</td>Open admin-modtasks. php
Search:
//continue updatesAdd below:
require_once("class/cryptage.php");
$crypt = new Cryptage();
$clef = $site_config["clef"];
$email = $crypt->b64encode($email, $clef);It's functional now:
#======================================================================#
# Mass Mail
#======================================================================#
if ($action == "massmail")
{
if ($do == "send")
{
//On instancie la classe cryptage
$crypt = new Cryptage();
$clef = $site_config["clef"];
@set_time_limit(0);
$subject = $_POST["subject"];
$body = format_comment($_POST["body"]);
if (!$subject || !$body) show_error_msg(T_('ERROR'), T_('MAIL_NO_SUBJECT_OR_BODY_SPECIFIED'), 1);
if (!@count($_POST["groups"])) show_error_msg(T_('ERROR'), T_('MAIL_NO_GROUPS_SELECTED'), 1);
$ids = array_map("intval", $_POST["groups"]);
$ids = implode(", ", $ids);
$res = SQL_Query_exec("SELECT u.email FROM users u LEFT JOIN groups g ON u.class = g.group_id WHERE u.enabled = 'yes' AND u.class IN ($ids)");
while ($row = mysqli_fetch_assoc($res))
{
//il faut décrypter le mail avant l'envoie
sendmail($crypt->b64decode($row["email"], $clef), $subject, $body, "Content-type: text/html; charset=utf-8", "-f$site_config[SITEEMAIL]");
}
show_error_msg(T_('MAIL_SUCCESS'), T_('MAIL_YOUR_MASS_EMAIL_HAS_BEEN_SENT'), 1);
}
$res = SQL_Query_exec("SELECT `group_id`, `level` FROM `groups` ORDER BY `group_id` ASC");
//block righ and left column
$site_config["MIDDLENAV"] = $site_config["RIGHTNAV"] = false; //Activate=true OR false
stdhead(T_("MAIL_MASS"));
navmenu();
if ($CURUSER["class"] < 9)
show_error_msg("Désolé", "Cette page est réservée au Co-Admin",1);
if("panel.php?action=massmail");
begin_frame(T_("MAIL_MASS"));
$dossier = $CURUSER['bbcode'];
?>
<script language="javascript">
<!--
function popupcentree(page,largeur,hauteur,options)
{
var top=(screen.height-hauteur)/2;
var left=(screen.width-largeur)/2;
window.open(page,"","top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options);
}
//-->
</script>
<center><?php echo T_('MAIL_MSG'); ?></center>
<br />
<form id="massmail" name="massmail" method="post" action="panel.php?action=massmail">
<input type="hidden" name="do" value="send" />
<table border="0" cellpadding="3" cellspacing="0" width="100%" align="center">
<tr>
<td align="center"><?php echo T_('MAIL_SUBJECT'); ?>: <input type="text" name="subject" size="40" /></td>
</tr>
<tr>
<td align="center"><b><?php echo T_('MAIL_FOR'); ?>:</b>
<?php while ($row = mysqli_fetch_assoc($res)): ?>
<input type="checkbox" name="groups[]" value="<?php echo $row["group_id"]; ?>" /> <?php echo $row["level"]; ?>
<?php endwhile; ?>
<input type="checkbox" name="checkall" onclick="checkAll(this.form.id)" /> <?php echo T_('MAIL_ALL_GROUPS'); ?>
</td>
</tr>
<tr>
<td align="center"><?php echo textbbcode("massmail","body",$dossier); ?></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="<?php echo T_("MAIL_TO_SEND"); ?>" />
<input type="reset" value="<?php echo T_("MAIL_RESET"); ?>" />
<!--<a href='javascript:popupcentree("previsualisation.html",900,800,"menubar=no,scrollbars=yes,statusbar=no")'><input type="button" value="<?php echo T_("PREVIEW"); ?>" /></a>-->
</td>
</tr>
</table>
</form>
<?php
end_frame();
navmenu();
stdfoot();
}
#======================================================================#
# End Mass Mail
#======================================================================#