Ok... AMP_PassData2CgiAndPrintCgiResult.cgi
<?php
/***********************************************************************
Copyright (C) 2002-2007 Punbb Community (deadram at gmail dot com)
This file is part of PunBB.
PunBB is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PunBB is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston,
MA 02111-1307 USA
************************************************************************/
// Make sure no one attempts to run this script "directly"
if (!defined('PUN'))
exit;
// Tell admin_loader.php that this is indeed a plugin and that it is loaded
define('PUN_PLUGIN_LOADED', 1);
//
// The rest is up to you!
//
// Display the admin navigation menu
generate_admin_menu($plugin);
?>
<div class="blockform">
<h2><span>A test plugin</span></h2>
<div class="box">
<form method="post" action="<?php echo $_SERVER['REQUEST_URI'] ?>">
<p class="submittop"><input type="submit" name="run_cgi" value="Run" /></p>
<div class="infldset">
<fieldset>
<legend>Options</legend>
<div class="infldset">
<table class="aligntop" cellspacing="0">
<tr>
<th scope="row">Run cgi</th>
<td>
<input type="text" name="cgi_path" value="./plugins/cgi/SomeCgiScript.cgi">
<p>Type the relative path from the forum root directory to a cgi script above</p>
</td>
</tr>
</table>
</div>
</fieldset>
</div>
<p class="submittop"><input type="submit" name="run_cgi" value="Run" /></p>
</form>
</div>
</div>
<div class="blockform">
<h2><span>Output</span></h2>
<div class="box">
<p><?php if (isset($_POST['run_cgi'])) { passthru($_POST['cgi_path'].' ARGVARS FROM PHP IE: data from the user table, ect...'); } ?></p>
</div>
</div>
SomeCgiScript.cgi
#!/usr/bin/perl
$numArgs = $#ARGV + 1;
print 'Thanks, you gave me '.$numArgs.' command-line arguments.'."\n\n";
foreach $argnum (0 .. $#ARGV) {
print "$ARGV[$argnum]\n";
}
print "\n\n".'Here\'s your environment variables:'."\n\n";
foreach $key (sort keys(%ENV)) {
print "$key = $ENV{$key}\n";
}
In the php script get whatever data you need. Stuff for the database, etc... in perl parse the argvars.
The cookie set by punbb is just a number that references a row in the punbb database, that has I think uid, ip, cookie "id", and accesstime. I forget exactly though. You don't need to fumble around with the cookie though. in the php script get the vars you want to change and/or alter. in perl do the work, and in php parse the output and change any values.
The php's official docs on passthru list a few alternative ways to call external applications.
If you wanted to use the example above and then access the database in the perl script, you will need to write your own database access code ($db->Function isn't official php, it's punbb's own db layer). Give me a few and I'll edit to include some info on the database records
EDIT --
Looks like I was wrong. Guess the cookie doesn't work like I expected it too. Anyways, you don't need the cookie, if you already have the uid