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


PHP user_add函数代码示例

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


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

示例1: update_bing_bot

    public function update_bing_bot()
    {
        $bot_name = 'Bing [Bot]';
        $bot_name_clean = utf8_clean_string($bot_name);
        $sql = 'SELECT user_id
			FROM ' . USERS_TABLE . "\n\t\t\tWHERE username_clean = '" . $this->db->sql_escape($bot_name_clean) . "'";
        $result = $this->db->sql_query($sql);
        $bing_already_added = (bool) $this->db->sql_fetchfield('user_id');
        $this->db->sql_freeresult($result);
        if (!$bing_already_added) {
            $bot_agent = 'bingbot/';
            $bot_ip = '';
            $sql = 'SELECT group_id, group_colour
				FROM ' . GROUPS_TABLE . "\n\t\t\t\tWHERE group_name = 'BOTS'";
            $result = $this->db->sql_query($sql);
            $group_row = $this->db->sql_fetchrow($result);
            $this->db->sql_freeresult($result);
            if (!$group_row) {
                // default fallback, should never get here
                $group_row['group_id'] = 6;
                $group_row['group_colour'] = '9E8DA7';
            }
            if (!function_exists('user_add')) {
                include $this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext;
            }
            $user_row = array('user_type' => USER_IGNORE, 'group_id' => $group_row['group_id'], 'username' => $bot_name, 'user_regdate' => time(), 'user_password' => '', 'user_colour' => $group_row['group_colour'], 'user_email' => '', 'user_lang' => $this->config['default_lang'], 'user_style' => $this->config['default_style'], 'user_timezone' => 0, 'user_dateformat' => $this->config['default_dateformat'], 'user_allow_massemail' => 0);
            $user_id = user_add($user_row);
            $sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $this->db->sql_build_array('INSERT', array('bot_active' => 1, 'bot_name' => (string) $bot_name, 'user_id' => (int) $user_id, 'bot_agent' => (string) $bot_agent, 'bot_ip' => (string) $bot_ip));
            $this->sql_query($sql);
        }
    }
开发者ID:Tarendai,项目名称:spring-website,代码行数:31,代码来源:bot_update.php

示例2: main

 public function main($id, $mode)
 {
     global $data, $config, $error, $submit;
     $timezone = $config['board_timezone'];
     $data = array('username' => utf8_normalize_nfc(request_var('username', '', true)), 'password' => request_var('password', '', true), 'password_confirm' => request_var('password_confirm', '', true), 'email' => request_var('email', ''), 'email_confirm' => request_var('email_confirm', ''), 'tz' => request_var('tz', (double) $timezone));
     if ($submit) {
         $error = validate_data($data, array('username' => array(array('string', false, $config['min_username_chars'], $config['max_username_chars']), array('username', '')), 'password' => array(array('string', false, $config['min_password_chars'], $config['max_password_chars'])), 'password_confirm' => array('string', false, $config['min_password_chars'], $config['max_password_chars']), 'email' => array(array('string', false, 6, 60), array('email')), 'email_confirm' => array('string', false, 6, 60), 'tz' => array('num', -14, 14)));
         if (!sizeof($error)) {
             if ($data['password'] != $data['password_confirm']) {
                 $error[] = 'PASSWORD_MATCH_ERROR';
             }
             if ($data['email'] != $data['email_confirm']) {
                 $error[] = 'EMAIL_MATCH_ERROR';
             }
         }
         if (!sizeof($error)) {
             if ($config['activation_required'] == USER_ACTIVATION_SELF || $config['activation_required'] == USER_ACTIVATION_ADMIN) {
                 $data['group_id'] = INACTIVE_USERS;
             } else {
                 $data['group_id'] = REGISTERED_USERS;
             }
             if (user_add($data) !== false) {
                 /**
                  * @todo registration ok
                  */
             } else {
                 /**
                  * @todo registration failed
                  */
             }
         }
     }
 }
