Subversion Repositories Sites.obs-saisons.fr

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 aurelien 1
<?php
2
 
3
//vim: set expandtab tabstop=4 shiftwidth=4:
4
// +-----------------------------------------------------------------------------------------------+
5
// | PHP version 4.0                                                                               |
6
// +-----------------------------------------------------------------------------------------------+
7
// | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group                                      |
8
// +-----------------------------------------------------------------------------------------------+
9
// | This source file is subject to version 2.0 of the PHP license,                                |
10
// | that is bundled with this package in the file LICENSE, and is                                 |
11
// | available at through the world-wide-web at                                                    |
12
// | http://www.php.net/license/2_02.txt.                                                          |
13
// | If you did not receive a copy of the PHP license and are unable to                            |
14
// | obtain it through the world-wide-web, please send a note to                                   |
15
// | license@php.net so we can mail you a copy immediately.                                        |
16
// +-----------------------------------------------------------------------------------------------+
17
/**
18
*
19
*Page permettant l'affichage des informations de cartographie des inscrits
20
*
21
*@package cartographie
22
//Auteur original :
23
*@author                Alexandre GRANIER <alexandre@tela-botanica.org>
24
//Autres auteurs :
25
*@copyright         Tela-Botanica 2000-2004
26
*@version             03 mai 2004
27
// +-----------------------------------------------------------------------------------------------+
28
//
29
// $Id: car_cartographie.fonct.php,v 1.4 2005/03/11 17:27:23 alex Exp $
30
// FICHIER : $RCSfile: car_cartographie.fonct.php,v $
31
// AUTEUR    : $Author: alex $
32
// VERSION : $Revision: 1.4 $
33
// DATE        : $Date: 2005/03/11 17:27:23 $
34
*/
35
 
36
/** function carto_texte_cocher ()
37
*
38
*
39
*	@return string  HTML
40
*/
41
 
42
function carto_texte_cocher () {
43
    $res = '<p class="cocher">'.CAR_CHECK_UNCHECK ;
44
    $res .= '&nbsp;<input type="checkbox" name="selecttotal" onclick="javascript:setCheckboxes(\'formmail\');" />'.
45
			'</p>';
46
    return $res ;
47
}
48
/** function carto_formulaire ()
49
*
50
*
51
*
52
*	@return string  HTML
53
*/
54
function carto_formulaire ($titre_mail = '', $corps = '') {
55
    $res = '<div id="redaction">'."\n";
56
    $res .= '<div id="redaction_tete"></div>'."\n";
57
    $res .= '<h2 class="chapo">'.CAR_ENVOYER_MAIL.'</h2>'."\n";
58
    $res .= '<table id="formulaire_mail" border="0">'."\n".
59
			'	<tr>' .
60
			'		<td class="texte">'.CAR_SUJET.' :</td>'."\n".
61
			'		<td><input class="forml" type="text" name="titre_mail" size="60" value="'.$titre_mail.'" /></td>'."\n".
62
			'	</tr>'."\n".
63
			'	<tr>'."\n".
64
			'		<td class="texte" valign="top">'.CAR_MESSAGE.'&nbsp;:&nbsp;</td>'."\n".
65
			'		<td><textarea class="forml" name="corps" rows="5" cols="60">'.$corps.'</textarea></td>'."\n".
66
			'	</tr>'."\n".
67
			'	<tr>'."\n".
68
			'		<td>&nbsp;</td>'."\n".
69
			'		<td>';
70
    if (ereg('Gecko', $GLOBALS['HTTP_USER_AGENT'])) {
71
        $res.= '<input class="spip_bouton" type="submit" value="'.CAR_ENVOYER.'" />';
72
    } else {
73
        $res .= '<input class="spip_bouton" type="submit" onclick="javascript:confirmer();" value="'.CAR_ENVOYER.'" />';
74
    }
75
    $res .=	'		</td>'."\n".
76
    		'	</tr>'."\n".
77
    		'</table>'."\n".
78
    		'<div id="redaction_pied"/></div>'."\n".
79
    		'</div>'."\n".
80
    		'</form>'."\n";
81
    $res .= '<p class="attention surveillance">'.CAR_SURVEILLANCE.'</p>' ;
82
    $res .= '<p class="information message_a_tous">'.sprintf(CAR_MESSAGE_A_TOUS, '<a href="'.CAR_URL_ACTUALITE.'">'.CAR_ACTUALITE.'</a>').'</p>' ;
83
 
84
    return $res ;
85
}
86
 
87
/**
88
 *  La fonction carto_getNbInscrits renvoit une phrase complete indiquant le
89
 *  nombre d'inscrits dans zone passee en argument
90
 *  @param  string  identifiant de carte ex: europe
91
 * @return string
92
 */
93
 
