Page 1 of 1

[BETA] Mail() function activation by acp

Posted: Thu May 01, 2003 6:22 pm
by FX
Hello, this is my first mod for all people please test it. :)

Code: Select all

############################################################## 
## Mod Title: Mail() function activation by acp 
## MOD Author: FX aka Burning Sneakers < FX@2037.biz > (Fran├žois-Xavier) http://www.phpbb.biz 
## MOD Description: If smtp function and mail() are disable you have the possibility with this mod to display a good message on your board (don't display failed sending mail and disable the mailer if you prefer). 
## Mod Version: 1.1.0 
## 
## Installation Level: moderate
## Installation Time: 15 Minutes
## Files To Edit: (16)
##      admin_board.php,
##      admin_mass_email.php,
##      admin_users.php,
##      functions_post.php,
##      usercp_activate.php,
##      usercp_email.php,
##      usercp_register.php,
##      usercp_sendpasswd.php,
##      lang_admin.php,
##      lang_main.php,
##      board_config_body.tpl,
##      user_edit_body.tpl,
##      profile_add_body.tpl,
##      groupcp.php,
##      posting.php,
##      privmsg.php,
##	viewtopic.php,
##	viewtopic_body.tpl,
##        
## Included Files: n/a 
############################################################## 
## For Security Purposes, Please Check: http://www.phpbb.com/mods/downloads/ for the 
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code 
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered 
## in our MOD-Database, located at: http://www.phpbb.com/mods/downloads/ 
############################################################## 
## Author Note: 
##     Insert 1 row of data into phpbb_config table. This mod is for user don't have the possibility to send 
##     email [smtp and mail()] 
## 
## Change History: 
## 
##     1.0.0    :    First release. 
## 
############################################################## 
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
############################################################## 

# 
#-----[ SQL ]----- 
# 
# Note:  Replace phpbb_ with whatever forum prefix you use. 
# 
INSERT INTO phpbb_config (config_name, config_value) VALUES ('mail_activate', '0'); 


# 
#-----[ OPEN ]----- 
# 
admin/admin_board.php 

# 
#-----[ FIND ]----- 
# 
$smtp_yes = ( $new['smtp_delivery'] ) ? "checked=\"checked\"" : ""; 
$smtp_no = ( !$new['smtp_delivery'] ) ? "checked=\"checked\"" : ""; 

# 
#-----[ AFTER, ADD ]----- 
# 
$activate_yes = ( $new['mail_activate'] ) ? "checked=\"checked\"" : ""; 
$activate_no = ( !$new['mail_activate'] ) ? "checked=\"checked\"" : ""; 

# 
#-----[ FIND ]----- 
# 
"L_COPPA_MAIL_EXPLAIN" => $lang['COPPA_mail_explain'], 
"L_EMAIL_SETTINGS" => $lang['Email_settings'], 

# 
#-----[ AFTER, ADD ]----- 
# 
"L_ACTIVATE_EMAIL" => $lang['Email_activate'], 
"L_ACTIVATE_EMAIL_EXPLAIN" => $lang['Email_Activate_Explain'], 

# 
#-----[ FIND ]----- 
# 
"SMTP_YES" => $smtp_yes, 
"SMTP_NO" => $smtp_no, 

# 
#-----[ AFTER, ADD ]----- 
# 
"ACTIVATE_YES" => $activate_yes, 
"ACTIVATE_NO" => $activate_no, 


# 
#-----[ OPEN ]----- 
# 
admin/admin_mass_email.php 

# 
#-----[ FIND ]----- 
# 
$no_page_header = TRUE; 
$phpbb_root_path = './../'; 
require($phpbb_root_path . 'extension.inc'); 
require('./pagestart.' . $phpEx); 

# 
#-----[ AFTER, ADD ]----- 
# 
if ($board_config['mail_activate']==1) 
{ 

# 
#-----[ FIND ]----- 
# 
$template->pparse('body'); 

include('./page_footer_admin.'.$phpEx); 

# 
#-----[ AFTER, ADD ]----- 
# 
} 
else 
{ 
   message_die(GENERAL_MESSAGE, $lang['Email_off']); 
} 

# 
#-----[ OPEN ]----- 
# 
admin/admin_users.php 

