mirror of
https://github.com/Yubico/yubikey-val.git
synced 2025-02-27 06:54:16 +01:00
Revert "Removed dead code."
This reverts commit 29deb6007dd66a47ab9275687fcac140a228e404. PHP functions are __not__ case-sensitive!
This commit is contained in:
parent
6e4b89048e
commit
b4f9bd4939
@ -91,6 +91,19 @@ function getUTCTimeStamp() {
|
|||||||
return date('Y-m-d\TH:i:s\Z0', time()) . $tiny;
|
return date('Y-m-d\TH:i:s\Z0', time()) . $tiny;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# NOTE: When we evolve to using general DB-interface, this functinality
|
||||||
|
# should be moved there.
|
||||||
|
function DbTimeToUnix($db_time)
|
||||||
|
{
|
||||||
|
$unix=strptime($db_time, '%F %H:%M:%S');
|
||||||
|
return mktime($unix[tm_hour], $unix[tm_min], $unix[tm_sec], $unix[tm_mon]+1, $unix[tm_mday], $unix[tm_year]+1900);
|
||||||
|
}
|
||||||
|
|
||||||
|
function UnixToDbTime($unix)
|
||||||
|
{
|
||||||
|
return date('Y-m-d H:i:s', $unix);
|
||||||
|
}
|
||||||
|
|
||||||
// Sign a http query string in the array of key-value pairs
|
// Sign a http query string in the array of key-value pairs
|
||||||
// return b64 encoded hmac hash
|
// return b64 encoded hmac hash
|
||||||
function sign($a, $apiKey, $logger) {
|
function sign($a, $apiKey, $logger) {
|
||||||
@ -107,6 +120,16 @@ function sign($a, $apiKey, $logger) {
|
|||||||
|
|
||||||
} // sign an array of query string
|
} // sign an array of query string
|
||||||
|
|
||||||
|
function hex2b64 ($hex_str) {
|
||||||
|
$bin = pack("H*", $hex_str);
|
||||||
|
return base64_encode($bin);
|
||||||
|
}
|
||||||
|
|
||||||
|
function modhex2b64 ($modhex_str) {
|
||||||
|
$hex_str = strtr ($modhex_str, "cbdefghijklnrtuv", "0123456789abcdef");
|
||||||
|
return hex2b64($hex_str);
|
||||||
|
}
|
||||||
|
|
||||||
function curl_settings($logger, $ident, $handle, $url, $timeout, $curlopts) {
|
function curl_settings($logger, $ident, $handle, $url, $timeout, $curlopts) {
|
||||||
//configure "hard" options
|
//configure "hard" options
|
||||||
$logger->log(LOG_DEBUG, $ident . " adding URL : " . $url);
|
$logger->log(LOG_DEBUG, $ident . " adding URL : " . $url);
|
||||||
|
@ -126,6 +126,11 @@ class DbImpl extends Db
|
|||||||
if($result) $result->closeCursor();
|
if($result) $result->closeCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function truncateTable($name)
|
||||||
|
{
|
||||||
|
$this->query("TRUNCATE TABLE " . $name);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* main function used to get rows by multiple key=>value pairs from Db table.
|
* main function used to get rows by multiple key=>value pairs from Db table.
|
||||||
*
|
*
|
||||||
|
65
ykval-db.php
65
ykval-db.php
@ -58,6 +58,33 @@ abstract class Db
|
|||||||
$this->myLog->addField($name, $value);
|
$this->myLog->addField($name, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* function to convert Db timestamps to unixtime(s)
|
||||||
|
*
|
||||||
|
* @param string $updated Database timestamp
|
||||||
|
* @return int Timestamp in unixtime format
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function timestampToTime($updated)
|
||||||
|
{
|
||||||
|
$stamp=strptime($updated, '%F %H:%M:%S');
|
||||||
|
return mktime($stamp[tm_hour], $stamp[tm_min], $stamp[tm_sec], $stamp[tm_mon]+1, $stamp[tm_mday], $stamp[tm_year]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* function to compute delta (s) between 2 Db timestamps
|
||||||
|
*
|
||||||
|
* @param string $first Database timestamp 1
|
||||||
|
* @param string $second Database timestamp 2
|
||||||
|
* @return int Deltatime (s)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function timestampDeltaTime($first, $second)
|
||||||
|
{
|
||||||
|
return Db::timestampToTime($second) - Db::timestampToTime($first);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* function to disconnect from database
|
* function to disconnect from database
|
||||||
*
|
*
|
||||||
@ -81,6 +108,11 @@ abstract class Db
|
|||||||
else return False;
|
else return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function truncateTable($name)
|
||||||
|
{
|
||||||
|
$this->query("TRUNCATE TABLE " . $name);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* function to update row in database by a where condition
|
* function to update row in database by a where condition
|
||||||
*
|
*
|
||||||
@ -235,4 +267,37 @@ or false on failure.
|
|||||||
{
|
{
|
||||||
return $this->query($query, true);
|
return $this->query($query, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* helper function used to get rows from Db table in reversed order.
|
||||||
|
* defaults to obtaining 1 row.
|
||||||
|
*
|
||||||
|
* @param string $table Database table to update row in
|
||||||
|
* @param string $key Column to select rows by
|
||||||
|
* @param string $value Value to select rows by
|
||||||
|
* @param int $nr Number of rows to collect. NULL=>inifinity. Default=1.
|
||||||
|
* @return mixed Array with values from Db row or 2d-array with multiple rows or false on failure.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function lastBy($table, $key, $value, $nr=1)
|
||||||
|
{
|
||||||
|
return Db::findBy($table, $key, $value, $nr, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* helper function used to get rows from Db table in standard order.
|
||||||
|
* defaults to obtaining 1 row.
|
||||||
|
*
|
||||||
|
* @param string $table Database table to update row in
|
||||||
|
* @param string $key Column to select rows by
|
||||||
|
* @param string $value Value to select rows by
|
||||||
|
* @param int $nr Number of rows to collect. NULL=>inifinity. Default=1.
|
||||||
|
* @return mixed Array with values from Db row or 2d-array with multiple rows or false on failure.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function firstBy($table, $key, $value, $nr=1)
|
||||||
|
{
|
||||||
|
return Db::findBy($table, $key, $value, $nr);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -63,6 +63,25 @@ class SyncLib
|
|||||||
return $this->isConnected;
|
return $this->isConnected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function DbTimeToUnix($db_time)
|
||||||
|
{
|
||||||
|
$unix=strptime($db_time, '%F %H:%M:%S');
|
||||||
|
return mktime($unix[tm_hour], $unix[tm_min], $unix[tm_sec], $unix[tm_mon]+1, $unix[tm_mday], $unix[tm_year]+1900);
|
||||||
|
}
|
||||||
|
|
||||||
|
function UnixToDbTime($unix)
|
||||||
|
{
|
||||||
|
return date('Y-m-d H:i:s', $unix);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getServer($index)
|
||||||
|
{
|
||||||
|
if (isset($this->syncServers[$index]))
|
||||||
|
return $this->syncServers[$index];
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
function getClientData($client)
|
function getClientData($client)
|
||||||
{
|
{
|
||||||
$res = $this->db->customQuery("SELECT id, secret FROM clients WHERE active='1' AND id='" . $client . "'");
|
$res = $this->db->customQuery("SELECT id, secret FROM clients WHERE active='1' AND id='" . $client . "'");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user