public function setBillingPeriod($billingPeriod) { $this->set('billingPeriod', $billingPeriod); switch ($this->billingPeriod) { case self::BILLING_PERIOD_YEAR: $this->duration = AnHelperDate::yearToSeconds(); break; case self::BILLING_PERIOD_MONTH: $this->duration = AnHelperDate::monthToSeconds(); break; case self::BILLING_PERIOD_WEEK: $this->duration = AnHelperDate::weekToSeconds(); break; case self::BILLING_PERIOD_DAY: $this->duration = AnHelperDate::dayToSeconds(); break; } }
/** * Logs in a user * * @param array $user The user as an array * @param boolean $remember Flag to whether remember the user or not * * @return boolean */ public function login(array $user, $remember = false) { $session =& JFactory::getSession(); // we fork the session to prevent session fixation issues $session->fork(); JFactory::getApplication()->_createSession($session->getId()); // Import the user plugin group JPluginHelper::importPlugin('user'); $options = array(); $results = JFactory::getApplication()->triggerEvent('onLoginUser', array($user, $options)); foreach ($results as $result) { if ($result instanceof JException || $result instanceof Exception || $result === false) { return false; } } //if remember is true, create a remember cookie that contains the ecrypted username and password if ($remember) { // Set the remember me cookie if enabled jimport('joomla.utilities.simplecrypt'); jimport('joomla.utilities.utility'); $key = JUtility::getHash(KRequest::get('server.HTTP_USER_AGENT', 'raw')); if ($key) { $crypt = new JSimpleCrypt($key); $cookie = $crypt->encrypt(serialize(array('username' => $user['username'], 'password' => $user['password']))); $lifetime = time() + AnHelperDate::yearToSeconds(); setcookie(JUtility::getHash('JLOGIN_REMEMBER'), $cookie, $lifetime, '/'); } } return true; }