本文整理汇总了PHP中JUserHelper类的典型用法代码示例。如果您正苦于以下问题:PHP JUserHelper类的具体用法?PHP JUserHelper怎么用?PHP JUserHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JUserHelper类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getLogin
/** User Login Task */
public function getLogin()
{
$db = JFactory::getDbo();
header("Content-Type: application/json; charset=UTF-8");
// ["fields",{"product_id":"10"}]
//$data=json_decode(JRequest::getVar('fields'),true);
//$product_id= $data['product_id'];
$result = array();
$username = JRequest::getVar('username');
$password = JRequest::getVar('password');
$query = $db->getQuery(true);
$query->select('*')->from($db->quoteName('#__users'))->where($db->quoteName('username') . " = " . $db->quote($username));
$db->setQuery($query);
$data = $db->loadAssocList();
foreach ($data as $results) {
$dbpassword = $results['password'];
$dbuserid = $results['id'];
}
if (JUserHelper::verifyPassword($password, $dbpassword, $dbuserid)) {
$datelogged = date('Y-m-d H:i:s');
$dat = array('status' => '1', 'result' => $results);
echo json_encode($dat);
exit;
} else {
$dat = array('status' => '0', 'result' => '');
echo json_encode($dat);
exit;
}
}
开发者ID:ranrolls,项目名称:php-web-offers-portal,代码行数:30,代码来源:controller.php
示例2: 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
示例3: createUser
/**
* Function to create a user of Joomla.
*
* @param array $params associated array
* @param string $mail email id for cms user
*
* @return uid if user exists, false otherwise
*
* @access public
*/
function createUser(&$params, $mail)
{
require_once JPATH_SITE . '/components/com_users/models/registration.php';
$userParams = JComponentHelper::getParams('com_users');
$model = new UsersModelRegistration();
$ufID = NULL;
// get the default usertype
$userType = $userParams->get('new_usertype');
if (!$userType) {
$userType = 2;
}
if (isset($params['name'])) {
$fullname = trim($params['name']);
} elseif (isset($params['contactID'])) {
$fullname = trim(CRM_Contact_BAO_Contact::displayName($params['contactID']));
} else {
$fullname = trim($params['cms_name']);
}
// Prepare the values for a new Joomla user.
$values = array();
$values['name'] = $fullname;
$values['username'] = trim($params['cms_name']);
$values['password1'] = $values['password2'] = $params['cms_pass'];
$values['email1'] = $values['email2'] = trim($params[$mail]);
$lang = JFactory::getLanguage();
$lang->load('com_users');
$register = $model->register($values);
$ufID = JUserHelper::getUserId($values['username']);
return $ufID;
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:40,代码来源:Joomla.php
示例4: 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
示例5: getInstance
/**
* Returns the global KunenaUser object, only creating it if it doesn't already exist.
*
* @access public
* @param int $id The user to load - Can be an integer or string - If string, it is converted to ID automatically.
* @return JUser The User object.
* @since 1.6
*/
public static function getInstance($identifier = null, $reset = false)
{
$c = __CLASS__;
if ($identifier instanceof KunenaUser) {
return $identifier;
}
if ($identifier === null || $identifier === false) {
$identifier = JFactory::getUser();
}
// Find the user id
if ($identifier instanceof JUser) {
$id = intval($identifier->id);
} else {
if (is_numeric($identifier)) {
$id = intval($identifier);
} else {
jimport('joomla.user.helper');
$id = intval(JUserHelper::getUserId((string) $identifier));
}
}
if ($id < 1) {
return new $c();
}
if (!$reset && empty(self::$_instances[$id])) {
self::$_instances[$id] = new $c($id);
}
return self::$_instances[$id];
}
开发者ID:redigy,项目名称:Kunena-1.6,代码行数:36,代码来源:user.php
示例6: 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
示例7: 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
示例8: authenticate
private function authenticate($username, $password = null, $valid = 86400)
{
// Get a database object
$db = JFactory::getDbo();
// Look for any tokens for this user
$db->setQuery($db->getQuery(true)->select('*')->from('#__rvs_user_tokens')->where('uid=' . $db->q($result->id)));
$obj = $db->loadObject();
// If there is already a valid token, just return that, otherwise try to create one
if ($obj->valid > JDate::getInstance()->toUnix()) {
return $obj->token;
} else {
$db->setQuery($db->getQuery(true)->select('id, password')->from('#__users')->where('username=' . $db->q($username)));
$result = $db->loadObject();
$parts = explode(':', $result->password);
$crypt = $parts[0];
$salt = @$parts[1];
$testcrypt = JUserHelper::getCryptedPassword($password, $salt);
if ($crypt == $testcrypt) {
// Authentication successful, create a token and populate the table
$obj = new stdClass();
$obj->uid = $result->id;
$obj->token = md5(rand() . $salt);
$obj->valid = JDate::getInstance()->toUnix() + $valid;
$db->setQuery($db->getQuery(true)->select('uid')->from('#__rvs_user_tokens')->where('uid=' . $db->q($obj->uid)));
if ($db->loadResult()) {
$db->updateObject('#__rvs_user_tokens', $obj, 'uid');
} else {
$db->insertObject('#__rvs_user_tokens', $obj, 'uid');
}
return $obj->token;
}
}
return null;
}
开发者ID:rvsjoen,项目名称:joomla-extensions,代码行数:34,代码来源:rvs_token.php
示例9: _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
示例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: display
function display($tpl = NULL)
{
/**
* @var JSite $app
*/
$app = JFactory::getApplication();
$this->params = $app->getParams();
/* Default Page fallback*/
$active = $app->getMenu()->getActive();
if (NULL == $active) {
$this->params->merge($app->getMenu()->getDefault()->params);
$active = $app->getMenu()->getDefault();
}
$this->currentItemid = $active->id;
$entriesPerPage = $this->params->get('max_events_per_page', 12);
$model = $this->getModel('events');
$eventModel = JModelLegacy::getInstance('Event', 'EventgalleryModel');
$recursive = $this->params->get('show_items_per_category_recursive', false);
$user = JFactory::getUser();
$usergroups = JUserHelper::getUserGroups($user->id);
$entries = $model->getEntries(JRequest::getVar('start', 0), $entriesPerPage, $this->params->get('tags'), $this->params->get('sort_events_by'), $usergroups, $this->params->get('catid', null), $recursive);
$this->pageNav = $model->getPagination();
$this->entries = $entries;
$this->eventModel = $eventModel;
$this->_prepareDocument();
parent::display($tpl);
}
开发者ID:sansandeep143,项目名称:av,代码行数:27,代码来源:view.html.php
示例12: 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
示例13: Authecticate
public function Authecticate()
{
global $dbObj, $common;
$username = $common->replaceEmpty('username', '');
$userpassword = $common->replaceEmpty('password', '');
$result = array();
if ($action = 'login') {
$sql_username = "SELECT * from ras_users where username = '" . $username . "' and block = '0' ";
$rs_username = $dbObj->runQuery($sql_username);
if ($rows_username = mysql_fetch_assoc($rs_username)) {
$dbpassword = $rows_username['password'];
if (JUserHelper::verifyPassword($userpassword, $rows_username['password'], $rows_username['id'])) {
$datelogged = date('Y-m-d H:i:s');
$sqlLog = "INSERT INTO ras_user_visit_log SET userID='" . $rows_username['id'] . "', useFrom = 'Android', dateLogged='" . $datelogged . "'";
$dbObj->runQuery($sqlLog);
$result[] = $rows_username;
echo json_encode(array('status' => '1', $result));
} else {
$result[] = "0";
echo json_encode($result);
}
} else {
$result[] = "No Record";
echo json_encode($result);
}
}
// action close
}
开发者ID:ranrolls,项目名称:php-web-services,代码行数:28,代码来源:Login.class.php
示例14: isAdmin
/**
* the user is admin?
* @param JUser $user
* @return boolean
*/
public function isAdmin($user = false)
{
jimport('joomla.user.helper');
if ($user == false) {
$user = JFactory::getUser();
}
$result = false;
if ($user) {
$groups = JUserHelper::getUserGroups($user->id);
//DBG foreach($groups as $fn => $fv) echo '<p>'.$fn.'='.$fv.'</p>'; exit();
$admin_groups = array();
//put all the groups that you consider to be admins
$admin_groups[] = "Super Users";
$admin_groups[] = "Administrator";
$admin_groups[] = "Manager";
$admin_groups[] = "8";
$admin_groups[] = "7";
$admin_groups[] = "6";
foreach ($admin_groups as $temp) {
if (!empty($groups[$temp])) {
$result = true;
}
}
}
return $result;
}
开发者ID:madcsaba,项目名称:li-de,代码行数:31,代码来源:temakorok.php
示例15: 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
示例16: display
function display($tpl = null)
{
$option = JRequest::getCMD('option');
$mainframe = JFactory::getApplication();
$user = JFactory::getUser();
if ($user->get('guest')) {
// Redirect to login
$uri = JFactory::getURI();
$mainframe->redirect('index.php?option=com_users&view=login&return=' . base64_encode($uri), null);
return;
} else {
$groups = JUserHelper::getUserGroups($user->get('id'));
if (!in_array(4, $groups)) {
JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR'));
return;
}
}
$document =& JFactory::getDocument();
//$document->addScript( '/media/system/js/viewutils.js');
//$document->addScript('/media/system/js/mootools1.js');
//$document->addStyleSheet('/media/system/css/global.css');
//$document->addStyleSheet('/media/system/css/content.css');
$document->addStylesheet('/media/system/css/ZoneStyle.css');
$helper = new comZonalesHelper();
$this->assignRef('template', $mainframe->getTemplate());
$this->assignRef('user', $user);
$host = 'localhost';
$this->assignRef('tomcat_host', $host);
$port = '38080';
$this->assignRef('tomcat_port', $port);
$this->assignRef('zonal_id', ucwords(str_replace("_", "+", $helper->getZonalActual())));
parent::display($tpl);
}
开发者ID:BGCX261,项目名称:zonales-svn-to-git,代码行数:33,代码来源:view.html.php
示例17: 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
示例18: onAuthenticate
function onAuthenticate($credentials, $options, &$response)
{
jimport('joomla.user.helper');
if (empty($credentials['password'])) {
$response->status = JAUTHENTICATE_STATUS_FAILURE;
$response->error_message = 'Empty password not allowed';
return false;
}
$db =& JFactory::getDBO();
$sql = 'SELECT `id`, `password`, `gid` FROM `#__users` WHERE payroll=' . $db->Quote($credentials['username']);
$db->setQuery($sql);
$result = $db->loadObject();
if ($result) {
$parts = explode(':', $result->password);
$crypt = $parts[0];
$salt = @$parts[1];
$testcrypt = JUserHelper::getCryptedPassword($credentials['password'], $salt);
if ($crypt == $testcrypt) {
$user = JUser::getInstance($result->id);
// Bring this in line with the rest of the system
$response->username = $user->username;
$response->email = $user->email;
$response->fullname = $user->name;
$response->status = JAUTHENTICATE_STATUS_SUCCESS;
$response->error_message = '';
} else {
$response->status = JAUTHENTICATE_STATUS_FAILURE;
$response->error_message = 'Invalid password';
}
} else {
$response->status = JAUTHENTICATE_STATUS_FAILURE;
$response->error_message = 'User does not exist';
}
}
开发者ID:patricmutwiri,项目名称:Payroll-Login-J1.5,代码行数:34,代码来源:plogin.php
示例19: handle
public function handle()
{
require_once PATH_CORE . DS . 'components' . DS . 'com_storefront' . DS . 'models' . DS . 'Memberships.php';
$ms = new \Components\Storefront\Models\Memberships();
/* NEW
$subscription = StorefrontModelMemberships::getSubscriptionObject($this->type, $this->pId, $this->uId);
// Get the expiration for the current subscription (if any)
$currentExpiration = $subscription->getExpiration();
*/
// Get current registration
$membership = $ms->getMembershipInfo($this->crtId, $this->item['info']->pId);
$expiration = $membership['crtmExpires'];
/* Add the user to the corresponding user access group (pull access group ID from the meta) */
try {
// Get user ID for the cart
require_once dirname(dirname(dirname(__DIR__))) . DS . 'models' . DS . 'Cart.php';
$userId = \Components\Cart\Models\Cart::getCartUser($this->crtId);
// Get the user group ID to set the user to (from meta)
require_once PATH_CORE . DS . 'components' . DS . 'com_storefront' . DS . 'models' . DS . 'Product.php';
$userGId = \Components\Storefront\Models\Product::getMeta($this->item['info']->pId, 'userGroupId');
$add = \JUserHelper::addUserToGroup($userId, $userGId);
if ($add instanceof \Exception) {
mail(Config::get('mailfrom'), 'Error adding to the group', $add->getMessage() . ' Cart #' . $this->crtId);
}
$table = \JTable::getInstance('User', 'JTable', array());
$table->load($userId);
// Trigger the onAftereStoreUser event
Event::trigger('onUserAfterSave', array($table->getProperties(), false, true, null));
} catch (Exception $e) {
// Error
return false;
}
}
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:33,代码来源:Access_Group_Membership_Type_Handler.php
示例20: validate
/**
* validate the elements data against the rule
* @param string data to check
* @param object element
* @param int plugin sequence ref
* @return bol true if validation passes, false if fails
*/
function validate($data, &$element, $c)
{
$params =& $this->getParams();
$ornot = $params->get('userexists_or_not');
$condition = $params->get('userexists-validation_condition');
$condition = $condition[$c];
if ($condition !== '') {
if (@eval($condition)) {
return true;
}
}
$ornot = $ornot[$c];
jimport('joomla.user.helper');
$id = 0;
if (!($id = JUserHelper::getUserId($data))) {
if ($ornot == 'fail_if_exists') {
return true;
}
} else {
if ($ornot == 'fail_if_not_exists') {
return true;
}
}
return false;
}
开发者ID:nickbunyan,项目名称:fabrik,代码行数:32,代码来源:userexists.php
注:本文中的JUserHelper类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论