Automatically exported from code.google.com/p/planningalerts
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

54 行
1.4 KiB

  1. <?php
  2. require_once('tools_ini.php');
  3. require_once('application.php');
  4. require_once('DB.php');
  5. //initialise
  6. $news_mailer = new news_mailer();
  7. $news_mailer->run();
  8. //class
  9. class news_mailer {
  10. //Run
  11. function run (){
  12. $db = DB::connect(DB_CONNECTION_STRING);
  13. //Grab all the users
  14. $sql = "select distinct email
  15. from user
  16. where confirmed = 1";
  17. $user_results = $db->getAll($sql);
  18. print "Found " . sizeof($user_results) . " to email ";
  19. if(sizeof($user_results) > 0){
  20. //Loop though users
  21. for ($i=0; $i < sizeof($user_results); $i++){
  22. //Smarty template
  23. $smarty = new Smarty;
  24. $smarty->force_compile = true;
  25. $smarty->compile_dir = SMARTY_COMPILE_DIRECTORY;
  26. //Get the email text
  27. $email_text = $smarty->fetch(SMARTY_TEMPLATE_DIRECTORY . 'news_mail.tpl');
  28. //Send the email
  29. if($email_text !=""){
  30. // send_text_email($user_results[$i][0], EMAIL_FROM_NAME, EMAIL_FROM_ADDRESS, "StreetWire - a new service from PlanningAlerts", $email_text);
  31. }
  32. }
  33. }
  34. }
  35. }
  36. ?>