vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   $GLOBALS['forumid'] (https://vborg.vbsupport.ru/showthread.php?t=308009)

Exa 02-07-2014 12:12 AM

$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.

Exa 02-07-2014 08:27 AM

code at attachment_start to check attachments forumid before download

PHP Code:

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




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?

Exa 02-07-2014 11:36 AM

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) ;



kh99 02-07-2014 11:50 AM

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.

Exa 02-07-2014 12:12 PM

maybe query is the best way

so, what query will look like ?

kh99 02-07-2014 01:35 PM

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.



Exa 02-07-2014 07:55 PM

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 !


All times are GMT. The time now is 01:11 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01131 seconds
  • Memory Usage 1,736KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete