Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 01-06-2007, 05:20 AM
Rik Brown's Avatar
Rik Brown Rik Brown is offline
 
Join Date: Nov 2005
Location: St. Louis, Missouri, USA
Posts: 132
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How to have one mod call another mod and return?

I would like to imbed into a mod a "call" to a cleanup routine I've written in php and then return control to the mod. The mod would need to pass one parameter ($forumid) to the cleanup routine. Both php files are in the vb forum root directory.

How does one "call" to another php file and "return" control to the original file such as this?

As an aside, can anyone tell me what "vbflush()" does as I see many people putting it at the end of their routines and I can't find an explanation?

Thanks for any help here! -- Rik

ps: I assume I could make the cleanup routine a function within the mod but I really want to keep the two separate as I'll be using the cleanup routine for other things outside of the mod.
Reply With Quote
  #2  
Old 01-06-2007, 02:13 PM
Tuk4 Tuk4 is offline
 
Join Date: Feb 2003
Posts: 19
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

hmmz.. if i got you stright, the solution should be require_once('./....');
that way you call the other file, send what eva you want to do, and the control stays on the same file.
im using it instead of long functions.
Reply With Quote
  #3  
Old 01-08-2007, 04:40 PM
Rik Brown's Avatar
Rik Brown Rik Brown is offline
 
Join Date: Nov 2005
Location: St. Louis, Missouri, USA
Posts: 132
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Tuk4 View Post
hmmz.. if i got you stright, the solution should be require_once('./....');
that way you call the other file, send what eva you want to do, and the control stays on the same file.
im using it instead of long functions.
Thanks, Tuk4. I'll give that a try. But I thought I'd need something like exec() to accomplish this. I'll update this thread once I've tried these and other possibilities and have a solution. But if anyone else has further ideas, I'd appreciate hearing those, too.

What I'd like to do is have the first script either call a URL such as vbulletin.com/myscript.php?do=run&forum=25 or pass the parameter such a forum 25 to the 2nd script which would then revert control to the first script once the 2nd script completed its tasks.

Thanks again. -- Rik
Reply With Quote
  #4  
Old 01-09-2007, 10:44 PM
Rik Brown's Avatar
Rik Brown Rik Brown is offline
 
Join Date: Nov 2005
Location: St. Louis, Missouri, USA
Posts: 132
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Require_once() won't work for us do to conflicts between variables in two scripts by two different authors.

1.) Can anyone show me an example of what to embed in the first script to use $_POST to send variables to a 2nd script (I think I understand how to evaluation them in the 2nd script)?

2.) Otherwise, I see that PHP has curl functions built into it. I'm temporarily using curl on our server via cron and a bash script to execute these 2nd php scripts. But I'd much rather have have them invoked from the first php script.

Again, we manually invoke our script with URLs such as vb.com/script.php?do=run&forum=27&days=30 etc. But we could make these script utilize any passed $_POST variable if there are no variables embeded in the script's command line.

Any suggestions?

Thanks. -- Rik
Reply With Quote
  #5  
Old 01-09-2007, 11:45 PM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

How about if you set a post variable before you call the script via require_once?
PHP Code:
$_POST['variable'] = 'something';
require_once(
'file.php'); 
Reply With Quote
  #6  
Old 01-10-2007, 06:45 PM
Rik Brown's Avatar
Rik Brown Rik Brown is offline
 
Join Date: Nov 2005
Location: St. Louis, Missouri, USA
Posts: 132
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks to both Tuk4 and Dismounted. Both of your suggestions were of help.

We went with the cURL option since the 2nd script was already designed for "get" instead of "post" parameters. Here is the code that works for us:

PHP Code:
   $send_forum $variable;
   
$send_days 21;
   
$do "run";
   
$send_url "http://vb.com/script.php?do=$do&forum=$send_forum&days=$send_days";
   
$curl curl_init();
    
curl_setopt($curlCURLOPT_URL,"$send_url");
    
curl_exec ($curl);
    
curl_close ($curl); 
Thanks again. -- Rik
Reply With Quote
  #7  
Old 01-10-2007, 11:34 PM
coderphp's Avatar
coderphp coderphp is offline
 
Join Date: Nov 2006
Location: Egypt
Posts: 204
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thanx for the info...!
Reply With Quote
Reply


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 09:38 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.03707 seconds
  • Memory Usage 2,222KB
  • 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
  • (2)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)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