Subversion Repositories Sites.tela-botanica.org

Rev

Go to most recent revision | Details | 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
// +------------------------------------------------------------------------------------------------------+
41
 
42
include_once 'Mail.php' ;
43
include_once "Mail/mime.php" ;
44
 
45
// +------------------------------------------------------------------------------------------------------+
46
// |                                            CORPS du PROGRAMME                                        |
47
// +------------------------------------------------------------------------------------------------------+
48
 
49
//Test pour vérifier que la lettre ne sera pas vide
50
//Connexion a la base d'actu
51
 
52
// TODO : pas de données de configuration embarquées dans les programmes !!!!
53
mysql_connect ("localhost", "telabotap", "") ;
54
mysql_select_db ("tela_prod_spip_actu") ;
55
 
56
//Recherche d'articles de moins de 7 jours
57
$requete = "select * from `spip_articles` WHERE `date` >= DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY)" ;
58
$resultat = mysql_query ($requete) or die ("Echec") ;
59
//Si c'est vide on interrompt le script
60
if (mysql_num_rows ($resultat) == 0) {
61
    exit;
62
    }
63
 
64
//Récupération de la date du jour pour l'ajouter dans le sujet du mail
65
 
66
$traduction_mois[1] = 'Janvier';
67
$traduction_mois[2] = 'Février';
68
$traduction_mois[3] = 'Mars';
69
$traduction_mois[4] = 'Avril';
70
$traduction_mois[5] = 'Mai';
71
$traduction_mois[6] = 'Juin';
72
$traduction_mois[7] = 'Juillet';
73
$traduction_mois[8] = 'Août';
74
$traduction_mois[9] = 'Septembre';
75
$traduction_mois[10] = 'Octobre';
76
$traduction_mois[11] = 'Novembre';
77
$traduction_mois[12] = 'Décembre';
78
 
79
$date_jour = date('j');
80
$date_mois = date('m');
81
$date_annee = date('Y');
82
//Pour traduire en français le nom de mois anglais obtenu par la fonction date
83
function traduction ($table,$mois){
84
    foreach ($table as $clef => $valeur) {
85
        if ($clef == $mois) {
86
            $resultat = $valeur;
87
        }
88
    }
89
    return($resultat);
90
}
91
 
92
$mois_francais = traduction ($traduction_mois,$date_mois);
93
//Préparation de la chaine de caractères a intégrer dans le sujet
94
$date_lettre = 'du '.$date_jour.' '.$mois_francais.' '.$date_annee;
95
 
96
//---------------------------------
97
 
98
$lettre_info_html = file_get_contents("http://www.tela-botanica.org/actu/lettre_info.php");
99
$lettre_info_txt = html_entity_decode(file_get_contents("http://www.tela-botanica.org/actu/lettre_info_txt.php"),ENT_QUOTES,"ISO-8859-15") ;
100
$crlf="\n";
101
 
102
$headers ['From'] = 'Association Tela Botanica <accueil@tela-botanica.org>' ;
103
$headers ['Subject'] = 'Lettre d\'information de Tela Botanica '.$date_lettre ;
104
$headers ['Reply-To'] = 'accueil@tela-botanica.org' ;
105
 
106
$mime = new Mail_mime($crlf);
107
 
108
$mime->setTXTBody($lettre_info_txt);
109
$mime->setHTMLBody($lettre_info_html);
110
 
111
$body = $mime->get();
112
$headers = $mime->headers($headers);
113
 
114
$mail = & Mail::factory ('mail') ;
115
 
116
$mail -> send ('actu@tela-botanica.org', $headers, $body) ;
117
 
118
if (PEAR::isError ($mail)) {
119
    echo 'erreur d\'envoi' ;
120
}
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
*/
144
 
145
 
146
 
147
?>