Exemplo n.º 1
0
 /**
  * Get the key for hashing
  * 
  * @return string
  */
 private static function getKey()
 {
     if (static::$key === null) {
         static::$key = Application::getConfig('application', 'key');
     }
     return static::$key;
 }
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     // make completely random key/bucket based on time
     static::$key = md5(rand(0, 99) . time());
     static::$bucket = md5(rand(0, 99) . time());
 }
Exemplo n.º 3
0
 /**
  * Get the Datastore key, as stored in the datastore configuration file.
  *
  * @return   string           Returns the datastore key
  */
 public static function key()
 {
     if (static::$key === false) {
         static::$key = Config::get('datastore.key');
     }
     return static::$key;
 }
Exemplo n.º 4
0
 protected static function getKey()
 {
     if (!static::$key) {
         static::$key = static::$cachePrefix . '_' . static::getClientIp();
     }
     return static::$key;
 }
Exemplo n.º 5
0
 public static function init()
 {
     if (!ctype_xdigit(Config::get('encryption.cipher'))) {
         throw new Exception('Change your cipher code in app/config/encryption.php file!');
     }
     static::$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
     static::$key = pack('H*', Config::get('encryption.cipher'));
 }
Exemplo n.º 6
0
 /**
  * Magic method called when a class is first encountered by the Autoloader,
  * providing static initialization.
  *
  * @return   void             No value is returned
  */
 public static function __initialize()
 {
     if ((static::$key = Config::get('crypt.key')) == '') {
         throw new \Exception('The Crypt class cannot be used without providing a shared key. Please specify on in your crypt configuration file');
     }
     static::$defaultDriver = Config::get('crypt.driver', 'xcrypt');
     static::$hasher = Config::get('crypt.hasher', 'sha1');
     static::$key = md5(static::$key);
 }
Exemplo n.º 7
0
 /**
  * Constructor.
  *
  * @access  protected
  */
 protected function __construct()
 {
     // Set current time
     static::$now = time();
     // Cache key allows us to invalidate all cache on configuration changes.
     static::$key = (Config::get('system.cache.prefix') ? Config::get('system.cache.prefix') : 'fansoro') . '-' . md5(ROOT_DIR . Fansoro::VERSION);
     // Get Cache Driver
     static::$driver = static::getCacheDriver();
     // Set the cache namespace to our unique key
     static::$driver->setNamespace(static::$key);
 }
Exemplo n.º 8
0
 /**
  * Sets up the fixture.
  *
  * This method is called before a test is executed.
  *
  * @return  void
  *
  * @since   1.0
  */
 protected function setUp()
 {
     if (empty(static::$object)) {
         $this->markTestSkipped('There is no caching engine.');
     }
     $key = md5(date(DATE_RFC2822));
     $value = 'Test value';
     static::$key = $key;
     static::$value = $value;
     static::$sessionName = 'SessionName';
     static::$sessionPath = 'SessionPath';
     static::$className = get_class(static::$object);
     parent::setUp();
 }
Exemplo n.º 9
0
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     // make completely random key based on time
     static::$key = md5(rand(0, 99) . time());
     try {
         // Skip this suite if the "hlls" bucket type is not present
         $command = (new Command\Builder\FetchBucketProperties(static::$riak))->buildBucket('test', static::HLL_BUCKET_TYPE)->build();
         $response = $command->execute();
         if (!$response->isSuccess() || $response->getCode() != 200) {
             throw new \PHPUnit_Framework_SkippedTestSuiteError("hlls bucket type is not enabled and activated, skipping");
         }
     } catch (\Exception $ex) {
         throw new \PHPUnit_Framework_SkippedTestSuiteError("hlls bucket type is not enabled and activated, skipping");
     }
 }
 public static function setUpBeforeClass()
 {
     // make completely random key based on time
     static::$key = md5(rand(0, 99) . time());
 }
