View Full Version : parsing variables to an external file
ageurtse
03-08-2014, 09:27 AM
Hello,
i'm in the process of building a plugin, with this plugin there is a post button which calls a external php file.
now i wan't have acces to all the variables that are present at that time.
for instance user name, thread id and so on. there are also some custom variables.
how can i use them in my custom php file.
i don't want use file.php?someinfo=info
i will only call file.php and all the info should be availeble in file.php
how can i do this.
I think maybe the answer is to follow the instructions in this article: https://vborg.vbsupport.ru/showthread.php?t=228112
Well, now that I reread what you posted, you wouldn't necessarily have access to every variable that is present - some things like threadid would need to be passed to the external php file in some way. If you don't want to pass the parameters on the url or via POST (i.e. an html form), then you would have to use some other method. (tbworld had posted about some possible methods, but deleted his post when I said he was wrong about what you wanted. :( . Maybe he can undelete it).
ageurtse
03-08-2014, 08:05 PM
Maybe post will do the job, i dont want the user to see variables on the command line.
ageurtse
03-10-2014, 05:48 PM
i can't get it to work.
when i load a php from a external site, the php file is displayed when i host the php file on the vbulletin site. the file isn't show.
how can i display this php file within vbulletin.
and alternate parse some variables from vbulletin to this php file.
i think i have to make a template and a different php file, but i don't have any experience with that. i followed the tutorial as kh99 in his first post mentioned but i don't get it.
would someone help me with this. not with the code but just with some tutorial help.
[edit]
I came from a button click from within a different plugin, here is a small peace of code.
$ptpnt_do = '';
//$ptpnt_action = 'https://www.paypal.com/cgi-bin/webscr';
$ptpnt_action = './test.php';
$ptpnt_item = $foruminfo['forumid'] . '_' . $vbulletin->userinfo['userid'] .
and a small bit of the template
<form action="{vb:raw ptpnt_action}" method="post">
<vb:if condition="$show['ptpnt_total_price']">
when the submit button is pushed then my peace of code should come in.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<?php
// include the settings file
require("settings.php");
?>
<html>
<head>
<title>Transactie Pay.nl</title>
<!-- css -->
<link rel="stylesheet" type="text/css" href="includes/css/ppt.css" />
<!-- script -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>
<script src="includes/script/ppt.js" type="text/javascript"></script>
</head>
<body>
<?php
if($_POST['submit_payment_method'])
{
try
{
// an amount has been entered and an payment method has been chosen
// now we can create a Pay.nl transaction
$objPay = new Transaction($iProgramId, $iWebsiteId, $iWebsiteLocationId, $arrEmailAddress, $iAccountId, $strToken, $boolDebugMode);
// set vars from settings.php
if(isset($_POST['external_order']) && strlen($_POST['external_order']) > 0)
{
$objPay->setExternalOrder($_POST['external_order']);
}
$objPay->setExchangeUrl($strExchangeUrl);
$objPay->setReturnUrl($strReturnUrl);
$objPay->setTestMode($boolTestMode);
// check if a bank has been chosen
if(intval($_POST['payment_profile']) == 10)
{
$objPay->setBankId($_POST['bank_id']);
}
// create transaction
$transaction = $objPay->createTransaction(intval($_POST['amount']), intval($_POST['payment_profile']), array('extra1' => isset($_POST['external_order']) ? $_POST['external_order'] : ''));
}
catch(Exception $exc)
{
// set error in debug info
if(is_object($objPay) && $objPay->getDebugMode()) $objPay->doDebug('An error occured: ' . $exc->getMessage(). ' - Script execution stopped');
// put error on screen
else echo 'An error occurend: '.$exc->getMessage(). ' - Script execution stopped';
exit;
}
// show Pay.nl transaction result
echo "<div class='ppt'>";
echo "<p>";
echo "U kunt uw betaling afronden via de onderstaande link.";
echo "</p>";
echo "<p>";
echo "<a href='" . $transaction['issuerUrl'] . "'>Betaling afronden</a>";
echo "</p>";
echo "</div>";
}
else
{
try
{
// an amount has been entered and the submit button has been clicked
// now we have to set the entered amount and display the available payment profiles
// create object
$objPay = new Transaction($iProgramId, $iWebsiteId, $iWebsiteLocationId, $arrEmailAddress, $iAccountId, $strToken, $boolDebugMode);
// get the availabel payment profiles
$arrPaymentProfiles = $objPay->getActivePaymentProfiles();
// generate select box with availabel payment profiles
$selectPaymentProfiles = '<option>Selecteer</option>';
if(is_array($arrPaymentProfiles))
{
foreach($arrPaymentProfiles as $arrPaymentProfile)
{
$selectPaymentProfiles .= '<option value="' . $arrPaymentProfile['id'] . '">' . $arrPaymentProfile['name'] . '</option>';
}
}
// if payment method 10 is available we need to show a list of banks
if($objPay->isBankList($arrPaymentProfiles))
{
$arrBankList = $objPay->getIdealBanks();
if(is_array($arrBankList))
{
$selectBank = '';
foreach($arrBankList as $arrBank)
{
// generate list of banks
$selectBank .= "<div><input type='radio' name='bank_id' value='" . $arrBank['id'] . "' /><img src='" . $arrBank['icon'] . "' alt='" . $arrBank['name'] . "'></div>";
}
}
}
}
catch(Exception $exc)
{
// set error in debug info
if(is_object($objPay) && $objPay->getDebugMode()) $objPay->doDebug('An error occured: ' . $exc->getMessage());
// put error on screen
else echo 'An error occurend: '.$exc->getMessage();
exit;
}
echo "<div class='ppt'>";
echo "<form method='POST'>";
// description
echo "<div>";
echo "<p>";
echo " test 2 Selecteer de gewenste betaalmethode en vul eventueel het ordernummer van uw systeem in.";
echo "</p>";
echo "<br />";
echo "</div>";
// amount in cents
echo "<div>";
echo "<label>";
echo "Over te boeken bedrag:";
echo "</label>";
echo "<input type='hidden' name='amount' value='".$bedragtotaal."'/>";
echo '€ '.number_format(($bedragtotaal/ 100), 2, ',', '');
echo " *** ".$ptpnt_total_price;
echo "</div>";
// optional: an external order
echo "<div>";
echo "<label>";
echo "Ordernummer van uw systeem:";
echo "</label>";
echo "<input type='hidden' name='external_order' value='vb_thread_1001' />";
echo "vb_thread_1001";
echo "</div>";
// available payment methods
echo "<div>";
echo "<label>";
echo "Selecteer betaalmethode:";
echo "</label>";
echo "<select name='payment_profile'>";
echo $selectPaymentProfiles;
echo "</select>";
echo "</div>";
// list of banks in case iDEAL has been selected
echo "<div id='banks'>";
echo "<label>";
echo "Selecteer bank:";
echo "</label>";
echo "<div class='bankList'>";
echo $selectBank;
echo "</div>";
echo "</div>";
// submit button
echo "<div>";
echo "<input type='submit' name='submit_payment_method' value='Volgende stap' class='button' />";
echo "</div>";
echo "<div class='clear'></div>";
echo "</form>";
echo "</div>";
}
?>
</body>
</html>
tbworld
03-11-2014, 04:09 AM
I would need to see the entire page you are posting on the vbulletin site. You can send it in a PM if you do not want to display it here. It is hard to follow in fragments. You are probably missing something relatively easy dealing with vbulletin.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.