当前位置: 首页>>代码示例>>PHP>>正文


PHP JUserHelper::genRandomPassword方法代码示例

本文整理汇总了PHP中JUserHelper::genRandomPassword方法的典型用法代码示例。如果您正苦于以下问题:PHP JUserHelper::genRandomPassword方法的具体用法?PHP JUserHelper::genRandomPassword怎么用?PHP JUserHelper::genRandomPassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JUserHelper的用法示例。


在下文中一共展示了JUserHelper::genRandomPassword方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createNewUser

 public function createNewUser($params)
 {
     $user = new JUser(0);
     JLoader::import('joomla.application.component.helper');
     $usersConfig = JComponentHelper::getParams('com_users');
     $newUsertype = $usersConfig->get('new_usertype');
     // get the New User Group from com_users' settings
     if (empty($newUsertype)) {
         $newUsertype = 2;
     }
     $params['groups'] = array($newUsertype);
     $params['sendEmail'] = 0;
     // Set the user's default language to whatever the site's current language is
     if (version_compare(JVERSION, '3.0', 'ge')) {
         $params['params'] = array('language' => JFactory::getConfig()->get('language'));
     } else {
         $params['params'] = array('language' => JFactory::getConfig()->getValue('config.language'));
     }
     JLoader::import('joomla.user.helper');
     $params['block'] = 0;
     $randomString = JUserHelper::genRandomPassword();
     if (version_compare(JVERSION, '3.2', 'ge')) {
         $hash = JApplication::getHash($randomString);
     } else {
         $hash = JFactory::getApplication()->getHash($randomString);
     }
     $params['activation'] = $hash;
     $user->bind($params);
     $userIsSaved = $user->save();
     if ($userIsSaved) {
         return $user->id;
     } else {
         return false;
     }
 }
开发者ID:jonatasmm,项目名称:akeebasubs,代码行数:35,代码来源:jusers.php

示例2: ajaxSaveRow

 function ajaxSaveRow()
 {
     $user = JFactory::getUser();
     $id = $user->get('id');
     jimport('joomla.mail.helper');
     jimport('joomla.user.helper');
     global $mainframe;
     $db =& JFactory::getDBO();
     $varolan = JRequest::getVar('varolan');
     $yeni = JRequest::getVar('yeni');
     $sql = "select password from jos_users where id={$id}";
     $liste = mysql_fetch_array(mysql_query($sql));
     $parts = explode(":", $liste[password]);
     $crypt = $parts[0];
     $salt = @$parts[1];
     $testcrypt = JUserHelper::getCryptedPassword($varolan, $salt);
     if ($crypt == $testcrypt) {
         $salt = JUserHelper::genRandomPassword(32);
         $crypt = JUserHelper::getCryptedPassword($yeni, $salt);
         $password = $crypt . ':' . $salt;
         $query = 'UPDATE #__users' . ' SET `password` = "' . $password . '"' . ' WHERE id = ' . (int) $id . ' AND block = 0';
         $db->setQuery($query);
         $db->query();
         echo "<p align=center>Şifreniz başarıyla değiştirildi.</p>";
     } else {
         echo "<p align=center>Geçerli şifreniz yanlış.</p><p align=center><a href='index.php?option=com_user&view=changepass'>Yeniden deneyiniz</a></p>";
     }
 }
开发者ID:kaantunc,项目名称:MYK-BOR,代码行数:28,代码来源:changepass.php

示例3: onUserAfterLogin

 /**
  * Password is saved to Joomla DB after succesful authentication
  *
  * @access    public
  * @return    boolean
  * @since 1.5
  */
 function onUserAfterLogin()
 {
     /* po uspesnem prihlaseni ulozime heslo */
     if (isset($_POST["password"]) && $_POST["password"] != "") {
         // misto $_POST["password"] by melo byt
         //$jinput = JFactory::getApplication()->input;
         //$password = $jinput->get('password', '', 'STRING');
         // http://stackoverflow.com/questions/2727043/using-php-to-create-a-joomla-user-password
         jimport('joomla.user.helper');
         $salt = JUserHelper::genRandomPassword(32);
         $crypt = JUserHelper::getCryptedPassword($_POST["password"], $salt);
         $password = $crypt . ':' . $salt;
         // Get a database object
         $user = JFactory::getUser();
         $db =& JFactory::getDBO();
         $query = $db->getQuery(true);
         $fields = array($db->quoteName('password') . ' = "' . $password . '"');
         $conditions = array($db->quoteName('username') . ' = "' . $user->username . '"');
         $query->update($db->quoteName('#__users'))->set($fields)->where($conditions);
         $db->setQuery($query);
         $result = $db->execute();
         return $result;
     }
     return false;
 }
