Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
  #1  
Old 08-04-2011, 02:18 AM
EquinoxWorld EquinoxWorld is offline
 
Join Date: Nov 2009
Location: Naples
Posts: 354
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Need Help with plugin that's not in forum root

Hello everyone, I am currently trying to utilize a part of a file as a plugin. I want to be able to sue this same file for several plugins to reduce number of files. The other issue is that this file is not in the forum root.

Here is the plugin:

Location Global Start
vb version 4.1.5

PHP Code:
ob_start();
  require_once(
'.intuitco/cotw/functions/cotw_func_contest_num.php?do=sotw');
$cotw_sotw_contests_number ob_get_contents();
ob_end_clean();
vB_Template::preRegister('COTW_SOTW',array('cotw_sotw_contests_number' => $cotw_sotw_contests_number)); 
As you can see the file is in httpdocs(forum root)/intuitco/cotw/functions/ . Also I am trying to use it as php?do=x , not sure if that is valid though when using it as a plugin. When I activate this plugin I get a internal server error, when disabled the page loads fine.

If anyone has any ideas or any additional info that might be useful please do let us know. Thank you for your time everyone.
Reply With Quote
  #2  
Old 08-04-2011, 02:34 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

One thing I notice, you say the file is in intuitco/cotw/functions directory but you've got .intuitco in the file name (maybe you meant ./intuitco). But anyway, I don't think you can put ?do=sotw on the file name, but this might work:

PHP Code:
require_once('http://www.domain.com/intuitco/cotw/functions/cotw_func_contest_num.php?do=sotw'); 

(of course you'd replace www.domain.com with your domain name).


Another alternative might be something like:

PHP Code:
$savedo $_GET['do'];
$_GET['do'] = 'sotw';
ob_start(); 
  require_once(
'./intuitco/cotw/functions/cotw_func_contest_num.php'); 
$cotw_sotw_contests_number ob_get_contents(); 
ob_end_clean(); 
vB_Template::preRegister('COTW_SOTW',array('cotw_sotw_contests_number' => $cotw_sotw_contests_number));  

$_GET['do'] = $savedo

but I'm not sure, I've never tried that, and it probably depends on what the included script actually does.
Reply With Quote
  #3  
Old 08-04-2011, 02:50 AM
EquinoxWorld EquinoxWorld is offline
 
Join Date: Nov 2009
Location: Naples
Posts: 354
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
One thing I notice, you say the file is in intuitco/cotw/functions directory but you've got .intuitco in the file name (maybe you meant ./intuitco). But anyway, I don't think you can put ?do=sotw on the file name, but this might work:

PHP Code:
require_once('http://www.domain.com/intuitco/cotw/functions/cotw_func_contest_num.php?do=sotw'); 

(of course you'd replace www.domain.com with your domain name).


Another alternative might be something like:

PHP Code:
$savedo $_GET['do'];
$_GET['do'] = 'sotw';
ob_start(); 
  require_once(
'./intuitco/cotw/functions/cotw_func_contest_num.php'); 
$cotw_sotw_contests_number ob_get_contents(); 
ob_end_clean(); 
vB_Template::preRegister('COTW_SOTW',array('cotw_sotw_contests_number' => $cotw_sotw_contests_number));  

$_GET['do'] = $savedo

but I'm not sure, I've never tried that, and it probably depends on what the included script actually does.
Well the second code you suggested did eliminate the error but the value does not show though. I beleive it has to do with the php?do= part. Here is the file I am using:

PHP Code:
<?php
//===================================Contests Number==================================//
//Require This is required everywhere//
require_once('./global.php'); 
//This protection si also required//
define('CSRF_PROTECTION'true); 
//================================First Contest:Signature Of The Week=======================================//
//==============================NOTHING IS CHANGED BEYOND THIS LINE!!!!!====================================//
//==========================================================================================================//
if ($_REQUEST['do'] == 'sotw')

{
$result $db->query_read("SELECT id FROM cotw_sotw_time_end ORDER BY id DESC LIMIT 1");
$row mysql_fetch_row($result);
echo 
$row[0];
}
//=========================================================================================================//
//===================================Second Contest:Avatar Of The Week=====================================//
//==============================NOTHING IS CHANGED BEYOND THIS LINE!!!!!====================================//
//==========================================================================================================//
if ($_REQUEST['do'] == 'aotw')

{
    
$result $db->query_read("SELECT id FROM cotw_aotw_time_end ORDER BY id DESC LIMIT 1");
$row mysql_fetch_row($result);
echo 
$row[0];
}
//==========================================================================================================//
//=================================END OF PRINTING CURRENT CONTEST NUMBER===================================//
//==========================================================================================================//
?>
I could just use two seperate files but it seems a waste to have to use 2 files to do such a simple operation....Any ideas?
Reply With Quote
  #4  
Old 08-04-2011, 02:55 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think that all boils down to a plugin with this code:

PHP Code:
$row $db->query_first("SELECT id FROM cotw_sotw_time_end ORDER BY id DESC LIMIT 1");
$cotw_sotw_contests_number $row['id'];
vB_Template::preRegister('COTW_SOTW',array('cotw_sotw_contests_number' => $cotw_sotw_contests_number)); 

I suppose you could put that query in a file and include() it if the code is used in more than one place.
Reply With Quote
  #5  
Old 08-04-2011, 02:59 AM
EquinoxWorld EquinoxWorld is offline
 
Join Date: Nov 2009
Location: Naples
Posts: 354
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
I think that all boils down to a plugin with this code:

PHP Code:
$row $db->query_first("SELECT id FROM cotw_sotw_time_end ORDER BY id DESC LIMIT 1");
$cotw_sotw_contests_number $row['id'];
vB_Template::preRegister('COTW_SOTW',array('cotw_sotw_contests_number' => $cotw_sotw_contests_number)); 

I suppose you could put that query in a file and include() it if the code is used in more than one place.
Well that worked! No need for a file, even better! Thanks for the help kh99, as always very helpful. I didn;t even know you could run queries from there like that... Opens up more possibilities :up:

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

Can I do this in the same plguin?

PHP Code:
$row $db->query_first("SELECT id FROM cotw_sotw_time_end ORDER BY id DESC LIMIT 1"); 
$cotw_sotw_contests_number $row['id']; 
$row2 $db->query_first("SELECT id FROM cotw_aotw_time_end ORDER BY id DESC LIMIT 1"); 
$cotw_aotw_contests_number $row2['id'];
vB_Template::preRegister('COTW_SOTW',array('cotw_sotw_contests_number' => $cotw_sotw_contests_number));
vB_Template::preRegister('COTW_SOTW',array('cotw_aotw_contests_number' => $cotw_aotw_contests_number)); 
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 01:12 AM.


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.04082 seconds
  • Memory Usage 2,231KB
  • Queries Executed 11 (?)
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
  • (9)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)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_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