Exemplo n.º 1
0
	static function send($destinataire) {
		$expediteur = CBdd::select_one("SELECT email FROM user WHERE type = 2", "email");
		$id_texte	= CConfiguration::get_valeur('WELCOME_TEXT_ID');
		
		$sql_texte_select = "SELECT * FROM texte WHERE id = " . $id_texte;
		$texte = CBdd::select_row($sql_texte_select);
		
		$sql_user = "******" . $destinataire . "'";
		$user = CBdd::select_row($sql_user);
		
		$message = str_replace('$NOM', $user['nom'], $texte['text']);
		$message = str_replace('$PRENOM', $user['prenom'], $message);
		
		//echo $message;
		
		$sujet = $texte['nom'];
		
		$sql_unicite_message = "SELECT id FROM email WHERE destinataire = '" . addslashes($destinataire) . "' AND nom = '" . addslashes($sujet) . "'";
		// echo $sql_unicite_message;
		if(CBdd::select_one($sql_unicite_message, 'id')) {
			return 1;
		}
		
		$sql_email_insert = "INSERT INTO email(expediteur, destinataire, nom, text, etat) VALUES ('" . addslashes($expediteur) . "', '" . addslashes($destinataire) . "', '" . addslashes($sujet) . "', '" . addslashes($message) . "', '2')";
		
		
		CBdd::insert($sql_email_insert);
		
		return CMail::send_mail($destinataire, CFonction::force_stripslashes($sujet), CFonction::force_stripslashes($message), $expediteur, array(), 'Bcc: ' . $expediteur);
	}
Exemplo n.º 2
0
	static function get_href($cible) {
		$href = "";
		if(CMail::is_email($cible)) {
			$tab_email = explode(",", $cible);
			foreach($tab_email as $email) {
				$sql = "SELECT id, nom, prenom FROM hbclients WHERE id = '" . $email . "' OR email = '" . $email . "'";
				$hbclients = CBdd::select_row($sql);
				$href .= '<span class="info"><a href="hb_clients.php?id=' . $hbclients['id'] . '&a=5">' .$email . '</a><div class="bulle">'. $hbclients['nom'] . '&nbsp;' . $hbclients['prenom'] . '</div></span>,';
			}
			$href = trim($href, ',');
		} else {
			$id = CBdd::select_one("SELECT id FROM hbgroupe WHERE id = '" . $cible . "' OR nom = '" . $cible . "'" , "id");
			$href = '<span class="info"><a href="hbgroupe.php?id=' . $id . '&a=5">' . $cible .'</a><div class="bulle">'. implode(', <br/>', self::get_array_nom_user($cible)) . '</span>';
		}
		return $href;
	}
Exemplo n.º 3
0
 function sendMail($to, $subject, $body, $from = '', $formName = '')
 {
     $mailer = new CMail();
     set_time_limit(30);
     if (!empty($from)) {
         $mailer->From = $from;
     }
     if (!empty($formName)) {
         $mailer->FromName = $formName;
     }
     $mailer->Subject = $subject;
     $mailer->MsgHTML($body);
     $mailer->AddAddress($to, '');
     $result = $mailer->Send();
     usleep(1000000);
     // sleep for 1 second
     return $result;
 }
Exemplo n.º 4
0
	static function get_href($cible) {
		$href = "";
		if(CMail::is_email($cible)) {
			$tab_email = explode(",", $cible);
			foreach($tab_email as $email) {
				$sql = "SELECT id, nom, prenom FROM user WHERE id = '" . $email . "' OR email = '" . $email . "'";
				$user = CBdd::select_row($sql);
				$href .= '<span class="info"><a href="user.php?id=' . $user['id'] . '&a=5">' .$email . '</a><div class="bulle">'. $user['nom'] . '&nbsp;' . $user['prenom'] . '</div></span>,';
			}
			$href = trim($href, ',');
		} else {
			$id = CBdd::select_one("SELECT id FROM groupe WHERE id = '" . $cible . "' OR nom = '" . $cible . "'" , "id");
			$list_user = self::get_array_nom_user($id);
			if(count($list_user)> 3) {
				$list_user = array_slice($list_user, 0, 3);
				$list_user[] = '...';
			}
			$href = '<span class="info"><a href="groupe.php?id=' . $id . '&a=5">' . $cible .'</a><div class="bulle">'. implode(', <br/>', $list_user) . '</span>';
		}
		return $href;
	}
Exemplo n.º 5
0
 function delete($group_id = false, $user_id = false)
 {
     if ($group_id !== false && $user_id !== false) {
         include_once PATH_CLASS . '/CGroup.php';
         $g =& CGroup::getInstance();
         $group_data = $g->groupData($group_id);
         $perms = $g->isOwner($group_id, $user_id, $group_data);
         if ($perms === true) {
             include_once PATH_CLASS . '/CMail.php';
             $m =& CMail::getInstance();
             $expiry = NOW + 86400;
             $safe_group_id = $this->dbh->sql_safe($group_id);
             $safe_user_id = $this->dbh->sql_safe($user_id);
             $safe_expiry = $this->dbh->sql_safe(date('Y-m-d', $expiry));
             $sql = 'REPLACE INTO group_delete(g_id, u_id, gd_dateToDelete) VALUES(' . $safe_group_id . ', ' . $safe_user_id . ', ' . $safe_expiry . ')';
             $this->dbh->execute($sql);
             $this->update(array('g_id' => $group_id, 'g_delete' => 1));
             $group_members = $g->members($group_id);
             $body = file_get_contents(PATH_DOCROOT . '/group_delete.tpl.php');
             $body = str_replace(array('{DATE}', '{GROUP}'), array(date(FF_FORMAT_DATE_LONG, $expiry), $group_data['G_NAME']), $body);
             $mail_headers = "MIME-Version: 1.0\n" . "Content-type: text/plain; charset=iso-8859-1\n" . "Return-Path: " . FF_EMAIL_FROM . "\n" . "From: " . FF_EMAIL_FROM_FORMATTED . "\n";
             foreach ($group_members as $v) {
                 $this_body = str_replace('{NAME}', $v['U_NAMEFIRST'], $body);
                 $email_formatted = $v['U_NAMEFIRST'] . ' ' . $v['U_NAMELAST'] . '<' . $v['U_EMAIL'] . '>';
                 $m->send($email_formatted, 'FotoGroup ' . $group_data['G_NAME'] . ' to be deleted!', $this_body, $mail_headers, '-f' . FF_EMAIL_FROM);
             }
             return true;
         }
     }
     return false;
 }
