vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.0 Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=33)
-   -   Delete PM sent before user reads it (https://vborg.vbsupport.ru/showthread.php?t=78729)

pie 03-23-2005 10:00 PM

Delete PM sent before user reads it
 
Update:
27th May 2005 -
Counters update on deletion. PM is now authenticated to user.


pie 03-24-2005 10:03 PM

Whoops, wrong forum. lol. Will get a mod to move it.

Sin City 03-24-2005 11:11 PM

when i saw it in the vB2 section i was like "why not for vB3? :(" then i seen it's just in the wrong area ;)

been looking for this.... thanks :)

yinyang 03-25-2005 03:23 AM

wow, this is awesome. i wish this existed for email. damn there's been a lot of emails to ex girlfriends i wish i could have deleted through yahoo..........

Erwin 03-25-2005 04:01 AM

It's a good idea. :)

nexialys 03-25-2005 08:37 AM

3 installs, and none to tell there is a major bug in it... funny how guys click easily.. lol

good hack PIE... but your "WHERE" in the queries are sticked with the rest, so the queries are not correct...

and why this first query about the pmreceipt ?! it's not used elsewhere in this hack...

Boofo 03-25-2005 11:19 AM

Quote:

Originally Posted by nexialys
3 installs, and none to tell there is a major bug in it... funny how guys click easily.. lol

good hack PIE... but your "WHERE" in the queries are sticked with the rest, so the queries are not correct...

and why this first query about the pmreceipt ?! it's not used elsewhere in this hack...

How would you suggest he fix it, sir? ;)

nexialys 03-25-2005 11:41 AM

Quote:

Originally Posted by Boofo
How would you suggest he fix it, sir? ;)

it's already answered in my post... need spaces...
[high]* nexialys lurk at Boofo with a strange look... are you laughing at me ?![/high]

Boofo 03-25-2005 12:01 PM

Quote:

Originally Posted by nexialys
it's already answered in my post... need spaces...
[high]* nexialys lurk at Boofo with a strange look... are you laughing at me ?![/high]


Laughing at you? hahahahahahahaha No way, sir. ;)

Boofo 03-25-2005 12:02 PM

Quote:

Originally Posted by pie
Whoops, wrong forum. lol. Will get a mod to move it.

Can you please put this in a txt file so others can download it and have it in case they ever need to re-install it? ;)

pie 03-26-2005 06:27 AM

Quote:

Originally Posted by Boofo
Can you please put this in a txt file so others can download it and have it in case they ever need to re-install it? ;)

Sure.

pie 03-26-2005 06:35 AM

Quote:

Originally Posted by nexialys
3 installs, and none to tell there is a major bug in it... funny how guys click easily.. lol

good hack PIE... but your "WHERE" in the queries are sticked with the rest, so the queries are not correct...

and why this first query about the pmreceipt ?! it's not used elsewhere in this hack...

Yes it is... its where it displays Delete Unread PM (...?)

And what do you not like about my query? I have to admit i just copied the code from PHPMYADMIN as I was being lazy.

Thanks everyone by the way for the kind words.

Quote:

Can you please put this in a txt file so others can download it andhave it in case they ever need to re-install it?
DONE!!

nexialys 03-26-2005 09:37 AM

@pie... it's not i don't like the query, but it's badly written:
PHP Code:

$pmquery=$DB_site->query("SELECT* FROM " TABLE_PREFIX "pmWHEREpmid='$pm'"); 

have to be
PHP Code:

$pmquery=$DB_site->query("SELECT * FROM " TABLE_PREFIX "pm WHERE pmid='$pm'"); 

that's all... they are all the same, missing some spaces between elements... easy to see anyway, the code will not work if you don't add the spaces...

Oblivion Knight 03-26-2005 09:57 AM

Quote:

Originally Posted by nexialys
that's all... they are all the same, missing some spaces between elements... easy to see anyway, the code will not work if you don't add the spaces...

I assume this was a WYSIWIG issue of some kind, as the text file has the queries written fine.. ;)

pie 03-26-2005 11:55 AM

Quote:

Originally Posted by nexialys
@pie... it's not i don't like the query, but it's badly written:
PHP Code:

$pmquery=$DB_site->query("SELECT* FROM " TABLE_PREFIX "pmWHEREpmid='$pm'"); 

have to be
PHP Code:

$pmquery=$DB_site->query("SELECT * FROM " TABLE_PREFIX "pm WHERE pmid='$pm'"); 

