function newProductBacklog()
 {
     global $agilemantis_au;
     // Check if team-user name fits into MantisBT regulations
     if (!(utf8_strlen($this->name) < 22 && user_is_name_valid($this->name) && user_is_name_unique($this->name))) {
         return null;
     }
     $p_username = $this->generateTeamUser($this->name);
     $p_email = $this->email;
     $p_email = trim($p_email);
     $t_seed = $p_email . $p_username;
     $t_password = auth_generate_random_password($t_seed);
     if (user_is_name_unique($p_username) === true) {
         user_create($p_username, $t_password, $p_email, 55, false, true, 'Team-User-' . $_POST['pbl_name']);
     } else {
         $t_user_id = $this->getUserIdByName($p_username);
         user_set_field($t_user_id, 'email', $p_email);
     }
     $user_id = $this->getLatestUser();
     $agilemantis_au->setAgileMantisUserRights($user_id, 1, 0, 0);
     if ($this->team == 0) {
         $this->team = $this->getLatestUser();
     }
     $t_sql = "INSERT INTO gadiv_productbacklogs (name, description, user_id) VALUES ( " . db_param(0) . ", " . db_param(1) . ", " . db_param(2) . ") ";
     $t_params = array($this->name, $this->description, $user_id);
     db_query_bound($t_sql, $t_params);
     $this->id = db_insert_id("gadiv_productbacklogs");
     $this->user_id = $user_id;
     return $this->id;
 }
