diff --git a/admin/award_upload.php b/admin/award_upload.php index cf5cca5..de6f7dc 100644 --- a/admin/award_upload.php +++ b/admin/award_upload.php @@ -181,7 +181,7 @@ curl_setopt ($ch, CURLOPT_URL,$r->external_postback); curl_setopt ($ch, CURLOPT_HEADER, 0); /// Header control curl_setopt ($ch, CURLOPT_POST, 1); /// tell it to make a POST, not a GET - curl_setopt ($ch, CURLOPT_POSTFIELDS, "xml=".$_POST['xmldata']); /// put the query string here starting with "?" + curl_setopt ($ch, CURLOPT_POSTFIELDS, "xml=$xmldata"); /// put the query string here starting with "?" curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); /// This allows the output to be set into a variable $datastream curl_setopt ($ch, CURLOPT_POSTFIELDSIZE, 0); curl_setopt ($ch, CURLOPT_TIMEOUT, 360); @@ -192,16 +192,29 @@ curl_close ($ch); /// close the curl session echo i18n("Response from server:"); $response=xml_parsexml($datastream); - $keys=array_keys($response); - if($keys[0]=="awardwinnersresponse") { - $status=$response['awardwinnersresponse'][0]['status'][0]; - if($status=="success") - echo happy(i18n("Success")); + if($response && is_array($response)) { + $keys=array_keys($response); + if($keys[0]=="awardwinnersresponse") { + $status=$response['awardwinnersresponse'][0]['status'][0]; + $statusmessage=$response['awardwinnersresponse'][0]['statusmessage'][0]; + if($status=="success") + echo happy(i18n("Success: %1",array($statusmessage))); + else + echo error(ucfirst($status).": ".$statusmessage); //not translated, because it came right from the server! + } else - echo error(ucfirst($status)); //not translated, because it came right from the server! + { + echo error(i18n("Invalid XML response. Expecting '%1', received '%2'",array("awardwinnersresponse",$keys[0]))); + echo "datastream: ".htmlspecialchars($datastream); + } } else - echo error(i18n("Invalid XML response. Expecting '%1', received '%2'",array("awardwinnersresponse",$keys[0]))); + { + echo error(i18n("Invalid response. Couldn't parse XML or no data returned",array("awardwinnersresponse",$keys[0]))); + echo "datastream: ".htmlspecialchars($datastream); + + } + } echo "
"; }