Подскажите пожалуйста человеку который первый раз сталкивается со скриптами рассылки. Нужно внедрить ограничение а по возможности и внедрить метод sleep () вот для этого кода.
PHP код:
<?
session_start();
require_once('../inc/global_var.php');
require_once('../inc/connect.php');
require('check_session.php');
require('../inc/lib.php');
$ds_arr = mysql_fetch_array(mysql_query('select count(distinct(t.em)) as cr from
(select email as em from object where email<>\'\'
union all
select email as em from job_list where email<>\'\'
union all
select from_email as em from send_message where from_email<>\'\'
) as t where t.em not in (SELECT email FROM send_ignore_list_email)'));
$count_all_email=$ds_arr['cr'];
//=====================================================================================================================
if (isset($_GET['test_id']))//делаем тестовую рассылку на порталовский адрес
{
$ds_arr=mysql_fetch_array(mysql_query("select * from send_to_all_mess where id=".$_GET['test_id']));
$msg_text = $ds_arr['text_message'];
$to_email='info@krasnodar-today.ru';
if ($ds_arr['unsubscribe']=='yes') $msg_text=$msg_text.'<br><br><br><br><p align="center" style="font-style:italic">
Если Вы хотите отказаться от получения этой рассылки, нажмите <a href="http://'.$g_domain.'/unsubscribe.php?email='.$to_email.'">здесь</a></p>';
$b = mail_($ds_arr['from_address'],$to_email,$ds_arr['subject'],$msg_text);
if ($b)
header("Location: send_to_all_email.php?test_send_email=success");
else
header("Location: send_to_all_email.php?test_send_email=falue");
}
//============================ГЕНЕРАЦИЯ НОВОСТНОЙ РАССЫЛКИ===============================================================
if (isset($_POST['save_add_news'])) // сформируем и сохраним письмо после его добавления
{
$body='<style type="text/css">
p, span, strong, b, div, a {font-family:tahoma;font-size:12px;}
a { text-decoration: underline; color: rgb(8, 87, 166); }
a:hover { text-decoration: none; }
#brd {border: 1px dotted rgb(204, 204, 204);}
</style>
<p>Новости '.$g_gorod_2.' от '.date("d.m.Y").'</p><br>
<a href="http://'.$g_domain.'"><img height="47" border="0" width="280" alt="" src="http://'.$g_domain.'/img/'.$g_gorod_4.'_logo_email.jpg" /></a>
<br><br><br>
<table cellspacing="5" cellpadding="5" width="100%" id="brd">
<tbody>';
$arr=explode("|", $_POST['sel_id_news']);
$n=1;
for ($i=0;$i<count($arr)-1;$i++)
{
$ds_arr = mysql_fetch_assoc(mysql_query("SELECT * FROM news_list where id_news=".$arr[$i]));
if ($n==1) {$body.='<tr>';}
$body.='<td width="50%" valign="top" id="brd">
<a target="_blank" href="http://'.$g_domain.'/news/news_full.php?id_news='.$ds_arr['id_news'].'">
<img border="0" src="http://'.$g_domain.'/news/news_files/image_pict/'.$ds_arr['id_news'].'.jpg" /><br><br>
<b>'.str_replace("'","\"",$ds_arr['caption_news']).'</b>
</a><br><br>
</td>';
$n++;
if ($n==3) {$body.='</tr>';$n=1;}
}
$body.='</tbody></table><br>
<p>С уважением, Администрация городского портала <a href="http://'.$g_domain.'">http://'.$g_domain.'/</a><br />
г. '.$g_gorod_1.'<br />
info@krasnodar-today.ru</p>';
if (isset($_POST['unsubscribe'])) $unsubscribe='yes'; else $unsubscribe='no';
$sql_str = "INSERT INTO send_to_all_mess(date_create,from_address,subject,text_message,count_email,status_,unsubscribe)
VALUES (NOW(),
'".$_POST['from_address']."',
'".$_POST['subject']."',
'".$body."',
".$count_all_email.",
'".$_POST['status_']."',
'".$unsubscribe."')";
//echo $sql_str;
mysql_query($sql_str) or die(mysql_error());
$insert_id=mysql_insert_id();
$sql_str = "INSERT INTO send_list_email(email,id_subscribe)
select distinct(t.em),".$insert_id." from
(select email as em from object where email<>''
union all
select email as em from job_list where email<>''
union all
select from_email as em from send_message where from_email<>''
) as t where t.em not in (SELECT email FROM send_ignore_list_email)";
mysql_query($sql_str) or die(mysql_error());
header("Location: send_to_all_email.php");
}
?>
Использую класс phpmailer
Заранее благодарен за любую помошь!