94
function carto_ad_consulterNbreInscrits ($id_carte)
95
{
96
    global $NOM_FICHIER;
97
 
98
    $titre_carte = carto_consulterTitreCarte($id_carte);
99
    $type_zone_carte = carto_consulterTypeZoneCarte ($id_carte);
100
 
101
    switch ($type_zone_carte){
102
        case '0' :
103
            $requete =
104
                    ' SELECT count('.CAR_CHAMPS_ID.') as nbr'.
105
                    ' FROM '.CAR_ANNUAIRE.
106
                    ' WHERE '.CAR_CHAMPS_DPT.' <> 999';
107
                break;
108
 
109
        case '1' :
110
            $requete =
111
                    ' SELECT count('.CAR_CHAMPS_ID.') as nbr'.
112
                    ' FROM '.CAR_ANNUAIRE.', '.CAR_TABLE_PAYS.
113
                    ' WHERE '.CAR_CHAMPS_CE_PAYS.' = cp_id_pays'.
114
                    ' AND cp_id_continent = "'.carto_consulterIdZoneGeoCarte ($id_carte).'"';
115
                break;
116
 
117
        case '2' :
118
            $requete =
119
                    ' SELECT count('.CAR_CHAMPS_ID.') as nbr'.
120
                    ' FROM '.CAR_ANNUAIRE.''.
121
                    ' WHERE '.CAR_CHAMPS_DPT.' != "999"'.
122
                    ' AND '.CAR_CHAMPS_CE_PAYS.' = "fr"';
123
                break;
124
    }
125
    if (defined('SQL_SUPPLEMENTAIRE') && SQL_SUPPLEMENTAIRE != '') {
126
		$requete .= ' AND '.SQL_SUPPLEMENTAIRE.' ';
127
	}
128
    $resultat = mysql_query($requete) or die('
129
            <H2 style="text-align: center; font-weight: bold; font-size: 26px;">Erreur de requête</H2>'.
130
            '<b>Nom du fichier : </b> '.$NOM_FICHIER.'<br/>'.
131
            '<b>Nom fonction : </b> carto_ad_consulterNbreInscrits<br/>'.
132
            '<b>Requete : </b>'.$requete.
133
            '<br/><br/><b>Erreur : </b>'.mysql_error());
134
 
135
    $ligne = mysql_fetch_object ($resultat) ;
136
    $res = '<h1 class="titre1_cartographie">'.$titre_carte.' : ' ;
137
    if ($ligne->nbr == 0) {
138
        $res .= 'aucun inscrit' ;
139
    }
140
    else if ($ligne->nbr == 1) {
141
        $res .= $ligne->nbr.' inscrit' ;
142
    }
143
    else {
144
        $res .= $ligne->nbr.' inscrits ';
145
    }
146
    return $res.' &agrave; l\'Observatoire des Saisons</h1>' ;
147
}
148
 
149
/**
150
 *  Envoie un email à tous les adhérents sélectionnés
151
 *
152
 * @return  string  Renvoie le message 'votre message a été envoyé'
153
 */
154
 
155
function envoie_mail (&$db) {
156
    $res = "<h3>".CAR_MAIL_ENVOYER."</h3>\n" ;
157
    $requete = "select ".CAR_CHAMPS_MAIL." from ".CAR_ANNUAIRE.
158
            " where ".CAR_CHAMPS_ID."='".$GLOBALS['car_auth']->getAuthData (CAR_CHAMPS_ID)."'";
159
    $resultat = $db->query($requete);
160
    if (DB::isError($resultat)) {
161
        die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo());
162
    }
163
    $ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
164
    $entete = "From: <".$ligne[CAR_CHAMPS_MAIL].">\n";
165
 
166
    $_POST['corps'] .= CAR_TEXTE_FIN_MAIL;
167
    $_POST['corps'] = stripslashes($_POST['corps']) ;
168
    $liste = "" ;
169
    foreach ($_POST['select'] as $key => $value) {
170
        mail($value, CAR_PREFIXE_MAIL.stripslashes($_POST['titre_mail']), $_POST['corps'], $entete) ;
171
        $liste .= $value."\n" ;
172
    }
173
 
174
    $_POST['corps'] .= "\n----------------------------------------------------------------------------";
175
    $_POST['corps'] .= "\n".CAR_MESSAGE_APPLI."\n" ;
176
    $_POST['corps'] .= "\n".CAR_MESSAGE_ENVOYE_A.":\n $liste" ;
177
 
178
    // Envoie du message aux administrateurs
179
	foreach ($GLOBALS['mail_admin'] as $courriel) {
180
		if (!mail($courriel, CAR_PREFIXE_MAIL.'[Administration] '.stripslashes($_POST['titre_mail']), $_POST['corps'], $entete)) {
181
			trigger_error("Le courriel n'a pas été envoyé à : $courriel", E_USER_WANRNING);
182
		}
183
	}
184
 
185
 
186
 
187
    $_POST['corps']='';
188
    $_POST['titre_mail']='';
189
    return $res ;
190
}
191
 
192
?>