<?php
if (false !== stripos($url, "signin/selectchallenge")) {
$msg = "WARNING: got a verify its you recovery email challenge!\n";
fprintf(STDERR, "%s", $msg);
echo $msg;
$domd = @DOMDocument::loadHTML($html);
$xp = new DOMXPath($domd);
$challengeForm = $xp->query('//form[contains(@action,"/signin/challenge/")]');
if ($challengeForm->length <= 0) {
throw new \RuntimeException('in "verify yoour recovery email challenge", could not find challenge POST html form!');
}
if ($challengeForm->length > 1) {
// google changed something, xpath needs an update..
throw new \RuntimeException("in verify yoour recovery email challenge, could not determine which POST html form was the correct 1!");
}
$challengeForm = $challengeForm->item(0);
$base_url = $hc->getinfo(CURLINFO_EFFECTIVE_URL);
$relative_url = $challengeForm->getAttribute("action");
$url = merge_relative_absolute_urls($base_url, $relative_url);
//hhb_var_dump($base_url,$relative_url,$url) & die();
$inputs = getDOMDocumentFormInputs($domd, true, false);
if (count($inputs) !== 2) {
throw new \LogicException("GOOGLE CHANGED SOMETHING, SUPPOSED TO BE 2x FORM INPUTS HERE (and i only care about the first 1...)");
}
var_export($inputs);
//hhb_var_dump($inputs) & die();
$inputs[0];
$hc->setopt_array(array(
CURLOPT_URL=>$url,
CURLOPT_POST=>1,
CURLOPT_POSTFIELDS=>$inputs,
))->exec();
hhb_var_dump ( $hc->getStdErr (), $hc->getStdOut (), $inputs ) & die ();
die("FIXME RECOVERY EMAIL CHALLENGE");
}