Exemplo n.º 6
0
 function ajax()
 {
     if (!$this->haveAccessTo('massend-clients')) {
         $this->ajaxResponse(Errors::ACCESSDENIED);
     }
     if (bff::$isAjax) {
         switch (func::POSTGET('action')) {
             case 'massend-filter':
                 $bClients = func::POSTGET('clients') ? 1 : 0;
                 $bEmployees = func::POSTGET('employees') ? 1 : 0;
                 $bUsers = func::POSTGET('users') ? 1 : 0;
                 $bUsers = func::POSTGET('usersall') && $bUsers ? 2 : $bUsers;
                 $bExludeBlocked = func::POSTGET('blocked') ? 1 : 0;
                 $this->ajaxResponse($this->getReceiversOptions($bClients, $bEmployees, $bUsers, $bExludeBlocked));
                 break;
             case 'massend':
                 $bClients = func::POSTGET('clients') ? 1 : 0;
                 $bEmployees = func::POSTGET('employees') ? 1 : 0;
                 $bUsers = func::POSTGET('users') ? 1 : 0;
                 $aReceivers = $this->getReceiversInfo($bClients || $bEmployees, $bUsers, func::POST('receivers', false));
                 $sFrom = func::POST('from', true);
                 $sSubject = func::POST('subject', true);
                 $sBodyHTML = func::POST('body', true);
                 if (false && count($aReceivers) > 0 && !empty($sFrom) && !empty($sSubject) && !empty($sBodyHTML)) {
                     $mailer = new CMail();
                     $mailer->From = $sFrom;
                     $mailer->Subject = $sSubject;
                     $mailer->MsgHTML($sBodyHTML);
                     //определяем какой текст требует обработки шаблонизатором
                     $aTemplateVars = array('{name}', '{login}', '{email}', '{password}');
                     str_replace($aTemplateVars, '', $sFrom, $bPrepareFrom);
                     str_replace($aTemplateVars, '', $sSubject, $bPrepareSubject);
                     str_replace($aTemplateVars, '', $sBodyHTML, $bPrepareBodyHTML);
                     foreach ($aReceivers as $receiver) {
                         set_time_limit(30);
                         // sets (or resets) maximum  execution time to 30 seconds)
                         $mailer->AddAddress($receiver['email'], $receiver['name']);
                         $aTemplateData = array('{name}' => $receiver['name'], '{login}' => $receiver['login'], '{email}' => $receiver['email'], '{password}' => $receiver['password']);
                         //prepare FROM
                         if ($bPrepareFrom) {
                             $mailer->From = strtr($sFrom, $aTemplateData);
                         }
                         //prepare SUBJECT
                         if ($bPrepareSubject) {
                             $mailer->Subject = strtr($sSubject, $aTemplateData);
                         }
                         //prepare BODY-HTML
                         if ($bPrepareBodyHTML) {
                             $mailer->MsgHTML(strtr($sBodyHTML, $aTemplateData));
                         }
                         $mailer->Send();
                         $mailer->ClearAddresses();
                         usleep(1000000);
                         // sleep for 1 second
                     }
                 }
                 $this->ajaxResponse($aReceivers);
                 break;
         }
     }
     $this->ajaxResponse(Errors::IMPOSSIBLE);
 }
Exemplo n.º 7
0
<?php