# 
#-----[ FIND ]----- 
# 
if( isset( $HTTP_POST_VARS['mode'] ) || isset( $HTTP_GET_VARS['mode'] ) ) 
{ 
   $mode = ( isset( $HTTP_POST_VARS['mode']) ) ? $HTTP_POST_VARS['mode'] : $HTTP_GET_VARS['mode']; 
} 
else 
{ 
   $mode = ''; 
} 

# 
#-----[ AFTER, ADD ]----- 
# 
if ($board_config['mail_activate']==0) 
{              
   $sql = "UPDATE ". USERS_TABLE ." SET user_notify='0'"; 
        
   if( !($result = $db->sql_query($sql)) ) 
   { 
      message_die(CRITICAL_ERROR, "Could not update user information", "", __LINE__, __FILE__, $sql); 
   } 
    
   $sql = "UPDATE ". USERS_TABLE ." SET user_notify_pm='0'"; 
        
   if( !($result = $db->sql_query($sql)) ) 
   { 
      message_die(CRITICAL_ERROR, "Could not update user information", "", __LINE__, __FILE__, $sql); 
   } 
} 

# 
#-----[ FIND ]----- 
# 
'L_NOTIFY_ON_PRIVMSG' => $lang['Notify_on_privmsg'],
'L_NOTIFY_ON_REPLY' => $lang['Always_notify'],  

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 
//'L_NOTIFY_ON_REPLY' => $lang['Always_notify'], 
//'L_NOTIFY_ON_PRIVMSG' => $lang['Notify_on_privmsg'], 

# 
#-----[ FIND ]----- 
# 
'S_HIDDEN_FIELDS' => $s_hidden_fields, 
'S_PROFILE_ACTION' => append_sid("admin_users.$phpEx")) 
); 

# 
#-----[ AFTER, ADD ]----- 
# 
if ($board_config['mail_activate']==1) 
{ 
   $template->assign_vars(array( 
   'L_NOTIFY_ON_REPLY' => $lang['Always_notify'], 
   'L_NOTIFY_ON_PRIVMSG' => $lang['Notify_on_privmsg']) 
); 


$template->assign_block_vars('mail_activate', array()); 
} 

# 
#-----[ OPEN ]----- 
# 
includes/function_post.php 

# 
#-----[ FIND ]----- 
# 
if (sizeof($bcc_list_ary)) 
{ 

# 
#-----[ AFTER, ADD ]----- 
# 
if ($board_config['mail_activate']==1) 
{ 

# 
#-----[ FIND ]----- 
# 
); 

$emailer->send(); 
$emailer->reset(); 

# 
#-----[ AFTER, ADD ]----- 
# 
} 

# 
#-----[ OPEN ]----- 
# 
includes/usercp_activate.php 

# 
#-----[ FIND ]----- 
# 
if ( !defined('IN_PHPBB') ) 
{ 
   die('Hacking attempt'); 
   exit; 
} 

# 
#-----[ AFTER, ADD ]----- 
# 
if ($board_config['mail_activate']==1) 
{ 

# 
#-----[ FIND ]----- 
# 
else 
{ 
   message_die(GENERAL_MESSAGE, $lang['No_such_user']); 
} 

# 
#-----[ AFTER, ADD ]----- 
# 
} 
else 
{ 
   message_die(GENERAL_MESSAGE, $lang['Email_off']); 
} 

# 
#-----[ OPEN ]----- 
# 
includes/usercp_email.php 

# 
#-----[ FIND ]----- 
# 
if ( !defined('IN_PHPBB') ) 
{ 
   die("Hacking attempt"); 
   exit; 
} 

# 
#-----[ AFTER, ADD ]----- 
# 
if ($board_config['mail_activate']==1) 
{ 

# 
#-----[ FIND ]----- 
# 
else 
{ 
   message_die(GENERAL_MESSAGE, $lang['User_not_exist']); 
} 

# 
#-----[ AFTER, ADD ]----- 
# 
} 
else 
{ 
   message_die(GENERAL_MESSAGE, $lang['Email_off']); 
} 

# 
#-----[ OPEN ]----- 
# 
includes/usercp_register.php 

