";
$fields['sessionid'] = $sessionid;
//print "All fields: ";
foreach ($fields as $value) {
//echo $value;
}
$POSTFIELDS = http_build_query($fields);
curl_setopt($ch, CURLOPT_POSTFIELDS, $POSTFIELDS);
// get result
$result = curl_exec($ch);
//print "result: ".$result;
$json = json_decode($result, true);
function findHash($item, $key)
{
if($key == 'kd_hash'){
$kd_hash=trim($item);
print $kd_hash;
}
}
array_walk_recursive($json, 'findHash');
//print "extracted kd_hash: ".$kd_hash;
function getFormFields($data)
{
if (preg_match('/(
)/is', $data, $matches)) {
$inputs = getInputs($matches[1]);
foreach($inputs as $value){
// echo $value;
}
return $inputs;
} else {
//print $data;
# die('didnt find login form');
}
// print "inputs: ".$inputs;
}
function getInputs($form)
{
$inputs = array();
$elements = preg_match_all('/(]+>)/is', $form, $matches);
if ($elements > 0) {
for($i = 0; $i < $elements; $i++) {
$el = preg_replace('/\s{2,}/', ' ', $matches[1][$i]);
if (preg_match('/name=(?:["\'])?([^"\'\s]*)/i', $el, $name)) {
$name = $name[1];
$value = '';
if (preg_match('/value=(?:["\'])?([^"\'\s]*)/i', $el, $value)) {
$value = $value[1];
}
$inputs[$name] = $value;
}
}
}
return $inputs;
}