Esempio n. 1
0
/**
 * @param array $config
 * @return array
 */
function wha_responder_dist($config)
{
    $mode = 'wha';
    // historique...
    if ($config['type'] == 'abo') {
        $mode = 'wha_abo';
    }
    $uoid = 0;
    if (!($m = _request('m'))) {
        return array($uoid, false);
    }
    $m = urldecode($m);
    if (!($decode = wha_unsign($m))) {
        spip_log($t = "wha_responder : signature invalide : {$m}", $mode);
        // on log ca dans un journal dedie
        spip_log($t, 'wha_douteux');
        return array($uoid, false);
    }
    list($unsign, $partnerId, $keyId) = $decode;
    #var_dump($unsign);
    $args = wha_extract_args($unsign);
    #var_dump($args);
    // recuperer le code de resultat
    $c = isset($args['c']) ? $args['c'] : "";
    // annulation de l'internaute
    if (!preg_match(",^(NMPOC_NEW)\$,i", $c)) {
        spip_log($t = "wha_responder : c invalide : {$m}", $mode);
        return array($uoid, false);
    }
    // OK
    if (!isset($args['v']) or !is_array($v = $args['v']) or !isset($v['r']) or !isset($v['uo'])) {
        spip_log($t = "wha_responder : traitement impossible : {$m}", $mode);
        return array($uoid, false);
    }
    $uoid = $v['uo'];
    // envoyer l'acquitement
    echo wha_message("ack", false, $partnerId, $keyId);
    // (id_abonnement, (immediat,commentaire))
    return array($uoid, array($v['r'] != 200, $v['r'] . ':' . $v['c']));
}
Esempio n. 2
0
function wha_action_url($action, $achat_desc, $config, $versionId = 2)
{
    $url = wha_node_url($config);
    $signed = wha_message($action, $achat_desc, $config['MERCHANT_ID'], $config['KEY_ID'], $versionId);
    return $url . (strpos($url, '?') === FALSE ? '?' : '&') . 'm=' . urlencode($signed);
}