Changeset 230
- Timestamp:
- 25.11.2005 00:52:02 (3 years ago)
- Files:
-
- trunk (modified) (1 prop)
- trunk/.htaccess (deleted)
- trunk/includes (modified) (1 prop)
- trunk/includes/class.form.php (modified) (20 diffs)
- trunk/includes/engine_send.php (modified) (6 diffs)
- trunk/includes/functions.validate.php (modified) (1 diff)
- trunk/language/lang_francais.php (modified) (1 diff)
- trunk/newsletter.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk
- Property svn:ignore set to
.htaccess
- Property svn:ignore set to
trunk/includes
- Property svn:ignore set to
config.inc.php
- Property svn:ignore set to
trunk/includes/class.form.php
r216 r230 40 40 var $hasAccount = false; 41 41 var $isRegistered = false; 42 var $update_stats = false;43 42 var $message = ''; 44 43 45 function Wanewsletter($listdata) 46 { 47 $this->listdata = $listdata; 48 $this->liste_email = ( !empty($listdata['liste_alias']) ) ? $listdata['liste_alias'] : $listdata['sender_email']; 49 } 50 51 function account_info($email, $pseudo, $code, $action) 52 { 53 $email = trim($email); 54 $this->code = trim($code); 55 56 switch( $this->listdata['liste_format'] ) 57 { 58 case FORMAT_MULTIPLE: 59 if( $this->format != FORMAT_TEXTE && $this->format != FORMAT_HTML ) 44 var $mailer; 45 46 function Wanewsletter($listdata = null) 47 { 48 global $nl_config, $lang; 49 50 require WAMAILER_DIR . '/class.mailer.php'; 51 52 $mailer =& new Mailer(WA_ROOTDIR . '/language/email_' . $nl_config['language'] . '/'); 53 54 if( $nl_config['use_smtp'] ) 55 { 56 $mailer->smtp_path = WAMAILER_DIR . '/'; 57 $mailer->use_smtp( 58 $nl_config['smtp_host'], 59 $nl_config['smtp_port'], 60 $nl_config['smtp_user'], 61 $nl_config['smtp_pass'] 62 ); 63 } 64 65 $mailer->correctRpath = !is_disabled_func('ini_set'); 66 $mailer->set_charset($lang['CHARSET']); 67 $mailer->set_format(FORMAT_TEXTE); 68 $this->mailer =& $mailer; 69 70 if( isset($listdata) ) 71 { 72 switch( $listdata['liste_format'] ) 73 { 74 case FORMAT_MULTIPLE: 75 if( $this->format != FORMAT_TEXTE && $this->format != FORMAT_HTML ) 76 { 77 $this->format = FORMAT_TEXTE; 78 } 79 break; 80 81 case FORMAT_HTML: 82 case FORMAT_TEXTE: 83 $this->format = $listdata['liste_format']; 84 break; 85 86 default: 87 $this->format = FORMAT_TEXTE; 88 break; 89 } 90 91 $this->listdata = $listdata; 92 $this->liste_email = ( !empty($listdata['liste_alias']) ) ? $listdata['liste_alias'] : $listdata['sender_email']; 93 } 94 } 95 96 function check($action, $email) 97 { 98 global $db, $nl_config, $lang; 99 100 // 101 // Vérification syntaxique de l'email 102 // 103 if( Mailer::validate_email($email) == false ) 104 { 105 return array('error' => true, 'message' => $lang['Message']['Invalid_email']); 106 } 107 108 // 109 // Vérification de la liste des masques de bannissements 110 // 111 if( $action == 'inscription' ) 112 { 113 $sql = "SELECT ban_email 114 FROM " . BANLIST_TABLE . " 115 WHERE liste_id = " . $this->listdata['liste_id']; 116 if( $result = $db->query($sql) ) 117 { 118 while( $row = $db->fetch_array($result) ) 60 119 { 61 $this->format = FORMAT_TEXTE; 120 if( preg_match('/\b' . str_replace('*', '.*?', $row['ban_email']) . '\b/i', $email) ) 121 { 122 return array('error' => true, 'message' => $lang['Message']['Email_banned']); 123 } 62 124 } 63 break; 64 65 case FORMAT_HTML: 66 case FORMAT_TEXTE: 67 $this->format = $this->listdata['liste_format']; 68 break; 69 70 default: 71 $this->format = FORMAT_TEXTE; 72 break; 73 } 74 75 $result = check_email($email, $this->listdata['liste_id'], $action); 76 77 if( !$result['error'] ) 78 { 79 if( is_array($result['abodata']) ) 80 { 81 $this->hasAccount = true; 82 $this->isRegistered = isset($result['abodata']['confirmed']); 83 84 $this->account['abo_id'] = $result['abodata']['abo_id']; 85 $this->account['email'] = $result['abodata']['abo_email']; 86 $this->account['pseudo'] = $result['abodata']['abo_pseudo']; 87 $this->account['code'] = $result['abodata']['abo_register_key']; 88 $this->account['date'] = $result['abodata']['register_date']; 89 $this->account['format'] = $result['abodata']['format']; 90 $this->account['status'] = $result['abodata']['abo_status']; 125 } 126 } 127 128 $sql = "SELECT a.abo_id, a.abo_pseudo, a.abo_pwd, a.abo_email, a.abo_lang, a.abo_register_key, 129 a.abo_register_date, a.abo_status, al.format, al.register_key, al.register_date, al.confirmed 130 FROM " . ABONNES_TABLE . " AS a 131 LEFT JOIN " . ABO_LISTE_TABLE . " AS al ON al.abo_id = a.abo_id 132 AND al.liste_id = {$this->listdata['liste_id']} 133 WHERE LOWER(a.abo_email) = '" . $db->escape(strtolower($email)) . "'"; 134 if( !($result = $db->query($sql)) ) 135 { 136 return array('error' => true, 'message' => 'Impossible de tester les tables d\'inscriptions'); 137 } 138 139 if( $abodata = $db->fetch_array($result) ) 140 { 141 if( isset($abodata['confirmed']) ) 142 { 143 if( $action == 'inscription' && $abodata['confirmed'] == SUBSCRIBE_CONFIRMED ) 144 { 145 return array('error' => true, 'message' => $lang['Message']['Allready_reg']); 146 } 147 else if( $action == 'desinscription' && $abodata['confirmed'] == SUBSCRIBE_NOT_CONFIRMED ) 148 { 149 return array('error' => true, 'message' => $lang['Message']['Unknown_email']); 150 } 151 } 152 else if( $action != 'inscription' ) 153 { 154 return array('error' => true, 'message' => $lang['Message']['Unknown_email']); 155 } 156 } 157 else if( $action != 'inscription' ) 158 { 159 return array('error' => true, 'message' => $lang['Message']['Unknown_email']); 160 } 161 162 if( $nl_config['check_email_mx'] && $abodata === false ) 163 { 164 // 165 // Vérification de l'existence d'un Mail eXchanger sur le domaine de l'email, 166 // et vérification de l'existence du compte associé (La vérification de l'existence du 167 // compte n'est toutefois pas infaillible, les serveurs smtp refusant parfois le relaying, 168 // c'est à dire de traiter les demandes émanant d'un entité extérieure à leur réseau, et 169 // pour une adresse email extérieure à ce réseau) 170 // 171 if( $this->mailer->validate_email_mx($email) == false ) 172 { 173 return array('error' => true, 'message' => $lang['Message']['Unrecognized_email']); 174 } 175 } 176 177 if( is_array($abodata) ) 178 { 179 $this->hasAccount = true; 180 $this->isRegistered = isset($abodata['confirmed']); 181 182 $this->account['abo_id'] = $abodata['abo_id']; 183 $this->account['email'] = $abodata['abo_email']; 184 $this->account['pseudo'] = $abodata['abo_pseudo']; 185 $this->account['code'] = $abodata['register_key']; 186 $this->account['date'] = $abodata['register_date']; 187 $this->account['format'] = $abodata['format']; 188 $this->account['status'] = $abodata['abo_status']; 189 } 190 else 191 { 192 $this->hasAccount = false; 193 194 $this->account['abo_id'] = 0; 195 $this->account['email'] = $email; 196 $this->account['pseudo'] = ''; 197 $this->account['code'] = generate_key(20); 198 $this->account['date'] = time(); 199 $this->account['format'] = $this->format; 200 $this->account['status'] = ( $this->listdata['confirm_subscribe'] == CONFIRM_NONE ) ? ABO_ACTIF : ABO_INACTIF; 201 } 202 203 return array('error' => false, 'abodata' => $abodata); 204 } 205 206 function do_action($action, $email) 207 { 208 $email = trim($email); 209 $result = $this->check($action, $email); 210 211 if( $result['error'] == false ) 212 { 213 switch( $action ) 214 { 215 case 'inscription': 216 $this->subscribe(); 217 break; 218 case 'desinscription': 219 $this->unsubscribe(); 220 break; 221 case 'setformat': 222 $this->setformat(); 223 break; 224 } 225 } 226 else if( empty($this->message) ) 227 { 228 $this->message = $result['message']; 229 } 230 } 231 232 function check_code($code) 233 { 234 global $db, $lang; 235 236 $sql = "SELECT a.abo_id, a.abo_email, a.abo_status, al.confirmed, al.register_date, l.liste_id, 237 l.liste_format, l.sender_email, l.liste_alias, l.limitevalidate, l.liste_name, 238 l.return_email, l.form_url, l.liste_sig, l.use_cron, l.confirm_subscribe 239 FROM " . ABONNES_TABLE . " AS a 240 INNER JOIN " . ABO_LISTE_TABLE . " AS al ON al.abo_id = a.abo_id 241 AND al.register_key = '" . $db->escape($code) . "' 242 INNER JOIN " . LISTE_TABLE . " AS l ON l.liste_id = al.liste_id"; 243 if( !($result = $db->query($sql)) ) 244 { 245 trigger_error('Impossible de tester les tables d\'inscriptions', ERROR); 246 } 247 248 if( $abodata = $db->fetch_array($result) ) 249 { 250 $this->account['abo_id'] = $abodata['abo_id']; 251 $this->account['email'] = $abodata['abo_email']; 252 $this->account['date'] = $abodata['register_date']; 253 $this->account['code'] = $code; 254 $this->listdata = $abodata; 255 256 if( $abodata['confirmed'] == SUBSCRIBE_NOT_CONFIRMED ) 257 { 258 $this->confirm($code); 91 259 } 92 260 else 93 261 { 94 $this->hasAccount = false; 95 96 $this->account['abo_id'] = 0; 97 $this->account['email'] = $email; 98 $this->account['pseudo'] = trim($pseudo); 99 $this->account['code'] = generate_key(); 100 $this->account['date'] = time(); 101 $this->account['format'] = $this->format; 102 $this->account['status'] = ( $this->listdata['confirm_subscribe'] == CONFIRM_NONE ) ? ABO_ACTIF : ABO_INACTIF; 103 } 104 105 return true; 106 } 107 else 108 { 109 $this->message = $result['message']; 110 111 return false; 262 $this->unsubscribe($code); 263 } 264 } 265 else 266 { 267 $this->message = $lang['Message']['Invalid_code']; 112 268 } 113 269 } … … 115 271 function subscribe() 116 272 { 117 global $db, $nl_config, $lang , $mailer;273 global $db, $nl_config, $lang; 118 274 119 275 $db->transaction(START_TRC); … … 124 280 'abo_email' => $this->account['email'], 125 281 'abo_pseudo' => $this->account['pseudo'], 126 'abo_register_key' => $this->account['code'],282 'abo_register_key' => generate_key(), 127 283 'abo_register_date' => $this->account['date'], 128 284 'abo_status' => $this->account['status'] … … 152 308 } 153 309 154 $sql = "INSERT INTO " . ABO_LISTE_TABLE . " (abo_id, liste_id, format, confirmed, register_date)155 VALUES({$this->account[ abo_id]}, {$this->listdata[liste_id]}, $this->format, $confirmed, " . time() . ")";310 $sql = "INSERT INTO " . ABO_LISTE_TABLE . " (abo_id, liste_id, format, register_key, register_date, confirmed) 311 VALUES({$this->account['abo_id']}, {$this->listdata['liste_id']}, $this->format, '{$this->account['code']}', " . time() . ", $confirmed)"; 156 312 if( !$db->query($sql) ) 157 313 { … … 166 322 { 167 323 $email_tpl = ( $this->listdata['use_cron'] ) ? 'welcome_cron2' : 'welcome_form2'; 168 $link_action = 'confirmation';169 324 } 170 325 else 171 326 { 172 327 $email_tpl = ( $this->listdata['use_cron'] ) ? 'welcome_cron1' : 'welcome_form1'; 173 $link_action = 'desinscription';174 175 328 $this->alert_admin(true); 176 329 } 177 330 178 $ mailer->clear_all();179 $ mailer->set_from($this->listdata['sender_email'], unhtmlspecialchars($this->listdata['liste_name']));180 $ mailer->set_address($this->account['email']);181 $ mailer->set_subject(sprintf($lang['Subject_email']['Subscribe'], $nl_config['sitename']));182 $ mailer->set_priority(1);183 $ mailer->set_return_path($this->listdata['return_email']);184 185 $ mailer->use_template($email_tpl, array(331 $this->mailer->clear_all(); 332 $this->mailer->set_from($this->listdata['sender_email'], unhtmlspecialchars($this->listdata['liste_name'])); 333 $this->mailer->set_address($this->account['email']); 334 $this->mailer->set_subject(sprintf($lang['Subject_email']['Subscribe'], $nl_config['sitename'])); 335 $this->mailer->set_priority(1); 336 $this->mailer->set_return_path($this->listdata['return_email']); 337 338 $this->mailer->use_template($email_tpl, array( 186 339 'LISTE' => unhtmlspecialchars($this->listdata['liste_name']), 187 340 'SITENAME' => $nl_config['sitename'], … … 193 346 if( $this->listdata['use_cron'] ) 194 347 { 195 $ mailer->assign_tags(array(348 $this->mailer->assign_tags(array( 196 349 'EMAIL_NEWSLETTER' => $this->liste_email 197 350 )); … … 199 352 else 200 353 { 201 $ mailer->assign_tags(array(202 'LINK' => $this->make_link( $link_action)354 $this->mailer->assign_tags(array( 355 'LINK' => $this->make_link() 203 356 )); 204 357 } … … 206 359 if( $nl_config['enable_profil_cp'] ) 207 360 { 208 $ mailer->assign_block_tags('enable_profil_cp', array(361 $this->mailer->assign_block_tags('enable_profil_cp', array( 209 362 'LINK_PROFIL_CP' => make_script_url('profil_cp.php') 210 363 )); 211 364 } 212 365 213 if( !$ mailer->send() )366 if( !$this->mailer->send() ) 214 367 { 215 368 $this->message = $lang['Message']['Failed_sending']; … … 221 374 if( $this->listdata['confirm_subscribe'] == CONFIRM_NONE ) 222 375 { 223 $this->update_stats = true;376 $this->update_stats(); 224 377 $message = $lang['Message']['Subscribe_2']; 225 378 } … … 237 390 else if( $this->listdata['confirm_subscribe'] != CONFIRM_ALWAYS ) 238 391 { 239 $this->update_stats = true;392 $this->update_stats(); 240 393 $message = $lang['Message']['Subscribe_2']; 241 394 } … … 249 402 } 250 403 251 function confirm($ time = 0)252 { 253 global $db, $nl_config, $lang , $mailer;254 255 if( $this->code == $this->account['code'])404 function confirm($code, $time = 0) 405 { 406 global $db, $nl_config, $lang; 407 408 if( strcmp($code, $this->account['code']) == 0 ) 256 409 { 257 410 $time = ( empty($time) ) ? time() : $time; … … 261 414 { 262 415 $low_priority = ( strncmp(DATABASE, 'mysql', 5) == 0 ) ? 'LOW_PRIORITY' : ''; 416 $this->account['code'] = generate_key(20); 263 417 264 418 $db->transaction(START_TRC); … … 274 428 275 429 $sql = "UPDATE $low_priority " . ABO_LISTE_TABLE . " 276 SET confirmed = " . SUBSCRIBE_CONFIRMED . " 430 SET confirmed = " . SUBSCRIBE_CONFIRMED . ", 431 register_key = '" . $this->account['code'] . "' 277 432 WHERE liste_id = " . $this->listdata['liste_id'] . " 278 433 AND abo_id = " . $this->account['abo_id']; … … 285 440 $db->transaction(END_TRC); 286 441 287 $this->update_stats = true;442 $this->update_stats(); 288 443 $this->alert_admin(true); 289 444 … … 305 460 } 306 461 307 function unsubscribe() 308 { 309 global $db, $nl_config, $lang, $mailer; 310 311 if( $this->code != '' ) 312 { 313 if( $this->code == $this->account['code'] ) 314 { 315 $sql = "SELECT COUNT(abo_id) AS num_subscribe 316 FROM " . ABO_LISTE_TABLE . " 317 WHERE abo_id = " . $this->account['abo_id']; 318 if( !($result = $db->query($sql)) ) 462 function unsubscribe($code = '') 463 { 464 global $db, $nl_config, $lang; 465 466 if( !empty($code) ) 467 { 468 $sql = "SELECT COUNT(abo_id) AS num_subscribe 469 FROM " . ABO_LISTE_TABLE . " 470 WHERE abo_id = " . $this->account['abo_id']; 471 if( !($result = $db->query($sql)) ) 472 { 473 trigger_error('Impossible de vérifier la table de jointure', ERROR); 474 return false; 475 } 476 477 $num_subscribe = $db->result($result, 0, 'num_subscribe'); 478 479 $db->transaction(START_TRC); 480 481 $sql = "DELETE FROM " . ABO_LISTE_TABLE . " 482 WHERE liste_id = " . $this->listdata['liste_id'] . " 483 AND abo_id = " . $this->account['abo_id']; 484 if( !$db->query($sql) ) 485 { 486 trigger_error('Impossible d\'effacer l\'entrée de la table abo_liste', ERROR); 487 return false; 488 } 489 490 if( $num_subscribe == 1 ) 491 { 492 $sql = 'DELETE FROM ' . ABONNES_TABLE . ' 493 WHERE abo_id = ' . $this->account['abo_id']; 494 if( !$db->query($sql) ) 319 495 { 320 trigger_error('Impossible d e vérifier la table de jointure', ERROR);496 trigger_error('Impossible d\'effacer l\'entrée de la table des abonnés', ERROR); 321 497 return false; 322 498 } 323 499 324 $num_subscribe = $db->result($result, 0, 'num_subscribe'); 325 326 $db->transaction(START_TRC); 327 328 $sql = "DELETE FROM " . ABO_LISTE_TABLE . " 329 WHERE liste_id = " . $this->listdata['liste_id'] . " 330 AND abo_id = " . $this->account['abo_id']; 331 if( !$db->query($sql) ) 332 { 333 trigger_error('Impossible d\'effacer l\'entrée de la table abo_liste', ERROR); 334 return false; 335 } 336 337 if( $num_subscribe == 1 ) 338 { 339 $sql = 'DELETE FROM ' . ABONNES_TABLE . ' 340 WHERE abo_id = ' . $this->account['abo_id']; 341 if( !$db->query($sql) ) 342 { 343 trigger_error('Impossible d\'effacer l\'entrée de la table des abonnés', ERROR); 344 return false; 345 } 346 347 $this->message = $lang['Message']['Unsubscribe_3']; 348 } 349 else 350 { 351 $this->message = $lang['Message']['Unsubscribe_2']; 352 } 353 354 $db->transaction(END_TRC); 355 $this->alert_admin(false); 356 357 return true; 500 $this->message = $lang['Message']['Unsubscribe_3']; 358 501 } 359 502 else 360 503 { 361 $this->message = $lang['Message']['Invalid_code']; 362 363 return false; 364 } 365 } 366 else 367 { 368 $mailer->set_from($this->listdata['sender_email'], unhtmlspecialchars($this->listdata['liste_name'])); 369 $mailer->set_address($this->account['email']); 370 $mailer->set_subject($lang['Subject_email']['Unsubscribe']); 371 $mailer->set_priority(3); 372 $mailer->set_return_path($this->listdata['return_email']); 504 $this->message = $lang['Message']['Unsubscribe_2']; 505 } 506 507 $db->transaction(END_TRC); 508 $this->alert_admin(false); 509 510 return true; 511 } 512 else 513 { 514 $this->mailer->set_from($this->listdata['sender_email'], unhtmlspecialchars($this->listdata['liste_name'])); 515 $this->mailer->set_address($this->account['email']); 516 $this->mailer->set_subject($lang['Subject_email']['Unsubscribe']); 517 $this->mailer->set_priority(3); 518 $this->mailer->set_return_path($this->listdata['return_email']); 373 519 374 520 $email_tpl = ( $this->listdata['use_cron'] ) ? 'unsubscribe_cron' : 'unsubscribe_form'; 375 521 376 $ mailer->use_template($email_tpl, array(522 $this->mailer->use_template($email_tpl, array( 377 523 'LISTE' => unhtmlspecialchars($this->listdata['liste_name']), 378 524 'SITENAME' => $nl_config['sitename'], … … 383 529 if( $this->listdata['use_cron'] ) 384 530 { 385 $ mailer->assign_tags(array(531 $this->mailer->assign_tags(array( 386 532 'EMAIL_NEWSLETTER' => $this->liste_email, 387 533 'CODE' => $this->account['code'] … … 390 536 else 391 537 { 392 $ mailer->assign_tags(array(393 'LINK' => $this->make_link( 'desinscription')538 $this->mailer->assign_tags(array( 539 'LINK' => $this->make_link() 394 540 )); 395 541 } 396 542 397 if( ! ($mailer->send()) )543 if( !$this->mailer->send() ) 398 544 { 399 545 $this->message = $lang['Message']['Failed_sending']; … … 447 593 } 448 594 449 function make_link( $action)450 { 451 $prefix = $this->listdata['form_url'] . ( ( strstr($this->listdata['form_url'], '?') ) ? '&' : '?' );452 453 return $prefix . 'action=' . $action . '&email=' . rawurlencode($this->account['email']) . '&code=' . $this->account['code'] . '&liste=' . $this->listdata['liste_id'];595 function make_link() 596 { 597 return $this->listdata['form_url'] 598 . (( strstr($this->listdata['form_url'], '?') ) ? '&' : '?') 599 . $this->account['code']; 454 600 } 455 601 456 602 function alert_admin($new_subscribe) 457 603 { 458 global $ nl_config, $db, $mailer;604 global $db, $nl_config, $lang; 459 605 460 606 if( $new_subscribe == true ) … … 483 629 if( $row = $db->fetch_array($result) ) 484 630 { 485 $mailer->clear_all(); 486 487 $mailer->set_from($this->listdata['sender_email'], unhtmlspecialchars($this->listdata['liste_name'])); 488 $mailer->set_subject($subject); 489 490 $mailer->use_template($template, array( 631 $this->mailer->clear_all(); 632 $this->mailer->set_from($this->listdata['sender_email'], unhtmlspecialchars($this->listdata['liste_name'])); 633 $this->mailer->set_subject($subject); 634 635 $this->mailer->use_template($template, array( 491 636 'EMAIL' => $this->account['email'], 492 637 'LISTE' => unhtmlspecialchars($this->listdata['liste_name']), … … 497 642 do 498 643 { 499 $ mailer->clear_address();500 $ mailer->set_address($row['admin_email'], $row['admin_login']);644 $this->mailer->clear_address(); 645 $this->mailer->set_address($row['admin_email'], $row['admin_login']); 501 646 502 $ mailer->assign_tags(array(647 $this->mailer->assign_tags(array( 503 648 'USER' => $row['admin_login'] 504 649 )); 505 650 506 $ mailer->send(); // envoi651 $this->mailer->send(); // envoi 507 652 } 508 653 while( $row = $db->fetch_array($result) ); 509 654 } 655 } 656 } 657 658 function update_stats() 659 { 660 @include WA_ROOTDIR . '/includes/functions.stats.php'; 661 662 if( function_exists('update_stats') ) 663 { 664 update_stats($this->listdata); 510 665 } 511 666 } trunk/includes/engine_send.php
r221 r230 165 165 // On récupère les infos sur les abonnés destinataires 166 166 // 167 $sql = "SELECT a.abo_id, a.abo_pseudo, $fields_str a.abo_email, a .abo_register_key, al.format167 $sql = "SELECT a.abo_id, a.abo_pseudo, $fields_str a.abo_email, al.register_key, al.format 168 168 FROM " . ABONNES_TABLE . " AS a 169 INNER JOIN " . ABO_LISTE_TABLE . " AS al 170 ON al.abo_id = a.abo_id 169 INNER JOIN " . ABO_LISTE_TABLE . " AS al ON al.abo_id = a.abo_id 171 170 AND al.liste_id = $listdata[liste_id] 172 171 AND al.confirmed = " . SUBSCRIBE_CONFIRMED . " … … 294 293 'abo_pseudo' => '', 295 294 'abo_email' => $address, 296 ' abo_register_key' => '',295 'register_key' => '', 297 296 'abo_id' => -1 298 297 )); … … 305 304 'abo_pseudo' => '', 306 305 'abo_email' => $address, 307 ' abo_register_key' => '',306 'register_key' => '', 308 307 'abo_id' => -1 309 308 )); … … 387 386 { 388 387 $tags_replace = array_merge($tags_replace, array( 389 'WA_CODE' => $row[' abo_register_key'],388 'WA_CODE' => $row['register_key'], 390 389 'WA_EMAIL' => rawurlencode($row['abo_email']) 391 390 )); … … 460 459 $sql = "SELECT COUNT(*) AS num_dest, al.send 461 460 FROM " . ABO_LISTE_TABLE . " AS al 462 INNER JOIN " . ABONNES_TABLE . " AS a 463 ON a.abo_id = al.abo_id 461 INNER JOIN " . ABONNES_TABLE . " AS a ON a.abo_id = al.abo_id 464 462 AND a.abo_status = " . ABO_ACTIF . " 465 463 WHERE al.liste_id = $listdata[liste_id] … … 583 581 else 584 582 { 585 $tmp_link = $listdata['form_url'] . ( ( strstr($listdata['form_url'], '?') ) ? '&' : '?' ); 586 $tmp_link .= 'action=desinscription&email={WA_EMAIL}&code={WA_CODE}&liste=' . $listdata['liste_id']; 583 $tmp_link = $listdata['form_url'] . ( ( strstr($listdata['form_url'], '?') ) ? '&' : '?' ) . '{WA_CODE}'; 587 584 588 585 $link = array( trunk/includes/functions.validate.php
r184 r230 29 29 30 30 define('FUNCTIONS_VALIDATE_INC', true); 31 32 /**33 * check_email()34 *35 * Vérification de l'email36 *37 * @param string $email Email à vérifier38 * @param integer $liste Id de la liste concernée39 * @param string $action Action en cours40 *41 * @return array42 */43 function check_email($email, $liste = 0, $action = '', $disable_check_mx = false)44 {45 global $db, $nl_config, $lang;46 47 if( !class_exists('Mailer') )48 {49 require WAMAILER_DIR . '/class.mailer.php';50 }51 52 //53 // Vérification syntaxique de l'email54 //55 if( Mailer::validate_email($email) == false )56 {57 return array('error' => true, 'message' => $lang['Message']['Invalid_email']);58 }59 60 $sql = 'SELECT ban_email FROM ' . BANLIST_TABLE . '61 WHERE liste_id = ' . $liste;62 if( $result = $db->query($sql) )63 {64 while( $row = $db->fetch_array($result) )65 {66 if( preg_match('/\b' . str_replace('*', '.*?', $row['ban_email']) . '\b/i', $email) )67 {68 return array('error' => true, 'message' => $lang['Message']['Email_banned']);69 }70 }71 }72 73 $abodata = array();74 $sql_email = $db->escape(strtolower($email));75 76 $sql = "SELECT a.abo_id, a.abo_pseudo, a.abo_pwd, a.abo_email, a.abo_lang, a.abo_register_key, a.abo_register_date,77 a.abo_status, al.format, al.confirmed, al.register_date78 FROM " . ABONNES_TABLE . " AS a79 LEFT JOIN " . ABO_LISTE_TABLE . " AS al ON al.abo_id = a.abo_id80 AND al.liste_id = $liste81 WHERE LOWER(a.abo_email) = '$sql_email'";82 if( !($result = $db->query($sql)) )83 {84 trigger_error('Impossible de tester les tables d\'inscriptions', ERROR);85 }86 87 if( $abodata = $db->fetch_array($result) )88 {89 if( isset($abodata['confirmed']) )90 {91 if( $action == 'inscription' && $abodata['confirmed'] == SUBSCRIBE_CONFIRMED )92 {93 return array('error' => true, 'message' => $lang['Message']['Allready_reg']);94 }95 else if( $action == 'confirmation' && $abodata['confirmed'] == SUBSCRIBE_CONFIRMED )96 {97 return array('error' => true, 'message' => $lang['Message']['Allready_confirm']);98 }99 }100 else if( $action != 'inscription' )101 {102 return array('error' => true, 'message' => $lang['Message']['Unknown_email']);103 }104 }105 else if( $action != 'inscription' )106 {107 return array('error' => true, 'message' => $lang['Message']['Unknown_email']);108 }109 110 if( !$disable_check_mx && $nl_config['check_email_mx'] && $abodata === false )111 {112 //113 // Vérification de l'existence d'un Mail eXchanger sur le domaine de l'email,114 // et vérification de l'existence du compte associé (La vérification de l'existence du115 // compte n'est toutefois pas infaillible, les serveurs smtp refusant parfois le relaying,116 // c'est à dire de traiter les demandes émanant d'un entité extérieure à leur réseau, et117 // pour une adresse email extérieure à ce réseau)118 //119 $mailer = new Mailer();120 $mailer->smtp_path = WAMAILER_DIR . '/';121 122 if( $mailer->validate_email_mx($email) == false )123 {124 return array('error' => true, 'message' => $lang['Message']['Unrecognized_email']);125 }126 }127 128 return array('error' => false, 'abodata' => $abodata);129 }130 31 131 32 /** trunk/language/lang_francais.php
r223 r230 249 249 $lang['Message']['Upload_error_7'] = "Échec de l'écriture du fichier sur le disque"; 250 250 $lang['Message']['Invalid_filename'] = "Nom de fichier non valide"; 251 $lang['Message']['Invalid_action'] = "Action non valide"; 251 252 $lang['Message']['Invalid_ext'] = "Cette extension de fichier a été interdite"; 252 253 $lang['Message']['weight_too_big'] = "Le poids total des fichiers joints excède le maximum autorisé, il ne vous reste que %.2f octets de libre"; trunk/newsletter.php
r208 r230 62 62 } 63 63 64 $action = ( !empty($_REQUEST['action']) ) ? trim($_REQUEST['action']) : ''; 65 $email = ( !empty($_REQUEST['email']) ) ? trim($_REQUEST['email']) : ''; 64 66 $message = ''; 67 $code = ''; 68 $liste = ( isset($_REQUEST['liste']) ) ? intval($_REQUEST['liste']) : 0; 65 69 66 $vararray = array('action', 'email', 'code', 'liste'); 67 foreach( $vararray AS $varname ) 70 if( empty($action) && preg_match('/([a-z0-9]{20})(?:&|$)/i', $_SERVER['QUERY_STRING'], $match) ) 68 71 { 69 $ {$varname} = ( !empty($_REQUEST[$varname]) ) ? $_REQUEST[$varname] : '';72 $code = $match[1]; 70 73 } 71 74 … … 73 76 // Compatibilité avec les version < 2.3.x 74 77 // 75 if(strlen($code) == 32 )78 else if( !empty($action) && !empty($email) && strlen($code) == 32 ) 76 79 { 77 80 $code = substr($code, 0, 20); 78 81 } 79 82 80 if( $action != '')83 if( !empty($action) || !empty($code) ) 81 84 { 82 $sql = 'SELECT * FROM ' . LISTE_TABLE . ' 83 WHERE liste_id = ' . intval($liste); 84 if( !($result = $db->query($sql)) ) 85 // 86 // Purge des éventuelles inscriptions dépassées 87 // pour parer au cas d'une réinscription 88 // 89 purge_liste(); 90 91 require WA_ROOTDIR . '/includes/class.form.php'; 92 93 if( !empty($action) ) 85 94 { 86 trigger_error('Impossible d\'obtenir les données sur la liste', ERROR); 87 } 88 else if( $listdata = $db->fetch_array($result) ) 89 { 90 // 91 // Purge des éventuelles inscriptions dépassées 92 // pour parer au cas d'une réinscription 93 // 94 purge_liste(); 95 96 require WAMAILER_DIR . '/class.mailer.php'; 97 require WA_ROOTDIR . '/includes/class.form.php'; 98 include WA_ROOTDIR . '/includes/functions.stats.php'; 99 100 $mailer = new Mailer(WA_ROOTDIR . '/language/email_' . $nl_config['language'] . '/'); 101 102 if( $nl_config['use_smtp'] ) 95 if( in_array($action, array('inscription', 'setformat', 'desinscription')) ) 103 96 { 104 $mailer->smtp_path = WAMAILER_DIR . '/'; 105 $mailer->use_smtp( 106 $nl_config['smtp_host'], 107 $nl_config['smtp_port'], 108 $nl_config['smtp_user'], 109 $nl_config['smtp_pass'] 110 ); 111