开发者ID:pwltt,项目名称:MES-PWLTT-ENVI,代码行数:33,代码来源:ucp_register.php

示例3: phpBBRegister

 private function phpBBRegister($userObj)
 {
     $save_sytem_config = $GLOBALS['config'];
     global $phpbb_root_path;
     global $phpEx;
     $messages = array();
     $phpbb_root_path = $this->_phpbb_src;
     $phpEx = 'php';
     ob_start();
     if (is_readable($this->_phpbb_src . 'config.php') and is_executable($this->_phpbb_src . 'config.php') and is_readable($this->_phpbb_src . 'common.php') and is_executable($this->_phpbb_src . 'common.php') and is_readable($this->_phpbb_src . 'includes/functions_user.php') and is_executable($this->_phpbb_src . 'includes/functions_user.php')) {
         require_once $this->_phpbb_src . 'config.php';
         require_once $this->_phpbb_src . 'common.php';
         require_once $this->_phpbb_src . 'includes/functions_user.php';
     } else {
         $messages[] = $this->lang('noaccessphpbbfiles.session.error');
         $messages[] = $this->_phpbb_src . 'config.php<br/>' . $this->_phpbb_src . 'common.php<br/>' . $this->_phpbb_src . 'includes/functions_user.php<br/>';
         return $messages;
     }
     if (!validate_username($userObj->u_login)) {
         $user_row = array('username' => $userObj->u_login, 'user_password' => phpbb_hash($userObj->u_pass), 'user_email' => $userObj->u_email, 'group_id' => 7, 'user_timezone' => 0.0, 'user_dst' => 0, 'user_lang' => 'ru', 'user_type' => 0, 'user_actkey' => '', 'user_dateformat' => '|d M Y|, H:i', 'user_style' => 1, 'user_regdate' => time());
         $lid = user_add($user_row);
         if (!$lid) {
             $messages[] = $this->lang('cannotadduser.session.error');
         }
     } else {
         $messages[] = $this->lang('loginallreadyexists.session.error');
     }
     ob_end_clean();
     $GLOBALS['config'] = $save_sytem_config;
     if (count($messages)) {
         return $messages;
     } else {
         return false;
     }
 }
开发者ID:ValenokPC,项目名称:tabernacms,代码行数:35,代码来源:registerphpbb.php

示例4: bots

    /**
     * Reset all bots
     */
    function bots($error)
    {
        global $config, $db;
        if (isset($_POST['yes'])) {
            $sql = 'SELECT group_id, group_colour
				FROM ' . GROUPS_TABLE . "\n\t\t\t\tWHERE group_name = 'BOTS'";
            $result = $db->sql_query($sql);
            $group_id = (int) $db->sql_fetchfield('group_id', false, $result);
            $group_colour = $db->sql_fetchfield('group_colour', 0, $result);
            $db->sql_freeresult($result);
            if (!$group_id) {
                // If we reach this point then something has gone very wrong
                $error[] = 'NO_BOT_GROUP';
                return $error;
            } else {
                if (!function_exists('user_add')) {
                    include PHPBB_ROOT_PATH . 'includes/functions_user.' . PHP_EXT;
                }
                // Remove existing bots
                $uids = array();
                $sql = 'SELECT user_id FROM ' . BOTS_TABLE;
                $result = $db->sql_query($sql);
                while ($row = $db->sql_fetchrow($result)) {
                    $uids[] = $row['user_id'];
                }
                $db->sql_freeresult($result);
                if (!empty($uids)) {
                    // Remove all the bots
                    foreach ($uids as $uid) {
                        user_delete('remove', $uid);
                    }
                    // Clear out the bots table
                    $db->sql_query('DELETE FROM ' . BOTS_TABLE);
                }
                // Add the bots
                foreach ($this->db_cleaner->data->bots as $bot_name => $bot_ary) {
                    /* Clean the users table of any bots matching this...
                     * this is an issue if a default bot was removed from the bots group. */
                    $username_clean = utf8_clean_string($bot_name);
                    if (empty($username_clean)) {
                        // This shouldn't happen but we should handle it anyway...
                        continue;
                    }
                    $sql = 'DELETE FROM ' . USERS_TABLE . ' WHERE username_clean = \'' . $db->sql_escape($username_clean) . '\'';
                    $db->sql_query($sql);
                    // `$bot_ary` can be false, if a bot was removed in a certain phpBB version
                    if ($bot_ary === false) {
                        continue;
                    }
                    $user_row = array('user_type' => USER_IGNORE, 'group_id' => $group_id, 'username' => $bot_name, 'user_regdate' => time(), 'user_password' => '', 'user_colour' => $group_colour, 'user_email' => '', 'user_lang' => $config['default_lang'], 'user_style' => 1, 'user_timezone' => 0, 'user_dateformat' => $config['default_dateformat'], 'user_allow_massemail' => 0);
                    $user_id = user_add($user_row);
                    if ($user_id) {
                        $sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $db->sql_build_array('INSERT', array('bot_active' => 1, 'bot_name' => (string) $bot_name, 'user_id' => (int) $user_id, 'bot_agent' => (string) $bot_ary[0], 'bot_ip' => (string) $bot_ary[1]));
                        $result = $db->sql_query($sql);
                    }
                }
            }
        }
    }
开发者ID:melvingb,项目名称:phpbb3.1-STK,代码行数:62,代码来源:database_cleaner_controller.php

示例5: addphpBBuser

function addphpBBuser($login, $pwd, $mail, $lang)
{
    $cryptpass = phpbb_hash($pwd);
    $sql = "SELECT * FROM `" . $_SESSION['Application_host'] . "`.`forum_users` WHERE `username` = '" . $login . "'";
    $dataset_exists = getDataFromSQL($sql, __FILE__, "function", __FUNCTION__);
    if ($dataset_exists['Count'] == 0) {
        $new_user_array = array('username' => stripslashes($login), 'user_password' => $cryptpass, 'user_email' => $mail, 'group_id' => 7, 'user_type' => 0, 'user_lang' => strtolower($lang));
        $phpBBid = user_add($new_user_array);
    }
}
开发者ID:GrottoCenter,项目名称:GrottoCenter,代码行数:10,代码来源:phpBBinterface.php

示例6: run_tool

 /**
  * Run Tool
  *
  * Does the actual stuff we want the tool to do after submission
  */
 function run_tool(&$error)
 {
     global $config, $user;
     $user->add_lang(array('acp/groups', 'ucp'));
     if (!check_form_key('add_user')) {
         $error[] = 'FORM_INVALID';
         return;
     }
     // Try to manually determine the timezone and adjust the dst if the server date/time complies with the default setting +/- 1
     $timezone = date('Z') / 3600;
     $is_dst = date('I');
     if ($config['board_timezone'] == $timezone || $config['board_timezone'] == $timezone - 1) {
         $timezone = $is_dst ? $timezone - 1 : $timezone;
         if (!isset($user->lang['tz_zones'][(string) $timezone])) {
             $timezone = $config['board_timezone'];
         }
     } else {
         $is_dst = $config['board_dst'];
         $timezone = $config['board_timezone'];
     }
     // Collect the user data
     $data = array('username' => utf8_normalize_nfc(request_var('username', '', true)), 'new_password' => request_var('new_password', '', true), 'password_confirm' => request_var('password_confirm', '', true), 'email' => strtolower(request_var('email', '')), 'email_confirm' => strtolower(request_var('email_confirm', '')), 'lang' => basename(request_var('lang', $user->lang_name)), 'tz' => request_var('tz', (double) $timezone));
     // Check vars
     $this->validate_data($data, $error);
     // Something went wrong
     if (!empty($error)) {
         return false;
     }
     // Collect the groups data
     $groups = array('default' => request_var('defaultgroup', 0), 'groups' => request_var('usergroups', array(0)), 'leaders' => request_var('groupleader', array(0)));
     // Register the user
     $user_row = array('username' => $data['username'], 'user_password' => phpbb_hash($data['new_password']), 'user_email' => $data['email'], 'group_id' => (int) $groups['default'], 'user_timezone' => (double) $data['tz'], 'user_dst' => $is_dst, 'user_lang' => $data['lang'], 'user_type' => USER_NORMAL, 'user_actkey' => '', 'user_ip' => $user->ip, 'user_regdate' => time(), 'user_inactive_reason' => 0, 'user_inactive_time' => 0);
     $user_id = user_add($user_row, false);
     // Remove the default group from the groups array. Keeping it here causes an error
     if (in_array($groups['default'], $groups['groups'])) {
         foreach ($groups['groups'] as $group_key => $group_id) {
             if ($group_id == $groups['default']) {
                 unset($groups['groups'][$group_key]);
                 break;
             }
         }
     }
     // This should not happen, because the required variables are listed above...
     if ($user_id === false) {
         trigger_error('NO_USER', E_USER_ERROR);
     }
     // Add the user to the selected groups
     $this->add_groups($user_id, $groups, $error);
     // Last check for errors
     if (!empty($error)) {
         return false;
     }
     // And done
     trigger_error('USER_ADDED');
 }
