Cronwerks MCCode/MCCodes Forums

Please login or register.

Login with username, password and session length

News:

Have you purchased a mod and are struggling to install it? Cronwerks now installs mods for only $3/$2.50. Message Cronus to discuss the details or purchase.


This forum is now closed and has moved to a new location! Click here to find out why.

AuthorTopic: [mccode v2] Ignore User Mail  (Read 1600 times)

Tonka

  • Basic Member
  • *
  • Reputation Power: 0
  • Tonka has no influence.
  • Offline Offline
  • Posts: 4
  • World of Conflict Owner
    • MSN Messenger - tonka_ce@live.com
    • View Profile
    • WWW
[mccode v2] Ignore User Mail
« on: February 25, 2009, 08:02:50 AM »
This will allow a user to ignore all mails from any other user
 - Username go to viewuser.php
 - Non-existent users can't be ignored
 - Users can't ignore staff

Create DB table
Code: [Select]
CREATE TABLE `ignore` (
`id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`userid` INT( 11 ) NOT NULL ,
`blocked` INT( 11 ) NOT NULL
) ENGINE = MYISAM ;

Create ignore.php
Code: [Select]
<?php
/*----------------------------------------------------- 
  -- Ignore User For MC Code V2
  -- Free Mod
  -- http://www.squangle.org
  -- By Tonka
  -- ignore.php
  -----------------------------------------------------*/
include "globals.php";
switch(
$_GET['action'])
{
case 
'ignoreform'ignore_form(); break;
case 
'ignoresub'ignore_submit(); break;
case 
'unignore'unignore(); break;
default; 
index(); break;
}
function 
index()
{
  global 
$db,$userid;
  echo 
'<h3>Ignoring a user</h3>
  <a href="'
.$_SERVER['PHP_SELF'].'?action=ignoreform">Add User To Be Ignored</a><br /><br />

  <table width="85%" cellspacing="1" class="table">
  <th>User ID</th> <th>Username</th> <th>Remove?</th> <th>Status</th>'
;
  
$sql sprintf(("SELECT `id`, `blocked` FROM `ignore` WHERE userid = %u"), $userid);
  
$q $db->query($sql);

  while(
$r=$db->fetch_row($q))
  {
    
$select sprintf(("SELECT `username`, `laston` FROM `users` WHERE userid = %u"), $r['blocked']);
    
$u2 $db->query($select);
    
$u=$db->fetch_row($u2);

    
$username $u['username'];
    
$id $r['id'];
    if(
$u['laston'] >= time()-15*60)
    {
      
$on='<font color=green><b>Online</b></font>';
    } else {
      
$on='<font color=red><b>Offline</b></font>';
    }
    echo 
'<tr><td>';
    echo 
sprintf("%u"$r['blocked']);
    echo 
'</td><td>';
    echo 
'<a href="viewuser.php?u=';
    echo 
sprintf("%u"$r['blocked']);
    echo 
'">';
    echo 
$username;
    echo 
'</a>';
    echo 
'</td><td>';
    echo 
'<a href="'.$_SERVER['PHP_SELF'].'?action=unignore&id=';
    echo 
$id;
    echo 
'">Remove</a>';
    echo 
'</td><td>';
    echo 
$on;
    echo 
'</td></tr>';
  }
  echo 
"</table>";
}

function 
ignore_form()
{
  echo 
'<h3>Ignore Mail From A Specified User</h3>
  The user will not be able to send you ingame mail.<br />
  <form action="'
.$_SERVER['PHP_SELF'].'?action=ignoresub" method="post">
  ID of person to ignore: <input type="text" name="blid" /><br />
  <input type="submit" value="Ignore Future Mail" /></form>'
;
}

function 
ignore_submit()
{
  global 
$db,$userid;
  
$blid mysql_real_escape_string($_POST['blid']);
  
  
$select sprintf(("SELECT `userid`, `user_level` FROM `users` WHERE userid = %u"), $blid);
  
$ul2 $db->query($select);
  
$ul=$db->fetch_row($ul2);
  
  if(empty(
$blid) or $blid == 0)
  {
    echo 
'You did not enter a userid.<br />
    <a href="'
.$_SERVER['PHP_SELF'].'?action=ignoreform">Back</a>';
  }
  else if(
$ul['userid'] != $blid)
  {
    echo 
'You can\'t ignore a non-existant user.<br />
    <a href="'
.$_SERVER['PHP_SELF'].'?action=ignoreform">Back</a>';
  }
  else if(
$ul['user_level'] != 1)
  {
    echo 
'You can\'t ignore staff.<br />
    <a href="'
.$_SERVER['PHP_SELF'].'?action=ignoreform">Back</a>';
  }
  else if(
$blid == $userid)
  {
    echo 
'You can\'t ignore yourself.<br />
    <a href="'
.$_SERVER['PHP_SELF'].'?action=ignoreform">Back</a>';
  } else {
    
$insert sprintf("INSERT INTO `ignore` (`id`, `userid`, `blocked`)
    VALUES ('NULL', '%u', '%u')"
$userid$blid);
    
$db->query($insert);
    echo 
'Users Mail will be Ignored.<br /><br /><a href='.$_SERVER['PHP_SELF'].'>Return to ignore</a>';
  }
}

function 
unignore()
{
  global 
$db,$userid;
  
$delete sprintf(("DELETE FROM `ignore` WHERE id=%u AND userid=%u"), mysql_real_escape_string($_GET['id']), $userid);
  
$db->query($delete);
  echo 
'User un-ignored.<br /><br /><a href='.$_SERVER['PHP_SELF'].'>Return to ignore</a>';
}
$h->endpage();
?>

Open mailbox.php
Find
Code: [Select]
<th><a href='contactlist.php'>My Contacts</a></th></tr>
Add below
Code: [Select]
<td><a href='ignore.php'>Ignore List</a></td></tr>
Find
Code: [Select]
function mail_send()
{
global $db,$ir,$c,$userid,$h;

Add under
Code: [Select]
$q = $db->query(sprintf(("SELECT `blocked` FROM `ignore` WHERE userid = %u AND blocked = %u"), $ir['userid'], $_POST['userid']));
$r = $db->fetch_row($q);
if($r['blocked'])
{
echo 'This person has choosen to ignore mails from you.<br />
<a href="'.$_SERVER['PHP_SELF'].'">&gt; Back</a>';
$h->endpage();
exit;
}
« Last Edit: March 30, 2009, 10:25:56 PM by Tonka »
Logged

Cronus

  • Administrator
  • Senior Member
  • *****
  • Reputation Power: 2901
  • Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!
  • Offline Offline
  • Posts: 550
    • MSN Messenger - preston__08@hotmail.com
    • View Profile
    • WWW
Re: [mccode v2] Ignore User Mail
« Reply #1 on: February 25, 2009, 11:07:07 AM »
Very nice tonka, great addition.
Logged
My msn is preston__08@hotmail.com if anyone is interested, I am online frequently.

ChrisJonesCJ

  • Basic Member
  • *
  • Reputation Power: 6
  • ChrisJonesCJ has no influence.
  • Offline Offline
  • Posts: 15
    • View Profile
Re: [mccode v2] Ignore User Mail
« Reply #2 on: March 25, 2009, 07:49:19 AM »
Yeah this would be a nice little mod if it worked =)
Mails can still be sent by the ignored user

I wish I could spot the problem and then I would be able to send a fix.

I hope you take the time to fix it but thanks for the thought Tonka.
Logged

Cronus

  • Administrator
  • Senior Member
  • *****
  • Reputation Power: 2901
  • Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!Cronus is awe-inspiring!
  • Offline Offline
  • Posts: 550
    • MSN Messenger - preston__08@hotmail.com
    • View Profile
    • WWW
Re: [mccode v2] Ignore User Mail
« Reply #3 on: March 25, 2009, 03:01:41 PM »
Yeah this would be a nice little mod if it worked =)
Mails can still be sent by the ignored user

I wish I could spot the problem and then I would be able to send a fix.

I hope you take the time to fix it but thanks for the thought Tonka.
What was the error? Maybe we can help out.
Logged
My msn is preston__08@hotmail.com if anyone is interested, I am online frequently.

ChrisJonesCJ

  • Basic Member
  • *
  • Reputation Power: 6
  • ChrisJonesCJ has no influence.
  • Offline Offline
  • Posts: 15
    • View Profile
Re: [mccode v2] Ignore User Mail
« Reply #4 on: March 30, 2009, 08:13:26 PM »
Well even if you ignore a user (the user) can still send you mail.
Logged

Tonka

  • Basic Member
  • *
  • Reputation Power: 0
  • Tonka has no influence.
  • Offline Offline
  • Posts: 4
  • World of Conflict Owner
    • MSN Messenger - tonka_ce@live.com
    • View Profile
    • WWW
Re: [mccode v2] Ignore User Mail
« Reply #5 on: March 30, 2009, 10:28:06 PM »
Sorry bout that guys, it was a small error on my part. Here is the updated code and I have updated the first post.

If you have already installed this mod replace what you have added to function mail_send() with this
Code: [Select]
$q = $db->query(sprintf(("SELECT `blocked` FROM `ignore` WHERE userid = %u AND blocked = %u"), $ir['userid'], $_POST['userid']));
$r = $db->fetch_row($q);
if($r['blocked'])
{
echo 'This person has choosen to ignore mails from you.<br />
<a href="'.$_SERVER['PHP_SELF'].'">&gt; Back</a>';
$h->endpage();
exit;
}
Logged

DeaTH_RideR

  • Basic Member
  • *
  • Reputation Power: 9
  • DeaTH_RideR has no influence.
  • Offline Offline
  • Posts: 20
    • MSN Messenger - jaynthelma05@live.com
    • View Profile
    • WWW
Re: [mccode v2] Ignore User Mail
« Reply #6 on: June 22, 2009, 02:07:23 PM »
i did everthing said to do but it still dont work. any thoughts ?


Code: [Select]
<?php
include "globals.php";

if(
$ir['mailban'])
{
die(
"<font color=red><h3>! ERROR</h3>
You have been mail banned for {$ir['mailban']} days.<br />
<br />
<b>Reason: {$ir['mb_reason']}</font></b>"
);
}
$_GET['ID'] = abs((int) $_GET['ID']);
print 
"<table width=85% class='table' cellspacing='1'><tr><td><a href='mailbox.php?action=inbox'>Inbox</a></td> <td><a href='mailbox.php?action=outbox'>Sent Messages</a></td> <td><a href='mailbox.php?action=compose'>Compose Message</a></td> <td><a href='mailbox.php?action=delall'>Delete All Messages</a></td> <td><a href='mailbox.php?action=archive'>Archive Messages</a><td><a href='contactlist.php'>My Contacts</a></td>
<td><a href='ignore.php'>Ignore List</a></td></tr></tr> </table><br />"
;
switch(
$_GET['action'])
{
case 
'inbox':
mail_inbox();
break;

case 
'outbox':
mail_outbox();
break;

case 
'compose':
mail_compose();
break;

case 
'delete':
mail_delete();
break;

case 
'send':
mail_send();
break;

case 
'delall':
mail_delall();
break;

case 
'delall2':
mail_delall2();
break;

case 
'archive':
mail_archive();
break;

default:
mail_inbox();
break;
}
function 
mail_inbox()
{
global 
$db,$ir,$c,$userid,$h;
print <<<OUT
OUT;
$q=$db->query("SELECT m.*,u.* FROM mail m LEFT JOIN users u ON m.mail_from=u.userid WHERE m.mail_to=$userid ORDER BY mail_time DESC LIMIT 25");
print 
"<script src='collapse.js' type='text/javascript'></script>
<link href='collapse.css' rel='stylesheet' type='text/css' />"
;
  while(
$r=$db->fetch_row($q))
{
$sent=date('F j, Y, g:i:s a',$r['mail_time']);
print 
"<div id='CollapsiblePanel{$r['mail_time']}' class='CollapsiblePanel'>
<div class='CollapsiblePanelTab' tabindex='0'>
    <table width='100%' border='0' cellspacing='0' cellpadding='0'>
      <tr>
        <td>From: <a href='viewuser.php?u={$r['userid']}'>{$r['username']}</a> [{$r['userid']}]&nbsp;</td>
        <td>Subject: {$r['mail_subject']}</td>
        <td>Sent at: $sent</td>
      </tr>
    </table>
  </div>
  <div class='CollapsiblePanelContent'>{$r['mail_text']}<br /><table width='100%' border='0' cellspacing='0' cellpadding='0'>
  <tr>
    <td valign='top'><div align='center'><a href='mailbox.php?action=compose&ID={$r['userid']}'>Reply</a> | <a href='mailbox.php?action=delete&ID={$r['mail_id']}'>Delete</a> | <a href='preport.php?ID={$r['userid']}&amp;report=Fradulent mail: {$fm}'>Report</a> | <a href='ignore.php?'>ignore</a></div></td>
    </tr>
</table>
</div>
</div>"
;
EOF;
print 
"
<script type='text/javascript'>
<!--
var CollapsiblePanel1 = new Spry.Widget.CollapsiblePanel('CollapsiblePanel{$r['mail_time']}', {contentIsOpen:false});
//-->
</script>"
;
}
if(
$ir['new_mail'] > 0)
{
$db->query("UPDATE mail SET mail_read=1 WHERE mail_to=$userid");
$db->query("UPDATE users SET new_mail=0 WHERE userid=$userid");
}
}
function 
mail_outbox()
{
global 
$db,$ir,$c,$userid,$h;
print 
"Only the last 25 messages you have sent are visible.<br />
<table width=75% cellspacing=1 class='table'><tr style='background:gray'><th>To</th><th></th></tr>"
;
$q=$db->query("SELECT m.*,u.* FROM mail m LEFT JOIN users u ON m.mail_to=u.userid WHERE m.mail_from=$userid ORDER BY mail_time DESC LIMIT 25");
while(
$r=$db->fetch_row($q))
{
$sent=date('F j, Y, g:i:s a',$r['mail_time']);
print 
"<tr><td><a href='viewuser.php?u={$r['userid']}'>{$r['username']}</a> [{$r['userid']}]</td><td>{$r['mail_subject']}</td></tr><tr><td>Sent at: $sent<br /></td><td>{$r['mail_text']}</td></tr>";
}

}
function 
mail_compose()
{
global 
$db,$ir,$c,$userid,$h;

print 
"<form action='mailbox.php?action=send' method='post'>
<table width=75% cellspacing=1 class='table'> <tr>
<td>Contact to send to:</td> <td>"
;
$q=$db->query("SELECT c.*, u.username FROM contactlist c LEFT JOIN users u ON c.cl_ADDED=u.userid WHERE c.cl_ADDER={$userid} ORDER BY u.username ASC");
if(
$db->num_rows($q) == 0)
{
  print 
"You have no contacts!";
}
else
{
  print 
"<select name='user1' type='dropdown'><option value=''>&lt;select a contact...&gt;</option>";
  while(
$r=$db->fetch_row($q))
  {
    print 
"<option value='{$r['username']}'>{$r['username']}</option>";
  }
  print 
"</select>";
}
if(
$_GET['ID'])
{
  
$user=$db->fetch_single($db->query("SELECT username FROM users WHERE userid={$_GET['ID']}"));
}  
print 
"</td></tr><tr>
<td><b>OR</b> Enter a username to send to:</td><td><input type='text' name='user2' value='{$user}' /></td></tr><tr>
<td>Subject:</td> <td><input type='text' name='subject' /></td></tr><tr>
<td>Message:</td>
<td><textarea rows=5 cols=40 name='message'></textarea></td></tr><tr> <td colspan=2><input type='submit' value='Send' /></td></tr></table></form>"
;
if(
$_GET['ID'])
{
print 
"<br /><table width=75% border=2><tr><td colspan=2><b>Your last 5 mails to/from this person:</b></td></tr>";
$q=$db->query("SELECT m.*,u1.username as sender from mail m left join users u1 on m.mail_from=u1.userid WHERE (m.mail_from=$userid AND m.mail_to={$_GET['ID']}) OR (m.mail_to=$userid AND m.mail_from={$_GET['ID']}) ORDER BY m.mail_time DESC LIMIT 5");
while(
$r=$db->fetch_row($q))
{
$sent=date('F j, Y, g:i:s a',$r['mail_time']);
print 
"<tr><td>$sent</td> <td><b>{$r['sender']} wrote:</b> {$r['mail_text']}</td></tr>";
}
print 
"</table>";
}
}

function 
mail_send()
{
global 
$db,$ir,$c,$userid,$h;
$q $db->query(sprintf(("SELECT `blocked` FROM `ignore` WHERE userid = %u AND blocked = %u"), $ir['userid'], $_POST['userid']));
$r $db->fetch_row($q);
if(
$r['blocked'])
{
echo 
'This person has choosen to ignore mails from you.<br />
<a href="'
.$_SERVER['PHP_SELF'].'">&gt; Back</a>';
$h->endpage();
exit;
}
$subj=str_replace(array("\n"),array("<br />"),strip_tags($_POST['subject']));
$msg=str_replace(array("\n"),array("<br />"),strip_tags($_POST['message']));
if(
$_POST['user1'] && $_POST['user2'])
{
  die(
"Please do not select a contact AND enter a username, only do one.<br />
<a href='mailbox.php'>&gt; Back</a>"
);
}
if(!
$_POST['user1'] && !$_POST['user2'])
{
  die(
"You must select a contact or enter a username.<br />
<a href='mailbox.php'>&gt; Back</a>"
);
}
$sendto=($_POST['user1']) ? $_POST['user1'] : $_POST['user2'];
$q=$db->query("SELECT userid FROM users WHERE username='{$sendto}'");
if(
$db->num_rows($q)==0)
{
  die(
"You cannot send mail to nonexistant users.<br />
<a href='mailbox.php'>&gt; Back</a>"
);
}
$to=$db->fetch_single($q);
$db->query("INSERT INTO mail VALUES ('',0,$userid,$to,unix_timestamp(),'$subj','$msg')");
$db->query("UPDATE users SET new_mail=new_mail+1 WHERE userid={$to}");
print 
"Message sent.<br />
<a href='mailbox.php'>&gt; Back</a>"
;
}
function 
mail_delete()
{
global 
$db,$ir,$c,$userid,$h;
$db->query("DELETE FROM mail WHERE mail_id={$_GET['ID']} AND mail_to=$userid");
print 
"Message deleted.<br />
<a href='mailbox.php'>&gt; Back</a>"
;
}
function 
mail_delall()
{
global 
$ir,$c,$userid,$h;
print 
"This will delete all the messages in your inbox.<br />
There is <b>NO</b> undo, so be sure.<br />
<a href='mailbox.php?action=delall2'>&gt; Yes, delete all messages</a><br />
<a href='mailbox.php'>&gt; No, go back</a>"
;
}
function 
mail_delall2()
{
global 
$db,$ir,$c,$userid,$h;
$db->query("DELETE FROM mail WHERE mail_to=$userid");
print 
"All ".$db->affected_rows()." mails in your inbox were deleted.<br />
<a href='mailbox.php'>&gt; Back</a>"
;
}
function 
mail_archive()
{
global 
$db,$ir,$c,$userid,$h;
print 
"This tool will download an archive of all your messages.<br />
<a href='dlarchive.php?a=inbox'>&gt; Download Inbox</a><br />
<a href='dlarchive.php?a=outbox'>&gt; Download Outbox</a>"
;
}
{
}
$h->endpage();
?>
Logged

Drizzah

  • Basic Member
  • *
  • Reputation Power: 4
  • Drizzah has no influence.
  • Offline Offline
  • Posts: 8
    • View Profile
Re: [mccode v2] Ignore User Mail
« Reply #7 on: October 04, 2009, 01:33:49 PM »
Do everything Tonka said except the last part as it has errors.
Use the updated code below.

Code: [Select]
$q=$db->query(sprintf(("SELECT `blocked` FROM `ignore` WHERE userid=userid AND blocked=%u"), $ir['userid'], $_POST['userid']));
$r=$db->fetch_row($q);
if($r['blocked'])
{
echo 'This person has choosen to ignore mails from you.<br />
<a href="'.$_SERVER['PHP_SELF'].'">&gt; Back</a>';
$h->endpage();
exit;
}
Logged
Good Info and Help with Securing
Strip HTML Tags - PHP Filtering
 


This forum is now closed and has moved to a new location! Click here to find out why.