开发者ID:haterzlin,项目名称:joomla_opensso_login,代码行数:32,代码来源:savepasswd.php

示例4: _owner

 function _owner($getgroup = false)
 {
     static $owner = false;
     static $group = false;
     if ($getgroup === false && !empty($owner)) {
         return $owner;
     }
     if ($getgroup === true && !empty($group)) {
         return $group;
     }
     jimport('joomla.user.helper');
     $tmp = md5(JUserHelper::genRandomPassword(16));
     $dir = self::tmpdir();
     if ($dir) {
         $test = $dir . DS . $tmp;
         // Create the test file
         JFile::write($test, '');
         // Test ownership
         $owner = fileowner($test);
         $group = filegroup($test);
         // Delete the test file
         JFile::delete($test);
     }
     return $getgroup ? $group : $owner;
 }
开发者ID:kaantunc,项目名称:MYK-BOR,代码行数:25,代码来源:kunena.file.class.php

示例5: action

 public function action($request)
 {
     $db = JFactory::getDBO();
     $set = array();
     if ($this->settings['activate']) {
         $set[] = '`block` = \'0\'';
         $set[] = '`activation` = \'\'';
     }
     $username = $this->getUsername($request);
     if (!empty($username)) {
         $set[] = '`username` = \'' . $username . '\'';
     }
     if (!empty($this->settings['password'])) {
         $pw = AECToolbox::rewriteEngineRQ($this->settings['password'], $request);
         jimport('joomla.user.helper');
         $salt = JUserHelper::genRandomPassword(32);
         $crypt = JUserHelper::getCryptedPassword($pw, $salt);
         $password = $crypt . ':' . $salt;
         $set[] = '`password` = \'' . $password . '\'';
     }
     if (!empty($set)) {
         $query = 'UPDATE #__users';
         $query .= ' SET ' . implode(', ', $set);
         $query .= ' WHERE `id` = \'' . (int) $request->metaUser->userid . '\'';
         $db->setQuery($query);
         $db->query() or die($db->stderr());
         $userid = $request->metaUser->userid;
         // Reloading metaUser object for other MIs
         $request->metaUser = new metaUser($userid);
     }
     if (!empty($this->settings['set_fields'])) {
         $this->setFields($request);
     }
 }
开发者ID:Ibrahim1,项目名称:aec,代码行数:34,代码来源:joomlauser.php

示例6: simple_registration

 function simple_registration($username, $password, $name, $email, $defaultUserGroups = array(2))
 {
     //Default group 2=registered
     $result = array('error', 'message');
     $usersConfig =& JComponentHelper::getParams('com_users');
     if ($usersConfig->get('allowUserRegistration') == '1') {
         //PASSWORD
         $salt = JUserHelper::genRandomPassword(32);
         $password_clear = $password;
         $crypted = JUserHelper::getCryptedPassword($password_clear, $salt);
         $password = $crypted . ':' . $salt;
         //set
         $instance = JUser::getInstance();
         $instance->set('id', 0);
         $instance->set('name', $name);
         $instance->set('username', $username);
         $instance->set('password', $password);
         $instance->set('password_clear', $password_clear);
         $instance->set('email', $email);
         $instance->set('groups', $defaultUserGroups);
         if (!$instance->save()) {
             //resultat
             $result['error'] = true;
             $result['message'] = 'bad data';
         } else {
             $result['error'] = false;
             $result['message'] = 'success';
         }
     } else {
         $result['error'] = true;
         $result['message'] = 'no allow user registration';
     }
     return $result;
 }
开发者ID:rizerok,项目名称:joomla,代码行数:34,代码来源:users_lib.php

