'; echo 'window.location.href="'.$url.'";'; echo ''; echo ''; } } /* The getToken function. ** ** NOTE: A function of convenience that extracts the value from the "name=value&name2=value2..." reply string ** ** Works even if one of the values is a URL containing the & or = signs. */ function getToken($thisString) { // List the possible tokens $Tokens = array( "Status", "StatusDetail", "VendorTxCode", "VPSTxId", "TxAuthNo", "Amount", "AVSCV2", "AddressResult", "PostCodeResult", "CV2Result", "GiftAid", "3DSecureStatus", "CAVV", "AddressStatus", "CardType", "Last4Digits", "PayerStatus","CardType"); // Initialise arrays $output = array(); $resultArray = array(); // Get the next token in the sequence for ($i = count($Tokens)-1; $i >= 0 ; $i--){ // Find the position in the string $start = strpos($thisString, $Tokens[$i]); // If it's present if ($start !== false){ // Record position and token name $resultArray[$i]->start = $start; $resultArray[$i]->token = $Tokens[$i]; } } // Sort in order of position sort($resultArray); // Go through the result array, getting the token values for ($i = 0; $istart + strlen($resultArray[$i]->token) + 1; // Get the length of the value if ($i==(count($resultArray)-1)) { $output[$resultArray[$i]->token] = substr($thisString, $valueStart); } else { $valueLength = $resultArray[$i+1]->start - $resultArray[$i]->start - strlen($resultArray[$i]->token) - 2; $output[$resultArray[$i]->token] = substr($thisString, $valueStart, $valueLength); } } // Return the ouput array return $output; } // Filters unwanted characters out of an input string. Useful for tidying up FORM field inputs. function cleanInput($strRawText,$strType) { if ($strType=="Number") { $strClean="0123456789."; $bolHighOrder=false; } else if ($strType=="VendorTxCode") { $strClean="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_."; $bolHighOrder=false; } else { $strClean=" ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.,'/{}@():?-_&£$=%~<>*+\""; $bolHighOrder=true; } $strCleanedText=""; $iCharPos = 0; do { // Only include valid characters $chrThisChar=substr($strRawText,$iCharPos,1); if (strspn($chrThisChar,$strClean,0,strlen($strClean))>0) { $strCleanedText=$strCleanedText . $chrThisChar; } else if ($bolHighOrder==true) { // Fix to allow accented characters and most high order bit chars which are harmless if (bin2hex($chrThisChar)>=191) { $strCleanedText=$strCleanedText . $chrThisChar; } } $iCharPos=$iCharPos+1; } while ($iCharPos