本文整理汇总了PHP中custom_profile类的典型用法代码示例。如果您正苦于以下问题:PHP custom_profile类的具体用法?PHP custom_profile怎么用?PHP custom_profile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了custom_profile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load_cp_fields
public static function load_cp_fields($user_ids)
{
// Only get the rows for those we have not gotten already
$user_ids = array_diff($user_ids, array_keys(self::$cp_fields));
if (!sizeof($user_ids)) {
return;
}
// Load custom profile fields
if (phpbb::$config['load_cpf_viewtopic']) {
phpbb::_include('functions_profile_fields', false, 'custom_profile');
$cp = new custom_profile();
// Grab all profile fields from users in id cache for later use - similar to the poster cache
$profile_fields_tmp = $cp->generate_profile_fields_template('grab', $user_ids);
// filter out fields not to be displayed on viewtopic. Yes, it's a hack, but this shouldn't break any MODs.
foreach ($profile_fields_tmp as $profile_user_id => $profile_fields) {
self::$cp_fields[$profile_user_id] = array();
foreach ($profile_fields as $used_ident => $profile_field) {
if ($profile_field['data']['field_show_on_vt']) {
self::$cp_fields[$profile_user_id][$used_ident] = $profile_field;
}
}
}
unset($profile_fields_tmp);
}
}
示例2: ucp_preregister
/**
* UCP Pre-Register Operations (Pre-Registration Captcha)
*/
public static function ucp_preregister()
{
global $config, $db, $phpbb_root_path, $phpEx, $template, $user;
if (!$config['asacp_enable']) {
return array();
}
$user->add_lang('mods/asacp');
// Profile fields stuff
$cp = new custom_profile();
foreach (self::$profile_fields as $field => $data) {
if ($data['field_type'] == 'disabled') {
continue;
}
// Special stuff for $cp->process_field_row
$data['var_name'] = $data['field_ident'] = $field;
$data['lang_default_value'] = '';
switch ($config['asacp_profile_' . $field]) {
case 1:
// Required Field
$template->assign_block_vars('profile_fields', array('FIELD_ID' => $field, 'LANG_NAME' => isset($user->lang[$data['lang']]) ? $user->lang[$data['lang']] : $data['lang'], 'S_REQUIRED' => true, 'LANG_EXPLAIN' => isset($user->lang[$data['lang'] . '_EXPLAIN']) ? $user->lang[$data['lang'] . '_EXPLAIN'] : '', 'FIELD' => $cp->process_field_row('change', $data)));
break;
case 2:
if ($config['asacp_profile_during_reg']) {
// Normal Field
$template->assign_block_vars('profile_fields', array('FIELD_ID' => $field, 'LANG_NAME' => isset($user->lang[$data['lang']]) ? $user->lang[$data['lang']] : $data['lang'], 'LANG_EXPLAIN' => isset($user->lang[$data['lang'] . '_EXPLAIN']) ? $user->lang[$data['lang'] . '_EXPLAIN'] : '', 'FIELD' => $cp->process_field_row('change', $data)));
}
break;
}
}
if (!$config['asacp_reg_captcha']) {
return array();
}
}
示例3: test_dropdown_validate
/**
* @dataProvider dropdownFields
*/
public function test_dropdown_validate($field_required, $field_value, $expected, $description)
{
global $db;
$db = $this->new_dbal();
$field_data = array('field_id' => 1, 'lang_id' => 1, 'field_novalue' => 1, 'field_required' => $field_required);
$cp = new custom_profile();
$result = $cp->validate_profile_field(FIELD_DROPDOWN, $field_value, $field_data);
$this->assertEquals($expected, $result, $description);
}
示例4: smiley_text
$bbcode->bbcode_second_pass($member['user_sig'], $member['user_sig_bbcode_uid'], $member['user_sig_bbcode_bitfield']);
}
$member['user_sig'] = smiley_text($member['user_sig']);
}
$poster_avatar = get_user_avatar($member['user_avatar'], $member['user_avatar_type'], $member['user_avatar_width'], $member['user_avatar_height']);
$template->assign_vars($karmamod->show_profile($member));
// Custom Profile Fields
$profile_fields = array();
if ($config['load_cpf_viewprofile'])
{
include_once($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);
$cp = new custom_profile();
$profile_fields = $cp->generate_profile_fields_template('grab', $user_id);
$profile_fields = (isset($profile_fields[$user_id])) ? $cp->generate_profile_fields_template('show', false, $profile_fields[$user_id]) : array();
}
$template->assign_vars(array(
'POSTS_DAY' => sprintf($user->lang['POST_DAY'], $posts_per_day),
'POSTS_PCT' => sprintf($user->lang['POST_PCT'], $percentage),
'OCCUPATION' => (!empty($member['user_occ'])) ? censor_text($member['user_occ']) : '',
'INTERESTS' => (!empty($member['user_interests'])) ? censor_text($member['user_interests']) : '',
'SIGNATURE' => $member['user_sig'],
'AVATAR_IMG' => $poster_avatar,
'PM_IMG' => $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE']),
'EMAIL_IMG' => $user->img('icon_contact_email', $user->lang['EMAIL']),
示例5: get_user_data
/**
* Get user data
*
* grabs the data on the user and places it in the self::$user array
*
* @param int|bool $id The user_id (or multiple user_ids if given an array) of the user we want to grab the data for
* @param bool $user_queue If user_queue is true then we just grab the user_ids from the user_queue, otherwise we select data from $id.
*/
public function get_user_data($id, $user_queue = false, $username = false)
{
global $user, $db, $phpbb_root_path, $phpEx, $config, $auth, $cp;
// if we are using the user_queue, set $user_id as that for consistency
if ($user_queue) {
$id = self::$user_queue;
}
blog_plugins::plugin_do('user_data_start');
// this holds the user_id's we will query
$users_to_query = array();
// if the $user_id isn't an array, make it one for consistency
if (!is_array($id)) {
$id = array(intval($id));
}
if ($username) {
$sql = 'SELECT user_id FROM ' . USERS_TABLE . ' WHERE username_clean = \'' . $db->sql_escape(utf8_clean_string($username)) . '\'';
$result = $db->sql_query($sql);
$id[] = $db->sql_fetchfield('user_id', $result);
$db->sql_freeresult($result);
}
if (!sizeof($id)) {
return;
}
$id[] = 1;
foreach ($id as $i) {
if ($i && !isset(self::$user[$i]) && !in_array($i, $users_to_query)) {
$users_to_query[] = (int) $i;
}
}
if (!sizeof($users_to_query)) {
return;
}
// Grab all profile fields from users in id cache for later use - similar to the poster cache
if ($config['user_blog_custom_profile_enable']) {
if (!class_exists('custom_profile')) {
include $phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx;
$cp = new custom_profile();
}
$profile_fields_cache = $cp->generate_profile_fields_template('grab', $users_to_query);
}
// Grab user status information
$status_data = array();
$sql = 'SELECT session_user_id, MAX(session_time) AS online_time, MIN(session_viewonline) AS viewonline
FROM ' . SESSIONS_TABLE . '
WHERE ' . $db->sql_in_set('session_user_id', $users_to_query) . '
GROUP BY session_user_id';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
$status_data[$row['session_user_id']] = $row;
}
$db->sql_freeresult($result);
$update_time = $config['load_online_time'] * 60;
// Get the rest of the data on the users and parse everything we need
$sql = 'SELECT * FROM ' . USERS_TABLE . ' WHERE ' . $db->sql_in_set('user_id', $users_to_query);
blog_plugins::plugin_do_ref('user_data_sql', $sql);
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
$user_id = $row['user_id'];
blog_plugins::plugin_do_ref('user_data_while', $row);
// view profile link
$row['view_profile'] = append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=viewprofile&u=" . $user_id);
// Full username, with colour
$row['username_full'] = get_username_string('full', $user_id, $row['username'], $row['user_colour']);
// format the color correctly
$row['user_colour'] = get_username_string('colour', $user_id, $row['username'], $row['user_colour']);
// Avatar
$row['avatar'] = get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'], $row['user_avatar_height']);
// Rank
get_user_rank($row['user_rank'], $row['user_posts'], $row['rank_title'], $row['rank_img'], $row['rank_img_src']);
if ($row['user_type'] != USER_IGNORE && $row['user_id'] != ANONYMOUS) {
// Online/Offline Status
$row['status'] = isset($status_data[$user_id]) && time() - $update_time < $status_data[$user_id]['online_time'] && ($status_data[$user_id]['viewonline'] && $row['user_allow_viewonline'] || $auth->acl_get('u_viewonline')) ? true : false;
// IM Links
$row['aim_url'] = $row['user_aim'] ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=contact&action=aim&u={$user_id}") : '';
$row['icq_url'] = $row['user_icq'] ? 'http://www.icq.com/people/webmsg.php?to=' . $row['user_icq'] : '';
$row['jabber_url'] = $row['user_jabber'] ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=contact&action=jabber&u={$user_id}") : '';
$row['msn_url'] = $row['user_msnm'] ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=contact&action=msnm&u={$user_id}") : '';
$row['yim_url'] = $row['user_yim'] ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . $row['user_yim'] . '&.src=pg' : '';
// PM and email links
$row['email_url'] = $config['board_email_form'] && $config['email_enable'] ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=email&u={$user_id}") : ($config['board_hide_emails'] && !$auth->acl_get('a_email') ? '' : 'mailto:' . $row['user_email']);
$row['pm_url'] = $row['user_id'] != ANONYMOUS && $config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($row['user_allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", "i=pm&mode=compose&u={$user_id}") : '';
// get the custom profile fields if the admin wants them
if ($config['user_blog_custom_profile_enable']) {
$row['cp_row'] = isset($profile_fields_cache[$user_id]) ? $cp->generate_profile_fields_template('show', false, $profile_fields_cache[$user_id]) : array();
}
} else {
$row = array_merge($row, array('status' => false, 'aim_url' => '', 'icq_url' => '', 'jabber_url' => '', 'msn_url' => '', 'yim_url' => '', 'email_url' => '', 'pm_url' => ''));
}
// now lets put everything in the user array
self::$user[$user_id] = $row;
}
$db->sql_freeresult($result);
//.........这里部分代码省略.........
示例6: main
function main($id, $mode)
{
global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx;
//
if ($config['require_activation'] == USER_ACTIVATION_DISABLE)
{
trigger_error('UCP_REGISTER_DISABLE');
}
include($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);
$confirm_id = request_var('confirm_id', '');
$coppa = (isset($_REQUEST['coppa'])) ? ((!empty($_REQUEST['coppa'])) ? 1 : 0) : false;
$agreed = (!empty($_POST['agreed'])) ? 1 : 0;
$submit = (isset($_POST['submit'])) ? true : false;
$change_lang = request_var('change_lang', '');
$user_lang = request_var('lang', $user->lang_name);
// not so fast, buddy
if (($submit && !check_form_key('ucp_register', false, '', false, $config['min_time_reg']))
|| (!$submit && !check_form_key('ucp_register_terms', false, '', false, $config['min_time_terms'])))
{
$agreed = false;
}
if ($agreed)
{
add_form_key('ucp_register');
}
else
{
add_form_key('ucp_register_terms');
}
if ($change_lang || $user_lang != $config['default_lang'])
{
$use_lang = ($change_lang) ? basename($change_lang) : basename($user_lang);
if (file_exists($phpbb_root_path . 'language/' . $use_lang . '/'))
{
if ($change_lang)
{
$submit = false;
// Setting back agreed to let the user view the agreement in his/her language
$agreed = (empty($_GET['change_lang'])) ? 0 : $agreed;
}
$user->lang_name = $lang = $use_lang;
$user->lang_path = $phpbb_root_path . 'language/' . $lang . '/';
$user->lang = array();
$user->add_lang(array('common', 'ucp'));
}
else
{
$change_lang = '';
$user_lang = $user->lang_name;
}
}
$cp = new custom_profile();
$error = $cp_data = $cp_error = array();
//
if (!$agreed || ($coppa === false && $config['coppa_enable']) || ($coppa && !$config['coppa_enable']))
{
$add_lang = ($change_lang) ? '&change_lang=' . urlencode($change_lang) : '';
$add_coppa = ($coppa !== false) ? '&coppa=' . $coppa : '';
$s_hidden_fields = ($confirm_id) ? array('confirm_id' => $confirm_id) : array();
// If we change the language, we want to pass on some more possible parameter.
if ($change_lang)
{
// We do not include the password!
$s_hidden_fields = array_merge($s_hidden_fields, array(
'username' => utf8_normalize_nfc(request_var('username', '', true)),
'email' => strtolower(request_var('email', '')),
'email_confirm' => strtolower(request_var('email_confirm', '')),
'confirm_code' => request_var('confirm_code', ''),
'lang' => $user->lang_name,
'tz' => request_var('tz', (float) $config['board_timezone']),
));
}
if ($coppa === false && $config['coppa_enable'])
{
$now = getdate();
$coppa_birthday = $user->format_date(mktime($now['hours'] + $user->data['user_dst'], $now['minutes'], $now['seconds'], $now['mon'], $now['mday'] - 1, $now['year'] - 13), $user->lang['DATE_FORMAT']);
unset($now);
$template->assign_vars(array(
'L_COPPA_NO' => sprintf($user->lang['UCP_COPPA_BEFORE'], $coppa_birthday),
'L_COPPA_YES' => sprintf($user->lang['UCP_COPPA_ON_AFTER'], $coppa_birthday),
'U_COPPA_NO' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register&coppa=0' . $add_lang),
//.........这里部分代码省略.........
示例7: display
//.........这里部分代码省略.........
$id_cache[] = $poster_id;
$user_cache[$poster_id] = array('joined' => $user->format_date($row['user_regdate']), 'posts' => $row['user_posts'], 'warnings' => isset($row['user_warnings']) ? $row['user_warnings'] : 0, 'from' => !empty($row['user_from']) ? $row['user_from'] : '', 'sig' => $user_sig, 'sig_bbcode_uid' => !empty($row['user_sig_bbcode_uid']) ? $row['user_sig_bbcode_uid'] : '', 'sig_bbcode_bitfield' => !empty($row['user_sig_bbcode_bitfield']) ? $row['user_sig_bbcode_bitfield'] : '', 'viewonline' => $row['user_allow_viewonline'], 'allow_pm' => $row['user_allow_pm'], 'avatar' => $user->optionget('viewavatars') ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'], $row['user_avatar_height']) : '', 'age' => '', 'rank_title' => '', 'rank_image' => '', 'rank_image_src' => '', 'username' => $row['username'], 'user_colour' => $row['user_colour'], 'online' => false, 'profile' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=viewprofile&u={$poster_id}"), 'www' => $row['user_website'], 'aim' => $row['user_aim'] && $auth->acl_get('u_sendim') ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=contact&action=aim&u={$poster_id}") : '', 'msn' => $row['user_msnm'] && $auth->acl_get('u_sendim') ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=contact&action=msnm&u={$poster_id}") : '', 'yim' => $row['user_yim'] ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($row['user_yim']) . '&.src=pg' : '', 'jabber' => $row['user_jabber'] && $auth->acl_get('u_sendim') ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=contact&action=jabber&u={$poster_id}") : '', 'search' => $auth->acl_get('u_search') ? append_sid("{$phpbb_root_path}search.{$phpEx}", "author_id={$poster_id}&sr=posts") : '', 'author_full' => get_username_string('full', $poster_id, $row['username'], $row['user_colour']), 'author_colour' => get_username_string('colour', $poster_id, $row['username'], $row['user_colour']), 'author_username' => get_username_string('username', $poster_id, $row['username'], $row['user_colour']), 'author_profile' => get_username_string('profile', $poster_id, $row['username'], $row['user_colour']));
get_user_rank($row['user_rank'], $row['user_posts'], $user_cache[$poster_id]['rank_title'], $user_cache[$poster_id]['rank_image'], $user_cache[$poster_id]['rank_image_src']);
if (!empty($row['user_allow_viewemail']) || $auth->acl_get('a_email')) {
$user_cache[$poster_id]['email'] = $config['board_email_form'] && $config['email_enable'] ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=email&u={$poster_id}") : ($config['board_hide_emails'] && !$auth->acl_get('a_email') ? '' : 'mailto:' . $row['user_email']);
} else {
$user_cache[$poster_id]['email'] = '';
}
if (!empty($row['user_icq'])) {
$user_cache[$poster_id]['icq'] = 'http://www.icq.com/people/' . $row['user_icq'] . '/';
$user_cache[$poster_id]['icq_status_img'] = '<img src="http://web.icq.com/whitepages/online?icq=' . $row['user_icq'] . '&img=5" width="18" height="18" alt="" />';
} else {
$user_cache[$poster_id]['icq_status_img'] = '';
$user_cache[$poster_id]['icq'] = '';
}
if ($config['allow_birthdays'] && !empty($row['user_birthday'])) {
list($bday_day, $bday_month, $bday_year) = array_map('intval', explode('-', $row['user_birthday']));
if ($bday_year) {
$diff = $now['mon'] - $bday_month;
if ($diff == 0) {
$diff = $now['mday'] - $bday_day < 0 ? 1 : 0;
} else {
$diff = $diff < 0 ? 1 : 0;
}
$user_cache[$poster_id]['age'] = (int) ($now['year'] - $bday_year - $diff);
}
}
}
}
}
$db->sql_freeresult($result);
// Load custom profile fields
if ($config['load_cpf_viewtopic']) {
if (!class_exists('custom_profile')) {
include $phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx;
}
$cp = new custom_profile();
// Grab all profile fields from users in id cache for later use - similar to the poster cache
$profile_fields_tmp = $cp->generate_profile_fields_template('grab', $id_cache);
// filter out fields not to be displayed on viewtopic. Yes, it's a hack, but this shouldn't break any MODs.
$profile_fields_cache = array();
foreach ($profile_fields_tmp as $profile_user_id => $profile_fields) {
$profile_fields_cache[$profile_user_id] = array();
foreach ($profile_fields as $used_ident => $profile_field) {
if ($profile_field['data']['field_show_on_vt']) {
$profile_fields_cache[$profile_user_id][$used_ident] = $profile_field;
}
}
}
unset($profile_fields_tmp);
}
// Generate online information for user
if ($config['load_onlinetrack'] && sizeof($id_cache)) {
$sql = 'SELECT session_user_id, MAX(session_time) as online_time, MIN(session_viewonline) AS viewonline
FROM ' . SESSIONS_TABLE . '
WHERE ' . $db->sql_in_set('session_user_id', $id_cache) . '
GROUP BY session_user_id';
$result = $db->sql_query($sql);
$update_time = $config['load_online_time'] * 60;
while ($row = $db->sql_fetchrow($result)) {
$user_cache[$row['session_user_id']]['online'] = time() - $update_time < $row['online_time'] && ($row['viewonline'] || $auth->acl_get('u_viewonline')) ? true : false;
}
$db->sql_freeresult($result);
}
unset($id_cache);
// Instantiate BBCode if need be
示例8: main
//.........这里部分代码省略.........
unset($sql_in);
}
if ($where_sql || $deleteall) {
$sql = 'DELETE FROM ' . LOG_TABLE . '
WHERE log_type = ' . LOG_USERS . "\n\t\t\t\t\t\t\t{$where_sql}";
$db->sql_query($sql);
add_log('admin', 'LOG_CLEAR_USER', $user_row['username']);
}
}
if ($submit && $message) {
add_log('admin', 'LOG_USER_FEEDBACK', $user_row['username']);
add_log('user', $user_id, 'LOG_USER_GENERAL', $message);
trigger_error($user->lang['USER_FEEDBACK_ADDED'] . adm_back_link($this->u_action . '&u=' . $user_id));
}
// Sorting
$limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
$sort_by_text = array('u' => $user->lang['SORT_USERNAME'], 't' => $user->lang['SORT_DATE'], 'i' => $user->lang['SORT_IP'], 'o' => $user->lang['SORT_ACTION']);
$sort_by_sql = array('u' => 'l.user_id', 't' => 'l.log_time', 'i' => 'l.log_ip', 'o' => 'l.log_operation');
$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
// Define where and sort sql for use in displaying logs
$sql_where = $sort_days ? time() - $sort_days * 86400 : 0;
$sql_sort = $sort_by_sql[$sort_key] . ' ' . ($sort_dir == 'd' ? 'DESC' : 'ASC');
// Grab log data
$log_data = array();
$log_count = 0;
view_log('user', $log_data, $log_count, $config['topics_per_page'], $start, 0, 0, $user_id, $sql_where, $sql_sort);
$template->assign_vars(array('S_FEEDBACK' => true, 'S_ON_PAGE' => on_page($log_count, $config['topics_per_page'], $start), 'PAGINATION' => generate_pagination($this->u_action . "&u={$user_id}&{$u_sort_param}", $log_count, $config['topics_per_page'], $start, true), 'S_LIMIT_DAYS' => $s_limit_days, 'S_SORT_KEY' => $s_sort_key, 'S_SORT_DIR' => $s_sort_dir, 'S_CLEARLOGS' => $auth->acl_get('a_clearlogs')));
foreach ($log_data as $row) {
$template->assign_block_vars('log', array('USERNAME' => $row['username'], 'IP' => $row['ip'], 'DATE' => $user->format_date($row['time']), 'ACTION' => nl2br($row['action']), 'ID' => $row['id']));
}
break;
case 'profile':
$cp = new custom_profile();
$cp_data = $cp_error = array();
$data = array();
$sql = 'SELECT lang_id
FROM ' . LANG_TABLE . "\n\t\t\t\t\tWHERE lang_iso = '" . $db->sql_escape($user_row['user_lang']) . "'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$user_row['iso_lang_id'] = $row['lang_id'];
if ($submit) {
$var_ary = array('icq' => (string) '', 'aim' => (string) '', 'msn' => (string) '', 'yim' => (string) '', 'jabber' => (string) '', 'website' => (string) '', 'location' => (string) '', 'occupation' => (string) '', 'interests' => (string) '', 'bday_day' => 0, 'bday_month' => 0, 'bday_year' => 0);
foreach ($var_ary as $var => $default) {
$data[$var] = in_array($var, array('location', 'occupation', 'interests')) ? request_var($var, $default, true) : ($data[$var] = request_var($var, $default));
}
$var_ary = array('icq' => array(array('string', true, 3, 15), array('match', true, '#^[0-9]+$#i')), 'aim' => array('string', true, 3, 17), 'msn' => array('string', true, 5, 255), 'jabber' => array(array('string', true, 5, 255), array('match', true, '#^[a-z0-9\\.\\-_\\+]+?@(.*?\\.)*?[a-z0-9\\-_]+?\\.[a-z]{2,4}(/.*)?$#i')), 'yim' => array('string', true, 5, 255), 'website' => array(array('string', true, 12, 255), array('match', true, '#^http[s]?://(.*?\\.)*?[a-z0-9\\-]+\\.[a-z]{2,4}#i')), 'location' => array('string', true, 2, 255), 'occupation' => array('string', true, 2, 500), 'interests' => array('string', true, 2, 500), 'bday_day' => array('num', true, 1, 31), 'bday_month' => array('num', true, 1, 12), 'bday_year' => array('num', true, 1901, gmdate('Y', time())));
$error = validate_data($data, $var_ary);
// validate custom profile fields
$cp->submit_cp_field('profile', $user_row['iso_lang_id'], $cp_data, $cp_error);
if (sizeof($cp_error)) {
$error = array_merge($error, $cp_error);
}
if (!sizeof($error)) {
$sql_ary = array('user_icq' => $data['icq'], 'user_aim' => $data['aim'], 'user_msnm' => $data['msn'], 'user_yim' => $data['yim'], 'user_jabber' => $data['jabber'], 'user_website' => $data['website'], 'user_from' => $data['location'], 'user_occ' => $data['occupation'], 'user_interests' => $data['interests'], 'user_birthday' => sprintf('%2d-%2d-%4d', $data['bday_day'], $data['bday_month'], $data['bday_year']));
$sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "\n\t\t\t\t\t\t\tWHERE user_id = {$user_id}";
$db->sql_query($sql);
// Update Custom Fields
if (sizeof($cp_data)) {
$sql = 'UPDATE ' . PROFILE_FIELDS_DATA_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $cp_data) . "\n\t\t\t\t\t\t\t\tWHERE user_id = {$user_id}";
$db->sql_query($sql);
if (!$db->sql_affectedrows()) {
$cp_data['user_id'] = (int) $user_id;
示例9: main
//.........这里部分代码省略.........
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
if (!$row['log_operation']) {
// We do not have a log-entry anymore, so there is no data available
$row['action'] = $user->lang['USER_WARNING_LOG_DELETED'];
} else {
$row['action'] = isset($user->lang[$row['log_operation']]) ? $user->lang[$row['log_operation']] : '{' . ucfirst(str_replace('_', ' ', $row['log_operation'])) . '}';
if (!empty($row['log_data'])) {
$log_data_ary = @unserialize($row['log_data']);
$log_data_ary = $log_data_ary === false ? array() : $log_data_ary;
if (isset($user->lang[$row['log_operation']])) {
// Check if there are more occurrences of % than arguments, if there are we fill out the arguments array
// It doesn't matter if we add more arguments than placeholders
if (substr_count($row['action'], '%') - sizeof($log_data_ary) > 0) {
$log_data_ary = array_merge($log_data_ary, array_fill(0, substr_count($row['action'], '%') - sizeof($log_data_ary), ''));
}
$row['action'] = vsprintf($row['action'], $log_data_ary);
$row['action'] = bbcode_nl2br(censor_text($row['action']));
} else {
if (!empty($log_data_ary)) {
$row['action'] .= '<br />' . implode('', $log_data_ary);
}
}
}
}
$template->assign_block_vars('warn', array('ID' => $row['warning_id'], 'USERNAME' => $row['log_operation'] ? get_username_string('full', $row['mod_user_id'], $row['mod_username'], $row['mod_user_colour']) : '-', 'ACTION' => make_clickable($row['action']), 'DATE' => $user->format_date($row['warning_time'])));
}
$db->sql_freeresult($result);
$template->assign_vars(array('S_WARNINGS' => true));
break;
case 'profile':
include $phpbb_root_path . 'includes/functions_user.' . $phpEx;
include $phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx;
$cp = new custom_profile();
$cp_data = $cp_error = array();
$sql = 'SELECT lang_id
FROM ' . LANG_TABLE . "\n\t\t\t\t\tWHERE lang_iso = '" . $db->sql_escape($user->data['user_lang']) . "'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$user_row['iso_lang_id'] = $row['lang_id'];
$data = array('icq' => request_var('icq', $user_row['user_icq']), 'aim' => request_var('aim', $user_row['user_aim']), 'msn' => request_var('msn', $user_row['user_msnm']), 'yim' => request_var('yim', $user_row['user_yim']), 'jabber' => utf8_normalize_nfc(request_var('jabber', $user_row['user_jabber'], true)), 'website' => request_var('website', $user_row['user_website']), 'location' => utf8_normalize_nfc(request_var('location', $user_row['user_from'], true)), 'occupation' => utf8_normalize_nfc(request_var('occupation', $user_row['user_occ'], true)), 'interests' => utf8_normalize_nfc(request_var('interests', $user_row['user_interests'], true)), 'bday_day' => 0, 'bday_month' => 0, 'bday_year' => 0);
if ($user_row['user_birthday']) {
list($data['bday_day'], $data['bday_month'], $data['bday_year']) = explode('-', $user_row['user_birthday']);
}
$data['bday_day'] = request_var('bday_day', $data['bday_day']);
$data['bday_month'] = request_var('bday_month', $data['bday_month']);
$data['bday_year'] = request_var('bday_year', $data['bday_year']);
$data['user_birthday'] = sprintf('%2d-%2d-%4d', $data['bday_day'], $data['bday_month'], $data['bday_year']);
if ($submit) {
$error = validate_data($data, array('icq' => array(array('string', true, 3, 15), array('match', true, '#^[0-9]+$#i')), 'aim' => array('string', true, 3, 255), 'msn' => array('string', true, 5, 255), 'jabber' => array(array('string', true, 5, 255), array('jabber')), 'yim' => array('string', true, 5, 255), 'website' => array(array('string', true, 12, 255), array('match', true, '#^http[s]?://(.*?\\.)*?[a-z0-9\\-]+\\.[a-z]{2,4}#i')), 'location' => array('string', true, 2, 100), 'occupation' => array('string', true, 2, 500), 'interests' => array('string', true, 2, 500), 'bday_day' => array('num', true, 1, 31), 'bday_month' => array('num', true, 1, 12), 'bday_year' => array('num', true, 1901, gmdate('Y', time())), 'user_birthday' => array('date', true)));
// validate custom profile fields
$cp->submit_cp_field('profile', $user_row['iso_lang_id'], $cp_data, $cp_error);
if (sizeof($cp_error)) {
$error = array_merge($error, $cp_error);
}
if (!check_form_key($form_name)) {
$error[] = 'FORM_INVALID';
}
if (!sizeof($error)) {
$sql_ary = array('user_icq' => $data['icq'], 'user_aim' => $data['aim'], 'user_msnm' => $data['msn'], 'user_yim' => $data['yim'], 'user_jabber' => $data['jabber'], 'user_website' => $data['website'], 'user_from' => $data['location'], 'user_occ' => $data['occupation'], 'user_interests' => $data['interests'], 'user_birthday' => $data['user_birthday']);
$sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "\n\t\t\t\t\t\t\tWHERE user_id = {$user_id}";
$db->sql_query($sql);
// Update Custom Fields
$cp->update_profile_field_data($user_id, $cp_data);
示例10: custom_profile
$user_cache[$poster_id]['age'] = (int) ($now['year'] - $bday_year - $diff);
}
}
}
}
}
$db->sql_freeresult($result);
// Load custom profile fields
if ($config['load_cpf_viewtopic'])
{
if (!class_exists('custom_profile'))
{
include($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);
}
$cp = new custom_profile();
// Grab all profile fields from users in id cache for later use - similar to the poster cache
$profile_fields_tmp = $cp->generate_profile_fields_template('grab', $id_cache);
// filter out fields not to be displayed on viewtopic. Yes, it's a hack, but this shouldn't break any MODs.
$profile_fields_cache = array();
foreach ($profile_fields_tmp as $profile_user_id => $profile_fields)
{
$profile_fields_cache[$profile_user_id] = array();
foreach ($profile_fields as $used_ident => $profile_field)
{
if ($profile_field['data']['field_show_on_vt'])
{
$profile_fields_cache[$profile_user_id][$used_ident] = $profile_field;
}
示例11: main
//.........这里部分代码省略.........
get_user_rank($row['user_rank'], $row['user_posts'], $user_cache[$poster_id]['rank_title'], $user_cache[$poster_id]['rank_image'], $user_cache[$poster_id]['rank_image_src']);
if (!empty($row['user_allow_viewemail']) || $auth->acl_get('a_email'))
{
$user_cache[$poster_id]['email'] = ($config['board_email_form'] && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=email&u=$poster_id") : (($config['board_hide_emails'] && !$auth->acl_get('a_email')) ? '' : 'mailto:' . $row['user_email']);
}
if ($row['user_birthday'])
{
list($bday_day, $bday_month, $bday_year) = array_map('intval', explode('-', $row['user_birthday']));
if ($bday_year)
{
$diff = $now['mon'] - $bday_month;
if ($diff == 0)
{
$diff = ($now['mday'] - $bday_day < 0) ? 1 : 0;
}
else
{
$diff = ($diff < 0) ? 1 : 0;
}
$user_cache[$poster_id]['age'] = (int) ($now['year'] - $bday_year - $diff);
}
}
}
$db->sql_freeresult($result);
// Load custom profile fields
if ($config['load_cpf_viewtopic'])
{
include($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);
$cp = new custom_profile();
// Grab all profile fields from users in id cache for later use - similar to the poster cache
$profile_fields_cache = $cp->generate_profile_fields_template('grab', $id_cache);
}
// Generate online information for user
if ($config['load_onlinetrack'] && sizeof($id_cache))
{
$sql = 'SELECT session_user_id, MAX(session_time) as online_time, MIN(session_viewonline) AS viewonline
FROM ' . SESSIONS_TABLE . '
WHERE ' . $db->sql_in_set('session_user_id', $id_cache) . '
GROUP BY session_user_id';
$result = $db->sql_query($sql);
$update_time = $config['load_online_time'] * 60;
while ($row = $db->sql_fetchrow($result))
{
$user_cache[$row['session_user_id']]['online'] = (time() - $update_time < $row['online_time'] && (($row['viewonline']) || $auth->acl_get('u_viewonline'))) ? true : false;
}
$db->sql_freeresult($result);
}
unset($id_cache);
$cp_row = array();
foreach ($message_cache as $post_id => $row)
{
$poster_id = $row['user_id'];
//
if ($config['load_cpf_viewtopic'])
示例12: main
//.........这里部分代码省略.........
$messenger->replyto($config['board_contact']);
$messenger->to($row['user_email'], $row['username']);
$messenger->im($row['user_jabber'], $row['username']);
$messenger->assign_vars(array('USERNAME' => html_entity_decode($username), 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']), 'U_ACTIVATE' => "{$server_url}/ucp.{$phpEx}?mode=activate&u={$user->data['user_id']}&k={$user_actkey}"));
$messenger->send($row['user_notify_type']);
}
$db->sql_freeresult($result);
}
$messenger->save_queue();
$sql_ary += array('user_type' => USER_INACTIVE, 'user_actkey' => $user_actkey);
}
if (sizeof($sql_ary)) {
$sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
WHERE user_id = ' . $user->data['user_id'];
$db->sql_query($sql);
}
// Need to update config, forum, topic, posting, messages, etc.
if ($username != $user->data['username'] && $auth->acl_get('u_chgname') && $config['allow_namechange']) {
user_update_name($user->data['username'], $username);
}
meta_refresh(3, $this->u_action);
$message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
trigger_error($message);
}
// Replace "error" strings with their real, localised form
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
}
$user_char_ary = array('.*' => 'USERNAME_CHARS_ANY', '[\\w]+' => 'USERNAME_ALPHA_ONLY', '[\\w_\\+\\. \\-\\[\\]]+' => 'USERNAME_ALPHA_SPACERS');
$template->assign_vars(array('ERROR' => sizeof($error) ? implode('<br />', $error) : '', 'USERNAME' => isset($username) ? $username : $user->data['username'], 'EMAIL' => isset($email) ? $email : $user->data['user_email'], 'PASSWORD_CONFIRM' => isset($password_confirm) ? $password_confirm : '', 'NEW_PASSWORD' => isset($new_password) ? $new_password : '', 'CUR_PASSWORD' => '', 'L_USERNAME_EXPLAIN' => sprintf($user->lang[$user_char_ary[str_replace('\\\\', '\\', $config['allow_name_chars'])] . '_EXPLAIN'], $config['min_name_chars'], $config['max_name_chars']), 'L_CHANGE_PASSWORD_EXPLAIN' => sprintf($user->lang['CHANGE_PASSWORD_EXPLAIN'], $config['min_pass_chars'], $config['max_pass_chars']), 'S_FORCE_PASSWORD' => $config['chg_passforce'] && $user->data['user_passchg'] < time() - $config['chg_passforce'] ? true : false, 'S_CHANGE_USERNAME' => $config['allow_namechange'] && $auth->acl_get('u_chgname') ? true : false, 'S_CHANGE_EMAIL' => $auth->acl_get('u_chgemail') ? true : false, 'S_CHANGE_PASSWORD' => $auth->acl_get('u_chgpasswd') ? true : false));
break;
case 'profile_info':
include $phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx;
$cp = new custom_profile();
$cp_data = $cp_error = array();
if ($submit) {
$var_ary = array('icq' => (string) '', 'aim' => (string) '', 'msn' => (string) '', 'yim' => (string) '', 'jabber' => (string) '', 'website' => (string) '', 'location' => (string) '', 'occupation' => (string) '', 'interests' => (string) '', 'bday_day' => 0, 'bday_month' => 0, 'bday_year' => 0);
foreach ($var_ary as $var => $default) {
$data[$var] = in_array($var, array('location', 'occupation', 'interests')) ? request_var($var, $default, true) : request_var($var, $default);
}
$var_ary = array('icq' => array(array('string', true, 3, 15), array('match', true, '#^[0-9]+$#i')), 'aim' => array('string', true, 3, 17), 'msn' => array('string', true, 5, 255), 'jabber' => array(array('string', true, 5, 255), array('match', true, '#^[a-z0-9\\.\\-_\\+]+?@(.*?\\.)*?[a-z0-9\\-_]+?\\.[a-z]{2,4}(/.*)?$#i')), 'yim' => array('string', true, 5, 255), 'website' => array(array('string', true, 12, 255), array('match', true, '#^http[s]?://(.*?\\.)*?[a-z0-9\\-]+\\.[a-z]{2,4}#i')), 'location' => array('string', true, 2, 255), 'occupation' => array('string', true, 2, 500), 'interests' => array('string', true, 2, 500), 'bday_day' => array('num', true, 1, 31), 'bday_month' => array('num', true, 1, 12), 'bday_year' => array('num', true, 1901, gmdate('Y', time())));
$error = validate_data($data, $var_ary);
extract($data);
unset($data);
// validate custom profile fields
$cp->submit_cp_field('profile', $user->get_iso_lang_id(), $cp_data, $cp_error);
if (sizeof($cp_error)) {
$error = array_merge($error, $cp_error);
}
if (!sizeof($error)) {
$sql_ary = array('user_icq' => $icq, 'user_aim' => $aim, 'user_msnm' => $msn, 'user_yim' => $yim, 'user_jabber' => $jabber, 'user_website' => $website, 'user_from' => $location, 'user_occ' => $occupation, 'user_interests' => $interests, 'user_birthday' => sprintf('%2d-%2d-%4d', $bday_day, $bday_month, $bday_year));
$sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
WHERE user_id = ' . $user->data['user_id'];
$db->sql_query($sql);
// Update Custom Fields
if (sizeof($cp_data)) {
$sql = 'UPDATE ' . PROFILE_FIELDS_DATA_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $cp_data) . '
WHERE user_id = ' . $user->data['user_id'];
$db->sql_query($sql);
if (!$db->sql_affectedrows()) {
$cp_data['user_id'] = (int) $user->data['user_id'];
$db->return_on_error = true;
$sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $cp_data);
$db->sql_query($sql);
示例13: user_add
/**
* Adds an user
*
* @param mixed $user_row An array containing the following keys (and the appropriate values): username, group_id (the group to place the user in), user_email and the user_type(usually 0). Additional entries not overridden by defaults will be forwarded.
* @param string $cp_data custom profile fields, see custom_profile::build_insert_sql_array
* @param array $notifications_data The notifications settings for the new user
* @return the new user's ID.
*/
function user_add($user_row, $cp_data = false, $notifications_data = null)
{
global $db, $user, $auth, $config, $phpbb_root_path, $phpEx;
global $phpbb_dispatcher, $phpbb_container;
if (empty($user_row['username']) || !isset($user_row['group_id']) || !isset($user_row['user_email']) || !isset($user_row['user_type'])) {
return false;
}
$username_clean = utf8_clean_string($user_row['username']);
if (empty($username_clean)) {
return false;
}
$sql_ary = array('username' => $user_row['username'], 'username_clean' => $username_clean, 'user_password' => isset($user_row['user_password']) ? $user_row['user_password'] : '', 'user_email' => strtolower($user_row['user_email']), 'user_email_hash' => phpbb_email_hash($user_row['user_email']), 'group_id' => $user_row['group_id'], 'user_type' => $user_row['user_type']);
// These are the additional vars able to be specified
$additional_vars = array('user_permissions' => '', 'user_timezone' => $config['board_timezone'], 'user_dateformat' => $config['default_dateformat'], 'user_lang' => $config['default_lang'], 'user_style' => (int) $config['default_style'], 'user_actkey' => '', 'user_ip' => '', 'user_regdate' => time(), 'user_passchg' => time(), 'user_options' => 230271, 'user_new' => 0, 'user_inactive_reason' => 0, 'user_inactive_time' => 0, 'user_lastmark' => time(), 'user_lastvisit' => 0, 'user_lastpost_time' => 0, 'user_lastpage' => '', 'user_posts' => 0, 'user_colour' => '', 'user_avatar' => '', 'user_avatar_type' => '', 'user_avatar_width' => 0, 'user_avatar_height' => 0, 'user_new_privmsg' => 0, 'user_unread_privmsg' => 0, 'user_last_privmsg' => 0, 'user_message_rules' => 0, 'user_full_folder' => PRIVMSGS_NO_BOX, 'user_emailtime' => 0, 'user_notify' => 0, 'user_notify_pm' => 1, 'user_notify_type' => NOTIFY_EMAIL, 'user_allow_pm' => 1, 'user_allow_viewonline' => 1, 'user_allow_viewemail' => 1, 'user_allow_massemail' => 1, 'user_sig' => '', 'user_sig_bbcode_uid' => '', 'user_sig_bbcode_bitfield' => '', 'user_form_salt' => unique_id());
// Now fill the sql array with not required variables
foreach ($additional_vars as $key => $default_value) {
$sql_ary[$key] = isset($user_row[$key]) ? $user_row[$key] : $default_value;
}
// Any additional variables in $user_row not covered above?
$remaining_vars = array_diff(array_keys($user_row), array_keys($sql_ary));
// Now fill our sql array with the remaining vars
if (sizeof($remaining_vars)) {
foreach ($remaining_vars as $key) {
$sql_ary[$key] = $user_row[$key];
}
}
/**
* Use this event to modify the values to be inserted when a user is added
*
* @event core.user_add_modify_data
* @var array user_row Array of user details submited to user_add
* @var array cp_data Array of Custom profile fields submited to user_add
* @var array sql_ary Array of data to be inserted when a user is added
* @since 3.1.0-a1
* @change 3.1.0-b5
*/
$vars = array('user_row', 'cp_data', 'sql_ary');
extract($phpbb_dispatcher->trigger_event('core.user_add_modify_data', compact($vars)));
///archi11 code starts
$sql = 'INSERT INTO ' . USERS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
$db->sql_query($sql);
$last_user_id = $db->sql_nextid();
// **** CVC-11/22/15
$sql1 = "INSERT INTO " . USER_SUBACCOUNT . " (uid,alias_accout_id) values('" . $user->data['user_id'] . "','" . $last_user_id . "')";
// **** CVC-11/22/15
$db->sql_query($sql1);
// **** CVC-11/22/15
$user_id = $db->sql_nextid();
// Insert Custom Profile Fields
if ($cp_data !== false && sizeof($cp_data)) {
$cp_data['user_id'] = (int) $user_id;
$cp = $phpbb_container->get('profilefields.manager');
if (!class_exists('custom_profile')) {
// **** CVC-11/22/15
include_once $phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx;
// **** CVC-11/22/15
}
// **** CVC-11/22/15
$sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', custom_profile::build_insert_sql_array($cp_data));
// **** CVC-11/22/15
//$db->sql_build_array('INSERT', $cp->build_insert_sql_array($cp_data));
$db->sql_query($sql);
}
// Place into appropriate group...
$sql = 'INSERT INTO ' . USER_GROUP_TABLE . ' ' . $db->sql_build_array('INSERT', array('user_id' => (int) $user_id, 'group_id' => (int) $user_row['group_id'], 'user_pending' => 0));
$db->sql_query($sql);
// Now make it the users default group...
group_set_user_default($user_row['group_id'], array($user_id), false);
// Add to newly registered users group if user_new is 1
if ($config['new_member_post_limit'] && $sql_ary['user_new']) {
$sql = 'SELECT group_id
FROM ' . GROUPS_TABLE . "\n\t\t\tWHERE group_name = 'NEWLY_REGISTERED'\n\t\t\t\tAND group_type = " . GROUP_SPECIAL;
$result = $db->sql_query($sql);
$add_group_id = (int) $db->sql_fetchfield('group_id');
$db->sql_freeresult($result);
if ($add_group_id) {
global $phpbb_log;
// Because these actions only fill the log unneccessarily we skip the add_log() entry.
$phpbb_log->disable('admin');
// Add user to "newly registered users" group and set to default group if admin specified so.
if ($config['new_member_group_default']) {
group_user_add($add_group_id, $user_id, false, false, true);
$user_row['group_id'] = $add_group_id;
} else {
group_user_add($add_group_id, $user_id);
}
$phpbb_log->enable('admin');
}
}
// set the newest user and adjust the user count if the user is a normal user and no activation mail is sent
if ($user_row['user_type'] == USER_NORMAL || $user_row['user_type'] == USER_FOUNDER) {
set_config('newest_user_id', $user_id, true);
//.........这里部分代码省略.........
示例14: main
public function main()
{
global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx, $mobiquo_config;
//
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 = $cp_data = $cp_error = array();
$is_dst = $config['board_dst'];
$timezone = $config['board_timezone'];
$email = request_var('email', '');
if (isset($_POST['tt_token']) && isset($_POST['tt_code'])) {
if ($mobiquo_config['sso_register'] == 0) {
trigger_error('UCP_REGISTER_DISABLE');
}
$result = tt_register_verify($_POST['tt_token'], $_POST['tt_code']);
if ($result->result && !empty($result->email) && (empty($email) || strtolower($email == strtolower($result->email)))) {
$verify_result = $result->result;
$email = $result->email;
} else {
if (!$result->result && empty($email) && !empty($result->email)) {
$email = $result->email;
}
}
}
$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($email), 'email_confirm' => strtolower($email), 'lang' => basename(request_var('lang', $user->lang_name)), 'tz' => request_var('tz', (double) $timezone));
$error = validate_data($data, array('username' => array(array('string', false, $config['min_name_chars'], $config['max_name_chars']), array('username', '')), '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]);
}
}
// validate custom profile fields
$cp->submit_cp_field('register', $user->get_iso_lang_id(), $cp_data, $error);
if (!sizeof($error)) {
if ($data['new_password'] != $data['password_confirm']) {
$error[] = $user->lang['NEW_PASSWORD_ERROR'];
}
if ($data['email'] != $data['email_confirm']) {
$error[] = $user->lang['NEW_EMAIL_ERROR'];
}
}
if (!sizeof($error)) {
// Which group by default?
$group_name = 'REGISTERED';
$sql = 'SELECT group_id
FROM ' . GROUPS_TABLE . "\r\r\n\t\t\t\tWHERE group_name = '" . $db->sql_escape($group_name) . "'\r\r\n\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 = $row['group_id'];
if ($config['require_activation'] == USER_ACTIVATION_NONE) {
$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_NONE && !$verify_result) {
$user_actkey = gen_rand_string(mt_rand(6, 10));
$user_type = USER_INACTIVE;
$user_inactive_reason = INACTIVE_REGISTER;
$user_inactive_time = time();
}
if ($verify_result && $config['require_activation'] != USER_ACTIVATION_ADMIN) {
$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;
}
$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;
}
// Register user...
$user_id = user_add($user_row, $cp_data);
// This should not happen, because the required variables are listed above...
if ($user_id === false) {
trigger_error('NO_USER', E_USER_ERROR);
}
if (!$verify_result) {
$this->sendEmail($data, $user_id, $user_actkey);
switch ($config['require_activation']) {
case USER_ACTIVATION_SELF:
$this->result_text = $user->lang['UCP_EMAIL_ACTIVATE'];
break;
case USER_ACTIVATION_ADMIN:
$this->result_text = $user->lang['UCP_ADMIN_ACTIVATE'];
break;
//.........这里部分代码省略.........
示例15: user_add
/**
* Add User
*/
function user_add($user_row, $cp_data = false)
{
global $db, $user, $auth, $config, $phpbb_root_path, $phpEx;
if (empty($user_row['username']) || !isset($user_row['group_id']) || !isset($user_row['user_email']) || !isset($user_row['user_type'])) {
return false;
}
$sql_ary = array('username' => $user_row['username'], 'user_password' => isset($user_row['user_password']) ? $user_row['user_password'] : '', 'user_email' => $user_row['user_email'], 'user_email_hash' => (int) crc32(strtolower($user_row['user_email'])) . strlen($user_row['user_email']), 'group_id' => $user_row['group_id'], 'user_type' => $user_row['user_type']);
// These are the additional vars able to be specified
$additional_vars = array('user_permissions' => '', 'user_timezone' => 0, 'user_dateformat' => $config['default_dateformat'], 'user_lang' => $config['default_lang'], 'user_style' => $config['default_style'], 'user_allow_pm' => 1, 'user_actkey' => '', 'user_ip' => '', 'user_regdate' => time(), 'user_lastmark' => time(), 'user_lastvisit' => 0, 'user_lastpost_time' => 0, 'user_lastpage' => '', 'user_posts' => 0, 'user_dst' => 0, 'user_colour' => '', 'user_avatar' => '', 'user_avatar_type' => 0, 'user_avatar_width' => 0, 'user_avatar_height' => 0, 'user_new_privmsg' => 0, 'user_unread_privmsg' => 0, 'user_last_privmsg' => 0, 'user_message_rules' => 0, 'user_full_folder' => PRIVMSGS_NO_BOX, 'user_emailtime' => 0, 'user_notify' => 0, 'user_notify_pm' => 1, 'user_notify_type' => NOTIFY_EMAIL, 'user_allow_pm' => 1, 'user_allow_email' => 1, 'user_allow_viewonline' => 1, 'user_allow_viewemail' => 1, 'user_allow_massemail' => 1, 'user_sig' => '', 'user_sig_bbcode_uid' => '', 'user_sig_bbcode_bitfield' => 0);
// Now fill the sql array with not required variables
foreach ($additional_vars as $key => $default_value) {
$sql_ary[$key] = isset($user_row[$key]) ? $user_row[$key] : $default_value;
}
// Any additional variables in $user_row not covered above?
$remaining_vars = array_diff(array_keys($user_row), array_keys($sql_ary));
// Now fill our sql array with the remaining vars
if (sizeof($remaining_vars)) {
foreach ($remaining_vars as $key) {
$sql_ary[$key] = $user_row[$key];
}
}
$db->sql_transaction('begin');
$sql = 'INSERT INTO ' . USERS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
$db->sql_query($sql);
$user_id = $db->sql_nextid();
// Insert Custom Profile Fields
if ($cp_data !== false && sizeof($cp_data)) {
$cp_data['user_id'] = (int) $user_id;
if (!class_exists('custom_profile')) {
include_once $phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx;
}
$sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', custom_profile::build_insert_sql_array($cp_data));
$db->sql_query($sql);
}
// Place into appropriate group...
$sql = 'INSERT INTO ' . USER_GROUP_TABLE . ' ' . $db->sql_build_array('INSERT', array('user_id' => (int) $user_id, 'group_id' => (int) $user_row['group_id'], 'user_pending' => 0));
$db->sql_query($sql);
$db->sql_transaction('commit');
return $user_id;
}