示例7: addTempUser

 public function addTempUser($data)
 {
     $db =& $this->getDBO();
     //get current session id.
     $mySess =& JFactory::getSession();
     $token = $mySess->get('JS_REG_TOKEN', '');
     $nowDate = JFactory::getDate();
     $nowDate = $nowDate->toMysql();
     // Combine firsname and last name as full name
     if (empty($data['jsname'])) {
         $data['jsname'] = $data['jsfirstname'] . ' ' . $data['jslastname'];
     }
     $obj = new stdClass();
     $obj->name = $data['jsname'];
     $obj->firstname = isset($data['jsfirstname']) ? $data['jsfirstname'] : '';
     $obj->lastname = isset($data['jslastname']) ? $data['jslastname'] : '';
     $obj->token = $token;
     $obj->username = $data['jsusername'];
     $obj->email = $data['jsemail'];
     $obj->password = $data['jspassword'];
     $obj->created = $nowDate;
     $obj->ip = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
     // no clear text password store in db
     jimport('joomla.user.helper');
     $salt = JUserHelper::genRandomPassword(32);
     $crypt = JUserHelper::getCryptedPassword($obj->password, $salt);
     $obj->password = $crypt . ':' . $salt;
     $db->insertObject('#__community_register', $obj);
     if ($db->getErrorNum()) {
         JError::raiseError(500, $db->stderr());
     }
     $this->return_value[__FUNCTION__] = true;
     return $this;
 }
开发者ID:Simarpreet05,项目名称:joomla,代码行数:34,代码来源:register.php

示例8: tmpdir

	function tmpdir()
	{
		static $tmpdir=false;
		if ($tmpdir) return realpath($tmpdir);

		jimport('joomla.filesystem.file');
		jimport('joomla.user.helper');

		$tmp = md5(JUserHelper::genRandomPassword(16));
		$ssp = ini_get('session.save_path');
		$jtp = JPATH_SITE.'/tmp';

		// Try to find a writable directory
		$tmpdir = @is_writable('/tmp') ? '/tmp' : false;
//		$tmpdir = (!$tmpdir && is_writable($ssp)) ? $ssp : false;
		$tmpdir = (!$tmpdir && is_writable($jtp)) ? $jtp : false;

		if (!$tmpdir) {
			$temp=tempnam(JPATH_ROOT . '/tmp','');
			if (file_exists($temp)) {
				unlink($temp);
				$tmpdir = dirname($temp);
			}
		}
		return realpath($tmpdir);
	}
开发者ID:GoremanX,项目名称:Kunena-2.0,代码行数:26,代码来源:kunena.file.class.1.6.php

示例9: createCoupon

 public function createCoupon($key, $pwd)
 {
     // Do I have a key/pwd pair?
     if (!$key || !$pwd) {
         return array('error' => JText::_('COM_AKEEBASUBS_APICOUPONS_INVALID_CREDENTIALS'));
     }
     $table = $this->getTable();
     $table->load(array('key' => $key, 'password' => $pwd));
     // Are they valid?
     if (!$table->akeebasubs_apicoupon_id || !$table->enabled) {
         return array('error' => JText::_('COM_AKEEBASUBS_APICOUPONS_INVALID_CREDENTIALS'));
     }
     // Do I hit a limit?
     if (!$this->performApiChecks($table)) {
         return array('error' => JText::_('COM_AKEEBASUBS_APICOUPONS_LIMIT_EXCEEDED'));
     }
     // If I'm here, I'm clear to go
     JLoader::import('joomla.user.helper');
     $coupon = F0FTable::getAnInstance('Coupon', 'AkeebasubsTable');
     $data['akeebasubs_apicoupon_id'] = $table->akeebasubs_apicoupon_id;
     $data['title'] = 'API coupon for: ' . $table->title;
     $data['coupon'] = strtoupper(JUserHelper::genRandomPassword(10));
     $data['subscriptions'] = $table->subscriptions;
     // By default I want the coupon to be single-use
     $data['hitslimit'] = 1;
     $data['userhits'] = 1;
     $data['type'] = $table->type;
     $data['value'] = $table->value;
     if (!$coupon->save($data)) {
         return array('error' => JText::_('COM_AKEEBASUBS_APICOUPONS_COUPON_ERROR'));
     }
     return array('coupon' => $coupon->coupon);
 }
开发者ID:jonatasmm,项目名称:akeebasubs,代码行数:33,代码来源:apicoupons.php

示例10: generateToken

 /**
  * Generate token here to standardize the token generation
  * @condition if the userId is provided it will be assign to the user directly
  * @see assignToken()
  * @return String generated token
  */
 public function generateToken()
 {
     $salt = JUserHelper::genRandomPassword(20);
     $crypt = JUserHelper::getCryptedPassword(rand(), $salt);
     $token = $crypt . ':' . $salt;
     return $token;
 }
开发者ID:ErickLopez76,项目名称:offiria,代码行数:13,代码来源:token.php

示例11: storeDatabaseFormat

 /**
  * Manupulates posted form data for insertion into database
  *
  * @param   mixed  $val   this elements posted form data
  * @param   array  $data  posted form data
  *
  * @return  mixed
  */
 public function storeDatabaseFormat($val, $data)
 {
     jimport('joomla.user.helper');
     $salt = JUserHelper::genRandomPassword(32);
     $crypt = JUserHelper::getCryptedPassword($val, $salt);
     $val = $crypt . ':' . $salt;
     return $val;
 }
开发者ID:rogeriocc,项目名称:fabrik,代码行数:16,代码来源:password.php

示例12: hashPassword

 function hashPassword($password)
 {
     require_once JPATH_BASE . '/includes/defines.php';
     require_once JPATH_LIBRARIES . '/joomla/user/helper.php';
     $salt = JUserHelper::genRandomPassword(32);
     $crypt = JUserHelper::getCryptedPassword($password, $salt);
     return "{$crypt}:{$salt}";
 }
开发者ID:roboshed,项目名称:Zuluru,代码行数:8,代码来源:user_joomla.php

示例13: requiresActivation

 /**
  * Automatically sets the activation token for the user.
  *
  * @return LibUsersDomainEntityUser
  */
 public function requiresActivation()
 {
     jimport('joomla.user.helper');
     $token = JUtility::getHash(JUserHelper::genRandomPassword());
     $salt = JUserHelper::getSalt();
     $hashedToken = sha1($token . $salt) . ':' . $salt;
     $this->activation = $hashedToken;
     return $this;
 }
开发者ID:stonyyi,项目名称:anahita,代码行数:14,代码来源:user.php

示例14: get_format_departure_code

 public static function get_format_departure_code($tsmart_departure_id, $day)
 {
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('departure.tsmart_departure_id')->from('#__tsmart_departure AS departure')->where('departure.tsmart_departure_id=' . (int) $tsmart_departure_id)->innerJoin('#__tsmart_products AS product ON product.tsmart_product_id=departure.tsmart_product_id')->innerJoin('#__tsmart_products_en_gb AS products_en_gb ON products_en_gb.tsmart_product_id=product.tsmart_product_id')->select('products_en_gb.product_name AS product_name')->innerJoin('#__tsmart_service_class AS service_class ON service_class.tsmart_service_class_id=departure.tsmart_service_class_id')->select('service_class.service_class_name');
     $db->setQuery($query);
     $departure_item = $db->loadObject();
     $departure_code = strtoupper(substr($departure_item->product_name, 0, 2) . substr($departure_item->service_class_name, 0, 2) . "SD" . JUserHelper::genRandomPassword(2) . $day->format('dm-y'));
     return $departure_code;
 }
开发者ID:cuongnd,项目名称:etravelservice,代码行数:10,代码来源:tsmdeparture.php

示例15: generatePassword

 public static function generatePassword($text, $is_cripted = false)
 {
     $password = $text;
     if ($is_cripted == false) {
         return $password;
     }
     jimport('joomla.user.helper');
     $salt = JUserHelper::genRandomPassword(8);
     $crypt = JUserHelper::getCryptedPassword($password, $salt);
     $password = $crypt . ":" . $salt;
     return $password;
 }
开发者ID:jmangarret,项目名称:webtuagencia24,代码行数:12,代码来源:UserService.php


注:本文中的JUserHelper::genRandomPassword方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。