forked from science-ation/science-ation
Recover missed commit for YSC awards downloading and winners upload.
This commit is contained in:
parent
615c265d00
commit
1ab43fef68
@ -76,7 +76,6 @@ case 'check':
|
||||
}
|
||||
|
||||
echo "<i>";
|
||||
$ar=$response['awardresponse'][0];
|
||||
$awards = $data['awards'];
|
||||
$postback = $data['postback'];
|
||||
echo i18n("Postback URL: %1",array($postback))." <br />";
|
||||
|
@ -27,6 +27,29 @@
|
||||
user_auth_required('committee', 'admin');
|
||||
require_once('xml.inc.php');
|
||||
|
||||
function xml_dearray(&$array)
|
||||
{
|
||||
// echo "<pre>";print_r($array);echo "</pre>";
|
||||
$keys = array_keys($array);
|
||||
foreach($keys as $k) {
|
||||
if(!is_array($array[$k])) {
|
||||
echo "Not array at key $k";
|
||||
exit;
|
||||
}
|
||||
|
||||
if(count($array[$k]) == 1) {
|
||||
$array[$k] = $array[$k][0];
|
||||
} else {
|
||||
/* Leave it alone */
|
||||
}
|
||||
|
||||
if(is_array($array[$k])) {
|
||||
xml_dearray($array[$k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function curl_query($fair, $data, $ysc_url='')
|
||||
{
|
||||
@ -55,7 +78,7 @@
|
||||
break;
|
||||
}
|
||||
|
||||
// echo "<pre>Curl Send: (type:{$fair['type']}=>$url) $str</pre>";
|
||||
// echo "<pre>Curl Send: (type:{$fair['type']}=>$url) ".htmlspecialchars($str)."</pre>";
|
||||
|
||||
$ch = curl_init(); /// initialize a cURL session
|
||||
curl_setopt ($ch, CURLOPT_URL, $url);
|
||||
@ -70,7 +93,7 @@
|
||||
$datastream = curl_exec ($ch); /// execute the curl session and return the output to a variable $datastream
|
||||
curl_close ($ch); /// close the curl session
|
||||
|
||||
// echo "<pre>Server Returned: ".urldecode($datastream)."</pre>";
|
||||
// echo "<pre>Server Returned: ".htmlspecialchars(urldecode($datastream))."</pre>";
|
||||
|
||||
switch($fair['type']) {
|
||||
case 'sfiab':
|
||||
@ -78,9 +101,36 @@
|
||||
break;
|
||||
case 'ysc':
|
||||
$datastream = str_replace(" standalone=\"yes\"","",$datastream);
|
||||
/* Return is plaintext, make a return array */
|
||||
$ret['error'] = 0;
|
||||
$ret['message'] = $datastream;
|
||||
/* Return is XML, make a return array */
|
||||
$response=xml_parsexml($datastream);
|
||||
/* De-array everything */
|
||||
xml_dearray($response);
|
||||
$key = array_keys($response);
|
||||
|
||||
// echo "<pre>";print_r($response);echo "</pre>";
|
||||
|
||||
switch($key[0]) {
|
||||
case 'awardresponse':
|
||||
/* Full response */
|
||||
$ret = $response['awardresponse'];
|
||||
|
||||
/* Undo variable to array */
|
||||
$ret['awards'] = $ret['awards']['award'];
|
||||
|
||||
/* Turn the awards into an array if it was dearrayed (in the case there is only one */
|
||||
if(!is_array($ret['awards'])) {
|
||||
$ret['awards'] = array($ret['awards']);
|
||||
}
|
||||
$ret['error'] = 0;
|
||||
$ret['message'] = '';
|
||||
break;
|
||||
case 'awardwinnersresponse':
|
||||
/* Parse return */
|
||||
$ret['error'] = ($response['awardwinnersresponse']['status'] == 'failed') ? 1 : 0;
|
||||
$ret['message'] = $response['awardwinnersresponse']['statusmessage'];
|
||||
break;
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
// echo "<pre>Server Returned: ";print_r($ret);echo "</pre><br>";
|
||||
|
Loading…
Reference in New Issue
Block a user