# 
#-----[ FIND ]----- 
# 
if ( !defined('IN_PHPBB') ) 
{ 
   die("Hacking attempt"); 
   exit; 
} 

# 
#-----[ AFTER, ADD ]----- 
# 
if ($board_config['mail_activate']==0) 
{ 
   $sql = "UPDATE ". CONFIG_TABLE ." SET config_value='0' WHERE config_name='require_activation'"; 
        
   if( !($result = $db->sql_query($sql)) ) 
   { 
      message_die(CRITICAL_ERROR, "Could not update user information", "", __LINE__, __FILE__, $sql); 
   }    
} 

# 
#-----[ FIND ]----- 
# 
if ( !$user_active ) 
{ 

# 
#-----[ AFTER, ADD ]----- 
# 
if ($board_config['mail_activate']==1) 
{ 

# 
#-----[ FIND ]----- 
# 
); 
$emailer->send(); 
$emailer->reset(); 

# 
#-----[ AFTER, ADD ]----- 
# 
} 

# 
#-----[ FIND ]----- 
# 
{ 
   $message = $lang['Account_added']; 
   $email_template = 'user_welcome'; 
} 

# 
#-----[ AFTER, ADD ]----- 
# 
if ($board_config['mail_activate']==1) 
{ 

# 
#-----[ FIND ]----- 
# 
'U_ACTIVATE' => $server_url . '?mode=activate&' . POST_USERS_URL . '=' . $user_id . '&act_key=' . $user_actkey) 
); 
   $emailer->send(); 
   $emailer->reset(); 

# 
#-----[ AFTER, ADD ]----- 
# 
}

# 
#-----[ FIND ]----- 
# 
'L_NOTIFY_ON_REPLY' => $lang['Always_notify'], 
'L_NOTIFY_ON_REPLY_EXPLAIN' => $lang['Always_notify_explain'], 
'L_NOTIFY_ON_PRIVMSG' => $lang['Notify_on_privmsg'], 

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 
//'L_NOTIFY_ON_REPLY' => $lang['Always_notify'], 
//'L_NOTIFY_ON_REPLY_EXPLAIN' => $lang['Always_notify_explain'], 
//'L_NOTIFY_ON_PRIVMSG' => $lang['Notify_on_privmsg'], 

# 
#-----[ FIND ]----- 
# 
'S_FORM_ENCTYPE' => $form_enctype, 
'S_PROFILE_ACTION' => append_sid("profile.$phpEx")) 
); 

# 
#-----[ AFTER, ADD ]----- 
# 
if ($board_config['mail_activate']==1) 
{ 
   $template->assign_vars(array( 
   'L_NOTIFY_ON_REPLY' => $lang['Always_notify'], 
   'L_NOTIFY_ON_REPLY_EXPLAIN' => $lang['Always_notify_explain'], 
   'L_NOTIFY_ON_PRIVMSG' => $lang['Notify_on_privmsg']) 
   ); 
    
   $template->assign_block_vars('mail_activate', array()); 
}

# 
#-----[ OPEN ]----- 
# 
includes/usercp_sendpasswd.php 

# 
#-----[ FIND ]----- 
# 
if ( !defined('IN_PHPBB') ) 
{ 
   die('Hacking attempt'); 
   exit; 
} 

