本文整理汇总了PHP中getRandomPassword函数的典型用法代码示例。如果您正苦于以下问题:PHP getRandomPassword函数的具体用法?PHP getRandomPassword怎么用?PHP getRandomPassword使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getRandomPassword函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: define
}
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
if (!defined('NOREQUIRESOC')) {
define('NOREQUIRESOC', '1');
}
if (!defined('NOREQUIRETRAN')) {
define('NOREQUIRETRAN', '1');
}
require '../../main.inc.php';
/*
* View
*/
// Ajout directives pour resoudre bug IE
//header('Cache-Control: Public, must-revalidate');
//header('Pragma: public');
//top_htmlhead("", "", 1); // Replaced with top_httphead. An ajax page does not need html header.
top_httphead();
//print '<!-- Ajax page called with url '.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' -->'."\n";
// Registering the location of boxes
if (isset($_GET['action']) && !empty($_GET['action'])) {
if ($_GET['action'] == 'getrandompassword' && $user->admin) {
require_once DOL_DOCUMENT_ROOT . "/core/lib/security2.lib.php";
$generic = $_GET['generic'];
echo getRandomPassword($generic);
}
}
开发者ID:nrjacker4,项目名称:crm-php,代码行数:31,代码来源:security.php
示例2: elseif
print '<tr><td valign="top"><span class="fieldrequired">' . $langs->trans("Login") . '</span></td>';
print '<td>';
if ($ldap_login) {
print '<input type="hidden" name="login" value="' . $ldap_login . '">';
print $ldap_login;
} elseif ($ldap_loginsmb) {
print '<input type="hidden" name="login" value="' . $ldap_loginsmb . '">';
print $ldap_loginsmb;
} else {
print '<input size="20" maxsize="24" type="text" name="login" value="' . $_POST["login"] . '">';
}
print '</td></tr>';
$generated_password = '';
if (!$ldap_sid) {
include_once DOL_DOCUMENT_ROOT . '/lib/security.lib.php';
$generated_password = getRandomPassword('');
}
$password = $generated_password;
// Mot de passe
print '<tr><td valign="top">' . $langs->trans("Password") . '</td>';
print '<td>';
if ($ldap_sid) {
print 'Mot de passe du domaine';
} else {
if ($ldap_pass) {
print '<input type="hidden" name="password" value="' . $ldap_pass . '">';
print preg_replace('/./i', '*', $ldap_pass);
} else {
// We do not use a field password but a field text to show new password to use.
print '<input size="30" maxsize="32" type="text" name="password" value="' . $password . '">';
}
开发者ID:netors,项目名称:dolibarr,代码行数:31,代码来源:fiche.php
示例3: setPassword
/**
* Change password of a user
* @param user Object user de l'utilisateur qui fait la modification
* @param password Nouveau mot de passe (a generer si non communique)
* @param isencrypted 0 ou 1 si il faut crypter le mot de passe en base (0 par defaut)
* @param notrigger 1=Ne declenche pas les triggers
* @param nosyncuser Do not synchronize linked user
* @return string If OK return clear password, 0 if no change, < 0 if error
*/
function setPassword($user, $password = '', $isencrypted = 0, $notrigger = 0, $nosyncuser = 0)
{
global $conf, $langs;
$error = 0;
dol_syslog(get_class($this) . "::setPassword user=" . $user->id . " password=" . preg_replace('/./i', '*', $password) . " isencrypted=" . $isencrypted);
// If new password not provided, we generate one
if (!$password) {
include_once DOL_DOCUMENT_ROOT . '/lib/security.lib.php';
$password = getRandomPassword('');
}
// Cryptage mot de passe
if ($isencrypted) {
// Crypte avec systeme encodage par defaut du PHP
//$sqlpass = crypt($password, makesalt());
$password_indatabase = md5($password);
} else {
$password_indatabase = $password;
}
// Mise a jour
$sql = "UPDATE " . MAIN_DB_PREFIX . "adherent SET pass = '" . $this->db->escape($password_indatabase) . "'";
$sql .= " WHERE rowid = " . $this->id;
//dol_syslog("Adherent::Password sql=hidden");
dol_syslog(get_class($this) . "::setPassword sql=" . $sql);
$result = $this->db->query($sql);
if ($result) {
$nbaffectedrows = $this->db->affected_rows($result);
if ($nbaffectedrows) {
$this->pass = $password;
$this->pass_indatabase = $password_indatabase;
if ($this->user_id && !$nosyncuser) {
require_once DOL_DOCUMENT_ROOT . "/user/class/user.class.php";
// This member is linked with a user, so we also update users informations
// if this is an update.
$luser = new User($this->db);
$result = $luser->fetch($this->user_id);
if ($result >= 0) {
$result = $luser->setPassword($user, $this->pass, 0, 0, 1);
if ($result < 0) {
$this->error = $luser->error;
dol_syslog(get_class($this) . "::setPassword " . $this->error, LOG_ERR);
$error++;
}
} else {
$this->error = $luser->error;
$error++;
}
}
if (!$error && !$notrigger) {
// Appel des triggers
include_once DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php";
$interface = new Interfaces($this->db);
$result = $interface->run_triggers('MEMBER_NEW_PASSWORD', $this, $user, $langs, $conf);
if ($result < 0) {
$error++;
$this->errors = $interface->errors;
}
// Fin appel triggers
}
return $this->pass;
} else {
return 0;
}
} else {
dol_print_error($this->db);
return -1;
}
}
开发者ID:ripasch,项目名称:dolibarr,代码行数:76,代码来源:adherent.class.php
示例4:
// API key
$generated_api_key = '';
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
$generated_password=getRandomPassword(false);
print '<tr><td>'.$langs->trans("ApiKey").'</td>';
print '<td>';
print '<input size="30" maxsize="32" type="text" id="api_key" name="api_key" value="'.$api_key.'" autocomplete="off">';
if (! empty($conf->use_javascript_ajax))
print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_api_key" class="linkobject"');
print '</td></tr>';
}
else
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
// PARTIAL WORKAROUND
$generated_fake_api_key=getRandomPassword(false);
print '<input type="hidden" name="api_key" value="'.$generated_fake_api_key.'">';
}
// Administrator
if (! empty($user->admin))
{
print '<tr><td>'.$langs->trans("Administrator").'</td>';
print '<td>';
print $form->selectyesno('admin',GETPOST('admin'),1);
if (! empty($conf->multicompany->enabled) && ! $user->entity && empty($conf->multicompany->transverse_mode))
{
if (! empty($conf->use_javascript_ajax))
{
print '<script type="text/javascript">
开发者ID:NoisyBoy86,项目名称:Dolibarr_test,代码行数:31,代码来源:card.php
示例5: setPassword
/**
* Change password of a user
*
* @param User $user Object user de l'utilisateur qui fait la modification
* @param string $password New password (to generate if empty)
* @param int $isencrypted 0 ou 1 si il faut crypter le mot de passe en base (0 par defaut)
* @param int $notrigger 1=Ne declenche pas les triggers
* @param int $nosyncuser Do not synchronize linked user
* @return string If OK return clear password, 0 if no change, < 0 if error
*/
function setPassword($user, $password = '', $isencrypted = 0, $notrigger = 0, $nosyncuser = 0)
{
global $conf, $langs;
$error = 0;
dol_syslog(get_class($this) . "::setPassword user=" . $user->id . " password=" . preg_replace('/./i', '*', $password) . " isencrypted=" . $isencrypted);
// If new password not provided, we generate one
if (!$password) {
require_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php';
$password = getRandomPassword(false);
}
// Cryptage mot de passe
if ($isencrypted) {
// Encryption
$password_indatabase = dol_hash($password);
} else {
$password_indatabase = $password;
}
$this->db->begin();
// Mise a jour
$sql = "UPDATE " . MAIN_DB_PREFIX . "adherent SET pass = '" . $this->db->escape($password_indatabase) . "'";
$sql .= " WHERE rowid = " . $this->id;
//dol_syslog("Adherent::Password sql=hidden");
dol_syslog(get_class($this) . "::setPassword", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result) {
$nbaffectedrows = $this->db->affected_rows($result);
if ($nbaffectedrows) {
$this->pass = $password;
$this->pass_indatabase = $password_indatabase;
if ($this->user_id && !$nosyncuser) {
require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php';
// This member is linked with a user, so we also update users informations
// if this is an update.
$luser = new User($this->db);
$result = $luser->fetch($this->user_id);
if ($result >= 0) {
$result = $luser->setPassword($user, $this->pass, 0, 0, 1);
if ($result < 0) {
$this->error = $luser->error;
dol_syslog(get_class($this) . "::setPassword " . $this->error, LOG_ERR);
$error++;
}
} else {
$this->error = $luser->error;
$error++;
}
}
if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger('MEMBER_NEW_PASSWORD', $user);
if ($result < 0) {
$error++;
$this->db->rollback();
return -1;
}
// End call triggers
}
$this->db->commit();
return $this->pass;
} else {
$this->db->rollback();
return 0;
}
} else {
$this->db->rollback();
dol_print_error($this->db);
return -1;
}
}
开发者ID:TAASA,项目名称:Dolibarr-ERP-3.8.1,代码行数:79,代码来源:adherent.class.php
示例6: Societe
}
if (!empty($id) && $action != 'edit' && $action != 'create') {
$objsoc = new Societe($db);
/*
* Fiche en mode visualisation
*/
dol_htmloutput_errors($error, $errors);
dol_fiche_head($head, 'card', $title, 0, 'contact');
if ($action == 'create_user') {
// Full firstname and lastname separated with a dot : firstname.lastname
include_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
$login = dol_buildlogin($object->lastname, $object->firstname);
$generated_password = '';
if (!$ldap_sid) {
require_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php';
$generated_password = getRandomPassword(false);
}
$password = $generated_password;
// Create a form array
$formquestion = array(array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login), array('label' => $langs->trans("Password"), 'type' => 'text', 'name' => 'password', 'value' => $password));
$text = $langs->trans("ConfirmCreateContact") . '<br>';
if (!empty($conf->societe->enabled)) {
if ($object->socid > 0) {
$text .= $langs->trans("UserWillBeExternalUser");
} else {
$text .= $langs->trans("UserWillBeInternalUser");
}
}
print $form->formconfirm($_SERVER["PHP_SELF"] . "?id=" . $object->id, $langs->trans("CreateDolibarrLogin"), $text, "confirm_create_user", $formquestion, 'yes');
}
print '<table class="border" width="100%">';
开发者ID:TAASA,项目名称:Dolibarr-ERP-3.8.1,代码行数:31,代码来源:card.php
示例7: setPassword
/**
* Change password of a user
*
* @param User $user Object user of user making change
* @param string $password New password in clear text (to generate if not provided)
* @param int $changelater 1=Change password only after clicking on confirm email
* @param int $notrigger 1=Does not launch triggers
* @param int $nosyncmember Do not synchronize linked member
* @return string If OK return clear password, 0 if no change, < 0 if error
*/
function setPassword($user, $password = '', $changelater = 0, $notrigger = 0, $nosyncmember = 0)
{
global $conf, $langs;
require_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php';
$error = 0;
dol_syslog(get_class($this) . "::setPassword user=" . $user->id . " password=" . preg_replace('/./i', '*', $password) . " changelater=" . $changelater . " notrigger=" . $notrigger . " nosyncmember=" . $nosyncmember, LOG_DEBUG);
// If new password not provided, we generate one
if (!$password) {
$password = getRandomPassword(false);
}
// Crypte avec md5
$password_crypted = dol_hash($password);
// Mise a jour
if (!$changelater) {
if (!is_object($this->oldcopy)) {
$this->oldcopy = clone $this;
}
$this->db->begin();
$sql = "UPDATE " . MAIN_DB_PREFIX . "user";
$sql .= " SET pass_crypted = '" . $this->db->escape($password_crypted) . "',";
$sql .= " pass_temp = null";
if (!empty($conf->global->DATABASE_PWD_ENCRYPTED)) {
$sql .= ", pass = null";
} else {
$sql .= ", pass = '" . $this->db->escape($password) . "'";
}
$sql .= " WHERE rowid = " . $this->id;
dol_syslog(get_class($this) . "::setPassword", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result) {
if ($this->db->affected_rows($result)) {
$this->pass = $password;
$this->pass_indatabase = $password;
$this->pass_indatabase_crypted = $password_crypted;
if ($this->fk_member && !$nosyncmember) {
require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php';
// This user is linked with a member, so we also update members informations
// if this is an update.
$adh = new Adherent($this->db);
$result = $adh->fetch($this->fk_member);
if ($result >= 0) {
$result = $adh->setPassword($user, $this->pass, 0, 1);
// Cryptage non gere dans module adherent
if ($result < 0) {
$this->error = $adh->error;
dol_syslog(get_class($this) . "::setPassword " . $this->error, LOG_ERR);
$error++;
}
} else {
$this->error = $adh->error;
$error++;
}
}
dol_syslog(get_class($this) . "::setPassword notrigger=" . $notrigger . " error=" . $error, LOG_DEBUG);
if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger('USER_NEW_PASSWORD', $user);
if ($result < 0) {
$error++;
$this->db->rollback();
return -1;
}
// End call triggers
}
$this->db->commit();
return $this->pass;
} else {
$this->db->rollback();
return 0;
}
} else {
$this->db->rollback();
dol_print_error($this->db);
return -1;
}
} else {
// We store clear password in password temporary field.
// After receiving confirmation link, we will crypt it and store it in pass_crypted
$sql = "UPDATE " . MAIN_DB_PREFIX . "user";
$sql .= " SET pass_temp = '" . $this->db->escape($password) . "'";
$sql .= " WHERE rowid = " . $this->id;
dol_syslog(get_class($this) . "::setPassword", LOG_DEBUG);
// No log
$result = $this->db->query($sql);
if ($result) {
return $password;
} else {
dol_print_error($this->db);
return -3;
}
//.........这里部分代码省略.........
开发者ID:Samara94,项目名称:dolibarr,代码行数:101,代码来源:user.class.php
示例8: assign_values
//.........这里部分代码省略.........
if (dol_strlen(trim($this->object->email)) == 0) {
$this->object->email = $objsoc->email;
}
}
// Zip
$this->tpl['select_zip'] = $formcompany->select_ziptown($this->object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6);
// Town
$this->tpl['select_town'] = $formcompany->select_ziptown($this->object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id'));
if (dol_strlen(trim($this->object->country_id)) == 0) {
$this->object->country_id = $objsoc->country_id;
}
// Country
$this->tpl['select_country'] = $form->select_country($this->object->country_id, 'country_id');
$countrynotdefined = $langs->trans("ErrorSetACountryFirst") . ' (' . $langs->trans("SeeAbove") . ')';
if ($user->admin) {
$this->tpl['info_admin'] = info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
}
// State
if ($this->object->country_id) {
$this->tpl['select_state'] = $formcompany->select_state($this->object->fk_departement, $this->object->country_code);
} else {
$this->tpl['select_state'] = $countrynotdefined;
}
// Public or private
$selectarray = array('0' => $langs->trans("ContactPublic"), '1' => $langs->trans("ContactPrivate"));
$this->tpl['select_visibility'] = $form->selectarray('priv', $selectarray, $this->object->priv, 0);
}
if ($action == 'view' || $action == 'edit' || $action == 'delete') {
// Emailing
if (!empty($conf->mailing->enabled)) {
$langs->load("mails");
$this->tpl['nb_emailing'] = $this->object->getNbOfEMailings();
}
// Linked element
$this->tpl['contact_element'] = array();
$i = 0;
$this->object->load_ref_elements();
if (!empty($conf->commande->enabled)) {
$this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForOrders");
$this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_commande ? $this->object->ref_commande : $langs->trans("NoContactForAnyOrder");
$i++;
}
if (!empty($conf->propal->enabled)) {
$this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForProposals");
$this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_propal ? $this->object->ref_propal : $langs->trans("NoContactForAnyProposal");
$i++;
}
if (!empty($conf->contrat->enabled)) {
$this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForContracts");
$this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_contrat ? $this->object->ref_contrat : $langs->trans("NoContactForAnyContract");
$i++;
}
if (!empty($conf->facture->enabled)) {
$this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForInvoices");
$this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_facturation ? $this->object->ref_facturation : $langs->trans("NoContactForAnyInvoice");
$i++;
}
// Dolibarr user
if ($this->object->user_id) {
$dolibarr_user = new User($this->db);
$result = $dolibarr_user->fetch($this->object->user_id);
$this->tpl['dolibarr_user'] = $dolibarr_user->getLoginUrl(1);
} else {
$this->tpl['dolibarr_user'] = $langs->trans("NoDolibarrAccess");
}
}
if ($action == 'view' || $action == 'delete') {
$this->tpl['showrefnav'] = $form->showrefnav($this->object, 'id');
if ($this->object->socid > 0) {
$objsoc = new Societe($this->db);
$objsoc->fetch($this->object->socid);
$this->tpl['company'] = $objsoc->getNomUrl(1);
} else {
$this->tpl['company'] = $langs->trans("ContactNotLinkedToCompany");
}
$this->tpl['civility'] = $this->object->getCivilityLabel();
$this->tpl['address'] = dol_nl2br($this->object->address);
$this->tpl['zip'] = $this->object->zip ? $this->object->zip . ' ' : '';
$img = picto_from_langcode($this->object->country_code);
$this->tpl['country'] = ($img ? $img . ' ' : '') . $this->object->country;
$this->tpl['phone_pro'] = dol_print_phone($this->object->phone_pro, $this->object->country_code, 0, $this->object->id, 'AC_TEL');
$this->tpl['phone_perso'] = dol_print_phone($this->object->phone_perso, $this->object->country_code, 0, $this->object->id, 'AC_TEL');
$this->tpl['phone_mobile'] = dol_print_phone($this->object->phone_mobile, $this->object->country_code, 0, $this->object->id, 'AC_TEL');
$this->tpl['fax'] = dol_print_phone($this->object->fax, $this->object->country_code, 0, $this->object->id, 'AC_FAX');
$this->tpl['email'] = dol_print_email($this->object->email, 0, $this->object->id, 'AC_EMAIL');
$this->tpl['visibility'] = $this->object->LibPubPriv($this->object->priv);
$this->tpl['note'] = nl2br($this->object->note);
}
if ($action == 'create_user') {
// Full firstname and lastname separated with a dot : firstname.lastname
include_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php';
$login = dol_buildlogin($this->object->lastname, $this->object->firstname);
$generated_password = getRandomPassword(false);
$password = $generated_password;
// Create a form array
$formquestion = array(array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login), array('label' => $langs->trans("Password"), 'type' => 'text', 'name' => 'password', 'value' => $password));
$this->tpl['action_create_user'] = $form->formconfirm($_SERVER["PHP_SELF"] . "?id=" . $this->object->id, $langs->trans("CreateDolibarrLogin"), $langs->trans("ConfirmCreateContact"), "confirm_create_user", $formquestion, 'no');
}
}
开发者ID:Samara94,项目名称:dolibarr,代码行数:101,代码来源:actions_contactcard_common.class.php
示例9: testGetRandomPassword
/**
* testGetRandomPassword
*
* @return number
*/
public function testGetRandomPassword()
{
global $conf;
$genpass1 = getRandomPassword(true);
// Should be a string return by dol_hash (if no option set, will be md5)
print __METHOD__ . " genpass1=" . $genpass1 . "\n";
$this->assertEquals(strlen($genpass1), 32);
$conf->global->USER_PASSWORD_GENERATED = 'None';
$genpass2 = getRandomPassword(false);
// Should be an empty string
print __METHOD__ . " genpass2=" . $genpass2 . "\n";
$this->assertEquals($genpass2, '');
$conf->global->USER_PASSWORD_GENERATED = 'Standard';
$genpass3 = getRandomPassword(false);
print __METHOD__ . " genpass3=" . $genpass3 . "\n";
$this->assertEquals(strlen($genpass3), 8);
return 0;
}
开发者ID:Samara94,项目名称:dolibarr,代码行数:23,代码来源:SecurityTest.php
示例10: switch
} else {
$mysql_error = 'mysql driver is not installed.';
$task = 'error';
}
$norender = false;
$break = false;
switch ($task) {
case 'add':
header('Cache-Control: private');
$token = token();
// Check db user settings
$sql = "SELECT COUNT(*) FROM mysql.user WHERE User LIKE '{$me}'";
$query = mysql_query($sql);
$result = mysql_fetch_row($query);
if (!$result[0]) {
$random_passwd = getRandomPassword();
// create user
if (ZDatabase::addmysqluser($me, $random_passwd)) {
setmsg(t("Added."), 'notice');
} else {
setmsg(t('Database Error. ') . mysql_error(), 'error');
}
}
if (!isadmin()) {
setmsg(t(''), 'warning');
}
if (checktoken()) {
$username = $_REQUEST['name'];
$password = $_REQUEST['password'];
$break = false;
if (in_array($username, ZDatabase::getDbUsers())) {
开发者ID:BGCX261,项目名称:zhpanel-svn-to-git,代码行数:31,代码来源:db.php
示例11: dolibarr_set_const
if ($checkread == 'on') {
$res = dolibarr_set_const($db, "MAILING_EMAIL_UNSUBSCRIBE", 1, 'chaine', 0, '', $conf->entity);
if (!$res > 0) {
$error++;
}
} else {
if ($checkread == 'off') {
$res = dolibarr_set_const($db, "MAILING_EMAIL_UNSUBSCRIBE", 0, 'chaine', 0, '', $conf->entity);
if (!$res > 0) {
$error++;
}
}
}
//Create temporary encryption key if nedded
if ($conf->global->MAILING_EMAIL_UNSUBSCRIBE == 1 && empty($checkread_key)) {
$checkread_key = getRandomPassword(true);
}
$res = dolibarr_set_const($db, "MAILING_EMAIL_UNSUBSCRIBE_KEY", $checkread_key, 'chaine', 0, '', $conf->entity);
if (!$res > 0) {
$error++;
}
if (!$error) {
$db->commit();
$mesg = "<font class=\"ok\">" . $langs->trans("SetupSaved") . "</font>";
} else {
$db->rollback();
$mesg = "<font class=\"error\">" . $langs->trans("Error") . "</font>";
}
}
/*
* View
开发者ID:nrjacker4,项目名称:crm-php,代码行数:31,代码来源:mailing.php
示例12: setPassword
/**
* Change password of a user
* @param user Object user of user making change
* @param password New password in clear text (to generate if not provided)
* @param changelater 1=Change password only after clicking on confirm email
* @param notrigger 1=Does not launch triggers
* @param nosyncmember Do not synchronize linked member
* @return string If OK return clear password, 0 if no change, < 0 if error
*/
function setPassword($user, $password='', $changelater=0, $notrigger=0, $nosyncmember=0)
{
global $conf, $langs;
$error=0;
dol_syslog("User::setPassword user=".$user->id." password=".preg_replace('/./i','*',$password)." changelater=".$changelater." notrigger=".$notrigger." nosyncmember=".$nosyncmember, LOG_DEBUG);
// If new password not provided, we generate one
if (! $password)
{
include_once(DOL_DOCUMENT_ROOT.'/lib/security.lib.php');
$password=getRandomPassword('');
}
// Crypte avec md5
$password_crypted = md5($password);
// Mise a jour
if (! $changelater)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."user";
$sql.= " SET pass_crypted = '".$this->db->escape($password_crypted)."',";
$sql.= " pass_temp = null";
if (! empty($conf->global->DATABASE_PWD_ENCRYPTED))
{
$sql.= ", pass = null";
}
else
{
$sql.= ", pass = '".$this->db->escape($password)."'";
}
$sql.= " WHERE rowid = ".$this->id;
dol_syslog("User::setPassword sql=hidden", LOG_DEBUG);
//dol_syslog("User::Password sql=".$sql);
$result = $this->db->query($sql);
if ($result)
{
if ($this->db->affected_rows($result))
{
$this->pass=$password;
$this->pass_indatabase=$password;
$this->pass_indatabase_crypted=$password_crypted;
if ($this->fk_member && ! $nosyncmember)
{
require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php");
// This user is linked with a member, so we also update members informations
// if this is an update.
$adh=new Adherent($this->db);
$result=$adh->fetch($this->fk_member);
if ($result >= 0)
{
$result=$adh->setPassword($user,$this->pass,0,1); // Cryptage non gere dans module adherent
if ($result < 0)
{
$this->error=$adh->error;
dol_syslog("User::setPassword ".$this->error,LOG_ERR);
$error++;
}
}
else
{
$this->error=$adh->error;
$error++;
}
}
dol_syslog("User::setPassword notrigger=".$notrigger." error=".$error,LOG_DEBUG);
if (! $error && ! $notrigger)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('USER_NEW_PASSWORD',$this,$user,$langs,$conf);
if ($result < 0) $this->errors=$interface->errors;
// Fin appel triggers
}
return $this->pass;
}
else
{
return 0;
}
}
else
//.........这里部分代码省略.........
开发者ID:remyyounes,项目名称:dolibarr,代码行数:101,代码来源:user.class.php
示例13: setPassword
/**
* Change password of a user
*
* @param User $user Object user de l'utilisateur qui fait la modification
* @param string $password New password (to generate if empty)
* @param int $isencrypted 0 ou 1 si il faut crypter le mot de passe en base (0 par defaut)
* @param int $notrigger 1=Ne declenche pas les triggers
* @param int $nosyncuser Do not synchronize linked user
* @return string If OK return clear password, 0 if no change, < 0 if error
*/
function setPassword($user, $password = '', $isencrypted = 0, $notrigger = 0, $nosyncuser = 0)
{
global $conf, $langs;
$error = 0;
dol_syslog(get_class($this) . "::setPassword user=" . $user->id . " password=" . preg_replace('/./i', '*', $password) . " isencrypted=" . $isencrypted);
// If new password not provided, we generate one
if (!$password) {
require_once DOL_DOCUMENT_ROOT . "/core/lib/security2.lib.php";
$password = getRandomPassword('');
}
// Cryptage mot de passe
if ($isencrypted) {
// Encryption
$password_indatabase = dol_hash($password);
} else {
$password_indatabase = $password;
}
$this->pass = $password;
$this->pass_indatabase = $password_indatabase;
if (!$error && !$notrigger) {
// Appel des triggers
include_once DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php";
$interface = new Interfaces($this->db);
$result = $interface->run_triggers('MEMBER_NEW_PASSWORD', $this, $user, $langs, $conf);
if ($result < 0) {
$error++;
$this->errors = $interface->errors;
}
// Fin appel triggers
}
return $this->pass;
}
开发者ID:nrjacker4,项目名称:crm-php,代码行数:42,代码来源:adherent.class.php
示例14: setmsg
$f = $files[0];
}
if (checkToken()) {
$new_content = $_REQUEST['content'];
if (file_put_contents('tpl/conf/' . $f, $new_content)) {
setmsg(t('Saved!'), 'notice', 'self');
}
}
$content = file_get_contents('tpl/conf/' . $f);
break;
case 'svn':
$users = array();
break;
case 'random':
// random password
$pass = getRandomPassword();
$id = $_REQUEST['id'];
break;
case 'tasks':
if (!isadmin()) {
break;
}
if (checktoken()) {
if ($pdo->insert('task', $_REQUEST)) {
setmsg(t('Saved!'), 'notice', 'self');
}
}
$sql = "SELECT * FROM task WHERE state=0";
$tasks = $pdo->fetchAll($sql);
break;
case 'login':
开发者ID:BGCX261,项目名称:zhpanel-svn-to-git,代码行数:31,代码来源:misc.php
注:本文中的getRandomPassword函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论