diff options
| author | Malf Furious <m@lfurio.us> | 2016-02-07 14:01:22 -0500 | 
|---|---|---|
| committer | Malf Furious <m@lfurio.us> | 2016-02-07 14:01:22 -0500 | 
| commit | 72e37180b69db2c067b926b54c64e1989bef0be4 (patch) | |
| tree | d5e76f4894d3822f1923464c641c63fa283bdd2b /app/class/object.class.php | |
| parent | 43ca317ea7d49396eb2958a38aed8b737ef4186b (diff) | |
| parent | c5564a0a2ae183c533a38905eccdbf383030cd4c (diff) | |
| download | scrott-72e37180b69db2c067b926b54c64e1989bef0be4.tar.gz scrott-72e37180b69db2c067b926b54c64e1989bef0be4.zip | |
Merge branch 'auth' into dev
Diffstat (limited to '')
| -rw-r--r-- | app/class/object.class.php | 25 | 
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)); +    }  }  /* | 
