1
0
mirror of https://github.com/Yubico/yubikey-val.git synced 2025-02-20 21:54:20 +01:00

getRowValue is not needed anymore

This commit is contained in:
Remi Mollon 2012-06-28 14:55:00 +02:00
parent b29d0ecdff
commit f9e1a3a883
5 changed files with 47 additions and 61 deletions

View File

@ -38,14 +38,14 @@ $result=$db->customQuery("SELECT id, active, secret ".
"FROM clients ".
"ORDER BY id");
while($row = $db->fetchArray($result)) {
$active = $db->getRowValue($row, 'active');
$active = $row['active'];
if ($active == "") {
# For some reason PostgreSQL returns empty strings for false values?!
$active = "0";
}
$everything = $everything .
$db->getRowValue($row, 'id') . "\t" . $active . "\t" .
$db->getRowValue($row, 'secret') . "\n";
$row['id'] . "\t" . $active . "\t" .
$row['secret'] . "\n";
}
$db->closeCursor($result);

View File

@ -205,20 +205,6 @@ class DbImpl extends Db
return 0;
}
}
/**
* Function to return the value corresponding to a given attribute name
* PDO requires lower case strings, whereas OCI requires upper case strings
*
* @param array $row Query result's row
* @param string $key Attribute name
* @return string Value of the attribute in this row
*
*/
public function getRowValue($row, $key)
{
return $row[$key];
}
}

View File