Exemplo n.º 11
0
 /**
  * Update a model instance in the database.
  *
  * @param  mixed  $id
  * @param  array  $attributes
  * @return int
  */
 public static function update($id, $attributes)
 {
     $model = new static(array(), true);
     if (static::$timestamps) {
         $attributes['updated_at'] = new \DateTime();
     }
     return $model->query()->where($model->key(), '=', $id)->update($attributes);
 }
Exemplo n.º 12
0
 /**
  * setKey modifie la clé de cryptage
  *
  * @param string $key
  */
 public static function setkey($key)
 {
     static::$key = $key;
 }
 public static function tearDownAfterClass()
 {
     static::$response_data = null;
     static::$key = null;
 }
Exemplo n.º 14
0
 /**
  * Retrieve key => value pairs using `id` for keys and the given attribute
  * for values.
  * 
  * @param string $attribute
  * @param array  $filter    [optional]
  * @param array  $order     [optional]
  * @param int    $limit     [optional]
  * @param int    $offset    [optional]
  * @return array
  */
 public static function listing($attribute, $filter = array(), $order = array(), $limit = null, $offset = 0)
 {
     $instance = new static();
     $storage = $instance->storage();
     $data = $storage->listing($instance->table(), array($instance->key(), $attribute), $filter, $order, $limit, $offset);
     return static::prepareListing($data, $attribute);
 }
 public static function tearDownAfterClass()
 {
     static::$key = null;
 }
Exemplo n.º 16
0
 /**
  * Transforms the wrapped value.
  *
  * @param string $newValue The new value. If not defined, nothing will change.
  *
  * @return IString The (new) string.
  */
 protected function transformWrappedValue($newValue = null) : IString
 {
     if (\func_num_args() < 1) {
         $newValue = $this->_wrappedValue;
     }
     $result = new static($newValue);
     // try to move to same position
     while ($result->valid()) {
         if ($result->key() === $this->key()) {
             break;
         }
         $result->next();
     }
     return $result;
 }
Exemplo n.º 17
0
 /**
  * @param string $text
  *
  * @return LineInterface
  */
 public static function parse_raw($text)
 {
     $line = new static($text);
     if (!$line->isPair()) {
         return $line;
     }
     return new KeyValue($line->key(), $line->value(), $line->quote());
 }
Exemplo n.º 18
0
 protected static function populateKey()
 {
     static::$now = new \DateTime("@1443816900");
     static::$key = [(new Cell("region"))->setValue("South Atlantic"), (new Cell("state"))->setValue("South Carolina"), (new Cell("time"))->setTimestampValue(static::$now->getTimestamp())];
 }
Exemplo n.º 19
0
 /**
  * Update a model instance in the database.
  *
  * @param  mixed  $id
  * @param  array  $attributes
  * @return int
  */
 public static function update($id, $attributes)
 {
     $model = new static(array(), true);
     $model->fill($attributes);
     if (static::$timestamps) {
         $model->timestamp();
     }
     return $model->query()->where($model->key(), '=', $id)->update($model->attributes);
 }
Exemplo n.º 20
0
 /**
  * Returns the stored url if it was already generated, false otherwise
  *
  * @param string $key
  * @return mixed
  */
 public static function get($url, $full)
 {
     $keyUrl = $url;
     if (is_array($keyUrl)) {
         $keyUrl += static::$extras;
         // prevent different hashs on different orders
         ksort($keyUrl, SORT_STRING);
         // prevent different hashs on different types (int/string/bool)
         foreach ($keyUrl as $key => $val) {
             $keyUrl[$key] = (string) $val;
         }
     }
     static::$key = md5(serialize($keyUrl) . $full);
     if (Configure::read('UrlCache.pageFiles')) {
         static::$type = 'cachePage';
         if (is_array($keyUrl)) {
             $res = array_diff_key($keyUrl, static::$extras);
             if (empty($res)) {
                 static::$type = 'cache';
             }
         }
         if (static::$type === 'cachePage') {
             return isset(static::$cachePage[static::$key]) ? static::$cachePage[static::$key] : false;
         }
     }
     return isset(static::$cache[static::$key]) ? static::$cache[static::$key] : false;
 }