本文整理汇总了PHP中generate_password函数的典型用法代码示例。如果您正苦于以下问题:PHP generate_password函数的具体用法?PHP generate_password怎么用?PHP generate_password使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了generate_password函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: read
function read($fname)
{
$xls = PHPExcel_IOFactory::load($fname);
$xls->setActiveSheetIndex(0);
$sheet = $xls->getActiveSheet();
$nRow = $sheet->getHighestRow();
$nColumn = PHPExcel_Cell::columnIndexFromString($sheet->getHighestColumn());
$arr = [];
for ($i = 1; $i <= $nRow; $i++) {
for ($j = 0; $j <= $nColumn; $j++) {
$row[$j] = trim($sheet->getCellByColumnAndRow($j, $i)->getValue());
}
if ($row[0] != '') {
$pass = generate_password(6);
$var = explode(' ', trim($row[0]));
$fio = array();
foreach ($var as $word) {
if ($word != '') {
$fio[] = trim($word);
}
}
$fam = $fio[0];
$name = $fio[1];
$otch = $fio[2];
$email = trim($row[1]);
$ou = trim($row[2]);
$arr[] = ['fam' => $fam, 'name' => $name, 'otch' => $otch, 'email' => $email, 'phone' => '', 'login' => getLogin($fam, $name, $otch), 'password' => $pass, 'password_md5' => md5($pass), 'mr' => '', 'ou' => $ou];
} else {
}
}
return $arr;
}
开发者ID:razikov,项目名称:user_ilias,代码行数:32,代码来源:lib.php
示例2: perform
function perform($edit = array())
{
$fields = array();
if (validate_nonblank($edit['username'])) {
$fields['username'] = $edit['username'];
}
if (validate_nonblank($edit['email'])) {
$fields['email'] = $edit['email'];
}
if (count($fields) < 1) {
error_exit("You must supply at least one of username or email address");
}
/* Now, try and find the user */
$user = Person::load($fields);
/* Now, we either have one or zero users. Regardless, we'll present
* the user with the same output; that prevents them from using this
* to guess valid usernames.
*/
if ($user) {
/* Generate a password */
$pass = generate_password();
$user->set_password($pass);
if (!$user->save()) {
error_exit("Error setting password");
}
/* And fire off an email */
$rc = send_mail($user, false, false, _person_mail_text('password_reset_subject', array('%site' => variable_get('app_name', 'Leaguerunner'))), _person_mail_text('password_reset_body', array('%fullname' => "{$user->firstname} {$user->lastname}", '%username' => $user->username, '%password' => $pass, '%site' => variable_get('app_name', 'Leaguerunner'))));
if ($rc == false) {
error_exit("System was unable to send email to that user. Please contact system administrator.");
}
}
}
开发者ID:roboshed,项目名称:leaguerunner,代码行数:32,代码来源:forgotpassword.php
示例3: generate_password
function generate_password($min_length = 8, $initials_required = 1, $caps_required = 1, $nums_required = 1)
{
$length = $min_length;
$req_length = $initials_required + $caps_required + $nums_required;
if ($req_length > $length) {
//If the combined number of required chars exceed the length of the password, increase the password length.
$length = $req_length;
}
$passwd = '';
//Define the characters table
$chars[0] = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z');
$chars[1] = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
$chars[2] = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
$counter = array(0 => 0, 1 => 0, 2 => 0);
//Keeps track of how many times each class has been used
for ($i = 0; $i < $length; $i++) {
$r = rand(0, 2);
//Find a random chartype (initial,capital,numeric)
$counter[$r]++;
//Increase the given counter
$char = $chars[$r][rand(0, count($chars[$r]))];
//Find a char from the array
$passwd .= $char;
//assign the char to the password string
}
if ($counter[0] >= $initials_required && $counter[1] >= $caps_required && $counter[2] >= $nums_required) {
//Test if the password string contains the number of charactes defined.
return $passwd;
} else {
//Try again
return generate_password($length, $initials_required, $caps_required, $nums_required);
}
}
开发者ID:rlindsgaard,项目名称:libraries,代码行数:33,代码来源:function.generate_password.php
示例4: generate_password
protected function generate_password($length = 9, $strength = 4)
{
if (defined('STRICT_TYPES') && CAMEL_CASE == '1') {
return (string) self::parameters(['length' => DT::UINT8, 'strength' => DT::UINT8])->call(__FUNCTION__)->with($length, $strength)->returning(DT::STRING);
} else {
return (string) generate_password($length, $strength);
}
}
开发者ID:tfont,项目名称:skyfire,代码行数:8,代码来源:strings.class.php
示例5: create_member
/**
* *
* * @return mixed
* */
function create_member()
{
$this->form_validation->set_rules('username', 'User name', 'trim|required|min_length[4]|is_unique[user.username]');
$this->form_validation->set_rules('password', 'Password', 'required');
$this->form_validation->set_rules('email', 'Email Address', 'trim|required|valid_email|is_unique[user.primary_email]');
$this->form_validation->set_message('is_unique', 'The %s is already taken! Please choose another.');
$this->form_validation->set_error_delimiters('<div style="margin:1%" class="alert alert-error"><strong>', '</strong></div>');
$this->form_validation->set_rules('membership', 'Membership', 'required');
$this->form_validation->set_rules('term_condition', 'Terms & Condition', 'required');
if ($this->form_validation->run() == TRUE) {
$username = $this->input->post('username');
$pass = generate_password();
$email = $this->input->post('email');
$color2 = $this->input->post('color2');
$membership_amt = $this->input->post('membership');
$data_to_store = array('date_of_registration' => date("Y-m-d H:i:s"), 'username' => $username, 'password' => md5($pass), 'firstname' => $this->input->post('username'), 'primary_email' => $email, 'color' => $this->input->post('color'), 'color2' => isset($color2) ? $color2 : "", 'term_condition' => $this->input->post('term_condition'), 'membership' => $membership_amt, 'status' => 'Inactive');
$uid = $this->user_model->store_user($data_to_store);
$this->load->helper('email');
$this->load->library('email');
if (valid_email($email)) {
// compose email
$this->email->clear(TRUE);
$get_admin_detail = get_admin_detail();
//common helper function for admin detail
$this->email->from($get_admin_detail['email'], $get_admin_detail['name']);
$this->email->to($email);
$this->email->set_mailtype("html");
$this->email->subject('Register Confirmation for StacksGuide Account!');
$mail_data['url'] = site_url() . 'payment/payment_send/' . $uid . '/' . encrypt($membership_amt);
$message = $this->load->view('mail_templates/stacks_signup_mail', $mail_data, true);
$this->email->message($message);
// try send mail ant if not able print debug
if (!$this->email->send()) {
$msgadd = "<strong>E-mail not sent </strong>";
//.$this->email->print_debugger();
$data['flash_message'] = TRUE;
$this->session->set_flashdata('flash_class', 'alert-error');
$this->session->set_flashdata('flash_message', $msgadd);
redirect('home');
} else {
$msgadd = "<strong>Please check your Email</strong>";
//.$this->email->print_debugger();
$data['flash_message'] = TRUE;
$this->session->set_flashdata('flash_class', 'alert-error');
$this->session->set_flashdata('flash_message', $msgadd);
redirect('home');
}
}
//redirect("payment/payment_send/$uid/$membership_amt");
}
// else {
//
// $this->session->set_flashdata('validation_error_messages', validation_errors());
// redirect('signup');
// }
$data['main_content'] = 'signup_view';
$this->load->view('includes/template', $data);
}
开发者ID:hardikamutech,项目名称:stacksguide,代码行数:62,代码来源:signup.php
示例6: turn_on
public static function turn_on($message = null, $key = null)
{
if (!$key) {
$key = generate_password(16);
}
self::turn_off();
self::generate_file($key, $message);
return $key;
}
开发者ID:cretzu89,项目名称:EPESI,代码行数:9,代码来源:maintenance_mode.php
示例7: generate_update_login_id
public function generate_update_login_id($user_name, $length, $user_id)
{
$user_name_subStr = substr($user_name, 0, $length);
$randomNuber = rand(10, 5000);
$user_data['login_id'] = $user_login_type . $user_name_subStr . $user_id . $randomNuber;
$user_data['password'] = generate_password(8);
$condition['student_Id'] = $student_Id;
$condition['user_login_type'] = 'S';
$data['user'] = $user_data;
$data['condition'] = $condition;
$this->update_id_pass($data);
}
开发者ID:jiveshsoftsolution,项目名称:eschool,代码行数:12,代码来源:student_model.php
示例8: signup
public function signup()
{
// TODO validate
$password = generate_password();
$user = Sentry::register(array('email' => Input::get('email'), 'password' => $password, 'username' => Input::get('name') . '.' . Input::get('last_name') . '.' . Input::get('second_last_name') . '.' . rand(1, 10)));
$student_data = Input::all();
$student_data['user_id'] = $user->id;
$this->repository->store($student_data);
Mail::queue('emails.courses.verification', ['student' => Input::except('photo'), 'password' => $password, 'activation_code' => $user->getActivationCode()], function ($message) {
$message->to(Input::get('email'), Input::get('name'))->subject('Filmoteca UNAM: Verificación de email');
});
}
开发者ID:filmoteca,项目名称:filmoteca,代码行数:12,代码来源:StudentController.php
示例9: process_magento_request
/**
* Returns success or failure
*
* @return bool success or failure
*/
public static function process_magento_request($order_number, $customer, $moodle_courses)
{
global $USER, $DB;
if (get_config('magentoconnector', 'magentoconnectorenabled') == 0) {
return false;
}
$params = self::validate_parameters(self::process_magento_request_parameters(), array('order_number' => $order_number, 'customer' => $customer, 'moodle_courses' => $moodle_courses));
$context = context_user::instance($USER->id);
self::validate_context($context);
if (!($user = $DB->get_record('user', array('email' => $customer['email'])))) {
$user = new stdClass();
$user->firstname = $customer['firstname'];
$user->lastname = $customer['lastname'];
$user->email = $customer['email'];
$user->city = $customer['city'];
$user->country = $customer['country'];
$user->confirmed = 1;
$user->policyagreed = 1;
$user->mnethostid = 1;
$user->username = local_magentoconnector_generate_username($customer['firstname'], $customer['lastname']);
$user->timecreated = time();
$password = generate_password();
$user->password = hash_internal_user_password($password);
$userid = $DB->insert_record('user', $user);
} else {
$userid = $user->id;
}
$roleid = $DB->get_field('role', 'id', array('shortname' => LOCAL_MAGENTOCONNECTOR_STUDENT_SHORTNAME));
$enrol = enrol_get_plugin('magento');
foreach ($moodle_courses as $moodle_course) {
if ($course = $DB->get_record('course', array('idnumber' => $moodle_course['course_id']))) {
$enrolinstance = $DB->get_record('enrol', array('courseid' => $course->id, 'enrol' => 'magento'), '*', MUST_EXIST);
$enrol->enrol_user($enrolinstance, $userid, $roleid);
$record = new stdClass();
$record->userid = $userid;
$record->ordernum = $order_number;
$record->courseid = $course->id;
$record->timestamp = time();
$DB->insert_record('local_magentoconnector_trans', $record);
} else {
// no such course ... ?
}
}
if (isset($password)) {
$enrolinstance->newusername = $user->username;
$enrolinstance->newaccountpassword = $password;
}
$customer = $DB->get_record('user', array('id' => $userid));
$enrol->email_welcome_message($enrolinstance, $customer);
return true;
}
开发者ID:srinathweb,项目名称:moodle_magento_connector,代码行数:56,代码来源:externallib.php
示例10: author_save_new
function author_save_new()
{
extract(doSlash(psa(array('privs', 'name', 'email', 'RealName'))));
$pw = generate_password(6);
$nonce = md5(uniqid(rand(), true));
if ($name) {
$rs = safe_insert("txp_users", "privs = '{$privs}',\n\t\t\t\t name = '{$name}',\n\t\t\t\t email = '{$email}',\n\t\t\t\t RealName = '{$RealName}',\n\t\t\t\t pass = password(lower('{$pw}')),\n\t\t\t\t nonce = '{$nonce}'");
}
if ($rs) {
send_password($pw, $email);
admin(gTxt('password_sent_to') . sp . $email);
} else {
admin(gTxt('error_adding_new_author'));
}
}
开发者ID:bgarrels,项目名称:textpattern,代码行数:15,代码来源:txp_admin.php
示例11: reset_author_pass
function reset_author_pass($name)
{
$email = safe_field('email', 'txp_users', "name = '" . doSlash($name) . "'");
$new_pass = doSlash(generate_password(6));
$rs = safe_update('txp_users', "pass = password(lower('{$new_pass}'))", "name = '" . doSlash($name) . "'");
if ($rs) {
if (send_new_password($new_pass, $email, $name)) {
return gTxt('password_sent_to') . ' ' . $email;
} else {
return gTxt('could_not_mail') . ' ' . $email;
}
} else {
return gTxt('could_not_update_author') . ' ' . htmlspecialchars($name);
}
}
开发者ID:nope,项目名称:Tipattern,代码行数:15,代码来源:txplib_admin.php
示例12: reset_author_pass
function reset_author_pass($name)
{
$email = safe_field('email', 'txp_users', "name = '" . doSlash($name) . "'");
$new_pass = generate_password(PASSWORD_LENGTH);
$hash = doSlash(txp_hash_password($new_pass));
$rs = safe_update('txp_users', "pass = '{$hash}'", "name = '" . doSlash($name) . "'");
if ($rs) {
if (send_new_password($new_pass, $email, $name)) {
return gTxt('password_sent_to') . ' ' . $email;
} else {
return gTxt('could_not_mail') . ' ' . $email;
}
} else {
return gTxt('could_not_update_author') . ' ' . txpspecialchars($name);
}
}
开发者ID:balcides,项目名称:Cathartic_server,代码行数:16,代码来源:txplib_admin.php
示例13: reset_user_password
function reset_user_password($username)
{
/* resets the password for the user with the username $username, and sends it
* to him/her via email */
global $CFG;
/* load up the user record */
$user = sql_getUserdataFromUsername($username);
/* reset the password */
$newpassword = generate_password();
sql_setUserpasswd($username, $newpassword);
/* email the user with the new account information */
$var = new Object();
$var->username = $username;
$var->fullname = $user->Firstname . " " . $user->Lastname;
$var->newpassword = $newpassword;
$var->support = $CFG->support;
$emailbody = read_template("{$CFG->templatedir}/email/reset_password.php", $var);
mail("{$var->fullname} <{$user->Email}>", "OTMP Account Information", $emailbody, "From: {$var->support}");
}
开发者ID:BackupTheBerlios,项目名称:otmp,代码行数:19,代码来源:otmplib.php
示例14: get_meeting_pin
function get_meeting_pin($length, $meeting_uuid)
{
global $db;
$pin = generate_password($length, 1);
$sql = "select count(*) as num_rows from v_meetings ";
$sql .= "where domain_uuid = '" . $_SESSION['domain_uuid'] . "' ";
//$sql .= "and meeting_uuid <> '".$meeting_uuid."' ";
$sql .= "and (moderator_pin = '" . $pin . "' or participant_pin = '" . $pin . "') ";
$prep_statement = $db->prepare(check_sql($sql));
if ($prep_statement) {
$prep_statement->execute();
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
if ($row['num_rows'] == 0) {
return $pin;
} else {
get_meeting_pin($length, $uuid);
}
}
}
开发者ID:kpabijanskas,项目名称:fusionpbx,代码行数:19,代码来源:conference_room_edit.php
示例15: send_newpassword
function send_newpassword($email, $current_ip)
{
/* get the Client and set the new password */
$client = User::get_from_email($email);
if ($client && $client->email == $email) {
$newpassword = generate_password(6);
$client->update_password($newpassword);
$mailer = new Mailer();
$mailer->set_default_sender();
$mailer->subject = T_("Lost Password");
$mailer->recipient_name = $client->fullname;
$mailer->recipient = $client->email;
$message = sprintf(T_("A user from %s has requested a password reset for '%s'."), $current_ip, $client->username);
$message .= "\n";
$message .= sprintf(T_("The password has been set to: %s"), $newpassword);
$mailer->message = $message;
return $mailer->send();
}
return false;
}
开发者ID:cheese1,项目名称:ampache,代码行数:20,代码来源:lostpassword.php
示例16: __app_reset_password_and_mail
private function __app_reset_password_and_mail($user)
{
global $CFG;
$site = get_site();
$supportuser = generate_email_supportuser();
$userauth = get_auth_plugin($user->auth);
if (!$userauth->can_reset_password() or !is_enabled_auth($user->auth)) {
trigger_error("Attempt to reset user password for user {$user->username} with Auth {$user->auth}.");
return false;
}
$newpassword = generate_password();
if (!$userauth->user_update_password($user, $newpassword)) {
$error->error = true;
$error->msg = 'fp_passwordgen_failure';
echo json_encode($error);
die;
}
$a = new stdClass();
$a->firstname = $user->firstname;
$a->lastname = $user->lastname;
$a->sitename = format_string($site->fullname);
$a->username = $user->username;
$a->newpassword = $newpassword;
//$a->signoff = generate_email_signoff();
$message = 'Hi ' . $a->firstname . ',
Your account password at \'' . $a->sitename . '\' has been reset
and you have been issued with a new temporary password.
Your current login information is now:
username: ' . $a->username . '
password: ' . $a->newpassword . '
Cheers from the \'' . $a->sitename . '\' administrator.';
//$message = get_string('newpasswordtext', '', $a);
$subject = format_string($site->fullname) . ': ' . get_string('changedpassword');
unset_user_preference('create_password', $user);
// prevent cron from generating the password
//directly email rather than using the messaging system to ensure its not routed to a popup or jabber
return email_to_user($user, $supportuser, $subject, $message);
}
开发者ID:vinoth4891,项目名称:clinique,代码行数:41,代码来源:clinique_forgot_password.php
示例17: _EM_change_password
public function _EM_change_password()
{
$old_password = I('post.old_password');
$new_password = I('post.new_password');
$user_id = I('get.id');
if (!$user_id || $user_id != get_current_user_id()) {
return $this->error(__('account.Params Error'));
}
if (!$old_password || !$new_password) {
return $this->error(__('account.Every item is required'));
}
$user_service = D('Account/User');
$user = $user_service->where(['id' => $user_id])->find();
list($old_hashed_password) = generate_password($old_password, $user['rand_hash']);
if ($old_hashed_password !== $user['password']) {
return $this->error(__('account.Old password not equal to saved'));
}
list($new_password_hashed, $new_hash) = generate_password($new_password);
$user_service->where(['id' => $user_id])->save(['password' => $new_password_hashed, 'rand_hash' => $new_hash]);
$this->logout();
}
开发者ID:chinapaul,项目名称:ones,代码行数:21,代码来源:UserController.class.php
示例18: update_profile
function update_profile($email, $password = NULL, $home = NULL)
{
$query_profile = "SELECT * FROM users";
$profile = mysql_query($query_profile) or die(mysql_error());
$row_profile = mysql_fetch_assoc($profile);
if ($home == NULL) {
$home = $row_profile['user_home'];
}
if ($password) {
$password_salt = time();
$password = generate_password($password, $password_salt);
} else {
$password = $row_profile['user_password'];
$password_salt = $row_profile['user_salt'];
}
mysql_query("UPDATE users SET \n user_email = '" . mysql_real_escape_string(trim($email)) . "', \n user_password = '" . mysql_real_escape_string(trim($password)) . "', \n user_salt = '" . mysql_real_escape_string(trim($password_salt)) . "', \n user_home = '" . mysql_real_escape_string(trim($home)) . "' \n WHERE user_email = '" . mysql_real_escape_string(trim($email)) . "'");
if (mysql_error()) {
die(mysql_error());
}
return mysql_affected_rows();
}
开发者ID:jmreardon,项目名称:donor-track,代码行数:21,代码来源:user.inc.php
示例19: __handle
/**
* Interactive
*
* @access private
*/
function __handle($address, $password = NULL, $random = false)
{
if ($random == true) {
$password = generate_password();
}
if ($password != NULL) {
$handler = new MailboxHandler();
if (!$handler->init($address)) {
$this->error("Change Password", join("\n", $handler->errormsg));
}
if (!$handler->change_pw($password, NULL, false)) {
$this->error("Change Password", join("\n", $handler->errormsg));
}
}
$this->out("");
$this->out("Password updated.");
$this->hr();
$this->out(sprintf('The Mail address is %20s', $address));
$this->out(sprintf('The new password is %20s', $password));
$this->hr();
return;
}
开发者ID:mpietruschka,项目名称:postfixadmin,代码行数:27,代码来源:mailbox.php
示例20: _validate_password
/**
* - compare password / password2 field (error message will be displayed at password2 field)
* - autogenerate password if enabled in config and $new
* - display password on $new if enabled in config or autogenerated
*/
protected function _validate_password($field, $val)
{
if (!$this->_validate_password2($field, $val)) {
return false;
}
if ($this->new && Config::read('generate_password') == 'YES' && $val == '') {
# auto-generate new password
unset($this->errormsg[$field]);
# remove "password too short" error message
$val = generate_password();
$this->values[$field] = $val;
# we are doing this "behind the back" of set()
$this->infomsg[] = Config::Lang('password') . ": {$val}";
return false;
# to avoid that set() overwrites $this->values[$field]
} elseif ($this->new && Config::read('show_password') == 'YES') {
$this->infomsg[] = Config::Lang('password') . ": {$val}";
}
return true;
# still here? good.
}
开发者ID:mpietruschka,项目名称:postfixadmin,代码行数:26,代码来源:MailboxHandler.php
注:本文中的generate_password函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论