コード例 #1
0
function prefetch_account_func()
{
    global $db;
    $user = tt_get_user_by_email(trim($_POST['email']));
    if (empty($user['user_id'])) {
        trigger_error("Can't find the user");
    }
    $result = array('result' => new xmlrpcval(true, 'boolean'), 'result_text' => new xmlrpcval('', 'base64'), 'user_id' => new xmlrpcval($user['user_id'], 'string'), 'login_name' => new xmlrpcval(basic_clean($user['username']), 'base64'), 'display_name' => new xmlrpcval(basic_clean($user['username']), 'base64'), 'avatar' => new xmlrpcval(get_user_avatar_url($user['user_avatar'], $user['user_avatar_type']), 'string'));
    return new xmlrpcresp(new xmlrpcval($result, 'struct'));
}
コード例 #2
0
function sign_in_func()
{
    global $config, $mobiquo_config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx, $user_info, $register;
    if ($mobiquo_config['native_register'] == 0) {
        trigger_error('UCP_REGISTER_DISABLE');
    }
    if ($config['require_activation'] == USER_ACTIVATION_DISABLE) {
        trigger_error('UCP_REGISTER_DISABLE');
    }
    include $phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx;
    $user_lang = request_var('lang', $user->lang_name);
    //$cp = new custom_profile();
    $verify_result = false;
    $error = array();
    $is_dst = $config['board_dst'];
    $timezone = $config['board_timezone'];
    $token = trim($_POST['token']);
    $code = trim($_POST['code']);
    $username = trim($_POST['username']);
    $password = trim($_POST['password']);
    $post_email = trim($_POST['email']);
    $status = '';
    if (isset($token) && isset($code)) {
        $return = tt_register_verify($token, $code);
        if ($return->result && !empty($return->email)) {
            $email = $return->email;
            if (!empty($post_email) && $post_email != $email) {
                $status = 3;
            } else {
                if ($user_info = tt_get_user_by_email($email)) {
                    if (!empty($username) && strtolower($username) != strtolower($user_info['username'])) {
                        $status = 3;
                    } else {
                        $register = 0;
                        return tt_login_success();
                    }
                } else {
                    if (!empty($username) && !empty($email)) {
                        $data = array('username' => utf8_normalize_nfc(request_var('username', '', true)), 'new_password' => request_var('password', '', true), 'password_confirm' => request_var('password', '', true), 'email' => strtolower($email), 'email_confirm' => strtolower($email), 'lang' => basename(request_var('lang', $user->lang_name)), 'tz' => request_var('tz', (double) $timezone));
                        //check username
                        if ($result_username = validate_username($username)) {
                            if ($result_username == 'USERNAME_TAKEN') {
                                $status = 1;
                            } else {
                                $error[] = empty($user->lang[$result_username . '_' . strtoupper('username')]) ? $result_username : $result_username . '_' . strtoupper('username');
                            }
                        } else {
                            if ($mobiquo_config['sso_signin'] == 0) {
                                trigger_error('UCP_REGISTER_DISABLE');
                            }
                            $error = validate_data($data, array('new_password' => array(array('string', false, $config['min_pass_chars'], $config['max_pass_chars']), array('password')), 'password_confirm' => array('string', false, $config['min_pass_chars'], $config['max_pass_chars']), 'email' => array(array('string', false, 6, 60), array('email')), 'email_confirm' => array('string', false, 6, 60), 'tz' => array('num', false, -14, 14), 'lang' => array('language_iso_name')));
                            // Replace "error" strings with their real, localised form
                            $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
                            // DNSBL check
                            if ($config['check_dnsbl']) {
                                if (($dnsbl = $user->check_dnsbl('register')) !== false) {
                                    $error[] = sprintf($user->lang['IP_BLACKLISTED'], $user->ip, $dnsbl[1]);
                                }
                            }
                            if (!sizeof($error)) {
                                // Which group by default?
                                $group_name = 'REGISTERED';
                                $sql = 'SELECT group_id
							FROM ' . GROUPS_TABLE . "\r\r\n\t\t\t\t\t\t\tWHERE group_name = '" . $db->sql_escape($group_name) . "'\r\r\n\t\t\t\t\t\t\t\tAND group_type = " . GROUP_SPECIAL;
                                $result = $db->sql_query($sql);
                                $row = $db->sql_fetchrow($result);
                                $db->sql_freeresult($result);
                                if (!$row) {
                                    trigger_error('NO_GROUP');
                                }
                                $group_id = isset($config['tapatalk_register_group']) ? $config['tapatalk_register_group'] : $row['group_id'];
                                $user_type = USER_NORMAL;
                                $user_actkey = '';
                                $user_inactive_reason = 0;
                                $user_inactive_time = 0;
                                if ($config['require_activation'] == USER_ACTIVATION_ADMIN && $config['email_enable']) {
                                    $user_type = USER_INACTIVE;
                                    $user_inactive_reason = INACTIVE_REGISTER;
                                    $user_inactive_time = time();
                                }
                                $user_row = array('username' => $data['username'], 'user_password' => phpbb_hash($data['new_password']), 'user_email' => $data['email'], 'group_id' => (int) $group_id, 'user_timezone' => (double) $data['tz'], 'user_dst' => $is_dst, 'user_lang' => $data['lang'], 'user_type' => $user_type, 'user_actkey' => $user_actkey, 'user_ip' => $user->ip, 'user_regdate' => time(), 'user_inactive_reason' => $user_inactive_reason, 'user_inactive_time' => $user_inactive_time);
                                if ($config['new_member_post_limit']) {
                                    $user_row['user_new'] = 1;
                                }
                                if (!empty($return->profile)) {
                                    $profile = $return->profile;
                                    if (!empty($profile->birthday) && $config['allow_birthdays']) {
                                        $birth_arr = explode('-', $profile->birthday);
                                        $user_row['user_birthday'] = sprintf('%2d-%2d-%4d', $birth_arr[2], $birth_arr[1], $birth_arr[0]);
                                    }
                                    $user_row['user_from'] = $profile->location;
                                    $user_row['user_website'] = $profile->link;
                                    $user_row['user_sig'] = $profile->signature;
                                }
                                // Register user...
                                $user_id = user_add($user_row);
                                //copy avatar
                                tt_copy_avatar($user_id, $profile->avatar_url);
                                // This should not happen, because the required variables are listed above...
                                if ($user_id === false) {
                                    trigger_error('NO_USER', E_USER_ERROR);
                                } else {
                                    if ($config['require_activation'] == USER_ACTIVATION_ADMIN && $config['email_enable']) {
                                        $message = $user->lang['ACCOUNT_INACTIVE_ADMIN'];
                                        $email_template = 'admin_welcome_inactive';
                                        $server_url = generate_board_url();
                                        include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
                                        $messenger = new messenger(false);
                                        $messenger->template($email_template, $data['lang']);
                                        $messenger->to($data['email'], $data['username']);
                                        if (!method_exists($messenger, 'anti_abuse_headers')) {
                                            $messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']);
                                            $messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']);
                                            $messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']);
                                            $messenger->headers('X-AntiAbuse: User IP - ' . $user->ip);
                                        } else {
                                            $messenger->anti_abuse_headers($config, $user);
                                        }
                                        $messenger->assign_vars(array('WELCOME_MSG' => htmlspecialchars_decode(sprintf($user->lang['WELCOME_SUBJECT'], $config['sitename'])), 'USERNAME' => htmlspecialchars_decode($data['username']), 'PASSWORD' => htmlspecialchars_decode($data['new_password']), 'U_ACTIVATE' => "{$server_url}/ucp.{$phpEx}?mode=activate&u={$user_id}&k={$user_actkey}"));
                                        $messenger->send(NOTIFY_EMAIL);
                                        if ($config['require_activation'] == USER_ACTIVATION_ADMIN) {
                                            // Grab an array of user_id's with a_user permissions ... these users can activate a user
                                            $admin_ary = $auth->acl_get_list(false, 'a_user', false);
                                            $admin_ary = !empty($admin_ary[0]['a_user']) ? $admin_ary[0]['a_user'] : array();
                                            // Also include founders
                                            $where_sql = ' WHERE user_type = ' . USER_FOUNDER;
                                            if (sizeof($admin_ary)) {
                                                $where_sql .= ' OR ' . $db->sql_in_set('user_id', $admin_ary);
                                            }
                                            $sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type
										FROM ' . USERS_TABLE . ' ' . $where_sql;
                                            $result = $db->sql_query($sql);
                                            while ($row = $db->sql_fetchrow($result)) {
                                                $messenger->template('admin_activate', $row['user_lang']);
                                                $messenger->to($row['user_email'], $row['username']);
                                                $messenger->im($row['user_jabber'], $row['username']);
                                                $messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($data['username']), 'U_USER_DETAILS' => "{$server_url}/memberlist.{$phpEx}?mode=viewprofile&u={$user_id}", 'U_ACTIVATE' => "{$server_url}/ucp.{$phpEx}?mode=activate&u={$user_id}&k={$user_actkey}"));
                                                $messenger->send($row['user_notify_type']);
                                            }
                                            $db->sql_freeresult($result);
                                        }
                                        trigger_error('UCP_ADMIN_ACTIVATE');
                                    }
                                    $user_info['user_id'] = $user_id;
                                    $register = 1;
                                    return tt_login_success();
                                }
                            } else {
                                foreach ($error as $msg) {
                                    trigger_error($msg);
                                }
                            }
                        }
                    } else {
                        $status = 2;
                    }
                }
            }
        } else {
            if (!$return->result) {
                if (!empty($return->result_text)) {
                    trigger_error($return->result_text);
                } else {
                    trigger_error("Tapatalk ID verify faile!");
                }
            }
        }
        if (!empty($status)) {
            $response = new xmlrpcval(array('result' => new xmlrpcval(0, 'boolean'), 'result_text' => new xmlrpcval('', 'base64'), 'status' => new xmlrpcval($status, 'string')), 'struct');
            return new xmlrpcresp($response);
        }
    } else {
        trigger_error("Invlaid params!");
    }
}
コード例 #3
0
ファイル: sign_in.php プロジェクト: dthiago/tapatalk-mybb
function sign_in_func()
{
    global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups, $mobiquo_config, $user, $register;
    // Load global language phrases
    $lang->load("member");
    $parser = new postParser();
    $token = trim($_POST['token']);
    $code = trim($_POST['code']);
    $username = $mybb->input['username'];
    $password = $mybb->input['password'];
    $post_email = $mybb->input['email'];
    $status = '';
    if (!empty($token) && !empty($code)) {
        $result = tt_register_verify($token, $code);
        if ($result->result && !empty($result->email)) {
            $email = $result->email;
            if (!empty($post_email) && $post_email != $email) {
                $status = 3;
            } else {
                if ($user = tt_get_user_by_email($email)) {
                    if (!empty($username) && strtolower($username) != strtolower($user['username'])) {
                        $status = 3;
                    } else {
                        $register = 0;
                        return tt_login_success();
                    }
                } else {
                    if (!empty($username) && !empty($email)) {
                        $profile = $result->profile;
                        if ($mybb->settings['disableregs'] == 1) {
                            error($lang->registrations_disabled);
                        }
                        // Set up user handler.
                        require_once MYBB_ROOT . "inc/datahandlers/user.php";
                        $userhandler = new UserDataHandler("insert");
                        $birthday_arr = explode('-', $profile->birthday);
                        $bday = array("day" => $birthday_arr[2], "month" => $birthday_arr[1], "year" => $birthday_arr[0]);
                        $user_field = array('fid3' => ucfirst($profile->gender), 'fid1' => $profile->location, 'fid2' => $profile->description);
                        if ($mybb->settings['regtype'] == "admin") {
                            $usergroup = 5;
                        } else {
                            $usergroup = isset($mybb->settings['tapatalk_register_group']) ? $mybb->settings['tapatalk_register_group'] : 2;
                        }
                        // Set the data for the new user.
                        $user = array("username" => $mybb->input['username'], "password" => $mybb->input['password'], "password2" => $mybb->input['password'], "email" => $email, "email2" => $email, "usergroup" => $usergroup, "referrer" => '', "timezone" => $mybb->settings['timezoneoffset'], "language" => '', "regip" => $session->ipaddress, "longregip" => my_ip2long($session->ipaddress), "coppa_user" => 0, "birthday" => $bday, "website" => $profile->link, "user_fields" => $user_field, "signature" => $profile->signature, "option" => array(), "regdate" => TIME_NOW, "lastvisit" => TIME_NOW);
                        if (!empty($profile->avatar_url)) {
                            $updated_avatar = tt_update_avatar_url($profile->avatar_url);
                        }
                        $userhandler->set_data($user);
                        $userhandler->verify_birthday();
                        $userhandler->verify_options();
                        if ($userhandler->verify_username_exists()) {
                            $status = 1;
                        } else {
                            if (!$userhandler->verify_password() || !$userhandler->verify_username()) {
                                $errors = $userhandler->get_friendly_errors();
                                error($errors[0]);
                            } else {
                                $userhandler->set_validated(true);
                                $user = $userhandler->insert_user();
                                if (!empty($updated_avatar)) {
                                    $db->update_query("users", $updated_avatar, "uid='" . $user['uid'] . "'");
                                }
                                $register = 1;
                                return tt_login_success();
                            }
                        }
                    } else {
                        $status = 2;
                    }
                }
            }
        } else {
            if (!$result->result) {
                if (!empty($result->result_text)) {
                    error($result->result_text);
                } else {
                    error("Tapatalk ID verify faile!");
                }
            }
        }
        if (!empty($status)) {
            $response = new xmlrpcval(array('result' => new xmlrpcval(0, 'boolean'), 'result_text' => new xmlrpcval('', 'base64'), 'status' => new xmlrpcval($status, 'string')), 'struct');
            return new xmlrpcresp($response);
        }
    } else {
        error("Invlaid params!");
    }
}