A lightweight forum engine written in PHP. Repository is now obsolete and read-only. http://www.pioder.pl/uforum.html
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
2.8 KiB

  1. <?php
  2. /**
  3. * @package uForum
  4. * @file includes/class_email.php
  5. * @version $Id: emailer.php -1 $
  6. * @copyright 2007-2010 (c) PioDer <pioder@wp.pl>
  7. * @link http://www.pioder.pl/
  8. * @license see LICENSE.txt
  9. **/
  10. if ( !defined('IN_uF') )
  11. {
  12. die('Hacking attempt');
  13. }
  14. function SendEmail($email, $title, $content)
  15. {
  16. global $forum_config;
  17. #headers
  18. $email_headers = "MIME-Version: 1.0\r\n";
  19. $email_headers .= "Content-type: text/html; charset=iso-8859-2\r\n";
  20. $email_headers .= "From: ".$forum_config['forumname']." \n";
  21. $email_date = date('d-m-Y, G:i',$_SERVER['REQUEST_TIME']);
  22. $email_content = '
  23. <html>
  24. <head>
  25. <title>'.$title.'</title>
  26. </head>
  27. <body>
  28. '.$content.'<br>
  29. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
  30. <font face="Verdana" style="font-size:10pt">
  31. Message generated automatic by &micro;Forum <b>('.$email_date.')</b></font>
  32. </body>
  33. </html>';
  34. #send email - do it!
  35. if ( !mail($email, $title, $email_content, $email_headers ))
  36. {
  37. message_die(GENERAL,'Could not send email from: '.$email.'. sorry :(','');
  38. }
  39. }
  40. function SendRegisterEmail()
  41. {
  42. global $forum_config;
  43. global $original_pass;
  44. global $lng;
  45. $email_content = $lng['email_newpasswd_msg'];
  46. $email_content = str_replace('%forum%',$forum_config['forumname'],$email_content);
  47. $email_content = str_replace('%url_f%',$forum_config['forumpatch'],$email_content);
  48. $email_content = str_replace('%ip%',$_SERVER['REMOTE_ADDR'],$email_content);
  49. $email_content = str_replace('%forum%',$forum_config['forumname'],$email_content);
  50. $email_content = str_replace('%login%',$_POST['nick'],$email_content);
  51. $email_content = str_replace('%pass%',$original_pass,$email_content);
  52. SendEmail($_POST['email'],$lng['email_welcome'].$forum_config['forumname'],$email_content);
  53. }
  54. function SendForgotPassEmail($newpass)
  55. {
  56. global $forum_config;
  57. global $original_pass;
  58. global $lng;
  59. global $uid;
  60. $email_content = $lng['email_register_msg'];
  61. $email_content = str_replace('%forum%',$forum_config['forumname'],$email_content);
  62. $email_content = str_replace('%url_f%',$forum_config['forumpatch'],$email_content);
  63. $email_content = str_replace('%ip%',$_SERVER['REMOTE_ADDR'],$email_content);
  64. $email_content = str_replace('%forum%',$forum_config['forumname'],$email_content);
  65. $email_content = str_replace('%login%',$_POST['username'],$email_content);
  66. $email_content = str_replace('%pass%',$newpass,$email_content);
  67. SendEmail(User::UserInformation($uid,'email'),$lng['email_sent_forget_pass'].$forum_config['forumname'],$email_content);
  68. }
  69. function SendMassEmail($title,$content)
  70. {
  71. $sql = "SELECT `email`,`u_id` FROM ".USERS_TABLE." WHERE `u_id`>0";
  72. $query = DataBase::sql_query($sql,CRITICAL,'Could not read users table');
  73. while($item = DataBase::fetch($query))
  74. {
  75. SendEmail($item['email'], $title, $content);
  76. }
  77. }
  78. ?>