Subversion Repositories Sites.tela-botanica.org

Rev

Rev 372 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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