include_once dirname($_SERVER['SCRIPT_FILENAME']) . '/_reporter.php';
chdir(dirname(__FILE__));
ob_start();
include_once $path = str_replace('scripts', '', dirname(__FILE__)) . 'init_constants.php';
include_once PATH_DOCROOT . '/init_database.php';
include_once PATH_INCLUDE . '/variables.php';
include_once PATH_CLASS . '/CSubscription.php';
include_once PATH_CLASS . '/CMail.php';
$s =& CSubscription::getInstance();
$m =& CMail::getInstance();
$time = mktime(0, 0, 0, date('m', NOW), date('d', NOW) - 1, date('Y', NOW));
$sTime = $time - 86400;
$hour = date('H', NOW) - 1;
$sHour = $hour + 1;
$headers = "MIME-Version: 1.0\n" . "Content-type: text/html; charset=iso-8859-1\n" . 'Return-Path: ' . FF_EMAIL_FROM_FORMATTED . "\n" . 'From: ' . FF_EMAIL_FROM_FORMATTED;
$yesterday = " BETWEEN '" . date("Y-m-d {$sHour}:00:00", $sTime) . "' AND '" . date("Y-m-d {$hour}:59:59", $time) . "' ";
$incompleteUsers = $GLOBALS['dbh']->query_all($sql = "SELECT * FROM user_incompletes WHERE u_dateCreated {$yesterday}");
echo $sql . "\n\n";
$template = file_get_contents(PATH_DOCROOT . '/account_incomplete_user.tpl.php');
$listElements = '';
foreach ($incompleteResponses as $k => $v) {
    $listElements .= '<li><a href="http://' . FF_SERVER_NAME . '/?action=account.incomplete_user_response.act&key={KEY}&response=' . $k . '">' . $v . '</a></li>';
}
$template = str_replace('{LI}', $listElements, $template);
foreach ($incompleteUsers as $v) {
    if (strstr($v['u_email'], '@')) {
        $m->send($v['u_email'], 'Complete your registration on Photagious', str_replace(array('{GREETING}', '{KEY}', '{SERVERNAME}'), array($v['u_username'], $v['u_key'], FF_SERVER_NAME), $template), $headers, FF_EMAIL_FROM_FORMATTED);
        echo 'send email to ' . $v['u_email'] . "\n";
    }
Exemplo n.º 8
0
 /**
  * @ignore
  */
 public static function maybeUpdateThirdParty()
 {
     if (!self::isInCliMode()) {
         // This method can be run in CLI mode only.
         assert('false', vs(isset($this), get_defined_vars()));
         return false;
     }
     $updates = CConfiguration::option("updates");
     $updatesAreEnabled = $updates["enable"];
     if ($updatesAreEnabled) {
         $minTimeBetweenDoUpdatesDays = $updates["minTimeBetweenDoUpdatesDays"];
         $components = $updates["components"];
         assert('is_int($minTimeBetweenDoUpdatesDays)', vs(isset($this), get_defined_vars()));
         // Logging.
         $logging = $updates["logging"];
         $loggingIsEnabled = $logging["enable"];
         $logFp = $logging["logFilePath"];
         if ($loggingIsEnabled) {
             assert('!CString::isEmpty($logFp)', vs(isset($this), get_defined_vars()));
             $logFp = CFilePath::frameworkPath($logFp);
             CShell::setLogging($logFp);
         }
         // Mailing.
         $mailing = $updates["mailing"];
         $mailingIsEnabled = $mailing["enable"];
         if ($mailingIsEnabled) {
             $adminMail = CConfiguration::option("admin.mail");
             $to = $adminMail["to"];
             $from = $adminMail["from"];
             $transport = $adminMail["transport"];
             assert('!CString::isEmpty($to) && !CString::isEmpty($from) && !CString::isEmpty($transport)', vs(isset($this), get_defined_vars()));
             $mail;
             if (CString::equalsCi($transport, "smtp")) {
                 $smtpOutgoingServer = $adminMail["smtpOutgoingServer"];
                 $smtpUsername = $adminMail["smtpUsername"];
                 $smtpPassword = $adminMail["smtpPassword"];
                 assert('!CString::isEmpty($smtpOutgoingServer) && !CString::isEmpty($smtpUsername) && ' . '!CString::isEmpty($smtpPassword)', vs(isset($this), get_defined_vars()));
                 $mail = CMail::makeSmtp($smtpOutgoingServer, $smtpUsername, $smtpPassword, $from, $to);
             } else {
                 if (CString::equalsCi($transport, "system")) {
                     $mail = CMail::makeSystem($from, $to);
                 } else {
                     assert('false', vs(isset($this), get_defined_vars()));
                 }
             }
             CShell::setMailing($mail);
         }
         $thirdPartyDp = $GLOBALS["PHRED_PATH_TO_THIRD_PARTY"];
         $lastUpdateTimeFp = CFilePath::add($thirdPartyDp, self::$ms_thirdPartyLastUpdateTimeFn);
         // Read the file containing the Unix seconds of the last update time stamp (if exists) and compare that
         // time with the current time.
         $numDaysSinceLastUpdate;
         if (CFile::exists($lastUpdateTimeFp)) {
             $lastUpdateTime = new CTime(CString::toInt(CFile::read($lastUpdateTimeFp)));
             $currTime = CTime::now();
             if ($lastUpdateTime->isBefore($currTime)) {
                 $numDaysSinceLastUpdate = $currTime->diffInDays($lastUpdateTime);
                 if ($numDaysSinceLastUpdate < $minTimeBetweenDoUpdatesDays) {
                     // It is too early for updates yet.
                     return false;
                 }
             } else {
                 assert('false', vs(isset($this), get_defined_vars()));
             }
         }
         $date = CShell::currentDate();
         CShell::say("Started on {$date}.");
         if (isset($numDaysSinceLastUpdate)) {
             CShell::say("It has been {$numDaysSinceLastUpdate} day(s) since last successful update.");
         }
         $concurrLockFp = CFilePath::add($thirdPartyDp, self::$ms_thirdPartyConcurrLockFn);
         // Try locking the operation.
         if (!self::setLock($concurrLockFp, false)) {
             assert('false', vs(isset($this), get_defined_vars()));
             CShell::onError(false, "Could not obtain a lock on the operation.");
             CShell::writeToLog("\n");
             return false;
         }
         $phpConfigNeedsReload = false;
         $totalNumComponents = CMap::length($components);
         $numComponentsUpdated = 0;
         // The Browser Capabilities Project (BrowsCap).
         if (CMap::hasKey($components, "browsCap")) {
             $browsCap = $components["browsCap"];
             $skip = $browsCap["skip"];
             if (!$skip) {
                 CShell::say("Updating the Browser Capabilities Project (BrowsCap) ...");
                 $lookupFileUrl = $browsCap["lookupFileUrl"];
                 assert('!CString::isEmpty($lookupFileUrl)', vs(isset($this), get_defined_vars()));
                 // Component-related constants.
                 static $s_configOptName = "browscap";
                 static $s_lookupFileDownloadTimeoutSeconds = 120;
                 if (self::hasConfigOption($s_configOptName)) {
                     $browsCapLookupFp = CString::trim(self::configOption($s_configOptName));
                     if (!CString::isEmpty($browsCapLookupFp)) {
                         $browsCapDp = CFilePath::directory($browsCapLookupFp);
                         CShell::say("Downloading a BrowsCap lookup file from '{$lookupFileUrl}' ...");
                         $temporaryFp = CFile::createTemporary($browsCapDp);
                         $downloadRes = CInetRequest::downloadFile($lookupFileUrl, $temporaryFp, $s_lookupFileDownloadTimeoutSeconds);
                         if ($downloadRes) {
                             // After the file is downloaded into a temporary one, move it to the destination,
                             // safely replacing the existing file, if any.
                             CFile::move($temporaryFp, $browsCapLookupFp);
                             $numComponentsUpdated++;
                             $phpConfigNeedsReload = true;
                             $downloadedFileSizeKB = CUUnit::convertStoragef((double) CFile::size($browsCapLookupFp), CUUnit::BYTE, CUUnit::KILOBYTE);
                             $downloadedFileSizeKB = CMathf::round($downloadedFileSizeKB, 2);
                             CShell::say("Done. The downloaded file is {$downloadedFileSizeKB} KB in size.");
                         } else {
                             CShell::onError(false, "Could not download a BrowsCap lookup file from '{$lookupFileUrl}'.");
                         }
                         // Just in case, check for any temporary files that could have been left by any previous
                         // operations in the directory.
                         $leftoverFiles = CFile::findFiles(CFilePath::add($browsCapDp, CFile::DEFAULT_TEMPORARY_FILE_PREFIX . "*"));
                         if (!CArray::isEmpty($leftoverFiles)) {
                             // Cleanup the directory from the temporary files.
                             $len = CArray::length($leftoverFiles);
                             for ($i = 0; $i < $len; $i++) {
                                 CFile::delete($leftoverFiles[$i]);
                             }
                         }
                     } else {
                         CShell::onError(false, "Could not read the value of '{$s_configOptName}' option " . "in the PHP CLI configuration file.");
                     }
                 } else {
                     CShell::onError(false, "Could not find '{$s_configOptName}' option in the PHP CLI configuration file.");
                 }
             } else {
                 CShell::say("Skipping the Browser Capabilities Project (BrowsCap).");
             }
         }
         // All the components have been processed. Unlock the operation.
         self::unsetLock($concurrLockFp);
         $date = CShell::currentDate();
         if ($numComponentsUpdated != 0) {
             // One or more third-party components have been updated. Put a time stamp on the directory where the
             // components are located.
             CFile::write($lastUpdateTimeFp, CString::fromInt(CTime::currentUTime()));
             if ($numComponentsUpdated == $totalNumComponents) {
                 CShell::speak("Success. All {$totalNumComponents} third-party component(s)");
             } else {
                 CShell::speak("Partial success. {$numComponentsUpdated} out of {$totalNumComponents} third-party component(s)");
             }
             CShell::say("have been updated. Completed on {$date}.");
         } else {
             CShell::say("No third-party components have been updated. Completed on {$date}.");
         }
         return $phpConfigNeedsReload;
     } else {
         return false;
     }
 }
Exemplo n.º 9
0
<?php
include("../inc/init.php");

//boucler pour voir tous les emails non envoyés
$sql = "SELECT * FROM email WHERE etat = 3 AND DATE_FORMAT(date, '%Y-%m-%d') <=  DATE_FORMAT(date, '%Y-%m-%d') LIMIT " . CTableConfiguration::get_value_by_element('MAIL_MAX_SEND');
$res = CBdd::select($sql);
while($email = mysql_fetch_array($res)) {
	//à chaque résultat, envoyer l'email
	$liste_email = CTableGroupe::get_liste_email($email['destinataire']);
	
	$tdes  		= new CTableTexte(array('id'=>$email['id_text']));
	$texte   		= $tdes->select_row();
	
	$body = CNmail::build_html_body($texte['style'], CFunction::stripslashes($text));
	
	$arr_pj = explode("|", @$email['pj']);
	
	if(CMail::send_mail($email['expediteur'], stripslashes($email['nom']), $body, $email['expediteur'], $arr_pj, 'Bcc: ' . $liste_email)) {
		//save
		$obj = new CTableEmail(array('id'=>$email['id'], 'expediteur'=>$email['expediteur'], 'destinataire'=>$email['destinataire'], 'nom'=>addslashes($email['nom']), 'text'=>addslashes($email['text']), 'pj'=>$email['pj'], 'etat'=>1, 'date'=>date("Y-m-d H:i:s")));
		$obj->update();
	}
	CFunction::print_r($email['destinataire']);
}

?>
Exemplo n.º 10
0
                        //----------------------------------------------------------------------------------------------
                        // AJOUT
                        //----------------------------------------------------------------------------------------------
                        ?>
                        <?php if($a == 4) { ?>
                        <form id="form_ajout" method="post" action="envoi.php" enctype="multipart/form-data">
                            <p> <?php echo CForm::get_hidden(44) ?> </p>
                            <fieldset>
                                <legend>Formulaire d'ajout d'email</legend>
                                <p>
                                    <label>Exp&eacute;diteur </label>
                                    <input name="expediteur" type="text" id="expediteur" value="<?php echo $expediteur ?>" readonly="true" />
                                    <?php echo  CHtml::get_msginfo($error_signe['expediteur'])?></p>
                             <?php
                             			// Envoi rapide
																	if (CMail::is_email ($destinataire)) { 
															?>
																<input type="hidden" name="isGr" value="<?=$bIsGr; ?>" />
                                <p>
                                    <label>Destinataire(s) </label>
																		<input type="text" name="destinataire" id="destinataire" value="" /><?php
																	}
																	else {
																		if ( strlen($destinataire) == 0 ){
																		// Planifier un envoi groupé
																	 ?>
						          					<p>
										          		<label>Type Groupe</label>
						          						<span style="font-size:12px">Groupe</span>  <input type="radio" id="groupe" name="isGr" value="0" <?php if ($bIsGr == 0) echo 'checked="checked"'; ?> onclick="javascript:location.href='<?= URL_RACINE; ?>adminpanther/src/envoi.php?a=4&isGr=0'" />
						          						<span style="font-size:12px">Groupe GR</span> <input type="radio" id="groupe_gr" name="isGr" value="1" <?php if ($bIsGr == 1) echo 'checked="checked"'; ?> onclick="javascript:location.href='<?= URL_RACINE; ?>adminpanther/src/envoi.php?a=4&isGr=1'" />
										          	</p>
Exemplo n.º 11
0
        case 'crdomain':
            list($acc['login'], $acc['domain']) = explode('@', $acc['LOGIN'], 2);
            $crCheckMailbox = CControllerClient::ExecuteEvent('OnMailControllerCheckMemberMailbox', array('DOMAIN' => $acc['domain'], 'NAME' => $acc['login']));
            if (isset($crCheckMailbox['result'])) {
                $unseen = intval($crCheckMailbox['result']);
            } else {
                $unseen = -1;
                $error = empty($crCheckMailbox['error']) ? GetMessage('INTR_MAIL_CONTROLLER_INVALID') : CMail::getErrorMessage($crCheckMailbox['error']);
            }
            break;
        case 'domain':
            $service = \Bitrix\Mail\MailServicesTable::getRowById($acc['SERVICE_ID']);
            list($acc['login'], $acc['domain']) = explode('@', $acc['LOGIN'], 2);
            $result = CMailDomain2::getUnreadMessagesCount($service['TOKEN'], $acc['domain'], $acc['login'], $error);
            if (is_null($result)) {
                $unseen = -1;
                $error = CMail::getErrorMessage($error);
            } else {
                $unseen = intval($result);
            }
            break;
    }
    CUserCounter::Set($userId, 'mail_unseen', $unseen, $siteId);
    CUserOptions::SetOption('global', 'last_mail_check_' . $siteId, time(), false, $userId);
    CUserOptions::SetOption('global', 'last_mail_check_success_' . $siteId, $unseen >= 0, false, $userId);
} else {
    $unseen = 0;
    CUserOptions::SetOption('global', 'last_mail_check_' . $siteId, -1, false, $userId);
}
header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET);
echo json_encode(array('result' => $error === false ? 'ok' : 'error', 'unseen' => $unseen, 'last_check' => CUserOptions::GetOption('global', 'last_mail_check_' . $siteId, false, $userId), 'error' => $error));
Exemplo n.º 12
0
function send_mail($destinataire, $sujet, $message, $expediteur, $arr_pj = array(), $headers="", $ct="text/html") {
  	  // instanciation de la classe
	  $mail = new CMail();
	  // parametres
	  $mail->to = $destinataire;
	  $mail->subject = $sujet;
	  $mail->body = $message;
	  $mail->from = $expediteur;
	  $mail->headers = $headers;
	  $mail->type;
	  // ouverture et lecture du fichier
	  if(!empty($arr_pj[0])) {
		  foreach($arr_pj as $url_file) {
			$file = file_get_contents($url_file);
			$mail->attach($file, basename($url_file));
		  }
	  }
	  // envoi du message
	  return ($mail->send());
} 
Exemplo n.º 13
0
<?php
include("../inc/init.php");
/*---------------------------------------------------------------------
		RECUPERATIONS
----------------------------------------------------------------------*/
$destinataire= (!empty($_GET['destinataire'])) 	? stripslashes($_GET['destinataire'])   : "";
$expediteur  = (!empty($_GET['expediteur'])) 	? stripslashes($_GET['expediteur']) 	: "";
$message  	 = (!empty($_GET['message'])) 		? stripslashes($_GET['message'])  		: "";
$sujet		 = "Un article intéressant";

/*---------------------------------------------------------------------
		INITIALISATION
----------------------------------------------------------------------*/
$msgerreur		= "<span class='erreur'>Erreur : Veuillez contacter le webmaster</span>";
$msgconfirm		= "Email bien envoy&eacute; &agrave; " . $destinataire;

/*---------------------------------------------------------------------
		ENVOI
----------------------------------------------------------------------*/
if(!CMail::send_mail($destinataire, $sujet, $message, $expediteur)) {
	$msginfo = $msgerreur;
} else {
	$msginfo = $msgconfirm;
}

/*---------------------------------------------------------------------
		CONFIRMATION
----------------------------------------------------------------------*/
echo $msginfo;
?>
Exemplo n.º 14
0
                                $toResult = @mysql_fetch_array($resResult);
                                if (((int)($toResult[0]))>0) {
                                    $zSql3 = "UPDATE retour_email SET retour_email_statut = '0', retour_email_lien='0' WHERE retour_email_id_email ='".$id."' AND retour_email_id_user ='******'";
                                    $resInsert = $bdd->update($zSql3);
                                }
                                else {
                                    $zSql3 = "INSERT INTO retour_email (retour_email_id_email,retour_email_id_user,retour_email_statut,retour_email_lien) VALUES ('".$id."', '".$zUser."', '0', '0')";
                                    $resInsert = $bdd->insert($zSql3);
                                }
                            }
                            if(!empty($_POST['text'])) $text = trim($_POST['text']);
                            $text = $text . '<p style="text-align: center;"><a href="'.URL_RACINE.'/adminpanther/src/email.php?id='.$id.'">Visualiser cette email comme page HTML</a></p>';
                            $text = $text .'<img src ="'.URL_RACINE.'/adminpanther/src/retour.php?id='.$resInsert.'" width="0" height="0" border="0"/>';
                            $text = $text . CDesinscription::insert_link();
                            $body = CNmail::build_html_body($style, CFunction::stripslashes($text));
                            if(!CMail::send_mailing($zEmail, $nom, $body, $expediteur, $arr_pj)) {
                                    //$msginfo = "Echec d'envoi d'email. Veuillez r&eacute;essayer ult&eacute;rieurement";
                                    break;
                            }
                        }
                    }
                    

                    $obj = new CTableEmail(array('id'=>$id, 'expediteur'=>CFunction::addslashes($expediteur), 'destinataire'=>CFunction::addslashes($destinataire), 'nom'=>CFunction::addslashes($nom), 'text'=>mysql_real_escape_string(CFunction::addslashes($body)), 'pj'=>CFunction::addslashes($pj), 'etat'=>1, 'date'=>date("Y-m-d H:i:s")));
                    if(!empty($id)) $obj->update(); else $obj->insert();
                    $obj->update();
                    $msginfo = "Email bien envoy&eacute;";
                }
                else /*($go == "Envoyer à la date pr&eacute;vue")*/ {
                    $obj = new CTableEmail(array('id'=>$id, 'expediteur'=>CFunction::addslashes($expediteur), 'destinataire'=>CFunction::addslashes($destinataire), 'nom'=>CFunction::addslashes($nom), 'text'=>CFunction::addslashes($body), 'pj'=>CFunction::addslashes($pj), 'etat'=>3, 'date'=>$date));
                    if(!empty($id)) $obj->update(); else $obj->insert();
Exemplo n.º 15
0
	if ($error_type > 0) {
		//erreur de type champ non valide
		$msginfo = "Champ non valide";
		$a = 5;
		break;
	}
	
	if($go == "Sauvegarder") {
		$obj = new CTableEmail(array('id'=>$id, 'expediteur'=>CFunction::addslashes($expediteur), 'destinataire'=>CFunction::addslashes($destinataire), 'nom'=>CFunction::addslashes($nom), 'text'=>CFunction::addslashes($text), 'pj'=>CFunction::addslashes($pj), 'date'=>$date));
		$obj->update();
		$msginfo = "Modification bien enregistr&eacute;e";
	}
	elseif($go == "Envoyer imm&eacute;diatement") {
		$arr_pj = explode("|", $pj);
		$text = $text . CDesinscription::insert_link();
		if(!CMail::send_mailing($liste_email, $nom, $text, $expediteur, $arr_pj)) {
			$msginfo = "Echec d'envoi d'email. Veuillez r&eacute;essayer ult&eacute;rieurement";
			break;
		}
		$obj = new CTableEmail(array('id'=>$id, 'expediteur'=>CFunction::addslashes($expediteur), 'destinataire'=>CFunction::addslashes($destinataire), 'nom'=>CFunction::addslashes($nom), 'text'=>CFunction::addslashes($text), 'pj'=>CFunction::addslashes($pj), 'etat'=>1, 'date'=>date("Y-m-d H:i:s")));
		$obj->update();
		$msginfo = "Email bien envoy&eacute;";
	}
	else /*($go == "Envoyer &agrave;  la date pr&eacute;vue")*/ {
		$obj = new CTableEmail(array('id'=>$id, 'expediteur'=>CFunction::addslashes($expediteur), 'destinataire'=>CFunction::addslashes($destinataire), 'nom'=>CFunction::addslashes($nom), 'text'=>CFunction::addslashes($text), 'pj'=>CFunction::addslashes($pj), 'etat'=>3, 'date'=>$date));
		$obj->update();	
		$msginfo = "Email mis en fil d'attente";
	}
	
	$a = 0;
	break;
Exemplo n.º 16
0
 private static function checkDomainStatus($settings, &$error)
 {
     if ($settings['type'] == 'domain') {
         $result = CMailDomain2::getDomainStatus($settings['token'], $settings['domain'], $error);
         if (is_null($result)) {
             $error = CMail::getErrorMessage($error);
         } else {
             if (!isset($result['stage']) || !in_array($result['stage'], array('owner-check', 'mx-check', 'added'))) {
                 $error = CMail::getErrorMessage(CMail::ERR_API_DENIED);
             }
         }
     } else {
         if ($settings['type'] == 'crdomain') {
             $result = null;
             $crResponse = CControllerClient::ExecuteEvent('OnMailControllerCheckMemberDomain', array('DOMAIN' => $settings['domain']));
             if (!isset($crResponse['result'])) {
                 $error = empty($crResponse['error']) ? GetMessage('INTR_MAIL_CONTROLLER_INVALID') : CMail::getErrorMessage($crResponse['error']);
             } else {
                 $result = $crResponse['result'];
                 if (!is_array($result)) {
                     $error = GetMessage('INTR_MAIL_CONTROLLER_INVALID');
                 } else {
                     if (!isset($result['stage']) || !in_array($result['stage'], array('owner-check', 'mx-check', 'added'))) {
                         $error = GetMessage('INTR_MAIL_CONTROLLER_INVALID');
                     } else {
                         if ($result['stage'] == 'owner-check' && (!isset($result['secrets']['name']) || !isset($result['secrets']['content']))) {
                             $error = GetMessage('INTR_MAIL_CONTROLLER_INVALID');
                         }
                     }
                 }
             }
         }
     }
     return $result;
 }
Exemplo n.º 17
0
 private static function executeManageDeleteMailbox(&$error)
 {
     $error = false;
     $userId = $_REQUEST['USER_ID'];
     if (!check_bitrix_sessid()) {
         $error = GetMessage('INTR_MAIL_CSRF');
     }
     if ($error === false) {
         $mailbox = CIntranetMailSetupHelper::getUserMailbox($userId);
         if (empty($mailbox) || !in_array($mailbox['SERVER_TYPE'], array('controller', 'domain', 'crdomain'))) {
             $error = GetMessage('INTR_MAIL_AJAX_ERROR');
         }
     }
     if ($error === false) {
         CMailbox::delete($mailbox['ID']);
         list($login, $domain) = explode('@', $mailbox['LOGIN'], 2);
         if ($mailbox['SERVER_TYPE'] == 'domain') {
             $domainService = CIntranetMailSetupHelper::getDomainService($mailbox['SERVICE_ID']);
             CMailDomain2::deleteUser($domainService['token'], $domain, $login);
         } else {
             if ($mailbox['SERVER_TYPE'] == 'crdomain') {
                 $crResponse = CControllerClient::ExecuteEvent('OnMailControllerDeleteMemberUser', array('DOMAIN' => $domain, 'NAME' => $login));
                 if (!isset($crResponse['result'])) {
                     $error = empty($crResponse['error']) ? GetMessage('INTR_MAIL_CONTROLLER_INVALID') : CMail::getErrorMessage($crResponse['error']);
                 }
             } else {
                 if ($mailbox['SERVER_TYPE'] == 'controller') {
                     $crResponse = CControllerClient::ExecuteEvent('OnMailControllerDeleteUser', array('DOMAIN' => $domain, 'NAME' => $login));
                     if (!isset($crResponse['result'])) {
                         $error = empty($crResponse['error']) ? GetMessage('INTR_MAIL_CONTROLLER_INVALID') : CMail::getErrorMessage($crResponse['error']);
                     }
                 }
             }
         }
         CUserCounter::Clear($userId, 'mail_unseen', $mailbox['LID']);
         CUserOptions::DeleteOption('global', 'last_mail_check_' . $mailbox['LID']);
         CUserOptions::DeleteOption('global', 'last_mail_check_success_' . $mailbox['LID']);
     }
     if ($error === false) {
         $create = '<a href="#" onclick="mb.create(' . intval($userId) . '); return false; ">' . GetMessage('INTR_MAIL_MANAGE_CREATE') . '</a>';
     }
     return array('result' => $error === false ? 'ok' : 'error', 'create' => isset($create) ? CharsetConverter::ConvertCharset($create, SITE_CHARSET, 'UTF-8') : '', 'error' => CharsetConverter::ConvertCharset($error, SITE_CHARSET, 'UTF-8'));
 }
Exemplo n.º 18
0
 function subscribe_finish()
 {
     set_time_limit(0);
     $aSendedID = array();
     $aReceivers = $this->db->select('SELECT I.user_id, U.user_id as id, U.login, U.password
                         FROM ' . TABLE_ITEMS . ' I, ' . TABLE_USERS . ' U
                         WHERE I.status = ' . ITEMS_STATUS_COMPLETED . ' AND I.user_id!=1
                             AND I.user_id = U.user_id
                             AND I.id NOT IN(
                                 39, 41, 70
                                 )
                         GROUP BY I.user_id
                         ORDER BY U.login ASC');
     //echo '<pre>', print_r($aReceivers, true), '</pre>'; exit;
     //        $aReceivers = array(
     //            array('id'=>1, 'login'=>'*****@*****.**', 'password'=>'x123')
     //        );
     # инициализируем класс рассылки
     $mailer = new CMail();
     $mailer->From = config::get('mail_noreply', BFF_EMAIL_NOREPLY);
     //"E-Mail адрес уведомлений" из настроек сайта
     # подготавливаем заголовок письма
     $mailer->FromName = 'ILove.zp.ua';
     $mailer->Subject = 'ILove.zp.ua - итоги акции!';
     $sTpl = nl2br($this->getMailTemplateContent('member_subscribe_open'));
     foreach ($aReceivers as $v) {
         if (func::IsEmailAddress($v['login'])) {
             # подготавливаем тело письма
             $mailer->AltBody = '';
             $mailer->MsgHTML(strtr($sTpl, array('{login}' => $v['login'], '{password}' => $v['password'])));
             # отправляем письмо
             $mailer->AddAddress($v['login']);
             if ($mailer->Send()) {
                 $aSendedID[] = $v['id'];
             }
             $mailer->ClearAddresses();
             usleep(150000);
             // sleep for 0.15 second
         }
     }
     echo sizeof($aReceivers), ' / ', sizeof($aSendedID), '<br/>';
     echo '<pre>', print_r($aSendedID, true), '</pre>';
     exit;
 }
Exemplo n.º 19
0
 public static function createMailbox($exists, $userId, $serviceId, $domain, $login, $password, &$error)
 {
     $error = false;
     if (intval($userId)) {
         $dbUser = CUser::getList($by = 'ID', $order = 'ASC', array('ID_EQUAL_EXACT' => intval($userId)), array('FIELDS' => 'ID'));
         if (!$dbUser->fetch()) {
             $error = GetMessage('INTR_MAIL_FORM_ERROR');
         }
     }
     if ($error === false) {
         $services = self::getMailServices();
         if (empty($services[$serviceId]) || !in_array($services[$serviceId]['type'], array('controller', 'domain', 'crdomain'))) {
             $error = GetMessage('INTR_MAIL_FORM_ERROR');
         }
     }
     if ($error === false) {
         $service = $services[$serviceId];
         if ($service['type'] == 'controller') {
             $crDomains = CControllerClient::ExecuteEvent('OnMailControllerGetDomains', array());
             $arDomains = empty($crDomains['result']) ? array() : $crDomains['result'];
             if (!is_array($arDomains) || !in_array($domain, $arDomains)) {
                 $error = CMail::getErrorMessage(CMail::ERR_API_OP_DENIED);
             }
         } else {
             if ($service['type'] == 'crdomain') {
                 $crDomains = CControllerClient::ExecuteEvent('OnMailControllerGetMemberDomains', array());
                 $arDomains = empty($crDomains['result']) ? array() : $crDomains['result'];
                 if (!is_array($arDomains) || !in_array($domain, $arDomains)) {
                     $error = CMail::getErrorMessage(CMail::ERR_API_OP_DENIED);
                 }
             } else {
                 if ($service['type'] == 'domain') {
                     if ($service['server'] != $domain) {
                         $error = GetMessage('INTR_MAIL_FORM_ERROR');
                     }
                 }
             }
         }
     }
     if ($error === false && !$exists) {
         if (!preg_match('/^[a-z0-9_]+(\\.?[a-z0-9_-]*[a-z0-9_]+)*?$/i', $login)) {
             $error = CMail::getErrorMessage(CMail::ERR_API_BAD_NAME);
         }
         if ($error === false) {
             if ($service['type'] == 'controller') {
                 $crResponse = CControllerClient::ExecuteEvent('OnMailControllerAddUser', array('DOMAIN' => $domain, 'NAME' => $login, 'PASSWORD' => $password));
                 if (!isset($crResponse['result'])) {
                     $error = empty($crResponse['error']) ? GetMessage('INTR_MAIL_CONTROLLER_INVALID') : CMail::getErrorMessage($crResponse['error']);
                 }
             } else {
                 if ($service['type'] == 'crdomain') {
                     $crResponse = CControllerClient::ExecuteEvent('OnMailControllerAddMemberUser', array('DOMAIN' => $domain, 'NAME' => $login, 'PASSWORD' => $password));
                     if (!isset($crResponse['result'])) {
                         $error = empty($crResponse['error']) ? GetMessage('INTR_MAIL_CONTROLLER_INVALID') : CMail::getErrorMessage($crResponse['error']);
                     }
                 } else {
                     if ($service['type'] == 'domain') {
                         $result = CMailDomain2::addUser($service['token'], $domain, $login, $password, $error);
                         if (is_null($result)) {
                             $error = CMail::getErrorMessage($error);
                         }
                     }
                 }
             }
         }
     }
     if ($error === false && intval($userId)) {
         if ($exists) {
             if ($service['type'] == 'controller') {
                 $crCheckMailbox = CControllerClient::ExecuteEvent('OnMailControllerCheckMailbox', array('DOMAIN' => $domain, 'NAME' => $login));
                 if (!isset($crCheckMailbox['result'])) {
                     $error = empty($crCheckMailbox['error']) ? GetMessage('INTR_MAIL_CONTROLLER_INVALID') : CMail::getErrorMessage($crCheckMailbox['error']);
                 }
             }
             if ($error === false) {
                 $dbMailbox = CMailbox::getList(array('TIMESTAMP_X' => 'ASC'), array('ACTIVE' => 'Y', '!USER_ID' => intval($userId), '=LOGIN' => $login . '@' . $domain));
                 if (($mailbox = $dbMailbox->fetch()) && $mailbox['USER_ID']) {
                     $error = GetMessage('INTR_MAIL_MAILBOX_OCCUPIED');
                 }
             }
         }
         if ($error === false) {
             $mailbox = self::getUserMailbox($userId);
             if (!empty($mailbox)) {
                 $res = CMailbox::delete($mailbox['ID']);
             }
             $arFields = array('LID' => SITE_ID, 'ACTIVE' => 'Y', 'SERVICE_ID' => $serviceId, 'NAME' => $service['name'], 'LOGIN' => $login . '@' . $domain, 'SERVER_TYPE' => $service['type'], 'USER_ID' => intval($userId));
             $res = CMailbox::add($arFields);
             if (!$res) {
                 $error = GetMessage('INTR_MAIL_SAVE_ERROR');
             }
         }
     }
     if ($error === false) {
         return $login . '@' . $domain;
     }
 }
Exemplo n.º 20
0
 function ajax()
 {
     if (bff::$isAjax) {
         switch (func::GETPOST('act')) {
             case 'subscribe':
                 /*
                  * При подписке:
                  * - email выступает в дальнейшем в качестве логина
                  * - пароль генерируется автоматически
                  */
                 $sName = $this->input->post('name', TYPE_NOHTML);
                 $sEmail = mb_strtolower($this->input->post('email', TYPE_NOHTML));
                 $response = '';
                 do {
                     if (empty($sEmail) || !func::IsEmailAddress($sEmail)) {
                         $response = 0;
                         break;
                         // некорректно указан email
                     }
                     $isSubscribed = $this->db->one_data('SELECT user_id FROM ' . TABLE_USERS . ' WHERE login='******'email' - для рассылки, 'login' - для авторизации
                     $nUserID = $this->userCreate(array('login' => $sEmail, 'email' => $sEmail, 'password' => $sPassword, 'name' => $sName, 'subscribed' => 1, 'ip_reg' => func::getRemoteAddress(true)), self::GROUPID_MEMBER);
                     if ($nUserID) {
                         $response = 1;
                         // успешно подписались
                         # высылаем письмо (ставим в очередь на рассылку)
                         CMail::SendQueue('subscribe', array('user_id' => $nUserID));
                     } else {
                         $response = 4;
                         // системная ошибка
                     }
                 } while (false);
                 $this->ajaxResponse(array('result' => $response));
                 break;
             case 'enter':
                 if ($this->security->isLogined()) {
                     $this->ajaxResponse(array('result' => 'login-ok'));
                 }
                 $aData = $this->input->postm(array('email' => TYPE_STR, 'pass' => TYPE_STR, 'reg' => TYPE_BOOL));
                 if (!func::IsEmailAddress($aData['email'])) {
                     $this->errors->set('wrong:email');
                     break;
                     //email не корректный
                 }
                 if ($this->security->checkBan(false, func::getRemoteAddress(), $aData['email'], true)) {
                     $this->errors->set(Errors::ACCESSDENIED);
                     break;
                     //не прошли бан-фильтр
                 }
                 if ($aData['reg']) {
                     //регистрация
                     if (empty($aData['pass']) || strlen($aData['pass']) < 3) {
                         $this->errors->set('password_short');
                         break;
                         //пароль слишком короткий
                     }
                     $aData['email_hash'] = func::getEmailHash($aData['email']);
                     if ($this->isEmailExists($aData['email_hash'])) {
                         $this->errors->set('email_exist');
                         break;
                         //email уже занят
                     }
                     $this->getActivationInfo($sCode, $sLink);
                     $nUserID = $this->userCreate(array('login' => $aData['email'], 'email' => $aData['email'], 'email_hash' => $aData['email_hash'], 'password' => $aData['pass'], 'ip_reg' => Func::getRemoteAddress(true), 'activatekey' => $sCode, 'activated' => 0), self::GROUPID_MEMBER);
                     if ($nUserID) {
                         //$this->userAUTH($aData['email'], $aData['pass'], null, true);
                         $res = bff::sendMailTemplate(array('password' => $aData['pass'], 'email' => $aData['email'], 'activate_link' => "<a href=\"{$sLink}\">{$sLink}</a>"), 'member_registration', $aData['email']);
                         $this->ajaxResponse(array('result' => 'reg-ok'));
                     } else {
                         $this->ajaxResponse(Errors::IMPOSSIBLE);
                     }
                 } else {
                     //авторизация
                     $nResult = $this->userAUTH($aData['email'], $aData['pass'], null, true);
                     if ($nResult == 1) {
                         //$this->security->setRememberMe('u', $aData['email'], $aData['pass']);
                         bff::i()->Bbs_getFavorites(true);
                         $bReload = false;
                         if (!empty($_SERVER['HTTP_REFERER'])) {
                             if (stripos($_SERVER['HTTP_REFERER'], '/item/') !== FALSE || stripos($_SERVER['HTTP_REFERER'], '/items/fav') !== FALSE) {
                                 $bReload = true;
                             }
                         }
                         $userMenu = $this->tplFetch('user.menu.tpl');
                         $this->ajaxResponse(array('result' => 'login-ok', 'usermenu' => $userMenu, 'reload' => $bReload));
                     } else {
                         $mResponse = null;
                         switch ($nResult) {
                             case 0:
                                 $this->errors->set('email_or_pass_incorrect');
                                 break;
                             case -3:
                                 $this->errors->set('activate_first');
                                 break;
                                 //активируйте ваш аккаунт
                             //активируйте ваш аккаунт
                             case -2:
                                 $this->errors->set(Errors::ACCESSDENIED);
                                 break;
                                 //удален
                         }
                         if (is_array($nResult)) {
                             if ($nResult['res'] == -1) {
                                 $this->errors->set('Аккаунт заблокирован.' . (!empty($nResult['reason']) ? ' <br/><b>Причина:</b>' . nl2br($nResult['reason']) : ''));
                             }
                         }
                     }
                 }
                 break;
         }
     }
     $this->ajaxResponse(null);
 }
Exemplo n.º 21
0
session_start();

if (!CCaptcha::testCode($code)) {
	echo 'NOT_SECURE';
	exit(0);
}
  
/*---------------------------------------------------------------------
		ENVOI
----------------------------------------------------------------------*/

$reception_form = CConfiguration::get_valeur('RECEPT_FORM_AUTO', 'non');
$reception_mail = CConfiguration::get_valeur('RECEPT_MAIL_AUTO', 'non');

if($reception_mail == 'oui') {
	if(!CMail::send_mail($destinataire, $sujet, CNmail::build_html_body('p { margin: 15px;}', $message), $expediteur)) {
		$msginfo = $msgerreur;
	} else {
		$msginfo = $msgconfirm;
	}
}
if($reception_form == 'oui'){
	$sql = "INSERT INTO email(id, nom, text, exp_nom, exp_prenom, expediteur, destinataire, date, imap) VALUES ";
	$sql.= "(null, '". CFunction::force_encode(addslashes($sujet)) . "', '" . CNmail::build_html_body('p { margin: 15px;}',addslashes($message)) . "', '". CFunction::force_encode(addslashes($nom)) . "', '". CFunction::force_encode(addslashes($prenom)) . "', '". $expediteur . "', '". $destinataire . "', '". date('Y-m-d H:i:s') . "', '')";
	
	//echo $sql;
	
	if(CBdd::insert($sql)) {
		$msginfo = $msgconfirm;		
		
		/**/
Exemplo n.º 22
0
        $iEmailId = $obj->insert();
        
        // MAIL EN HTML
        
        $pj = ($radioPiece) ? $toEnvoyes['piece'] : '' ;
        $text = $texte['text'] ;
        
        $arr_pj = explode("|", $pj);
		
		$text = $text . '<p style="text-align: center;"><a href="'.URL_RACINE.'/adminpanther/src/email.php?id=' . $iEmailId . '">Visualiser cette email comme page HTML</a></p>';
		
		$text = $text . CDesinscription::insert_link();
		
		$body = CNmail::build_html_body($texte['style'], CFunctions::stripslashes($text));
		
		if(!CMail::send_mailing($liste_email, $texte['nom'], $body, $expediteur, $arr_pj)) {
			$msginfo = "Echec d'envoi d'email. Veuillez r&eacute;essayer ult&eacute;rieurement";
			break;
		}		
		
		$obj = new CTableEmail(array('id'=>$iEmailId, 'expediteur'=>CFunctions::addslashes($expediteur), 'destinataire'=>CFunctions::addslashes($destinataire), 'nom'=>CFunctions::addslashes($texte['nom']), 'text'=>mysql_real_escape_string(CFunctions::addslashes($body)), 'pj'=>CFunctions::addslashes($pj), 'etat'=>1, 'date'=>date("Y-m-d H:i:s")));
		if(is_numeric($iEmailId)) $obj->update(); else $obj->insert();
		$obj->update();
		$msginfo = "Email bien envoy&eacute;<br/>";
    }
    // FIN ENVOI MAIL
	
	$msginfo = "user bien modifi&eacute;";
	$a = 0;
	break;
	
Exemplo n.º 23
0
<?php

$_SESSION_HASH = $_FF_SESSION->value('sess_hash');
$mail =& CMail::getInstance();
$user =& CUser::getInstance();
$ecom =& new CEcom($_USER_ID, $_SESSION_HASH);
$user_data = $user->find($_USER_ID);
$order_id = $ecom->getCartID();
$redirect_success = isset($_POST['redirect_success']) ? $_POST['redirect_success'] : '/?action=cart.checkout.confirmation';
$redirect_failure = isset($_POST['redirect_failure']) ? $_POST['redirect_failure'] : '/?action=cart.view?e=declined';
if (!empty($_POST['i_ids'])) {
    $ids = !empty($_POST['i_ids']) ? $_POST['i_ids'] : array();
    $quantities = !empty($_POST['i_quantities']) ? $_POST['i_quantities'] : array();
    $prices = !empty($_POST['i_prices']) ? $_POST['i_prices'] : array();
    $details = !empty($_POST['i_details']) ? $_POST['i_details'] : array();
    $ecom->addCartItems($ids, $quantities, $prices, $details);
}
$cart_data = $ecom->getCartItems();
if (isset($_POST['s_nameFull'])) {
    $rpos = strrpos($_POST['s_nameFull'], ' ');
    $ship_f_name = substr($_POST['s_nameFull'], $rpos);
    $ship_l_name = substr($_POST['s_nameFull'], 0, $rpos);
    $ship_address = $_POST['s_address'];
    $ship_city = $_POST['s_city'];
    $ship_state = $_POST['s_state'];
    $ship_zip = $_POST['s_zip'];
    $shipping = $_POST['s_shipping'];
    $do_shipping = true;
} else {
    $ship_f_name = '';
    $ship_l_name = '';
Exemplo n.º 24
0
* Период выполнения: каждые 15 минут
*/
$log = new CFileLogger(PATH_BASE . 'files/logs/', 'cron.log');
$log->log('bbs.items.comments.enotify: started...');
$oBff->GetModule('bbs');
//echo "start\r\n";
$oDb->execute('START TRANSACTION');
$aNotify = $oDb->select('SELECT EN.*
    FROM ' . TABLE_BBS_ITEMS_COMMENTS_ENOTIFY . ' EN
    WHERE EN.sended = 0
    ORDER BY EN.created
    LIMIT 100 
    FOR UPDATE');
// <- lock пока не разошлём письма (100)
if (!empty($aNotify)) {
    $mail = new CMail();
    $tpl = $oBff->Sendmail_getMailTemplate('bbs_comments_notify');
    foreach ($aNotify as $v) {
        try {
            $mail->From = BFF_EMAIL_NOREPLY;
            $mail->FromName = BFF_EMAIL_FROM_NAME;
            $mail->Subject = $tpl['subject'];
            $mail->AltBody = '';
            $mail->MsgHTML(nl2br(strtr($tpl['body'], array('{item_id}' => $v['item_id'], '{item_url}' => SITEURL . '/item/' . $v['item_id'], '{item_comment_url}' => SITEURL . '/item/' . $v['item_id'] . '?comments=1', '{comment}' => $v['comment']))));
            $mail->AddAddress($v['email']);
            $res = $mail->Send() ? 1 : 0;
            if ($res) {
                $aNotifyID[] = $v['id'];
            }
            $mail->ClearAddresses();
        } catch (Exception $e) {
Exemplo n.º 25
0
 function flag($id, $u_id, $session_id)
 {
     $id_safe = $this->dbh->sql_safe($id);
     $u_id_safe = $this->dbh->sql_safe($u_id);
     $session_id_safe = $this->dbh->sql_safe($session_id);
     $sql = "SELECT COUNT(*) as _count FROM foto_objectionable WHERE fo_up_id = " . $id_safe . " AND fo_us_hash = " . $session_id_safe;
     $ar = $this->dbh->query_first($sql);
     if ($ar['_count'] == 0) {
         $sql_insert = "INSERT INTO foto_objectionable (fo_up_id, fo_us_hash, fo_dateCreated) VALUES (" . $id_safe . ", " . $session_id_safe . ", NOW())";
         $this->dbh->execute($sql_insert);
     }
     $sql = "SELECT COUNT(*) as _count FROM foto_objectionable WHERE fo_up_id = " . $id_safe;
     $ar = $this->dbh->query_first($sql);
     if ($ar['_count'] > 2) {
         $sql_insert = "INSERT INTO foto_quarantined (fq_up_id, fq_dateCreated) VALUES (" . $id_safe . ", NOW())";
         $this->dbh->execute($sql_insert);
         $this->violation($id, $u_id);
         $sql_delete = "DELETE FROM foto_objectionable WHERE fo_up_id = " . $id_safe;
         $this->dbh->execute($sql_delete);
         include_once PATH_CLASS . '/CMail.php';
         $cm =& CMail::getInstance();
         $to = '*****@*****.**';
         $subject = 'Foto Quarantined';
         $message = 'This foto has been quarantined.  Foto ID: ' . $id . ', User ID: ' . $u_id;
         $headers = 'From: kevin@fotoflix.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
         $cm->send($to, $subject, $message, $headers);
     }
 }
Exemplo n.º 26
0
} else if($submit == "changemail") {
	$email = $pc->POSTisSetOrSetDefault('email');
	$email = $mysqli->real_escape_string($email);
	
	$query = <<< EOD
	CALL {$spUpdateEmail}('{$userId}', '{$email}', @pRowsAffected);
	SELECT @pRowsAffected AS rowsAffected;
EOD;
	
	$res = $db->performDirectMultiQuery($query);
	$db->getAndStoreResults($result);
	$row = $result[1]->fetch_object();
	
	if($row->rowsAffected == 1) {
	
		$mail = new CMail();
		$to = $email;
		$from = "*****@*****.**";
		$subject = "Ny mailadress registrerad";
		$message = <<< EOD
Välkommen,
Din nya mailadress är registrerad.

MVH
Dolphin

EOD;
		$success = $mail->SendMail($to, $from, $subject, $message);
		
		if($success) {
			$_SESSION['errorMessage'] = "Lyckades med att skicka mail till " . $email;
Exemplo n.º 27
0
	/** Generation de l'email a envoyer pour un destinataire
	 * @param Array _tzData Donnees de l'email
	 */
	function generateAndSend ($_tzData) {
		global $giNbSent;
		$zStr = 'pj';
		$arr_pj = explode ("|", $_tzData[$zStr]);

		$zStr = 'destinataire';
		$liste_email = $_tzData[$zStr];
		if (!is_email($liste_email)) {
			$liste_email = get_liste_email($liste_email,$_tzData['type_envoi']);
		}

		$zStr = 'nom';
		$zStr1 = 'expediteur';
		$zStr2 = 'id';

		$tzEmail = explode (",", $liste_email);
		print "\n\n------------------- INSERT INTO TABLE envoi " . $_tzData[$zStr2] . " -------------------------\n";
		print_r ($tzEmail);
		foreach ($tzEmail AS $iIndex => $zEmail) {
		//-- Ne plas sauvegarder les emails déjà sauvegardé
			$zQuery = "SELECT etat FROM envoi WHERE id_envoi = " . $_tzData[$zStr2] . " AND email = '" . $zEmail . "'";
			if ($tiCount = mysql_fetch_assoc (mysql_query ($zQuery))) {
				if ($tiCount['etat'] == 1) {
					unset ($tzEmail[$iIndex]);
				}
				continue;
			}
		//-- Sauvegarder en base les adresses email à envoyer de l'envoi
			$zQuery = "INSERT INTO envoi (id_envoi, email, etat) VALUES (" . $_tzData[$zStr2] . ", '" . $zEmail . "', 0)";
			mysql_query ($zQuery);
		}
		
		print "\n\n------------------- SEND EMAILS " . $_tzData[$zStr2] . " -------------------------\n";
		print_r ($tzEmail);
		$str_repl = 1;

		$zStr_txt = 'text';
		$zStr_id = 'id';
		$text_init = $_tzData[$zStr_txt];		// Le corps du message initial
			
		foreach ($tzEmail AS $zEmail) {

			// Traitement du lien si le client clique dessus
			$text = str_replace('href="','href="' . URL_RACINE . 'adminpanther/src/redirection.php?a=' . $_tzData[$zStr_id] . '&m=' . $zEmail . '&u=', $text_init);
			if($text == $text_init){
				$text = str_replace('href=\"','href=\"' . URL_RACINE . 'adminpanther/src/redirection.php?a=' . $_tzData[$zStr_id] . '&m=' . $zEmail . '&u=', $text_init);
			}
			

			$text .= '<p style="text-align: center;"><a href="' . URL_RACINE . 'adminpanther/src/email.php?id=' . $_tzData[$zStr_id] . '&m='.$zEmail.'">Visualiser cette email comme page HTML</a></p>';
			$text .= '<img src="' . URL_RACINE . 'adminpanther/src/email.php?id=' . $_tzData[$zStr_id] . '&m='.$zEmail.'" style="width:1px; height:1px;" frameborder="0" />';
//			$text .= '<iframe src="' . URL_RACINE . 'adminpanther/src/email.php?id=' . $_tzData[$zStr_id] . '&m='.$zEmail.'" style="width:1px; height:1px; display: none; width: 1px;" />';
	
			$text .= insert_link($_tzData[$zStr_id]);
      $body = CNmail::build_html_body('', stripslashes($text));
      
      if(!CMail::send_mailing($zEmail, $_tzData[$zStr], $body, $_tzData[$zStr1], $arr_pj)) {
        // $msginfo = "Echec d'envoi d'email. Veuillez r&eacute;essayer ult&eacute;rieurement";
        break;
      }

		//-- Marquer l'email comme envoye a l'adresse
			$zQuery = "UPDATE envoi SET etat = 1 WHERE id_envoi = " . $_tzData[$zStr2] . " AND email = '" . $zEmail . "'";
			mysql_query ($zQuery);
			$giNbSent ++;
			if ($giNbSent == ENVOI_NB_EMAILS_MAXI) {
				break;
			}
		}
	}