View Full Version : $GLOBALS['forumid']
i'm trying to use $GLOBALS['forumid'] at hook attachment_start and not working .
any idea ?
ozzy47
02-07-2014, 12:20 AM
$GLOBALS[] is a "superglobal" so it should be available everywhere.
What is it you are trying to do, you did not explain to much, also the full code you are using might help.
code at attachment_start to check attachments forumid before download
if(!in_array($GLOBALS['forumid'], array(1, 2, 3, 4))){
}
ozzy47
02-07-2014, 11:30 AM
That still does not show what it is you are trying to do, what is the full code?
the full code
if(!in_array($GLOBALS['forumid'], array(1, 2, 3, 4))){
$out = $_SERVER['SERVER_NAME'] ;
header('Status: 301 Moved Permanently', false, 301);
header( 'Location:' . $out) ;
}
The forumid global will only be available if there is a -f or -forum parameter, and there isn't for an attachment. There doesn't seem to be any way to do what you want to do in a plugin unless you do your own query to find out what forum the postid or attachmentid is related to (if you look at attachment.php and search for 'attachment_start' you can see what's going on there).
Of course if you don't mind modifying the php files you could insert your code in attachment.php somewhere after the query has been done. Then you would use $attachmentinfo['forumid'] instead of the global.
maybe query is the best way
so, what query will look like ?
Well, I haven't tried it but I guess it would look like the one that's in attachment.php, but you don't need to read everything since you only need the forumid. So maybe:
if (!$attachmentinfo = $db->query_first_slave("
SELECT thread.forumid FROM " . TABLE_PREFIX . "attachment AS attachment
LEFT JOIN " . TABLE_PREFIX . "post AS post ON (post.postid = attachment.postid)
LEFT JOIN " . TABLE_PREFIX . "thread AS thread ON (post.threadid = thread.threadid)
WHERE " . ($vbulletin->GPC['postid'] ? "attachment.postid = " . $vbulletin->GPC['postid'] : "attachmentid = " . $vbulletin->GPC['attachmentid']) . "
"))
{
eval(standard_error(fetch_error('invalidid', $vbphrase['attachment'], $vbulletin->options['contactuslink'])));
}
if (!in_array($attachmentinfo['forumid'], array(1, 2, 3, 4))
{
// etc.
}
Let me try and feed you back
--------------- Added 1391811107 at 1391811107 ---------------
you forget to add ")" at the end of forumid array
That's work exactly, thank you !
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.