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


PHP UserModel::addUser方法代码示例

本文整理汇总了PHP中UserModel::addUser方法的典型用法代码示例。如果您正苦于以下问题:PHP UserModel::addUser方法的具体用法?PHP UserModel::addUser怎么用?PHP UserModel::addUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserModel的用法示例。


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

示例1: testAddInValidateUsers

 /**
  * @dataProvider getInValidateUsers
  */
 public function testAddInValidateUsers($phone, $name, $address, $password, $repassword, $img, $downlineID)
 {
     $data['phone'] = $phone;
     $data['nickname'] = $name;
     $data['address'] = $address;
     $data['password'] = $password;
     $data['repassword'] = $repassword;
     $data['img'] = $img;
     $data['downline_id'] = $downlineID;
     $table = new UserModel();
     $ret = $table->addUser($data);
     if (empty($data['phone'])) {
         $this->assertTrue('手机号码必须填写' == $table->getError()['phone']);
     } else {
         if (empty($data['nickname'])) {
             $this->assertTrue('昵称必须填写' == $table->getError()['nickname']);
         } else {
             if ($data['nickname'] == '手机号重复') {
                 $this->assertTrue('手机号码已被注册' == $table->getError()['phone']);
             } else {
                 if ($data['nickname'] == '密码不一致') {
                     $this->assertTrue('两次输入密码不一致' == $table->getError()['repassword']);
                 } else {
                     $this->assertTrue(is_numeric($ret));
                 }
             }
         }
     }
 }
开发者ID:chen8840,项目名称:LMJ-s-project,代码行数:32,代码来源:UserModelTest.php

示例2: login

 public function login()
 {
     //header('content-type:text/html;charset=utf-8');
     $qq = new QQLogin(self::QQAppid, self::QQCallback, self::QQAppkey);
     $openId = $qq->getOpenId();
     $user = new UserModel();
     if ($row = $user->getUserByOpenId($openId)) {
         //echo 123;
         $_SESSION['qq'] = $row;
         header('location:' . $qq->state);
     } else {
         //echo 456;
         //var_dump($qq->state);
         $arr = $qq->getUserInfo();
         //var_dump($arr);
         $data['openId'] = $openId;
         $data['userName'] = Data::filter($arr['nickname'], 9);
         $data['face'] = $arr['figureurl_qq_1'];
         $data['source'] = 'QQ';
         //var_dump($data);
         $row = $user->addUser($data);
         //var_dump($row);
         //var_dump($qq->state);
         if ($row) {
             $array = $user->getUserByOpenId($openId);
             $_SESSION['qq'] = $array;
             header('location:' . $qq->state);
         } else {
             E('对不起,亲,注册失败了');
         }
     }
 }
开发者ID:Jnnock,项目名称:myyyk,代码行数:32,代码来源:QQLoginCtrl.class.php

示例3: registerAction

 /**
  * 注册
  */
 public function registerAction()
 {
     $username = trim($this->getRequest()->getPost('username', ''));
     $password = trim($this->getRequest()->getPost('password', ''));
     $email = trim($this->getRequest()->getPost('email', ''));
     //校验参数是否为空
     if (empty($username) || empty($password) || empty($email)) {
         $this->getView->assign('message', '参数不能为空');
         $this->getView->render('/user/index.phtml');
     }
     $userModel = new UserModel();
     //校验用户名是否存在
     $isExistUsername = $userModel->getUserByUsername($username);
     if ($isExistUsername) {
         $this->getView->assign('message', '用户名已存在');
         $this->getView->render('/user/index.phtml');
     }
     //校验邮箱是否存在
     $isExistEmail = $userModel->getUserByEmail($email);
     if ($isExistEmail) {
         $this->getView()->assign('message', '邮箱已存在');
         $this->getView()->render('/user/index.phtml');
     }
     //进行注册
     $flag = $userModel->addUser($username, $password, $email);
     //如果成功,登录返回首页
     if ($flag) {
         Yaf_Session::getInstance()->set('userId', $flag);
         $this->getView()->render('/index/index.phtml');
     } else {
         $this->getView()->assign('message', '注册失败');
         $this->getView()->render('/user/index.phtml');
     }
 }
