本文整理汇总了PHP中create_user函数的典型用法代码示例。如果您正苦于以下问题:PHP create_user函数的具体用法?PHP create_user怎么用?PHP create_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_user函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setup_user
function setup_user()
{
global $grid;
if (!empty($grid->user)) {
return;
}
if (!empty($grid->request)) {
$view = $grid->request->params['view'];
if (strpos($view, 'wispr') !== false || strpos($view, '404') !== false) {
return;
}
}
ini_set('session.name', 'SESSION');
ini_set('session.use_cookies', true);
ini_set('session.cookie_lifetime', time() + 60 * 60 * 24 * 365);
ini_set('session.gc_maxlifetime', time() + 60 * 60 * 24 * 365);
session_set_save_handler('session_open', 'session_close', 'session_read', 'session_write', 'session_delete', 'session_gc');
register_shutdown_function('session_write_close');
session_start();
if (!empty($_SESSION['user_id'])) {
$user = $grid->db->record('user', $_SESSION['user_id']);
}
if (empty($user)) {
$user = create_user();
}
$grid->user = $user;
$grid->users = array($user->id => $user);
}
示例2: create_user_from_mysql
function create_user_from_mysql()
{
$q = new mysql();
ini_set('display_errors', 1);
ini_set('error_reporting', E_ALL);
ini_set('error_prepend_string', null);
ini_set('error_append_string', null);
$GLOBALS["WAIT"] = true;
build_progress("{start}", 10);
$results = $q->QUERY_SQL("SELECT * FROM CreateUserQueue", "artica_backup");
if (!$q->ok) {
echo $q->mysql_error;
build_progress("MySQL error", 110);
return;
}
@mkdir("/usr/share/artica-postfix/ressources/logs/web/create-users", 0755, true);
echo mysql_num_rows($results) . " member(s) to create...\n";
while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
$zMD5 = $ligne["zMD5"];
$content = $ligne["content"];
@file_put_contents("/usr/share/artica-postfix/ressources/logs/web/create-users/{$zMD5}", $content);
if (create_user($zMD5)) {
build_progress("{removing_order}", 95);
$q->QUERY_SQL("DELETE FROM `CreateUserQueue` WHERE `zMD5`='{$zMD5}'", "artica_backup");
} else {
$q->QUERY_SQL("DELETE FROM `CreateUserQueue` WHERE `zMD5`='{$zMD5}'", "artica_backup");
build_progress("{failed}", 110);
return;
}
}
build_progress("{done}", 100);
}
示例3: console_create_user
function console_create_user($args)
{
$fname = array_shift($args);
$lname = array_shift($args);
$email = array_shift($args);
$admin = array_shift($args) == 'true';
if (is_null($fname) || is_null($lname) || is_null($email)) {
throw new Exception('create_user: Missing arguments. Expected: (fname, lname, email, admin)');
}
$display_name = $fname . " " . $lname;
$username = str_replace(" ", "_", strtolower($display_name));
$user_data = array('username' => $username, 'display_name' => $display_name, 'email' => $email, 'password_generator' => 'random', 'timezone' => 0, 'autodetect_time_zone' => 1, 'create_contact' => false, 'company_id' => owner_company()->getId(), 'send_email_notification' => true, 'personal_project' => 0);
// array
try {
DB::beginWork();
$user = create_user($user_data, $admin, '');
if (!$user->getContact() instanceof Contact) {
$contact = new Contact();
$contact->setFirstName($fname);
$contact->setLastName($lname);
$contact->setEmail($email);
$contact->setUserId($user->getId());
$contact->save();
}
DB::commit();
} catch (Exception $e) {
DB::rollback();
throw $e;
}
}
示例4: authenticate
function authenticate(&$sid)
{
global $user, $TABLE_USERS, $rpgDB;
if (!$user->data['is_registered']) {
return false;
}
$sid->_sid = $user->session_id;
$sid->_username = $user->data['username'];
$sid->_email = $user->data['user_email'];
$sid->_ip = $user->ip;
// Attempt to retrieve the user session details from the db.
$sql = sprintf("SELECT iplog, slength, dm FROM %s WHERE pname = '%s'", $TABLE_USERS, $sid->_username);
$res = $rpgDB->query($sql);
if (!$res) {
$err = $rpgDB->error();
__printFatalErr("Failed to query database: " . $err['message'] . "\n" . $sql, __LINE__, __FILE__);
}
if ($rpgDB->num_rows() == 1) {
// Record the user data.
$row = $rpgDB->fetch_row($res);
$sid->_iplog = unserialize(stripslashes($row['iplog']));
$sid->_slength = $row['slength'];
$sid->_dm = $row['dm'] == 'Y';
} else {
create_user($user->data['username']);
$sid->_iplog = "";
$sid->_slength = 180;
$sid->_dm = false;
}
return true;
}
示例5: create_new_user
public function create_new_user($email)
{
if (!$this->config['weautocreateusers']) {
return null;
}
if (record_exists('artefact_internal_profile_email', 'email', $email)) {
throw new AccountAutoCreationException(get_string('emailalreadyclaimed', 'auth.browserid', $email));
}
if (record_exists('usr', 'username', $email)) {
throw new AccountAutoCreationException(get_string('emailclaimedasusername', 'auth.browserid', $email));
}
// Personal details are currently not provided by the Persona API.
$user = new stdClass();
$user->username = $email;
$user->firstname = '';
$user->lastname = '';
$user->email = $email;
// no need for a password on Persona accounts
$user->password = '';
$user->passwordchange = 0;
$user->authinstance = $this->instanceid;
// Set default values to activate this user
$user->deleted = 0;
$user->expiry = null;
$user->suspendedcusr = null;
$user->id = create_user($user, array(), $this->institution);
return $user;
}
示例6: prep_DB_content
function prep_DB_content()
{
global $conn;
create_tables($conn);
create_user($conn);
create_user_devices($conn);
create_env($conn);
create_env_devices($conn);
}
示例7: update_user
private function update_user()
{
$fb_response = $this->facebook->api('/me');
$this->display_name = $fb_response['name'];
global $db;
if (user_exists($this)) {
$this->updated = time();
$db->query('UPDATE users SET display_name = "' . $this->display_name . '", updated = ' . $this->updated . ' WHERE uid = ' . $this->uid);
} else {
create_user($this);
}
}
示例8: create_linked_user
function create_linked_user($username, $email, $password, $panelType)
{
// Global variables
global $redis_enabled, $redis_server;
// Connect to the DB
$ret = create_connection($connection);
if ($ret !== true) {
return $ret;
}
// Connect to Redis
if ($redis_enabled === true) {
$redis = new Redis();
if (!$redis->connect($redis_server)) {
$redis = false;
}
} else {
$redis = false;
}
// Validate input
$ret = validate_input($username, $email, $password, $panelType);
if ($ret !== true) {
end_connection(true, $connection);
return $ret;
}
// Create user
if (create_user($username, $email, $password, $userid, $apikey, $connection) !== true) {
end_connection(true, $connection);
return 'Username already exists';
}
// Set the type of user profile
$prefix = 'data/' . $panelType;
// Create feeds
if (create_feeds($prefix . '_feeds.json', $feeds, $apikey) !== true) {
end_connection(true, $connection);
return 'Error while creating the feeds';
}
// Create inputs
if (create_inputs($prefix . '_inputs.json', $userid, $inputs, $connection, $redis) !== true) {
end_connection(true, $connection);
return 'Error while creating the inputs';
}
// Create processes
if (create_processes($prefix . '_processes.json', $feeds, $inputs, $apikey) !== true) {
end_connection(true, $connection);
return 'Error while creating the processes';
}
end_connection(false, $connection);
return true;
}
示例9: create_and_enrol_user
function create_and_enrol_user($student_name, $ruserid, $courseid)
{
if (preg_match('/^\\s*(.+?)\\s*(\\S+)\\s*$/', $student_name, $names)) {
$fname = $names[1];
$sname = $names[2];
} else {
$fname = '';
$sname = $student_name;
}
$userid = get_existing_user($ruserid, $fname, $sname);
if (!$userid) {
$userid = create_user($ruserid, $fname, $sname);
}
enrol_user($userid, $courseid);
}
示例10: import_submit
function import_submit(Pieform $form, $values)
{
global $SESSION;
$date = time();
$nicedate = date('Y/m/d h:i:s', $date);
$uploaddir = get_config('dataroot') . 'import/test-' . $date . '/';
$filename = $uploaddir . $values['file']['name'];
check_dir_exists($uploaddir);
move_uploaded_file($values['file']['tmp_name'], $filename);
if ($values['file']['type'] == 'application/zip') {
// Unzip here
$command = sprintf('%s %s %s %s', escapeshellcmd(get_config('pathtounzip')), escapeshellarg($filename), get_config('unzipdirarg'), escapeshellarg($uploaddir));
$output = array();
exec($command, $output, $returnvar);
if ($returnvar != 0) {
$SESSION->add_error_msg('Unable to unzip the file');
redirect('/import/');
}
$filename = $uploaddir . 'leap2a.xml';
if (!is_file($filename)) {
$SESSION->add_error_msg('No leap2a.xml file detected - please check your export file again');
redirect('/import/');
}
}
// Create dummy user
$user = (object) array('username' => 'import_' . $date, 'password' => 'import1', 'firstname' => 'Imported', 'lastname' => 'User (' . $nicedate . ')', 'email' => 'imported@example.org');
$userid = create_user($user);
// And we're good to go
echo '<pre>';
$filename = substr($filename, strlen(get_config('dataroot')));
require_once dirname(dirname(__FILE__)) . '/import/lib.php';
safe_require('import', 'leap');
db_begin();
$importer = PluginImport::create_importer(null, (object) array('token' => '', 'usr' => $userid, 'queue' => (int) (!PluginImport::import_immediately_allowed()), 'ready' => 0, 'expirytime' => db_format_timestamp(time() + 60 * 60 * 24), 'format' => 'leap', 'data' => array('filename' => $filename), 'loglevel' => PluginImportLeap::LOG_LEVEL_VERBOSE, 'logtargets' => LOG_TARGET_STDOUT, 'profile' => true));
$importer->process();
// Now done, delete the temporary e-mail address if there's a new one
// A bit sucky, presumes only one email in the import
$email = artefact_instance_from_id(get_field('artefact', 'id', 'title', 'imported@example.org', 'artefacttype', 'email', 'owner', $userid));
$email->delete();
execute_sql('UPDATE {artefact_internal_profile_email} SET principal = 1 WHERE "owner" = ?', array($userid));
db_commit();
echo "\n\n";
echo 'Done. You can <a href="' . get_config('wwwroot') . '/admin/users/changeuser.php?id=' . $userid . '">change to this user</a> to inspect the result, ';
echo 'or <a href="' . get_config('wwwroot') . 'import/">try importing again</a>';
echo '</pre>';
exit;
}
示例11: import_next_user
function import_next_user($filename, $username, $authinstance)
{
global $ADDEDUSERS, $FAILEDUSERS;
log_debug('adding user ' . $username . ' from ' . $filename);
$authobj = get_record('auth_instance', 'id', $authinstance);
$institution = new Institution($authobj->institution);
$date = time();
$nicedate = date('Y/m/d h:i:s', $date);
$niceuser = preg_replace('/[^a-zA-Z0-9_-]/', '-', $username);
$uploaddir = get_config('dataroot') . 'import/' . $niceuser . '-' . $date . '/';
check_dir_exists($uploaddir);
// Unzip the file
$archive = new ZipArchive();
if ($archive->open($filename) && $archive->extractTo($uploaddir)) {
// successfully extracted
$archive->close();
} else {
$FAILEDUSERS[$username] = get_string('unzipfailed', 'admin', hsc($filename));
return;
}
$leap2afilename = $uploaddir . 'leap2a.xml';
if (!is_file($leap2afilename)) {
$FAILEDUSERS[$username] = get_string('noleap2axmlfiledetected', 'admin');
log_debug($FAILEDUSERS[$username]);
return;
}
// If the username is already taken, append something to the end
while (get_record('usr', 'username', $username)) {
$username .= "_";
}
$user = (object) array('authinstance' => $authinstance, 'username' => $username, 'firstname' => 'Imported', 'lastname' => 'User', 'password' => get_random_key(6), 'passwordchange' => 1);
db_begin();
try {
$user->id = create_user($user, array(), $institution, $authobj);
} catch (EmailException $e) {
// Suppress any emails (e.g. new institution membership) sent out
// during user creation, becuase the user doesn't have an email
// address until we've imported them from the Leap2A file.
log_debug("Failed sending email during user import");
}
$niceuser = preg_replace('/[^a-zA-Z0-9_-]/', '-', $user->username);
$record = (object) array('token' => '', 'usr' => $user->id, 'queue' => (int) (!PluginImport::import_immediately_allowed()), 'ready' => 0, 'expirytime' => db_format_timestamp(time() + 60 * 60 * 24), 'format' => 'leap', 'data' => array('importfile' => $filename, 'importfilename' => $filename, 'importid' => $niceuser . time(), 'mimetype' => file_mime_type($filename)), 'loglevel' => PluginImportLeap::LOG_LEVEL_VERBOSE, 'logtargets' => LOG_TARGET_FILE, 'profile' => true);
$tr = new LocalImporterTransport($record);
$tr->extract_file();
$importer = PluginImport::create_importer(null, $tr, $record);
unset($record, $tr);
try {
$importer->process();
log_info("Imported user account {$user->id} from Leap2A file, see" . $importer->get('logfile') . 'for a full log');
} catch (ImportException $e) {
log_info("Leap2A import failed: " . $e->getMessage());
$FAILEDUSERS[$username] = get_string("leap2aimportfailed");
db_rollback();
}
db_commit();
if (empty($FAILEDUSERS[$username])) {
// Reload the user details, as various fields are changed by the
// importer when importing (e.g. firstname/lastname)
$newuser = get_record('usr', 'id', $user->id);
$newuser->clearpasswd = $user->password;
$ADDEDUSERS[] = $newuser;
}
return;
}
示例12: mysqli
$username = "root";
$password = "College@2015";
$dbname = "ESPDB";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if ($conn->query($sql) === TRUE) {
echo "User Successfully Registered";
register($_POST[firstname], $_POST[middlename], $_POST[lastname], $_POST[email], $_POST[dob], $_POST[phone], $_POST[addr1], $_POST[addr2], $_POST[city], $_POST[state], $_POST[country], $_POST[postalCode]);
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
$msg = "Error: " . "<br>" . $conn->error;
$h_fail = $h_fail . "?msg=" . $msg;
header($h_fail);
exit;
}
$conn->close();
}
//---------------------------------------------------------------Function Calls--------------------------------------------------------------
if ($_POST[register]) {
create_user($_POST[email], $_POST[pass1], $_POST[pass2], $_POST[firstname], $_POST[middlename], $_POST[lastname]);
//register($_POST[firstname], $_POST[middlename], $_POST[lastname], $_POST[email], $_POST[dob], $_POST[phone], $_POST[addr1], $_POST[addr2], $_POST[city], $_POST[state], $_POST[country], $_POST[postalCode]);
}
//-------------------------------------------------------- End of Function Calls ------------------------------------------------------------
?>
示例13: author_save_new
/**
* Creates a new user.
*/
function author_save_new()
{
require_privs('admin.edit');
extract(psa(array('privs', 'name', 'email', 'RealName')));
$privs = assert_int($privs);
if (is_valid_username($name) && is_valid_email($email)) {
if (user_exists($name)) {
author_list(array(gTxt('author_already_exists', array('{name}' => $name)), E_ERROR));
return;
}
$password = generate_password(PASSWORD_LENGTH);
$rs = create_user($name, $email, $password, $RealName, $privs);
if ($rs) {
send_password($RealName, $name, $email, $password);
author_list(gTxt('password_sent_to') . sp . $email);
return;
}
}
author_list(array(gTxt('error_adding_new_author'), E_ERROR));
}
示例14: unlink
<link rel="stylesheet" href="inc/style.css">
</head>
<body>
<?php
if (file_exists("install.php")) {
unlink("install.php");
}
include_once "client_functions.php";
include_once "users.php";
include_once "admin_functions.php";
include_once "list.php";
if (admin_logged_in()) {
if (isset($_POST['create'])) {
echo '<div class="login-card">';
echo "<center>Password : " . create_user() . "</center>";
echo '</div>';
direct("admin.php", 3);
} elseif (isset($_POST['log_out'])) {
session_destroy();
direct('admin.php', 0);
} elseif (isset($_POST['update_book'])) {
$list = new BookList(get_pathname());
$list->saveList();
echo '<div class="login-card">';
echo "<center>List has been updated.</center>";
echo '</div>';
direct('admin.php', 3);
} else {
echo '<div class="login-card">';
echo "<form method='post' action=''>\n\t\t<input type='submit' name='create' value='Create User' class='login login-submit' />\n\t\t<br/>\n\t\t<input type='submit' name='update_book' value='Update List' class='login login-submit' />\n\t\t<br/>\n\t\t<input type='submit' name='log_out' value='Logout' class='login login-submit' />\n\t\t</form>";
示例15: create_registered_user
function create_registered_user($profilefields = array())
{
global $registration, $SESSION, $USER;
require_once get_config('libroot') . 'user.php';
db_begin();
// Move the user record to the usr table from the registration table
$registrationid = $registration->id;
unset($registration->id);
unset($registration->expiry);
if ($expirytime = get_config('defaultregistrationexpirylifetime')) {
$registration->expiry = db_format_timestamp(time() + $expirytime);
}
$registration->lastlogin = db_format_timestamp(time());
$authinstance = get_record('auth_instance', 'institution', $registration->institution, 'authname', $registration->authtype ? $registration->authtype : 'internal');
if (false == $authinstance) {
throw new ConfigException('No ' . ($registration->authtype ? $registration->authtype : 'internal') . ' auth instance for institution');
}
if (!empty($registration->extra)) {
// Additional user settings were added during confirmation
$extrafields = unserialize($registration->extra);
}
$user = new User();
$user->active = 1;
$user->authinstance = $authinstance->id;
$user->firstname = $registration->firstname;
$user->lastname = $registration->lastname;
$user->email = $registration->email;
$user->username = get_new_username($user->firstname . $user->lastname);
$user->passwordchange = 1;
// Points that indicate the user is a "new user" who should be restricted from spammy activities.
// We count these down when they do good things; when they have 0 they're no longer a "new user"
if (is_using_probation()) {
$user->probation = get_config('probationstartingpoints');
} else {
$user->probation = 0;
}
if ($registration->institution != 'mahara') {
if (count_records_select('institution', "name != 'mahara'") == 1 || $registration->pending == 2) {
if (get_config_plugin('artefact', 'file', 'institutionaloverride')) {
$user->quota = get_field('institution', 'defaultquota', 'name', $registration->institution);
}
}
}
create_user($user, $profilefields);
// If the institution is 'mahara' then don't do anything
if ($registration->institution != 'mahara') {
$institutions = get_records_select_array('institution', "name != 'mahara'");
// If there is only one available, join it without requiring approval
if (count($institutions) == 1) {
$user->join_institution($registration->institution);
} else {
if ($registration->pending == 2) {
if (get_config('requireregistrationconfirm') || get_field('institution', 'registerconfirm', 'name', $registration->institution)) {
$user->join_institution($registration->institution);
}
} else {
if ($registration->authtype && $registration->authtype != 'internal') {
$auth = AuthFactory::create($authinstance->id);
if ($auth->weautocreateusers) {
$user->join_institution($registration->institution);
} else {
$user->add_institution_request($registration->institution);
}
} else {
$user->add_institution_request($registration->institution);
}
}
}
if (!empty($extrafields->institutionstaff)) {
// If the user isn't a member yet, this does nothing, but that's okay, it'll
// only be set after successful confirmation.
set_field('usr_institution', 'staff', 1, 'usr', $user->id, 'institution', $registration->institution);
}
}
if (!empty($registration->lang) && $registration->lang != 'default') {
set_account_preference($user->id, 'lang', $registration->lang);
}
// Delete the old registration record
delete_records('usr_registration', 'id', $registrationid);
db_commit();
// Log the user in and send them to the homepage
$USER = new LiveUser();
$USER->reanimate($user->id, $authinstance->id);
if (function_exists('local_post_register')) {
local_post_register($registration);
}
$SESSION->add_ok_msg(get_string('registrationcomplete', 'mahara', get_config('sitename')));
$SESSION->set('resetusername', true);
redirect();
}