Changeset 37
- Timestamp:
- 04/28/08 12:36:26 (2 years ago)
- Files:
-
- trunk/apps/main/config/i18n.yml (modified) (1 diff)
- trunk/apps/main/config/routing.yml (modified) (1 diff)
- trunk/apps/main/lib/myActions.class.php (modified) (3 diffs)
- trunk/data/fixtures/data.yml (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/apps/main/config/i18n.yml
r2 r37 6 6 default_culture: en 7 7 source: XLIFF 8 debug: o n8 debug: off 9 9 cache: off 10 10 untranslated_prefix: "[T]" trunk/apps/main/config/routing.yml
r2 r37 98 98 99 99 # Applications 100 applications_test: 101 url: /applications/test 102 param: { module: applications, action: test } 100 103 applications_countries: 101 104 url: /applications/countries trunk/apps/main/lib/myActions.class.php
r2 r37 235 235 protected function sendSwiftSmtpPlainMail($module, $action, $to, $subject, $options = array()) 236 236 { 237 try 238 { 239 $this->checkMailFlood(); 240 } 241 catch (sfException $e) 242 { 243 $this->setFlash('warning', $e->getMessage()); 244 $this->forward404(sprintf('User "%s" is flooding by mail', $this->getUser()->getGuardUser()->getUsername())); 245 } 246 237 247 $conn = new Swift_Connection_SMTP(sfConfig::get('app_mail_hostname')); 238 248 switch (strtolower(sfConfig::get('app_mail_protocol'))) … … 298 308 } 299 309 $mailer->disconnect(); 310 311 // Add mailSent timestamp 312 $this->getUser()->setAttribute('lastMailAt', time()); 313 300 314 return ($sent > 0); 301 315 } … … 338 352 return $address; 339 353 } 354 355 /** 356 * Checks for mail flooding (die, dirty spammers) 357 * 358 * @return boolean 359 * @throws sfException if mail flooding is detected 360 */ 361 protected function checkMailFlood() 362 { 363 $user = $this->getUser(); 364 365 if (!$user) 366 { 367 throw new sfException($this->__('Mail sending use the session, please allow cookies')); 368 } 369 370 $lastMailAt = $user->getAttribute('lastMailAt', null); 371 372 if (is_null($lastMailAt)) 373 { 374 return; 375 } 376 377 $ttl = sfConfig::get('app_mail_mail_flood_time', 300); 378 379 if (time() - $lastMailAt < $ttl) 380 { 381 throw new sfException(sprintf($this->__('You must wait at least %d seconds between two mail send, please try again later'), $ttl)); 382 } 383 } 340 384 341 385 } trunk/data/fixtures/data.yml
r2 r37 5 5 summary: Father of the Symfony framework 6 6 password: password 7 email: fabien@symfony-project.com7 email: nperriault+test1@gmail.com 8 8 trac_username: fabien 9 9 homepage: "http://www.symfony-project.com/" … … 19 19 display_name: Nicolas Perriault 20 20 password: password 21 email: nperriault @gmail.com21 email: nperriault+test2@gmail.com 22 22 trac_username: nicolas 23 23 homepage: "http://prendreuncafe.com/blog" … … 42 42 display_name: Tristan Rivoallan 43 43 password: password 44 email: tristan@rivoallan.net44 email: nperriault+test3@gmail.com 45 45 trac_username: trivoallan 46 46 country: FR … … 55 55 display_name: François Zaninotto 56 56 password: password 57 email: fzaninotto@ma-generation.com57 email: nperriault+test4@gmail.com 58 58 trac_username: francois 59 59 homepage: "http://www.mageneration.com/" … … 67 67 username: johndoe 68 68 password: password 69 email: john@doe.com69 email: nperriault+test5@gmail.com 70 70 summary: "Super newbie" 71 71 country: US … … 78 78 username: I_shouldnt_appear 79 79 password: password 80 email: foo@bar.com80 email: nperriault+test6@gmail.com 81 81 country: UK 82 82 is_validated: 0
