Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.6 > vBulletin 3.6 Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Attached Image Watermarking PLUS Guest Viewing of Thumbnails Details »»
Attached Image Watermarking PLUS Guest Viewing of Thumbnails
Version: 1.00, by ConqSoft ConqSoft is offline
Developer Last Online: Mar 2012 Show Printable Version Email this Page

Category: Add-On Releases - Version: 3.6.8 Rating:
Released: 03-11-2007 Last Update: 03-12-2007 Installs: 210
Uses Plugins
Additional Files  
No support by the author.

I had been looking for these two options for quite a while, and was finally able to hire Brian (of vBadvanced) to write them for me. Since a lot of people have been looking for this, I have decided (with Brian's permission) to release this as a free, unsupported, modification.

This modification will allow you to specify a watermark image that will be overlayed over any attached JPG or PNG file on your site in real time, as the image is displayed. NO PERMANENT CHANGES ARE MADE TO ANY OF YOUR ATTACHMENTS. You can also exclude specific forums and usergroups from seeing the watermark.

As an added bonus, he included the ability to allow guests to see attached image thumbnails, while still requiring them to register to see the full size attachments. (Make sure you have your Unregistered / Not Logged In usergroup set to NOT have access to download attachments.)

PLEASE CLICK INSTALL so that maybe Jelsoft will include these as built-in features in a future version.

Notes/Troubleshooting:
  • Your server needs to have GD2 installed.
  • Attachments must be stored in the file system. Database storage of file attachments will not work.
  • Make sure you use the full PHYSICAL path to your watermark image.
  • Make sure you have a low number in the width/height setting. (I use 200, since my watermark image is 150 pixels wide.)
  • If you have previously viewed the attached image, your browser may cache it, so you will need to clear your browser cache or force a hard refresh (CTRL-F5) while viewing the image to get the new watermarked version.


Well, on to the modification:

=============================================
STEP 1:
Since the resulting file contains too much vBulletin code, I am unable to include it with this modification. So, the first step is to copy vBulletin's attachment.php to a file named attachment_watermark.php. Then, edit attachment_watermark.php, making the following changes.

=============================================
STEP 2:
You need to delete a LOT of lines from the top of the file. Find this line...
Code:
$idname = $vbphrase['attachment'];
...and delete everything ABOVE it other than the <?php line at the top of the file.

Your attachment_watermark.php file should begin with this code when you've completed this step:
Code:
<?php
$idname = $vbphrase['attachment'];

=============================================
STEP 3:
Find this line of code:
Code:
if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) OR !($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewthreads']) OR !($forumperms & $vbulletin->bf_ugp_forumpermissions['cangetattachment']) OR (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewothers']) AND ($attachmentinfo['postuserid'] != $vbulletin->userinfo['userid'] OR $vbulletin->userinfo['userid'] == 0)))
REPLACE with this code:
Code:
if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) OR !($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewthreads']) OR (!($forumperms & $vbulletin->bf_ugp_forumpermissions['cangetattachment']) AND !$vbulletin->GPC['thumb'])  OR (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewothers']) AND ($attachmentinfo['postuserid'] != $vbulletin->userinfo['userid'] OR $vbulletin->userinfo['userid'] == 0)))

