New: Reset invalid email script

This commit is contained in:
lmarcouiller 2020-11-12 17:22:33 +01:00
parent 7272f64177
commit e9d837c02d

View File

@ -23,7 +23,7 @@
*/ */
if (!defined('NOSESSION')) define('NOSESSION', '1'); if (!defined('NOSESSION')) define('NOSESSION', '1');
if (!defined('MAXEMAILS')) define('MAXEMAILS',100); if (!defined('MAXEMAILS')) define('MAXEMAILS', 100);
$sapi_type = php_sapi_name(); $sapi_type = php_sapi_name();
$script_file = basename(__FILE__); $script_file = basename(__FILE__);
@ -68,27 +68,27 @@ if (!empty($login))
$db->begin(); $db->begin();
$myfile = fopen($id,"r") or die("Unable to open file\n"); $myfile = fopen($id, "r") or die("Unable to open file\n");
$groupofemails=array(); $groupofemails=array();
for ($i=0; $i < MAXEMAILS; $i++) for ($i=0; $i < MAXEMAILS; $i++)
{ {
$tmp =fgets($myfile); $tmp =fgets($myfile);
if($tmp == null) if ($tmp == null)
{ {
break; break;
} }
$groupofemails[$i] = trim($tmp,"\n"); $groupofemails[$i] = trim($tmp, "\n");
} }
// For each groupofemail, we update tables to set email field to empty // For each groupofemail, we update tables to set email field to empty
$sql_base = "UPDATE ".MAIN_DB_PREFIX; $sql_base = "UPDATE ".MAIN_DB_PREFIX;
foreach($groupofemails as $email) foreach ($groupofemails as $email)
{ {
if ($type == 'all' || $type == 'thirdparty') if ($type == 'all' || $type == 'thirdparty')
{ {
// Loop on each record and update the email to null if email into $groupofemails // Loop on each record and update the email to null if email into $groupofemails
$sql=$sql_base."societe as s SET s.email = NULL WHERE s.email = '".$email."';"; $sql=$sql_base."societe as s SET s.email = NULL WHERE s.email = '".$email."';";
$db->query($sql); $db->query($sql);
} }
@ -99,7 +99,6 @@ foreach($groupofemails as $email)
$sql=$sql_base."socpeople as s SET s.email = NULL WHERE s.email = '".$email."';"; $sql=$sql_base."socpeople as s SET s.email = NULL WHERE s.email = '".$email."';";
$db->query($sql); $db->query($sql);
} }
if ($type == 'all' || $type == 'user') if ($type == 'all' || $type == 'user')
@ -108,7 +107,6 @@ foreach($groupofemails as $email)
$sql=$sql_base."user as u SET u.email = NULL WHERE u.email = '".$email."';"; $sql=$sql_base."user as u SET u.email = NULL WHERE u.email = '".$email."';";
$db->query($sql); $db->query($sql);
} }
if ($type == 'all' || $type == 'member') if ($type == 'all' || $type == 'member')