# 
#-----[ AFTER, ADD ]----- 
# 
if ($board_config['mail_activate']==1) 
{ 

# 
#-----[ FIND]----- 
# 
$template->pparse('body'); 

include($phpbb_root_path . 'includes/page_tail.'.$phpEx); 


# 
#-----[ AFTER, ADD ]----- 
# 
else 
{ 
   message_die(GENERAL_MESSAGE, $lang['Email_off']); 
} 


# 
#-----[ OPEN ]----- 
# 
language/lang_english/lang_admin.php 

# 
#-----[ FIND ]----- 
# 
// 
// That's all Folks! 
// ------------------------------------------------- 

# 
#-----[ BEFORE, ADD ]----- 
# 
$lang['Email_activate'] = 'Activate the mail() function on the board'; 
$lang['Email_Activate_Explain'] = 'You can activate the mail function if your host support.'; 

# 
#-----[ OPEN ]----- 
# 
language/lang_english/lang_main.php 

# 
#-----[ FIND ]----- 
# 
// 
// That's all, Folks! 
// ------------------------------------------------- 

# 
#-----[ BEFORE, ADD ]----- 
# 
$lang['Email_off'] = 'Mail() function has been disable on this board'; 

# 
#-----[ OPEN ]----- 
# 
templates/subSilver/profile_add_body.tpl 

# 
#-----[ FIND ]----- 
# 
<tr> 
  <td class="row1"><span class="gen">{L_NOTIFY_ON_REPLY}:</span><br /> 
    <span class="gensmall">{L_NOTIFY_ON_REPLY_EXPLAIN}</span></td> 
  <td class="row2"> 
    <input type="radio" name="notifyreply" value="1" {NOTIFY_REPLY_YES} /> 
    <span class="gen">{L_YES}</span>&& 
    <input type="radio" name="notifyreply" value="0" {NOTIFY_REPLY_NO} /> 
    <span class="gen">{L_NO}</span></td> 
</tr> 
<tr> 
  <td class="row1"><span class="gen">{L_NOTIFY_ON_PRIVMSG}:</span></td> 
  <td class="row2"> 
    <input type="radio" name="notifypm" value="1" {NOTIFY_PM_YES} /> 
    <span class="gen">{L_YES}</span>&& 
    <input type="radio" name="notifypm" value="0" {NOTIFY_PM_NO} /> 
    <span class="gen">{L_NO}</span></td> 
</tr>
 

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 
<!-- BEGIN mail_activate --> 
<tr> 
  <td class="row1"><span class="gen">{L_NOTIFY_ON_REPLY}:</span><br /> 
    <span class="gensmall">{L_NOTIFY_ON_REPLY_EXPLAIN}</span></td> 
  <td class="row2"> 
    <input type="radio" name="notifyreply" value="1" {NOTIFY_REPLY_YES} /> 
    <span class="gen">{L_YES}</span>&& 
    <input type="radio" name="notifyreply" value="0" {NOTIFY_REPLY_NO} /> 
    <span class="gen">{L_NO}</span></td> 
</tr> 
<tr> 
  <td class="row1"><span class="gen">{L_NOTIFY_ON_PRIVMSG}:</span></td> 
  <td class="row2"> 
    <input type="radio" name="notifypm" value="1" {NOTIFY_PM_YES} /> 
    <span class="gen">{L_YES}</span>&& 
    <input type="radio" name="notifypm" value="0" {NOTIFY_PM_NO} /> 
    <span class="gen">{L_NO}</span></td> 
</tr> 
<!-- END mail_activate --> 

# 
#-----[ OPEN ]----- 
# 
templates/subSilver/admin/board_config_body.tpl 

# 
#-----[ FIND ]----- 
# 
<tr> 
  <th class="thHead" colspan="2">{L_EMAIL_SETTINGS}</th> 
</tr> 

# 
#-----[ AFTER, ADD ]----- 
# 
<tr> 
    <td class="row1">{L_ACTIVATE_EMAIL}<br /><span class="gensmall">{L_ACTIVATE_EMAIL_EXPLAIN}</span></td> 
    <td class="row2"><input type="radio" name="mail_activate" value="1" {ACTIVATE_YES} /> {L_YES}&&<input type="radio" name="mail_activate" value="0" {ACTIVATE_NO} /> {L_NO}</td> 
</tr> 

# 
#-----[ OPEN ]----- 
# 
templates/subSilver/admin/user_edit_body.tpl 

# 
#-----[ FIND ]----- 
# 
<tr> 
  <td class="row1"><span class="gen">{L_NOTIFY_ON_REPLY}</span></td>
  <td class="row2"> 
    <input type="radio" name="notifyreply" value="1" {NOTIFY_REPLY_YES} />
    <span class="gen">{L_YES}</span>&& 
    <input type="radio" name="notifyreply" value="0" {NOTIFY_REPLY_NO} />
    <span class="gen">{L_NO}</span></td>
</tr>
<tr> 
  <td class="row1"><span class="gen">{L_NOTIFY_ON_PRIVMSG}</span></td>
  <td class="row2"> 
    <input type="radio" name="notifypm" value="1" {NOTIFY_PM_YES} />
    <span class="gen">{L_YES}</span>&& 
    <input type="radio" name="notifypm" value="0" {NOTIFY_PM_NO} />
    <span class="gen">{L_NO}</span></td>
</tr> 

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 
<!-- BEGIN mail_activate --> 
<tr> 
  <td class="row1"><span class="gen">{L_NOTIFY_ON_REPLY}</span></td> 
  <td class="row2"> 
    <input type="radio" name="notifyreply" value="1" {NOTIFY_REPLY_YES} /> 
    <span class="gen">{L_YES}</span>&& 
    <input type="radio" name="notifyreply" value="0" {NOTIFY_REPLY_NO} /> 
    <span class="gen">{L_NO}</span></td> 
</tr> 
<tr> 
  <td class="row1"><span class="gen">{L_NOTIFY_ON_PRIVMSG}</span></td> 
  <td class="row2"> 
    <input type="radio" name="notifypm" value="1" {NOTIFY_PM_YES} /> 
    <span class="gen">{L_YES}</span>&& 
    <input type="radio" name="notifypm" value="0" {NOTIFY_PM_NO} /> 
    <span class="gen">{L_NO}</span></td> 
</tr> 
<!-- END mail_activate --> 

# 
#-----[ OPEN ]----- 
# 
groupcp.php 

# 
#-----[ FIND ]----- 
# 
message_die(GENERAL_ERROR, "Error getting group moderator data", "", __LINE__, __FILE__, $sql); 
} 