开发者ID:ancongcong,项目名称:todo_project,代码行数:37,代码来源:User.php

示例4: addUser

 private function addUser()
 {
     $data = array('name' => $_POST['name'], 'email' => $_POST['email'], 'type' => $_POST['type']);
     $model = new UserModel();
     $model->addUser($data);
     show_json();
 }
开发者ID:chenyongze,项目名称:m3d,代码行数:7,代码来源:UserAction.class.php

示例5: register

 public static function register()
 {
     $fields = self::get_fields();
     if (!self::validation($fields)) {
         return false;
     }
     if (!UserModel::addUser($fields)) {
         return false;
     }
     return true;
 }
开发者ID:heyjohnnyfunt,项目名称:sendashare,代码行数:11,代码来源:RegistrationModel.php

示例6: testAddValidateUser

 /**
  * @dataProvider getValidateUsers
  */
 public function testAddValidateUser($phone, $name, $address, $password, $repassword, $img, $downlineID)
 {
     $data['phone'] = $phone;
     $data['nickname'] = $name;
     $data['address'] = $address;
     $data['password'] = $password;
     $data['repassword'] = $repassword;
     $data['img'] = $img;
     $data['downline_id'] = $downlineID;
     $table = new UserModel();
     $ret = $table->addUser($data);
     $this->assertTrue(is_numeric($ret));
 }
开发者ID:chen8840,项目名称:LMJ-s-project,代码行数:16,代码来源:LetterListModelTest.php

示例7: ActionRegistration

 public static function ActionRegistration()
 {
     if (isset($_POST['login']) and isset($_POST['email']) and isset($_POST['password']) and isset($_POST['passwordConfirm']) and isset($_POST['g-recaptcha-response'])) {
         $login = Validator::clear($_POST['login']);
         $email = $_POST['email'];
         $password = $_POST['password'];
         $passwordConfirm = $_POST['passwordConfirm'];
         $userId = UserModel::addUser($login, $email, $password);
         $path = root . '/application/data/users/' . $userId;
         mkdir($path);
         copy(root . '/images/avatar.jpg', $path . '/avatar.jpg');
         UserModel::setUser($userId, $login, 1);
         exit(json_encode(['status' => 'ok']));
     }
     exit(json_encode(['status' => 'false']));
 }
开发者ID:yasch-kub,项目名称:auroracing.com,代码行数:16,代码来源:UserController.php

示例8: UserModel

 $objUser = new UserModel(DB::GetDBH());
 // тест получения данных по ID
 //print_r ( $objUser->selectUserByID('30')->toArray() );
 // получаем структуру таблицы пользователей, для определения ID и доступных полей
 $arr = $objUser->getTableStructure()->toArray();
 echo '<br>' . "Структура таблицы" . '<br>';
 print_r($arr);
 echo '<br>';
 echo '<br>' . "тест создания пользователей" . '<br>';
 try {
     for ($i = 0; $i < 20; $i++) {
         $userArr = array();
         $userArr['login'] = "user" . $i;
         $userArr['nick'] = "userNick" . $i;
         $userArr['email'] = "user" . $i . "@mail.ru";
         echo "Новый пользователь создан, ID = " . $objUser->addUser($userArr) . '<br>';
     }
 } catch (Exception $e) {
     echo $e->getMessage() . '<br>';
 }
 echo '<br>' . "тест получения списка пользователей" . '<br>';
 try {
     foreach ($objUser->selectUsers()->toArray() as $userArray) {
         foreach ($userArray as $key => $val) {
             echo " [" . $key . " = " . $val . "] ";
         }
         echo '<br>';
     }
 } catch (Exception $e) {
     echo $e->getMessage() . '<br>';
 }
