diff -c -rNbB attach_mod_v236/admin/admin_attach_cp.php attach_mod_v237/admin/admin_attach_cp.php
*** attach_mod_v236/admin/admin_attach_cp.php	Sun Mar  9 03:35:17 2003
--- attach_mod_v237/admin/admin_attach_cp.php	Sun Mar  9 03:35:18 2003
***************
*** 6,12 ****
   *	copyright			: (C) 2002 Meik Sievertsen
   *	email				: acyd.burn@gmx.de
   *
!  *	$Id: admin_attach_cp.php,v 1.14 2003/01/15 23:24:26 acydburn Exp $
   *
   ***************************************************************************/
  
--- 6,12 ----
   *	copyright			: (C) 2002 Meik Sievertsen
   *	email				: acyd.burn@gmx.de
   *
!  *	$Id: admin_attach_cp.php,v 1.16 2003/03/07 17:48:23 acydburn Exp $
   *
   ***************************************************************************/
  
***************
*** 35,40 ****
--- 35,61 ----
  require($phpbb_root_path . 'extension.inc');
  require('pagestart.' . $phpEx);
  
+ @include_once($phpbb_root_path . 'attach_mod/includes/constants.'.$phpEx);
+ 
+ if (!intval($attach_config['allow_ftp_upload']))
+ {
+ 	if ( ($attach_config['upload_dir'][0] == '/') || ( ($attach_config['upload_dir'][0] != '/') && ($attach_config['upload_dir'][1] == ':') ) )
+ 	{
+ 		$upload_dir = $attach_config['upload_dir'];
+ 	}
+ 	else
+ 	{
+ 		$upload_dir = '../' . $attach_config['upload_dir'];
+ 	}
+ }
+ else
+ {
+ 	$upload_dir = $attach_config['download_path'];
+ }
+ 
+ include($phpbb_root_path . 'attach_mod/includes/functions_selects.' . $phpEx);
+ include($phpbb_root_path . 'attach_mod/includes/functions_admin.' . $phpEx);
+ 
  //
  // Init Variables
  //
diff -c -rNbB attach_mod_v236/admin/admin_attachments.php attach_mod_v237/admin/admin_attachments.php
*** attach_mod_v236/admin/admin_attachments.php	Sun Mar  9 03:35:17 2003
--- attach_mod_v237/admin/admin_attachments.php	Sun Mar  9 03:35:18 2003
***************
*** 6,12 ****
   *   copyright            : (C) 2002 Meik Sievertsen
   *   email                : acyd.burn@gmx.de
   *
!  *   $Id: admin_attachments.php,v 1.40 2003/01/15 23:24:26 acydburn Exp $
   *
   ***************************************************************************/
  
--- 6,12 ----
   *   copyright            : (C) 2002 Meik Sievertsen
   *   email                : acyd.burn@gmx.de
   *
!  *   $Id: admin_attachments.php,v 1.43 2003/03/07 17:48:23 acydburn Exp $
   *
   ***************************************************************************/
  
***************
*** 39,46 ****
--- 39,66 ----
  require($phpbb_root_path . 'extension.inc');
  require('pagestart.' . $phpEx);
  
+ @include_once($phpbb_root_path . 'attach_mod/includes/constants.'.$phpEx);
  include($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
  
+ if (!intval($attach_config['allow_ftp_upload']))
+ {
+ 	if ( ($attach_config['upload_dir'][0] == '/') || ( ($attach_config['upload_dir'][0] != '/') && ($attach_config['upload_dir'][1] == ':') ) )
+ 	{
+ 		$upload_dir = $attach_config['upload_dir'];
+ 	}
+ 	else
+ 	{
+ 		$upload_dir = '../' . $attach_config['upload_dir'];
+ 	}
+ }
+ else
+ {
+ 	$upload_dir = $attach_config['download_path'];
+ }
+ 
+ include($phpbb_root_path . 'attach_mod/includes/functions_selects.' . $phpEx);
+ include($phpbb_root_path . 'attach_mod/includes/functions_admin.' . $phpEx);
+ 
  //
  // Init Vars
  //
***************
*** 1092,1097 ****
--- 1112,1143 ----
  	}
  
  	print_r('<br /><br />');
+ 	print_r('Sync Posts');
+ 	
+ 	// Reassign Attachments to the Poster ID
+ 	$sql = "SELECT a.attach_id, a.post_id, a.user_id_1, p.poster_id FROM " . ATTACHMENTS_TABLE . " a, " . POSTS_TABLE . " p 
+ 	WHERE a.user_id_2 = 0 AND p.post_id = a.post_id AND a.user_id_1 <> p.poster_id";
+ 
+ 	if ( !($result = $db->sql_query($sql)) )
+ 	{
+ 		message_die(GENERAL_ERROR, 'Could not get post ID', '', __LINE__, __FILE__, $sql);
+ 	}
+ 
+ 	print_r('<br />');
+ 
+ 	$rows = $db->sql_fetchrowset($result);
+ 	$num_rows = $db->sql_numrows($result);
+ 
+ 	for ($i = 0; $i < $num_rows; $i++)
+ 	{
+ 		$sql = "UPDATE " . ATTACHMENTS_TABLE . " SET user_id_1 = " . intval($rows[$i]['poster_id']) . " WHERE attach_id = " . intval($rows[$i]['attach_id']) . " AND post_id = " . intval($rows[$i]['post_id']);
+ 
+ 		$db->sql_query($sql);
+ 
+ 		print_r('.');
+ 	}
+ 
+ 	print_r('<br /><br />');
  	print_r('Sync Thumbnails');
  	
  	// Sync Thumbnails (if a thumbnail is no longer there, delete it)
diff -c -rNbB attach_mod_v236/admin/admin_extensions.php attach_mod_v237/admin/admin_extensions.php
*** attach_mod_v236/admin/admin_extensions.php	Sun Mar  9 03:35:17 2003
--- attach_mod_v237/admin/admin_extensions.php	Sun Mar  9 03:35:18 2003
***************
*** 6,12 ****
   *   copyright            : (C) 2002 Meik Sievertsen
   *   email                : acyd.burn@gmx.de
   *
!  *   $Id: admin_extensions.php,v 1.19 2003/01/26 12:23:20 acydburn Exp $
   *
   ***************************************************************************/
  
--- 6,12 ----
   *   copyright            : (C) 2002 Meik Sievertsen
   *   email                : acyd.burn@gmx.de
   *
!  *   $Id: admin_extensions.php,v 1.21 2003/03/07 17:48:23 acydburn Exp $
   *
   ***************************************************************************/
  
***************
*** 37,42 ****
--- 37,63 ----
  require($phpbb_root_path . 'extension.inc');
  require('pagestart.' . $phpEx);
  
