home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 April / PCWorld_2005-04_cd.bin / akce / web / phpbb2plus / phpBB2_plus_1.52.exe / phpBB2 / tellafriend.php < prev    next >
PHP Script  |  2004-07-18  |  5KB  |  121 lines

  1. <?php
  2. define('IN_PHPBB', true);
  3. $phpbb_root_path = "./";
  4. include($phpbb_root_path . 'extension.inc');
  5. include($phpbb_root_path . 'common.'.$phpEx);
  6. include($phpbb_root_path . 'includes/functions_post.'.$phpEx);
  7.  
  8. $topic = (isset($HTTP_POST_VARS['topic'])) ? $HTTP_POST_VARS['topic'] : $HTTP_GET_VARS['topic']; 
  9. $friendname =  $HTTP_POST_VARS['friendname'];
  10. $message = $HTTP_POST_VARS['message'];
  11. $link = $HTTP_GET_VARS['link'];
  12. $PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF'];
  13.  
  14. $userdata = session_pagestart($user_ip, PAGE_INDEX);
  15. init_userprefs($userdata);
  16.  
  17. if( !$userdata['session_logged_in'] ) 
  18.     { 
  19.         header("Location: " . append_sid("login.$phpEx?redirect=$PHP_SELF&topic=$topic&link=$link", true));
  20.            exit; 
  21.     } 
  22.         
  23. include($phpbb_root_path . 'includes/page_header.'.$phpEx);
  24.  
  25. $mail_body = str_replace("{TOPIC}", trim(stripslashes($topic)), $lang['Tell_Friend_Body']);
  26. $mail_body = str_replace("{LINK}", $link, $mail_body);
  27. $mail_body = str_replace("{SITENAME}", $board_config['sitename'], $mail_body);
  28.  
  29. $template->assign_vars(array(
  30. 'L_TELL_FRIEND_TITLE' => $lang['Tell_Friend_Title'],
  31. 'L_TELL_FRIEND_EMAIL_MESSAGE' => $lang['Tell_Friend_Email_Message'],
  32. 'L_TELL_FRIEND_SENDER_USER' => $lang['Tell_Friend'],
  33. 'L_TELL_FRIEND_SENDER_USER' => $lang['Tell_Friend_Sender_User'],
  34. 'L_TELL_FRIEND_SENDER_EMAIL' => $lang['Tell_Friend_Sender_Email'],
  35. 'L_TELL_FRIEND_RECIEVER_USER' => $lang['Tell_Friend_Reciever_User'],
  36. 'L_TELL_FRIEND_RECIEVER_EMAIL' => $lang['Tell_Friend_Reciever_Email'],
  37. 'L_TELL_FRIEND_MSG' => $lang['Tell_Friend_Msg'],
  38. 'L_TELL_FRIEND_BODY' => $mail_body,
  39.  
  40. "SUBMIT_ACTION" => append_sid("$PHP_SELF", true),
  41. "L_SUBMIT" => $lang['Send_email'],
  42. "SITENAME" => $board_config['sitename'], 
  43. "TOPIC" => trim(stripslashes($topic)), 
  44. "LINK" => $link, 
  45. "SENDER_NAME" => $userdata['username'], 
  46. "SENDER_MAIL" => $userdata['user_email'], 
  47. ));
  48.  
  49. /**************/
  50.         if ( isset($HTTP_POST_VARS['submit']) )
  51.         {
  52.             $error = FALSE;
  53.  
  54.             if ( !empty($HTTP_POST_VARS['friendemail']) && (strpos($HTTP_POST_VARS['friendemail'],"@")>0) )
  55.             {
  56.                 $friendemail = trim(stripslashes($HTTP_POST_VARS['friendemail']));
  57.                 if (!$HTTP_POST_VARS['friendname']) { $friendname=substr($friendemail,0,strpos($HTTP_POST_VARS['friendemail'],"@")); };
  58.             }
  59.             else
  60.             {
  61.                 $error = TRUE;
  62.                 $error_msg = "You have not entered a (valid) email address";
  63.             }
  64.  
  65.             if ( !$error )
  66.             {
  67.                     include($phpbb_root_path . 'includes/emailer.'.$phpEx);
  68.                     $emailer = new emailer($board_config['smtp_delivery']);
  69.  
  70.                     //$email_headers = 'Return-Path: ' . $userdata['user_email'] . "\nFrom: ". $userdata['username'] .'<'. $userdata['user_email'] .'>' . "\n";
  71.                     // The above line did not work for some people, so we use the simpler below line
  72.                     $email_headers = 'Return-Path: ' . $userdata['user_email'] . "\nFrom: ". $userdata['user_email'] ."\n";
  73.                     $email_headers .= 'X-AntiAbuse: Board servername - ' . $server_name . "\n";
  74.                     $email_headers .= 'X-AntiAbuse: User_id - ' . $userdata['user_id'] . "\n";
  75.                     $email_headers .= 'X-AntiAbuse: Username - ' . $userdata['username'] . "\n";
  76.                     $email_headers .= 'X-AntiAbuse: User IP - ' . decode_ip($user_ip) . "\r\n";
  77.  
  78.                     $emailer->use_template('tellafriend_email', $user_lang);
  79.                     $emailer->email_address($friendname .'<'. $friendemail .'>');
  80.                     //$emailer->set_subject($friendname.', du wurdest eingeladen nach '. $board_config[sitename]);
  81.                     $emailer->set_subject(trim(stripslashes($topic)));
  82.                     $emailer->extra_headers($email_headers);
  83.  
  84.                     $emailer->assign_vars(array(
  85.                         'SITENAME' => $board_config['sitename'], 
  86.                         'BOARD_EMAIL' => $board_config['board_email'], 
  87.                         'FROM_USERNAME' => $userdata['username'], 
  88.                         'TO_USERNAME' => $friendname, 
  89.                         'MESSAGE' => $message)
  90.                     );
  91.                     $emailer->send();
  92.                     $emailer->reset();
  93.  
  94.                     $template->assign_vars(array(
  95.                         'META' => '<meta http-equiv="refresh" content="5;url=' . append_sid("index.$phpEx") . '">')
  96.                     );
  97.  
  98.                     $message = $lang['Email_sent'] . '<br /><br />' . sprintf($lang['Click_return_index'],  '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
  99.  
  100.                     message_die(GENERAL_MESSAGE, $message);
  101.             }
  102.  
  103.             if ( $error )
  104.             {
  105.                 $template->set_filenames(array(
  106.                     'reg_header' => 'error_body.tpl')
  107.                 );
  108.                 $template->assign_vars(array(
  109.                     'ERROR_MESSAGE' => $error_msg)
  110.                 );
  111.                 $template->assign_var_from_handle('ERROR_BOX', 'reg_header');
  112.             }
  113.  
  114.         }
  115.  
  116.  
  117. $template->set_filenames(array("body" => "tellafriend_body.tpl"));
  118. $template->pparse("body");
  119.  
  120. include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
  121. ?>