开发者ID:napus,项目名称:support-toolkit,代码行数:60,代码来源:add_user.php

示例7: process_form

function process_form()
{
    $page = isset($_POST["page"]) ? $_POST["page"] : "";
    $processed = true;
    switch ($page) {
        case FORM_LOGIN:
            require 'inc/process/login.php';
            sign_in();
            break;
        case FORM_CUSTOMER_NEW:
            require 'inc/process/customer.php';
            customer_add();
            break;
        case FORM_CUSTOMER_EDIT:
            require 'inc/process/customer.php';
            customer_edit();
            break;
        case FORM_PURCHASE_NEW:
            require 'inc/process/purchase.php';
            purchase_add();
            break;
        case FORM_PURCHASE_EDIT:
            require 'inc/process/purchase.php';
            purchase_edit();
            break;
        case "sell_new":
            require 'inc/process/sell.php';
            sell_add();
            break;
        case "sell_edit":
            require 'inc/process/sell.php';
            sell_edit();
            break;
        case "store_edit":
            require 'inc/process/store.php';
            store_edit();
            break;
        case "user_new":
            require 'inc/process/user.php';
            user_add();
            break;
        case "user_edit":
            require 'inc/process/user.php';
            user_edit();
            break;
        case FORM_LOT_NEW:
            require 'inc/process/lot.php';
            lot_add();
            break;
        default:
            $processed = false;
    }
    return $processed;
}
开发者ID:BackupTheBerlios,项目名称:rinventory-svn,代码行数:54,代码来源:form.php

示例8: telek_hook_recvsms_intercept

