View Full Version : How to have one mod call another mod and return?
Rik Brown
01-06-2007, 05:20 AM
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.
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.
Rik Brown
01-08-2007, 04:40 PM
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
Rik Brown
01-09-2007, 10:44 PM
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
Dismounted
01-09-2007, 11:45 PM
How about if you set a post variable before you call the script via require_once?
$_POST['variable'] = 'something';
require_once('file.php');
Rik Brown
01-10-2007, 06:45 PM
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:
$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($curl, CURLOPT_URL,"$send_url");
curl_exec ($curl);
curl_close ($curl);
Thanks again. -- Rik
coderphp
01-10-2007, 11:34 PM
thanx for the info...!
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.