Jump to content
MakeWebGames

Mass Mail error


HITMAN 17

Recommended Posts

Re: Mass Mail error

now it comes up

Mailbox (29) here is the staff_special code please can you fix it

<?php
include "sglobals.php";
if($ir['user_level'] > 2)
{
die("403");
}
//This contains punishment stuffs
switch($_GET['action'])
{
case 'editnews': newspaper_form(); break;
case 'subnews': newspaper_submit(); break;
case 'givedpform': give_dp_form(); break;
case 'givedpsub': give_dp_submit(); break;
case 'stafflist': staff_list(); break;
case 'userlevel': userlevel(); break;
case 'userlevelform': userlevelform(); break;
case 'massmailer': massmailer(); break;
default: print "Error: This script requires an action."; break;
}
function newspaper_form()
{
global $db,$ir,$c,$h,$userid;
$q=$db->query("SELECT * FROM papercontent LIMIT 1");
$news=$db->fetch_single($q);
print "<h3>Editing Newspaper</h3><form action='staff_special.php?action=subnews' method='post'>
<textarea rows='7' cols='35' name='newspaper'>$news</textarea>
<input type='submit' value='Change' /></form>";
}
function newspaper_submit()
{
global $db,$ir,$c,$h,$userid;
$news=$_POST['newspaper'];
$db->query("UPDATE papercontent SET content='$news'");
print "Newspaper updated!";
stafflog_add("Updated game newspaper");
}
function give_dp_form()
{
global $db,$ir,$c,$h,$userid;
print "<h3>Giving User DP</h3>
The user will receive the benefits of one 30-day donator pack.

<form action='staff_special.php?action=givedpsub' method='post'>
User: ".user_dropdown($c,'user')."

<input type='radio' name='type' value='1' /> Pack 1 (Standard)

<input type='radio' name='type' value='2' /> Pack 2 (Crystals)

<input type='radio' name='type' value='3' /> Pack 3 (IQ)

<input type='radio' name='type' value='4' /> Pack 4 (5.00)

<input type='radio' name='type' value='5' /> Pack 5 (10.00)

<input type='submit' value='Give User DP' /></form>";
}
function give_dp_submit()
{
global $db,$ir,$c,$h,$userid;
if($_POST['type']==1)
{
$db->query("UPDATE users u LEFT JOIN userstats us ON u.userid=us.userid SET u.money=u.money+5000,u.crystals=u.crystals+50,
us.IQ=us.IQ+50,u.donatordays=u.donatordays+30 WHERE u.userid={$_POST['user']}");
$d=30;
}
else if($_POST['type']==2)
{
$db->query("UPDATE users u LEFT JOIN userstats us ON u.userid=us.userid SET u.crystals=u.crystals+100,u.donatordays=u.donatordays+30 WHERE u.userid={$_POST['user']}");
$d=30;
}
else if($_POST['type']==3)
{
$db->query("UPDATE users u LEFT JOIN userstats us ON u.userid=us.userid SET 
us.IQ=us.IQ+120,u.donatordays=u.donatordays+30 WHERE u.userid={$_POST['user']}");
$d=30;
}
else if($_POST['type']==4)
{
$db->query("UPDATE users u LEFT JOIN userstats us ON u.userid=us.userid SET u.money=u.money+15000,u.crystals=u.crystals+75,
us.IQ=us.IQ+80,u.donatordays=u.donatordays+55 WHERE u.userid={$_POST['user']}");
$d=55;
}
else if($_POST['type']==5)
{
$db->query("UPDATE users u LEFT JOIN userstats us ON u.userid=us.userid SET u.money=u.money+35000,u.crystals=u.crystals+160,
us.IQ=us.IQ+180,u.donatordays=u.donatordays+115 WHERE u.userid={$_POST['user']}");
$d=115;
}

event_add($_POST['user'],"You were given one $d -day donator pack (Pack {$_POST['type']}) from the administration.",$c);
print "User given a DP.";
stafflog_add("Gave ID {$_POST['user']} a $d -day donator pack (Pack {$_POST['type']})");
}
function staff_list()
{
global $db,$ir,$c,$h,$userid;

print "<h3>Staff Management</h3>";
print "[b]Admins[/b]

<table width=80%><tr style='background:gray'> <th>User</th> <th>Online?</th> <th>Links</th> </tr>";
$q=$db->query("SELECT * FROM users WHERE user_level=2 ORDER BY userid ASC");
while($r=$db->fetch_row($q))
{
if($r['laston'] >= time()-15*60) { $on="<font color=green>[b]Online[/b]</font>"; } else { $on="<font color=red>[b]Offline[/b]</font>"; }
print "\n<tr> <td>[url='viewuser.php?u={$r[']{$r['username']}[/url] [{$r['userid']}]</td> <td>$on</td> <td>[url='staff_special.php?action=userlevel&level=3&ID={$r[']Secretary[/url]  · [url='staff_special.php?action=userlevel&level=5&ID={$r[']Assistant[/url] · [url='staff_special.php?action=userlevel&level=1&ID={$r[']Member[/url]</td></tr>";
}
print "</table>";
print "[b]Secretaries[/b]

<table width=80%><tr style='background:gray'> <th>User</th> <th>Online?</th> <th>Links</th> </tr>";
$q=$db->query("SELECT * FROM users WHERE user_level=3 ORDER BY userid ASC");
while($r=$db->fetch_row($q))
{
if($r['laston'] >= time()-15*60) { $on="<font color=green>[b]Online[/b]</font>"; } else { $on="<font color=red>[b]Offline[/b]</font>"; }
print "\n<tr> <td>[url='viewuser.php?u={$r[']{$r['username']}[/url] [{$r['userid']}]</td> <td>$on</td> <td>[url='staff_special.php?action=userlevel&level=2&ID={$r[']Admin[/url]  · [url='staff_special.php?action=userlevel&level=5&ID={$r[']Assistant[/url] · [url='staff_special.php?action=userlevel&level=1&ID={$r[']Member[/url]</td></tr>";
}
print "</table>";
print "[b]Assistants[/b]

<table width=80%><tr style='background:gray'> <th>User</th> <th>Online?</th> <th>Links</th> </tr>";
$q=$db->query("SELECT * FROM users WHERE user_level=5 ORDER BY userid ASC");
while($r=$db->fetch_row($q))
{
if($r['laston'] >= time()-15*60) { $on="<font color=green>[b]Online[/b]</font>"; } else { $on="<font color=red>[b]Offline[/b]</font>"; }
print "\n<tr> <td>[url='viewuser.php?u={$r[']{$r['username']}[/url] [{$r['userid']}]</td> <td>$on</td> <td>[url='staff_special.php?action=userlevel&level=2&ID={$r[']Admin[/url] · [url='staff_special.php?action=userlevel&level=3&ID={$r[']Secretary[/url]  · [url='staff_special.php?action=userlevel&level=1&ID={$r[']Member[/url]</td></tr>";
}
print "</table>";
}
function userlevel()
{
global $db,$ir,$c,$h,$userid;

$_GET['level']=abs((int) $_GET['level']);
$_GET['ID']=abs((int) $_GET['ID']);
$db->query("UPDATE users SET user_level={$_GET['level']} WHERE userid={$_GET['ID']}");
print "User's level adjusted.";
stafflog_add("Adjusted user ID {$_GET['ID']}'s staff status.");
}
function userlevelform()
{
global $db,$ir,$c,$h,$userid;


print "<h3>User Level Adjust</h3>
<form action='staff_special.php' method='get'>
<input type='hidden' name='action' value='userlevel'>
User: ".user_dropdown($c,'ID')."

User Level:

<input type='radio' name='level' value='1' /> Member

<input type='radio' name='level' value='2' /> Admin

<input type='radio' name='level' value='3' /> Secretary

<input type='radio' name='level' value='4' /> IRC Op

<input type='radio' name='level' value='5' /> Assistant

<input type='submit' value='Adjust' /></form>";
}
function massmailer()
{
global $db,$ir,$c,$userid;
if($_POST['text'])
{
$_POST['text']=nl2br(strip_tags($_POST['text']));
$subj="This is a mass mail from the administration";
if($_POST['cat']==1)
$q=$db->query("SELECT * FROM users ");
else if($_POST['cat']==2)
$q=$db->query("SELECT * FROM users WHERE user_level > 1");
else if($_POST['cat']==3)
$q=$db->query("SELECT * FROM users WHERE user_level=2");
else
$q=$db->query("SELECT * FROM users WHERE user_level={$_POST['level']}");
while($r=$db->fetch_row($q))
{
$db->query("INSERT INTO mail VALUES('', 0, 0, {$r['userid']}, unix_timestamp(),'$subj','{$_POST['text']}')");
$db->query("UPDATE users SET new_mail=new_mail+1 WHERE user_level>0") or die(mysql_error());
print "Mass mail sent to {$r['username']}.
";
}
print "Mass mail sending complete!

[url='staff_special.php?action=massmailer']> Back[/url]";
}
else
{
print "[b]Mass Mailer[/b]

<form action='staff_special.php?action=massmailer' method='post'> Text: 

<textarea name='text' rows='7' cols='40'></textarea>

<input type='radio' name='cat' value='1' /> Send to all members <input type='radio' name='cat' value='2' /> Send to staff only <input type='radio' name='cat' value='3' /> Send to admins only

OR Send to user level:

<input type='radio' name='level' value='1' /> Member

<input type='radio' name='level' value='2' /> Admin

<input type='radio' name='level' value='3' /> Secretary

<input type='radio' name='level' value='5' /> Assistant

<input type='submit' value='Send' /></form>";
}
}

$h->endpage();
?>
Link to comment
Share on other sites

Re: Mass Mail error

 

now it comes up

Mailbox (29) here is the staff_special code please can you fix it

<?php
include "sglobals.php";
if($ir['user_level'] > 2)
{
die("403");
}
//This contains punishment stuffs
switch($_GET['action'])
{
case 'editnews': newspaper_form(); break;
case 'subnews': newspaper_submit(); break;
case 'givedpform': give_dp_form(); break;
case 'givedpsub': give_dp_submit(); break;
case 'stafflist': staff_list(); break;
case 'userlevel': userlevel(); break;
case 'userlevelform': userlevelform(); break;
case 'massmailer': massmailer(); break;
default: print "Error: This script requires an action."; break;
}
function newspaper_form()
{
global $db,$ir,$c,$h,$userid;
$q=$db->query("SELECT * FROM papercontent LIMIT 1");
$news=$db->fetch_single($q);
print "<h3>Editing Newspaper</h3><form action='staff_special.php?action=subnews' method='post'>
<textarea rows='7' cols='35' name='newspaper'>$news</textarea>
<input type='submit' value='Change' /></form>";
}
function newspaper_submit()
{
global $db,$ir,$c,$h,$userid;
$news=$_POST['newspaper'];
$db->query("UPDATE papercontent SET content='$news'");
print "Newspaper updated!";
stafflog_add("Updated game newspaper");
}
function give_dp_form()
{
global $db,$ir,$c,$h,$userid;
print "<h3>Giving User DP</h3>
The user will receive the benefits of one 30-day donator pack.

<form action='staff_special.php?action=givedpsub' method='post'>
User: ".user_dropdown($c,'user')."

<input type='radio' name='type' value='1' /> Pack 1 (Standard)

<input type='radio' name='type' value='2' /> Pack 2 (Crystals)

<input type='radio' name='type' value='3' /> Pack 3 (IQ)

<input type='radio' name='type' value='4' /> Pack 4 (5.00)

<input type='radio' name='type' value='5' /> Pack 5 (10.00)

<input type='submit' value='Give User DP' /></form>";
}
function give_dp_submit()
{
global $db,$ir,$c,$h,$userid;
if($_POST['type']==1)
{
$db->query("UPDATE users u LEFT JOIN userstats us ON u.userid=us.userid SET u.money=u.money+5000,u.crystals=u.crystals+50,
us.IQ=us.IQ+50,u.donatordays=u.donatordays+30 WHERE u.userid={$_POST['user']}");
$d=30;
}
else if($_POST['type']==2)
{
$db->query("UPDATE users u LEFT JOIN userstats us ON u.userid=us.userid SET u.crystals=u.crystals+100,u.donatordays=u.donatordays+30 WHERE u.userid={$_POST['user']}");
$d=30;
}
else if($_POST['type']==3)
{
$db->query("UPDATE users u LEFT JOIN userstats us ON u.userid=us.userid SET 
us.IQ=us.IQ+120,u.donatordays=u.donatordays+30 WHERE u.userid={$_POST['user']}");
$d=30;
}
else if($_POST['type']==4)
{
$db->query("UPDATE users u LEFT JOIN userstats us ON u.userid=us.userid SET u.money=u.money+15000,u.crystals=u.crystals+75,
us.IQ=us.IQ+80,u.donatordays=u.donatordays+55 WHERE u.userid={$_POST['user']}");
$d=55;
}
else if($_POST['type']==5)
{
$db->query("UPDATE users u LEFT JOIN userstats us ON u.userid=us.userid SET u.money=u.money+35000,u.crystals=u.crystals+160,
us.IQ=us.IQ+180,u.donatordays=u.donatordays+115 WHERE u.userid={$_POST['user']}");
$d=115;
}

event_add($_POST['user'],"You were given one $d -day donator pack (Pack {$_POST['type']}) from the administration.",$c);
print "User given a DP.";
stafflog_add("Gave ID {$_POST['user']} a $d -day donator pack (Pack {$_POST['type']})");
}
function staff_list()
{
global $db,$ir,$c,$h,$userid;

print "<h3>Staff Management</h3>";
print "[b]Admins[/b]

<table width=80%><tr style='background:gray'> <th>User</th> <th>Online?</th> <th>Links</th> </tr>";
$q=$db->query("SELECT * FROM users WHERE user_level=2 ORDER BY userid ASC");
while($r=$db->fetch_row($q))
{
if($r['laston'] >= time()-15*60) { $on="<font color=green>[b]Online[/b]</font>"; } else { $on="<font color=red>[b]Offline[/b]</font>"; }
print "\n<tr> <td>[url='viewuser.php?u={$r[']{$r['username']}[/url] [{$r['userid']}]</td> <td>$on</td> <td>[url='staff_special.php?action=userlevel&level=3&ID={$r[']Secretary[/url]  · [url='staff_special.php?action=userlevel&level=5&ID={$r[']Assistant[/url] · [url='staff_special.php?action=userlevel&level=1&ID={$r[']Member[/url]</td></tr>";
}
print "</table>";
print "[b]Secretaries[/b]

<table width=80%><tr style='background:gray'> <th>User</th> <th>Online?</th> <th>Links</th> </tr>";
$q=$db->query("SELECT * FROM users WHERE user_level=3 ORDER BY userid ASC");
while($r=$db->fetch_row($q))
{
if($r['laston'] >= time()-15*60) { $on="<font color=green>[b]Online[/b]</font>"; } else { $on="<font color=red>[b]Offline[/b]</font>"; }
print "\n<tr> <td>[url='viewuser.php?u={$r[']{$r['username']}[/url] [{$r['userid']}]</td> <td>$on</td> <td>[url='staff_special.php?action=userlevel&level=2&ID={$r[']Admin[/url]  · [url='staff_special.php?action=userlevel&level=5&ID={$r[']Assistant[/url] · [url='staff_special.php?action=userlevel&level=1&ID={$r[']Member[/url]</td></tr>";
}
print "</table>";
print "[b]Assistants[/b]

<table width=80%><tr style='background:gray'> <th>User</th> <th>Online?</th> <th>Links</th> </tr>";
$q=$db->query("SELECT * FROM users WHERE user_level=5 ORDER BY userid ASC");
while($r=$db->fetch_row($q))
{
if($r['laston'] >= time()-15*60) { $on="<font color=green>[b]Online[/b]</font>"; } else { $on="<font color=red>[b]Offline[/b]</font>"; }
print "\n<tr> <td>[url='viewuser.php?u={$r[']{$r['username']}[/url] [{$r['userid']}]</td> <td>$on</td> <td>[url='staff_special.php?action=userlevel&level=2&ID={$r[']Admin[/url] · [url='staff_special.php?action=userlevel&level=3&ID={$r[']Secretary[/url]  · [url='staff_special.php?action=userlevel&level=1&ID={$r[']Member[/url]</td></tr>";
}
print "</table>";
}
function userlevel()
{
global $db,$ir,$c,$h,$userid;

$_GET['level']=abs((int) $_GET['level']);
$_GET['ID']=abs((int) $_GET['ID']);
$db->query("UPDATE users SET user_level={$_GET['level']} WHERE userid={$_GET['ID']}");
print "User's level adjusted.";
stafflog_add("Adjusted user ID {$_GET['ID']}'s staff status.");
}
function userlevelform()
{
global $db,$ir,$c,$h,$userid;


print "<h3>User Level Adjust</h3>
<form action='staff_special.php' method='get'>
<input type='hidden' name='action' value='userlevel'>
User: ".user_dropdown($c,'ID')."

User Level:

<input type='radio' name='level' value='1' /> Member

<input type='radio' name='level' value='2' /> Admin

<input type='radio' name='level' value='3' /> Secretary

<input type='radio' name='level' value='4' /> IRC Op

<input type='radio' name='level' value='5' /> Assistant

<input type='submit' value='Adjust' /></form>";
}
function massmailer()
{
global $db,$ir,$c,$userid;
if($_POST['text'])
{
$_POST['text']=nl2br(strip_tags($_POST['text']));
$subj="This is a mass mail from the administration";
if($_POST['cat']==1)
$q=$db->query("SELECT * FROM users ");
else if($_POST['cat']==2)
$q=$db->query("SELECT * FROM users WHERE user_level > 1");
else if($_POST['cat']==3)
$q=$db->query("SELECT * FROM users WHERE user_level=2");
else
$q=$db->query("SELECT * FROM users WHERE user_level={$_POST['level']}");
while($r=$db->fetch_row($q))
{
$db->query("INSERT INTO mail VALUES('', 0, 0, {$r['userid']}, unix_timestamp(),'$subj','{$_POST['text']}')");
$db->query("UPDATE users SET new_mail=new_mail+1 WHERE user_level>0") or die(mysql_error());
print "Mass mail sent to {$r['username']}.
";
}
print "Mass mail sending complete!

[url='staff_special.php?action=massmailer']> Back[/url]";
}
else
{
print "[b]Mass Mailer[/b]

<form action='staff_special.php?action=massmailer' method='post'> Text: 

<textarea name='text' rows='7' cols='40'></textarea>

<input type='radio' name='cat' value='1' /> Send to all members <input type='radio' name='cat' value='2' /> Send to staff only <input type='radio' name='cat' value='3' /> Send to admins only

OR Send to user level:

<input type='radio' name='level' value='1' /> Member

<input type='radio' name='level' value='2' /> Admin

<input type='radio' name='level' value='3' /> Secretary

<input type='radio' name='level' value='5' /> Assistant

<input type='submit' value='Send' /></form>";
}
}

$h->endpage();
?>

 

 

i could fix it but that would defeat the object of creating a game...

Link to comment
Share on other sites

Guest Anonymous

Re: Mass Mail error

 

$db->query("INSERT INTO mail VALUES('', 0, 0, {$r['userid']}, unix_timestamp(),'$subj','{$_POST['text']}')");
$db->query("UPDATE users SET new_mail=new_mail+1 WHERE user_level>0") or die(mysql_error());

 

This is what comes of not reading the sources *carefully*.

For each user in the list (all users, all staff or just administrators) this code is updating the new_mail count. Therefore... the solution presents itself immediately.

[Hint] Read the top line carefully...

Of course this method of sending mass mail to users is utterly stupid, imagine what would happen if you mass-mailed 700,000 users...

Link to comment
Share on other sites

  • 2 weeks later...

Re: Mass Mail error

Quote: "what do i do"

1. Learn to code

2. Learn to punctuate! Damn...

3. Replace your $db->queries' with these:

$db->query("INSERT INTO mail VALUES('', 0, 0, {$r['userid']}, unix_timestamp(),'$subj','{$_POST['text']}')");
print "Mass mail sent to {$r['username']}.
";
$db->query("UPDATE users SET new_mail=new_mail+1 WHERE userid = {$r['userid']}");
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...