Subversion Repositories Sites.tela-botanica.org

Rev

Rev 372 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4 david 1
<?php
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */
3
// +------------------------------------------------------------------------------------------------------+
4
// | PHP version 4.1                                                                                      |
5
// +------------------------------------------------------------------------------------------------------+
6
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
7
// +------------------------------------------------------------------------------------------------------+
8
// | This library is free software; you can redistribute it and/or                                        |
9
// | modify it under the terms of the GNU Lesser General Public                                           |
10
// | License as published by the Free Software Foundation; either                                         |
11
// | version 2.1 of the License, or (at your option) any later version.                                   |
12
// |                                                                                                      |
13
// | This library is distributed in the hope that it will be useful,                                      |
14
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
15
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
16
// | Lesser General Public License for more details.                                                      |
17
// |                                                                                                      |
18
// | You should have received a copy of the GNU Lesser General Public                                     |
19
// | License along with this library; if not, write to the Free Software                                  |
20
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
21
// +------------------------------------------------------------------------------------------------------+
22
// CVS : $Id: envoi_mail.php,v 1.4 2005/02/18 13:35:02 david Exp $
23
/**
24
* Titre
25
*
26
* Description
27
*
28
*@package site_actu_tela
29
//Auteur original :
30
*@author        Alexandre GRANIER <alexandre@tela-botanica.org>
31
//Autres auteurs :
32
*@author        David Delon <david.delon@clapas.net>
33
*@copyright     Tela-Botanica 2000-2004
34
*@version       $Revision: 1.4 $ $Date: 2005/02/18 13:35:02 $
35
// +------------------------------------------------------------------------------------------------------+
36
*/
37
 
38
// +------------------------------------------------------------------------------------------------------+
39
// |                                            ENTETE du PROGRAMME                                       |
40
// +------------------------------------------------------------------------------------------------------+
372 jpm 41
include_once dirname(realpath(__FILE__)).'/../papyrus/configuration/pap_config_avancee.inc.php' ;
42
include_once dirname(realpath(__FILE__)).'/../papyrus/configuration/pap_config.inc.php' ;
4 david 43
 
295 jpm 44
include_once 'Mail.php';
45
include_once 'Mail/mime.php';
4 david 46
 
47
// +------------------------------------------------------------------------------------------------------+
48
// |                                            CORPS du PROGRAMME                                        |
49
// +------------------------------------------------------------------------------------------------------+
50
 
51
//Test pour vérifier que la lettre ne sera pas vide
52
//Connexion a la base d'actu
53
 
54
// TODO : pas de données de configuration embarquées dans les programmes !!!!
372 jpm 55
mysql_connect(PAP_BDD_SERVEUR, PAP_BDD_UTILISATEUR, PAP_BDD_MOT_DE_PASSE, true) or die('Impossible de se connecter à la base de données : '.mysql_error());
56
mysql_select_db('tela_prod_spip_actu');
4 david 57
 
58
//Recherche d'articles de moins de 7 jours
59
$requete = "select * from `spip_articles` WHERE `date` >= DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY)" ;
60
$resultat = mysql_query ($requete) or die ("Echec") ;
61
//Si c'est vide on interrompt le script
62
if (mysql_num_rows ($resultat) == 0) {
372 jpm 63
	exit;
64
}
4 david 65
 
66
//Récupération de la date du jour pour l'ajouter dans le sujet du mail
67
$traduction_mois[1] = 'Janvier';
587 david 68
$traduction_mois[2] = 'Fevrier';
4 david 69
$traduction_mois[3] = 'Mars';
70
$traduction_mois[4] = 'Avril';
71
$traduction_mois[5] = 'Mai';
72
$traduction_mois[6] = 'Juin';
73
$traduction_mois[7] = 'Juillet';
587 david 74
$traduction_mois[8] = 'Aout';
4 david 75
$traduction_mois[9] = 'Septembre';
76
$traduction_mois[10] = 'Octobre';
77
$traduction_mois[11] = 'Novembre';
587 david 78
$traduction_mois[12] = 'Decembre';
4 david 79
 
80
$date_jour = date('j');
81
$date_mois = date('m');
82
$date_annee = date('Y');
83
//Pour traduire en français le nom de mois anglais obtenu par la fonction date
84
function traduction ($table,$mois){
85
    foreach ($table as $clef => $valeur) {
86
        if ($clef == $mois) {
87
            $resultat = $valeur;
88
        }
89
    }
90
    return($resultat);
91
}
92
 
93
$mois_francais = traduction ($traduction_mois,$date_mois);
94
//Préparation de la chaine de caractères a intégrer dans le sujet
95
$date_lettre = 'du '.$date_jour.' '.$mois_francais.' '.$date_annee;
96
 
372 jpm 97
// +------------------------------------------------------------------------------------------------------+
4 david 98
 
99
$lettre_info_html = file_get_contents("http://www.tela-botanica.org/actu/lettre_info.php");
100
$lettre_info_txt = html_entity_decode(file_get_contents("http://www.tela-botanica.org/actu/lettre_info_txt.php"),ENT_QUOTES,"ISO-8859-15") ;
101
$crlf="\n";
102
 
103
$headers ['From'] = 'Association Tela Botanica <accueil@tela-botanica.org>' ;
104
$headers ['Subject'] = 'Lettre d\'information de Tela Botanica '.$date_lettre ;
105
$headers ['Reply-To'] = 'accueil@tela-botanica.org' ;
106
 
107
$mime = new Mail_mime($crlf);
108
 
109
$mime->setTXTBody($lettre_info_txt);
110
$mime->setHTMLBody($lettre_info_html);
111
 
112
$body = $mime->get();
113
$headers = $mime->headers($headers);
114
 
115
$mail = & Mail::factory ('mail') ;
116
 
117
$mail -> send ('actu@tela-botanica.org', $headers, $body) ;
118
 
119
if (PEAR::isError ($mail)) {
120
    echo 'erreur d\'envoi' ;
121
}
122
 
123
// +------------------------------------------------------------------------------------------------------+
124
// |                                           LISTE de FONCTIONS                                         |
125
// +------------------------------------------------------------------------------------------------------+
126
                                        /*Mettre ici la liste de fonctions.*/
127
 
128
 
129
// +------------------------------------------------------------------------------------------------------+
130
// |                                            PIED du PROGRAMME                                         |
131
// +------------------------------------------------------------------------------------------------------+
132
                                           /*Partie non obligatoire*/
133
 
134
 
135
/* +--Fin du code ----------------------------------------------------------------------------------------+
136
*
137
* $Log: envoi_mail.php,v $
138
* Revision 1.4  2005/02/18 13:35:02  david
139
* Lettre actu format text + html
140
*
141
*
142
* +-- Fin du code ----------------------------------------------------------------------------------------+
143
*/
372 jpm 144
?>