Index: branches/5.1.x/units/shipping_quote_engines/usps.php =================================================================== diff -u -N -r14257 -r14359 --- branches/5.1.x/units/shipping_quote_engines/usps.php (.../usps.php) (revision 14257) +++ branches/5.1.x/units/shipping_quote_engines/usps.php (.../usps.php) (revision 14359) @@ -1,6 +1,6 @@ logFilePath = (defined('RESTRICTED') ? RESTRICTED : WRITEABLE . '/user_files') . '/usps.log'; + // EXPRESS, FIRST CLASS, PRIORITY, PARCEL, BMP, MEDIA $this->types = Array( 'EXPRESS' => 'Express Mail', @@ -1141,20 +1148,22 @@ $body = curl_exec($curl); curl_close($curl); - if (defined('USPS_LOG_FILE')) { - $filename = USPS_LOG_FILE; - if ( !$fp = fopen($filename, "a") ) echo("Failed opening file $filename"); + if ($this->logFilePath) { + $fp = fopen($this->logFilePath, 'a'); + + if ($fp) { + $request_url = sprintf("Date %s : IP %s\n\nPost\n\n%s\n\nReplay\n\n%s\n\n", + adodb_date('m/d/Y H:i:s'), + $_SERVER['REMOTE_ADDR'], + $usps_server . '/' . $api_dll . '?' . urldecode($request), + $body + ); + + fwrite($fp, $request_url); + fclose($fp); + } } - $request_url = sprintf("Date %s : IP %s\n\nPost\n\n%s\n\nReplay\n\n%s\n\n", - date("m/d/Y H:i:s",time()), - $_SERVER['REMOTE_ADDR'], - $usps_server.'/'.$api_dll.'?'.urldecode($request), - $body - ); - if (defined('USPS_LOG_FILE')) { - if (!fwrite($fp, $request_url)) echo("Failed writing to file $filename"); - fclose($fp); - } + return $body; } Index: branches/5.1.x/units/gateways/gw_classes/google_checkout.php =================================================================== diff -u -N -r14257 -r14359 --- branches/5.1.x/units/gateways/gw_classes/google_checkout.php (.../google_checkout.php) (revision 14257) +++ branches/5.1.x/units/gateways/gw_classes/google_checkout.php (.../google_checkout.php) (revision 14359) @@ -1,6 +1,6 @@ Application->isDebugMode()) { - $fp = fopen(FULL_PATH.'/xml_request.html', 'a'); - fwrite($fp, '--- '.adodb_date('Y-m-d H:i:s').' ---'."\n".$xml_data); - fclose($fp); + if ( $this->Application->isDebugMode() ) { + $this->toLog($xml_data, 'xml_request.html'); } return $xml_data; @@ -235,16 +233,27 @@ echo $xml_responce; - if ($this->Application->isDebugMode()) { - $fp = fopen(FULL_PATH.'/xml_responce.html', 'a'); - fwrite($fp, '--- '.adodb_date('Y-m-d H:i:s').' ---'."\n".$xml_responce."\n"); - fclose($fp); + if ( $this->Application->isDebugMode() ) { + $this->toLog($xml_responce, 'xml_responce.html'); } return $order_approvable ? 1 : 0; } /** + * Writes XML requests and responces to a file + * + * @param string $xml_data + * @param string $xml_file + */ + function toLog($xml_data, $xml_file) + { + $fp = fopen( (defined('RESTRICTED') ? RESTRICTED : FULL_PATH) . '/' . $xml_file, 'a' ); + fwrite($fp, '--- ' . adodb_date('Y-m-d H:i:s') . ' ---' . "\n" . $xml_data); + fclose($fp); + } + + /** * Processes notification * * @param kXMLNode $root_node Index: branches/5.1.x/gw_notify.php =================================================================== diff -u -N -r14257 -r14359 --- branches/5.1.x/gw_notify.php (.../gw_notify.php) (revision 14257) +++ branches/5.1.x/gw_notify.php (.../gw_notify.php) (revision 14359) @@ -1,6 +1,6 @@ Init(); - /* + // for debugging payment gateway notifications, don't remove - $fh = fopen(WRITEABLE . '/gw.log', 'a'); + /*$fh = fopen((defined('RESTRICTED') ? RESTRICTED : WRITEABLE) . '/gw.log', 'a'); fwrite ($fh, "\n\n".date('d/m/y h:i:s').":\n"); foreach ($_REQUEST as $key => $val) { fwrite($fh, "\n"); } - fclose($fh); - */ - + fclose($fh);*/ + + $db =& $application->GetADODBConnection(); $application->setUnitOption('ord','AutoLoad',false); $order =& $application->recallObject('ord'); - + $order_id = $application->GetVar('order_id'); if ($order_id) { $order->Load($order_id); } - + $gw_data = $order->getGatewayData($application->GetVar('payment_type_id')); $application->registerClass( $gw_data['ClassName'], GW_CLASS_PATH.'/'.$gw_data['ClassFile'] ); $gateway_object =& $application->recallObject( $gw_data['ClassName'] );