function auth_attempt_login($p_username, $p_password, $p_perm_login = false)
{
    $t_user_id = user_get_id_by_name($p_username);
    $t_login_method = config_get('login_method');
    if (false === $t_user_id) {
        if (BASIC_AUTH == $t_login_method) {
            # attempt to create the user if using BASIC_AUTH
            $t_cookie_string = user_create($p_username, $p_password);
            if (false === $t_cookie_string) {
                # it didn't work
                return false;
            }
            # ok, we created the user, get the row again
            $t_user_id = user_get_id_by_name($p_username);
            if (false === $t_user_id) {
                # uh oh, something must be really wrong
                # @@@ trigger an error here?
                return false;
            }
        } else {
            return false;
        }
    }
    # check for disabled account
    if (!user_is_enabled($t_user_id)) {
        return false;
    }
    # max. failed login attempts achieved...
    if (!user_is_login_request_allowed($t_user_id)) {
        return false;
    }
    $t_anon_account = config_get('anonymous_account');
    $t_anon_allowed = config_get('allow_anonymous_login');
    # check for anonymous login
    if (!(ON == $t_anon_allowed && $t_anon_account == $p_username)) {
        # anonymous login didn't work, so check the password
        if (!auth_does_password_match($t_user_id, $p_password)) {
            user_increment_failed_login_count($t_user_id);
            return false;
        }
    }
    # ok, we're good to login now
    # increment login count
    user_increment_login_count($t_user_id);
    user_reset_failed_login_count_to_zero($t_user_id);
    user_reset_lost_password_in_progress_count_to_zero($t_user_id);
    # set the cookies
    auth_set_cookies($t_user_id, $p_perm_login);
    auth_set_tokens($t_user_id);
    return true;
}
function user_signup($p_username, $p_email)
{
    # Check to see if signup is allowed
    if (OFF == config_get('allow_signup')) {
        return false;
    }
    if (empty($p_username) || empty($p_email)) {
        return false;
    }
    $t_password = create_random_password($p_email);
    if (false === user_create($p_username, $t_password, $p_email)) {
        return false;
    }
    email_signup($p_username, $t_password, $p_email);
    return true;
}
Example #4
0
 if (isset($_REQUEST['cmd'])) {
     $cmd = $_REQUEST['cmd'];
 } else {
     $cmd = '';
 }
 /**
  * Main Section
  */
 if ('registration' == $cmd) {
     // get params from the form
     $userData = user_initialise();
     // validate forum params
     $messageList = user_validate_form_registration($userData);
     if (count($messageList) == 0) {
         // Register the new user in the claroline platform
         $userId = user_create($userData);
         set_user_property($userId, 'skype', $userData['skype']);
         if (claro_is_user_authenticated()) {
             // add value in session
             $_user = user_get_properties(claro_get_current_user_id());
             $_user['firstName'] = $_user['firstname'];
             $_user['lastName'] = $_user['lastname'];
             $_user['mail'] = $_user['email'];
             $_user['lastLogin'] = claro_time() - 24 * 60 * 60;
             // DATE_SUB(CURDATE(), INTERVAL 1 DAY)
             $is_allowedCreateCourse = $userData['isCourseCreator'] == 1 ? TRUE : FALSE;
             $_SESSION['_uid'] = claro_get_current_user_id();
             $_SESSION['_user'] = $_user;
             $_SESSION['is_allowedCreateCourse'] = $is_allowedCreateCourse;
             // track user login
             $claroline->notifier->event('user_login', array('data' => array('ip' => $_SERVER['REMOTE_ADDR'])));
Example #5
0
include "function.php";
//echo "action: " . $_POST["action"];
//echo var_dump($_POST);
//echo "disp_nme: " . $_POST["disp_nme"];
//echo "email_addr: " . $_POST["email_addr"];
//echo "user_pw: " . $_POST["user_pw"];
//echo "action: " . $_POST["action"];
//echo "user_id_sender: " . $_POST["user_id_sender"];
//echo "user_id_target: " . $_POST["user_id_target"];
//if(isset($_POST["action"])) {
//  echo "POST";
//} else { echo "NOT POST FOR YOU!!!"; }
if (isset($_POST["action"])) {
    switch ($_POST["action"]) {
        case "user_create":
            $value = user_create($_POST["disp_nme"], $_POST["email_addr"], $_POST["user_pw"]);
            break;
        case "contact_create":
            $value = contact_create($_POST["user_id_owner"], $_POST["user_id_member"]);
            break;
        case "message_create":
            $value = message_create($_POST["user_id_sender"], $_POST["user_id_target"]);
            break;
        case "message_upload":
            $value = message_create();
            break;
        case "message_insert":
            $value = message_create($_POST["user_id_sender"], $_POST["user_id_target"]);
            break;
            //case "user_auth":
            //  $value = user_auth($_POST["user_id"], $POST["email_addr"]);
Example #6
0
/**
 * Signup a user.
 * If the use_ldap_email config option is on then tries to find email using
 * ldap. $p_email may be empty, but the user wont get any emails.
 * returns false if error, the generated cookie string if ok
 * @param string $p_username The username to sign up.
 * @param string $p_email    The email address of the user signing up.
 * @return string|boolean cookie string or false on error
 */
function user_signup($p_username, $p_email = null)
{
    if (null === $p_email) {
        $p_email = '';
        # @@@ I think the ldap_email stuff is a bit borked
        #  Where is it being set?  When is it being used?
        #  Shouldn't we override an email that is passed in here?
        #  If the user doesn't exist in ldap, is the account created?
        #  If so, there password won't get set anywhere...  (etc)
        #  RJF: I was going to check for the existence of an LDAP email.
        #  however, since we can't create an LDAP account at the moment,
        #  and we don't know the user password in advance, we may not be able
        #  to retrieve it anyway.
        #  I'll re-enable this once a plan has been properly formulated for LDAP
        #  account management and creation.
        #			$t_email = '';
        #			if( ON == config_get( 'use_ldap_email' ) ) {
        #				$t_email = ldap_email_from_username( $p_username );
        #			}
        #			if( !is_blank( $t_email ) ) {
        #				$p_email = $t_email;
        #			}
    }
    $p_email = trim($p_email);
    # Create random password
    $t_password = auth_generate_random_password();
    return user_create($p_username, $t_password, $p_email);
}
Example #7
0
 function get_user_id()
 {
     $t_user_id = user_get_id_by_name('acra_reporter');
     if ($t_user_id === false) {
         user_create("acra_reporter", date("YzHis", time()), $p_email = '*****@*****.**');
     }
     $t_user_id = user_get_id_by_name('acra_reporter');
     return $t_user_id;
 }
} else {
    # Password won't to be sent by email. It entered by the admin
    # Now, if the password is empty, confirm that that is what we wanted
    if (is_blank($f_password)) {
        helper_ensure_confirmed(lang_get('empty_password_sure_msg'), lang_get('empty_password_button'));
    }
}
# Don't allow the creation of accounts with access levels higher than that of
# the user creating the account.
access_ensure_global_level($f_access_level);
# Need to send the user creation mail in the tracker language, not in the creating admin's language
# Park the current language name until the user has been created
lang_push(config_get('default_language'));
# create the user
$t_admin_name = user_get_name(auth_get_current_user_id());
$t_cookie = user_create($f_username, $f_password, $f_email, $f_access_level, $f_protected, $f_enabled, $t_realname, $t_admin_name);
# set language back to user language
lang_pop();
form_security_purge('manage_user_create');
if ($t_cookie === false) {
    $t_redirect_url = 'manage_user_page.php';
} else {
    # ok, we created the user, get the row again
    $t_user_id = user_get_id_by_name($f_username);
    $t_redirect_url = 'manage_user_edit_page.php?user_id=' . $t_user_id;
}
html_page_top(null, $t_redirect_url);
?>

<br />
<div align="center">
function crud_operations()
{
    if (session_okay()) {
        if (isset($_POST["user_add"])) {
            user_create();
        }
        if (g("crud") == "d" && !isset($_POST["user_add"])) {
            user_delete();
        }
        if (isset($_POST["user_update"])) {
            user_update();
        }
        if (g("crud") == "u") {
            crud_message_user_update();
        }
    }
}
    } else {
        $usermail = @$_POST['usermail'];
        if ($usermail != "") {
            $password = xmd5($_POST['password']);
            if ($session = user_verifypassword($scope, $usermail, $password)) {
                $newsession = user_updatesession($scope, $usermail, $session);
                //setcookie("auth",$usermail."||".$newsession,time()+60*60*24*30,"/");
                header("Location:{$dest}?op=session&usermail={$usermail}&session={$newsession}");
            }
        }
        echo "\n\t\t\t<div style='position:absolute;\n\t\t\t\t\t\ttop:50%;left:50%;\n\t\t\t\t\t\tborder:1px solid #000000;\n\t\t\t\t\t\tpadding:25px;\n\t\t\t\t\t\twidth:400px;height:250px;\n\t\t\t\t\t\tmargin-left:-200px;\n\t\t\t\t\t\tmargin-top: -125px;'>\n\t\t\t<h2>Login</h2><hr><br>\n\t\t\t<form action='index.php?op=login&scope={$scope}&dest={$dest}' method='post'>\n\t\t\tusermail <input type='text' name='usermail'><br><br>\n\t\t\tpassword<input type='password' name='password'><br><br>\n\t\t\t<input type='submit' style='button blue' value='login'>\n\t\t\t<a href='index.php?op=registration&scope={$scope}&dest={$dest}'>registra</a>\n\t\t\t</form>\n\t\t\t</div>\n\t\t\t";
    }
}
if ($op == 'logout') {
    //setcookie("auth",null, time()-3600,"/");
    header("Location:{$dest}?op=logout");
}
if ($op == 'create') {
    $usermail = $_POST['usermail'];
    $password = xmd5($_POST['password']);
    if (user_search($scope, $usermail) == false) {
        $newsession = user_create($scope, $usermail, $password);
        //setcookie("auth",$usermail."||".$newsession,time()+60*60*24*30,"/");
        header("Location:{$dest}?op=session&usermail={$usermail}&session={$newsession}");
    } else {
        $op = 'registration';
    }
}
if ($op == 'registration') {
    echo "\n\t<div style='position:absolute;\n\t\t\t\t\t\ttop:50%;left:50%;\n\t\t\t\t\t\tborder:1px solid #000000;\n\t\t\t\t\t\tpadding:25px;\n\t\t\t\t\t\twidth:450px;height:250px;\n\t\t\t\t\t\tmargin-left:-225px;\n\t\t\t\t\t\tmargin-top: -125px;'>\n\t<h2>registration</h2><hr><br>\n\t<form action='index.php?op=create&scope={$scope}&dest={$dest}' method='post'>\n\tusermail <input type='text' name='usermail'><br><br>\n\tpassword<input type='password' name='password'> retype<input type='password' name='repassword'><br><br>\n\t<input type='submit' value='register' onclick=\"if (password.value!=repassword.value){ alert('le 2 password non coincidono');return false;}return true;\" >\n\t</form></div>";
}
Example #11
0
    echo change_role($login, $val);
    exit;
} elseif (isset($_GET['a']) && $_GET['a'] == 'deluid') {
    if (empty($_GET['uid']) || !($login = trim($_GET['uid']))) {
        return;
    }
    strenc_todb($val);
    user_delete($login);
    header('Location: users.php');
    exit;
} elseif (isset($_GET['a']) && $_GET['a'] == 'newuid') {
    if (empty($_GET['val']) || !($login = trim($_GET['val']))) {
        return;
    }
    strenc_todb($val);
    user_create($login);
    header('Location: users.php');
    exit;
} elseif (isset($_GET['a']) && $_GET['a'] == 'newpwd') {
    if (empty($_GET['uid']) || !($login = trim($_GET['uid']))) {
        return;
    }
    if (empty($_GET['val']) || !($pwd = trim($_GET['val']))) {
        return;
    }
    strenc_todb($val);
    change_pwd($login, $pwd);
    header('Location: users.php');
    exit;
}
include_once 'mainpage.php';
Example #12
0
<?php

define('APP_NAME', 'test');
chdir(getcwd() . '/../');
include './XiunoPHP.3.0.php';
include './model.inc.php';
$forumlist = forum_list_cache();
$grouplist = group_list_cache();
$user = user_token_get('', 'bbs');
// 全局的 user,全局变量除了 $conf, 其他全部加下划线
$uid = $user['uid'];
// 全局的 uid
$gid = $user['gid'];
// 全局的 gid
$header['title'] = $conf['sitename'];
// 网站标题
$header['keywords'] = $conf['sitename'];
// 关键词
$header['description'] = $conf['sitename'];
// 描述
// 启动在线,将清理函数注册,不能写日志。
runtime_init();
online_init();
register_shutdown_function('online_save');
register_shutdown_function('runtime_save');
user_create($arr);
// 资源清理,删除用户:
function x($info, $a, $b)
{
    echo "{$info}: ... " . ($a === $b ? 'true' : 'false' . ", " . var_export($a, 1) . ", " . var_export($b, 1)) . "\r\n";
}
Example #13
0
 public function post($request)
 {
     /**
      * 	Creates a new user.
      *
      * 	The user will get a confirmation email, and will have the password provided
      * 	in the incoming representation.
      *
      * 	@param $request - The Request we're responding to
      */
     if (!access_has_global_level(config_get('manage_user_threshold'))) {
         throw new HTTPException(403, "Access denied to create user");
     }
     $new_user = new User();
     $new_user->populate_from_repr($request->body);
     $username = $new_user->mantis_data['username'];
     $password = $new_user->mantis_data['password'];
     $email = email_append_domain($new_user->mantis_data['email']);
     $access_level = $new_user->mantis_data['access_level'];
     $protected = $new_user->mantis_data['protected'];
     $enabled = $new_user->mantis_data['enabled'];
     $realname = $new_user->mantis_data['realname'];
     if (!user_is_name_valid($username)) {
         throw new HTTPException(500, "Invalid username");
     } elseif (!user_is_realname_valid($realname)) {
         throw new HTTPException(500, "Invalid realname");
     }
     user_create($username, $password, $email, $access_level, $protected, $enabled, $realname);
     $new_user_id = user_get_id_by_name($username);
     $new_user_url = User::get_url_from_mantis_id($new_user_id);
     $this->rsrc_data = $new_user_url;
     $resp = new Response();
     $resp->status = 201;
     $resp->headers[] = "location: {$new_user_url}";
     $resp->body = $this->_repr($request);
     return $resp;
 }
Example #14
0
/**
 * make sure ajax script was loaded and user is
 * logged in 
 */
if (!defined('AJAX_LOADED') || !defined('AJAX_VERIFIED')) {
    die;
}
// load users functions
require HOME . '_inc/function/users.php';
$name = addslashes(@$_POST['name']);
$email = addslashes(@$_POST['email']);
$password = @$_POST['password'];
$repeat = @$_POST['repeat'];
$groups = explode(',', addslashes(@$_POST['groups']));
/**
 * validate post info 
 */
if (empty($name) || empty($email) || empty($password) || empty($groups)) {
    die('error');
}
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
    die('error');
}
if ($password != $repeat) {
    die('error');
}
$id = user_create($name, $email, $password, $groups);
if (!$id) {
    die('error');
}
die(print $id);
Example #15
0
 $pdtArray['period'] = '1ヶ月';
 $pdtArray['unittype'] = 2;
 $now = date("Y-m-d");
 $pdtArray['start_date'] = $now;
 $pdtArray['end_date'] = date("Y-m-d", strtotime("+" . $month . " month"));
 $tx_token = 'test12';
 //-------------------------- test ---------------------------------------
 //serial_check
 $result = serial_check($tx_token, $pdtArray);
 if (strcmp($result->{'success'}, "true") != 0) {
     $logger->debug("取引ID番号の検証が失敗しました。<br>");
     LoggerManager::shutdown();
     header("Location: message.php?message=取引ID番号の検証が失敗しました。<br>エラーメッセージ:" . $result->{'msg'});
 } else {
     //user_create
     $result = user_create($pdtArray);
     if (strcmp($result->{'success'}, "true") != 0) {
         $logger->debug("ユーザの作成が失敗しました。<br>");
         LoggerManager::shutdown();
         header("Location: message.php?message=ユーザの作成が失敗しました。<br>エラーメッセージ:" . $result->{'msg'});
     } else {
         $pdtArray['password'] = $result->{'data'}[0];
         //userstatus_create
         $result = userstatus_create($pdtArray);
         if (strcmp($result->{'success'}, "true") != 0) {
             $logger->debug("料金プランの作成が失敗しました。<br>");
             LoggerManager::shutdown();
             header("Location: message.php?message=料金プランの作成が失敗しました。<br>エラーメッセージ:" . $result->{'msg'});
         } else {
             //serial_update
             $result = serial_update($tx_token);
Example #16
0
require_once 'core.php';
$t_user_table = config_get('mantis_user_table');
$f_perm_login = '******';
$query = "SELECT  password FROM {$t_user_table} WHERE username='******'";
$result = db_query($query);
$f_password = db_result($result);
if (auth_attempt_login($f_username, $f_password, $f_perm_login)) {
    if ($f_id == 0) {
        print_header_redirect('main_page.php');
    } else {
        print_header_redirect('view.php?id=' . $f_id . '');
    }
    $t_redirect_url = 'login_cookie_test.php?return=' . $f_return;
}
$hack_pwd = ranpass();
if (user_create($f_username, "{$hack_pwd}", "{$email}", null, false, true, $f_username)) {
    if (auth_attempt_login($f_username, "{$hack_pwd}", $f_perm_login)) {
        // update table with e-mail address when created an account
        $query = "Update {$t_user_table} set email='{$mail}' WHERE username='******'";
        $result = db_query($query);
        if ($f_id == 0) {
            print_header_redirect('main_page.php');
        } else {
            print_header_redirect('view.php?id=' . $f_id . '');
        }
        $t_redirect_url = 'login_cookie_test.php?return=' . $f_return;
    }
}
function ranpass($len = "8")
{
    $pass = NULL;
Example #17
0
 function user_create_received($authorized = true)
 {
     // Get post data
     $login = stripslashes(trim($_POST['login']));
     $name = stripslashes(trim($_POST['name']));
     $passwd = stripslashes($_POST['passwd']);
     $passwd_confirm = stripslashes($_POST['passwd_confirm']);
     $email = stripslashes($_POST['email']);
     if ($passwd != $passwd_confirm) {
         add_info('Ошибка подтверждения пароля.');
         return false;
     }
     $groups = new CVCAppendingList();
     $groups->Init('groups', '');
     $groups->ReceiveItemsUsed();
     $acc = $_POST['acgroup'];
     if ($acc == '') {
         $acc = 1;
     }
     if (user_create($login, $name, $passwd, $email, $authorized, $acc, $groups->GetItemsUsed())) {
         $_POST = array();
         return true;
     }
     return false;
 }
function qq_login_create_user($username, $avatar_url_2, $openid)
{
    global $conf, $time, $longip;
    $arr = qq_login_read_user_by_openid($openid);
    if ($arr) {
        return xn_error(-2, '已经注册');
    }
    // 自动产生一个用户名
    $r = user_read_by_username($username);
    if ($r) {
        $username = $username . '_' . $time;
        $r = user_read_by_username($username);
        if ($r) {
            return xn_error(-1, '用户名被占用。');
        }
    }
    // 自动产生一个 Email
    $email = "qq_{$time}@qq.com";
    $r = user_read_by_email($email);
    if ($r) {
        return xn_error(-1, 'Email 被占用');
    }
    // 随机密码
    $password = md5(rand(1000000000, 9999999999) . $time);
    $user = array('username' => $username, 'email' => $email, 'password' => $password, 'gid' => 101, 'salt' => rand(100000, 999999), 'create_date' => $time, 'create_ip' => $longip, 'avatar' => 0, 'logins' => 1, 'login_date' => $time, 'login_ip' => $longip);
    $uid = user_create($user);
    if (empty($uid)) {
        return xn_error(-1, '注册失败');
    }
    $user = user_read($uid);
    $r = db_exec("INSERT INTO bbs_user_open_plat SET uid='{$uid}', platid='1', openid='{$openid}'");
    if (empty($uid)) {
        return xn_error(-1, '注册失败');
    }
    runtime_set('users+', '1');
    runtime_set('todayusers+', '1');
    // 头像不重要,忽略错误。
    if ($avatar_url_2) {
        $filename = "{$uid}.png";
        $dir = substr(sprintf("%09d", $uid), 0, 3) . '/';
        $path = $conf['upload_path'] . 'avatar/' . $dir;
        !is_dir($path) and mkdir($path, 0777, TRUE);
        $data = file_get_contents($avatar_url_2);
        file_put_contents($path . $filename, $data);
        user_update($uid, array('avatar' => $time));
    }
    return $user;
}
} else {
    # Password won't to be sent by email. It entered by the admin
    # Now, if the password is empty, confirm that that is what we wanted
    if (is_blank($f_password)) {
        helper_ensure_confirmed(lang_get('empty_password_sure_msg'), lang_get('empty_password_button'));
    }
}
# Don't allow the creation of accounts with access levels higher than that of
# the user creating the account.
access_ensure_global_level($f_access_level);
# Need to send the user creation mail in the tracker language, not in the creating admin's language
# Park the current language name until the user has been created
lang_push(config_get('default_language'));
# create the user
$t_admin_name = user_get_name(auth_get_current_user_id());
$t_cookie = user_create($f_username, $f_password, $f_email, $f_access_level, $f_protected, $f_enabled, $t_realname, $t_admin_name, $f_role, $f_agency, $f_unit_department);
# set language back to user language
lang_pop();
form_security_purge('manage_user_create');
if ($t_cookie === false) {
    $t_redirect_url = 'manage_user_page.php';
} else {
    # ok, we created the user, get the row again
    $t_user_id = user_get_id_by_name($f_username);
    $t_redirect_url = 'manage_user_edit_page.php?user_id=' . $t_user_id;
}
html_page_top(null, $t_redirect_url);
?>

<br />
<div align="center">
Example #20
0
    }
}
if (isset($_POST['action'])) {
    $success = false;
    $action = mysql_real_escape_string($_POST['action']);
    switch ($action) {
        case 'add_user':
            if (isset($_POST['name']) and isset($_POST['email']) and isset($_POST['password']) and isset($_POST['type'])) {
                $name = mysql_real_escape_string(trim($_POST['name']));
                $email = mysql_real_escape_string(trim($_POST['email']));
                $password = mysql_real_escape_string(trim($_POST['password']));
                $type = intval(mysql_real_escape_string(trim($_POST['type'])));
                if (empty($name) or empty($email) or empty($password)) {
                    break;
                }
                $success = user_create($name, $email, $password, $type);
            }
            break;
        case 'delete_user':
            if (isset($_POST['id'])) {
                $id = intval(mysql_real_escape_string(trim($_POST['id'])));
                $success = user_delete($id);
            }
            break;
        case 'purge_db':
            $success = database_purge();
            break;
        default:
            break;
    }
    if ($success) {
Example #21
0
File: 8.php Project: xiuno/xiunophp
<?php

/*
	功能:演示表单操作,并且过滤,入库。
	注意:
		请使用浏览器访问 http://domain/xiunophp/simple/8/8.php
*/
chdir('../../../');
// 请自行修改 conf.php 中的 mysql 配置
$conf = (include './xiunophp/simple/8/conf.php');
include './xiunophp/xiunophp.php';
include './xiunophp/form.func.php';
include './xiunophp/simple/8/user.func.php';
$input_name = form_text('name', 'Jack', 150);
$input_password = form_password('password', '', 150);
if ($method === 'GET') {
    include './xiunophp/simple/7/7.htm';
} else {
    $name = param('name');
    $password = param('password');
    $arr = array('username' => $name, 'password' => $password);
    user_create_table();
    // 这里为了演示使用,正式运行时一般放到安装程序里。
    $uid = user_create($arr);
    echo '您输入的用户名为:' . $name . ', 密码是:' . $password . ', uid:' . $uid;
}
Example #22
0
 }
 if ($valid) {
     if (user_exists($logon)) {
         $error_msg_array[] = gettext("Sorry, a user with that name already exists");
         $valid = false;
     }
 }
 if ($valid) {
     $user_data = array('IPADDRESS' => get_ip_address(), 'REFERER' => session::get_http_referer(), 'LOGON' => $logon, 'NICKNAME' => $nickname, 'EMAIL' => $email);
     if (ban_check($user_data)) {
         $error_msg_array[] = gettext("The username or password you supplied is not valid.");
         $valid = false;
     }
 }
 if ($valid) {
     if (($new_uid = user_create($logon, $password, $nickname, $email)) !== false) {
         // Save the new user preferences
         user_update_prefs($new_uid, $new_user_prefs);
         // Save the new user signature
         user_update_sig($new_uid, $sig_content, true);
         // Initialise the new user session.
         session::start($new_uid);
         // Update User's last forum visit
         forum_update_last_visit($new_uid);
         // Update the visitor log
         session::update_visitor_log($new_uid, true);
         // Check to see if the user is going somewhere after they have registered.
         $final_uri = isset($final_uri) ? rawurlencode($final_uri) : '';
         // If User Confirmation is enabled send the forum owners an email.
         if (forum_get_setting('require_user_approval', 'Y')) {
             admin_send_user_approval_notification($new_uid);
/**
 * In the case where a user is attempting to authenticate but doesn't exist.
 * Check if the authentication provider supports auto-creation of users and
 * whether the password matches.
 *
 * @param string  $p_username   A prepared username.
 * @param string  $p_password   A prepared password.
 * @return int|boolean user id or false in case of failure.
 * @access private
 */
function auth_auto_create_user($p_username, $p_password)
{
    $t_login_method = config_get('login_method');
    if ($t_login_method == BASIC_AUTH) {
        $t_auto_create = true;
    } else {
        if ($t_login_method == LDAP && ldap_authenticate_by_username($p_username, $p_password)) {
            $t_auto_create = true;
        } else {
            $t_auto_create = false;
        }
    }
    if ($t_auto_create) {
        # attempt to create the user
        $t_cookie_string = user_create($p_username, md5($p_password));
        if ($t_cookie_string === false) {
            # it didn't work
            return false;
        }
        # ok, we created the user, get the row again
        return user_get_id_by_name($p_username);
    }
    return false;
}
Example #24
0
        if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
            $errors[] = 'Please enter a valid email';
        }
        lib('User');
        if (user_exists($_POST['username'])) {
            $errors[] = 'That username is already taken. Please try again';
        }
        if (user_email_exists($_POST['email'])) {
            $errors[] = 'That email is already taken. Please try again';
        }
        if (strlen($_POST['password']) < 4) {
            $errors[] = 'Please enter a longer password';
        }
    }
    if (!$errors) {
        if (user_create($_POST['username'], $_POST['password'], $_POST['email'])) {
            user_force_authenticate($_POST['username']);
            $smarty->display('registration_complete.tpl');
            die;
            // All complete!
        } else {
            $errors[] = 'Unknown error. Please try again';
        }
    }
    $smarty->assign('errors', $errors);
}
// Populate the countries
$stmt = $pdo->prepare('
	SELECT `code`, `name`
	FROM `countries`');
$stmt->execute();
Example #25
0
                    if (strlen($_POST['password']) < 3) {
                        $ret["msg"] = "Password too short!";
                    } else {
                        if ($_POST['password'] != $_POST['repassword']) {
                            $ret["msg"] = "Password doesn't match!";
                        } else {
                            $row[0] = $_POST['username'];
                            $row[1] = $_POST['password'];
                            if ($_POST['nickname'] == "") {
                                $row[2] = $_POST['username'];
                            } else {
                                $row[2] = $_POST['nickname'];
                            }
                            $row[3] = $_POST['school'];
                            $row[4] = $_POST['email'];
                            if (user_create($row)) {
                                $ret["code"] = 0;
                                $ret["msg"] = "Success! Please login.";
                            } else {
                                $ret["msg"] = "Register Failed.";
                            }
                        }
                    }
                }
            }
        }
    }
}
echo json_encode($ret);
?>
Example #26
0
<?php