$moderator = $db->sql_fetchrow($result); 

# 
#-----[ AFTER, ADD ]----- 
# 
if ($board_config['mail_activate']==1) 
{ 

# 
#-----[ FIND ]----- 
# 
$emailer->send(); 
$emailer->reset(); 

# 
#-----[ AFTER, ADD ]----- 
# 
} 

# 
#-----[ FIND ]----- 
# 
$group_name_row = $db->sql_fetchrow($result); 

$group_name = $group_name_row['group_name']; 

# 
#-----[ AFTER, ADD ]----- 
# 
if ($board_config['mail_activate']==1) 
{ 

# 
#-----[ FIND ]----- 
# 
'U_GROUPCP' => $server_url . '?' . POST_GROUPS_URL . "=$group_id") 
); 
$emailer->send(); 
$emailer->reset(); 

# 
#-----[ AFTER, ADD ]----- 
# 
} 

# 
#-----[ FIND ]----- 
# 
message_die(GENERAL_ERROR, 'Could not get group information', '', __LINE__, __FILE__, $group_sql); 
} 

$group_name_row = $db->sql_fetchrow($result); 
$group_name = $group_name_row['group_name']; 

# 
#-----[ AFTER, ADD ]----- 
# 
if ($board_config['mail_activate']==1) 
{ 

# 
#-----[ FIND ]----- 
# 
'U_GROUPCP' => $server_url . '?' . POST_GROUPS_URL . "=$group_id") 
); 
$emailer->send(); 
$emailer->reset(); 

# 
#-----[ AFTER, ADD ]----- 
# 
} 

# 
#-----[ OPEN ]----- 
# 
posting.php 

# 
#-----[ FIND ]----- 
# 
// 
// End session management 
// 

# 
#-----[ AFTER, ADD ]----- 
# 
if ($board_config['mail_activate']==0) 
{        
   $sql = "TRUNCATE TABLE ". TOPICS_WATCH_TABLE; 
        
   if( !($result = $db->sql_query($sql)) ) 
   { 
      message_die(CRITICAL_ERROR, "Could not truncate topic watch table", "", __LINE__, __FILE__, $sql); 
   } 
        
   $sql = "UPDATE ". USERS_TABLE ." SET user_notify='0'"; 
        
   if( !($result = $db->sql_query($sql)) ) 
   { 
      message_die(CRITICAL_ERROR, "Could not update user information", "", __LINE__, __FILE__, $sql); 
   } 
} 

