25 if (!defined(
'NOSESSION')) {
26 define(
'NOSESSION',
'1');
28 if (!defined(
'MAXEMAILS')) {
29 define(
'MAXEMAILS', 100);
32 $sapi_type = php_sapi_name();
33 $script_file = basename(__FILE__);
37 if (substr($sapi_type, 0, 3) ==
'cgi') {
38 echo
"Error: You are using PHP for CGI. To execute ".$script_file.
" from command line, you must use PHP for CLI mode.\n";
42 if (!isset($argv[3]) || !$argv[3]) {
43 print
"Usage: ".$script_file.
" inputfile-with-invalid-emails type [test|confirm]\n";
44 print
"- inputfile-with-invalid-emails is a file with list of invalid email\n";
45 print
"- type can be 'all' or 'thirdparties', 'contacts', 'members', 'users'\n";
48 $fileofinvalidemail = $argv[1];
52 require_once $path.
"../../htdocs/master.inc.php";
53 require_once DOL_DOCUMENT_ROOT.
"/core/class/CMailFile.class.php";
54 require_once DOL_DOCUMENT_ROOT.
"/comm/mailing/class/mailing.class.php";
57 $version = DOL_VERSION;
65 $user =
new User($db);
68 print
"***** ".$script_file.
" (".$version.
") pid=".
dol_getmypid().
" *****\n";
70 if (!in_array($type, array(
'all',
'thirdparties',
'contacts',
'users',
'members'))) {
71 print
"Bad value for parameter type.\n";
75 if (!empty($dolibarr_main_db_readonly)) {
76 print
"Error: instance in read-onyl mode\n";
83 $myfile = fopen($fileofinvalidemail,
"r");
85 echo
"Failed to open file";
93 while ($tmp !=
null) {
94 $groupofemails = array();
95 for ($i = 0; $i < MAXEMAILS; $i++) {
96 $tmp = fgets($myfile);
100 $groupofemails[$i] = trim($tmp,
"\n");
105 foreach ($groupofemails as $email) {
106 $emailsin .= ($emailsin ?
", " :
"").
"'".$db->escape($email).
"'";
110 $nbingroup = count($groupofemails);
112 print
"Process group of ".$nbingroup.
" emails (".$counter.
" - ".($counter + $nbingroup - 1).
"), type = ".$type.
"\n";
116 $sql_base =
"UPDATE ".MAIN_DB_PREFIX;
118 if ($type ==
'all' || $type ==
'users') {
120 $sql = $sql_base.
"user as u SET u.email = NULL WHERE u.email IN (".$db->sanitize($emailsin, 1).
");";
121 print
"Try to update users, ";
122 $resql = $db->query($sql);
126 $numerased += $db->affected_rows(
$resql);
129 if ($type ==
'all' || $type ==
'thirdparties') {
131 $sql = $sql_base.
"societe as s SET s.email = NULL WHERE s.email IN (".$db->sanitize($emailsin, 1).
");";
132 print
"Try to update thirdparties, ";
133 $resql = $db->query($sql);
137 $numerased += $db->affected_rows(
$resql);
140 if ($type ==
'all' || $type ==
'contacts') {
143 $sql = $sql_base.
"socpeople as s SET s.email = NULL WHERE s.email IN (".$db->sanitize($emailsin, 1).
");";
144 print
"Try to update contacts, ";
145 $resql = $db->query($sql);
149 $numerased += $db->affected_rows(
$resql);
152 if ($type ==
'all' || $type ==
'members') {
155 $sql = $sql_base.
"adherent as a SET a.email = NULL WHERE a.email IN (".$db->sanitize($emailsin, 1).
");";
156 print
"Try to update members, ";
157 $resql = $db->query($sql);
161 $numerased += $db->affected_rows(
$resql);
164 $numerasedtotal += $numerased;
166 print $numerased.
" emails cleared.\n";
167 $counter = $counter + $nbingroup;
170 if (!$error && $mode ==
'confirm') {
171 print
"Commit - ".$numerasedtotal.
" operations validated.\n";
174 print
"Rollback - ".$numerasedtotal.
" Operations canceled.\n";
Class to manage Dolibarr users.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
dol_getmypid()
Return getmypid() or random PID when function is disabled Some web hosts disable this php function fo...
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
if(!defined( 'CSRFCHECK_WITH_TOKEN'))