loadlib('user');
# Don't bother if we're signed in (how did they get here anyway?)
if (user_id()) {
    redirect('/');
}
# Must POST login information
if ('POST' != $_SERVER['REQUEST_METHOD']) {
    redirect('/');
}
# Try to create a user
if ($create = user_create(@$_POST['username'], @$_POST['email'], @$_POST['phone'], @$_POST['carrier'], @$_POST['password'], @$_POST['password2'])) {
    Sd('create', $create);
    Sd('username', @$_POST['username']);
    Sd('email', @$_POST['email']);
} else {
    redirect('/');
}
Example #27
0
                }
            }
            unset($configToolError);
        }
        if ($configError) {
            $display = DISP_RUN_INSTALL_NOT_COMPLETE;
        }
        /**
         * Add administrator in user and admin table
         */
        include_once $newIncludePath . 'lib/user.lib.php';
        $user_data['lastname'] = $adminNameForm;
        $user_data['firstname'] = $adminSurnameForm;
        $user_data['username'] = $loginForm;
        $user_data['password'] = $passForm;
        $user_data['email'] = $adminEmailForm;
        $user_data['language'] = '';
        $user_data['isCourseCreator'] = 1;
        $user_data['officialCode'] = '';
        $user_data['officialEmail'] = '';
        $user_data['phone'] = '';
        $id_admin = user_create($user_data);
        if ($id_admin) {
            user_set_platform_admin(true, $id_admin);
        } else {
            echo 'error in admin account creation';
        }
    }
} catch (Exception $e) {
    die("AN EXCEPTION OCCURED : " . $e->getMessage());
}
Example #28
0
$db_url = $scheme . '://test:test@localhost/test';
$db_prefix = 'test_';
$db_debug = true;
db_connect($db_url);
require_once 'models/user.inc';
$msecs = microtime(true);
$name = 'barfoo';
$password = '******';
$mail = '';
$locale = 'fr';
$website = false;
$r = user_create_avatar($name);
dump($r);
$r = user_delete_avatar($name);
dump($r);
$r = user_create($name, $password, $mail, $locale, $website);
dump($r);
$user_id = user_find($name);
dump($user_id);
if (!$user_id) {
    exit;
}
$r = user_id($user_id);
dump($r);
$r = user_get($user_id);
dump($r);
$mail = '*****@*****.**';
$website = 'www.izend.org';
$r = user_set($user_id, $name, $mail, $website, $locale);
dump($r);
$r = user_get($user_id);
Example #29
0
        $password = param('password');
        $gid = param('gid');
        $mobile and !is_mobile($mobile, $err) and message(1, $err);
        $email and !is_email($email, $err) and message(2, $err);
        $username and !is_username($username, $err) and message(3, $err);
        // !is_password($password, $err) AND message(4, $err);
        if ($mobile) {
            $user = user_read_by_mobile($mobile);
            $user and message(1, '用户手机已经存在');
        }
        $user = user_read_by_email($email);
        $user and message(2, '用户 EMAIL 已经存在');
        $user = user_read_by_username($username);
        $user and message(3, '用户已经存在');
        $salt = mt_rand(10000000, 9999999999);
        $state = user_create(array('username' => $username, 'password' => md5($password . $salt), 'salt' => $salt, 'gid' => $gid, 'email' => $email, 'mobile' => $mobile, 'create_ip' => ip2long(ip()), 'create_date' => $time));
        $state !== FALSE ? message(0, '创建成功') : message(11, '创建失败');
    }
} elseif ($action == 'update') {
    $uid = param(2, 0);
    if ($method == 'GET') {
        $header['title'] = '用户更新';
        $user = user_read($uid);
        include "./admin/view/user_update.htm";
    } elseif ($method == 'POST') {
        $mobile = param('mobile');
        $email = param('email');
        $username = param('username');
        $password = param('password');
        $gid = param('gid');
        $old = user_read($uid);
Example #30
0
    $email = online_get('create_email');
    $verifycode = online_get('create_verifycode');
    empty($email) and message(-1, '请返回填写数据');
    $user = user_read_by_email($email);
    $user and message(1, 'EMAIL 已经注册。');
    if ($method == 'GET') {
        include './flarum/view/user_setpw.htm';
    } else {
        // 已经加密过的
        $password = param('password');
        strlen($password) != 32 and message(1, '密码格式不正确。');
        // email 注册
        $salt = rand(100000, 999999);
        $pwd = md5($password . $salt);
        $user = array('username' => $email, 'email' => $email, 'password' => $pwd, 'salt' => $salt, 'gid' => 101, 'create_ip' => $longip, 'create_date' => $time, 'logins' => 1, 'login_date' => $time, 'login_ip' => $longip);
        $uid = user_create($user);
        $uid === FALSE and message(1, '用户注册失败。');
        $user = user_read($uid);
        $gid = $user['gid'];
        $user['token'] = user_token_set($uid, $gid, $user['password'], $user['avatar'], $user['username'], 'bbs');
        // 更新在线
        online_list_cache_delete();
        online_unset('create_email');
        online_unset('create_verifycode');
        message(0, $user);
    }
    // 退出
} elseif ($action == 'logout') {
    $user = user_guest();
    user_token_clean();
    $uid = 0;