# 
#-----[ FIND ]----- 
# 
if ( $userdata['session_logged_in'] && $is_auth['auth_read'] ) 
{ 
   if ( $mode != 'editpost' || ( $mode == 'editpost' && $post_info['poster_id'] != ANONYMOUS ) ) 
   { 

      $template->assign_block_vars('switch_notify_checkbox', array()); 
        
   } 
} 

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 
if ( $userdata['session_logged_in'] && $is_auth['auth_read'] ) 
{ 
   if ( $mode != 'editpost' || ( $mode == 'editpost' && $post_info['poster_id'] != ANONYMOUS ) ) 
   { 
      if ($board_config['mail_activate']==1) 
      { 
         $template->assign_block_vars('switch_notify_checkbox', array()); 
      } 
   } 
} 

# 
#-----[ OPEN ]----- 
# 
privmsg.php 

# 
#-----[ FIND ]----- 
# 
if ( !empty($board_config['privmsg_disable']) ) 
{ 
   message_die(GENERAL_MESSAGE, 'PM_disabled'); 
} 

# 
#-----[ AFTER, ADD ]----- 
# 
if ($board_config['mail_activate']==0) 
{ 
   $sql = "UPDATE ". USERS_TABLE ." SET user_notify_pm='0'"; 
        
   if( !($result = $db->sql_query($sql)) ) 
   { 
      message_die(CRITICAL_ERROR, "Could not update user information", "", __LINE__, __FILE__, $sql); 
   } 
} 

# 
#-----[ FIND ]----- 
# 
$server_name = trim($board_config['server_name']); 
$server_protocol = ( $board_config['cookie_secure'] ) ? 'https://' : 'http://'; 
$server_port = ( $board_config['server_port'] <> 80 ) ? ':' . trim($board_config['server_port']) . '/' : '/'; 

# 
#-----[ AFTER, ADD ]----- 
# 
if ($board_config['mail_activate']==1) 
{ 

# 
#-----[ FIND ]----- 
# 
$emailer->send(); 
$emailer->reset(); 

# 
#-----[ AFTER, ADD ]----- 
# 
}

# 
#-----[ OPEN ]----- 
#

viewtopic.php

# 
#-----[ FIND ]----- 
#

'S_WATCH_TOPIC' => $s_watching_topic,
'S_WATCH_TOPIC_IMG' => $s_watching_topic_img,

# 
#-----[ REPLACE WITH ]------------------------------------------ 
#

//'S_WATCH_TOPIC' => $s_watching_topic,
//'S_WATCH_TOPIC_IMG' => $s_watching_topic_img,

# 
#-----[ FIND ]----- 
#
'U_POST_NEW_TOPIC' => $new_topic_url,
	'U_POST_REPLY_TOPIC' => $reply_topic_url)
);


# 
#-----[ AFTER, ADD ]----- 
#

if ($board_config['mail_activate']==1) 
{
   $template->assign_vars(array(
	'S_WATCH_TOPIC' => $s_watching_topic,
	'S_WATCH_TOPIC_IMG' => $s_watching_topic_img) 
   ); 
    
   $template->assign_block_vars('mail_activate', array()); 
}

# 
#-----[ OPEN ]----- 
#

viewtopic_body.tpl

# 
#-----[ FIND ]----- 
#
<tr> 
	<td width="40%" valign="top" nowrap="nowrap" align="left"><span class="gensmall">{S_WATCH_TOPIC}</span><br />
	  &<br />
	  {S_TOPIC_ADMIN}</td>
	<td align="right" valign="top" nowrap="nowrap">{JUMPBOX}<span class="gensmall">{S_AUTH_LIST}</span></td>
  </tr>

# 
#-----[ REPLACE WITH ]------------------------------------------ 
#
<tr> 
	<td width="40%" valign="top" nowrap="nowrap" align="left">
	<!-- BEGIN mail_activate -->
	<span class="gensmall">{S_WATCH_TOPIC}</span>
	<br />
	<!-- END mail_activate -->
	  &<br />
	  {S_TOPIC_ADMIN}</td>
	<td align="right" valign="top" nowrap="nowrap">{JUMPBOX}<span class="gensmall">{S_AUTH_LIST}</span></td>
  </tr>


# 
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ 
# 
# EoM

Posted: Thu Jun 12, 2003 7:29 pm
by FX
new beta.

Fixed link in viewtopic (watch this topic).