function telek_hook_recvsms_intercept($sms_datetime, $sms_sender, $message, $sms_receiver)
{
    //$ret = array();
    $ps = explode(" ", $message, 2);
    $ikut = strtoupper($ps[0]);
    //$pesan = '';
    $hooked = false;
    if ($ikut == 'DAFTAR') {
        $pecah = preg_split("/#/", $ps[1], null, PREG_SPLIT_NO_EMPTY);
        $c_uid = user_mobile2uid($sms_sender);
        $data = array();
        $data['name'] = trim($pecah[0]);
        $data['username'] = trim($pecah[1]);
        $data['mobile'] = $sms_sender;
        $data['email'] = $data['name'] . "@noreply.org";
        $data['parent_uid'] = 0;
        $data['status'] = 4;
    }
    if ($nama && $nohp && $pengguna) {
        logger_print("*******", 3, "telek");
        logger_print("sms_sender " . $sms_sender, 3, "telek");
        logger_print("message " . $message, 3, "telek");
        logger_print("new message " . $nama, 3, "telek");
        logger_print("sms target user" . $sms_receiver, 3, "telek");
        logger_print("*******", 3, "telek");
        if (($uid = user_mobile2uid($sms_sender)) && $nama) {
            _log("save in inbox u:" . $username . " uid:" . $uid . " dt:" . $sms_datetime . " s:" . $sms_sender . " r:" . $sms_receiver . " m:[" . $nohp . "]", 3, 'telek');
            //recvsms_inbox_add($sms_datetime, $sms_sender, $username, $nama, $sms_receiver);
            //$hooked = true;
            //$status = ($ok ? 'handled' : 'unhandled');
        }
    }
    ////	$ret['uid'] = user_mobile2uid($sms_sender);
    ////	$ret['status'] = TRUE;
    //	$ret['param']['message'] = $ikut . ' ' . $nama .' '. $nohp . ' ' . $pengguna;
    //       $ret['modified'] = TRUE;
    //        $ret['hooked'] = TRUE;
    $ret = user_add($data);
    $ok = $ret['status'] ? TRUE : FALSE;
    if ($ok) {
        echo "okee";
        $items = array('uid' => 1, 'name' => $data['name'], 'mobile' => $data['mobile'], 'email' => $data['email'], 'tags' => $tags);
        if ($c_pid = dba_add(_DB_PREF_ . '_featurePhonebook', $items)) {
            $save_to_group = TRUE;
        } else {
            logger_print('fail to add contact pid:' . $c_pid . ' m:' . $mobile . ' n:' . $name . ' e:' . $email . ' tags:[' . $tags . ']', 3, 'phonebook_add');
        }
    } else {
        echo "gagal";
    }
    return $ret;
}
开发者ID:pr4ka5a,项目名称:telek,代码行数:52,代码来源:fn-telek.php

示例9: deprecated_check

function deprecated_check()
{
    // In 1.5.0b has exists temporary db.users
    if (file_exists(SERVDIR . '/cdata/db.users.php')) {
        $users = file(SERVDIR . '/cdata/db.users.php');
        unset($users[0]);
        foreach ($users as $v) {
            list(, $b) = explode('|', $v, 2);
            $b = unserialize($b);
            if (user_search($b[UDB_NAME]) == false) {
                user_add($b);
            }
        }
    }
}
开发者ID:jasmith152,项目名称:Jackie_Davis,代码行数:15,代码来源:core.php

示例10: add_contact

function add_contact()
{
    /*Проверка прав на выполнение действия*/
    if (!check_rights('add_contact')) {
        //Возвращаем значение функции
        return "У вас нет соответствующих прав";
    }
    //IF
    if (!isset($_POST['name'])) {
        //Возвращаем значение функции
        return show_form_add_contact();
        //ELSE
    } else {
        //Проверка 'name'
        if (preg_match(REGEXP_USERNAME, $_POST['name'])) {
            if (db_easy_count("SELECT `user_id` FROM `phpbb_users` WHERE `username`='" . $_POST['name'] . "'") > 0) {
                $errors[] = ERROR_USERNAME_EXISTS;
            } else {
                $name = $_POST['name'];
            }
        } else {
            $errors[] = ERROR_USERNAME_REQUIREMENT;
        }
        //IF
        if (count($errors) == 0) {
            //Определяем переменную
            /*$user_data=array(	'username'=>$name.,
            			'group_id'=>'1774',
            			'user_lang'=>'ru',
            			'user_type'=>0,
            			'user_regdate'=>time()
            		);*/
            $user_data = array('username' => $name, 'user_password' => phpbb_hash('вава'), 'user_email' => '', 'group_id' => '1774', 'user_lang' => 'ru', 'user_type' => 0, 'user_regdate' => time(), 'point_id' => 1);
            /*Добавляем пользователя, использую функцию PHPBB*/
            $user_id = user_add($user_data);
            //Отправляем HTTP запрос
            header("location: /manager.php?action=edit_contact&contact={$user_id}");
            //ELSE
        } else {
            //Возвращаем значение функции
            return show_form_add_contact($_POST, $errors);
        }
    }
}
开发者ID:jsib,项目名称:intranet,代码行数:44,代码来源:add_contact.php

示例11: reg_save

function reg_save()
{
    global $smarty;
    $email = @$_POST['email'];
    $pass = @$_POST['loginpass'];
    $pass2 = @$_POST['loginpass2'];
    if ($pass == '' || $email == '') {
        reg_main(_('Please enter email and password'));
        return false;
    }
    if (strpos($email, '@') == false || strpos($email, '.') == false) {
        reg_main(_('Invalid email address'));
        return false;
    }
    if ($pass != $pass2) {
        reg_main(_('Password does not match'));
        return false;
    }
    if (recaptcha_verify() !== true) {
        reg_main(_('The CAPTCHA you enter is not correct'));
        return false;
    }
    if (INVITECODE_ENABLED == 1 && reg_checkinvite(@$_POST['invitecode']) == false) {
        reg_main(_('The invite code is invalid or have been used'));
        return false;
    }
    $ret = user_add($email, $pass);
    if ($ret !== true) {
        reg_main("<p>{$ret}</p>" . _('<p>Register fail, please contact us for help if you need.</p>'));
        return false;
    }
    $user = user_get($email);
    if (INVITECODE_ENABLED == 1) {
        invite_use($_POST['invitecode'], $user['id']);
    }
    user_online($email);
    $smarty->assign('tip_title', _('Register successed'));
    $smarty->assign('tip_msg', _('You have registerd successfully'));
    $smarty->assign('redirect_url', 'account.php');
    $smarty->display('tip.html');
}
开发者ID:iwarsong,项目名称:seavpn,代码行数:41,代码来源:reg.php

示例12: insertUserRow

function insertUserRow($username, $email = "")
{
    global $db, $openid;
    $group_id = 2;
    $sql = "SELECT *\n            FROM " . GROUPS_TABLE . "\n            WHERE group_name = 'REGISTERED' ";
    if (!($result = $db->sql_query($sql))) {
        message_die(GENERAL_ERROR, 'Error in obtaining userdata', '', __LINE__, __FILE__, $sql);
    }
    if ($row = $db->sql_fetchrow($result)) {
        $group_id = $row['group_id'];
    }
    // add user
    $user_row = array('username' => $username, 'user_password' => '', 'user_email' => empty($email) ? 'openid@mailinator.com' : $email, 'group_id' => $group_id, 'user_timezone' => '0', 'user_dst' => '0', 'user_lang' => 'en', 'user_type' => '0', 'user_actkey' => '', 'user_ip' => $_SERVER['REMOTE_ADDR'], 'user_inactive_reason' => '0', 'user_website' => $openid, 'user_inactive_time' => '0');
    $user_id = user_add($user_row);
    $sql = "UPDATE " . USERS_TABLE . " SET user_openid ='" . $openid . "'\n    WHERE user_id = {$user_id}";
    if (!($result = $db->sql_query($sql))) {
        message_die(GENERAL_ERROR, 'Error in obtaining userdata', '', __LINE__, __FILE__, $sql);
    } else {
        return $user_id;
    }
}
开发者ID:phpbbopenid,项目名称:openid,代码行数:21,代码来源:new_openid_user.php

示例13: add_bots

