1
0
mirror of https://github.com/Yubico/yubikey-val.git synced 2025-02-01 10:52:18 +01:00
This commit is contained in:
Olov Danielson 2010-01-25 18:01:30 +00:00
parent 4551dff93d
commit dcce9b6644

View File

@ -35,21 +35,31 @@ while ($res=fscanf(STDIN, "%d\t%d\t%d\t%s\t%d\t%d\t%d\t%d\t%s\t%s\t")) {
"nonce"=>$res[8], "nonce"=>$res[8],
"notes"=>$res[9]); "notes"=>$res[9]);
$query="UPDATE yubikeys SET " .
"active='" . $params["active"] . "' " .
",created='" . $params["created"] . "' " .
",modified='" . $params["modified"] . "' " .
",yk_counter='" . $params["yk_counter"] . "' " .
",yk_use='" . $params["yk_use"] . "' " .
",yk_low='" . $params["yk_low"] . "' " .
",yk_high='" . $params["yk_high"] . "' " .
",nonce='" . $params["nonce"] . "' " .
",notes='" . $params["notes"] . "' " .
"WHERE yk_publicname='" . $params['yk_publicname'] . "' AND " .
"(".$params['yk_counter'].">yk_counter or (".$params['yk_counter']."=yk_counter and " .
$params['yk_use'] . ">yk_use))";
if(!$db->customQuery($query)) { $query="SELECT * FROM yubikeys WHERE yk_publicname='" . $params['yk_publicname'] . "'";
$result=$db->customQuery($query);
if($result->fetch(PDO::FETCH_ASSOC)) {
$query="UPDATE yubikeys SET " .
"active='" . $params["active"] . "' " .
",created='" . $params["created"] . "' " .
",modified='" . $params["modified"] . "' " .
",yk_counter='" . $params["yk_counter"] . "' " .
",yk_use='" . $params["yk_use"] . "' " .
",yk_low='" . $params["yk_low"] . "' " .
",yk_high='" . $params["yk_high"] . "' " .
",nonce='" . $params["nonce"] . "' " .
",notes='" . $params["notes"] . "' " .
"WHERE yk_publicname='" . $params['yk_publicname'] . "' AND " .
"(".$params['yk_counter'].">yk_counter or (".$params['yk_counter']."=yk_counter and " .
$params['yk_use'] . ">yk_use))";
if(!$db->customQuery($query)) {
$myLog->log(LOG_ERR, "Failed to update yk_publicname with query " . $query);
error_log("Failed to update yk_publicname with query " . $query);
exit(1);
}
} else {
// We didn't have the yk_publicname in database so we need to do insert instead // We didn't have the yk_publicname in database so we need to do insert instead
$query="INSERT INTO yubikeys " . $query="INSERT INTO yubikeys " .
"(active,created,modified,yk_publicname,yk_counter,yk_use,yk_low,yk_high,nonce,notes) VALUES " . "(active,created,modified,yk_publicname,yk_counter,yk_use,yk_low,yk_high,nonce,notes) VALUES " .