note 15894 deleted from ref.pfpro by jimw
| From: | jimw@php.net | Date: | Tue, 18 Dec 2001 21:02:10 +0000 |
| Subject: | note 15894 deleted from ref.pfpro by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-23238@lists.php.net to get a copy of this message | ||
I've updated the FUNCTION within the 'php_pfpro.inc' file to fix a *postential*
problem with the '&' character -- normally, messages get returned with the RESULT.. at
least one of these messages -6 contains an ampersand '&' -- this causes the expode
command to create a distored array. I've added a check 'str_replace()' to replace
any ampersands with a space on either side .. this assumes that the ampersand is part of a string
(message) and not intended to be a delimiter. Replace the FUNCTION (PFPRO_PROCESS)in the previous
code with this new updated one:
-- UPDATED 10.07.01 --
function pfpro_process($transaction, $url=pfpro_defaulthost, $port=pfpro_defaultport,
$timeout=pfpro_defaulttimeout,
$proxy_url=pfpro_proxyaddress, $proxy_port=pfpro_proxyport, $proxy_logon=pfpro_proxylogin,
$proxy_password=pfpro_proxypassword)
{
if(!(is_array($transaction)))
return(NULL);
/* destruct (transaction) array into (trans) string
and dynamically add LENGTH TAGS */
foreach($transaction as $val1=>$val2)
$parmsArray[] = $val1 . '[' . strlen($val2) . ']=' . $val2;
$parmsString = implode($parmsArray, '&');
$trans = PFPRO_EXE_PATH . ' ';
$trans .= $url . ' ';
$trans .= $port . ' "';
$trans .= $parmsString . '" ';
$trans .= $timeout . ' ';
$trans .= $proxy_url . ' ';
$trans .= $proxy_port . ' ';
$trans .= $proxy_logon . ' ';
$trans .= $proxy_password;
/* run transaction, if result blank, return(NULL) */
@exec($trans, $result);
if($result[0] == NULL)
return(NULL);
/* replace any '&' that are surrounded by spaces -- this assumes
the '&' isn't a delimiter, but instead part of a message string
and converting it to 'ASCII(38)' will prevent the explode function from
thinking it's actually a delimiter. */
$result[0] = str_replace(' & ', ' ASCII(38) ', $result[0]);
/* construct (pfpro) array out of (result) string */
$valArray = explode('&', $result[0]);
foreach($valArray as $val)
{
$valArray2 = explode('=', $val);
$pfpro[$valArray2[0]] = str_replace('ASCII(38)', '&', $valArray2[1]);
}
return($pfpro);
}