+ @include_once($phpbb_root_path . 'attach_mod/includes/constants.'.$phpEx);
+ 
+ if (!intval($attach_config['allow_ftp_upload']))
+ {
+ 	if ( ($attach_config['upload_dir'][0] == '/') || ( ($attach_config['upload_dir'][0] != '/') && ($attach_config['upload_dir'][1] == ':') ) )
+ 	{
+ 		$upload_dir = $attach_config['upload_dir'];
+ 	}
+ 	else
+ 	{
+ 		$upload_dir = '../' . $attach_config['upload_dir'];
+ 	}
+ }
+ else
+ {
+ 	$upload_dir = $attach_config['download_path'];
+ }
+ 
+ include($phpbb_root_path . 'attach_mod/includes/functions_selects.' . $phpEx);
+ include($phpbb_root_path . 'attach_mod/includes/functions_admin.' . $phpEx);
+ 
  //
  // Init Vars
  //
diff -c -rNbB attach_mod_v236/attach_mod/attachment_mod.php attach_mod_v237/attach_mod/attachment_mod.php
*** attach_mod_v236/attach_mod/attachment_mod.php	Sun Mar  9 03:35:17 2003
--- attach_mod_v237/attach_mod/attachment_mod.php	Sun Mar  9 03:35:18 2003
***************
*** 6,12 ****
   *   copyright            : (C) 2002 Meik Sievertsen
   *   email                : acyd.burn@gmx.de
   *
!  *   $Id: attachment_mod.php,v 1.17 2003/01/15 23:24:26 acydburn Exp $
   *
   *
   ***************************************************************************/
--- 6,12 ----
   *   copyright            : (C) 2002 Meik Sievertsen
   *   email                : acyd.burn@gmx.de
   *
!  *   $Id: attachment_mod.php,v 1.18 2003/02/23 20:38:36 acydburn Exp $
   *
   *
   ***************************************************************************/
***************
*** 133,169 ****
  // PM Attachments Class
  include($phpbb_root_path . 'attach_mod/pm_attachments.'.$phpEx);
  
! if ( defined('IN_ADMIN') )
  {
- 	if (!intval($attach_config['allow_ftp_upload']))
- 	{
- 		if ( ($attach_config['upload_dir'][0] == '/') || ( ($attach_config['upload_dir'][0] != '/') && ($attach_config['upload_dir'][1] == ':') ) )
- 		{
  			$upload_dir = $attach_config['upload_dir'];
- 		}
- 		else
- 		{
- 			$upload_dir = '../' . $attach_config['upload_dir'];
- 		}
- 	}
- 	else
- 	{
- 		$upload_dir = $attach_config['download_path'];
- 	}
- 
- 	include($phpbb_root_path . 'attach_mod/includes/functions_selects.' . $phpEx);
- 	include($phpbb_root_path . 'attach_mod/includes/functions_admin.' . $phpEx);
  }
  else
  {
- 	if (!intval($attach_config['allow_ftp_upload']))
- 	{
- 		$upload_dir = $attach_config['upload_dir'];
- 	}
- 	else
- 	{
  		$upload_dir = $attach_config['download_path'];
- 	}
  }
  
  ?>
\ No newline at end of file
--- 133,145 ----
  // PM Attachments Class
  include($phpbb_root_path . 'attach_mod/pm_attachments.'.$phpEx);
  
! if (!intval($attach_config['allow_ftp_upload']))
  {
  	$upload_dir = $attach_config['upload_dir'];
  }
  else
  {
  	$upload_dir = $attach_config['download_path'];
  }
  
  ?>
\ No newline at end of file
diff -c -rNbB attach_mod_v236/attach_mod/displaying.php attach_mod_v237/attach_mod/displaying.php
*** attach_mod_v236/attach_mod/displaying.php	Sun Mar  9 03:35:17 2003
--- attach_mod_v237/attach_mod/displaying.php	Sun Mar  9 03:35:18 2003
***************
*** 6,12 ****
   *   copyright            : (C) 2002 Meik Sievertsen
   *   email                : acyd.burn@gmx.de
   *
!  *   $Id: displaying.php,v 1.43 2003/02/01 03:07:24 acydburn Exp $
   *
   *
   ***************************************************************************/
--- 6,12 ----
   *   copyright            : (C) 2002 Meik Sievertsen
   *   email                : acyd.burn@gmx.de
   *
!  *   $Id: displaying.php,v 1.44 2003/03/06 23:30:52 acydburn Exp $
   *
   *
   ***************************************************************************/
***************
*** 802,808 ****
  	
  					if ( !(attach_sql_query($sql)) )
  					{
! 						message_die(GENERAL_MESSAGE, 'Couldn\'t update attachment download count.', '', __LINE__, __FILE__, $sql);
  					}
  				}
  			}
--- 802,808 ----
  	
  					if ( !(attach_sql_query($sql)) )
  					{
! 						message_die(GENERAL_ERROR, 'Couldn\'t update attachment download count.', '', __LINE__, __FILE__, $sql);
  					}
  				}
  			}
***************
*** 865,871 ****
  	
  				if ( !(attach_sql_query($sql)) )
  				{
! 					message_die(GENERAL_MESSAGE, 'Couldn\'t update attachment download count', '', __LINE__, __FILE__, $sql);
  				}
  			}
  			
--- 865,871 ----
  	
  				if ( !(attach_sql_query($sql)) )
  				{
! 					message_die(GENERAL_ERROR, 'Couldn\'t update attachment download count', '', __LINE__, __FILE__, $sql);
  				}
  			}
  			
***************
*** 899,905 ****
  	
  				if ( !(attach_sql_query($sql)) )
  				{
! 					message_die(GENERAL_MESSAGE, 'Couldn\'t update attachment download count', '', __LINE__, __FILE__, $sql);
  				}
  			}
  
--- 899,905 ----
  	
  				if ( !(attach_sql_query($sql)) )
  				{
! 					message_die(GENERAL_ERROR, 'Couldn\'t update attachment download count', '', __LINE__, __FILE__, $sql);
  				}
  			}
  
diff -c -rNbB attach_mod_v236/attach_mod/includes/constants.php attach_mod_v237/attach_mod/includes/constants.php
*** attach_mod_v236/attach_mod/includes/constants.php	Sun Mar  9 03:35:17 2003
--- attach_mod_v237/attach_mod/includes/constants.php	Sun Mar  9 03:35:18 2003
***************
*** 6,12 ****
   *   copyright            : (C) 2002 Meik Sievertsen
   *   email                : acyd.burn@gmx.de
   *
!  *   $Id: constants.php,v 1.21 2003/01/29 13:26:50 acydburn Exp $
   *
   *
   ***************************************************************************/
--- 6,12 ----
   *   copyright            : (C) 2002 Meik Sievertsen
   *   email                : acyd.burn@gmx.de
   *
!  *   $Id: constants.php,v 1.22 2003/03/05 18:01:10 acydburn Exp $
   *
   *
   ***************************************************************************/
***************
*** 72,77 ****
  define('QUOTA_UPLOAD_LIMIT', 1);
  define('QUOTA_PM_LIMIT', 2);
  
! define('ATTACH_VERSION', '2.3.6');
  
  ?>
\ No newline at end of file
--- 72,77 ----
  define('QUOTA_UPLOAD_LIMIT', 1);
  define('QUOTA_PM_LIMIT', 2);
  
! define('ATTACH_VERSION', '2.3.7');
  
  ?>
\ No newline at end of file
diff -c -rNbB attach_mod_v236/attach_mod/includes/functions_delete.php attach_mod_v237/attach_mod/includes/functions_delete.php
*** attach_mod_v236/attach_mod/includes/functions_delete.php	Sun Mar  9 03:35:17 2003
--- attach_mod_v237/attach_mod/includes/functions_delete.php	Sun Mar  9 03:35:18 2003
***************
*** 6,12 ****
   *   copyright            : (C) 2002 Meik Sievertsen
   *   email                : acyd.burn@gmx.de
   *
!  *   $Id: functions_delete.php,v 1.9 2003/01/22 11:25:49 acydburn Exp $
   *
   *
   ***************************************************************************/
--- 6,12 ----
   *   copyright            : (C) 2002 Meik Sievertsen
   *   email                : acyd.burn@gmx.de
   *
!  *   $Id: functions_delete.php,v 1.10 2003/02/23 13:15:29 acydburn Exp $
   *
   *
   ***************************************************************************/
***************
*** 28,34 ****
  //
  // Delete Attachment(s) from post(s) (intern)
  //
! function delete_attachment($post_id_array = -1, $attach_id_array = -1, $page = -1)
  {
  	global $db;
  
--- 28,34 ----
  //
  // Delete Attachment(s) from post(s) (intern)
  //
! function delete_attachment($post_id_array = -1, $attach_id_array = -1, $page = -1, $user_id = -1)
  {
  	global $db;
  
***************
*** 188,193 ****
--- 188,246 ----
  	if ($page == PAGE_PRIVMSGS)
  	{
  		$sql_id = 'privmsgs_id';
+ 		if ($user_id != -1)
+ 		{
+ 			$post_id_array_2 = array();
+ 
+ 			for ($i = 0; $i < count($post_id_array); $i++)
+ 			{
+ 				$sql = "SELECT privmsgs_type, privmsgs_to_userid, privmsgs_from_userid
+ 				FROM " . PRIVMSGS_TABLE . "
+ 				WHERE privmsgs_id = " . $post_id_array[$i];
+ 
+ 				if ( !($result = attach_sql_query($sql)) )
+ 				{
+ 					message_die(GENERAL_ERROR, 'Couldn\'t get Privmsgs Type', '', __LINE__, __FILE__, $sql);
+ 				}
+ 
+ 				if ($db->sql_numrows($result) != 0)
+ 				{
+ 					$row = $db->sql_fetchrow($result);
+ 					$privmsgs_type = $row['privmsgs_type'];
+ 								
+ 					if (($privmsgs_type == PRIVMSGS_READ_MAIL) || ($privmsgs_type == PRIVMSGS_NEW_MAIL) || ($privmsgs_type == PRIVMSGS_UNREAD_MAIL))
+ 					{
+ 						if ($row['privmsgs_to_userid'] == $user_id)
+ 						{
+ 							$post_id_array_2[] = $post_id_array[$i];
+ 						}
+ 					}
+ 					else if ($privmsgs_type == PRIVMSGS_SENT_MAIL)
+ 					{
+ 						if ($row['privmsgs_from_userid'] == $user_id)
+ 						{
+ 							$post_id_array_2[] = $post_id_array[$i];
+ 						}
+ 					}
+ 					else if ( ($privmsgs_type == PRIVMSGS_SAVED_OUT_MAIL) )
+ 					{
+ 						if ($row['privmsgs_from_userid'] == $user_id)
+ 						{
+ 							$post_id_array_2[] = $post_id_array[$i];
+ 						}
+ 					}
+ 					else if ( ($privmsgs_type == PRIVMSGS_SAVED_IN_MAIL) )
+ 					{
+ 						if ($row['privmsgs_to_userid'] == $user_id)
+ 						{
+ 							$post_id_array_2[] = $post_id_array[$i];
+ 						}
+ 					}
+ 				}
+ 			}
+ 
+ 			$post_id_array = $post_id_array_2;
+ 		}
  	}
  	else
  	{
diff -c -rNbB attach_mod_v236/attach_mod/includes/functions_thumbs.php attach_mod_v237/attach_mod/includes/functions_thumbs.php
*** attach_mod_v236/attach_mod/includes/functions_thumbs.php	Sun Mar  9 03:35:17 2003
--- attach_mod_v237/attach_mod/includes/functions_thumbs.php	Sun Mar  9 03:35:18 2003
***************
*** 6,12 ****
   *   copyright            : (C) 2002 Meik Sievertsen
   *   email                : acyd.burn@gmx.de
   *
!  *   $Id: functions_thumbs.php,v 1.21 2003/01/15 23:24:26 acydburn Exp $
   *
   *
   ***************************************************************************/
--- 6,12 ----
   *   copyright            : (C) 2002 Meik Sievertsen
   *   email                : acyd.burn@gmx.de
   *
!  *   $Id: functions_thumbs.php,v 1.22 2003/02/23 11:36:25 acydburn Exp $
   *
   *
   ***************************************************************************/
***************
*** 124,135 ****
  {
  	global $attach_config, $imagick;
  
  	$min_filesize = intval($attach_config['img_min_thumb_filesize']);
  
  	$img_filesize = (@file_exists(@amod_realpath($source))) ? filesize($source) : false;
  
- 	$destination = trim($destination);
- 
  	if (!$img_filesize || $img_filesize <= $min_filesize) 
  	{
  		return (FALSE);
--- 124,135 ----
  {
  	global $attach_config, $imagick;
  
+ 	$source = amod_realpath($source);
+ 	
  	$min_filesize = intval($attach_config['img_min_thumb_filesize']);
  
  	$img_filesize = (@file_exists(@amod_realpath($source))) ? filesize($source) : false;
  
  	if (!$img_filesize || $img_filesize <= $min_filesize) 
  	{
  		return (FALSE);
***************
*** 170,183 ****
  		$new_file = trim($value) . '/t00000';
  	}
  	
  	if (is_imagick()) 
  	{
  		if (is_array($size) && count($size) > 0) 
  		{
! 			@exec($imagick . ' -quality 90 -antialias -sample ' . $new_size[0] . 'x' . $new_size[1] . ' ' . $source . ' ' . $new_file);
  		}
  	} 
! 	else 
  	{
  		$type = $size[2];
  		$supported_types = get_supported_image_types();
--- 170,190 ----
  		$new_file = trim($value) . '/t00000';
  	}
  	
+ 	$used_imagick = FALSE;
+ 
  	if (is_imagick()) 
  	{
  		if (is_array($size) && count($size) > 0) 
  		{
! 			@exec($imagick . ' -quality 75 -antialias -sample ' . $new_size[0] . 'x' . $new_size[1] . ' ' . $source . ' ' . $new_file);
! 			if (@file_exists(@amod_realpath($new_file)))
! 			{
! 				$used_imagick = TRUE;
  			}
  		}
! 	} 
! 
! 	if (!$used_imagick) 
  	{
  		$type = $size[2];
  		$supported_types = get_supported_image_types();
diff -c -rNbB attach_mod_v236/attach_mod/posting_attachments.php attach_mod_v237/attach_mod/posting_attachments.php
*** attach_mod_v236/attach_mod/posting_attachments.php	Sun Mar  9 03:35:17 2003
--- attach_mod_v237/attach_mod/posting_attachments.php	Sun Mar  9 03:35:18 2003
***************
*** 6,12 ****
   *   copyright            : (C) 2002 Meik Sievertsen
   *   email                : acyd.burn@gmx.de
   *
!  *   $Id: posting_attachments.php,v 1.54 2003/01/29 11:43:57 acydburn Exp $
   *
   *
   ***************************************************************************/
--- 6,12 ----
   *   copyright            : (C) 2002 Meik Sievertsen
   *   email                : acyd.burn@gmx.de
   *
!  *   $Id: posting_attachments.php,v 1.56 2003/02/27 14:04:02 acydburn Exp $
   *
   *
   ***************************************************************************/
***************
*** 701,707 ****
  	//
  	function do_insert_attachment($mode, $message_type, $message_id)
  	{
! 		global $db;
  
  		if (intval($message_id) < 0)
  		{
--- 701,707 ----
  	//
  	function do_insert_attachment($mode, $message_type, $message_id)
  	{
! 		global $db, $upload_dir;
  
  		if (intval($message_id) < 0)
  		{
***************
*** 719,730 ****
  		}
  		else if ($message_type = 'post')
  		{
! 			global $userdata;
  		
  			$post_id = $message_id;
  			$privmsgs_id = 0;
! 			$user_id_1 = $userdata['user_id'];
  			$user_id_2 = 0;
  		}
  
  		if ($mode == 'attach_list')
--- 719,735 ----
  		}
  		else if ($message_type = 'post')
  		{
! 			global $post_info, $userdata;
  
  			$post_id = $message_id;
  			$privmsgs_id = 0;
! 			$user_id_1 = $post_info['poster_id'];
  			$user_id_2 = 0;
+ 
+ 			if (!$user_id_1)
+ 			{
+ 				$user_id_1 = $userdata['user_id'];
+ 			}
  		}
  
  		if ($mode == 'attach_list')
***************
*** 1295,1302 ****
  				$this->filename = stripslashes($r_file);
  
  				$this->attach_filename = strtolower($this->filename);
- 				$this->attach_filename = str_replace(' ', '_', $this->attach_filename);
  				
  				$this->attach_filename = rawurlencode($this->attach_filename);
  				$this->attach_filename = preg_replace("/%(\w{2})/", "_", $this->attach_filename);
  
--- 1300,1312 ----
  				$this->filename = stripslashes($r_file);
  
  				$this->attach_filename = strtolower($this->filename);
  				
+ 				// To re-add cryptic filenames, change this variable to true
+ 				$cryptic = false;
+ 
+ 				if (!$cryptic)
+ 				{
+ 					$this->attach_filename = str_replace(' ', '_', $this->attach_filename);
  					$this->attach_filename = rawurlencode($this->attach_filename);
  					$this->attach_filename = preg_replace("/%(\w{2})/", "_", $this->attach_filename);
  
***************
*** 1305,1313 ****
--- 1315,1330 ----
  						$this->attach_filename = delete_extension($this->attach_filename);
  						$this->attach_filename = $this->attach_filename . '_' . substr(rand(), 0, 3) . '.' . $this->extension;
  					}
+ 				}
+ 				else
+ 				{
+ 					$u_id = (intval($userdata['user_id']) == ANONYMOUS) ? 0 : intval($userdata['user_id']);
+ 					$this->attach_filename = $u_id . '_' . $this->filetime . '.' . $this->extension;
+ 				}
  				
  				$this->filename = str_replace("'", "\'", $this->filename);
  
+ 				
  				//
  				// Do we have to create a thumbnail ?
  				//
***************
*** 1480,1486 ****
  			else
  			{
  				$source = $upload_dir . '/' . $this->attach_filename;
! 				$dest_file = $upload_dir . '/' . THUMB_DIR . '/t_' . $this->attach_filename;
  			}
  
  			if (!create_thumbnail($source, $dest_file, $this->type))
--- 1497,1504 ----
  			else
  			{
  				$source = $upload_dir . '/' . $this->attach_filename;
! 				$dest_file = amod_realpath($upload_dir);
! 				$dest_file .= '/' . THUMB_DIR . '/t_' . $this->attach_filename;
  			}
  
  			if (!create_thumbnail($source, $dest_file, $this->type))
diff -c -rNbB attach_mod_v236/download.php attach_mod_v237/download.php
*** attach_mod_v236/download.php	Sun Mar  9 03:35:18 2003
--- attach_mod_v237/download.php	Sun Mar  9 03:35:18 2003
***************
*** 6,12 ****
   *   copyright            : (C) 2002 Meik Sievertsen
   *   email                : acyd.burn@gmx.de
   *
!  *   $Id: download.php,v 1.30 2003/02/02 18:34:45 acydburn Exp $
   *
   *
   ***************************************************************************/
--- 6,12 ----
   *   copyright            : (C) 2002 Meik Sievertsen
   *   email                : acyd.burn@gmx.de
   *
!  *   $Id: download.php,v 1.33 2003/03/05 18:01:11 acydburn Exp $
   *
   *
   ***************************************************************************/
***************
*** 31,36 ****
--- 31,105 ----
  include($phpbb_root_path . 'extension.inc');
  include($phpbb_root_path . 'common.'.$phpEx);
  
+ //
+ // Delete the / * to uncomment the block, and edit the values (read the comments) to
+ // enable additional security to your board (preventing third site linkage)
+ //
+ /*
+ define('ALLOWED_DENIED', 0);
+ define('DENIED_ALLOWED', 1);
+ 
+ //
+ // From this line on you are able to edit the stuff
+ //
+ 
+ // Possible Values:
+ // ALLOWED_DENIED <- First allow the listed sites, and then deny all others
+ // DENIED_ALLOWED <- First deny the listed sites, and then allow all others
+ $allow_deny_order = ALLOWED_DENIED;
+ 
+ //
+ // Allowed Syntax:
+ // Full Domain Name -> www.opentools.de
+ // Partial Domain Names -> opentools.de
+ //
+ $sites = array(
+ 	$board_config['server_name'],	// This is your domain
+ 	'opentools.de',
+ 	'phpbb.com',
+ 	'phpbbhacks.com',
+ 	'phpbb.de'
+ );
+ 
+ // This is the message displayed, if someone links to this site...
+ $lang['Denied_Message'] = 'You are not authorized to view, download or link to this Site.';
+ 
+ // End of editable area
+ 
+ //
+ // Parse the order and evaluate the array
+ //
+ 
+ $site = explode('?', $HTTP_SERVER_VARS['HTTP_REFERER']);
+ $url = trim($site[0]);
+ //$url = $HTTP_HOST;
+ 
+ if ($url != '')
+ {
+ 	$allowed = ($allow_deny_order == ALLOWED_DENIED) ? FALSE : TRUE;
+ 	
+ 	for ($i = 0; $i < count($sites); $i++)
+ 	{
+ 		if (strstr($url, $sites[$i]))
+ 		{
+ 			$allowed = ($allow_deny_order == ALLOWED_DENIED) ? TRUE : FALSE;
+ 			break;
+ 		}
+ 	}
+ }
+ else
+ {
+ 	$allowed = TRUE;
+ }
+ 
+ if ($allowed == FALSE)
+ {
+ 	message_die(GENERAL_MESSAGE, $lang['Denied_Message']);
+ }
+ 
+ // Delete the following line, to uncomment this block
+ */
+ 
  if( isset($HTTP_POST_VARS['id']) || isset($HTTP_GET_VARS['id']) )
  {
  	$download_id = ( isset($HTTP_POST_VARS['id']) ) ? intval($HTTP_POST_VARS['id']) : intval($HTTP_GET_VARS['id']);
***************
*** 147,152 ****
--- 216,226 ----
  		}
  	}
  
+ 	@ob_end_clean();
+ 	@ini_set('zlib.output_compression', 'Off');
+ 	header('Pragma: public');
+ 	header('Content-Transfer-Encoding: none');
+ 
  	//
  	// Send out the Headers
  	//
***************
*** 160,172 ****
  		header('Content-Type: ' . $mimetype . '; name="' . $real_filename . '"');
  		header('Content-Disposition: attachment; filename=' . $real_filename);
  	}
- 	header('Pragma: public');
  
  	//
  	// Now send the File Contents to the Browser
  	//
  	if ($gotit)
  	{
  		readfile($filename);
  	}
  	else if ((!$gotit) && (intval($attach_config['allow_ftp_upload'])))
--- 234,250 ----
  		header('Content-Type: ' . $mimetype . '; name="' . $real_filename . '"');
  		header('Content-Disposition: attachment; filename=' . $real_filename);
  	}
  
  	//
  	// Now send the File Contents to the Browser
  	//
  	if ($gotit)
  	{
+ 		$size = @filesize($filename);
+ 		if ($size)
+ 		{
+ 			header("Content-length: $size");
+ 		}
  		readfile($filename);
  	}
  	else if ((!$gotit) && (intval($attach_config['allow_ftp_upload'])))
***************
*** 195,200 ****
--- 273,283 ----
  	
  		@ftp_quit($conn_id);
  
+ 		$size = @filesize($tmp_filename);
+ 		if ($size)
+ 		{
+ 			header("Content-length: $size");
+ 		}
  		readfile($tmp_filename);
  		@unlink($tmp_filename);
  	}
***************
*** 203,209 ****
  		message_die(GENERAL_ERROR, $lang['Error_no_attachment'] . "<br /><br /><b>404 File Not Found:</b> The File <i>" . $filename . "</i> does not exist.");
  	}
  
! 	exit();
  }
  //
  // End Functions
--- 286,292 ----
  		message_die(GENERAL_ERROR, $lang['Error_no_attachment'] . "<br /><br /><b>404 File Not Found:</b> The File <i>" . $filename . "</i> does not exist.");
  	}
  
! 	exit;
  }
  //
  // End Functions
