vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   attachment viewing.. (https://vborg.vbsupport.ru/showthread.php?t=37105)

JediKNight 04-07-2002 02:06 AM

attachment viewing..
 
I think of a small modification (since I am very new to PHP, i don't want to call it a hack yet :D) to let user view the attachment nicely on a page with a layout..
I commented out the if at the end of attachment.php and the echo command, to insert this:

PHP Code:

header("Content-type:text/html");

$pointer=fopen("$attachmentinfo[filename]""a+");
fwrite ($pointer,$attachmentinfo[filedata]);
fclose($pointer);

print <<<END
You're viewing attachment from $bbtitle
<img src="
$attachmentinfo[filename]">
END; 

but it took the server too long to write the file and show the html with the picture.. and guess what.. the image actually showed up but was totally corrupted.. so bad that was beyond recognization..

there is no way to overcome that?

Jedi

Admin 04-07-2002 10:46 AM

I wrote this kind of hack, check it out "Attachment Viewer". You can just link to attachment.php?attachmentid=XX to view the image, but you also need to make sure you don't output the HTML twice. :)

JediKNight 04-07-2002 01:58 PM

FireFly, thank you for your speedy reply.

My idea of attachment viewing is slightly different from your solution.

I would like to WRITE the $attachmentinfo[filedata] into an image file on the server, then serve the user a page in HTML to show that image (with <img..> tags), this way we can create a new template to have a better attachment viewing experience for user, and better advertising for our forums..
We will be also able to let them know where are they watching the image... (In case someone links attachment in our forum to other places.)

but I don't know why the fwrite() tooks so long to finish, and the newly written file is totally corrupted.. I think fwrite() is binary safe?

my board is 2.2.4 and I am testing with 2.2.4

Jedi


All times are GMT. The time now is 02:18 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.01021 seconds
  • Memory Usage 1,715KB
  • 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
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete