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


PHP hash_internal_user_password函数代码示例

本文整理汇总了PHP中hash_internal_user_password函数的典型用法代码示例。如果您正苦于以下问题:PHP hash_internal_user_password函数的具体用法?PHP hash_internal_user_password怎么用?PHP hash_internal_user_password使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: user_signup

 /**
  * Sign up a new user ready for confirmation.
  * Password is passed in plaintext.
  *
  * @param object $user new user object (with system magic quotes)
  * @param boolean $notify print notice with link and terminate
  */
 function user_signup($user, $notify = true)
 {
     global $CFG;
     require_once $CFG->dirroot . '/user/profile/lib.php';
     $user->password = hash_internal_user_password($user->password);
     if (!($user->id = insert_record('user', $user))) {
         print_error('auth_emailnoinsert', 'auth');
     }
     /// Save any custom profile field information
     profile_save_data($user);
     $user = get_record('user', 'id', $user->id);
     events_trigger('user_created', $user);
     if (!send_confirmation_email($user)) {
         print_error('auth_emailnoemail', 'auth');
     }
     if ($notify) {
         global $CFG;
         $emailconfirm = get_string('emailconfirm');
         $navlinks = array();
         $navlinks[] = array('name' => $emailconfirm, 'link' => null, 'type' => 'misc');
         $navigation = build_navigation($navlinks);
         print_header($emailconfirm, $emailconfirm, $navigation);
         notice(get_string('emailconfirmsent', '', $user->email), "{$CFG->wwwroot}/index.php");
     } else {
         return true;
     }
 }
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:34,代码来源:auth.php

示例2: user_signup

 /**
  * Sign up a new user ready for confirmation.
  * Password is passed in plaintext.
  *
  * @param object $user new user object
  * @param boolean $notify print notice with link and terminate
  */
 function user_signup($user, $notify = true)
 {
     global $CFG, $DB;
     require_once $CFG->dirroot . '/user/profile/lib.php';
     $user->password = hash_internal_user_password($user->password);
     $user->id = $DB->insert_record('user', $user);
     /// Save any custom profile field information
     profile_save_data($user);
     $user = $DB->get_record('user', array('id' => $user->id));
     events_trigger('user_created', $user);
     if (!send_confirmation_email($user)) {
         print_error('auth_emailnoemail', 'auth_email');
     }
     if ($notify) {
         global $CFG, $PAGE, $OUTPUT;
         $emailconfirm = get_string('emailconfirm');
         $PAGE->navbar->add($emailconfirm);
         $PAGE->set_title($emailconfirm);
         $PAGE->set_heading($PAGE->course->fullname);
         echo $OUTPUT->header();
         notice(get_string('emailconfirmsent', '', $user->email), "{$CFG->wwwroot}/index.php");
     } else {
         return true;
     }
 }
开发者ID:JP-Git,项目名称:moodle,代码行数:32,代码来源:auth.php

示例3: test_user_update_user

 /**
  * Test user_update_user.
  */
 public function test_user_update_user()
 {
     global $DB;
     $this->resetAfterTest();
     // Create user and modify user profile.
     $user = $this->getDataGenerator()->create_user();
     $user->firstname = 'Test';
     $user->password = 'M00dLe@T';
     // Update user and capture event.
     $sink = $this->redirectEvents();
     user_update_user($user);
     $events = $sink->get_events();
     $sink->close();
     $event = array_pop($events);
     // Test updated value.
     $dbuser = $DB->get_record('user', array('id' => $user->id));
     $this->assertSame($user->firstname, $dbuser->firstname);
     $this->assertNotSame('M00dLe@T', $dbuser->password);
     // Test event.
     $this->assertInstanceOf('\\core\\event\\user_updated', $event);
     $this->assertSame($user->id, $event->objectid);
     $this->assertSame('user_updated', $event->get_legacy_eventname());
     $this->assertEventLegacyData($dbuser, $event);
     $this->assertEquals(context_user::instance($user->id), $event->get_context());
     $expectedlogdata = array(SITEID, 'user', 'update', 'view.php?id=' . $user->id, '');
     $this->assertEventLegacyLogData($expectedlogdata, $event);
     // Update user with no password update.
     $password = $user->password = hash_internal_user_password('M00dLe@T');
     user_update_user($user, false);
     $dbuser = $DB->get_record('user', array('id' => $user->id));
     $this->assertSame($password, $dbuser->password);
 }
开发者ID:tyleung,项目名称:CMPUT401MoodleExams,代码行数:35,代码来源:userlib_test.php

示例4: user_signup

 /**
  * Sign up a new user ready for confirmation.
  * Password is passed in plaintext.
  *
  * @param object $user new user object
  * @param boolean $notify print notice with link and terminate
  */
 public function user_signup($user, $notify = true)
 {
     global $CFG, $DB;
     require_once $CFG->dirroot . '/user/profile/lib.php';
     require_once $CFG->dirroot . '/user/lib.php';
     $plainpassword = $user->password;
     $user->password = hash_internal_user_password($user->password);
     if (empty($user->calendartype)) {
         $user->calendartype = $CFG->calendartype;
     }
     $user->id = user_create_user($user, false, false);
     user_add_password_history($user->id, $plainpassword);
     // Save any custom profile field information.
     profile_save_data($user);
     // Trigger event.
     \core\event\user_created::create_from_userid($user->id)->trigger();
     if (!send_confirmation_email($user)) {
         print_error('auth_emailnoemail, auth_email');
     }
     if ($notify) {
         global $CFG, $PAGE, $OUTPUT;
         $emailconfirm = get_string('emailconfirm');
         $PAGE->navbar->add($emailconfirm);
         $PAGE->set_title($emailconfirm);
         $PAGE->set_heading($PAGE->course->fullname);
         echo $OUTPUT->header();
         notice(get_string('emailconfirmsent', '', $user->email), "{$CFG->wwwroot}/index.php");
     } else {
         return true;
     }
 }
开发者ID:posttechguy,项目名称:moodle-whia-auth_whia,代码行数:38,代码来源:auth.php

示例5: user_update_user

/**
 * Update a user with a user object (will compare against the ID)
 * @param object $user - the user to update
 */
function user_update_user($user)
{
    global $DB;
    /// set the timecreate field to the current time
    if (!is_object($user)) {
        $user = (object) $user;
    }
    /// hash the password
    $user->password = hash_internal_user_password($user->password);
    $user->timemodified = time();
    $DB->update_record('user', $user);
}
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:16,代码来源:lib.php

示例6: 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

示例7: xmldb_local_lae_install

function xmldb_local_lae_install()
{
    global $CFG, $DB;
    $dbman = $DB->get_manager();
    // Migrate the old config setting, if present.
    if (!empty($CFG->forum_anonymous)) {
        set_config('forum_enableanonymousposts', $CFG->forum_anonymous);
        set_config('forum_anonymous', null);
    }
    // Extend forum tables.
    $table = new xmldb_table('forum');
    $field = new xmldb_field('anonymous');
    $field->set_attributes(XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'completionposts');
    if (!$dbman->field_exists($table, $field)) {
        $dbman->add_field($table, $field);
    }
    $table = new xmldb_table('forum_posts');
    $field = new xmldb_field('hiddenuserid');
    $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, 'mailnow');
    if (!$dbman->field_exists($table, $field)) {
        $dbman->add_field($table, $field);
    }
    // Add anonymous user.
    if (empty($CFG->anonymous_userid)) {
        $anon_user = new stdClass();
        $anon_user->username = 'anonymous_user';
        // The password needs strings.
        $anon_user->password = hash_internal_user_password(str_shuffle($anon_user->username) . (string) mt_rand());
        $anon_user->auth = 'nologin';
        $anon_user->firstname = get_string('auser_firstname', 'local_lae');
        $anon_user->lastname = get_string('auser_lastname', 'local_lae');
        $anon_user->mnethostid = $CFG->mnet_localhost_id;
        $anon_user->email = get_string('auser_email', 'local_lae');
        if ($result = $DB->insert_record('user', $anon_user)) {
            set_config('anonymous_userid', $result);
            context_user::instance($result);
        } else {
            print_error("Failed to create anonymous user");
            return false;
        }
    }
    // Update course table to support display defaults
    $table = new xmldb_table('course');
    $field = new xmldb_field('filedisplaydefault', XMLDB_TYPE_INTEGER, '2', null, null, null, null, null);
    if (!$dbman->field_exists($table, $field)) {
        $dbman->add_field($table, $field);
    }
    return true;
}
开发者ID:mackensen,项目名称:moodle-local_lae,代码行数:49,代码来源:install.php

示例8: user_signup

 /**
  * Sign up a new user ready for confirmation.
  * Password is passed in plaintext.
  *
  * @param object $user new user object (with system magic quotes)
  * @param boolean $notify print notice with link and terminate
  */
 function user_signup($user, $notify = true)
 {
     $user->password = hash_internal_user_password($user->password);
     if (!($user->id = insert_record('user', $user))) {
         print_error('auth_emailnoinsert', 'auth');
     }
     if (!send_confirmation_email($user)) {
         print_error('auth_emailnoemail', 'auth');
     }
     if ($notify) {
         global $CFG;
         $emailconfirm = get_string('emailconfirm');
         print_header($emailconfirm, $emailconfirm, $emailconfirm);
         notice(get_string('emailconfirmsent', '', $user->email), "{$CFG->wwwroot}/index.php");
     } else {
         return true;
     }
 }
开发者ID:veritech,项目名称:pare-project,代码行数:25,代码来源:auth.php

示例9: xmldb_auth_manual_upgrade

/**
 * @param int $oldversion the version we are upgrading from
 * @return bool result
 */
function xmldb_auth_manual_upgrade($oldversion)
{
    global $CFG, $DB, $OUTPUT;
    if ($oldversion < 2011022700) {
        // force creation of missing passwords
        $createpassword = hash_internal_user_password('');
        $rs = $DB->get_recordset('user', array('password' => $createpassword, 'auth' => 'manual'));
        foreach ($rs as $user) {
            if (validate_email($user->email)) {
                $DB->set_field('user', 'password', 'to be created', array('id' => $user->id));
                unset_user_preference('auth_forcepasswordchange', $user);
                set_user_preference('create_password', 1, $user);
            }
        }
        $rs->close();
        upgrade_plugin_savepoint(true, 2011022700, 'auth', 'manual');
    }
    return true;
}
开发者ID:esyacelga,项目名称:sisadmaca,代码行数:23,代码来源:upgrade.php

示例10: user_signup

 /**
  * Sign up a new user ready for confirmation.
  * Password is passed in plaintext.
  *
  * @param object $user new user object (with system magic quotes)
  * @param boolean $notify print notice with link and terminate
  */
 function user_signup($user, $notify = true)
 {
     global $CFG;
     require_once $CFG->dirroot . '/user/profile/lib.php';
     $user->password = hash_internal_user_password($user->password);
     if (!($user->id = insert_record('user', $user))) {
         print_error('auth_emailnoinsert', 'auth');
     }
     /// Save any custom profile field information
     profile_save_data($user);
     //Added by JAM: 12.02.2010 - Call the set user time-zone for WS, cannot set time-zone until, user is created
     setWSUserDefaultTimeZone($user->username, $user);
     $user = get_record('user', 'id', $user->id);
     events_trigger('user_created', $user);
     //Added by JAM: 01.06.2011 - this is where the user id exists
     if (!addQSUser($user)) {
         admin_signuperror_email($user);
         // Added: JAM - 01.06.2011
         //error('An error has occured, please try again shortly.');
     }
     if (!send_confirmation_email($user)) {
         print_error('auth_emailnoemail', 'auth');
     }
     if ($notify) {
         global $CFG;
         $emailconfirm = get_string('emailconfirm');
         $navlinks = array();
         $navlinks[] = array('name' => $emailconfirm, 'link' => null, 'type' => 'misc');
         $navigation = build_navigation($navlinks);
         print_header($emailconfirm, $emailconfirm, $navigation);
         // Added by SMS: 7/28/2011
         $data = new object();
         $data->useremail = $user->email;
         $supportuser = generate_email_supportuser();
         $data->adminemail = $supportuser->email;
         // Edited by SMS: 7/28/2011
         // notice(get_string('emailconfirmsent', '', $user->email), "$CFG->wwwroot/index.php");
         notice(get_string('emailconfirmsent', '', $data), "{$CFG->wwwroot}/index.php");
     } else {
         return true;
     }
 }
开发者ID:arshanam,项目名称:Moodle-ITScholars-LMS,代码行数:49,代码来源:auth.php

示例11: application_user_signup

function application_user_signup($user)
{
    // Derived from email->user_signup
    global $CFG, $PAGE, $OUTPUT;
    $user->password = hash_internal_user_password($user->password);
    if (empty($user->calendartype)) {
        $user->calendartype = $CFG->calendartype;
    }
    $user->id = user_create_user($user, false, false);
    // Save any custom profile field information
    profile_save_data($user);
    // Save contact information
    write_contact_details($user->id, $user);
    // Trigger event
    \core\event\user_created::create_from_userid($user->id)->trigger();
    if (!send_application_confirmation_email($user)) {
        print_error('auth_emailnoemail', 'auth_email');
    }
    $PAGE->set_title($CFG->pageheading . ': ' . get_string('emailconfirm'));
    echo $OUTPUT->header();
    notice(get_string('emailconfirmsent', '', $user->email), $CFG->wwwroot . '/local/obu_application/login.php');
}
开发者ID:OBU-OBIS,项目名称:moodle-local_obu_application,代码行数:22,代码来源:locallib.php

示例12: user_signup

 function user_signup($user, $notify = true)
 {
     global $CFG, $DB;
     require_once $CFG->dirroot . '/user/profile/lib.php';
     $password_clear = $user->password;
     $user->password = hash_internal_user_password($user->password);
     if (!($user->id = $DB->insert_record('user', $user))) {
         print_error('auth_emailnoinsert', 'auth');
     }
     /// Save any custom profile field information
     profile_save_data($user);
     $conditions = array('id' => $user->id);
     $user = $DB->get_record('user', $conditions);
     /* Create user in Joomla */
     $userinfo['username'] = $user->username;
     $userinfo['password'] = $password_clear;
     $userinfo['password2'] = $password_clear;
     $userinfo['name'] = $user->firstname . " " . $user->lastname;
     $userinfo['firstname'] = $user->firstname;
     $userinfo['lastname'] = $user->lastname;
     $userinfo['email'] = $user->email;
     $userinfo['block'] = 1;
     \core\event\user_created::create_from_userid($user->id)->trigger();
     if (!send_confirmation_email($user)) {
         print_error('auth_emailnoemail', 'auth');
     }
     if ($notify) {
         $emailconfirm = get_string('emailconfirm');
         $PAGE->set_url('/auth/joomdle/auth.php');
         $PAGE->navbar->add($emailconfirm);
         $PAGE->set_title($emailconfirm);
         $PAGE->set_heading($emailconfirm);
         echo $OUTPUT->header();
         notice(get_string('emailconfirmsent', '', $user->email), "{$CFG->wwwroot}/index.php");
     } else {
         return true;
     }
 }
开发者ID:anawu2006,项目名称:PeerLearning,代码行数:38,代码来源:auth.php

示例13: user_signup

 function user_signup($user, $notify = true)
 {
     global $CFG, $DB;
     require_once $CFG->dirroot . '/user/profile/lib.php';
     $password_clear = $user->password;
     $user->password = hash_internal_user_password($user->password);
     if (!($user->id = $DB->insert_record('user', $user))) {
         print_error('auth_emailnoinsert', 'auth');
     }
     /// Save any custom profile field information
     profile_save_data($user);
     $conditions = array('id' => $user->id);
     $user = $DB->get_record('user', $conditions);
     /* Create user in Joomla */
     $userinfo['username'] = $user->username;
     $userinfo['password'] = $password_clear;
     $userinfo['password2'] = $password_clear;
     $userinfo['name'] = $user->firstname . " " . $user->lastname;
     $userinfo['email'] = $user->email;
     $userinfo['block'] = 1;
     $this->call_method("createUser", $userinfo);
     events_trigger('user_created', $user);
     if (!send_confirmation_email($user)) {
         print_error('auth_emailnoemail', 'auth');
     }
     if ($notify) {
         global $CFG;
         $emailconfirm = get_string('emailconfirm');
         $navlinks = array();
         $navlinks[] = array('name' => $emailconfirm, 'link' => null, 'type' => 'misc');
         $navigation = build_navigation($navlinks);
         print_header($emailconfirm, $emailconfirm, $navigation);
         notice(get_string('emailconfirmsent', '', $user->email), "{$CFG->wwwroot}/index.php");
     } else {
         return true;
     }
 }
开发者ID:esyacelga,项目名称:sisadmaca,代码行数:37,代码来源:auth.php

示例14: test_hash_internal_user_password

 /**
  * Test function hash_internal_user_password().
  */
 public function test_hash_internal_user_password()
 {
     $passwords = array('pw', 'abc123', 'C0mP1eX_&}<?@*&%` |\\"', 'ĩńťėŕňăţĩōŋāĹ');
     // Check that some passwords that we convert to hashes can
     // be validated.
     foreach ($passwords as $password) {
         $hash = hash_internal_user_password($password);
         $fasthash = hash_internal_user_password($password, true);
         $user = new stdClass();
         $user->auth = 'manual';
         $user->password = $hash;
         $this->assertTrue(validate_internal_user_password($user, $password));
         // They should not be in md5 format.
         $this->assertFalse(password_is_legacy_hash($hash));
         // Check that cost factor in hash is correctly set.
         $this->assertRegExp('/\\$10\\$/', $hash);
         $this->assertRegExp('/\\$04\\$/', $fasthash);
     }
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:22,代码来源:moodlelib_test.php

示例15: create_user

 /**
  * Create a test user
  * @param array|stdClass $record
  * @param array $options
  * @return stdClass user record
  */
 public function create_user($record = null, array $options = null)
 {
     global $DB, $CFG;
     $this->usercounter++;
     $i = $this->usercounter;
     $record = (array) $record;
     if (!isset($record['auth'])) {
         $record['auth'] = 'manual';
     }
     if (!isset($record['firstname']) and !isset($record['lastname'])) {
         $country = rand(0, 5);
         $firstname = rand(0, 4);
         $lastname = rand(0, 4);
         $female = rand(0, 1);
         $record['firstname'] = $this->firstnames[$country * 10 + $firstname + $female * 5];
         $record['lastname'] = $this->lastnames[$country * 10 + $lastname + $female * 5];
     } else {
         if (!isset($record['firstname'])) {
             $record['firstname'] = 'Firstname' . $i;
         } else {
             if (!isset($record['lastname'])) {
                 $record['lastname'] = 'Lastname' . $i;
             }
         }
     }
     if (!isset($record['idnumber'])) {
         $record['idnumber'] = '';
     }
     if (!isset($record['mnethostid'])) {
         $record['mnethostid'] = $CFG->mnet_localhost_id;
     }
     if (!isset($record['username'])) {
         $record['username'] = 'username' . $i;
         $j = 2;
         while ($DB->record_exists('user', array('username' => $record['username'], 'mnethostid' => $record['mnethostid']))) {
             $record['username'] = 'username' . $i . '_' . $j;
             $j++;
         }
     }
     if (!isset($record['password'])) {
         $record['password'] = 'lala';
     }
     if (!isset($record['email'])) {
         $record['email'] = $record['username'] . '@example.com';
     }
     if (!isset($record['confirmed'])) {
         $record['confirmed'] = 1;
     }
     if (!isset($record['lang'])) {
         $record['lang'] = 'en';
     }
     if (!isset($record['maildisplay'])) {
         $record['maildisplay'] = 1;
     }
     if (!isset($record['deleted'])) {
         $record['deleted'] = 0;
     }
     $record['timecreated'] = time();
     $record['timemodified'] = $record['timecreated'];
     $record['lastip'] = '0.0.0.0';
     $record['password'] = hash_internal_user_password($record['password']);
     if ($record['deleted']) {
         $delname = $record['email'] . '.' . time();
         while ($DB->record_exists('user', array('username' => $delname))) {
             $delname++;
         }
         $record['idnumber'] = '';
         $record['email'] = md5($record['username']);
         $record['username'] = $delname;
         $record['picture'] = 0;
     }
     $userid = $DB->insert_record('user', $record);
     if (!$record['deleted']) {
         context_user::instance($userid);
     }
     return $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
 }
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:83,代码来源:data_generator.php


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