that's all... they are all the same, missing some spaces between elements... easy to see anyway, the code will not work if you don't add the spaces...

Updated

Boofo 03-26-2005 12:35 PM

Would there be a way to show us exactky what edits need to be made to the pm_receiptsbit template for those that have been altered from the original instead of just replacing the template?

pie 03-27-2005 10:34 PM

I will sort that A.S.A.P.

pie 03-27-2005 10:37 PM

Updated

why-not 03-28-2005 06:02 PM

How about adding a userid to the query! Sure it would be difficult to know who has unread PM(s), but all one has to do is start sending requests with PM ids and they can delete all unread PM(s) even ones that are not theirs! Then you should also check the request, because allowing what you allow, can end up with anyone reading any table they want or even delete your whole database! Nice idea, but it needs to be made secure!

Sonia

hate 03-28-2005 06:09 PM

This is a nice idea, but the trouble is to many have email when pm, so if they get a email saying so and so pmed them, they will go to their pm box and find nothing.

That is the only draw back stoping me from using it.

Boofo 03-28-2005 06:25 PM

Quote:

Originally Posted by why-not
How about adding a userid to the query! Sure it would be difficult to know who has unread PM(s), but all one has to do is start sending requests with PM ids and they can delete all unread PM(s) even ones that are not theirs! Then you should also check the request, because allowing what you allow, can end up with anyone reading any table they want or even delete your whole database! Nice idea, but it needs to be made secure!

Sonia

How would you do that exactly? ;)

nexialys 03-28-2005 06:29 PM

the best way would be to have a dropdown with multiple choices where you select the users that need to be deleted from the list of receiving the pm ... so if there is only one receiver, the dropdown will be a single choice... if we choose nobody, no pm will be deleted...

pie 03-29-2005 01:30 AM

Quote:

Originally Posted by why-not
How about adding a userid to the query! Sure it would be difficult to know who has unread PM(s), but all one has to do is start sending requests with PM ids and they can delete all unread PM(s) even ones that are not theirs! Then you should also check the request, because allowing what you allow, can end up with anyone reading any table they want or even delete your whole database! Nice idea, but it needs to be made secure!

Sonia

Very good point... I have to say silly me for not doing it.

Quote:

That is the only draw back stoping me from using it.
Theres nothing that can be done about that, unfortunatly you can't pull back emails. I could do a "This PM has been deleted" error message if you guys'd prefer.

Quote:

the best way would be to have a dropdown with multiple choices where you select the users that need to be deleted from the list of receiving the pm ... so if there is only one receiver, the dropdown will be a single choice... if we choose nobody, no pm will be deleted...
Thats a good idea, the fact that it could be for mulitple users completly slipped my mind. I'd probally do checkboxes rather than a list purely because i find checkboxes easier and I want them as easy as possible.

Dennis Olson 03-29-2005 04:06 PM

A couple of points:

1) The delete function LEAVES the tracking notice in your tracking folder. How can that be removed at the same time? (After all, you don't need the tracking notice anymore).

2) You create the following phrase:

Phrase Type: Private Messaging
Varname: was_deleted
Text: You deleted it!


but in your EVAL statement, you use:

eval(print_standard_redirect('deleted_private_mess ages_successfully'));

Thus never referencing that phrase....

pie 03-29-2005 05:16 PM

Quote:

Originally Posted by Dennis Olson
A couple of points:

1) The delete function LEAVES the tracking notice in your tracking folder. How can that be removed at the same time? (After all, you don't need the tracking notice anymore).

2) You create the following phrase:

Phrase Type: Private Messaging
Varname: was_deleted
Text: You deleted it!


but in your EVAL statement, you use:

eval(print_standard_redirect('deleted_private_mess ages_successfully'));

Thus never referencing that phrase....

Yes. This hack is still not 100% Featured, I will be adding it so that in the Sent Messages folder, it'll show that it was deleted and thus didn't get through.

DivisionByZero 04-03-2005 03:16 AM

Quote:

Originally Posted by Dennis Olson
A couple of points:

