هنگاميكه ما ميخواهيم خبرنامهيي بفرستيم، دو امكان در دسترس مان است، يكي فرستادن آن به كسانيكه عضو خبرنامه شده اند و ديگري هم نامه همگاني به همه كاربران سايت.
اما بنده كمي جلو رفته خواستم تا يك table ديگر در بانك اطلاعاتي باز كنم همانند nuke_user مثلاً به نام nuke_toalluser و در آنجا نام و ايميل كساني را درج كنم كه حتي عضو سايت هم نشده اند و از اين طريق بتوانم تبليغات وسيعتر هم فرستاد. الان توي فايل newsletter.php اين تغييرات را آوردم:
توي فايل case.newsletter.php همچنان اين تغييرات را بياوريد:
الان تا اينجا پيش رفتيم و بعداً كوشش مي كنم كه تو ديتابيس هم بتوانيم ايميل ها را اضافه كنيم و يا اگر كسي ديگري بتواند اين كار انجام دهد و موژول درست كند كه بسيار خوب ميباشد.
البته بايد گفت كه توي تابل nuke_toalluser ما صرف به نام و ايميل ضرورت داريم.
اما بنده كمي جلو رفته خواستم تا يك table ديگر در بانك اطلاعاتي باز كنم همانند nuke_user مثلاً به نام nuke_toalluser و در آنجا نام و ايميل كساني را درج كنم كه حتي عضو سايت هم نشده اند و از اين طريق بتوانم تبليغات وسيعتر هم فرستاد. الان توي فايل newsletter.php اين تغييرات را آوردم:
کد:
if (!eregi("admin.php", $_SERVER['PHP_SELF'])) { die ("Access Denied"); }
$result = sql_query("select radminnewsletter, radminsuper from ".$prefix."_authors where aid='$aid'", $dbi);
list($radminnewsletter, $radminsuper) = sql_fetch_row($result, $dbi);
if (($radminnewsletter==1) OR ($radminsuper==1)) {
/*********************************************************/
/* Sections Manager Functions */
/*********************************************************/
function newsletter() {
global $prefix, $user_prefix, $dbi, $sitename;
include("header.php");
GraphicAdmin();
$srow = sql_num_rows(sql_query("select * from ".$user_prefix."_users where newsletter='1'", $dbi), $dbi);
$urow = sql_num_rows(sql_query("select * from ".$user_prefix."_users", $dbi), $dbi);
$trow = sql_num_rows(sql_query("select * from ".$user_prefix."_toalluser", $dbi), $dbi);
$urow--;
$trow--;
OpenTable();
echo "<center><font class=\"title\"><b>"._NEWSLETTER."</b></font></center>";
CloseTable();
echo "<br>";
OpenTable();
echo "<center><font class=\"content\"><b>"._NEWSLETTER."</b></font></center>"
."<br><br>"
."<form method=\"post\" action=\"admin.php\">"
."<b>"._FROM.":</b> $sitename"
."<br><br>"
."<b>"._SUBJECT.":</b><br><input type=\"text\" name=\"subject\" size=\"50\"onkeypress=FKeyPress(this); onkeydown=FKeyDown(this);> <IMG src=\"images/fa2.gif\" style=\"CURSOR: hand\" onclick=change(subject)>"
."<br><br>"
."<b>"._CONTENT.":</b><br><textarea name=\"content\" cols=\"80\" rows=\"15\";></textarea><br>"
. "<script language=\"JavaScript1.2\" defer>\n"
. "editor_generate('content');\n"
. "</script>\n"
."<br><br>"
."<b>"._WHATTODO."</b><br>"
."<input type=\"radio\" name=\"type\" value=\"newsletter\"> "._ANEWSLETTER." ($srow "._SUBSCRIBEDUSERS.")<br>"
."<input type=\"radio\" name=\"type\" value=\"massmail\" checked> "._MASSMAIL." ($urow "._USERS.")<br>"
."<input type=\"radio\" name=\"type\" value=\"toallmail\"> "._TOALLMAIL." ($trow "._USERS.")"
."<br><br>"
."<input type=\"hidden\" name=\"op\" value=\"check_type\">"
."<input type=\"submit\" value=\""._PREVIEW."\">"
."</form>";
CloseTable();
include("footer.php");
}
function check_type($subject, $content, $type) {
global $user_prefix, $dbi, $sitename;
include("header.php");
GraphicAdmin();
$srow = sql_num_rows(sql_query("select * from ".$user_prefix."_users where newsletter='1'", $dbi), $dbi);
$urow = sql_num_rows(sql_query("select * from ".$user_prefix."_users", $dbi), $dbi);
$trow = sql_num_rows(sql_query("select * from ".$user_prefix."_toalluser", $dbi), $dbi);
$urow--;
$trow--;
OpenTable();
echo "<center><font class=\"title\"><b>"._NEWSLETTER."</b></font></center>";
CloseTable();
echo "<br>";
OpenTable();
$content = stripslashes($content);
if ($type == "newsletter") {
echo "<center><font class=\"content\"><b>"._NEWSLETTER."</b></font>"
."<br><br>"
."<form action\"admin.php\" method=\"post\">"
.""._NYOUAREABOUTTOSEND."<br>"
."<b>$srow</b> "._NUSERWILLRECEIVE."<br><br>"
."<b>"._REVIEWTEXT."</b></center><br><br>"
."<b>"._FROM.":</b> $sitename<br><br>"
."<b>"._CHANGELANG."</b><br><br><b>"._SUBJECT.":</b><br><input type=\"text\" name=\"title\" value=\"$subject\" size=\"50\"onkeypress=FKeyPress(this); onkeydown=FKeyDown(this);> <br><br>"
."<b>"._CONTENT.":</b><br><textarea name=\"content\" cols=\"80\" rows=\"15\";>$content</textarea><br><br><br><br>"
. "<script language=\"JavaScript1.2\" defer>\n"
. "editor_generate('content');\n"
. "</script>\n"
."<b>"._NAREYOUSURE2SEND."</b><br><br>"
."<input type=\"hidden\" name=\"op\" value=\"newsletter_send\">"
."<input type=\"submit\" value=\""._SEND."\"> &nbsp;&nbsp; "._GOBACK.""
."</form>";
} elseif ($type == "toallmail") {
echo "<center><font class=\"content\"><b>"._TOALLMASSIVEEMAIL."</b></font>"
."<br><br>"
."<form action\"admin.php\" method=\"post\">"
.""._MYOUAREABOUTTOSEND."<br>"
."<b>$trow</b> "._MUSERWILLRECEIVE."<br>"
."<i><b>"._POSSIBLESPAM."</b></i><br><br>"
."<b>"._REVIEWTEXT."</b></center><br><br>"
."<b>"._FROM.":</b> $sitename<br><br>"
."<b>"._CHANGELANG."</b><br><br><b>"._SUBJECT.":</b><br><input type=\"text\" name=\"title\" value=\"$subject\" size=\"50\"onkeypress=FKeyPress(this); onkeydown=FKeyDown(this);><br><br>"
."<b>"._CONTENT.":</b><br><textarea name=\"content\" cols=\"80\" rows=\"10\";>$content</textarea><br><br><br><br>"
. "<script language=\"JavaScript1.2\" defer>\n"
. "editor_generate('content');\n"
. "</script>\n"
."<b>"._MAREYOUSURE2SEND."</b><br><br>"
."<input type=\"hidden\" name=\"op\" value=\"toallmail_send\">"
."<input type=\"submit\" value=\""._SEND."\"> &nbsp;&nbsp; "._GOBACK.""
."</form>";
} elseif ($type == "massmail") {
echo "<center><font class=\"content\"><b>"._MASSIVEEMAIL."</b></font>"
."<br><br>"
."<form action\"admin.php\" method=\"post\">"
.""._MYOUAREABOUTTOSEND."<br>"
."<b>$urow</b> "._MUSERWILLRECEIVE."<br>"
."<i><b>"._POSSIBLESPAM."</b></i><br><br>"
."<b>"._REVIEWTEXT."</b></center><br><br>"
."<b>"._FROM.":</b> $sitename<br><br>"
."<b>"._CHANGELANG."</b><br><br><b>"._SUBJECT.":</b><br><input type=\"text\" name=\"title\" value=\"$subject\" size=\"50\"onkeypress=FKeyPress(this); onkeydown=FKeyDown(this);><br><br>"
."<b>"._CONTENT.":</b><br><textarea name=\"content\" cols=\"80\" rows=\"10\";>$content</textarea><br><br><br><br>"
. "<script language=\"JavaScript1.2\" defer>\n"
. "editor_generate('content');\n"
. "</script>\n"
."<b>"._MAREYOUSURE2SEND."</b><br><br>"
."<input type=\"hidden\" name=\"op\" value=\"massmail_send\">"
."<input type=\"submit\" value=\""._SEND."\"> &nbsp;&nbsp; "._GOBACK.""
."</form>";
}
if (($type == "newsletter") AND ($srow > 500)) {
CloseTable();
echo "<br>";
OpenTable();
echo "<center><i>"._MANYUSERSNOTE."</i></center>";
} elseif (($type == "toallmail") AND ($trow > 500)) {
CloseTable();
echo "<br>";
OpenTable();
echo "<center><i>"._MANYUSERSNOTE."</i></center>";
} elseif (($type == "massmail") AND ($urow > 500)) {
CloseTable();
echo "<br>";
OpenTable();
echo "<center><i>"._MANYUSERSNOTE."</i></center>";
}
CloseTable();
include("footer.php");
}
function newsletter_send($title, $content) {
global $user_prefix, $sitename, $dbi, $nukeurl, $adminmail;
$from = $adminmail;
$subject = "[$sitename Newsletter]: ".stripslashes($title)."";
$content = stripslashes($content);
$content = "<div align=\"right\" dir=\"rtl\">"._NEWSLETTER." $sitename\n\n\n<br><br><br>$content\n\n<br><br>- "._STAFF." $sitename\n\n\n\n\n\n<br><br><br><br><br><br>"._NLUNSUBSCRIBE."</div>";
$content = FarsiMailNewsletter($content);
$result = sql_query("select user_email from ".$user_prefix."_users where newsletter='1'", $dbi);
while(list($user_email) = sql_fetch_row($result, $dbi)) {
mail($user_email, $subject, $content, "MIME-Version: 1.0\r\nContent-type: text/html; charset=utf-8\r\nFrom: $from\nX-Mailer: PHP/" . phpversion());
}
Header("Location: admin.php?op=newsletter_sent");
}
function newsletter_sent() {
include("header.php");
GraphicAdmin();
OpenTable();
echo "<center><font class=\"title\"><b>"._NEWSLETTER."</b></font></center>";
CloseTable();
echo "<br>";
OpenTable();
echo "<center><font class=\"content\"><b>"._NEWSLETTER."</b></font><br><br>";
echo "<b>"._NEWSLETTERSENT."</b></center>";
CloseTable();
include("footer.php");
}
function massmail_send($title, $content) {
global $user_prefix, $sitename, $dbi, $nukeurl, $adminmail;
$from = $adminmail;
$subject = "[$sitename]: $title";
$content = stripslashes($content);
$content = "<div align=\"right\" dir=\"rtl\">"._FROM.": $sitename\n\n\n\n<br><br><br><br>$content\n\n\n\n<br><br><br><br>- "._STAFF." $sitename\n\n\n\n<br><br><br><br>"._MASSEMAILMSG."</div>";
$content = FarsiMailNewsletter($content);
$result = sql_query("select user_email from ".$user_prefix."_users where user_id != '1'", $dbi);
while(list($user_email) = sql_fetch_row($result, $dbi)) {
mail($user_email, $subject, $content, "MIME-Version: 1.0\r\nContent-type: text/html; charset=utf-8\r\nFrom: $from\nX-Mailer: PHP/" . phpversion());
}
Header("Location: admin.php?op=massmail_sent");
}
function massmail_sent() {
include("header.php");
GraphicAdmin();
OpenTable();
echo "<center><font class=\"title\"><b>"._MASSEMAIL."</b></font></center>";
CloseTable();
echo "<br>";
OpenTable();
echo "<center><font class=\"content\"><b>"._MASSEMAIL."</b></font><br><br>";
echo "<b>"._MASSEMAILSENT."</b></center>";
CloseTable();
include("footer.php");
}
function toallmail_send($title, $content) {
global $user_prefix, $sitename, $dbi, $nukeurl, $adminmail;
$from = $adminmail;
$subject = "[$sitename]: $title";
$content = stripslashes($content);
$content = "<div align=\"right\" dir=\"rtl\">"._FROM.": $sitename\n\n\n\n<br><br><br><br>$content\n\n\n\n<br><br><br><br>- "._STAFF." $sitename\n\n\n\n<br><br><br><br>"._MASSEMAILMSG."</div>";
$content = FarsiMailNewsletter($content);
$result = sql_query("select user_email from ".$user_prefix."_toalluser where user_id != '1'", $dbi);
while(list($user_email) = sql_fetch_row($result, $dbi)) {
mail($user_email, $subject, $content, "MIME-Version: 1.0\r\nContent-type: text/html; charset=utf-8\r\nFrom: $from\nX-Mailer: PHP/" . phpversion());
}
Header("Location: admin.php?op=toallmail_sent");
}
function toallmail_sent() {
include("header.php");
GraphicAdmin();
OpenTable();
echo "<center><font class=\"title\"><b>"._TOALLEMAIL."</b></font></center>";
CloseTable();
echo "<br>";
OpenTable();
echo "<center><font class=\"content\"><b>"._TOALLEMAIL."</b></font><br><br>";
echo "<b>"._TOALLEMAILSENT."</b></center>";
CloseTable();
include("footer.php");
}
switch ($op) {
case "newsletter":
newsletter();
break;
case "newsletter_send":
newsletter_send($title, $content);
break;
case "newsletter_sent":
newsletter_sent();
break;
case "massmail_send":
massmail_send($title, $content);
break;
case "massmail_sent":
massmail_sent();
break;
case "toallmail_send":
toallmail_send($title, $content);
break;
case "toallmail_sent":
toallmail_sent();
break;
case "check_type":
check_type($subject, $content, $type);
break;
}
} else {
echo "Access Denied";
}
?>
کد:
if (!eregi("admin.php", $_SERVER['PHP_SELF'])) { die ("Access Denied"); }
switch($op) {
case "newsletter":
case "newsletter_send":
case "newsletter_sent":
case "massmail_send":
case "massmail_sent":
case "toallmail_send":
case "toallmail_sent":
case "check_type":
include("admin/modules/newsletter.php");
break;
}
?>
البته بايد گفت كه توي تابل nuke_toalluser ما صرف به نام و ايميل ضرورت داريم.