1
0
mirror of https://github.com/Yubico/yubikey-val.git synced 2024-11-29 00:24:13 +01:00

Refactor updateDbCounters.

- make it easier to follow what is happening.
This commit is contained in:
Jean Paul Galea 2015-07-15 16:46:45 +02:00
parent 3b4735d34d
commit d5a56f6b8c

View File

@ -263,24 +263,33 @@ class SyncLib
{
if (isset($params['yk_publicname'])) {
$condition='('.$params['yk_counter'].'>yk_counter or ('.$params['yk_counter'].'=yk_counter and ' . $params['yk_use'] . '>yk_use))' ;
if(! $this->db->conditionalUpdateBy('yubikeys', 'yk_publicname', $params['yk_publicname'],
array('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']),
$condition))
{
$this->log(LOG_CRIT, 'failed to update internal DB with new counters');
return false;
} else
{
if ($this->db->rowCount()>0) $this->log(LOG_INFO, "updated database ", $params);
else $this->log(LOG_INFO, 'database not updated', $params);
return true;
}
} else return false;
$arr = array(
'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']
);
if (! $this->db->conditionalUpdateBy('yubikeys', 'yk_publicname', $params['yk_publicname'], $arr, $condition))
{
$this->log(LOG_CRIT, 'failed to update internal DB with new counters');
return false;
}
else
{
if ($this->db->rowCount()>0)
$this->log(LOG_INFO, "updated database ", $params);
else
$this->log(LOG_INFO, 'database not updated', $params);
return true;
}
}
return false;
}
public function countersHigherThan($p1, $p2)