1
0
mirror of https://github.com/Yubico/yubikey-val.git synced 2025-02-21 15:54:15 +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 ". "FROM clients ".
"ORDER BY id"); "ORDER BY id");
while($row = $db->fetchArray($result)) { while($row = $db->fetchArray($result)) {
$active = $db->getRowValue($row, 'active'); $active = $row['active'];
if ($active == "") { if ($active == "") {
# For some reason PostgreSQL returns empty strings for false values?! # For some reason PostgreSQL returns empty strings for false values?!
$active = "0"; $active = "0";
} }
$everything = $everything . $everything = $everything .
$db->getRowValue($row, 'id') . "\t" . $active . "\t" . $row['id'] . "\t" . $active . "\t" .
$db->getRowValue($row, 'secret') . "\n"; $row['secret'] . "\n";
} }
$db->closeCursor($result); $db->closeCursor($result);

View File

@ -205,20 +205,6 @@ class DbImpl extends Db
return 0; 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"); $result = $db->customQuery("select id, active, created, secret, email, notes, otp from clients order by id");
while($row = $db->fetchArray($result)) { while($row = $db->fetchArray($result)) {
echo $db->getRowValue($row, 'id') . echo $row['id'] .
"\t" . $db->getRowValue($row, 'active') . "\t" . $row['active'] .
"\t" . $db->getRowValue($row, 'created') . "\t" . $row['created'] .
"\t" . $db->getRowValue($row, 'secret') . "\t" . $row['secret'] .
"\t" . $db->getRowValue($row, 'email') . "\t" . $row['email'] .
"\t" . $db->getRowValue($row, 'notes') . "\t" . $row['notes'] .
"\t" . $db->getRowValue($row, 'otp') . "\t" . $row['otp'] .
"\n"; "\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"); $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)){ while($row = $db->fetchArray($result)){
echo $db->getRowValue($row, 'active') . echo $row['active'] .
"\t" . $db->getRowValue($row, 'created') . "\t" . $row['created'] .
"\t" . $db->getRowValue($row, 'modified') . "\t" . $row['modified'] .
"\t" . $db->getRowValue($row, 'yk_publicname') . "\t" . $row['yk_publicname'] .
"\t" . $db->getRowValue($row, 'yk_counter') . "\t" . $row['yk_counter'] .
"\t" . $db->getRowValue($row, 'yk_use') . "\t" . $row['yk_use'] .
"\t" . $db->getRowValue($row, 'yk_low') . "\t" . $row['yk_low'] .
"\t" . $db->getRowValue($row, 'yk_high') . "\t" . $row['yk_high'] .
"\t" . $db->getRowValue($row, 'nonce') . "\t" . $row['nonce'] .
"\t" . $db->getRowValue($row, 'notes') . "\t" . $row['notes'] .
"\n"; "\n";
} }

View File

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