示例#1
0
 /**
  * 
  * Increments a cache entry value by the specified amount.  If the entry
  * does not exist, creates it at zero, then increments it.
  * 
  * @param string $key The entry ID.
  * 
  * @param string $amt The amount to increment by (default +1).  Using
  * negative values is effectively a decrement.
  * 
  * @return int The new value of the cache entry.
  * 
  */
 public function increment($key, $amt = 1)
 {
     if (!$this->_active) {
         return;
     }
     // modify the key to add the prefix
     $key = $this->entry($key);
     // make sure we have a key to increment
     $this->add($key, 0, null, $this->_life);
     // increment it
     $val = $this->_entries->get($key);
     $this->_entries->set($key, $val + $amt);
     // done!
     return $this->_entries->get($key);
 }
示例#2
0
 /**
  * 
  * Increments a cache entry value by the specified amount.  If the entry
  * does not exist, creates it at zero, then increments it.
  * 
  * @param string $key The entry ID.
  * 
  * @param string $amt The amount to increment by (default +1).  Using
  * negative values is effectively a decrement.
  * 
  * @return int The new value of the cache entry.
  * 
  */
 public function increment($key, $amt = 1)
 {
     if (!$this->_active) {
         return;
     }
     // make sure we have a key to increment (the add() method adds the
     // prefix on its own, so no need to use entry() here)
     $this->add($key, 0, null, $this->_life);
     // modify the key to add the prefix
     $key = $this->entry($key);
     // increment it
     $val = $this->_entries->get($key);
     $this->_entries->set($key, $val + $amt);
     // done!
     return $this->_entries->get($key);
 }
示例#3
0
文件: Csrf.php 项目: agentile/foresmo
 /**
  * 
  * Sets the token value to be used in outgoing forms.
  * 
  * @param string $token The new token value.
  * 
  * @return string
  * 
  */
 public function setToken($token)
 {
     $this->_update();
     self::$_session->set('token', $token);
 }
示例#4
0
文件: Auth.php 项目: kalkin/solarphp
 /**
  * 
  * Resets any authentication data in the session.
  * 
  * Typically used for idling, expiration, and logout.  Calls
  * [[php::session_regenerate_id() | ]] to clear previous session, if any
  * exists.
  * 
  * @param string $status A Solar_Auth status string; default is Solar_Auth::ANON.
  * 
  * @param array $info If status is Solar_Auth::VALID, populate properties with this
  * user data, with keys for 'handle', 'email', 'moniker', 'uri', and 
  * 'uid'.  If a key is empty or does not exist, its value is set to null.
  * 
  * @return void
  * 
  */
 public function reset($status = Solar_Auth::ANON, $info = array())
 {
     // canonicalize the status value
     $status = strtoupper($status);
     if ($this->status == self::ANON && $status == self::ANON) {
         // If we are transitioning between anonymous and anonymous,
         // don't attempt to store information which would trigger
         // a session to start
         return;
     }
     // change the current status
     $this->status = $status;
     // change properties
     if ($this->status == Solar_Auth::VALID) {
         // update the timers, leave user info alone
         $now = time();
         $this->initial = $now;
         $this->active = $now;
     } else {
         // clear the timers *and* the user info
         $this->initial = null;
         $this->active = null;
         $info = null;
     }
     $this->_setInfo($info);
     // reset the session id and delete previous session
     $this->_session->regenerateId();
     // cache any messages
     $this->_session->set('status_text', $this->locale($this->status));
 }