Antivirus
11-10-2007, 01:58 PM
I'm creating a script which utilizes attachment.php to generate thumbnails for images in the attachment table. The problem is however that the attachments aren't associated with any thread, forum. They are easily identified though by having a postid of '4294967295'.
Now, if any attachment hasn't been moderated, attachment.php won't display the image because the script can't determine if the user has permission to view/moderate the attachment (due to following code in attachment.php):
if (!$attachmentinfo['visible'] AND !can_moderate($attachmentinfo['forumid'], 'canmoderateattachments') AND $attachmentinfo['userid'] != $vbulletin->userinfo['userid'])
{
eval(standard_error(fetch_error('invalidid', $idname, $vbulletin->options['contactuslink'])));
}
The results for the query to get $attachmentinfo within attachment.php are shown in query.gif below. As you can see, $attachmentinfo['visible'] = '0' (image isn't yet moderated) and $attachmentinfo['forumid'] is empty (there's no associated forumid), therefore we get the error...
There are however the hooks within the query for getting $attachmentinfo:
SELECT filename, attachment.postid, attachment.userid, attachmentid,
" . ((!empty($vbulletin->GPC['thumb'])
? 'attachment.thumbnail AS filedata, thumbnail_dateline AS dateline, thumbnail_filesize AS filesize,'
: 'attachment.dateline, SUBSTRING(filedata, 1, 2097152) AS filedata, filesize,')) . "
attachment.visible, mimetype, thread.forumid, thread.threadid, thread.postuserid,
post.visible AS post_visible, thread.visible AS thread_visible
$hook_query_fields
FROM " . TABLE_PREFIX . "attachment AS attachment
LEFT JOIN " . TABLE_PREFIX . "attachmenttype AS attachmenttype ON (attachmenttype.extension = attachment.extension)
LEFT JOIN " . TABLE_PREFIX . "post AS post ON (post.postid = attachment.postid)
LEFT JOIN " . TABLE_PREFIX . "thread AS thread ON (post.threadid = thread.threadid)
$hook_query_joins
WHERE " . ($vbulletin->GPC['postid'] ? "attachment.postid = " . $vbulletin->GPC['postid'] : "attachmentid = " . $vbulletin->GPC['attachmentid']) . "
$hook_query_where
Is it possible somehow to put a conditional into the query which assigns a specific forumid in the event that the attachment's postid = '4294967295'?
Unfortunately there's no hook location after the query, only before ( attachment_start ) which leaves me to somehow utilize $hook_query_fields or $hook_query_joins or $hook_query_where.
Any ideas???
Now, if any attachment hasn't been moderated, attachment.php won't display the image because the script can't determine if the user has permission to view/moderate the attachment (due to following code in attachment.php):
if (!$attachmentinfo['visible'] AND !can_moderate($attachmentinfo['forumid'], 'canmoderateattachments') AND $attachmentinfo['userid'] != $vbulletin->userinfo['userid'])
{
eval(standard_error(fetch_error('invalidid', $idname, $vbulletin->options['contactuslink'])));
}
The results for the query to get $attachmentinfo within attachment.php are shown in query.gif below. As you can see, $attachmentinfo['visible'] = '0' (image isn't yet moderated) and $attachmentinfo['forumid'] is empty (there's no associated forumid), therefore we get the error...
There are however the hooks within the query for getting $attachmentinfo:
SELECT filename, attachment.postid, attachment.userid, attachmentid,
" . ((!empty($vbulletin->GPC['thumb'])
? 'attachment.thumbnail AS filedata, thumbnail_dateline AS dateline, thumbnail_filesize AS filesize,'
: 'attachment.dateline, SUBSTRING(filedata, 1, 2097152) AS filedata, filesize,')) . "
attachment.visible, mimetype, thread.forumid, thread.threadid, thread.postuserid,
post.visible AS post_visible, thread.visible AS thread_visible
$hook_query_fields
FROM " . TABLE_PREFIX . "attachment AS attachment
LEFT JOIN " . TABLE_PREFIX . "attachmenttype AS attachmenttype ON (attachmenttype.extension = attachment.extension)
LEFT JOIN " . TABLE_PREFIX . "post AS post ON (post.postid = attachment.postid)
LEFT JOIN " . TABLE_PREFIX . "thread AS thread ON (post.threadid = thread.threadid)
$hook_query_joins
WHERE " . ($vbulletin->GPC['postid'] ? "attachment.postid = " . $vbulletin->GPC['postid'] : "attachmentid = " . $vbulletin->GPC['attachmentid']) . "
$hook_query_where
Is it possible somehow to put a conditional into the query which assigns a specific forumid in the event that the attachment's postid = '4294967295'?
Unfortunately there's no hook location after the query, only before ( attachment_start ) which leaves me to somehow utilize $hook_query_fields or $hook_query_joins or $hook_query_where.
Any ideas???