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)

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 10:37 PM.

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.01172 seconds
  • Memory Usage 1,766KB
  • 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
  • (4)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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