/**
* Add the search bots into the database
* This code should be used in execute_last if the source database did not have bots
* If you are converting bots this function should not be called
* @todo We might want to look at sharing the bot list between the install code and this code for consistency
*/
function add_bots($bots)
{
    global $db, $config;
    $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . " WHERE group_name = 'BOTS'";
    $result = $db->sql_query($sql);
    $group_id = (int) $db->sql_fetchfield('group_id', false, $result);
    $db->sql_freeresult($result);
    $db->sql_query('TRUNCATE TABLE ' . BOTS_TABLE);
    if (!$group_id) {
        add_default_groups();
        $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . " WHERE group_name = 'BOTS'";
        $result = $db->sql_query($sql);
        $group_id = (int) $db->sql_fetchfield('group_id', false, $result);
        $db->sql_freeresult($result);
    }
    foreach ($bots as $bot_name => $bot_ary) {
        $user_row = array('user_type' => USER_IGNORE, 'group_id' => $group_id, 'username' => $bot_name, 'user_regdate' => time(), 'user_password' => '', 'user_colour' => '9E8DA7', 'user_email' => '', 'user_lang' => $config['default_lang'], 'user_style' => 1, 'user_timezone' => 'UTC', 'user_allow_massemail' => 0);
        $user_id = user_add($user_row);
        if ($user_id) {
            $sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $db->sql_build_array('INSERT', array('bot_active' => 1, 'bot_name' => $bot_name, 'user_id' => $user_id, 'bot_agent' => $bot_ary[0], 'bot_ip' => $bot_ary[1]));
            $db->sql_query($sql);
        }
    }
}
开发者ID:MrAdder,项目名称:phpbb,代码行数:30,代码来源:repair_bots.php

