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)
-   -   [VB3 RC3] Attachments in private messages (https://vborg.vbsupport.ru/showthread.php?t=59840)

Keyser S?ze 07-22-2004 10:52 PM

ok this works fine for me in 3.0.1 BUT, when i load a PM with a attachment, takes forever, like a full 2 minutes to load the PM

thats the only problem, other PMs load very fast, almost instantly

moley 07-25-2004 12:12 PM

when i used it on 3.0.1 i got an error

An error occurred while attempting to execute your query. The following information was returned.
error number: 1064
error desc: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ';
ALTER TABLE pmtext add attach int not null;
ALTER TABLE att

anyone know how to fix it?

Datenpapst 07-26-2004 01:27 PM

aren't privat messages privat and only for the users themselfs?

moley 07-27-2004 03:19 PM

a private message is from one person to another this hack can be used in this sorta of case user 1 made a new wallpaper and he wants to show his friend user 2. Instead of making a thread user 1 goes and makes a pm with the image attahment so that way the only two people who will see it are user 1 and user 2.

Also on your sites portal you seem to have latest thread replies twince once on the left hand colum and once under the latest news. justing pointing out.

weaver 08-02-2004 03:28 PM

I can't find either of these pieces of code in private.php. I'm running 3.0.3.

Quote:

$postid = verify_id('post', $attachmentinfo['postid']);
Quote:

verify_forum_password($foruminfo['forumid'], $foruminfo['password']);

Weasel 08-24-2004 03:32 AM

snobbymom, in that last piece of code just replace foruminfo with attachmentinfo everywhere you see it in the edit.

As for the " $postid = ..." I'm wondering the same thing myself. Its possible that that edit could be skipped.

Otherwise all of the edits are fairly straightforward even if they dont match the new 3.0.3 code exactly. Can anyone get this working in 3.0.3?

RobinHood 09-12-2004 12:37 AM

Oh, guess what? I got this working for VB 3.0.3! :)

Took me an hour, but I got it! :)

A working demo of it is at http://www.generazn.com.

I will post a fix for this hack very soon. :)

RobinHood 09-12-2004 01:13 AM

Okay, here is the fix! :)

First,

Open attachment.php:

Find:


PHP Code:

if (!$attachmentinfo $DB_site->query_first("
    SELECT filename, attachment.postid, attachment.userid, attachmentid,
        " 
iif($thumb'thumbnail AS filedata, thumbnail_dateline AS dateline, thumbnail_filesize AS filesize,''attachment.dateline, filedata, filesize,') . "
        attachment.visible, mimetype, NOT ISNULL(deletionlog.primaryid) AS isdeleted,
        thread.forumid, forum.password, thread.threadid
    FROM " 
TABLE_PREFIX "attachment AS attachment
    LEFT JOIN " 
TABLE_PREFIX "attachmenttype AS attachmenttype ON(attachmenttype.extension = SUBSTRING_INDEX(attachment.filename, '.', -1))
    LEFT JOIN " 
TABLE_PREFIX "deletionlog AS deletionlog ON(attachment.postid = deletionlog.primaryid AND type = 'post')
    LEFT JOIN " 
TABLE_PREFIX "post AS post ON (post.postid = attachment.postid)
    LEFT JOIN " 
TABLE_PREFIX "thread AS thread ON (post.threadid = thread.threadid)
    LEFT JOIN " 
TABLE_PREFIX "forum AS forum ON (forum.forumid = thread.forumid)
    " 
iif($postid"WHERE attachment.postid = $postid""WHERE attachmentid = $attachmentid") . "
"
)) 

Replace with:

PHP Code:

if (!$attachmentinfo $DB_site->query_first("
    SELECT filename, attachment.postid, attachment.userid, attachmentid,
        " 
iif($thumb'thumbnail AS filedata, thumbnail_dateline AS dateline, thumbnail_filesize AS filesize,''attachment.dateline, filedata, filesize,') . "
        attachment.visible, mimetype, NOT ISNULL(deletionlog.primaryid) AS isdeleted, private, 
        thread.forumid, forum.password, thread.threadid
    FROM " 
TABLE_PREFIX "attachment AS attachment
    LEFT JOIN " 
TABLE_PREFIX "attachmenttype AS attachmenttype ON(attachmenttype.extension = SUBSTRING_INDEX(attachment.filename, '.', -1))
    LEFT JOIN " 
TABLE_PREFIX "deletionlog AS deletionlog ON(attachment.postid = deletionlog.primaryid AND type = 'post')
    LEFT JOIN " 
TABLE_PREFIX "post AS post ON (post.postid = attachment.postid)
    LEFT JOIN " 
TABLE_PREFIX "thread AS thread ON (post.threadid = thread.threadid)
    LEFT JOIN " 
TABLE_PREFIX "forum AS forum ON (forum.forumid = thread.forumid)
    " 
iif($postid"WHERE attachment.postid = $postid""WHERE attachmentid = $attachmentid") . "
"
)) 

Next, find:

PHP Code:

if ($attachment['postid'] == AND $bbuserinfo['userid'] == $attachmentinfo['userid']) 

On top of that, add the following:

PHP Code:

if (!$attachmentinfo['private']) {
    
$postid verify_id('post'$attachmentinfo['postid']);


Next, find:

PHP Code:

if (!($forumperms CANVIEW) OR !($forumperms CANGETATTACHMENT))
    {
        
print_no_permission();
    }

    
// check if there is a forum password and if so, ensure the user has it set
    
verify_forum_password($attachmentinfo['forumid'], $attachmentinfo['password']); 

Replace it with the following:

PHP Code:

if (!($forumperms CANGETATTACHMENT))
{
    
$vboptions['viewattachedimages'] = 0;
    
$vboptions['attachthumbs'] = 0;
}

// check if there is a forum password and if so, ensure the user has it set
    
verify_forum_password($attachmentinfo['forumid'], $attachmentinfo['password']);

$pmUsers $DB_site->query_first("SELECT toUserArray FROM ".TABLE_PREFIX."pmtext WHERE pmtextid='".$attachmentinfo['private']."'");
    
$toUserArray unserialize($pmUsers['toUserArray']);         
    if (
$toUserArray[$bbuserinfo['userid']] != $bbuserinfo['username'] && $attachmentinfo['userid'] != $bbuserinfo['userid']) {
            
print_no_permission();        
           } 


THAT'S IT! YOU'RE DONE!

It should be working now. If not, let me know because it is working for me. :)

btappan 09-12-2004 08:34 PM

Props to RobinHood! up and working on my forums, no problems thus far! man does this hack take a while to install though!

Weasel 09-14-2004 02:00 AM

I'm having problems with your code RobinHood, it seems to break the permissions of normal attachments, i.e. no one can view them now.

RobinHood 09-14-2004 02:34 AM

Quote:

Originally Posted by Weasel
I'm having problems with your code RobinHood, it seems to break the permissions of normal attachments, i.e. no one can view them now.

Okay, try this:

Change:

PHP Code:

if (!($forumperms CANGETATTACHMENT)) 

    
$vboptions['viewattachedimages'] = 0
    
$vboptions['attachthumbs'] = 0


To:

PHP Code:

if (!($forumperms CANVIEW) OR !($forumperms CANGETATTACHMENT)) 

    
$vboptions['viewattachedimages'] = 0
    
$vboptions['attachthumbs'] = 0


That should do the trick. Let me know how it goes. :)

BamaStangGuy 09-14-2004 05:08 AM

Quote:

Originally Posted by RobinHood
Okay, try this:

Change:

PHP Code:

if (!($forumperms CANGETATTACHMENT)) 

    
$vboptions['viewattachedimages'] = 0
    
$vboptions['attachthumbs'] = 0


To:

PHP Code:

if (!($forumperms CANVIEW) OR !($forumperms CANGETATTACHMENT)) 

    
$vboptions['viewattachedimages'] = 0
    
$vboptions['attachthumbs'] = 0


That should do the trick. Let me know how it goes. :)

all my thumbnails are red x's and I get a no permisson

I have done what you said to do above and it still doesnt work

BamaStangGuy 09-14-2004 05:12 AM

Something I just realized

It breaks all the thumbnails and images that were uploaded before the pm hack was installed. But if I upload a new image on the forum it works fine.

Basically all my old attachments show up as red x's and give a no permission when clicked.

But if I add a new attachment to a thread then it works fine

BamaStangGuy 09-14-2004 05:57 AM

Quote:

Code:

if (!($forumperms & CANGETATTACHMENT))
{
    $vboptions['viewattachedimages'] = 0;
    $vboptions['attachthumbs'] = 0;
}

// check if there is a forum password and if so, ensure the user has it set
    verify_forum_password($attachmentinfo['forumid'], $attachmentinfo['password']);

$pmUsers = $DB_site->query_first("SELECT toUserArray FROM ".TABLE_PREFIX."pmtext WHERE pmtextid='".$attachmentinfo['private']."'");
    $toUserArray = unserialize($pmUsers['toUserArray']);         
    if ($toUserArray[$bbuserinfo['userid']] != $bbuserinfo['username'] && $attachmentinfo['userid'] != $bbuserinfo['userid']) {
            print_no_permission();       
          }


It works fine until I had this part. Id di it in steps. Aded the first uploaded images showed. Added the second part images still showed. When I added the above part the images broke.

It still does it with what you posted in your lsat post as well

Weasel 09-14-2004 10:38 AM

Yea same here, it breaks all previously uploaded attechments to the forum (thumbs and permissions to view).

Saphrym 09-14-2004 05:49 PM

Quote:

Originally Posted by Weasel
Yea same here, it breaks all previously uploaded attechments to the forum (thumbs and permissions to view).

Ok. Got this thing to work right in 3.0.3. I spent some time trying to figure out exactly what was trying to be done with the edits, and figured out how to do it.


Start with a fresh attachment.php (or one without the modifications for pms)

Find:
PHP Code:

attachment.visiblemimetypeNOT ISNULL(deletionlog.primaryid) AS isdeleted,
        
thread.forumidforum.passwordthread.threadid 

Change to: (Purpose: Adds private as an option variable)
PHP Code:

attachment.visiblemimetypeNOT ISNULL(deletionlog.primaryid) AS isdeleted,
        
thread.forumidforum.passwordthread.threadid, private 

Find:
PHP Code:

if ($attachment['postid'] == AND $bbuserinfo['userid'] == $attachmentinfo['userid']) 

Add Above: (Purpose: Starts an if/then statement that if it's not a private message attachment do things like normal)
PHP Code:

if (!$attachmentinfo['private']) { 

Find:
PHP Code:

    // check if there is a forum password and if so, ensure the user has it set
    
verify_forum_password($attachmentinfo['forumid'], $attachmentinfo['password']);

    if (!
$attachmentinfo['visible'] AND !can_moderate($attachmentinfo['forumid'], 'canmoderateattachments') AND $attachmentinfo['userid'] != $bbuserinfo['userid'])
    {
        
$idname 'attachment';
        eval(
print_standard_error('error_invalidid'));
    }


Add Below: (Purpose: Ends the if/then statement and adds what to do if it IS a private message attachment.)
PHP Code:

} else {
    
$pmUsers $DB_site->query_first("SELECT toUserArray FROM ".TABLE_PREFIX."pmtext WHERE pmtextid='".$attachmentinfo['private']."'");
    
$toUserArray unserialize($pmUsers['toUserArray']);         
    if (
$toUserArray[$bbuserinfo['userid']] != $bbuserinfo['username'] && $attachmentinfo['userid'] != $bbuserinfo['userid']) {
            
print_no_permission();        
           }


I've tested it with different users until I got the code working properly for both regular attachments and pm attachments. So this should work fine for those of you using 3.0.3.

Hope this helps.

BamaStangGuy 09-14-2004 06:02 PM

It worked!!!

Thanks

Weasel 09-14-2004 09:16 PM

Good job, the simplest solution is always the best, huh?

RobinHood 09-18-2004 09:46 PM

Quote:

Originally Posted by Weasel
Good job, the simplest solution is always the best, huh?

Is it just me or is there something wrong with the script? Why does it kept deleting the attachments right after a few hours or so???

AZone 09-19-2004 06:23 PM

I am sorry, but can someone summarize all the steps I need to do to get it work? Or does the file in the first post contain complete solution?
Thank you.

Weasel 09-20-2004 05:32 PM

Quote:

Originally Posted by RobinHood
Is it just me or is there something wrong with the script? Why does it kept deleting the attachments right after a few hours or so???

Hmm, you're right. It must be a problem in the cleanup cron. :disappointed:

beano33 09-20-2004 09:40 PM

Quote:

Originally Posted by AZone
I am sorry, but can someone summarize all the steps I need to do to get it work? Or does the file in the first post contain complete solution?
Thank you.

I'd appreciate that too. A re-release for vBulletin Version 3.0.3 is what's needed.

Mattius 09-22-2004 04:05 AM

the same problem occurs with the attachments for calendar hack. the same missing $postid code etc...

Ive posted a message there as well

theArchitect 09-22-2004 11:48 PM

This Hack concept sounds sensational. But I am having a problem with the install. I have got down to the section where I need to modify the attachment.php file and I have been asked to find:

PHP Code:

$postid verify_id('post'$attachmentinfo['postid']); 

But I can't find this code anywhere. I initially thought it was due to another hack I had installed. But I have checked the original vB 3.0.3 file and it isn't there either. Nor is the next line of code:

PHP Code:

verify_forum_password($foruminfo['forumid'], $foruminfo['password']); 

Assistance would be most appreciated.

Mattius 09-23-2004 06:42 AM

Many others are in the same boat :) Its not in the 3.0.3 code, this current hack is designed for 3.0.0 and 3.0.1...but with relatively small changes you should be able to get it too work in 3.0.3.

The problem gets worse when your trying to implement the calendar hack as well because modify identical bits of code, which i sort of had working apart from the fact the attachment disappears after a while :)...a couple others have had the same problem here...Im using 3.0.3.