=============================================
STEP 4:
Find these lines of code:
Code:
	else
	{
		$attachpath = fetch_attachment_path($attachmentinfo['userid'], $attachmentinfo['attachmentid']);
Add this code BELOW the lines referenced above:
Code:
// #########################################
// ##### Start modified section for watermarks
// #########################################

$vbulletin->options['attach_water_exforums'] = explode(',', $vbulletin->options['attach_water_exforums']);
$vbulletin->options['attach_water_exgroups'] = explode(',', $vbulletin->options['attach_water_exgroups']);


if ($vbulletin->options['attach_water_filelocation']
	AND in_array($extension, array('jpg', 'jpeg', 'png'))
	AND !in_array($attachmentinfo['forumid'], $vbulletin->options['attach_water_exforums'])
	AND !array_intersect(fetch_membergroupids_array($vbulletin->userinfo), $vbulletin->options['attach_water_exgroups'])
)
{
	$attachsize = getimagesize($attachpath);

	if ($attachsize[0] >= $vbulletin->options['attach_water_minsize'] AND $attachsize[1] >= $vbulletin->options['attach_water_minsize'])
	{
		$waterimage =& $vbulletin->options['attach_water_filelocation'];
		$watersize = getimagesize($waterimage);

		$waterext = strtolower(substr($waterimage, strrpos($waterimage, '.') + 1));

		// Coordinates (height)
		switch ($vbulletin->options['attach_water_coordinates'][0])
		{
			case 'n':
				$waterpos['height'] = 0 + $vbulletin->options['attach_water_padding'];
			break;
			case 'm':
				$waterpos['height'] = round(($attachsize[1] - $watersize[1]) / 2);
			break;
			case 's':
				$waterpos['height'] = round(($attachsize[1] - $watersize[1])) - $vbulletin->options['attach_water_padding'];
			break;
		}

		// Coordinates (width)
		switch ($vbulletin->options['attach_water_coordinates'][1])
		{
			case 'w':
				$waterpos['width'] = 0 + $vbulletin->options['attach_water_padding'];
			break;
			case 'c':
				$waterpos['width'] = round(($attachsize[0] - $watersize[0]) / 2);
			break;
			case 'e':
				$waterpos['width'] = round(($attachsize[0] - $watersize[0])) - $vbulletin->options['attach_water_padding'];
			break;
		}

		// Watermark ext
		switch ($waterext)
		{
			case 'jpg':
			case 'jpeg':
				$watermark = imagecreatefromjpeg($waterimage);
			break;

			case 'png':
				$watermark = imagecreatefrompng($waterimage);
			break;
		}

		// Attachment ext
		switch ($extension)
		{
			case 'jpg':
			case 'jpeg':
				$attachimage = imagecreatefromjpeg($attachpath);
			break;

			case 'png':
				$attachimage = imagecreatefrompng($attachpath);
			break;
		}

		imagealphablending($attachimage, true);

		$watermark_width = imagesx($watermark);
		$watermark_height = imagesy($watermark);

		imagecopy($attachimage, $watermark, $waterpos['width'], $waterpos['height'], 0, 0, $watersize[0], $watersize[1]);
		define('WATERMARKED', true);
	}
}
// #########################################
// ##### End modified section for watermarks
// #########################################

=============================================
STEP 5:
Find this line of code:
Code:
header('Content-Length: ' . (($lastbyte + 1) - $startbyte));
REPLACE with this code:
Code:
// #########################################
// ##### Start modified section for watermarks
// ##### Changed to prevent filesize header on watermarked images
// #########################################
if (!defined('WATERMARKED'))
{
	header('Content-Length: ' . (($lastbyte + 1) - $startbyte));
}
// #########################################
// ##### End modified section for watermarks
// #########################################

=============================================
STEP 6:
Find this line of code:
Code:
($hook = vBulletinHook::fetch_hook('attachment_display')) ? eval($hook) : false;
REPLACE with this code:
Code:
// #########################################
// ##### Start modified section for watermarks
// #########################################
if (!$vbulletin->GPC['thumb'] AND defined('WATERMARKED'))
{
	imagejpeg($attachimage);
	imagedestroy($attachimage);
	imagedestroy($watermark);
}
// #########################################
// ##### End modified section for watermarks
=============================================
STEP 7:
Find this line of code:
Code:
($hook = vBulletinHook::fetch_hook('attachment_complete')) ? eval($hook) : false;
REPLACE with this code:
Code:
exit;

=============================================
STEP 8:
Save and upload attachment_watermark.php to your forum root directory.


=============================================
STEP 9:
Install the product-attach_watermark.xml Product via the vBulletin AdminCP Product Manager.


=============================================
STEP 10:
Configure the options at AdminCP -> vBulletin Options -> Attachment Watermarks. All fields should be self-explanatory.

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #102  
Old 09-13-2007, 03:48 AM
geevest.com geevest.com is offline
 
Join Date: Apr 2006
Posts: 709
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

not work for me?

Code:
/usr/www/home/abc/abc.com/images/watermark.png
Reply With Quote
  #103  
Old 09-15-2007, 05:11 PM
Alibass's Avatar
Alibass Alibass is offline
 
Join Date: Mar 2007
Posts: 615
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

@ConqSoft

Nice hack and thanks for sharing. Works great!
Reply With Quote
  #104  
Old 09-23-2007, 07:05 AM
Alibass's Avatar
Alibass Alibass is offline
 
Join Date: Mar 2007
Posts: 615
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

@ConqSoft

Can your hack be modify to work with vB-Blog v1.01?
Reply With Quote
  #105  
Old 09-27-2007, 11:46 AM
ndut ndut is offline
 
Join Date: Sep 2007
Location: Indonesia
Posts: 335
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

hello.. can somebody help me, please..

i've tried to try this cool add ons.. but it doesn't work..
i've followed this script step by step... still no working..

i'm using vbulletin 3.6.8
i've put file attachment_watermark.php into my root forums folder
i've put file watermark.png into my images folder..
i've install the product-attach_watermark.xml Product via the vBulletin AdminCP Product Manager. still not working..

what should i type in "Watermark Image Location"
if my images. i stored in httpdocs/images folder..
fox example.. my site names is : www.ndut.com
now, i type : /ndut.com/httpdocs/images/watermark.png
but, doesnt work..

can somebody help me?? thanks before..
Reply With Quote
  #106  
Old 10-02-2007, 04:50 PM
clonebaby clonebaby is offline
 
Join Date: Apr 2007
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm using 3.6.8 but it doesn't work. Anybody help me please. Is it work with 3.6.8?
Reply With Quote
  #107  
Old 10-18-2007, 10:18 PM
nickypoooo's Avatar
nickypoooo nickypoooo is offline
 
Join Date: Aug 2007
Location: San Diego
Posts: 73
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

3.6.8 doesn't work, Anybody help us please
Reply With Quote
  #108  
Old 10-18-2007, 10:23 PM
ConqSoft's Avatar
ConqSoft ConqSoft is offline
 
Join Date: Jul 2003
Location: Raleigh, NC
Posts: 686
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by nickypoooo View Post
3.6.8 doesn't work, Anybody help us please
Works perfectly fine on 3.6.8 (and 3.6.8 PL1)
Reply With Quote
  #109  
Old 10-18-2007, 10:53 PM
Alibass's Avatar
Alibass Alibass is offline
 
Join Date: Mar 2007
Posts: 615
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I am using it on 3.6.8 PL1 also and it works great, fantastic mod!
Reply With Quote
  #110  
Old 11-05-2007, 02:08 AM
davidw's Avatar
davidw davidw is offline
 
Join Date: Jul 2005
Location: Arkansas
Posts: 2,815
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

How difficult would watermarking the thumbnails be?
I've rewritten some of this to add a second watermark (for smaller images). That worked out nicely. But I've not figured out watermarking thumbs yet.
Reply With Quote
  #111  
Old 11-05-2007, 10:21 AM
peterpigman peterpigman is offline
 
Join Date: May 2006
Posts: 200
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by davidw View Post
How difficult would watermarking the thumbnails be?
I've rewritten some of this to add a second watermark (for smaller images). That worked out nicely. But I've not figured out watermarking thumbs yet.
Why bother? thumbs are too small to watermark imho.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:20 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.07522 seconds
  • Memory Usage 2,329KB
  • Queries Executed 25 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (13)bbcode_code
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete