Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
  #1  
Old 02-07-2014, 12:12 AM
Exa Exa is offline
 
Join Date: Feb 2010
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default $GLOBALS['forumid']

i'm trying to use $GLOBALS['forumid'] at hook attachment_start and not working .
any idea ?
Reply With Quote
  #2  
Old 02-07-2014, 12:20 AM
ozzy47's Avatar
ozzy47 ozzy47 is offline
 
Join Date: Jul 2009
Location: USA
Posts: 10,929
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

$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.
Reply With Quote
  #3  
Old 02-07-2014, 08:27 AM
Exa Exa is offline
 
Join Date: Feb 2010
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

code at attachment_start to check attachments forumid before download

PHP Code:
if(!in_array($GLOBALS['forumid'], array(1234))){


Reply With Quote
  #4  
Old 02-07-2014, 11:30 AM
ozzy47's Avatar
ozzy47 ozzy47 is offline
 
Join Date: Jul 2009
Location: USA
Posts: 10,929
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That still does not show what it is you are trying to do, what is the full code?
Reply With Quote
  #5  
Old 02-07-2014, 11:36 AM
Exa Exa is offline
 
Join Date: Feb 2010
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

the full code

PHP Code:
if(!in_array($GLOBALS['forumid'], array(1234))){
$out $_SERVER['SERVER_NAME'] ;
header('Status: 301 Moved Permanently'false301);
header'Location:' $out) ;

Reply With Quote
  #6  
Old 02-07-2014, 11:50 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #7  
Old 02-07-2014, 12:12 PM
Exa Exa is offline
 
Join Date: Feb 2010
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

maybe query is the best way

so, what query will look like ?
Reply With Quote
  #8  
Old 02-07-2014, 01:35 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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:
PHP Code:
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(1234))
{
  
// etc.

Reply With Quote
  #9  
Old 02-07-2014, 07:55 PM
Exa Exa is offline
 
Join Date: Feb 2010
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Let me try and feed you back

--------------- Added [DATE]1391811107[/DATE] at [TIME]1391811107[/TIME] ---------------

you forget to add ")" at the end of forumid array

That's work exactly, thank you !
Reply With Quote
Reply

Thread Tools
Display Modes

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 03:15 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.04488 seconds
  • Memory Usage 2,244KB
  • Queries Executed 13 (?)
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
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)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_postinfo_query
  • fetch_postinfo
  • 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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete