示例#1
0
 /**
  * Display method for the raw track data.
  *
  * @param   boolean  $cachable   If true, the view output will be cached
  * @param   array    $urlparams  An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
  *
  * @return  BannersControllerTracks  This object to support chaining.
  *
  * @since   1.5
  * @todo    This should be done as a view, not here!
  */
 public function display($cachable = false, $urlparams = array())
 {
     // Get the document object.
     $vName = 'tracks';
     // Get and render the view.
     if ($view = $this->getView($vName, 'raw')) {
         // Get the model for the view.
         /** @var BannersModelTracks $model */
         $model = $this->getModel($vName);
         // Load the filter state.
         $app = JFactory::getApplication();
         $model->setState('filter.type', $app->getUserState($this->context . '.filter.type'));
         $model->setState('filter.begin', $app->getUserState($this->context . '.filter.begin'));
         $model->setState('filter.end', $app->getUserState($this->context . '.filter.end'));
         $model->setState('filter.category_id', $app->getUserState($this->context . '.filter.category_id'));
         $model->setState('filter.client_id', $app->getUserState($this->context . '.filter.client_id'));
         $model->setState('list.limit', 0);
         $model->setState('list.start', 0);
         $form = $this->input->get('jform', array(), 'array');
         $model->setState('basename', $form['basename']);
         $model->setState('compressed', $form['compressed']);
         $config = JFactory::getConfig();
         $cookie_domain = $config->get('cookie_domain', '');
         $cookie_path = $config->get('cookie_path', '/');
         setcookie(JApplicationHelper::getHash($this->context . '.basename'), $form['basename'], time() + 365 * 86400, $cookie_path, $cookie_domain);
         setcookie(JApplicationHelper::getHash($this->context . '.compressed'), $form['compressed'], time() + 365 * 86400, $cookie_path, $cookie_domain);
         // Push the model into the view (as default).
         $view->setModel($model, true);
         // Push document object into the view.
         $view->document = JFactory::getDocument();
         $view->display();
     }
     return $this;
 }
 protected function hideModule($moduleName)
 {
     $module = JModuleHelper::getModule($moduleName);
     if (is_object($module) and $module->id > 0) {
         $seed = substr(md5(uniqid(time() * rand(), true)), 0, 10);
         $module->position = 'fp' . JApplicationHelper::getHash($seed);
     }
 }
 protected function hideModule($moduleName)
 {
     $module = JModuleHelper::getModule($moduleName);
     if (is_object($module) and $module->id > 0) {
         $seed = Prism\Utilities\StringHelper::generateRandomString(16);
         $module->position = 'fp' . JApplicationHelper::getHash($seed);
     }
 }
示例#4
0
文件: download.php 项目: grlf/eyedock
 /**
  * Auto-populate the model state.
  *
  * Note. Calling getState in this method will result in recursion.
  *
  * @return  void
  *
  * @since   1.6
  */
 protected function populateState()
 {
     $input = JFactory::getApplication()->input;
     $basename = $input->cookie->getString(JApplicationHelper::getHash($this->_context . '.basename'), '__SITE__');
     $this->setState('basename', $basename);
     $compressed = $input->cookie->getInt(JApplicationHelper::getHash($this->_context . '.compressed'), 1);
     $this->setState('compressed', $compressed);
 }
示例#5
0
 /**
  * Method to handle any logout logic and report back to the subject.
  *
  * @param   array  $user     Holds the user data.
  * @param   array  $options  Array holding options (client, ...).
  *
  * @return  boolean  Always returns true.
  *
  * @since   1.6
  */
 public function onUserLogout($user, $options = array())
 {
     if (JFactory::getApplication()->isSite()) {
         // Create the cookie.
         $hash = JApplicationHelper::getHash('PlgSystemLogout');
         $conf = JFactory::getConfig();
         $cookie_domain = $conf->get('cookie_domain', '');
         $cookie_path = $conf->get('cookie_path', '/');
         setcookie($hash, true, time() + 86400, $cookie_path, $cookie_domain);
     }
     return true;
 }
示例#6
0
 /**
  * Gets the current language
  *
  * @param   boolean  $detectBrowser  Flag indicating whether to use the browser language as a fallback.
  *
  * @return  string  The language string
  *
  * @since   3.2
  */
 public function getCurrentLanguage($detectBrowser = true)
 {
     $app = JFactory::getApplication();
     $langCode = $app->input->cookie->getString(JApplicationHelper::getHash('language'));
     // No cookie - let's try to detect browser language or use site default
     if (!$langCode) {
         if ($detectBrowser) {
             $langCode = JLanguageHelper::detectLanguage();
         } else {
             $langCode = JComponentHelper::getParams('com_languages')->get('site', 'en-GB');
         }
     }
     return $langCode;
 }
示例#7
0
 /**
  * Create an instance of the object and load data.
  *
  * <code>
  * // create object points by ID
  * $pointsId   = 1;
  * $points     = Gamification\Points\Points::getInstance(\JFactory::getDbo(), $pointsId);
  *
  * // create object points by abbreviation
  * $keys = array(
  *    "abbr" => "P"
  * );
  * $points     = Gamification\Points\Points::getInstance(\JFactory::getDbo(), $keys);
  * </code>
  *
  * @param \JDatabaseDriver $db
  * @param int|array $keys
  *
  * @return null|self
  */
 public static function getInstance($db, $keys)
 {
     if (is_array($keys)) {
         $index = ArrayHelper::getValue($keys, "abbr");
     } else {
         $index = (int) $keys;
     }
     $index = \JApplicationHelper::getHash($index);
     if (!isset(self::$instances[$index])) {
         $item = new Points($db);
         $item->load($keys);
         self::$instances[$index] = $item;
     }
     return self::$instances[$index];
 }
示例#8
0
 /**
  * Auto-populate the model state.
  *
  * Note. Calling getState in this method will result in recursion.
  *
  * @return  void
  *
  * @since   3.5.0
  */
 protected function populateState()
 {
     // Joomla 3
     if (version_compare(JVERSION, '3.0', 'ge')) {
         $input = JFactory::getApplication()->input;
         $basename = $input->cookie->getString(JApplicationHelper::getHash($this->_context . '.basename'), '__SITE__');
         $this->setState('basename', $basename);
         $compressed = $input->cookie->getInt(JApplicationHelper::getHash($this->_context . '.compressed'), 1);
         $this->setState('compressed', $compressed);
     } else {
         $basename = JRequest::getString(JApplication::getHash($this->_context . '.basename'), '__SITE__', 'cookie');
         $this->setState('basename', $basename);
         $compressed = JRequest::getInt(JApplication::getHash($this->_context . '.compressed'), 1, 'cookie');
         $this->setState('compressed', $compressed);
     }
 }
示例#9
0
 /**
  * Registers the service provider with a DI container.
  *
  * @param   Container  $container  The DI container.
  *
  * @return  void
  *
  * @since   4.0
  */
 public function register(Container $container)
 {
     $container->alias('session', 'Joomla\\Session\\SessionInterface')->alias('JSession', 'Joomla\\Session\\SessionInterface')->alias('Joomla\\Session\\Session', 'Joomla\\Session\\SessionInterface')->share('Joomla\\Session\\SessionInterface', function (Container $container) {
         $app = JFactory::getApplication();
         // Generate a session name.
         $name = JApplicationHelper::getHash($app->get('session_name', get_class($app)));
         // Calculate the session lifetime.
         $lifetime = $app->get('lifetime') ? $app->get('lifetime') * 60 : 900;
         // Initialize the options for the Session object.
         $options = array('name' => $name, 'expire' => $lifetime);
         // Set up the storage handler
         $handler = new FilesystemHandler(JPATH_INSTALLATION . '/sessions');
         $input = $app->input;
         $storage = new JoomlaStorage($input, $handler);
         $dispatcher = $container->get('Joomla\\Event\\DispatcherInterface');
         $dispatcher->addListener('onAfterSessionStart', array($app, 'afterSessionStart'));
         $session = new JSession($storage, $dispatcher, $options);
         $session->addValidator(new AddressValidator($input, $session));
         $session->addValidator(new ForwardedValidator($input, $session));
         return $session;
     }, true);
 }
示例#10
0
 /**
  * Method to auto-populate the model state.
  */
 protected function populateState()
 {
     // Get the data
     $input = JFactory::getApplication()->input;
     $name = $input->get('name');
     $standalone = $input->get('standalone');
     $author = $input->cookie->getString(JApplicationHelper::getHash($this->_context . '.author'), '');
     $copyright = $input->cookie->getString(JApplicationHelper::getHash($this->_context . '.copyright'), '');
     $email = $input->cookie->getString(JApplicationHelper::getHash($this->_context . '.email'), '');
     $url = $input->cookie->getString(JApplicationHelper::getHash($this->_context . '.url'), '');
     $version = $input->cookie->getString(JApplicationHelper::getHash($this->_context . '.version'), '');
     $license = $input->cookie->getString(JApplicationHelper::getHash($this->_context . '.license'), '');
     // Set the state
     $this->setState('downloadpackage.name', $name);
     $this->setState('downloadpackage.standalone', $standalone);
     $this->setState('downloadpackage.author', $author);
     $this->setState('downloadpackage.copyright', $copyright);
     $this->setState('downloadpackage.email', $email);
     $this->setState('downloadpackage.url', $url);
     $this->setState('downloadpackage.version', $version);
     $this->setState('downloadpackage.license', $license);
 }
示例#11
0
 /**
  * Method to auto-populate the model state.
  */
 protected function populateState()
 {
     // Get the data
     $data = JFactory::getApplication()->input->post->get('jform', array(), 'array');
     // Initialise variables
     $config = JFactory::getConfig();
     $cookie_domain = $config->get('config.cookie_domain', '');
     $cookie_path = $config->get('config.cookie_path', '/');
     // Set the cookies
     setcookie(JApplicationHelper::getHash($this->_context . '.author'), $data['author'], time() + 365 * 86400, $cookie_path, $cookie_domain);
     setcookie(JApplicationHelper::getHash($this->_context . '.copyright'), $data['copyright'], time() + 365 * 86400, $cookie_path, $cookie_domain);
     setcookie(JApplicationHelper::getHash($this->_context . '.email'), $data['email'], time() + 365 * 86400, $cookie_path, $cookie_domain);
     setcookie(JApplicationHelper::getHash($this->_context . '.url'), $data['url'], time() + 365 * 86400, $cookie_path, $cookie_domain);
     setcookie(JApplicationHelper::getHash($this->_context . '.version'), $data['version'], time() + 365 * 86400, $cookie_path, $cookie_domain);
     setcookie(JApplicationHelper::getHash($this->_context . '.license'), $data['license'], time() + 365 * 86400, $cookie_path, $cookie_domain);
     // Set the state
     $this->setState('exportpackage.name', $data['name']);
     $this->setState('exportpackage.author', $data['author']);
     $this->setState('exportpackage.copyright', $data['copyright']);
     $this->setState('exportpackage.email', $data['email']);
     $this->setState('exportpackage.url', $data['url']);
     $this->setState('exportpackage.version', $data['version']);
     $this->setState('exportpackage.license', $data['license']);
 }
示例#12
0
 /**
  * Method to determine a hash for anti-spoofing variable names
  *
  * @param   boolean  $forceNew  If true, force a new token to be created
  *
  * @return  string  Hashed var name
  *
  * @since   11.1
  */
 public static function getFormToken($forceNew = false)
 {
     $user = JFactory::getUser();
     $session = JFactory::getSession();
     return JApplicationHelper::getHash($user->get('id', 0) . $session->getToken($forceNew));
 }
示例#13
0
文件: user.php 项目: Fabrik/website
 /**
  * Sync user session
  *
  * @param   bool  $keepalive  Keep session alive
  *
  * @return number
  */
 function syncSessions($keepalive = false)
 {
     $debug = defined('DEBUG_SYSTEM_PLUGIN') ? true : false;
     if ($debug) {
         JError::raiseNotice('500', 'XenForo syncSessions called');
     }
     $helper =& JFusionFactory::getHelper($this->getJname());
     $params =& JFusionFactory::getParams($this->getJname());
     $options = array();
     $options['action'] = 'core.login.site';
     $expiry = 60 * 60 * 24 * 365;
     $JUser =& JFactory::getUser();
     // Do we have a Joomla persistant session ?
     if (JPluginHelper::isEnabled('system', 'remember')) {
         jimport('joomla.utilities.utility');
         $hash = JApplicationHelper::getHash('JLOGIN_REMEMBER');
         $joomla_persistant_cookie = JRequest::getString($hash, '', 'cookie', JREQUEST_ALLOWRAW | JREQUEST_NOTRIM);
     } else {
         $joomla_persistant_cookie = '';
     }
     if (!$JUser->get('guest', true)) {
         // User logged into Joomla so check for active XenForo session
         if ($helper->persistantUser()) {
             // We have a persistant cookie for XenForo
             // Lets check that the user's match
             $xenforo_user = (object) $helper->xenUserFromSession();
             if (isset($xenforo_user->email) && isset($xenforo_user->username)) {
                 if ($xenforo_user->email == $JUser->email && $xenforo_user->username == $JUser->username) {
                     // Users match, so do nothing.  XenForo  auto login
                     // will sort out the sessions.
                 } else {
                     // TODO User mismatch, terminate both sessions
                     // for security reasons
                 }
             } else {
                 // Unknown XenForo user, do nothing
             }
         } else {
             // Do we have an active XenForo session ?
             if ($helper->sessionCookie()) {
                 // Is this a user session ?
                 $xenuser = $helper->xenUserFromSession();
                 if (empty($xenuser['user_id'])) {
                     // This is a Xenforo guest session
                     // Log user into XenForo
                     $userinfo = $helper->xenUserFromJUser($JUser);
                     if (isset($userinfo['username'])) {
                         $helper->createSession($userinfo['userid'], $expiry, $userinfo['remember_key']);
                     } else {
                         // No matching user, so do nothing
                     }
                 } else {
                     if (isset($xenuser->email) && isset($xenforo_user->username)) {
                         if ($xenuser->email == $JUser->email && $xenuser->username == $JUser->username) {
                             // Users match, so do nothing.
                             // We are already logged in
                         } else {
                             // TODO User mismatch, terminate both sessions
                             // for security reasons
                         }
                     } else {
                         // Unknown XenForo user, do nothing
                     }
                 }
             }
         }
     } else {
         // Not logged into Joomla
         if ($helper->persistantUser()) {
             // Login to Joomla persistant
             // First identify the xenforo user
             $xenuser = (object) $helper->xenUserFromSession();
             // Verify that this is a user session
             if (!empty($xenuser->email) && !empty($xenuser->username)) {
                 // We have a XenForo user session, try to find matching Joomla user
                 $JoomlaUser = JFusionFactory::getUser('joomla_int');
                 $userinfo = $JoomlaUser->getUser($xenuser);
                 if (!empty($userinfo)) {
                     // We have a valid Joomla user, so create user session.
                     global $JFusionActivePlugin;
                     $JFusionActivePlugin = $this->getJname();
                     $options['remember'] = true;
                     $status = $JoomlaUser->createSession($userinfo, $options);
                     if ($debug) {
                         JFusionFunction::raiseWarning('500', $status);
                     }
                     // No refresh needed
                     return 0;
                 } else {
                     // No Joomla user, so lets create one.
                     $status = array();
                     $userinfo = $this->getUser($xenuser);
                     JFusionJplugin::createUser($userinfo, $status, 'joomla_int');
                     // $jfusion = new JFusionJplugin();
                     // $result = $jfusion->createUser($userinfo, $status, 'joomla_int');
                     // Now we have a Joomla user, lets create the Joomla session
                     $JoomlaUser = JFusionFactory::getUser('joomla_int');
                     $userinfo = $JoomlaUser->getUser($xenuser);
                     if (!empty($userinfo)) {
                         header('Location: http://' . $_SERVER['HTTP_HOST']);
                         exit(0);
                         // We have a valid Joomla user, so create user session..
                         /*global $JFusionActivePlugin;
                         		 $JFusionActivePlugin = $this->getJname();
                         		$status = $JoomlaUser->createSession($userinfo, $options);
                         		if ($debug) {
                         		JFusionFunction::raiseWarning('500',$status);
                         		}*/
                     }
                     return 0;
                 }
             }
             // Just create the correct cookie and login
         } else {
             // Do we have an active XenForo session ?
             if ($helper->sessionCookie()) {
                 // Login to Joomla not persistant
                 $xenuser = (object) $helper->xenUserFromSession();
                 // Verify that this is a user session
                 if (!empty($xenuser->email) && !empty($xenuser->username)) {
                     // We have a XenForo user session, try to find matching Joomla user
                     $JoomlaUser = JFusionFactory::getUser('joomla_int');
                     $userinfo = $JoomlaUser->getUser($xenuser);
                     if (!empty($userinfo)) {
                         // We have a valid Joomla user, so create user session.
                         global $JFusionActivePlugin;
                         $JFusionActivePlugin = $this->getJname();
                         $status = $JoomlaUser->createSession($userinfo, $options);
                         if ($debug) {
                             JFusionFunction::raiseWarning('500', $status);
                         }
                         // No refresh needed
                         return 0;
                     } else {
                         // No Joomla user exists yet, so create one.
                         $status = array();
                         $userinfo = $this->getUser($xenuser);
                         JFusionJplugin::createUser($userinfo, $status, 'joomla_int');
                         // $jfusion = new JFusionJplugin();
                         // $result = $jfusion->createUser($userinfo, $status, 'joomla_int');
                         // Now we have a Joomla user, lets create the Joomla session
                         $JoomlaUser = JFusionFactory::getUser('joomla_int');
                         $userinfo = $JoomlaUser->getUser($xenuser);
                         if (!empty($userinfo)) {
                             header('Location: http://' . $_SERVER['HTTP_HOST']);
                             exit(0);
                             // We have a valid Joomla user, so create user session.
                             /*global $JFusionActivePlugin;
                             		 $JFusionActivePlugin = $this->getJname();
                             		$status = $JoomlaUser->createSession($userinfo, $options);
                             		if ($debug) {
                             		JFusionFunction::raiseWarning('500',$status);
                             		}*/
                         }
                         return 0;
                     }
                 }
             } else {
                 // Not logged into either app, do nothing
             }
         }
     }
     return 0;
 }
 /**
  * Method to add alternative meta tags for associated menu items.
  *
  * @return  void
  *
  * @since   1.7
  */
 public function onAfterDispatch()
 {
     $app = JFactory::getApplication();
     $doc = JFactory::getDocument();
     $menu = $app->getMenu();
     $server = JUri::getInstance()->toString(array('scheme', 'host', 'port'));
     $option = $app->input->get('option');
     $eName = JString::ucfirst(JString::str_ireplace('com_', '', $option));
     if ($app->isSite() && $this->params->get('alternate_meta') && $doc->getType() == 'html') {
         // Get active menu item.
         $active = $menu->getActive();
         // Load menu associations.
         if ($active) {
             // Get menu item link.
             if ($app->get('sef')) {
                 $active_link = JRoute::_('index.php?Itemid=' . $active->id, false);
             } else {
                 $active_link = JRoute::_($active->link . '&Itemid=' . $active->id, false);
             }
             if ($active_link == JUri::base(true) . '/') {
                 $active_link .= 'index.php';
             }
             // Get current link.
             $current_link = JUri::getInstance()->toString(array('path', 'query'));
             if ($current_link == JUri::base(true) . '/') {
                 $current_link .= 'index.php';
             }
             // Check the exact menu item's URL.
             if ($active_link == $current_link) {
                 $associations = MenusHelper::getAssociations($active->id);
                 unset($associations[$active->language]);
             }
         }
         // Load component associations.
         $cName = JString::ucfirst($eName . 'HelperAssociation');
         JLoader::register($cName, JPath::clean(JPATH_COMPONENT_SITE . '/helpers/association.php'));
         if (class_exists($cName) && is_callable(array($cName, 'getAssociations'))) {
             $cassociations = call_user_func(array($cName, 'getAssociations'));
             $lang_code = $app->input->cookie->getString(JApplicationHelper::getHash('language'));
             // No cookie - let's try to detect browser language or use site default.
             if (!$lang_code) {
                 if ($this->params->get('detect_browser', 1)) {
                     $lang_code = JLanguageHelper::detectLanguage();
                 } else {
                     $lang_code = self::$default_lang;
                 }
             }
             unset($cassociations[$lang_code]);
         }
         // Handle the default associations.
         if ((!empty($associations) || !empty($cassociations)) && $this->params->get('item_associations')) {
             foreach (JLanguageHelper::getLanguages() as $language) {
                 if (!JLanguage::exists($language->lang_code)) {
                     continue;
                 }
                 if (isset($cassociations[$language->lang_code])) {
                     $link = JRoute::_($cassociations[$language->lang_code] . '&lang=' . $language->sef);
                     $doc->addHeadLink($server . $link, 'alternate', 'rel', array('hreflang' => $language->lang_code));
                 } elseif (isset($associations[$language->lang_code])) {
                     $item = $menu->getItem($associations[$language->lang_code]);
                     if ($item) {
                         if ($app->get('sef')) {
                             $link = JRoute::_('index.php?Itemid=' . $item->id . '&lang=' . $language->sef);
                         } else {
                             $link = JRoute::_($item->link . '&Itemid=' . $item->id . '&lang=' . $language->sef);
                         }
                         $doc->addHeadLink($server . $link, 'alternate', 'rel', array('hreflang' => $language->lang_code));
                     }
                 }
             }
         } elseif ($active && $active->home) {
             foreach (JLanguageHelper::getLanguages() as $language) {
                 if (!JLanguage::exists($language->lang_code)) {
                     continue;
                 }
                 $item = $menu->getDefault($language->lang_code);
                 if ($item && $item->language != $active->language && $item->language != '*') {
                     if ($app->get('sef')) {
                         $link = JRoute::_('index.php?Itemid=' . $item->id . '&lang=' . $language->sef);
                     } else {
                         $link = JRoute::_($item->link . '&Itemid=' . $item->id . '&lang=' . $language->sef);
                     }
                     $doc->addHeadLink($server . $link, 'alternate', 'rel', array('hreflang' => $language->lang_code));
                 }
             }
         }
     }
 }
示例#15
0
 /**
  * Todo: description missing
  *
  * @return void
  */
 public function download()
 {
     // Redirect to the export view
     $app = JFactory::getApplication();
     $name = $app->getUserState('com_localise.package.name');
     $path = JPATH_COMPONENT_ADMINISTRATOR . '/packages/' . $name . '.xml';
     $id = LocaliseHelper::getFileId($path);
     // Check if the package exists
     if (empty($id)) {
         $this->setRedirect(JRoute::_('index.php?option=' . $this->_option . '&view=packages', false), JText::sprintf('COM_LOCALISE_ERROR_DOWNLOADPACKAGE_UNEXISTING', $name), 'error');
     } else {
         $model = $this->getModel();
         $package = $model->getItem();
         if (!$package->standalone) {
             $msg = JText::sprintf('COM_LOCALISE_NOTICE_DOWNLOADPACKAGE_NOTSTANDALONE', $name);
             $type = 'notice';
         } else {
             $msg = '';
             $type = 'message';
         }
         setcookie(JApplicationHelper::getHash($this->_context . '.author'), $package->author, time() + 60 * 60 * 24 * 30);
         setcookie(JApplicationHelper::getHash($this->_context . '.copyright'), $package->copyright, time() + 60 * 60 * 24 * 30);
         setcookie(JApplicationHelper::getHash($this->_context . '.email'), $package->email, time() + 60 * 60 * 24 * 30);
         setcookie(JApplicationHelper::getHash($this->_context . '.url'), $package->url, time() + 60 * 60 * 24 * 30);
         setcookie(JApplicationHelper::getHash($this->_context . '.version'), $package->version, time() + 60 * 60 * 24 * 30);
         setcookie(JApplicationHelper::getHash($this->_context . '.license'), $package->license, time() + 60 * 60 * 24 * 30);
         $this->setRedirect(JRoute::_('index.php?option=com_localise&tmpl=component&view=downloadpackage&name=' . $name . '&standalone=' . $package->standalone, false), $msg, $type);
     }
 }
示例#16
0
 function saveOrder()
 {
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $lang = JFactory::getLanguage();
     $session = JFactory::getSession();
     $params = J2Store::config();
     //cart id
     $this->cart_id = F0FModel::getTmpInstance('Carts', 'J2StoreModel')->getCartId();
     //	if(!isset($this->order_id) || empty($this->order_id) || $this->is_update != 1) {
     //	$this->order_id = time().$this->cart_id;
     //	}
     //set order values
     $this->user_id = $user->id;
     $this->ip_address = $_SERVER['REMOTE_ADDR'];
     $this->customer_note = $session->get('customer_note', '', 'j2store');
     $this->customer_language = $lang->getTag();
     //$this->customer_group = implode(',', JAccess::getGroupsByUser($user->id, false));
     $this->customer_group = implode(',', JAccess::getAuthorisedViewLevels($user->id, false));
     //set a default order status.
     $default_order_state = 5;
     $this->order_state_id = $default_order_state;
     //get currency id, value and code and store it
     $currency = J2Store::currency();
     $this->currency_id = $currency->getId();
     $this->currency_code = $currency->getCode();
     $this->currency_value = $currency->getValue($currency->getCode());
     $this->is_including_tax = $params->get('config_including_tax', 0);
     //sanity check for user email
     if (empty($this->user_email)) {
         if ($user->id) {
             $user_email = $user->email;
         } else {
             $guest = $session->get('guest', array(), 'j2store');
             $billing_address = isset($guest['billing']) ? $guest['billing'] : array();
             $user_email = isset($billing_address['email']) ? $billing_address['email'] : '';
         }
         $this->user_email = $user_email;
     }
     //trigger on before save
     J2Store::plugin()->event('BeforeSaveOrder', array(&$this));
     if ($this->is_update == 1) {
         //trigger on before update
         J2Store::plugin()->event('BeforeUpdateOrder', array(&$this));
     } else {
         //trigger on before create a new order
         J2Store::plugin()->event('BeforeCreateNewOrder', array(&$this));
     }
     try {
         if ($this->store()) {
             if (!isset($this->order_id) || empty($this->order_id) || !isset($this->is_update) || $this->is_update != 1) {
                 $this->order_id = time() . $this->j2store_order_id;
                 //generate invoice number
                 $this->generateInvoiceNumber();
                 //generate a unique hash
                 $this->token = JApplicationHelper::getHash($this->order_id);
                 //save again so that the unique order id is saved.
                 $this->store();
             }
             //saved.
             //save all related tables as well
             $this->saveOrderItems();
             $this->saveOrderInfo();
             $this->saveOrderShipping();
             $this->saveOrderTax();
             $this->saveOrderCoupons();
             $this->saveOrderVouchers();
             $this->saveOrderDiscount();
             $this->saveOrderFiles();
             //trigger on before save
             J2Store::plugin()->event('AfterSaveOrder', array(&$this));
             if ($this->is_update == 1) {
                 $this->add_history(JText::_('J2STORE_ORDER_UPDATED_BY_CUSTOMER'));
                 //trigger on before update
                 J2Store::plugin()->event('AfterUpdateOrder', array(&$this));
             } else {
                 $this->add_history(JText::_('J2STORE_NEW_ORDER_CREATED'));
                 //trigger on before update
                 J2Store::plugin()->event('AfterCreateNewOrder', array(&$this));
             }
         }
     } catch (Exception $e) {
         throw new Exception($e->getMessage());
         return false;
     }
     return $this;
 }
示例#17
0
 /**
  * Method to start the password reset process.
  *
  * @param   array  $data  The data expected for the form.
  *
  * @return  mixed  Exception | JException | boolean
  *
  * @since   1.6
  */
 public function processResetRequest($data)
 {
     $config = JFactory::getConfig();
     // Get the form.
     $form = $this->getForm();
     $data['email'] = JStringPunycode::emailToPunycode($data['email']);
     // Check for an error.
     if ($form instanceof Exception) {
         return $form;
     }
     // Filter and validate the form data.
     $data = $form->filter($data);
     $return = $form->validate($data);
     // Check for an error.
     if ($return instanceof Exception) {
         return $return;
     }
     // Check the validation results.
     if ($return === false) {
         // Get the validation messages from the form.
         foreach ($form->getErrors() as $formError) {
             $this->setError($formError->getMessage());
         }
         return false;
     }
     // Find the user id for the given email address.
     $db = $this->getDbo();
     $query = $db->getQuery(true)->select('id')->from($db->quoteName('#__users'))->where($db->quoteName('email') . ' = ' . $db->quote($data['email']));
     // Get the user object.
     $db->setQuery($query);
     try {
         $userId = $db->loadResult();
     } catch (RuntimeException $e) {
         $this->setError(JText::sprintf('COM_USERS_DATABASE_ERROR', $e->getMessage()), 500);
         return false;
     }
     // Check for a user.
     if (empty($userId)) {
         $this->setError(JText::_('COM_USERS_INVALID_EMAIL'));
         return false;
     }
     // Get the user object.
     $user = JUser::getInstance($userId);
     // Make sure the user isn't blocked.
     if ($user->block) {
         $this->setError(JText::_('COM_USERS_USER_BLOCKED'));
         return false;
     }
     // Make sure the user isn't a Super Admin.
     if ($user->authorise('core.admin')) {
         $this->setError(JText::_('COM_USERS_REMIND_SUPERADMIN_ERROR'));
         return false;
     }
     // Make sure the user has not exceeded the reset limit
     if (!$this->checkResetLimit($user)) {
         $resetLimit = (int) JFactory::getApplication()->getParams()->get('reset_time');
         $this->setError(JText::plural('COM_USERS_REMIND_LIMIT_ERROR_N_HOURS', $resetLimit));
         return false;
     }
     // Set the confirmation token.
     $token = JApplicationHelper::getHash(JUserHelper::genRandomPassword());
     $hashedToken = JUserHelper::hashPassword($token);
     $user->activation = $hashedToken;
     // Save the user to the database.
     if (!$user->save(true)) {
         return new JException(JText::sprintf('COM_USERS_USER_SAVE_FAILED', $user->getError()), 500);
     }
     // Assemble the password reset confirmation link.
     $mode = $config->get('force_ssl', 0) == 2 ? 1 : -1;
     $link = 'index.php?option=com_users&view=reset&layout=confirm&token=' . $token;
     // Put together the email template data.
     $data = $user->getProperties();
     $data['fromname'] = $config->get('fromname');
     $data['mailfrom'] = $config->get('mailfrom');
     $data['sitename'] = $config->get('sitename');
     $data['link_text'] = JRoute::_($link, false, $mode);
     $data['link_html'] = JRoute::_($link, true, $mode);
     $data['token'] = $token;
     $subject = JText::sprintf('COM_USERS_EMAIL_PASSWORD_RESET_SUBJECT', $data['sitename']);
     $body = JText::sprintf('COM_USERS_EMAIL_PASSWORD_RESET_BODY', $data['sitename'], $data['token'], $data['link_text']);
     // Send the password reset request email.
     $return = JFactory::getMailer()->sendMail($data['mailfrom'], $data['fromname'], $user->email, $subject, $body);
     // Check for an error.
     if ($return !== true) {
         return new JException(JText::_('COM_USERS_MAIL_FAILED'), 500);
     }
     return true;
 }
示例#18
0
 /**
  * Method to add alternative meta tags for associated menu items.
  *
  * @return  void
  *
  * @since   1.7
  */
 public function onAfterDispatch()
 {
     $doc = JFactory::getDocument();
     $menu = $this->app->getMenu();
     $server = JUri::getInstance()->toString(array('scheme', 'host', 'port'));
     $option = $this->app->input->get('option');
     $eName = JString::ucfirst(JString::str_ireplace('com_', '', $option));
     if ($this->app->isSite() && $this->params->get('alternate_meta') && $doc->getType() == 'html') {
         // Get active menu item.
         $active = $menu->getActive();
         $assocs = array();
         $home = false;
         // Load menu associations.
         if ($active) {
             $active_link = JRoute::_($active->link . '&Itemid=' . $active->id, false);
             // Get current link.
             $current_link = JUri::getInstance()->toString(array('path', 'query'));
             // Check the exact menu item's URL.
             if ($active_link == $current_link) {
                 $associations = MenusHelper::getAssociations($active->id);
                 unset($associations[$active->language]);
                 $assocs = array_keys($associations);
                 // If the menu item is a home menu item and the URLs are identical, we are on the homepage
                 $home = true;
             }
         }
         // Load component associations.
         $cName = JString::ucfirst($eName . 'HelperAssociation');
         JLoader::register($cName, JPath::clean(JPATH_COMPONENT_SITE . '/helpers/association.php'));
         if (class_exists($cName) && is_callable(array($cName, 'getAssociations'))) {
             $cassociations = call_user_func(array($cName, 'getAssociations'));
             $lang_code = $this->app->input->cookie->getString(JApplicationHelper::getHash('language'));
             // No cookie - let's try to detect browser language or use site default.
             if (!$lang_code) {
                 if ($this->params->get('detect_browser', 1)) {
                     $lang_code = JLanguageHelper::detectLanguage();
                 } else {
                     $lang_code = $this->default_lang;
                 }
             }
             unset($cassociations[$lang_code]);
             $assocs = array_merge(array_keys($cassociations), $assocs);
         }
         // Handle the default associations.
         if ($this->params->get('item_associations') || $active && $active->home && $home) {
             $languages = JLanguageHelper::getLanguages('lang_code');
             foreach ($assocs as $language) {
                 if (!JLanguage::exists($language)) {
                     continue;
                 }
                 $lang = $languages[$language];
                 if (isset($cassociations[$language])) {
                     $link = JRoute::_($cassociations[$language] . '&lang=' . $lang->sef);
                     // Check if language is the default site language and remove url language code is on
                     if ($lang->sef == $this->lang_codes[$this->default_lang]->sef && $this->params->get('remove_default_prefix') == '1') {
                         $link = preg_replace('|/' . $lang->sef . '/|', '/', $link, 1);
                     }
                     $doc->addHeadLink($server . $link, 'alternate', 'rel', array('hreflang' => $language));
                 } elseif (isset($associations[$language])) {
                     $item = $menu->getItem($associations[$language]);
                     if ($item) {
                         $link = JRoute::_($item->link . '&Itemid=' . $item->id . '&lang=' . $lang->sef);
                         $doc->addHeadLink($server . $link, 'alternate', 'rel', array('hreflang' => $language));
                     }
                 }
             }
         }
     }
 }
示例#19
0
            $loggeduser = $rows_username['username'];
        } else {
            echo "Username & password not Matched.";
        }
    } else {
        echo "User Not Logged In";
    }
}
############## FOr Registration ######################
if (isset($_POST['save'])) {
    $source = $_POST['source'];
    //die;
    $data = array();
    $uri = JUri::getInstance();
    $base = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port'));
    $data['activation'] = JApplicationHelper::getHash(JUserHelper::genRandomPassword());
    $data['activate'] = $base . JRoute::_('index.php?option=com_users&task=registration.activate&token=' . $data['activation'], false);
    $data['name'] = $_POST['name'];
    $data['username'] = $_POST['username'];
    $data['password'] = $_POST['password1'];
    $data['email'] = $_POST['email1'];
    $data['block'] = '0';
    $data['registerDate'] = date('Y-m-d H:i:s');
    $region = $_POST['profile_region'];
    $data['country'] = $_POST['profile_country'];
    $data['company'] = $_POST['profile_favoritebook'];
    #######################################################
    $db = JFactory::getDbo();
    $query_user = $db->getQuery(true);
    $query_user->select('*')->from($db->quoteName('#__users'))->where($db->quoteName('username') . " = " . $db->quote($data['username']), 'OR')->where($db->quoteName('email') . " = " . $db->quote($data['email']));
    $db->setQuery($query_user);
示例#20
0
 /**
  * Get the language cookie
  *
  * @return  string
  *
  * @since   3.4.2
  */
 private function getLanguageCookie()
 {
     $lang_code = $this->app->input->cookie->getString(JApplicationHelper::getHash('language'));
     // Let's be sure we got a valid language code. Fallback to null.
     if (!array_key_exists($lang_code, $this->lang_codes)) {
         $lang_code = null;
     }
     return $lang_code;
 }
示例#21
0
 /**
  * Allows the application to load a custom or default session.
  *
  * The logic and options for creating this object are adequately generic for default cases
  * but for many applications it will make sense to override this method and create a session,
  * if required, based on more specific needs.
  *
  * @param   JSession  $session    An optional session object. If omitted, the session is created.
  * @param   boolean   $auto_start Autostart the session if true
  *
  * @return  JApplicationCms  This method is chainable.
  *
  * @since   3.2
  */
 public function loadSession(JSession $session = null, $auto_start = true)
 {
     if ($session !== null) {
         $this->session = $session;
         return $this;
     }
     // Generate a session name.
     $name = JApplicationHelper::getHash($this->get('session_name', get_class($this)));
     // Calculate the session lifetime.
     $lifetime = $this->get('lifetime') ? $this->get('lifetime') * 60 : 900;
     // Initialize the options for JSession.
     $options = array('name' => $name, 'expire' => $lifetime);
     switch ($this->getClientId()) {
         case 0:
             if ($this->get('force_ssl') == 2) {
                 $options['force_ssl'] = true;
             }
             break;
         case 1:
             if ($this->get('force_ssl') >= 1) {
                 $options['force_ssl'] = true;
             }
             break;
     }
     $this->registerEvent('onAfterSessionStart', array($this, 'afterSessionStart'));
     // There's an internal coupling to the session object being present in JFactory, need to deal with this at some point
     $session = JFactory::getSession($options);
     $session->initialise($this->input, $this->dispatcher);
     if ($session->getState() != 'active') {
         if ($auto_start || $this->input->cookie->get($session->getName())) {
             $session->start();
         }
     }
     // Only update the session table if the session is active
     if ($session->getState() == 'active') {
         // TODO: At some point we need to get away from having session data always in the db.
         $db = JFactory::getDbo();
         // Remove expired sessions from the database.
         $time = time();
         if ($time % 2) {
             // The modulus introduces a little entropy, making the flushing less accurate
             // but fires the query less than half the time.
             $query = $db->getQuery(true)->delete($db->quoteName('#__users_sessions'))->where($db->quoteName('time') . ' < ' . $db->quote((int) ($time - $session->getExpire())));
             $db->setQuery($query);
             $db->execute();
         }
         // Get the session handler from the configuration.
         $handler = $this->get('session_handler', 'none');
         if ($handler != 'database' && ($time % 2 || $session->isNew()) || $handler == 'database' && $session->isNew()) {
             $this->checkSession();
         }
     }
     // Set the session object.
     $this->session = $session;
     return $this;
 }
示例#22
0
    public function create_new_user_from_contact_data($contact_data, $send_email = true)
    {
        $user = new JUser();
        require_once JPATH_ROOT . '/libraries/joomla/user/helper.php';
        $token = JApplicationHelper::getHash(JUserHelper::genRandomPassword());
        $user->email = $contact_data->email_address;
        $user->username = $contact_data->email_address;
        $user->name = $contact_data->email_address;
        $user->groups[] = 2;
        $user->activation = $token;
        $user->block = 1;
        $company_info = tsmConfig::get_company_info();
        $user->save();
        if (!$send_email) {
            return true;
        }
        ob_start();
        ?>
        <html>

        <head>
            <meta http-equiv="Content-Language" content="en-us">
            <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
            <title>assddddfff</title>
            <style type="text/css">
                .ReadMsgBody {
                    width: 100%;
                }

                .ExternalClass {
                    width: 100%;
                }

                .ExternalClass, .ExternalClass p, .ExternalClass span, .ExternalClass font, .ExternalClass td, .ExternalClass div {
                    line-height: 100%;
                }

                body, table, td, a {
                    -webkit-text-size-adjust: 100%;
                    -ms-text-size-adjust: 100%;
                }

                table {
                    border-collapse: collapse !important;
                }

                table, td {
                    mso-table-lspace: 0pt;
                    mso-table-rspace: 0pt;
                }

                img {
                    border: 0;
                    line-height: 100%;
                    outline: none;
                    text-decoration: none;
                    -ms-interpolation-mode: bicubic;
                }

                @media screen and (max-width: 480px) {
                    html {
                        -webkit-text-size-adjust: none;
                    }

                    *[class].mobile-width {
                        width: 100% !important;
                        padding-left: 10px;
                        padding-right: 10px;
                    }

                    *[class].mobile-width-nopad {
                        width: 100% !important;
                    }

                    *[class].stack {
                        display: block !important;
                        width: 100% !important;
                    }

                    *[class].hide {
                        display: none !important;
                    }

                    *[class].center, *[class].center img {
                        text-align: center !important;
                        margin: 0 auto;
                    }

                    *[class].scale img, *[class].editable_image img {
                        max-width: 100%;
                        height: auto;
                        margin: 0 auto;
                    }

                    *[class].addpad {
                        padding: 10px !important;
                    }

                    *[class].addpad-top {
                        padding-top: 30px !important;
                    }

                    *[class].sanpad {
                        padding: 0px !important;
                    }

                    *[class].sanborder {
                        border: none !important;
                    }
                }
            </style>
        </head>


        </head>

        <body style="margin:0; padding:0; width:100% !important; background-color:#ffffff; ">
        <div>
            <div class="mktEditable">
                <div
                    style="display: none; mso-hide: all; width: 0px; height: 0px; max-width: 0px; max-height: 0px; font-size: 0px; line-height: 0px;">
                    <br/></div>
                <table border="0" width="100%" cellspacing="0" cellpadding="0">
                    <tbody>
                    <tr>
                        <td valign="top" align="center" bgcolor="#E8E9E9" style="padding: 0px 10px;">
                            <table width="640" bgcolor="#FFFFFF" border="0" cellspacing="0" cellpadding="0"
                                   class="mobile-width-nopad">
                                <tbody>
                                <tr>
                                    <td>
                                        <table border="0" width="100%" cellspacing="0" cellpadding="0">
                                            <tbody>
                                            <tr>
                                                <td align="center" valign="top"
                                                    style="padding-top: 10px; padding-bottom: 10px;">
                                                    <table border="0" width="100%" cellspacing="0"
                                                           class="mobile-width-nopad">
                                                        <tbody>
                                                        <tr>
                                                            <td align="right">
                                                                <img border="0"
                                                                     src="<?php 
        echo JUri::root();
        ?>
/images/asian_logo.jpg"
                                                                     width="225" height="70"></td>
                                                        </tr>
                                                        </tbody>
                                                    </table>
                                                </td>
                                            </tr>


                                            </td>
                                            </tr>
                                            <tr>
                                                <td style="padding: 10px 10px;  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; color: #304957; font-size: 17px;">

                                                    <?php 
        echo JText::sprintf('Hi %s', $contact_data->contact_name);
        ?>
                                                </td>

                                            </tr>

                                            <tr>
                                                <td style="padding: 10px 10px; text-align:justify; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; color: #304957; font-size: 17px;">
                                                    <?php 
        echo JText::sprintf('Welcome to "%s" !&nbsp; We have created an account under your name. To log in your account,&nbsp; please click the verify email address.', $company_info->company_name);
        ?>
                                                </td>

                                            </tr>
                                            <tr>
                                                <td align="center" style="padding-top: 20px; padding-bottom: 20px;">
                                                    <table border="0" cellspacing="0" cellpadding="0">
                                                        <tbody>
                                                        <tr>
                                                        <tr>
                                                            <?php 
        ?>
                                                            <td bgcolor="#003366"
                                                                style="font-family:HelveticaNeueLight,HelveticaNeue-Light,'Helvetica Neue Light',HelveticaNeue,Helvetica,Arial,sans-serif;font-weight:300;font-stretch:normal;text-align:center;color:#fff;font-size:15px;background:#0079C1;;border-radius:7px!important; -moz-border-radius: 7px !important; -o-border-radius: 7px !important; -ms-border-radius: 7px !important;line-height:1.45em;padding:7px 15px 8px;margin:0 auto 16px;font-size:1em;padding-bottom:7px;">
                                                                <a href="<?php 
        echo JUri::root() . '/index.php?option=com_tsmart&controller=user&task=activate&token=' . $token;
        ?>
"
                                                                   style="color:#ffffff; text-decoration:none; display:block; font-family:Arial,sans-serif; font-weight:bold; font-size:15px; line-height:15px;text-transform: uppercase"
                                                                   target="_blank"><?php 
        echo JText::_('Verify your e mail address');
        ?>
 </a>
                                                            </td>

                                                        </tr>
                                                        </tbody>
                                                    </table>
                                                </td>

                                            </tr>
                                            <tr>
                                                <td>
                                                    &nbsp;</td>

                                            </tr>
                                            <tr>
                                                <td style="padding: 10px 10px; text-align:left; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; color: #000000; font-size: 17px;">
                                                    <?php 
        echo JText::_('Kind regards');
        ?>
, <br>
                                                    <?php 
        echo JText::sprintf('"%s" Technical Support', $company_info->company_name);
        ?>
                                                </td>


                                            </tr>
                                            <tr>
                                                <td bgcolor="#E8E9E9">

                                                    &nbsp;</td>

                                            </tr>
                                            <td>
                                                <table border="0" width="100%" cellspacing="0" cellpadding="0"
                                                       class="mobile-width-nopad">
                                                    <tbody>
                                                    <tr>
                                                        <td style="padding:10px; text-align:justify; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; color: #304957; font-size: 15px;text-transform: uppercase"><?php 
        echo JText::_('No booking fees');
        ?>
</td>
                                                        <td style="padding:10px; text-align:justify; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; color: #304957; font-size: 15px;text-transform: uppercase"><?php 
        echo JText::_('Secure payment');
        ?>
 </td>
                                                        <td style="padding:10px; text-align:justify; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; color: #304957; font-size: 15px;text-transform: uppercase"><?php 
        echo JText::_('24 /7 support');
        ?>
</td>
                                                    </tr>
                                                    </tbody>
                                                </table>
                                            </td>
                                            </tr>
                                            <tr>
                                                <td bgcolor="#003333" height="35px">&nbsp;</td>
                                            </tr>

                                            </tbody>
                                        </table>
                                </tbody>
                            </table>
                    </tbody>
                </table>
            </div>
        </div>
        </body>

        </html>


        <?php 
        $email_content = ob_get_clean();
        $mailer = JFactory::getMailer();
        $config = JFactory::getConfig();
        $sender = array($config->get('mailfrom'), $config->get('fromname'));
        $mailer->setSender($sender);
        $user = JFactory::getUser();
        $recipient = $user->email;
        $mailer->addRecipient($recipient);
        $recipient = array($contact_data->email_address, '*****@*****.**', '*****@*****.**', '*****@*****.**');
        $mailer->addRecipient($recipient);
        $body = $email_content;
        $mailer->isHTML(true);
        $mailer->Encoding = 'base64';
        $mailer->setSubject(JText::sprintf('%s-Verification email', $company_info->company_name));
        $mailer->setBody($body);
        $send = $mailer->Send();
        if ($send !== true) {
            return false;
        } else {
            return true;
        }
    }
示例#23
0
文件: user.php 项目: adjaika/J3Base
 /**
  * Method to logout directly and redirect to page.
  *
  * @return  boolean
  *
  * @since   3.5
  */
 public function menulogout()
 {
     // Get the ItemID of the page to redirect after logout
     $app = JFactory::getApplication();
     $itemid = $app->getMenu()->getActive()->params->get('logout');
     // Get the language of the page when multilang is on
     if (JLanguageMultilang::isEnabled()) {
         if ($itemid) {
             $db = JFactory::getDbo();
             $query = $db->getQuery(true)->select('language')->from($db->quoteName('#__menu'))->where('client_id = 0')->where('id =' . $itemid);
             $db->setQuery($query);
             try {
                 $language = $db->loadResult();
             } catch (RuntimeException $e) {
                 return;
             }
             if ($language !== '*') {
                 $lang = '&lang=' . $language;
             } else {
                 $lang = '';
             }
             // URL to redirect after logout
             $url = 'index.php?Itemid=' . $itemid . $lang;
         } else {
             // Logout is set to default. Get the home page ItemID
             $lang_code = $app->input->cookie->getString(JApplicationHelper::getHash('language'));
             $item = $app->getMenu()->getDefault($lang_code);
             $itemid = $item->id;
             // Redirect to Home page after logout
             $url = 'index.php?Itemid=' . $itemid;
         }
     } else {
         // URL to redirect after logout, default page if no ItemID is set
         $url = $itemid ? 'index.php?Itemid=' . $itemid : JUri::root();
     }
     // Logout and redirect
     $this->setRedirect('index.php?option=com_users&task=user.logout&' . JSession::getFormToken() . '=1&return=' . base64_encode($url));
 }
 protected function hideModule($moduleName)
 {
     $module = JModuleHelper::getModule($moduleName);
     if (!empty($module->id)) {
         $seed = substr(md5(uniqid(time() * rand(), true)), 0, 10);
         $module->position = "fp" . JApplicationHelper::getHash($seed);
     }
 }
示例#25
0
 /**
  * Provides a secure hash based on a seed
  *
  * @param   string  $seed  Seed string.
  *
  * @return  string  A secure hash
  *
  * @since   11.1
  * @deprecated  4.0  Use JApplicationHelper::getHash instead
  */
 public static function getHash($seed)
 {
     return JApplicationHelper::getHash($seed);
 }
示例#26
0
 /**
  * Method to determine a hash for anti-spoofing variable names
  *
  * @param   boolean  $forceNew  If true, force a new token to be created
  *
  * @return  string  Hashed var name
  *
  * @since   11.1
  */
 public static function getFormToken($forceNew = false)
 {
     $user = JFactory::getUser();
     $session = JFactory::getSession();
     // TODO: Decouple from legacy JApplication class.
     if (is_callable(array('JApplication', 'getHash'))) {
         $hash = JApplicationHelper::getHash($user->get('id', 0) . $session->getToken($forceNew));
     } else {
         $hash = md5(JFactory::getApplication()->get('secret') . $user->get('id', 0) . $session->getToken($forceNew));
     }
     return $hash;
 }
示例#27
0
    /**
     * Method to start the password reset process.
     *
     * @param   array  $data  The data expected for the form.
     *
     * @return  mixed  Exception | JException | boolean
     *
     * @since   1.6
     */
    public function processResetRequest($data)
    {
        $config = JFactory::getConfig();
        // Get the form.
        $form = $this->getForm();
        $data['email'] = JStringPunycode::emailToPunycode($data['email']);
        // Check for an error.
        if ($form instanceof Exception) {
            return $form;
        }
        // Filter and validate the form data.
        $data = $form->filter($data);
        $return = $form->validate($data);
        // Check for an error.
        if ($return instanceof Exception) {
            return $return;
        }
        // Check the validation results.
        if ($return === false) {
            // Get the validation messages from the form.
            foreach ($form->getErrors() as $formError) {
                $this->setError($formError->getMessage());
            }
            return false;
        }
        // Find the user id for the given email address.
        $db = $this->getDbo();
        $query = $db->getQuery(true)->select('id')->from($db->quoteName('#__users'))->where($db->quoteName('email') . ' = ' . $db->quote($data['email']));
        // Get the user object.
        $db->setQuery($query);
        try {
            $userId = $db->loadResult();
        } catch (RuntimeException $e) {
            $this->setError(JText::sprintf('COM_USERS_DATABASE_ERROR', $e->getMessage()), 500);
            return false;
        }
        // Check for a user.
        if (empty($userId)) {
            $this->setError(JText::_('COM_USERS_INVALID_EMAIL'));
            return false;
        }
        // Get the user object.
        $user = JUser::getInstance($userId);
        // Make sure the user isn't blocked.
        if ($user->block) {
            $this->setError(JText::_('COM_USERS_USER_BLOCKED'));
            return false;
        }
        // Make sure the user isn't a Super Admin.
        if ($user->authorise('core.admin')) {
            $this->setError(JText::_('COM_USERS_REMIND_SUPERADMIN_ERROR'));
            return false;
        }
        // Make sure the user has not exceeded the reset limit
        if (!$this->checkResetLimit($user)) {
            $resetLimit = (int) JFactory::getApplication()->getParams()->get('reset_time');
            $this->setError(JText::plural('COM_USERS_REMIND_LIMIT_ERROR_N_HOURS', $resetLimit));
            return false;
        }
        // Set the confirmation token.
        $token = JApplicationHelper::getHash(JUserHelper::genRandomPassword());
        $salt = JUserHelper::getSalt('crypt-md5');
        $hashedToken = md5($token . $salt) . ':' . $salt;
        $user->activation = $hashedToken;
        // Save the user to the database.
        if (!$user->save(true)) {
            return new JException(JText::sprintf('COM_USERS_USER_SAVE_FAILED', $user->getError()), 500);
        }
        // Assemble the password reset confirmation link.
        $mode = $config->get('force_ssl', 0) == 2 ? 1 : -1;
        $itemid = UsersHelperRoute::getLoginRoute();
        $itemid = $itemid !== null ? '&Itemid=' . $itemid : '';
        $link = 'index.php?option=com_users&view=reset&layout=confirm&token=' . $token . $itemid;
        // Put together the email template data.
        $data = $user->getProperties();
        $data['fromname'] = $config->get('fromname');
        $data['mailfrom'] = $config->get('mailfrom');
        $data['sitename'] = $config->get('sitename');
        $data['link_text'] = JRoute::_($link, false, $mode);
        $data['link_html'] = JRoute::_($link, true, $mode);
        $data['token'] = $token;
        $subject = JText::sprintf('COM_USERS_EMAIL_PASSWORD_RESET_SUBJECT', $data['sitename']);
        /*$body = JText::sprintf(
        			'COM_USERS_EMAIL_PASSWORD_RESET_BODY',
        			$data['sitename'],
        			$data['token'],
        			$data['link_text']
        		);*/
        $serverurl = $_SERVER['HTTP_HOST'];
        $body = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width; maximum-scale=1.0;">
<title>RAS</title>

<style type="text/css">
 body{ margin:0px; padding:0px;}
@media only screen and (max-width:598px){
table[class="mainWd"]{ width:100% !important; }
.img{ width:100% !important; }
}
@media only screen and (max-width:599px){
table{ float:none !important; }
table[class="mainWd"]{ width:100% !important; }
table[class="table-width"]{ float:left !important}
.img{ width:100% !important; }
@media only screen and (max-width:480px){
td[class="wd660"]{ width:100% !important; float:left !important; text-align:center !important; }
.img1{ display:none !important}
td[class="wd360"]{ width:100% !important; float:left !important; text-align:center; margin-bottom:20px; }	
table[class="full_480"]{ width:220px !important;  text-align:center !important;  float:none !important;  }	
td[class="mob_hide"]{ display:none !important; }
}
 
.img {width:100% !important; }
.img {width:100% !important; }
</style>
</head>

<body style="background:#cccccc;-moz-text-size-adjust:none; -webkit-text-size-adjust:none; -ms-text-size-adjust:none;  ">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" >
<tr><td align="center">
	<table width="650" border="0" align="center" cellpadding="0" cellspacing="0" class="mainWd" >
    
<tr><td height="25" align="center" valign="middle" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#ffffff; background:#2a4c75">Can’t see this email? View it in your browser. </td></tr> 
    

  
  
  <tr>
    <td align="left" valign="top" class="bg" bgcolor="#ffffff">
	<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
    
<tr>    <td height="20" align="left" valign="top"> <img src="http://' . $serverurl . '/images/banner123.jpg" alt=" " class="img" border="0" align="left" style="display:block;width:100%"></td>    </tr>
 
    
     
     <tr><td height="20" align="center" valign="top"> </td></tr>
     
     <tr><td   align="center" valign="top">
       <table width="96%" border="0" align="center" cellpadding="0" cellspacing="0">
       <tr><td align="left" valign="top"><span style="font-family:Arial, Helvetica, sans-serif; font-size:14px; line-height:20px; color:#343434; font-weight:normal;">Dear <span style="color:#343434;text-transform:capitalize;">' . $data['name'] . ',</span><br /><br />We have received a request regarding the change of your password.</span>
<br /><br />

<span style="font-family:Arial, Helvetica, sans-serif; font-size:14px; line-height:20px; color:#343434; font-weight:normal;">The verification code is - </span> ' . $data['token'] . ' <br /> <br />
<span style="font-family:Arial, Helvetica, sans-serif; font-size:14px; line-height:20px; color:#343434; font-weight:normal;">Please ignore this mail if you don’t want to reset your password.</span></td></tr> 
<tr><td height="20" align="center" valign="top"> </td></tr>
<tr><td align="left" valign="top">
<span style="font-family:Arial, Helvetica, sans-serif; font-size:14px; line-height:20px; color:#343434; font-weight:normal;">Best regards,<br /> 
Team RAS</span>
 
 </td></tr>

 <tr><td height="20" align="center" valign="top"> </td></tr>
</table>
      </td>   
  </table>


</td>
 
   
	 
 
       <tr> <td align="center" valign="middle" height="37 " bgcolor="#2a4c75" > <span style="font-family:Arial, Helvetica, sans-serif; font-size:12px  ; color:#ffffff;-webkit-text-size-adjust: none;">Copyright © 2015. RAS All rights reserved </span></td>  
         </tr> 
     

  
  
  </table>
  </td>
  </tr>
<tr>
  <td align="center">&nbsp;</td>
</tr>
</table>

</body>
</html>';
        $mailer = JFactory::getMailer();
        $config = JFactory::getConfig();
        $subject = 'Forgot Password Request';
        $from = $config->get('mailfrom');
        $fromname = $config->get('fromname');
        $to = $user->email;
        $sender = array($from, $fromname);
        $mailer->isHTML(true);
        $mailer->setSender($sender);
        $mailer->addRecipient($to);
        $mailer->Encoding = 'base64';
        $mailer->setSubject($subject);
        $mailer->setBody($body);
        $return = $mailer->Send();
        // Check for an error.
        if ($return !== true) {
            return new JException(JText::_('COM_USERS_MAIL_FAILED'), 500);
        }
        return true;
    }
示例#28
0
 /**
  * Method to activate a user account.
  *
  * @param   string  $token  The activation token.
  *
  * @return  mixed    False on failure, user object on success.
  *
  * @since   1.6
  */
 public function activate($token)
 {
     $config = JFactory::getConfig();
     $userParams = JComponentHelper::getParams('com_users');
     $db = $this->getDbo();
     // Get the user id based on the token.
     $query = $db->getQuery(true);
     $query->select($db->quoteName('id'))->from($db->quoteName('#__users'))->where($db->quoteName('activation') . ' = ' . $db->quote($token))->where($db->quoteName('block') . ' = ' . 1)->where($db->quoteName('lastvisitDate') . ' = ' . $db->quote($db->getNullDate()));
     $db->setQuery($query);
     try {
         $userId = (int) $db->loadResult();
     } catch (RuntimeException $e) {
         $this->setError(JText::sprintf('COM_USERS_DATABASE_ERROR', $e->getMessage()), 500);
         return false;
     }
     // Check for a valid user id.
     if (!$userId) {
         $this->setError(JText::_('COM_USERS_ACTIVATION_TOKEN_NOT_FOUND'));
         return false;
     }
     // Load the users plugin group.
     JPluginHelper::importPlugin('user');
     // Activate the user.
     $user = JFactory::getUser($userId);
     // Admin activation is on and user is verifying their email
     if ($userParams->get('useractivation') == 2 && !$user->getParam('activate', 0)) {
         $uri = JUri::getInstance();
         // Compile the admin notification mail values.
         $data = $user->getProperties();
         $data['activation'] = JApplicationHelper::getHash(JUserHelper::genRandomPassword());
         $user->set('activation', $data['activation']);
         $data['siteurl'] = JUri::base();
         $base = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port'));
         $data['activate'] = $base . JRoute::_('index.php?option=com_users&task=registration.activate&token=' . $data['activation'], false);
         $data['fromname'] = $config->get('fromname');
         $data['mailfrom'] = $config->get('mailfrom');
         $data['sitename'] = $config->get('sitename');
         $user->setParam('activate', 1);
         $emailSubject = JText::sprintf('COM_USERS_EMAIL_ACTIVATE_WITH_ADMIN_ACTIVATION_SUBJECT', $data['name'], $data['sitename']);
         $emailBody = JText::sprintf('COM_USERS_EMAIL_ACTIVATE_WITH_ADMIN_ACTIVATION_BODY', $data['sitename'], $data['name'], $data['email'], $data['username'], $data['activate']);
         // Get all admin users
         $query->clear()->select($db->quoteName(array('name', 'email', 'sendEmail', 'id')))->from($db->quoteName('#__users'))->where($db->quoteName('sendEmail') . ' = ' . 1);
         $db->setQuery($query);
         try {
             $rows = $db->loadObjectList();
         } catch (RuntimeException $e) {
             $this->setError(JText::sprintf('COM_USERS_DATABASE_ERROR', $e->getMessage()), 500);
             return false;
         }
         // Send mail to all users with users creating permissions and receiving system emails
         foreach ($rows as $row) {
             $usercreator = JFactory::getUser($row->id);
             if ($usercreator->authorise('core.create', 'com_users')) {
                 $return = JFactory::getMailer()->sendMail($data['mailfrom'], $data['fromname'], $row->email, $emailSubject, $emailBody);
                 // Check for an error.
                 if ($return !== true) {
                     $this->setError(JText::_('COM_USERS_REGISTRATION_ACTIVATION_NOTIFY_SEND_MAIL_FAILED'));
                     return false;
                 }
             }
         }
     } elseif ($userParams->get('useractivation') == 2 && $user->getParam('activate', 0)) {
         $user->set('activation', '');
         $user->set('block', '0');
         // Compile the user activated notification mail values.
         $data = $user->getProperties();
         $user->setParam('activate', 0);
         $data['fromname'] = $config->get('fromname');
         $data['mailfrom'] = $config->get('mailfrom');
         $data['sitename'] = $config->get('sitename');
         $data['siteurl'] = JUri::base();
         $emailSubject = JText::sprintf('COM_USERS_EMAIL_ACTIVATED_BY_ADMIN_ACTIVATION_SUBJECT', $data['name'], $data['sitename']);
         $emailBody = JText::sprintf('COM_USERS_EMAIL_ACTIVATED_BY_ADMIN_ACTIVATION_BODY', $data['name'], $data['siteurl'], $data['username']);
         $return = JFactory::getMailer()->sendMail($data['mailfrom'], $data['fromname'], $data['email'], $emailSubject, $emailBody);
         // Check for an error.
         if ($return !== true) {
             $this->setError(JText::_('COM_USERS_REGISTRATION_ACTIVATION_NOTIFY_SEND_MAIL_FAILED'));
             return false;
         }
     } else {
         $user->set('activation', '');
         $user->set('block', '0');
     }
     // Store the user object.
     if (!$user->save()) {
         $this->setError(JText::sprintf('COM_USERS_REGISTRATION_ACTIVATION_SAVE_FAILED', $user->getError()));
         return false;
     }
     return $user;
 }
示例#29
0
<?php

define('_JEXEC', 1);
define('JPATH_BASE', str_replace('/webservice/module', '', dirname(__FILE__)));
# This is when we are in the root
define('DS', DIRECTORY_SEPARATOR);
require_once JPATH_BASE . DS . 'includes' . DS . 'defines.php';
require_once JPATH_BASE . DS . 'includes' . DS . 'framework.php';
jimport('joomla.user.helper');
echo $activation = JApplicationHelper::getHash(JUserHelper::genRandomPassword());
//$activation = md5($password);
示例#30
0
 /**
  * Method to save the form data.
  *
  * @param   array  $temp  The form data.
  *
  * @return  mixed  The user id on success, false on failure.
  *
  * @since   1.6
  */
 public function register($temp)
 {
     $params = JComponentHelper::getParams('com_users');
     // Initialise the table with JUser.
     $user = new JUser();
     $data = (array) $this->getData();
     // Merge in the registration data.
     foreach ($temp as $k => $v) {
         $data[$k] = $v;
     }
     // Prepare the data for the user object.
     $data['email'] = JStringPunycode::emailToPunycode($data['email1']);
     $data['password'] = $data['password1'];
     $useractivation = $params->get('useractivation');
     $sendpassword = $params->get('sendpassword', 1);
     // Check if the user needs to activate their account.
     if ($useractivation == 1 || $useractivation == 2) {
         $data['activation'] = JApplicationHelper::getHash(JUserHelper::genRandomPassword());
         $data['block'] = 1;
     }
     // Bind the data.
     if (!$user->bind($data)) {
         $this->setError(JText::sprintf('COM_USERS_REGISTRATION_BIND_FAILED', $user->getError()));
         return false;
     }
     // Load the users plugin group.
     JPluginHelper::importPlugin('user');
     // Store the data.
     if (!$user->save()) {
         $this->setError(JText::sprintf('COM_USERS_REGISTRATION_SAVE_FAILED', $user->getError()));
         return false;
     }
     $config = JFactory::getConfig();
     $db = $this->getDbo();
     $query = $db->getQuery(true);
     // Compile the notification mail values.
     $data = $user->getProperties();
     $data['fromname'] = $config->get('fromname');
     $data['mailfrom'] = $config->get('mailfrom');
     $data['sitename'] = $config->get('sitename');
     $data['siteurl'] = JUri::root();
     // Handle account activation/confirmation emails.
     if ($useractivation == 2) {
         // Set the link to confirm the user email.
         $uri = JUri::getInstance();
         $base = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port'));
         $data['activate'] = $base . JRoute::_('index.php?option=com_users&task=registration.activate&token=' . $data['activation'], false);
         // Remove administrator/ from activate url in case this method is called from admin
         if (JFactory::getApplication()->isAdmin()) {
             $adminPos = strrpos($data['activate'], 'administrator/');
             $data['activate'] = substr_replace($data['activate'], '', $adminPos, 14);
         }
         $emailSubject = JText::sprintf('COM_USERS_EMAIL_ACCOUNT_DETAILS', $data['name'], $data['sitename']);
         if ($sendpassword) {
             $emailBody = JText::sprintf('COM_USERS_EMAIL_REGISTERED_WITH_ADMIN_ACTIVATION_BODY', $data['name'], $data['sitename'], $data['activate'], $data['siteurl'], $data['username'], $data['password_clear']);
         } else {
             $emailBody = JText::sprintf('COM_USERS_EMAIL_REGISTERED_WITH_ADMIN_ACTIVATION_BODY_NOPW', $data['name'], $data['sitename'], $data['activate'], $data['siteurl'], $data['username']);
         }
     } elseif ($useractivation == 1) {
         // Set the link to activate the user account.
         $uri = JUri::getInstance();
         $base = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port'));
         $data['activate'] = $base . JRoute::_('index.php?option=com_users&task=registration.activate&token=' . $data['activation'], false);
         // Remove administrator/ from activate url in case this method is called from admin
         if (JFactory::getApplication()->isAdmin()) {
             $adminPos = strrpos($data['activate'], 'administrator/');
             $data['activate'] = substr_replace($data['activate'], '', $adminPos, 14);
         }
         $emailSubject = JText::sprintf('COM_USERS_EMAIL_ACCOUNT_DETAILS', $data['name'], $data['sitename']);
         if ($sendpassword) {
             $emailBody = JText::sprintf('COM_USERS_EMAIL_REGISTERED_WITH_ACTIVATION_BODY', $data['name'], $data['sitename'], $data['activate'], $data['siteurl'], $data['username'], $data['password_clear']);
         } else {
             $emailBody = JText::sprintf('COM_USERS_EMAIL_REGISTERED_WITH_ACTIVATION_BODY_NOPW', $data['name'], $data['sitename'], $data['activate'], $data['siteurl'], $data['username']);
         }
     } else {
         $emailSubject = JText::sprintf('COM_USERS_EMAIL_ACCOUNT_DETAILS', $data['name'], $data['sitename']);
         if ($sendpassword) {
             $emailBody = JText::sprintf('COM_USERS_EMAIL_REGISTERED_BODY', $data['name'], $data['sitename'], $data['siteurl'], $data['username'], $data['password_clear']);
         } else {
             $emailBody = JText::sprintf('COM_USERS_EMAIL_REGISTERED_BODY_NOPW', $data['name'], $data['sitename'], $data['siteurl']);
         }
     }
     // Send the registration email.
     $return = JFactory::getMailer()->sendMail($data['mailfrom'], $data['fromname'], $data['email'], $emailSubject, $emailBody);
     // Send Notification mail to administrators
     if ($params->get('useractivation') < 2 && $params->get('mail_to_admin') == 1) {
         $emailSubject = JText::sprintf('COM_USERS_EMAIL_ACCOUNT_DETAILS', $data['name'], $data['sitename']);
         $emailBodyAdmin = JText::sprintf('COM_USERS_EMAIL_REGISTERED_NOTIFICATION_TO_ADMIN_BODY', $data['name'], $data['username'], $data['siteurl']);
         // Get all admin users
         $query->clear()->select($db->quoteName(array('name', 'email', 'sendEmail')))->from($db->quoteName('#__users'))->where($db->quoteName('sendEmail') . ' = ' . 1);
         $db->setQuery($query);
         try {
             $rows = $db->loadObjectList();
         } catch (RuntimeException $e) {
             $this->setError(JText::sprintf('COM_USERS_DATABASE_ERROR', $e->getMessage()), 500);
             return false;
         }
         // Send mail to all superadministrators id
         foreach ($rows as $row) {
             $return = JFactory::getMailer()->sendMail($data['mailfrom'], $data['fromname'], $row->email, $emailSubject, $emailBodyAdmin);
             // Check for an error.
             if ($return !== true) {
                 $this->setError(JText::_('COM_USERS_REGISTRATION_ACTIVATION_NOTIFY_SEND_MAIL_FAILED'));
                 return false;
             }
         }
     }
     // Check for an error.
     if ($return !== true) {
         $this->setError(JText::_('COM_USERS_REGISTRATION_SEND_MAIL_FAILED'));
         // Send a system message to administrators receiving system mails
         $db = $this->getDbo();
         $query->clear()->select($db->quoteName(array('name', 'email', 'sendEmail', 'id')))->from($db->quoteName('#__users'))->where($db->quoteName('block') . ' = ' . (int) 0)->where($db->quoteName('sendEmail') . ' = ' . (int) 1);
         $db->setQuery($query);
         try {
             $sendEmail = $db->loadColumn();
         } catch (RuntimeException $e) {
             $this->setError(JText::sprintf('COM_USERS_DATABASE_ERROR', $e->getMessage()), 500);
             return false;
         }
         if (count($sendEmail) > 0) {
             $jdate = new JDate();
             // Build the query to add the messages
             foreach ($sendEmail as $userid) {
                 $values = array($db->quote($userid), $db->quote($userid), $db->quote($jdate->toSql()), $db->quote(JText::_('COM_USERS_MAIL_SEND_FAILURE_SUBJECT')), $db->quote(JText::sprintf('COM_USERS_MAIL_SEND_FAILURE_BODY', $return, $data['username'])));
                 $query->clear()->insert($db->quoteName('#__messages'))->columns($db->quoteName(array('user_id_from', 'user_id_to', 'date_time', 'subject', 'message')))->values(implode(',', $values));
                 $db->setQuery($query);
                 try {
                     $db->execute();
                 } catch (RuntimeException $e) {
                     $this->setError(JText::sprintf('COM_USERS_DATABASE_ERROR', $e->getMessage()), 500);
                     return false;
                 }
             }
         }
         return false;
     }
     if ($useractivation == 1) {
         return "useractivate";
     } elseif ($useractivation == 2) {
         return "adminactivate";
     } else {
         return $user->id;
     }
 }