| [ Index ] |
|
Code source de phpMyVisites 2.3 |
1 <?php 2 /* 3 * phpMyVisites : website statistics and audience measurements 4 * Copyright (C) 2002 - 2006 5 * http://www.phpmyvisites.net/ 6 * phpMyVisites is free software (license GNU/GPL) 7 * Authors : phpMyVisites team 8 */ 9 10 // $Id: SendMail.class.php 82 2006-09-14 17:40:31Z matthieu_ $ 11 12 require_once INCLUDE_PATH."/core/include/ViewModule.class.php"; 13 require_once INCLUDE_PATH."/core/include/PmvConfig.class.php"; 14 require_once INCLUDE_PATH."/libs/Cache/Lite.php"; 15 require_once INCLUDE_PATH."/core/views/ViewVisitsRss.class.php"; 16 require_once INCLUDE_PATH."/core/include/myMailer.class.php"; 17 require_once INCLUDE_PATH."/core/include/UserConfigDb.class.php"; 18 19 class SendMail extends Module 20 { 21 var $defaultAction = "showAll"; 22 23 function SendMail() 24 { 25 parent::Module(); 26 } 27 28 function showAll() 29 { 30 $this->tpl->setMainTemplate("structure_mail.tpl"); 31 32 33 $this->request->setModuleName( 'view_visits_rss'); 34 $allSiteArchive = DataModel::getSites(); 35 36 /** 37 * Cache Lite 38 */ 39 $options = array( 40 'cacheDir' => DIR_CACHE_MAIL, 41 'lifeTime' => CACHE_MAIL_LIFETIME 42 ); 43 $Cache_Lite = new Cache_Lite($options); 44 45 46 $lang =& Lang::getInstance(); 47 48 // case update to 2.2RC1 without executing global info 49 if(!defined('INTERFACE_DEFAULT_LANG')) define('INTERFACE_DEFAULT_LANG', 'en-utf-8.php'); 50 51 $lang->setNewLang( INTERFACE_DEFAULT_LANG ); 52 53 /** 54 * Compute mails 55 */ 56 57 $o_config =& PmvConfig::getInstance(); 58 59 60 foreach($allSiteArchive as $infoSite) 61 { 62 63 /** 64 * php Mailer 65 */ 66 $mail = new MyMailer(); 67 $mail->IsHTML(true); 68 69 $imgUrl = INCLUDE_PATH . "/themes/default/images/phpmv.png"; 70 $mail->AddEmbeddedImage($imgUrl, "my-attach", $GLOBALS['lang']['logo_description'], "base64", "image/png"); 71 72 $uniqCacheId = md5(serialize($infoSite).date("Y-m-d")) . '.mail'; 73 74 // Test if thereis a valide cache for this id 75 if (true)//!$allData = $Cache_Lite->get($uniqCacheId)) 76 { 77 $o_mod = new ViewVisitsRss($infoSite); 78 $this->request->date=getDateFromTimestamp(time()- 86400); 79 $o_mod->init($this->request); 80 81 $dateLiteral = $o_mod->data->archive->getLiteralDate(); 82 83 $body = '<html xml:lang="fr" > 84 <head> 85 <meta http-equiv="content-type" content="text/html; charset=utf-8" /> 86 </head> 87 88 <body> 89 '; 90 91 $body .= $o_mod->showAll( true, true); 92 $body .= '</body></html>'; 93 $textBody = strip_tags($body); 94 95 $subject = vsprintf($GLOBALS['lang']['rss_titre'], 96 array($infoSite->getName(), $dateLiteral)); 97 98 print("<br>Subject : $subject<hr>"); 99 print("<br>Content : $body<hr>"); 100 101 //$Cache_Lite->save($body); 102 } 103 104 $mail->Subject = $subject; 105 $mail->Body = $body; 106 $mail->AltBody = $textBody; 107 $mail->CharSet = $GLOBALS['lang']['charset']; 108 109 110 $user = new UserConfigDb(); 111 $groups = $user->getGroups(); 112 113 $users = array_merge( 114 array( 115 0 => array( 'email' => SU_EMAIL, 116 'alias' => 'phpMyVisites Administrator', 117 'send_mail' => (SEND_MAIL=="yes" ? 1 : 0) 118 ), 119 ), 120 $user->getUserByGroup( 1, $infoSite->getId() ), 121 $user->getUserByGroup( 2, $infoSite->getId() ) 122 ); 123 124 // we send all emails once 125 126 $emailsToSend_infos = array( 127 'object' => $mail, 128 'to' => array( 129 // email, alias 130 ) 131 ); 132 133 // add recipients for the mail 134 foreach($users as $userInfo) 135 { 136 //print_r($userInfo); 137 138 if(!empty($userInfo['email']) && $userInfo['send_mail'] == 1) 139 { 140 $emailsToSend_infos['to'][] = array( $userInfo['email'], $userInfo['alias'] ); 141 } 142 } 143 144 $emailsToSend[] = $emailsToSend_infos; 145 } 146 147 // send all emails 148 foreach($emailsToSend as $currMail) 149 { 150 $mail =& $currMail['object']; 151 152 foreach($currMail['to'] as $recipient) 153 { 154 $mail->AddAddress($recipient[0], $recipient[1] ); 155 if(!@$mail->Send()) 156 { 157 echo "<u><b>There was an error sending the message to ".$userInfo['email']."</u></b><br>"; 158 } 159 else 160 { 161 echo "<u><b>Message was sent successfully to ".$userInfo['email']."</u></b><br>"; 162 } 163 $mail->ClearAddresses(); 164 } 165 } 166 } 167 } 168 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Mon Nov 26 14:10:01 2007 | par Balluche grâce à PHPXref 0.7 |
|