@ -19,13 +19,13 @@ if (!$db->connect()) {
$result = $db->customQuery("select id, active, created, secret, email, notes, otp from clients order by id");
while($row = $db->fetchArray($result)) {
echo $db->getRowValue($row, 'id') .
"\t" . $db->getRowValue($row, 'active') .
"\t" . $db->getRowValue($row, 'created') .
"\t" . $db->getRowValue($row, 'secret') .
"\t" . $db->getRowValue($row, 'email') .
"\t" . $db->getRowValue($row, 'notes') .
"\t" . $db->getRowValue($row, 'otp') .
echo $row['id'] .
"\t" . $row['active'] .
"\t" . $row['created'] .
"\t" . $row['secret'] .
"\t" . $row['email'] .
"\t" . $row['notes'] .
"\t" . $row['otp'] .
"\n";
}

View File

@ -19,16 +19,16 @@ if (!$db->connect()) {
$result=$db->customQuery("SELECT active, created, modified, yk_publicname, yk_counter, yk_use, yk_low, yk_high, nonce, notes FROM yubikeys ORDER BY yk_publicname");
while($row = $db->fetchArray($result)){
echo $db->getRowValue($row, 'active') .
"\t" . $db->getRowValue($row, 'created') .
"\t" . $db->getRowValue($row, 'modified') .
"\t" . $db->getRowValue($row, 'yk_publicname') .
"\t" . $db->getRowValue($row, 'yk_counter') .
"\t" . $db->getRowValue($row, 'yk_use') .
"\t" . $db->getRowValue($row, 'yk_low') .
"\t" . $db->getRowValue($row, 'yk_high') .
"\t" . $db->getRowValue($row, 'nonce') .
"\t" . $db->getRowValue($row, 'notes') .
echo $row['active'] .
"\t" . $row['created'] .
"\t" . $row['modified'] .
"\t" . $row['yk_publicname'] .
"\t" . $row['yk_counter'] .
"\t" . $row['yk_use'] .
"\t" . $row['yk_low'] .
"\t" . $row['yk_high'] .
"\t" . $row['nonce'] .
"\t" . $row['notes'] .
"\n";
}

View File

@ -155,14 +155,14 @@ class SyncLib
$res=$this->db->findBy('yubikeys', 'yk_publicname', $yk_publicname,1);
}
if ($res) {
$localParams=array('modified' => $this->db->getRowValue($res, 'modified'),
'nonce' => $this->db->getRowValue($res, 'nonce'),
'active' => $this->db->getRowValue($res, 'active'),
$localParams=array('modified' => $res['modified'],
'nonce' => $res['nonce'],
'active' => $res['active'],
'yk_publicname' => $yk_publicname,
'yk_counter' => $this->db->getRowValue($res, 'yk_counter'),
'yk_use' => $this->db->getRowValue($res, 'yk_use'),
'yk_high' => $this->db->getRowValue($res, 'yk_high'),
'yk_low' => $this->db->getRowValue($res, 'yk_low'));
'yk_counter' => $res['yk_counter'],
'yk_use' => $res['yk_use'],
'yk_high' => $res['yk_high'],
'yk_low' => $res['yk_low']);
$this->log(LOG_INFO, "yubikey found in db ", $localParams);
return $localParams;
@ -288,15 +288,15 @@ class SyncLib
while ($my_server=$this->db->fetchArray($server_res)) {
$this->log(LOG_INFO, "Sending queue request to server on server " . $this->db->getRowValue($my_server, 'server'));
$res=$this->db->customQuery("select * from queue WHERE (queued < " . $queued_limit . " or queued is null) and server='" . $this->db->getRowValue($my_server, 'server') . "'");
$this->log(LOG_INFO, "Sending queue request to server on server " . $my_server['server']);
$res=$this->db->customQuery("select * from queue WHERE (queued < " . $queued_limit . " or queued is null) and server='" . $my_server['server'] . "'");
$ch = curl_init();
while ($entry=$this->db->fetchArray($res)) {
$this->log(LOG_INFO, "server=" . $this->db->getRowValue($entry, 'server') . " , info=" . $this->db->getRowValue($entry, 'info'));
$url=$this->db->getRowValue($entry, 'server') .
"?otp=" . $this->db->getRowValue($entry, 'otp') .
"&modified=" . $this->db->getRowValue($entry, 'modified') .
"&" . $this->otpPartFromInfoString($this->db->getRowValue($entry, 'info'));
$this->log(LOG_INFO, "server=" . $entry['server'] . " , info=" . $entry['info']);
$url=$entry['server'] .
"?otp=" . $entry['otp'] .
"&modified=" . $entry['modified'] .
"&" . $this->otpPartFromInfoString($entry['info']);
/* Send out sync request */
$this->log(LOG_DEBUG, 'url is ' . $url);
@ -309,7 +309,7 @@ class SyncLib
$response = curl_exec($ch);
if ($response==False) {
$this->log(LOG_NOTICE, 'Timeout. Stopping queue resync for server ' . $this->db->getRowValue($entry, 'server'));
$this->log(LOG_NOTICE, 'Timeout. Stopping queue resync for server ' . $entry['server']);
break;
}
@ -322,8 +322,8 @@ class SyncLib
/* Retrieve info from entry info string */
$validationParams=$this->localParamsFromInfoString($this->db->getRowValue($entry, 'info'));
$otpParams=$this->otpParamsFromInfoString($this->db->getRowValue($entry, 'info'));
$validationParams=$this->localParamsFromInfoString($entry['info']);
$otpParams=$this->otpParamsFromInfoString($entry['info']);
$localParams=$this->getLocalParams($otpParams['yk_publicname']);
$this->log(LOG_DEBUG, "validation params: ", $validationParams);
@ -356,13 +356,13 @@ class SyncLib
}
/* Deletion */
$this->log(LOG_INFO, 'deleting queue entry with modified=' . $this->db->getRowValue($entry, 'modified') .
' server_nonce=' . $this->db->getRowValue($entry, 'server_nonce') .
' server=' . $this->db->getRowValue($entry, 'server'));
$this->log(LOG_INFO, 'deleting queue entry with modified=' . $entry['modified'] .
' server_nonce=' . $entry['server_nonce'] .
' server=' . $entry['server']);
$this->db->deleteByMultiple('queue',
array("modified"=>$this->db->getRowValue($entry, 'modified'),
"server_nonce"=>$this->db->getRowValue($entry, 'server_nonce'),
'server'=>$this->db->getRowValue($entry, 'server')));
array("modified"=>$entry['modified'],
"server_nonce"=>$entry['server_nonce'],
'server'=>$entry['server']));
} else {
$this->log(LOG_ERR, "Remote server refused our sync request. Check remote server logs.");
}
@ -384,10 +384,10 @@ class SyncLib
$urls=array();
$res=$this->db->findByMultiple('queue', array("modified"=>$this->otpParams['modified'], "server_nonce"=>$this->server_nonce));
foreach($res as $row) {
$urls[]=$this->db->getRowValue($row, 'server') .
"?otp=" . $this->db->getRowValue($row, 'otp') .
"&modified=" . $this->db->getRowValue($row, 'modified') .
"&" . $this->otpPartFromInfoString($this->db->getRowValue($row, 'info'));
$urls[]=$row['server'] .
"?otp=" . $row['otp'] .
"&modified=" . $row['modified'] .
"&" . $this->otpPartFromInfoString($row['info']);
}
/*