/**
  * Create a new onetimecall
  * @param \System\Db\Database The database to query
  * @param string The key which we should use to find the appropriate callback
  * @param string The value to reference the object with
  * @return \Module\Onetimecall\Onetimecall the newly created instance
  */
 public static function create(\System\Db\Database $db, $key, $value)
 {
     $hash = new \System\Security\Hash();
     $hash->addString(\System\Calendar\Time::now());
     $token = $hash->getHash();
     $query = new \System\Db\Query($db, SQL_ONETIMECALL_CREATE);
     $query->bind($token, \System\Db\QueryType::TYPE_STRING);
     $query->bind($key, \System\Db\QueryType::TYPE_STRING);
     $query->bind((string) $value, \System\Db\QueryType::TYPE_STRING);
     $db->query($query);
     $insertId = $db->getInsertId();
     return \Module\Onetimecall\Onetimecall::loadPrimary($db, $insertId);
 }
Exemple #2
0
 /**
  * Creates a fingerprint of the entire system and returns it as an encoded json string. This fingerprint only gives information about the system version.
  * By using this fingerprint, we can identify the versions used in the currently deployed build
  * Note that the used encryption is not a secure one.
  * @param string The key used to encode the resultset and generate the hashes. This key is required for decryption.
  * @return string The encoded fingerprint
  */
 public static final function getSystemFingerprint($encodeKey = \System\Version::FINGERPRINT_KEY)
 {
     $baseDir = PATH_SYSTEM;
     $files = \System\IO\Directory::walkDir($baseDir, new \System\Collection\Vector('php'));
     $map = new \System\Collection\Map();
     foreach ($files as $file) {
         $hash = new \System\Security\Hash(\System\Security\Hash::HASH_SHA512);
         $hash->addFile($file);
         $map[\System\Security\Base64Encoding::Base64Encode($file->stripBase(PATH_SYSTEM), $encodeKey)] = $hash->getHash();
     }
     $jsonObject = json_encode($map->getArrayCopy());
     $encoded = \System\Security\XOREncoding::XOREncrypt($jsonObject, $encodeKey);
     return $encoded;
 }