1) The delete function LEAVES the tracking notice in your tracking folder. How can that be removed at the same time? (After all, you don't need the tracking notice anymore).

I would like to leave the tracking message just to remind the sender that he deleted it. But, I would like to have the "Delete Their PM!" link removed. The way it stands now, if the sender deletes the PM, the "Delete Their PM" link is still active. This could be gotten rid of to prevent an error message.

DivisionByZero 04-03-2005 05:03 AM

Ok, in the meantime, while pie works on the authenticate_sender_before_delete scheme, I added a quick fix to it. It's simple.. It replaces the entire request routine and here it is:

PHP Code:

if ($_REQUEST['do'] == "deleteunread")
{
$pm $_GET['pm'];

// check to see if it is still unread and the user hasn't dilly-dallied
        
$pmquery $DB_site->query("SELECT * FROM " TABLE_PREFIX "pm WHERE pmid='$pm'");
        
$pmnum $DB_site->num_rows($pmquery);

        if (
$pmnum == 0)
        {
            
$idname $vbphrase['private_message'];
            eval(
print_standard_error('invalidid'));
        }

     
$pmquery $DB_site->query("SELECT * FROM " TABLE_PREFIX "pm WHERE pmid=$pm AND messageread=0");
        if (
$DB_site->num_rows($pmquery) == 0)
        {
            eval(
print_standard_error('hasbeenread'));
        }
        
// check to the actual sender of the PM is the one trying to delete it. Done by chris
        
$suspectuser $bbuserinfo['userid'];
    
$senderquery $DB_site->query("SELECT userid FROM " TABLE_PREFIX "pmreceipt WHERE pmid=$pm AND readtime=0");
        
$senderresult mysql_fetch_assoc($senderquery);
        if (
$senderresult['userid'] == $suspectuser) {

        
$receiptSql "UPDATE " TABLE_PREFIX "pmreceipt SET deleted=1 WHERE pmid=$pm";
        
$DB_site->query($receiptSql);

        
$deletePmSql "DELETE FROM " TABLE_PREFIX "pm WHERE pmid=" $pm;
        
$DB_site->query($deletePmSql);        

        
$url "private.php?$session[sessionurl]do=trackpm";
        eval(
print_standard_redirect('deleted_private_messages_successfully'));
        }
        else {
        
$idname $vbphrase['private_message'];
        eval(
print_standard_error('invalidid'));
        }



DivisionByZero 04-03-2005 05:18 AM

To replace the "Delete Their PM!" link if the PM has already been deleted by the sender, do the following:

In private.php, find

PHP Code:

 $pmreceipts $DB_site->query("
        SELECT
            pmreceipt.*, pmreceipt.pmid AS receiptid
        FROM " 
TABLE_PREFIX "pmreceipt AS pmreceipt
        WHERE pmreceipt.userid = 
$bbuserinfo[userid]
        ORDER BY pmreceipt.sendtime DESC
    "
); 

Replace with:
PHP Code:

    $pmreceipts $DB_site->query("
        SELECT
            deleted, pmreceipt.*, pmreceipt.pmid AS receiptid
        FROM " 
TABLE_PREFIX "pmreceipt AS pmreceipt
        WHERE pmreceipt.userid = 
$bbuserinfo[userid]
        ORDER BY pmreceipt.sendtime DESC
    "
); 

The pm_receiptsbit template replacement string should be changed to:
HTML Code:

                <td class="alt2"><span class="smallfont"><if condition="$show['readpm']">$receipt[read_date] <span class="time">$receipt[read_time]</span><else /><em>$vbphrase[unread_date]<br /><if condition="$receipt[deleted] == '0'"><a href="private.php?$sesion[sessionurl]do=unsend&amp;pm=$receipt[receiptid]">$vbphrase[deleteunread]</a><else />$vbphrase[was_deleted]</if></em></if></td>

pie 04-12-2005 10:05 PM

You saying you want an Undelete?

DivisionByZero 04-12-2005 11:29 PM

No, i noticed now if a user deletes the PM WITHOUT reading it, the receipt should be processed as "confirmed" and not have the "delete their pm" availability anymore. :)

angelicGrace 05-04-2005 05:20 PM

Question.

Ok I installed the hack and it seems to be working well. But I have a q. When you send a pm, then delete it before they read it, it still shows up in the navabar as the user having a new pm. This is what it looks like:

Welcome, Test User.
You last visited: Today at 12:53 PM
Private Messages: 1 Unread, Total 1.

I can't seem to find away to clear that up. Any suggestions?

BeePee 05-15-2005 10:28 PM

Yup and I tried to finally found a fix:


change the original file edit to this:

FILE EDITS:
private.php

**find
PHP Code:


        
// #############################################################################

        
if ($templatename != '')
        { 

**ABOVE ADD
PHP Code:


// ############################### delete unread pm ############################
if ($_REQUEST['do'] == "deleteunread")
{
$pm $_GET['pm'];

// check to see if it is still unread and the user hasn't dilly-dallied
        
$pmquery $DB_site->query("SELECT * FROM " TABLE_PREFIX "pm WHERE pmid='$pm'");
        
$pmnum $DB_site->num_rows($pmquery);

        if (
$pmnum == 0)
        {
            
$idname $vbphrase['private_message'];
            eval(
print_standard_error('invalidid'));
        }

    
$pmquery $DB_site->query("SELECT * FROM " TABLE_PREFIX "pm WHERE pmid=$pm AND messageread=0");
        if (
$DB_site->num_rows($pmquery) == 0)
        {
            eval(
print_standard_error('hasbeenread'));
        }
        
// check to the actual sender of the PM is the one trying to delete it. Done by chris
        
$suspectuser $bbuserinfo['userid'];
    
$senderquery $DB_site->query("SELECT userid, touserid FROM " TABLE_PREFIX "pmreceipt WHERE pmid=$pm AND readtime=0");
        
$senderresult mysql_fetch_assoc($senderquery);
        if (
$senderresult['userid'] == $suspectuser) {

        
$receiptSql "UPDATE " TABLE_PREFIX "pmreceipt SET deleted=1 WHERE pmid=$pm";
        
$DB_site->query($receiptSql);

        
$reduceunreadPmSql "UPDATE " TABLE_PREFIX "user SET pmunread=pmunread-1 WHERE " $senderresult['touserid'];
        
$DB_site->query($reduceunreadPmSql);        
        
$reducetotalPmSql "UPDATE " TABLE_PREFIX "user SET pmtotal=pmtotal-1 WHERE " $senderresult['touserid'];
        
$DB_site->query($reducetotalPmSql);        

        
$deletePmSql "DELETE FROM " TABLE_PREFIX "pm WHERE pmid=" $pm;
        
$DB_site->query($deletePmSql);        

        
$url "private.php?$session[sessionurl]do=trackpm";
        eval(
print_standard_redirect('deleted_private_messages_successfully'));
        }
        else {
        
$idname $vbphrase['private_message'];
        eval(
print_standard_error('invalidid'));
        }


If you have users which have already a PM count problem run the following querries on them depending which count is off use one of them or both for each affected user:

Code:

UPDATE user SET pmunread=pmunread-1 WHERE userid='<<recipient>>';
UPDATE user SET pmtotal=pmtotal-1 WHERE userid='<<recipient>>';

replace '<<recipient>>' with the userid nbr.

HTH
cheers

angelicGrace 05-16-2005 12:50 AM

Thank you EVER so much! :)

Marco van Herwaarden 05-16-2005 08:47 AM

Nice one BeePee. :D

The $pm variable should however be sanitized to prevent a possible SQL injection.

replace:
PHP Code:

$pm $_GET['pm']; 

by
PHP Code:

$pm intval($_GET['pm']); 


BeePee 05-16-2005 01:17 PM

Thanks m8 ;)

yoyoyoyo 05-16-2005 11:26 PM

while doing the template edits I get this error in 3.0.6:

Quote:

The following error occurred when attempting to evaluate this template:

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/site/public_html/forum/includes/adminfunctions_template.php(3096) : eval()'d code on line 4

This is likely caused by a malformed conditional statement. It is highly recommended that you fix this error before continuing, but you may continue as-is if you wish.
line 3096 is:
Code:

                eval('$devnull = "' . $template . '";');

yoyoyoyo 05-17-2005 01:37 PM

does anyone know what the problem is? I find it odd that I am the first one to encounter this error, since I am adding this hack to a new forum without any other hacks installed. Is this a 3.0.6 incompatibilty issue?

Marco van Herwaarden 05-17-2005 02:30 PM

What editor did you use to change the files?

yoyoyoyo 05-17-2005 04:05 PM

Quote:

Originally Posted by MarcoH64
What editor did you use to change the files?

notepad2

Marco van Herwaarden 05-17-2005 06:06 PM

Please post a few lines before and after the line you posted above.


All times are GMT. The time now is 01:25 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01614 seconds
  • Memory Usage 1,899KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (1)bbcode_html_printable
  • (11)bbcode_php_printable
  • (17)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete