25include_once DOL_DOCUMENT_ROOT.
'/core/modules/mailings/modules_mailings.php';
26require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
34 public $name =
'EmailsFromFile';
36 public $desc =
'EMails from a file';
37 public $require_module = array();
38 public $require_admin = 0;
43 public $picto =
'generic';
44 public $tooltip =
'UseFormatFileEmailToTarget';
69 $langs->load(
"users");
99 return $langs->trans(
'LineInFile',
$id);
115 $maxmin = $maxfilesizearray[
'maxmin'];
117 $s .=
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
119 $s .=
'<input type="file" name="username" class="flat">';
133 global
$conf, $langs, $_FILES;
135 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
138 ini_set(
'auto_detect_line_endings',
true);
142 $upload_dir =
$conf->mailing->dir_temp;
145 $resupload =
dol_move_uploaded_file($_FILES[
'username'][
'tmp_name'], $upload_dir.
"/".$_FILES[
'username'][
'name'], 1, 0, $_FILES[
'username'][
'error']);
146 if (is_numeric($resupload) && $resupload > 0) {
149 $file = $upload_dir.
"/".$_FILES[
'username'][
'name'];
150 $handle = @fopen($file,
"r");
156 while (!feof($handle)) {
158 $buffer = trim(fgets($handle));
159 $tab = explode(
';', $buffer, 4);
166 if (!empty($buffer)) {
169 if ($old != $email) {
173 'firstname' => $firstname,
177 'source_type' =>
'file'
184 $langs->load(
"errors");
185 $msg = $langs->trans(
"ErrorFoundBadEmailInFile", $i, $cpt, $email);
189 $this->error =
'ErrorFoundBadEmailInFile '.$i.
' '.$cpt.
' '.$email;
200 $this->error = $langs->trans(
"ErrorFaildToOpenFile");
204 dol_syslog(get_class($this).
"::add_to_target mailing ".$cpt.
" targets found");
206 $langs->load(
"errors");
207 if ($resupload < 0) {
208 $this->error =
'<div class="error">'.$langs->trans(
"ErrorFileNotUploaded").
'</div>';
209 } elseif (preg_match(
'/ErrorFileIsInfectedWithAVirus/', $resupload)) {
210 $this->error =
'<div class="error">'.$langs->trans(
"ErrorFileIsInfectedWithAVirus").
'</div>';
212 $this->error =
'<div class="error">'.$langs->trans($resupload).
'</div>';
217 ini_set(
'auto_detect_line_endings',
false);
219 return parent::addTargetsToDatabase($mailing_id, $cibles);
Parent class of emailing target selectors modules.
dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disablevirusscan=0, $uploaderrorcode=0, $nohook=0, $varfiles='addedfile', $upload_dir='')
Check validity of a file upload from an GUI page, and move it to its final destination.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
getMaxFileSizeArray()
Return the max allowed for file upload.