Глобальную Отправить сообщение всем своим членам.
Но я столкнулись с проблемой: Если у меня есть,
например 50 + членов, вместо того, чтобы отправить
его к ним, соответственно, он пошлет сообщение мне
50 раз. Вот код PHP, попробуйте помочь мне
исправить
<?php
#MODIFICATION BY COMRADE79
#DONT REMOVE MY COPYRIGHT
define('_IN_JOHNCMS', 1);
require_once("../incfiles/core.php");
if (core::$user_rights < 7) {
header('Location: ../index.php');
exit;
}
$headmod = 'Message to all';
$textl = 'Message to all';
require_once("../incfiles/head.php");
switch($_GET['act']) {
default:
$subj = "Notification";
echo '<div class="mainblok"><div class="phdr" style="font-weight:bold;">Message To All</div>' . "\n";
echo '<div class="gmenu"><form action="sendpm.php?act=start" method="POST">';
echo '<b>Send to:</b><br/>';
echo '<select name="sel"><option value="all">All Members</option><option value="m">All Boys</option><option value="zh">All Girls</option><option value="fmoder">Forum moderator</option><option value="dmoder">Download moderator</option><option value="lmoder">Library moderator</option><option value="smoder">Super moderator</option><option value="administrator">Administrator</option></select><br/>' . "\n";
echo '<b>Subject: </b><br/>';
echo '<input type="text" name="subject" value="' . $subj . '"/><br/>';
echo '<b>Message: </b><br/>';
echo '<textarea rows="' . $set_user['field_h'] . '" cols="17" name="message"></textarea><br/>';
echo '<input type="submit" value="Send pm"/>' . "\n";
echo '</form></div>';
echo '<div class="phdr"><a href="/pages/faq.php?act=tags">Bbcode</a> • <a href="/pages/faq.php?act=smileys">Smileys</a></div>';
break;
case 'start':
if (empty($_POST['message'])) {
echo '<div class="orange">Error.. Your message could not be empty..!!<br/><a href="sendpm.php">Back</a></div>';
require_once("../incfiles/end.php");
exit;
}
echo '<div class="mainblok"><div class="phdr" style="font-weight:bold;">Succes sended..!!</div>' . "\n";
echo '<div class="gmenu">';
$inform = functions::check(trim($_POST['subject']));
$soob = functions::check(trim($_POST['message']));
#COMRADE 79
if ($_POST['sel'] == 'all') {
$col1 = mysql_result(mysql_query("SELECT COUNT(*) FROM `users`;"), 0);
$asp = mysql_query("SELECT `name` FROM `users` ORDER BY `id` DESC LIMIT $col1;");
$wx = 0;
while ($user = mysql_fetch_assoc($asp)) {
$usname = $user['name'];
$admin = 'Supervisor';
if ($usname == $admin) {
continue;
}
mysql_query("INSERT INTO `cms_mail` SET
`user_id` = '" . $usname . "',
`from_id` = '0',
`text` = '" . $soob . "',
`time` = '" . time() . "',
`sys` = '1',
`them` = '" . $inform . "'
");
$wx++;
}
echo 'Message succsesfully executed..<br/>and sended to <span class="red"><b>' .$wx. '</b></span> Members..!!';
}
#COMRADE 79
if ($_POST['sel'] == 'm') {
$col2 = mysql_result(mysql_query("SELECT COUNT(*) FROM `users` WHERE `sex`='m';"), 0);
$asp = mysql_query("SELECT `name` FROM `users` WHERE `sex`='m' ORDER BY `id` DESC LIMIT $col2;");
$wx = 0;
while ($user = mysql_fetch_assoc($asp)) {
$usname = $user['name'];
$admin = 'Administrator';
if ($usname == $admin) {
continue;
}
mysql_query("INSERT INTO `cms_mail` SET
`user_id` = '0',
`from_id` = '" . $user_id . "',
`text` = '" . $soob . "',
`time` = '" . time() . "',
`sys` = '0',
`them` = '" . $inform . "'
");
$wx++;
}
echo 'Message successfully executed..<br/>and sended to <span class="red"><b>' .$wx. '</b></span> Male members..!!';
}
#COMRADE 79
elseif ($_POST['sel'] == 'zh') {
$col3 = mysql_result(mysql_query("SELECT COUNT(*) FROM `users` WHERE `sex`='zh';"), 0);
$asp = mysql_query("SELECT `name` FROM `users` WHERE `sex`='zh' ORDER BY `id` DESC LIMIT $col3;");
$wx = 0;
while ($user = mysql_fetch_assoc($asp)) {
$usname = $user['name'];
$admin = 'Administrator';
if ($usname != $admin) {
continue;
}
mysql_query("INSERT INTO `cms_mail` SET
`user_id` = '0',
`from_id` = '" . $user_id . "',
`text` = '" . $soob . "',
`time` = '" . time() . "',
`sys` = '1',
`them` = '" . $inform . "'
");
$wx++;
}
echo 'Message successfully executed..<br/>and sended to <span class="red"><b>' .$wx. '</b></span> Female members..!!';
}
#COMRADE 79
elseif ($_POST['sel'] == 'fmoder') {
$col4 = mysql_result(mysql_query("SELECT COUNT(*) FROM `users` WHERE `rights`=3;"), 0);
$asp = mysql_query("SELECT `name` FROM `users` WHERE `rights`=3 ORDER BY `id` DESC LIMIT $col4;");
$wx = 0;
while ($user = mysql_fetch_assoc($asp)) {
$usname = $user['name'];
$admin = 'Administrator';
if ($usname == $admin) {
continue;
}
mysql_query("INSERT INTO `cms_mail` SET
`user_id` = '0',
`from_id` = '" . $user_id . "',
`text` = '" . $soob . "',
`time` = '" . time() . "',
`sys` = '1',
`them` = '" . $inform . "'
");
$wx++;
}
echo 'Message successfully executed..<br/>and sended to <span class="red"><b>' .$wx. '</b></span> Forum moderator..!!';
}
#COMRADE 79
elseif ($_POST['sel'] == 'dmoder') {
$col5 = mysql_result(mysql_query("SELECT COUNT(*) FROM `users` WHERE `rights`=4;"), 0);
$asp = mysql_query("SELECT `name` FROM `users` WHERE `rights`=4 ORDER BY `id` DESC LIMIT $col5;");
$wx = 0;
while ($user = mysql_fetch_assoc($asp)) {
$usname = $user['name'];
$admin = 'Administrator';
if ($usname == $admin) {
continue;
}
mysql_query("INSERT INTO `cms_mail` SET
`user_id` = '0',
`from_id` = '" . $user_id . "',
`text` = '" . $soob . "',
`time` = '" . time() . "',
`sys` = '1',
`them` = '" . $inform . "'
");
$wx++;
}
echo 'Message successfully executed..<br/>and sended to <span class="red"><b>' .$wx. '</b></span> Download moderator..!!';
}
#COMRADE 79
elseif ($_POST['sel'] == 'lmoder') {
$col6 = mysql_result(mysql_query("SELECT COUNT(*) FROM `users` WHERE `rights`=5;"), 0);
$asp = mysql_query("SELECT `name` FROM `users` WHERE `rights`=5 ORDER BY `id` DESC LIMIT $col6;");
$wx = 0;
while ($res = mysql_fetch_assoc($asp)) {
$usname = $res['name'];
$admin = 'Administrator';
if ($usname == $admin) {
continue;
}
mysql_query("INSERT INTO `cms_mail` SET
`user_id` = '0',
`from_id` = '" . $user_id . "',
`text` = '" . $soob . "',
`time` = '" . time() . "',
`sys` = '1',
`them` = '" . $inform . "'
");
$wx++;
}
echo 'Message successfully executed..<br/>and sended to <span class="red"><b>' .$wx. '</b></span> Library moderator..!!';
}
#COMRADE 79
elseif ($_POST['sel'] == 'smoder') {
$col7 = mysql_result(mysql_query("SELECT COUNT(*) FROM `users` WHERE `rights`=6;"), 0);
$asp = mysql_query("SELECT `name` FROM `users` WHERE `rights`=6 ORDER BY `id` DESC LIMIT $col7;");
$wx = 0;
while ($res = mysql_fetch_assoc($asp)) {
$usname = $res['name'];
$admin = 'Administrator';
if ($usname == $admin) {
continue;
}
mysql_query("INSERT INTO `cms_mail` SET
`user_id` = '0',
`from_id` = '" . $user_id . "',
`text` = '" . $soob . "',
`time` = '" . time() . "',
`sys` = '1',
`them` = '" . $inform . "'
");
$wx++;
}
echo 'Message successfully executed..<br/>and sended to <span class="red"><b>' .$wx. '</b></span> Super moderator..!!';
}
#COMRADE 79
elseif ($_POST['sel'] == 'administrator') {
$col8 = mysql_result(mysql_query("SELECT COUNT(*) FROM `users` WHERE `rights`=7;"), 0);
$asp = mysql_query("SELECT `name` FROM `users` WHERE `rights`=7 ORDER BY `id` DESC LIMIT $col8;");
$wx = 0;
while ($res = mysql_fetch_assoc($asp)) {
$usname = $res['name'];
$admin = 'Supervisor';
if ($usname == $admin) {
continue;
}
mysql_query("INSERT INTO `cms_mail` SET
`user_id` = '0',
`from_id` = '" . $user_id . "',
`text` = '" . $soob . "',
`time` = '" . time() . "',
`sys` = '1',
`them` = '" . $inform . "'
");
$wx++;
}
echo 'Message successfully executed..<br/>and sended to <span class="red"><b>' .$wx. '</b></span> Administrator..!!';
}
echo '</div><div class="phdr"><a href="index.php">' . $lng['admin_panel'] . '</a></div>';
break;
}
echo '</div>';
require_once("../incfiles/end.php");
?>