We really need a genius to come along and sort it all out for us. Unfortunately im not that genius :)

theArchitect 09-23-2004 06:49 AM

Quote:

Originally Posted by Mattius
Many others are in the same boat :) Its not in the 3.0.3 code, this current hack is designed for 3.0.0 and 3.0.1...

yes, for the first time what version of vB I am using is becoming an issue (I am very new to hacks). I am also dreading what will happen when vB produce the next release. I am not looking forward to having to re-install all of my hacks.

Mattius 09-23-2004 08:09 AM

Yup hopefully more hack writers will use the HTL script, so it will be easy to adminster hacks...

Dont loose hope though i im pretty sure this particular hack will be modified for 3.0.3 soon...

btappan 09-29-2004 04:59 PM

Quote:

Originally Posted by RobinHood
Is it just me or is there something wrong with the script? Why does it kept deleting the attachments right after a few hours or so???

anybody fix this yet? can i make it delete them after they are a week old or something?

btappan 10-01-2004 01:39 AM

do you think if we just revert the clean up file it would work temporarily at least to avoid pm attachments being deleted. they would probably build up but couldnt we manually clear them out once in a while?

theArchitect 10-01-2004 02:37 AM

Quote:

Originally Posted by btappan
anybody fix this yet? can i make it delete them after they are a week old or something?

As I understand, the attachment exists so long as the PM does. So once the PM is deleted so too is the attachment.

I would probably leave it like this as if attachments are auto deleted you will get lots of complaint PMs about "where have my attachments gone?"

As for the build up, This is something users need to control (unless you have restrictions on your web space). Just set the attachment allowance to a lower number, then users will need to delete older (or less important ) attachments before they can include new ones.

RobinHood 10-01-2004 03:04 AM

Quote:

Originally Posted by btappan
anybody fix this yet? can i make it delete them after they are a week old or something?

I already tried that. The attachment would still be deleted even though the PM still exists. The attachment would be deleted within a few hours.

btappan 10-01-2004 04:14 PM

believe me, the attachments are being deleted even when the pm is still there. I have informed my users to not delete any messages to test what is happening. no one has deleted their messages, and the attachments are still dissappearing.

btappan 10-01-2004 04:42 PM

I have determined from my testing that the attachments are being deleted shortly after they have been viewed, not when the user deletes the PM. Also, if I send another user a PM attachment and then look at what i sent them in my sent items folder before the recipient has even looked at it, it is usually deleted before they view it unless they look at it quick enough b4 it gets cleaned out by thr cron file. so wether the sender or the recipient views the attachment once it has been sent, it will be deleted shortly thereafter. back to my original question: can i temporarily fix this by reverting my cleanup file? i don't really care if the attachments aren't being deleted in the mean time until someone comes up with a fix for this. let me know

Kentaurus 10-05-2004 02:23 AM

