function error($description, $error_place = '', $params = array()) { if (defined('DEVELOPER_ENVIROMENT')) { trigger_error('error', E_USER_WARNING); echo $description . '<br>' . $error_place . '<br><pre>'; print_r($params); echo '</pre>'; } debug::write_error($description, $error_place, $params); rollback_user_transaction(); if (debug::is_console_enabled()) { echo debug::parse_html_console(); } else { $message = ''; if ($user_id = user::get_id()) { $message .= "user id:\t{$user_id}\nlogin:\t\t" . user::get_login() . "\ne-mail:\t\t" . user::get_email() . "\n"; } $message .= "ip:\t\t" . sys::client_ip() . "\nrequest:\t" . REQUEST_URI . "\nerror:\t\t{$title}\ndescription:\t{$msg}"; $mail = new mime_mail(); $mail->set_body($message); $mail->build_message(); $mail->send('developer', DEVELOPER_EMAIL, '', WEBSITE_EMAIL, $_SERVER['HTTP_HOST'] . ' internal error!'); } ob_end_flush(); exit; }
function _valid_perform() { $mail_data = $this->dataspace->export(); $body = sprintf(strings::get('body_template', 'feedback'), $mail_data['sender_name'], $mail_data['sender_email'], $mail_data['body']); $body = str_replace('<br>', "\n", $body); $subject = sprintf(strings::get('message_subject', 'feedback'), $mail_data['subject'], $_SERVER['HTTP_HOST']); $mail = new mime_mail(); $mail->set_body($body); $mail->build_message(); $recipient_email = constant('ADMINISTRATOR_EMAIL'); if (!$recipient_email || !$mail->send('administrator', $recipient_email, $mail_data['sender_name'], $mail_data['sender_email'], $subject)) { message_box::write_error(strings::get('mail_not_sent', 'feedback')); return false; } return true; }
function send_plain_mail($recipients, $sender, $subject, $body, $headers = array()) { $mail = new mime_mail(); $mail->set_text($body); $mail->set_subject($subject); $mail->set_from($sender); foreach ($headers as $key => $value) { $mail->set_header($key, $value); } return $mail->send($recipients); }
function send_html_mail($recipients, $sender, $subject, $html, $text = null, $headers = array()) { $mail = new mime_mail(); $mail->set_html($html, $text); $mail->set_subject($subject); $mail->set_from($sender); foreach ($headers as $key => $value) { $mail->set_header($key, $value); } return $mail->send($recipients); }
function send_html_mail($recipients, $sender, $subject, $html, $text = null, $headers = array()) { $mail = new mime_mail(); //$text = convert_html_to_plain_text(preg_replace('(<p>|br>)', "\n", $html)); $mail->set_html($html, $text); $mail->set_subject($subject); $mail->set_from($sender); foreach ($headers as $key => $value) { $mail->set_header($key, $value); } return $mail->send($recipients); }
function sendXML($send = '') { if ($send) { global $options; global $errs; $date = new clDate(); // Création du fichier XML. $nomFic = $options->getOption('RPU_IdActeur') . "_" . $date->getDate('YmdHis') . '.xml'; $nomFicC = URLRPU . $nomFic; $FIC = fopen($nomFicC, "w"); if (fwrite($FIC, $this->xmlRpu)) { $this->message .= "<font color=\"green\">La création du fichier ({$nomFicC}) s'est bien déroulée.<br/></font>"; } else { $this->message .= "<font color=\"red\">La création du fichier ({$nomFicC}) a échoué.<br/></font>"; } fclose($FIC); if (!$options->getOption('RPU_SansCryptEnvoi')) { // Cryptage du fichier RPU. $mailE = $options->getOption('RPU_Envoi_Mail'); $gpg = new gnuPG(false, GNUPG); $gpg->EncryptFile($mailE, $nomFicC); if (!$gpg->error) { $this->message .= "<font color=\"green\">Le cryptage du fichier ({$nomFicC}.gpg) s'est bien déroulé.<br/></font>"; } else { $this->message .= "<font color=\"red\">Le cryptage du fichier ({$nomFicC}.gpg) a échoué :" . $gpg->error . "<br/></font>"; } if ($options->getOption('RPU_TypeEnvoi') == 'mail') { // Envoi du fichier RPU. $contenuFic = fread(fopen($nomFicC . '.gpg', "r"), filesize($nomFicC . '.gpg')); // eko ( $contenuFic ) ; $mail = new mime_mail(); $mail->to = $mailE; $mail->subject = "Envois RPU (" . $_REQUEST['dateRPU'] . ")"; $mail->body = "Envois RPU (" . $_REQUEST['dateRPU'] . ")"; $mail->from = Erreurs_MailApp; $mail->attach($contenuFic, $nomFic . '.gpg'); if ($options->getOption('SMTP_BCC')) { $mail->headers = "CC: " . $options->getOption('SMTP_BCC') . "\r"; } if ($mail->sendXham()) { $this->message .= "<font color=\"green\">L'envoi du fichier ({$nomFicC}.gpg) s'est bien déroulé.<br/></font>"; } else { $this->message .= "<font color=\"red\">L'envoi du fichier ({$nomFicC}.gpg) a échoué.<br/></font>"; } rename(URLRPU . $nomFic, URLRPU . 'ok/' . $nomFic); rename(URLRPU . $nomFic . '.gpg', URLRPU . 'ok/' . $nomFic . '.gpg'); } else { rename(URLRPU . $nomFic, URLRPU . 'ok/' . $nomFic); $this->message .= "Connexion au serveur FTP '" . $options->getOption('RPU_FTP_Host') . ':' . $options->getOption('RPU_FTP_Port') . "' -> "; $con = ftp_connect($options->getOption('RPU_FTP_Host')); if (!$con) { $this->message .= "<font color='red'>KO</font><br/>"; $errs->addErreur('RPU : Impossible de se connecter au serveur "' . $options->getOption('RPU_FTP_Host') . ':' . $options->getOption('RPU_FTP_Port') . '"'); } else { $this->message .= "<font color='green'>OK</font><br/>"; $this->message .= "Authentification au serveur FTP avec l'utilisateur '" . $options->getOption('RPU_FTP_User') . "' -> "; $log = ftp_login($con, $options->getOption('RPU_FTP_User'), $options->getOption('RPU_FTP_Pass')); if (!$log) { $this->message .= "<font color='red'>KO</font><br/>"; $errs->addErreur('RPU : Impossible de se connecter au serveur avec l\'utilisateur "' . $options->getOption('RPU_FTP_User') . '"'); } else { $this->message .= "<font color='green'>OK</font><br/>"; $r = opendir('rpu/'); while ($fic = readdir($r)) { if ($fic != "." and $fic != ".." and $fic != "ok" and $fic != "logs" and $fic != 'arh') { $this->message .= "Envoi du fichier '{$fic}' -> "; $put = ftp_put($con, $fic, URLRPU . $fic, FTP_BINARY); if (!$put) { $this->message .= "<font color='red'>KO</font><br/>"; $errs->addErreur('RPU : Impossible d\'envoyer le fichier "' . $fic . '".'); } else { $this->message .= "<font color='green'>OK</font><br/>"; rename(URLRPU . $fic, URLRPU . 'ok/' . $fic); } } } } } } // Création du fichier Logs. $nomFicL = $options->getOption('RPU_IdActeur') . "_" . $date->getDate('YmdHis') . '.html'; $nomFicLC = URLRPULOGS . $nomFicL; $FICL = fopen($nomFicLC, "w"); fwrite($FICL, '<h3>RPU du ' . $_REQUEST['dateRPU'] . '</h3><h4>Messages :</h4>' . $this->message . '<h4>Contenu du fichier XML envoyé :</h4>' . nl2br(htmlentities($this->xmlRpu))); fclose($FICL); } return '<br/><br/>' . $this->message; } else { return '<br/><br/>Affichage des RPU.'; } }
} if ($zip->open($filename, ZIPARCHIVE::CREATE) !== TRUE) { echo "<h2 class=\"error\">" . $webgen_send_to_zip_error[$language] . " " . $filename . "</h2>"; } addFolderToZip($dirname, $zip, $_SESSION['step_all_4']['presentation_name']); $zip->close(); chmod($filename, 0777); // odeslani emailu s prilohou include_once "./library/mime_mail.inc"; $content_type = "application/octet-stream"; # read a JPEG picture from the disk $fd = fopen($filename, "r"); $data = fread($fd, filesize($filename)); fclose($fd); # create object instance $mail = new mime_mail(); # set all data slots $mail->from = $from; $mail->to = $email; $mail->subject = $predmet; $mail->body = $text; # append the attachment $filename = $zipdir . "/" . $_SESSION['step_all_4']['presentation_name'] . ".zip"; $mail->add_attachment($data, $filename, $content_type); # send e-mail if ($mail->send()) { echo "<h2 class=\"ok\">" . $webgen_send_to_email_send[$language] . "</h2>"; } else { echo "<h2 class=\"error\">" . $webgen_send_to_email_error[$language] . "</h2>"; } if ("c" == $_SESSION['step_pp_20']['send_choice']) {
// $mail->cc = stripslashes($cc); // $mail->bcc = stripslashes($bcc); $mail->prepare(); $mail->to = $to; $mail->subject = $subject; $mail->send(); $emails->next(); } $emails = new sql(); $emails->setQuery("select email from rex_email"); for ($i = 0; $i < $emails->getRows(); $i++) { $from = stripslashes($from); $subject = stripslashes($subject); $body = stripslashes($body); $to = stripslashes($emails->getValue("rex_email.email")); $mail = new mime_mail(); $mail->from = $from; $mail->headers = "Errors-To: " . $from; $mail->body = $body; // $mail->cc = stripslashes($cc); // $mail->bcc = stripslashes($bcc); $mail->prepare(); $mail->to = $to; $mail->subject = $subject; $mail->send(); $emails->next(); } // no form $form_show = false; $errmsg = "Ihre Eingaben wurden als Newsletter geschickt !"; }
function send_activate_password_email(&$user_data, $password) { global $_SERVER; $http_host = $_SERVER['HTTP_HOST']; $filename = TEMPLATES_DIR . '/user/generated_password_mail.html'; if (!file_exists($filename)) { error('template file for password notification email not found!', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('file_name' => $filename)); } $fd = fopen($filename, "r"); $contents = fread($fd, filesize($filename)); fclose($fd); $contents = str_replace('%website_name%', $http_host, $contents); $contents = str_replace('%user_name%', $user_data['name'] . ' ' . $user_data['lastname'], $contents); $contents = str_replace('%new_password%', $password, $contents); $contents = str_replace('%website_href%', $http_host, $contents); $contents = str_replace('%website_email%', ADMINISTRATOR_EMAIL, $contents); $activate_href = 'http://' . $http_host . '/root/activate_password?user='******'email'] . '&id=' . $user_data['password']; $contents = str_replace('%activate_href%', $activate_href, $contents); include_once LIMB_DIR . '/core/lib/mail/mime_mail.class.php'; $mail = new mime_mail(); $mail->set_body($contents); $mail->build_message(); if (!$mail->send($user_data['name'] . ' ' . $user_data['lastname'], $user_data['email'], $http_host, ADMINISTRATOR_EMAIL, strings::get('generate_password_theme', 'user'))) { debug::write_error('error while sending password notification email', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__); return false; } else { return true; } }
function my_mail($message, $subject = HOST, $to = EMAIL_ADMIN, $from = EMAIL_ADMIN, $headers = "") { $mail = new mime_mail(); $mail->from = $from; $mail->to = $to; $mail->subject = $subject; $mail->body = normalize($message); //$mail->add_attachment($aMail['file'], $aMail['filename'], $mimetype); $mail->send(); /* //$headers .= "To: ".$to."\r\n"; $headers .= "From: ".$from."\r\n"; if (!@mail($to, $subject, $message, $headers)) { //safewrite(FLGR_MESSAGES.'/'.getmicrotime().'.txt', $message); } */ }
function genEnvoi() { global $options; global $errs; //Attention, jour concerné = lendemain des données $dateJourConcerne = new clDate(); $tsp = $dateJourConcerne->getTimestamp(); define(nomForm, "URG"); define(idActeur, $options->getOption('RPU_IdActeur')); define(arRequis, $options->getOption('RPU_AR_Actif')); define(cleDepot, $options->getOption('RPU_CleActeur')); define(mail, $options->getOption('RPU_AR_Mail')); define(cfg_expediteur_alerte, "terminal_urgences"); define(chemin, URLRPU . 'arh/'); define(date_jour, date("Ymd", $tsp)); define(jour, substr(date_jour, 6, 2)); define(mois, substr(date_jour, 4, 2)); define(annee, substr(date_jour, 0, 4)); define(date_file, date("YmdHis")); define(date_envoi, date("d/m/Y à H:i:s")); define(date_event, date("d/m/Y", mktime(0, 0, 0, mois, jour - 1, annee))); define(from, date("Y-m-d H:i:s", mktime(0, 0, 0, mois, jour - 1, annee))); define(to, date("Y-m-d H:i:s", mktime(23, 59, 59, mois, jour - 1, annee))); $req = "select idpatient, uf , dt_naissance , type_destination\r\n from patients_sortis\r\n\t where manuel!=1 and dt_admission between '" . from . "' and '" . to . "' and type_destination!='X' and valide>=1\r\n\t\tUNION\r\n\t\tselect idpatient, uf , dt_naissance , type_destination\r\n\t\tfrom patients_presents\r\n\t\twhere manuel!=1 and dt_admission between '" . from . "' and '" . to . "' and type_destination!='X' and valide>=1"; $config[type] = "MySQL"; $config[host] = MYSQL_HOST; $config[login] = MYSQL_USER; $config[password] = MYSQL_PASS; $config[db] = BDD; $requete = new clResultQuery(); // On récupère le résultat de la requête sous la forme ResultQuery. $res = $requete->Execute("requete", $req, $config); eko($res[INDIC_SVC]); $age1 = 0; $age75 = 0; $NbHospit = 0; $NbUHCD = 0; $NbTransfert = 0; $ufUHCD = $options->getOption("numUFUHCD"); //eko ( $res['INDIC_SVC'] ) ; if ($res[INDIC_SVC][2]) { $NbPassages = $res[INDIC_SVC][2]; // On a le nombre de passages while (list($key, $val) = each($res[dt_naissance])) { $dateN = new clDate($val); $dateA = new clDate(from); $duree = new clDuree(); $duree->setValues($dateA->getDifference($dateN)); $age = $duree->getYears(); if ($age < 1) { $age1++; // Constitution du nb de passage < à 1 an } elseif ($age > 75) { $age75++; // Constitution du nb de passage > 75 ans } // Hospitalisations if ($res[type_destination][$key] == "H" and $res[uf][$key] != $ufUHCD) { $NbHospit++; } // UHCD if ($res[uf][$key] == $ufUHCD) { $NbUHCD++; } // Transferts if ($res[type_destination][$key] == "T") { $NbTransfert++; } //echo $val."--=> ".$res[type_destination][$key]." ".$age ." ans <br>"; } $balise_element = "\n<entete>"; $balise_element .= "\n<idActeur>" . idActeur . "</idActeur>"; $balise_element .= "\n<cleActeur>" . cleDepot . "</cleActeur>"; $balise_element .= "\n<arRequis>" . arRequis . "</arRequis>"; $balise_element .= "\n<mail>" . mail . "</mail>"; $balise_element .= "\n</entete>"; $balise_element .= "\n<element>"; $balise_element .= "\n<nomForm>" . nomForm . "</nomForm>"; $balise_element .= "\n<date_event>" . date_event . "</date_event>"; $balise_element .= "\n<NbPassages>{$NbPassages}</NbPassages>"; $balise_element .= "\n<NbPassInf1An>{$age1}</NbPassInf1An>"; $balise_element .= "\n<NbPassageSup75Ans>{$age75}</NbPassageSup75Ans>"; $balise_element .= "\n<NbHospit>{$NbHospit}</NbHospit>"; $balise_element .= "\n<NbHospitUHCD>{$NbUHCD}</NbHospitUHCD>"; $balise_element .= "\n<NbTransfert>{$NbTransfert}</NbTransfert>"; $balise_element .= "\n</element>"; $nom_fic = idActeur . "_" . date_file . ".xml"; $nom_fic_export = chemin . $nom_fic; $xml_data = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" standalone=\"yes\"?>\r\n\t\t\t\n<result>" . $balise_element . "\n</result>"; $fp = fopen($nom_fic_export, "w"); if (!fwrite($fp, $xml_data)) { eko("pb ecriture fichier xml"); } fclose($fp); copy($nom_fic_export, URLLOCAL . 'rpu/logs/' . $nom_fic); $affichage = "<center><h2>Export des données Urgences - CH-Hyères</h2></center>\r\n\t\t\t<u>Date d'export:</u> le " . date_envoi . "<br>\r\n\t\t\t<u>Contenu exporté :</u> {$balise_element}<br>\r\n\t\t\t<u>Fichier d'export :</u> {$nom_fic_export}"; // Cryptage du fichier. $mailE = $options->getOption('RPU_Envoi_Mail'); $gpg = new gnuPG(false, GNUPG); $gpg->EncryptFile($mailE, $nom_fic_export); if (!$gpg->error) { $this->message .= "<font color=\"green\">Le cryptage du fichier ({$nom_fic_export}.gpg) s'est bien déroulé.<br/></font>"; } else { $this->message .= "<font color=\"red\">Le cryptage du fichier ({$nom_fic_export}.gpg) a échoué :" . $gpg->error . "<br/></font>"; } if ($options->getOption('RPU_TypeEnvoi') == 'mail') { // Envoi du fichier RPU. $contenuFic = fread(fopen($nom_fic_export . '.gpg', "r"), filesize($nom_fic_export . '.gpg')); // eko ( $contenuFic ) ; $mail = new mime_mail(); $mail->to = $options->getOption("RPU_Envoi_Mail"); //$mail->to = "*****@*****.**" ; //eko ( $options->getOption ( "RPU_Envoi_Mail" ) ) ; $mail->subject = "Données urgences (" . date_envoi . ")"; $mail->body = "Données urgences (" . date_envoi . ")"; $mail->from = Erreurs_MailApp; $mail->attach($contenuFic, $nom_fic . '.gpg'); if ($mail->sendXham()) { $this->message .= "<font color=\"green\">L'envoi du fichier ({$nom_fic_export}.gpg) s'est bien déroulé.<br/></font>"; } else { $this->message .= "<font color=\"red\">L'envoi du fichier ({$nom_fic_export}.gpg) a échoué.<br/></font>"; } } else { rename($nom_fic_export, chemin . 'ok/' . $nom_fic); $this->message .= "Connexion au serveur FTP '" . $options->getOption('RPU_FTP_Host') . ':' . $options->getOption('RPU_FTP_Port') . "' -> "; $con = ftp_connect($options->getOption('RPU_FTP_Host')); if (!$con) { $this->message .= "<font color='red'>KO</font><br/>"; $errs->addErreur('RPU : Impossible de se connecter au serveur "' . $options->getOption('RPU_FTP_Host') . ':' . $options->getOption('RPU_FTP_Port') . '"'); } else { $this->message .= "<font color='green'>OK</font><br/>"; $this->message .= "Authentification au serveur FTP avec l'utilisateur '" . $options->getOption('RPU_FTP_User') . "' -> "; $log = ftp_login($con, $options->getOption('RPU_FTP_User'), $options->getOption('RPU_FTP_Pass')); if (!$log) { $this->message .= "<font color='red'>KO</font><br/>"; $errs->addErreur('RPU : Impossible de se connecter au serveur avec l\'utilisateur "' . $options->getOption('RPU_FTP_User') . '"'); } else { $this->message .= "<font color='green'>OK</font><br/>"; $r = opendir('rpu/arh/'); while ($fic = readdir($r)) { if ($fic != "." and $fic != ".." and $fic != "ok" and $fic != "logs" and $fic != 'arh') { $this->message .= "Envoi du fichier '{$fic}' -> "; $put = ftp_put($con, $fic, chemin . $fic, FTP_BINARY); if (!$put) { $this->message .= "<font color='red'>KO</font><br/>"; $errs->addErreur('RPU : Impossible d\'envoyer le fichier "' . $fic . '".'); } else { $this->message .= "<font color='green'>OK</font><br/>"; rename(chemin . $fic, chemin . 'ok/' . $fic); } } } } } } $this->af = $affichage . "<br/>" . $this->message; } else { $this->af .= "Aucun patient retourné par la requête : envoi impossible."; } }