vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 2.x Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=4)
-   -   Attachments show up as links if larger than a certain size. (https://vborg.vbsupport.ru/showthread.php?t=36828)

Zzed 03-31-2002 10:00 PM

Attachments show up as links if larger than a certain size.
 
Note: I have revised this hack to use the MySql LENGTH() function.

This hack alters the attachment view property. If the size of the attached
image is larger than a specified size, the attachment will show up as a
hyperlink as opposed to the actual image.

The size limit for the time being is hardcoded at 50000. I know I should
have made it configurable. My apologies. :( I will work on it if anyone is
interested.

This hack was requested by Fzale.

Here are the instructions on how to implement it.

In admin/functions.php, look for the following text:
PHP Code:

        if ($post[attachmentid]!=and $post[attachmentvisible]) {
                
$post[attachmentextension]=strtolower(getextension($post[filename]));
                if (
$post[attachmentextension]=="gif" or $post[attachmentextension]=="jpg" or $post[attachmentextension]=="jpeg" or $post[attac\
hmentextension]=="jpe" or $post[attachmentextension]=="png") {
                        if ((
$viewattachedimages) and ($bbuserinfo[userid]==or $bbuserinfo[showimages])) {
                                eval(
"\$post[attachment] = \"".gettemplate("postbit_attachmentimage")."\";");
                        } else {
                                eval(
"\$post[attachment] = \"".gettemplate("postbit_attachment")."\";");
                        }
                } else {
                        eval(
"\$post[attachment] = \"".gettemplate("postbit_attachment")."\";");
                }
        } else {
                
$post[attachment]="";
        } 

And replace it with the following:
PHP Code:

//
// Attachment size hack
//
                        
global $DB_site;
                        
$attachinfo=$DB_site->query_first("SELECT LENGTH(filedata) as ATTLEN from attachment where attachmentid = '$post[attachmentid]'");
                        if(
$attachinfo[ATTLEN] > 50000) {
                                
$ok_to_watch=0;
                        }
                        else {
                                
$ok_to_watch=1;
                        }
                        if ((
$ok_to_watch) and ($viewattachedimages) and ($bbuserinfo[userid]==or $bbuserinfo[showimages])) {
                                eval(
"\$post[attachment] = \"".gettemplate("postbit_attachmentimage")."\";");
                        } else {
                                eval(
"\$post[attachment] = \"".gettemplate("postbit_attachment")."\";");
                        }
                } else {
                        eval(
"\$post[attachment] = \"".gettemplate("postbit_attachment")."\";");
                }
        } else {
                
$post[attachment]="";
        } 

Your feedback will be appreciated. :)

Admin 04-01-2002 05:53 AM

Very nice. :)
Although, I think you should use LENGTH() directly in MySQL as I think it will be faster than catching the data for PHP. And, you should also do this query in showthread.php, in that huge query that gets all the info. That way you don't need to add another query for every attachment you have in the thread. Good job nonetheless! :)

Zzed 04-01-2002 06:00 AM

Thank you for the kind words and the suggestions. :)

I feel so honored to be complimented by the great FireFly. :)

Thanks again. :)

Neo 04-01-2002 07:00 AM

ver nice man... now I need to make my damn attachments hack :O

Zzed 04-01-2002 07:25 AM

Thanks neo. :)

BTW, I like the ideas of your current projects. :) I will be very interested in getting them when you are finished. :)

freakyshiat 04-02-2002 04:26 AM

works perfect :)
thanks a bunch

Zzed 04-02-2002 05:59 AM

You're welcome. :)

freakyshiat 04-02-2002 02:53 PM

Quote:

Originally posted by FireFly
Very nice. :)
Although, I think you should use LENGTH() directly in MySQL as I think it will be faster than catching the data for PHP. And, you should also do this query in showthread.php, in that huge query that gets all the info. That way you don't need to add another query for every attachment you have in the thread. Good job nonetheless! :)

so for every attachment, its adding a query, right?
Do you have a little time to do the coding you explained? If not, its cool... :)

(Thanks again Zzed)

Zzed 04-02-2002 04:50 PM

Ok, I revised the code to use the MySql LENGTH() function. I already tested it. Works like a charm. :)

I have already edited the original post and I have reposted the revised instructions file. ;)

freakyshiat 04-02-2002 09:53 PM

Quote:

Originally posted by Zzed
Ok, I revised the code to use the MySql LENGTH() function. I already tested it. Works like a charm. :)

I have already edited the original post and I have reposted the revised instructions file. ;)

http://forums.off-topic.net/images/smilies/bowdown.gif


All times are GMT. The time now is 09:22 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.01241 seconds
  • Memory Usage 1,764KB
  • 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_php_printable
  • (2)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
  • (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