summaryrefslogtreecommitdiffstats
path: root/app/class/object.class.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/class/object.class.php')
-rw-r--r--app/class/object.class.php25
1 files changed, 23 insertions, 2 deletions
diff --git a/app/class/object.class.php b/app/class/object.class.php
index bcd8dfa..96cc810 100644
--- a/app/class/object.class.php
+++ b/app/class/object.class.php
@@ -77,6 +77,8 @@ abstract class Object extends Framework
{
if (isset($this->guid))
{
+ $this->timeUpdated = $this->getCurrentTimestamp();
+
/* Update Base */
$updateStr = "";
@@ -117,6 +119,8 @@ abstract class Object extends Framework
else
{
$this->guid = $this->getNewGUID();
+ $this->timeCreated = $this->getCurrentTimestamp();
+ $this->timeUpdated = $this->timeCreated;
/* Insert Base */
$colsStr = "";
@@ -180,6 +184,16 @@ abstract class Object extends Framework
}
/*
+ * Get current timestamp for object database purposes
+ */
+ function getCurrentTimestamp()
+ {
+ $query = "SELECT now() AS stamp";
+ $result = $this->db->query($query);
+ return $result[0]['stamp'];
+ }
+
+ /*
* Check whether given GUID exists
*/
function isGUID($guid)
@@ -200,13 +214,20 @@ abstract class Object extends Framework
{
do
{
- $sha = hash("sha256", rand());
- $guid = substr($sha, 0, 8);
+ $guid = substr($this->getBlob(), 0, 8);
}
while ($this->isGUID($guid));
return $guid;
}
+
+ /*
+ * Get a random sha256 blob
+ */
+ function getBlob()
+ {
+ return hash("sha256", openssl_random_pseudo_bytes(64));
+ }
}
/*