Problem with sending General Pm to members

287
.
I tried to mod my Send Message to All member using Johncms latest version of 5.2.1 but the problem is that it doesn't send the message.

Here is the php code, please help me to fix it
<?php
#MODIFICATION BY ADEPETER
#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 name="form11" 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 bbcode::auto_bb2('form11', 'message');
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> &bull; <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']));
# ADEPETER TO MEMBERS
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 ($res = mysql_fetch_assoc($asp)) {
$usname = $res['name'];
$admin = 'Supervisor';
if ($usname == $admin) {
continue;
}
mysql_query("INSERT INTO `cms_mail` SET `user_id` = '" . $usname . "',`from_id` = '" . $admin . "',`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..!!';
}
#ADEPETER TO MALE MEMBERS
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 ($res = mysql_fetch_assoc($asp)) {
$usname = $res['name'];
$admin = 'Administrator';
if ($usname == $admin) {
continue;
}
mysql_query("INSERT INTO `cms_mail` SET `user_id` = '" . $usname . "',`from_id` = '" . $admin . "',`text` = '" . $soob . "',`time` = '" . time() . "',`sys` = '1',`them` = '" . $inform . "'");
$wx++;
}
echo 'Message successfully executed..<br/>and sended to <span class="red"><b>' .$wx. '</b></span> Male members..!!'; 
}
#ADEPETER PM TO FEMALE MEMBER
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 ($res = mysql_fetch_assoc($asp)) {
$usname = $res['name'];
$admin = 'Administrator';
if ($usname == $admin) {
continue;
}
mysql_query("INSERT INTO `cms_mail` SET `user_id` = '" . $usname . "',`from_id` = '" . $admin . "',`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..!!';
}
#ADEPETER PM TO FORUM MOD
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 ($res = mysql_fetch_assoc($asp)) {
$usname = $res['name'];
$admin = 'Administrator';
if ($usname == $admin) {
continue;
}
mysql_query("INSERT INTO `cms_mail` SET `user_id` = '" . $usname . "',`from_id` = '" . $admin . "',`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..!!';
}
#ADEPETER
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 ($res = mysql_fetch_assoc($asp)) {
$usname = $res['name'];
$admin = 'Administrator';
if ($usname == $admin) {
continue;
}
mysql_query("INSERT INTO `cms_mail` SET `user_id` = '" . $usname . "',`from_id` = '" . $admin . "',`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..!!';
}
#ADEPETER
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` = '" . $usname . "',`from_id` = '" . $admin . "',`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..!!';
}
#TO SUPER MOD
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` = '" . $usname . "',`from_id` = '" . $admin . "',`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..!!';
}
#TO ADMIN
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` = '" . $usname . "',`from_id` = '" . $admin . "',`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");
?>
.
Sir correct it pls
Всего: 2