I'm really really sorry about not upgrading this hack, I have it upgraded in my forum and there are a couple modifications that have to be made to make it compatible with 3.0.3. theArchitect sent me a pm today and I headed here to upgrade my hack as fast as I could :)

I originally designed this hack for RC3 and upgraded it until gold, but I haven't had time lately to upgrade my hacks (or to document them). Anyway, I'll attach in the first post the upgraded txt for the 3.0.3 vbulletin.

About the cron job. Hourly all the orphan attachments (that is the attachments that were uploaded but the post was never commited) are deleted. When my hack is not installed then an attachment in the pm counts as a not commited attachment (that are the replacements in the cleanup2.php file). That is new behaviour in 3.0.3, in earlier versions they checked the posthash instead of the postid.

That would mean that if you upgraded to 3.0.3 and didn't upgrade the hack you might've lost your private attachments. You'd need to edit the files (or at least the cleanup2.php, then upgrade to 3.0.3 for your attachments to be safe.

theArchitect 10-05-2004 11:31 PM

Quote:

Originally Posted by Kentaurus
I'm really really sorry about not upgrading this hack, I have it upgraded in my forum and there are a couple modifications that have to be made to make it compatible with 3.0.3. theArchitect sent me a pm today and I headed here to upgrade my hack as fast as I could :)

Many thanks, you assistance is most appreciated.

However I am having a problem with the install. I have rechecked my work but am getting the following error message when I try and upload an attachment:

Invalid Post specified. If you followed a valid link, please notify the webmaster

I also recieved a DB error report:

Code:

Database error in vBulletin 3.0.3:
 
 Invalid SQL:
 
                DELETE FROM attachment
 
                WHERE postid = 0 AND private = 0 AND
 
                dateline < 1097016998
 mysql error: Unknown column 'private' in 'where clause'
 
 mysql error number: 1054

Do you have any thoughts as to what stage of the hack install I have done incorrectly?

RobinHood 10-06-2004 03:57 AM

Quote:

Originally Posted by theArchitect
Many thanks, you assistance is most appreciated.

However I am having a problem with the install. I have rechecked my work but am getting the following error message when I try and upload an attachment:

Invalid Post specified. If you followed a valid link, please notify the webmaster

I also recieved a DB error report:

Code:

Database error in vBulletin 3.0.3:
 
 Invalid SQL:
 
                DELETE FROM attachment
 
                WHERE postid = 0 AND private = 0 AND
 
                dateline < 1097016998
 mysql error: Unknown column 'private' in 'where clause'
 
 mysql error number: 1054

Do you have any thoughts as to what stage of the hack install I have done incorrectly?

Make sure you have "private" column in the attachment table.

theArchitect 10-06-2004 06:46 AM

Quote:

Originally Posted by RobinHood
Make sure you have "private" column in the attachment table.

Bizarre. I re-checked this on one of my test forums and ended up with the error that the row had already been added (when I tried it I got rows affected 0).

So I ran the entire install process on a different board and everything seems to be working fine. I guess I will just have to put it down to another vB X File.

But thankyou for your help.

btappan 10-06-2004 02:11 PM

Quote:

Originally Posted by Kentaurus
About the cron job. Hourly all the orphan attachments (that is the attachments that were uploaded but the post was never commited) are deleted. When my hack is not installed then an attachment in the pm counts as a not commited attachment (that are the replacements in the cleanup2.php file). That is new behaviour in 3.0.3, in earlier versions they checked the posthash instead of the postid.

So if I reinstall the entire hack with your new release it will cure my current problem of pm attachments being deleted hourly once they have been viewed? also, how different is your release compared to the other? Am I going to have a problem running the commands since I already have the last version installed?

Kentaurus 10-10-2004 12:23 AM

Yes, it should cure that problem. However for that you need only to modify the cleanup2.php file in your includes/cron directory (with the instructions in the hack)

Only attachment.php and cleanup2.php have heavy modifications, you might want to check only those if it is already installed and working.

Debbi 10-22-2004 07:21 AM

I would LOVE to have this mod for 3.0.3. Any chance of this in the near future?


All times are GMT. The time now is 12:33 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.02821 seconds
  • Memory Usage 1,921KB
  • 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
  • (3)bbcode_code_printable
  • (18)bbcode_php_printable
  • (17)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
  • (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