示例14: elseif

                if (!$email) {
                    $error[] = $_CLASS['core_user']->get_lang('EMAIL_ERROR');
                } elseif (!check_email($email)) {
                    $error[] = $_CLASS['core_user']->get_lang('EMAIL_INVALID');
                }
                if (!$tz || !in_array($tz, tz_array())) {
                    $tz = null;
                }
                if (empty($error)) {
                    $password = encode_password($password, $_CORE_CONFIG['user']['password_encoding']);
                    if (!$password) {
                        //do some admin contact thing here
                        die('Try again later');
                    }
                    $data = array('username' => (string) $username, 'user_email' => (string) $email, 'user_group' => (int) $coppa ? 3 : 2, 'user_reg_date' => (int) $_CLASS['core_user']->time, 'user_timezone' => $tz, 'user_password' => (string) $password, 'user_password_encoding' => (string) $_CORE_CONFIG['user']['password_encoding'], 'user_lang' => $lang == $_CORE_CONFIG['global']['default_lang'] ? null : $lang, 'user_type' => USER_NORMAL, 'user_status' => STATUS_ACTIVE, 'user_act_key' => null, 'user_ip' => '');
                    user_add($data);
                    set_core_config('user', 'newest_user_id', $data['user_id'], false);
                    set_core_config('user', 'newest_username', $data['username'], false);
                    set_core_config('user', 'total_users', $_CORE_CONFIG['user']['total_users'] + 1);
                    trigger_error('USER_ADDED');
                }
            }
            $_CLASS['core_template']->assign_array(array('COPPA' => isset($coppa) ? $coppa : false, 'EMAIL' => isset($email) ? $email : '', 'ERROR' => empty($error) ? false : implode('<br />', $error), 'PASSWORD' => isset($password) ? $password : '', 'USERNAME' => isset($username) ? $username : '', 'SELECT_TZ' => select_tz(isset($tz) ? $tz : $_CORE_CONFIG['global']['default_timezone']), 'S_ACTION' => generate_link('users&amp;mode=add_user', array('admin' => true))));
            $_CLASS['core_display']->display(false, 'admin/users/add.html');
            break;
        case 'bots':
            if ($id && isset($_REQUEST['option'])) {
                require_once $site_file_root . 'includes/functions_user.php';
                $sql = 'SELECT user_id, user_type, user_status
					FROM ' . USERS_TABLE . ' 
					WHERE user_id = ' . $id;
开发者ID:BackupTheBerlios,项目名称:viperals-svn,代码行数:31,代码来源:users.php

示例15: login

 /**
  * {@inheritdoc}
  */
 public function login($username, $password)
 {
     ini_set('display_errors', 'On');
     error_reporting(E_ALL | E_STRICT);
     $sqlByUsername = 'SELECT user_id, username, user_password, user_passchg, user_email, user_type, user_login_attempts FROM ' . USERS_TABLE . ' WHERE username = \'%s\'';
     $sqlByID = 'SELECT user_id, username, user_password, user_passchg, user_email, user_type, user_login_attempts FROM ' . USERS_TABLE . ' WHERE user_id = %d';
     $password = trim($password);
     // Do not allow empty passwords.
     if (!$password) {
         return ['status' => LOGIN_ERROR_PASSWORD, 'error_msg' => 'NO_PASSWORD_SUPPLIED', 'user_row' => ['user_id' => ANONYMOUS]];
     }
     // Do not allow empty usernames.
     if (!$username) {
         return ['status' => LOGIN_ERROR_USERNAME, 'error_msg' => 'LOGIN_ERROR_USERNAME', 'user_row' => ['user_id' => ANONYMOUS]];
     }
     // Do not allow the default admin to log in.
     if ($username == 'admin') {
         return ['status' => LOGIN_ERROR_USERNAME, 'error_msg' => 'LOGIN_ERROR_ADMIN_USERNAME', 'user_row' => ['user_id' => ANONYMOUS]];
     }
     // Find a phpbb user incase someone is trying to login with their
     // character name. Use the user's email address instead to login.
     // This is needed in order to use the administration panel.
     $sth = $this->db->sql_query(sprintf($sqlByUsername, $this->db->sql_escape($username)));
     $phpbb_user = $this->db->sql_fetchrow($sth);
     $this->db->sql_freeresult($sth);
     if ($phpbb_user) {
         $username = $phpbb_user['user_email'];
     }
     // Get the user details from seat.
     $user = $this->authenticateUser($username, $password);
     if (is_integer($user)) {
         switch ($user) {
             case 1001:
                 $error = 'LOGIN_ERROR_INVALID_CONNECTION';
                 break;
             case 1002:
                 $error = 'LOGIN_ERROR_INVALID_CREDENTIALS';
                 break;
             case 1003:
                 $error = 'LOGIN_ERROR_NO_MAIN_CHARACTER_SET';
                 break;
             case 1004:
                 $error = 'LOGIN_ERROR_MAIN_CHARACTER_UNAUTHORIZED';
                 break;
             default:
                 $error = 'LOGIN_ERROR_UNKNOWN';
                 break;
         }
         return ['status' => LOGIN_ERROR_EXTERNAL_AUTH, 'error_msg' => $error, 'user_row' => ['user_id' => ANONYMOUS]];
     }
     // Return the phpbb user if it was already found earlier.
     if ($phpbb_user) {
         return ['status' => LOGIN_SUCCESS, 'error_msg' => false, 'user_row' => $phpbb_user];
     }
     // Find a phpbb user using the seat user's character name.
     $sth = $this->db->sql_query(sprintf($sqlByUsername, $this->db->sql_escape($user['characterName'])));
     $phpbb_user = $this->db->sql_fetchrow($sth);
     $this->db->sql_freeresult($sth);
     if ($phpbb_user) {
         return ['status' => LOGIN_SUCCESS, 'error_msg' => false, 'user_row' => $phpbb_user];
     }
     // Create a new phpbb user if one wasn't found.
     $result = user_add(['username' => $user['characterName'], 'user_password' => phpbb_hash(openssl_random_pseudo_bytes(256)), 'user_email' => $user['userEmail'], 'group_id' => in_array('Superuser', $user['userRoles']) ? 5 : 2, 'user_type' => in_array('Superuser', $user['userRoles']) ? 3 : USER_NORMAL]);
     // Return the newly created user.
     $sth = $this->db->sql_query(sprintf($sqlByID, $this->db->sql_escape($result)));
     $phpbb_user = $this->db->sql_fetchrow($sth);
     $this->db->sql_freeresult($sth);
     return ['status' => LOGIN_SUCCESS, 'error_msg' => false, 'user_row' => $phpbb_user];
 }
开发者ID:msims04,项目名称:eveseat-addon-auth,代码行数:72,代码来源:seat.php


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