diff -c -rNbB attach_mod_v236/files/.htaccess attach_mod_v237/files/.htaccess
*** attach_mod_v236/files/.htaccess	Sun Mar  9 03:35:17 2003
--- attach_mod_v237/files/.htaccess	Thu Jan  1 01:00:00 1970
***************
*** 1,2 ****
- 
- Options -Includes -ExecCGI -Indexes
--- 0 ----
diff -c -rNbB attach_mod_v236/install/attach_update_23x_to_latest.php attach_mod_v237/install/attach_update_23x_to_latest.php
*** attach_mod_v236/install/attach_update_23x_to_latest.php	Sun Mar  9 03:35:18 2003
--- attach_mod_v237/install/attach_update_23x_to_latest.php	Sun Mar  9 03:35:18 2003
***************
*** 1,8 ****
  <?php
  
  //
! // Update File for updating Attachment Mod V2.3.x to V2.3.6
! // $Id: attach_update_23x_to_latest.php,v 1.9 2003/02/03 12:39:18 acydburn Exp $
  //
  
  error_reporting  (E_ERROR | E_WARNING | E_PARSE); // This will NOT report uninitialized variables
--- 1,8 ----
  <?php
  
  //
! // Update File for updating Attachment Mod V2.3.x to V2.3.7
! // $Id: attach_update_23x_to_latest.php,v 1.11 2003/03/05 18:01:12 acydburn Exp $
  //
  
  error_reporting  (E_ERROR | E_WARNING | E_PARSE); // This will NOT report uninitialized variables
