Esempio n. 1
0
File: acte.php Progetto: nursit/bank
/**
 * signer le contexte du formulaire
 * s'applique sur le html pour permettre sa personalisation
 *
 * @param string $texte
 * @param array $config
 * @return string
 */
function ogone_form_sha_in($texte, $config = null)
{
    // ne rien faire si pas de config
    if (!$config) {
        return $texte;
    }
    $forms = extraire_balises($texte, "form");
    foreach ($forms as $form) {
        $form_s = $form;
        $input = extraire_balises($form, "input");
        $args = array();
        foreach ($input as $i) {
            if (extraire_attribut($i, 'type') == 'hidden') {
                $name = extraire_attribut($i, 'name');
                $value = extraire_attribut($i, 'value');
                // si jamais on applique 2 fois, supprimer la signature precedement calculee
                if ($name == "SHASign") {
                    $form_s = str_replace($i, "", $form_s);
                } else {
                    $args[$name] = $value;
                }
            }
        }
        $s = ogone_sha_in($args, $config);
        $form_s = str_replace(end($input), end($input) . "<input type='hidden' name='SHASign' value='{$s}' />", $form_s);
        $texte = str_replace($form, $form_s, $texte);
    }
    return $texte;
}
Esempio n. 2
0
/**
 * signer le contexte du formulaire
 * s'applique sur le html pour permettre sa personalisation
 * 
 * @param string $texte
 */
function ogone_form_sha_in($texte)
{
    $form = extraire_balise($texte, "form");
    $input = extraire_balises($form, "input");
    $args = array();
    foreach ($input as $i) {
        if (extraire_attribut($i, 'type') == 'hidden') {
            $name = extraire_attribut($i, 'name');
            $value = extraire_attribut($i, 'value');
            $args[$name] = $value;
        }
    }
    $s = ogone_sha_in($args);
    $texte = str_replace(end($input), end($input) . "<input type='hidden' name='SHASign' value='{$s}' />", $texte);
    return $texte;
}