Massmail

Started by Diablo999, June 06, 2016, 05:02:14 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

DragonCoder


Diablo999

Requested by DragonCoder.
<?php

if ( ! defined'IN_TBDEV_ADMIN' ) )
{
        
$htmlout='';
        
$htmlout .= "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
                \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
                <html xmlns='http://www.w3.org/1999/xhtml'>
                <head>
                <title>Error!</title>
                </head>
                <body>
        <div style='font-size:33px;color:white;background-color:red;text-align:center;'>Incorrect access<br />You cannot access this file directly.</div>
        </body></html>"
;
        print 
$htmlout;
        exit();
}

require_once 
"include/user_functions.php";

   
   
$lang array_merge($langload_language('ad_massmail') );

if ((
$CURUSER['class'] < UC_SYSOP) || ($CURUSER['id'] == '1,3')) /* sysop id check */ 
        
stderr("{$lang['email_error']}""{$lang['email_error2']}"); 
}       

if (
$_SERVER["REQUEST_METHOD"] == "POST"
{

        
$to '';

        switch(
$_POST['to']) {
        
        case 
'class_0'$to "FROM users WHERE class = '0' ";
                break;
        case 
'class_1'$to "FROM users WHERE class = '1' ";
                break;
        case 
'class_2'$to "FROM users WHERE class = '2' ";
                break;
        case 
'class_3'$to "FROM users WHERE class = '3' ";
                break;
        case 
'class_4'$to "FROM users WHERE class = '4' ";
                break;
        case 
'class_5'$to "FROM users WHERE class = '5' ";
                break;
        case 
'class_6'$to "FROM users WHERE class = '6' ";
                break;
        case 
'class_7'$to "FROM users WHERE class <= '3' ";
            break;
        case 
'dt'$to "FROM users WHERE last_login=$dt ";
                break;
        case 
'all'$to "FROM users ";
                break;
        }
// end switch

  
$subject $_POST['subject'];
  
$message $_POST['message'];


   
$x 1;
   
$hold 50// quantity of emails sent before 3 sec delay
   
$days 42;
   
$dt = (time() - ($days 86400));
   
   
$emails mysql_query("SELECT email $to ");

while (
$sendemail mysql_fetch_array($emails)) {
   
$email $sendemail["email"];
   
$success mail($email$subject,$message"{$lang['email_from']}{$TBDEV["site_name"]} {$TBDEV["site_email"]}");
   

   
$x++;
        if(
$x == $hold) { // When $x is equal to $hold, a 3 sec delay will occur avoiding php to timeout
        
sleep(3);
        
$x 0;
        }
// end of while loop

if ($success)
        
stderr("{$lang['email_success']}""{$lang['email_queued']}");
        else
        
stderr("{$lang['email_error']}""{$lang['email_failed']}");
        
        
 }
 
 
$HTMLOUT '';

$HTMLOUT .= "<form method='post' action='admin.php?action=massmail'>";
$HTMLOUT .= "
<table align='center'  width='700' border='0' cellpadding='0' cellspacing='0' class='main'>
<tr><td align='center' class='colhead'><b><h2>
{$lang['email_to']}</h2></b></td></tr>

<tr><td align='center' style='height:25px;'>
{$lang['email_send']}

<select name='to' size='1' style='background-color: #F7F7F7'>
<option value='all'> 
{$lang['email_all']} </option>
<option value='dt'> 
{$lang['email_inactive']}</option>
<option value='class_0'> 
{$lang['email_users']}  </option>
<option value='class_1'> 
{$lang['email_power_users']} </option>
<option value='class_2'> 
{$lang['email_vip']} </option>
<option value='class_3'> 
{$lang['email_fls']}  </option>
<option value='class_4'> 
{$lang['email_moderators']}  </option>
<option value='class_5'> 
{$lang['email_administrators']}  </option>
<option value='class_6'> 
{$lang['email_sys_op']}  </option>
<option value='class_7'> 
{$lang['email_below']}  </option>
</select></td></tr>

<tr><td align='center' style='height:25px;'>
{$lang['email_subject']}<input name='subject' type='text' maxlength='50' size='70' /></td></tr>

<tr><td align='center'>
{$lang['email_message']}<br /><textarea wrap name='message' rows='20' cols='145'></textarea></td></tr>
<tr><td align='center' style='height:35px;'><input type='submit' name='submit' value='SUBMIT' style='color:green;' /></td></tr>

</table></form>"
;

print 
stdhead("{$lang['email_mass']}"false) . $HTMLOUT stdfoot();

?>


/lang/en/lang_massmail.php
<?php

$lang 
= array(


'email_mass'=>"Mass Mail",
'email_error' =>"Error",
'email_error2'=>"You have no rights to be here",
'email_to'=>"SEND GROUP-MAIL",
'email_from' => "From: ",
'email_send'=>"<b>Send message to:</b>",
'email_subject' =>"<b>Subject:</b>  ",
'email_message' =>"<b>Message:</b>",
'email_all'=>"All Users",
'email_inactive'=>"Inactiv Users (last login < 42 days)",
'email_users'=>"Users",
'email_power_users'=>"Power Users",
'email_vip'=>"Super VIP",
'email_fls'=>"FLS",
'email_moderators'=>"Moderators",
'email_administrators'=>"Administrators",
'email_sys_op'=>"Sysop",
'email_below'=>"All below Moderators",
'email_queued' => "E-mail successfully queued for delivery.",
'email_failed' => "The mail could not be sent. Please try again later.",
'email_success' => "Success",
);

?>