开发者ID:freecod,项目名称:UserList,代码行数:31,代码来源:tests.php

示例9: upgradeDatabaseVersion20

/**
 * Upgrades a Version 19 version of the Yioop! database to a Version 20 version
 * This is a major upgrade as the user table have changed. This also acts
 * as a cumulative since version 0.98. It involves a web form that has only
 * been localized to English
 * @param object $db datasource to use to upgrade
 */
function upgradeDatabaseVersion20(&$db)
{
    if (!isset($_REQUEST['v20step'])) {
        $_REQUEST['v20step'] = 1;
    }
    $upgrade_check_file = WORK_DIRECTORY . "/v20check.txt";
    if (!file_exists($upgrade_check_file)) {
        $upgrade_password = substr(sha1(microtime() . AUTH_KEY), 0, 8);
        file_put_contents($upgrade_check_file, $upgrade_password);
    } else {
        $v20check = trim(file_get_contents($upgrade_check_file));
        if (isset($_REQUEST['v20step']) && $_REQUEST['v20step'] == 2 && (!isset($_REQUEST['upgrade_code']) || $v20check != trim($_REQUEST['upgrade_code']))) {
            $_REQUEST['v20step'] = 1;
            $data['SCRIPT'] = "doMessage('<h1 class=\"red\" >" . "v20check.txt not typed in correctly!</h1>')";
        }
    }
    switch ($_REQUEST['v20step']) {
        case "2":
            /** Get base class for profile_model.php*/
            require_once BASE_DIR . "/models/model.php";
            /** For ProfileModel::createDatabaseTables method */
            require_once BASE_DIR . "/models/profile_model.php";
            /** For UserModel::addUser method */
            require_once BASE_DIR . "/models/user_model.php";
            $profile_model = new ProfileModel(DB_NAME, false);
            $profile_model->db = $db;
            $save_tables = array("ACTIVE_FETCHER", "CURRENT_WEB_INDEX", "FEED_ITEM", "MACHINE", "MEDIA_SOURCE", "SUBSEARCH", "VERSION");
            $dbinfo = array("DBMS" => DBMS, "DB_HOST" => DB_HOST, "DB_USER" => DB_USER, "DB_PASSWORD" => DB_PASSWORD, "DB_NAME" => DB_NAME);
            $creation_time = microTimestamp();
            $profile = $profile_model->getProfile(WORK_DIRECTORY);
            $new_profile = $profile;
            $new_profile['AUTHENTICATION_MODE'] = NORMAL_AUTHENTICATION;
            $new_profile['FIAT_SHAMIR_MODULUS'] = generateFiatShamirModulus();
            $new_profile['MAIL_SERVER'] = "";
            $new_profile['MAIL_PORT'] = "";
            $new_profile['MAIL_USERNAME'] = "";
            $new_profile['MAIL_PASSWORD'] = "";
            $new_profile['MAIL_SECURITY'] = "";
            $new_profile['REGISTRATION_TYPE'] = 'disable_registration';
            $new_profile['USE_MAIL_PHP'] = true;
            $new_profile['WORD_SUGGEST'] = true;
            $profile_model->updateProfile(WORK_DIRECTORY, $new_profile, $profile);
            //get current users (assume can fit in memory and doesn't take long)
            $users = array();
            $sha1_of_upgrade_code = bchexdec(sha1($v20check));
            $temp = bcpow($sha1_of_upgrade_code . '', '2');
            $zkp_password = bcmod($temp, $new_profile['FIAT_SHAMIR_MODULUS']);
            $user_tables_sql = array("SELECT USER_NAME FROM USER", "SELECT USER_NAME, FIRST_NAME, LAST_NAME, EMAIL FROM USERS");
            $i = 0;
            foreach ($user_tables_sql as $sql) {
                $result = $db->execute($sql);
                if ($result) {
                    while ($users[$i] = $db->fetchArray($result)) {
                        $setup_user_fields = array();
                        if ($users[$i]["USER_NAME"] == "root" || $users[$i]["USER_NAME"] == "public") {
                            continue;
                        }
                        $users[$i]["FIRST_NAME"] = isset($users[$i]["FIRST_NAME"]) ? $users[$i]["FIRST_NAME"] : "FIRST_{$i}";
                        $users[$i]["LAST_NAME"] = isset($users[$i]["LAST_NAME"]) ? $users[$i]["LAST_NAME"] : "LAST_{$i}";
                        $users[$i]["EMAIL"] = isset($users[$i]["EMAIL"]) ? $users[$i]["EMAIL"] : "user{$i}@dev.null";
                        /* although not by default using zkp set up so
                              accounts would work on switch
                           */
                        $users[$i]["PASSWORD"] = $v20check;
                        $users[$i]["STATUS"] = INACTIVE_STATUS;
                        $users[$i]["CREATION_TIME"] = $creation_time;
                        $users[$i]["UPS"] = 0;
                        $users[$i]["DOWNS"] = 0;
                        $users[$i]["ZKP_PASSWORD"] = $zkp_password;
                        $i++;
                    }
                    unset($users[$i]);
                    $result = NULL;
                }
            }
            $dbinfo = array("DBMS" => DBMS, "DB_HOST" => DB_HOST, "DB_USER" => DB_USER, "DB_PASSWORD" => DB_PASSWORD, "DB_NAME" => DB_NAME);
            $profile_model->initializeSql($db, $dbinfo);
            $database_tables = array_diff(array_keys($profile_model->create_statements), $save_tables);
            $database_tables = array_merge($database_tables, array("BLOG_DESCRIPTION", "USER_OLD", "ACCESS"));
            foreach ($database_tables as $table) {
                if (!in_array($table, $save_tables)) {
                    $db->execute("DROP TABLE " . $table);
                }
            }
            if ($profile_model->migrateDatabaseIfNecessary($dbinfo, $save_tables)) {
                $user_model = new UserModel(DB_NAME, false);
                $user_model->db = $db;
                foreach ($users as $user) {
                    $user_model->addUser($user["USER_NAME"], $user["PASSWORD"], $user["FIRST_NAME"], $user["LAST_NAME"], $user["EMAIL"], $user["STATUS"], $user["ZKP_PASSWORD"]);
                }
                $user = array();
                $user['USER_ID'] = ROOT_ID;
                $user['PASSWORD'] = $v20check;
//.........这里部分代码省略.........
开发者ID:yakar,项目名称:yioop,代码行数:101,代码来源:upgrade_functions.php

示例10: UserModel

/** For UserModel::addUser method*/
require_once BASE_DIR . "/models/user_model.php";
/** To create groups that can add users to */
require_once BASE_DIR . "/models/group_model.php";
/** To create roles that can add users to */
require_once BASE_DIR . "/models/role_model.php";
/** To create a set of crawl mixes */
require_once BASE_DIR . "/models/crawl_model.php";
/** For crawlHash function */
require_once BASE_DIR . "/lib/utility.php";
$user_model = new UserModel();
//Add lots of users
$user_ids = array();
for ($i = 0; $i < 500; $i++) {
    echo "Adding User {$i}\n";
    $id = $user_model->addUser("User{$i}", "test", "First{$i}", "Last{$i}", "user{$i}@email.net", ACTIVE_STATUS);
    if ($id === false) {
        echo "Problem inserting user into DB, aborting...\n";
        exit(1);
    }
    $user_ids[$i] = $id;
}
// add lots of groups
$group_model = new GroupModel();
$group_ids = array();
for ($i = 0; $i < 100; $i++) {
    echo "Creating Group {$i}\n";
    $group_ids[$i] = $group_model->addGroup("Group{$i}", $user_ids[$i], PUBLIC_JOIN, GROUP_READ_WRITE);
}
// add lots of users to group 1
for ($i = 0; $i < 100; $i++) {
开发者ID:yakar,项目名称:yioop,代码行数:31,代码来源:many_user_experiment.php


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