***************
*** 51,57 ****
  
  if ( (!strstr($attach_version, '2.3.')) )
  {
! 	message_die(GENERAL_MESSAGE, 'Wrong Attachment Version detected.<br />Please update your Attachment Mod (V' . $attach_version . ') to at least Version 2.2.1 before you update to 2.3.6.');
  }
  
  $available_dbms = array(
--- 51,57 ----
  
  if ( (!strstr($attach_version, '2.3.')) )
  {
! 	message_die(GENERAL_MESSAGE, 'Wrong Attachment Version detected.<br />Please update your Attachment Mod (V' . $attach_version . ') to at least Version 2.2.1 before you update to 2.3.7.');
  }
  
  $available_dbms = array(
***************
*** 382,388 ****
  		<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
  			<tr>
  				<td><img src="./../templates/subSilver/images/logo_phpBB.gif" border="0" alt="Forum Home" vspace="1" /></td>
! 				<td align="center" width="100%" valign="middle"><span class="maintitle">Updating from Attachment Mod Version <? echo $attach_version; ?> to Version 2.3.6</span></td>
  			</tr>
  		</table></td>
  	</tr>
--- 382,388 ----
  		<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
  			<tr>
  				<td><img src="./../templates/subSilver/images/logo_phpBB.gif" border="0" alt="Forum Home" vspace="1" /></td>
! 				<td align="center" width="100%" valign="middle"><span class="maintitle">Updating from Attachment Mod Version <? echo $attach_version; ?> to Version 2.3.7</span></td>
  			</tr>
  		</table></td>
  	</tr>
***************
*** 400,411 ****
  insert_into_config('display_order', '0');
  insert_into_config('img_imagick', '');
  insert_into_config('show_apcp', '1');
! insert_into_config('attach_version', '2.3.6');
  insert_into_config('default_upload_quota', '0');
  insert_into_config('default_pm_quota', '0');
  insert_into_config('ftp_pasv_mode', '1');
  
! $sql = "UPDATE phpbb_attachments_config SET config_value = '2.3.6' WHERE config_name = 'attach_version';";
  $result = evaluate_statement($sql, TRUE, TRUE);
  
  if (($dbms == 'mysql') || ($dbms == 'mysql4'))
--- 400,411 ----
  insert_into_config('display_order', '0');
  insert_into_config('img_imagick', '');
  insert_into_config('show_apcp', '1');
! insert_into_config('attach_version', '2.3.7');
  insert_into_config('default_upload_quota', '0');
  insert_into_config('default_pm_quota', '0');
  insert_into_config('ftp_pasv_mode', '1');
  
! $sql = "UPDATE phpbb_attachments_config SET config_value = '2.3.7' WHERE config_name = 'attach_version';";
  $result = evaluate_statement($sql, TRUE, TRUE);
  
  if (($dbms == 'mysql') || ($dbms == 'mysql4'))
***************
*** 497,503 ****
  if ( ($dbms == "mysql") || ($dbms == "mysql4") )
  {
  	$sql_query = "ALTER TABLE phpbb_quota_limits CHANGE quota_limit quota_limit bigint(20) UNSIGNED DEFAULT '0' NOT NULL;"; 
! 	evaluate_statement($sql_query);
  }
  else if ( ($dbms == "mssql") || ($dbms == "mssql-odbc") )
  {
--- 497,503 ----
  if ( ($dbms == "mysql") || ($dbms == "mysql4") )
  {
  	$sql_query = "ALTER TABLE phpbb_quota_limits CHANGE quota_limit quota_limit bigint(20) UNSIGNED DEFAULT '0' NOT NULL;"; 
! 	evaluate_statement($sql_query, FALSE, TRUE);
  }
  else if ( ($dbms == "mssql") || ($dbms == "mssql-odbc") )
  {
diff -c -rNbB attach_mod_v236/install/mod_table_inst.php attach_mod_v237/install/mod_table_inst.php
*** attach_mod_v236/install/mod_table_inst.php	Sun Mar  9 03:35:18 2003
--- attach_mod_v237/install/mod_table_inst.php	Sun Mar  9 03:35:18 2003
***************
*** 6,12 ****
   *   copyright            : (C) 2002 Meik Sievertsen
   *   email                : acyd.burn@gmx.de
   *
!  *   $Id: mod_table_inst.php,v 1.4 2003/02/03 12:39:18 acydburn Exp $
   *
   ***************************************************************************/
  
--- 6,12 ----
   *   copyright            : (C) 2002 Meik Sievertsen
   *   email                : acyd.burn@gmx.de
   *
!  *   $Id: mod_table_inst.php,v 1.5 2003/03/05 18:01:16 acydburn Exp $
   *
   ***************************************************************************/
  
***************
*** 167,173 ****
  		<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
  			<tr>
  				<td><img src="./../templates/subSilver/images/logo_phpBB.gif" border="0" alt="Forum Home" vspace="1" /></td>
! 				<td align="center" width="100%" valign="middle"><span class="maintitle">Installing Attachment Mod Version 2.3.6</span></td>
  			</tr>
  		</table></td>
  	</tr>
--- 167,173 ----
  		<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
  			<tr>
  				<td><img src="./../templates/subSilver/images/logo_phpBB.gif" border="0" alt="Forum Home" vspace="1" /></td>
! 				<td align="center" width="100%" valign="middle"><span class="maintitle">Installing Attachment Mod Version 2.3.7</span></td>
  			</tr>
  		</table></td>
  	</tr>
diff -c -rNbB attach_mod_v236/install/schemas/attach_mssql_basic.sql attach_mod_v237/install/schemas/attach_mssql_basic.sql
*** attach_mod_v236/install/schemas/attach_mssql_basic.sql	Sun Mar  9 03:35:17 2003
--- attach_mod_v237/install/schemas/attach_mssql_basic.sql	Sun Mar  9 03:35:18 2003
***************
*** 1,7 ****
  /*
    Basic DB data for Attachment Mod - mssql
  
!   $Id: attach_mssql_basic.sql,v 1.5 2003/01/29 12:50:46 acydburn Exp $
  
  */
  
--- 1,7 ----
  /*
    Basic DB data for Attachment Mod - mssql
  
!   $Id: attach_mssql_basic.sql,v 1.6 2003/03/05 18:01:17 acydburn Exp $
  
  */
  
***************
*** 25,31 ****
  INSERT INTO phpbb_attachments_config (config_name, config_value) VALUES ('attachment_topic_review','0');
  INSERT INTO phpbb_attachments_config (config_name, config_value) VALUES ('allow_ftp_upload','0');
  INSERT INTO phpbb_attachments_config (config_name, config_value) VALUES ('show_apcp','1');
! INSERT INTO phpbb_attachments_config (config_name, config_value) VALUES ('attach_version','2.3.6');
  INSERT INTO phpbb_attachments_config (config_name, config_value) VALUES ('default_upload_quota', '0');
  INSERT INTO phpbb_attachments_config (config_name, config_value) VALUES ('default_pm_quota', '0');
  
--- 25,31 ----
  INSERT INTO phpbb_attachments_config (config_name, config_value) VALUES ('attachment_topic_review','0');
  INSERT INTO phpbb_attachments_config (config_name, config_value) VALUES ('allow_ftp_upload','0');
  INSERT INTO phpbb_attachments_config (config_name, config_value) VALUES ('show_apcp','1');
! INSERT INTO phpbb_attachments_config (config_name, config_value) VALUES ('attach_version','2.3.7');
  INSERT INTO phpbb_attachments_config (config_name, config_value) VALUES ('default_upload_quota', '0');
  INSERT INTO phpbb_attachments_config (config_name, config_value) VALUES ('default_pm_quota', '0');
  
diff -c -rNbB attach_mod_v236/install/schemas/attach_mysql_basic.sql attach_mod_v237/install/schemas/attach_mysql_basic.sql
*** attach_mod_v236/install/schemas/attach_mysql_basic.sql	Sun Mar  9 03:35:18 2003
--- attach_mod_v237/install/schemas/attach_mysql_basic.sql	Sun Mar  9 03:35:18 2003
***************
*** 1,7 ****
  #
  # Basic DB data for Attachment Mod
  #
! # $Id: attach_mysql_basic.sql,v 1.4 2003/01/29 12:50:46 acydburn Exp $
  # 
  
  # -- attachments_config
--- 1,7 ----
  #
  # Basic DB data for Attachment Mod
  #
! # $Id: attach_mysql_basic.sql,v 1.5 2003/03/05 18:01:19 acydburn Exp $
  # 
  
  # -- attachments_config
***************
*** 22,28 ****
  INSERT INTO phpbb_attachments_config (config_name, config_value) VALUES ('attachment_topic_review','0');
  INSERT INTO phpbb_attachments_config (config_name, config_value) VALUES ('allow_ftp_upload','0');
  INSERT INTO phpbb_attachments_config (config_name, config_value) VALUES ('show_apcp','1');
! INSERT INTO phpbb_attachments_config (config_name, config_value) VALUES ('attach_version','2.3.6');
  INSERT INTO phpbb_attachments_config (config_name, config_value) VALUES ('default_upload_quota', '0');
  INSERT INTO phpbb_attachments_config (config_name, config_value) VALUES ('default_pm_quota', '0');
  
--- 22,28 ----
  INSERT INTO phpbb_attachments_config (config_name, config_value) VALUES ('attachment_topic_review','0');
  INSERT INTO phpbb_attachments_config (config_name, config_value) VALUES ('allow_ftp_upload','0');
  INSERT INTO phpbb_attachments_config (config_name, config_value) VALUES ('show_apcp','1');
! INSERT INTO phpbb_attachments_config (config_name, config_value) VALUES ('attach_version','2.3.7');
  INSERT INTO phpbb_attachments_config (config_name, config_value) VALUES ('default_upload_quota', '0');
  INSERT INTO phpbb_attachments_config (config_name, config_value) VALUES ('default_pm_quota', '0');
  
diff -c -rNbB attach_mod_v236/install/schemas/attach_postgres_basic.sql attach_mod_v237/install/schemas/attach_postgres_basic.sql
*** attach_mod_v236/install/schemas/attach_postgres_basic.sql	Sun Mar  9 03:35:17 2003
--- attach_mod_v237/install/schemas/attach_postgres_basic.sql	Sun Mar  9 03:35:18 2003
***************
*** 1,7 ****
  /*
    Basic DB Data for Attachment Mod - Postgresql
   
!   $Id: attach_postgres_basic.sql,v 1.5 2003/01/29 12:50:46 acydburn Exp $
  
  */
  
--- 1,7 ----
  /*
    Basic DB Data for Attachment Mod - Postgresql
   
!   $Id: attach_postgres_basic.sql,v 1.6 2003/03/05 18:01:24 acydburn Exp $
  
  */
  
***************
*** 23,29 ****
  INSERT INTO phpbb_attachments_config (config_name, config_value) VALUES ('attachment_topic_review','0');
  INSERT INTO phpbb_attachments_config (config_name, config_value) VALUES ('allow_ftp_upload','0');
  INSERT INTO phpbb_attachments_config (config_name, config_value) VALUES ('show_apcp','1');
! INSERT INTO phpbb_attachments_config (config_name, config_value) VALUES ('attach_version','2.3.6');
  INSERT INTO phpbb_attachments_config (config_name, config_value) VALUES ('default_upload_quota', '0');
  INSERT INTO phpbb_attachments_config (config_name, config_value) VALUES ('default_pm_quota', '0');
  
--- 23,29 ----
  INSERT INTO phpbb_attachments_config (config_name, config_value) VALUES ('attachment_topic_review','0');
  INSERT INTO phpbb_attachments_config (config_name, config_value) VALUES ('allow_ftp_upload','0');
  INSERT INTO phpbb_attachments_config (config_name, config_value) VALUES ('show_apcp','1');
! INSERT INTO phpbb_attachments_config (config_name, config_value) VALUES ('attach_version','2.3.7');
  INSERT INTO phpbb_attachments_config (config_name, config_value) VALUES ('default_upload_quota', '0');
  INSERT INTO phpbb_attachments_config (config_name, config_value) VALUES ('default_pm_quota', '0');
  
diff -c -rNbB attach_mod_v236/install/schemas/attach_postgres_schema.sql attach_mod_v237/install/schemas/attach_postgres_schema.sql
*** attach_mod_v236/install/schemas/attach_postgres_schema.sql	Sun Mar  9 03:35:18 2003
--- attach_mod_v237/install/schemas/attach_postgres_schema.sql	Sun Mar  9 03:35:18 2003
***************
*** 1,7 ****
  /*
    phpBB2 - attach_mod schema - Postgresql
  
!   $Id: attach_postgres_schema.sql,v 1.2 2003/01/29 11:43:58 acydburn Exp $
  
  */
  
--- 1,7 ----
  /*
    phpBB2 - attach_mod schema - Postgresql
  
!   $Id: attach_postgres_schema.sql,v 1.3 2003/03/09 02:21:03 acydburn Exp $
  
  */
  
***************
*** 13,19 ****
  CREATE SEQUENCE phpbb_forbidden_extensions_id_seq start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1;
  CREATE SEQUENCE phpbb_extension_groups_id_seq start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1;
  CREATE SEQUENCE phpbb_attachments_desc_id_seq start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1;
! CREATE SEQUENCE phpbb_quota_limits_quota_limit_id_seq start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1;
  
  /* --- Table structure for table 'phpbb_attachments_config' */
  CREATE TABLE phpbb_attachments_config (
--- 13,19 ----
  CREATE SEQUENCE phpbb_forbidden_extensions_id_seq start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1;
  CREATE SEQUENCE phpbb_extension_groups_id_seq start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1;
  CREATE SEQUENCE phpbb_attachments_desc_id_seq start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1;
! CREATE SEQUENCE phpbb_quota_limits_id_seq start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1;
  
  /* --- Table structure for table 'phpbb_attachments_config' */
  CREATE TABLE phpbb_attachments_config (
***************
*** 80,86 ****
  
  /* --- Table structure for table 'phpbb_quota_limits' */
  CREATE TABLE phpbb_quota_limits (
!   quota_limit_id int4 DEFAULT nextval('phpbb_quota_limits_quota_limit_id_seq'::text) NOT NULL,
    quota_desc varchar(20) DEFAULT '' NOT NULL,
    quota_limit int8 DEFAULT 0 NOT NULL,
    CONSTRAINT phpbb_quota_limits_pkey PRIMARY KEY (quota_limit_id)
--- 80,86 ----
  
  /* --- Table structure for table 'phpbb_quota_limits' */
  CREATE TABLE phpbb_quota_limits (
!   quota_limit_id int4 DEFAULT nextval('phpbb_quota_limits_id_seq'::text) NOT NULL,
    quota_desc varchar(20) DEFAULT '' NOT NULL,
    quota_limit int8 DEFAULT 0 NOT NULL,
    CONSTRAINT phpbb_quota_limits_pkey PRIMARY KEY (quota_limit_id)
diff -c -rNbB attach_mod_v236/uacp.php attach_mod_v237/uacp.php
*** attach_mod_v236/uacp.php	Sun Mar  9 03:35:17 2003
--- attach_mod_v237/uacp.php	Sun Mar  9 03:35:18 2003
***************
*** 6,12 ****
   *   copyright            : (C) 2002 Meik Sievertsen
   *   email                : acyd.burn@gmx.de
   *
!  *   $Id: uacp.php,v 1.10 2003/02/03 12:33:51 acydburn Exp $
   *
   *
   ***************************************************************************/
--- 6,12 ----
   *   copyright            : (C) 2002 Meik Sievertsen
   *   email                : acyd.burn@gmx.de
   *
!  *   $Id: uacp.php,v 1.11 2003/02/23 13:15:30 acydburn Exp $
   *
   *
   ***************************************************************************/
***************
*** 207,213 ****
  {
  	$attachments = array();
  
! 	delete_attachment(-1, $delete_id_list);
  }
  else if ( ($delete) && (count($delete_id_list)) > 0 )
  {
--- 207,231 ----
  {
  	$attachments = array();
  
! 	for ($i = 0; $i < count($delete_id_list); $i++)
! 	{
! 		$sql = "SELECT post_id FROM " . ATTACHMENTS_TABLE . " WHERE attach_id = " . $delete_id_list[$i];
! 		$result = $db->sql_query($sql);
! 		if ($result)
! 		{
! 			$row = $db->sql_fetchrow($result);
! 			if ($row['post_id'] != 0)
! 			{
! 				delete_attachment(-1, $delete_id_list[$i]);
! 			}
! 			else
! 			{
! 				delete_attachment(-1, $delete_id_list[$i], PAGE_PRIVMSGS, intval($profiledata['user_id']));
! 			}
! 		}
! 	}
! 	
! 
  }
  else if ( ($delete) && (count($delete_id_list)) > 0 )
  {
***************
*** 291,297 ****
  
  $sql = "SELECT attach_id 
  FROM " . ATTACHMENTS_TABLE . "
! WHERE user_id_1 = " . $profiledata['user_id'] . "
  GROUP BY attach_id";
  		
  if ( !($result = attach_sql_query($sql)) )
--- 309,315 ----
  
  $sql = "SELECT attach_id 
  FROM " . ATTACHMENTS_TABLE . "
! WHERE user_id_1 = " . $profiledata['user_id'] . " OR user_id_2 = " . $profiledata['user_id'] . "
  GROUP BY attach_id";
  		
  if ( !($result = attach_sql_query($sql)) )
***************
*** 334,350 ****
  {
  	for ($i = 0; $i < count($attachments); $i++)
  	{
- 		$delete_box = '<input type="checkbox" name="delete_id_list[]" value="' . $attachments[$i]['attach_id'] . '" />';
- 
- 		for ($j = 0; $j < count($delete_id_list); $j++)
- 		{
- 			if ($delete_id_list[$j] == $attachments[$i]['attach_id'])
- 			{
- 				$delete_box = '<input type="checkbox" name="delete_id_list[]" value="' . $attachments[$i]['attach_id'] . '" checked />';
- 				break;
- 			}
- 		}
- 
  		$row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
  		$row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
  
--- 352,357 ----
***************
*** 394,401 ****
  			}
  			else
  			{
! 				$desc = $lang['Private_Message'];
! 				$sql = "SELECT privmsgs_type
  				FROM " . PRIVMSGS_TABLE . "
  				WHERE privmsgs_id = " . $ids[$j]['privmsgs_id'];
  
--- 401,409 ----
  			}
  			else
  			{
! 				$desc = '';
! 
! 				$sql = "SELECT privmsgs_type, privmsgs_to_userid, privmsgs_from_userid
  				FROM " . PRIVMSGS_TABLE . "
  				WHERE privmsgs_id = " . $ids[$j]['privmsgs_id'];
  
***************
*** 404,428 ****
  					message_die(GENERAL_ERROR, 'Couldn\'t get Privmsgs Type', '', __LINE__, __FILE__, $sql);
  				}
  		
  				$row = $db->sql_fetchrow($result);
  				$privmsgs_type = $row['privmsgs_type'];
  								
  				if (($privmsgs_type == PRIVMSGS_READ_MAIL) || ($privmsgs_type == PRIVMSGS_NEW_MAIL) || ($privmsgs_type == PRIVMSGS_UNREAD_MAIL))
  				{
! 					$desc .= ' (' . $lang['Inbox'] . ')';
  				}
  				else if ($privmsgs_type == PRIVMSGS_SENT_MAIL)
  				{
! 					$desc .= ' (' . $lang['Sentbox'] . ')';
  				}
! 				else if ( ($privmsgs_type == PRIVMSGS_SAVED_IN_MAIL) || ($privmsgs_type == PRIVMSGS_SAVED_OUT_MAIL) )
  				{
! 					$desc .= ' (' . $lang['Savebox'] . ')';
  				}
  
  				$post_titles[] = $desc;
  			}
  		}
  
  		$post_titles = implode('<br />', $post_titles);
  
--- 412,472 ----
  					message_die(GENERAL_ERROR, 'Couldn\'t get Privmsgs Type', '', __LINE__, __FILE__, $sql);
  				}
  
+ 				if ($db->sql_numrows($result) != 0)
+ 				{
  					$row = $db->sql_fetchrow($result);
  					$privmsgs_type = $row['privmsgs_type'];
  								
  					if (($privmsgs_type == PRIVMSGS_READ_MAIL) || ($privmsgs_type == PRIVMSGS_NEW_MAIL) || ($privmsgs_type == PRIVMSGS_UNREAD_MAIL))
  					{
! 						if ($row['privmsgs_to_userid'] == $profiledata['user_id'])
! 						{
! 							$desc = $lang['Private_Message'] . ' (' . $lang['Inbox'] . ')';
! 						}
  					}
  					else if ($privmsgs_type == PRIVMSGS_SENT_MAIL)
  					{
! 						if ($row['privmsgs_from_userid'] == $profiledata['user_id'])
! 						{
! 							$desc = $lang['Private_Message'] . ' (' . $lang['Sentbox'] . ')';
  						}
! 					}
! 					else if ( ($privmsgs_type == PRIVMSGS_SAVED_OUT_MAIL) )
! 					{
! 						if ($row['privmsgs_from_userid'] == $profiledata['user_id'])
  						{
! 							$desc = $lang['Private_Message'] . ' (' . $lang['Savebox'] . ')';
! 						}
! 					}
! 					else if ( ($privmsgs_type == PRIVMSGS_SAVED_IN_MAIL) )
! 					{
! 						if ($row['privmsgs_to_userid'] == $profiledata['user_id'])
! 						{
! 							$desc = $lang['Private_Message'] . ' (' . $lang['Savebox'] . ')';
! 						}
  					}
  
+ 					if ($desc != '')
+ 					{
  						$post_titles[] = $desc;
  					}
  				}
+ 			}
+ 		}
+ 
+ 		// Iron out those Attachments assigned to us, but not more controlled by us. ;) (PM's)
+ 		if (count($post_titles) > 0)
+ 		{
+ 			$delete_box = '<input type="checkbox" name="delete_id_list[]" value="' . $attachments[$i]['attach_id'] . '" />';
+ 
+ 			for ($j = 0; $j < count($delete_id_list); $j++)
+ 			{
+ 				if ($delete_id_list[$j] == $attachments[$i]['attach_id'])
+ 				{
+ 					$delete_box = '<input type="checkbox" name="delete_id_list[]" value="' . $attachments[$i]['attach_id'] . '" checked />';
+ 					break;
+ 				}
+ 			}
  
  			$post_titles = implode('<br />', $post_titles);
  
***************
*** 445,453 ****
  			'S_DELETE_BOX' => $delete_box,
  			'S_HIDDEN' => $hidden_field,
  			'U_VIEW_ATTACHMENT' => append_sid($phpbb_root_path . 'download.' . $phpEx . '?id=' . $attachments[$i]['attach_id']))
! //			'U_VIEW_POST' => ($attachments[$i]['post_id'] != 0) ? append_sid("../viewtopic." . $phpEx . "?" . POST_POST_URL . "=" . $attachments[$i]['post_id'] . "#" . $attachments[$i]['post_id']) : '')
  		);
! 			
  	}
  }
  
--- 489,497 ----
  				'S_DELETE_BOX' => $delete_box,
  				'S_HIDDEN' => $hidden_field,
  				'U_VIEW_ATTACHMENT' => append_sid($phpbb_root_path . 'download.' . $phpEx . '?id=' . $attachments[$i]['attach_id']))
! 	//			'U_VIEW_POST' => ($attachments[$i]['post_id'] != 0) ? append_sid("../viewtopic." . $phpEx . "?" . POST_POST_URL . "=" . $attachments[$i]['post_id'] . "#" . $attachments[$i]['post_id']) : '')
  			);
! 		}
  	}
  }
  
