Beispiel #1
0
 /**
  * Construct a CSRF guard hidden field. You should provide the name of the csrf guard as second parameter here.
  * @param jWidget $Parent
  */
 function __construct(jWidget $Parent, $Name)
 {
     $this->__setname($Name);
     parent::__construct($Parent);
     $this->SetValidation(function ($Data) use($Name) {
         return jf::LoadSessionSetting(jFormCsrf::SettingNamePrefix . $Name) == $Data;
     });
 }
Beispiel #2
0
 /**
  * Checks if CAPTCHA is valid or not. Caches the status so no matter how many times in one instance of application
  * it is checked, it returns true.
  * @param unknown_type $Data
  * @return NULL
  */
 function Validate($Data)
 {
     if ($this->isValid === null) {
         $this->isValid = strtolower($Data) == strtolower(jf::LoadSessionSetting(jFormCaptcha::SettingNamePrefix . $this->Name()));
         jf::DeleteSessionSetting(jFormCaptcha::SettingNamePrefix . $this->Name());
     }
     return $this->isValid;
 }
Beispiel #3
0
 /**
  * Get the stored session data
  *
  * @param string|int $key The key associated with the value
  *
  * @return mixed    The stored data
  * @throws ArgumentMissingException If $key is missing
  */
 protected function getSessionData($key = null)
 {
     if ($key == null) {
         throw new ArgumentMissingException('Missing key to get session data');
     }
     return \jf::LoadSessionSetting($key);
 }
Beispiel #4
0
 /**
  * @depends testLoadSession
  */
 function testSaveSessionTimeOut()
 {
     $this->assertTrue(jf::SaveSessionSetting("some_name", "some_value", jf\Timeout::DAY));
     $this->movetime(jf\Timeout::DAY + 1);
     jf::$Settings->_Sweep(true);
     $this->assertNull(jf::LoadSessionSetting("some_name"));
     $this->assertTrue(jf::SaveSessionSetting("some_name2", "some_value", 1));
     $this->movetime(jf\Timeout::YEAR * 10);
     $this->assertNotNull(jf::LoadSessionSetting("some_name2", 1));
     $this->movetime(0);
     $this->movetime(jf\Timeout::NEVER - jf::time());
     $this->assertEquals(jf::time(), 2147483647);
     jf::$Settings->_Sweep(true);
     $this->assertNull(jf::LoadSessionSetting("some_name2", 1));
 }