Пример #1
0
/**
 * Add a member.
 *
 * @param  SHORT_TEXT		The username.
 * @param  SHORT_TEXT		The password.
 * @param  SHORT_TEXT		The e-mail address.
 * @param  ?array				A list of usergroups (NULL: default/current usergroups).
 * @param  ?integer			Day of date of birth (NULL: unknown).
 * @param  ?integer			Month of date of birth (NULL: unknown).
 * @param  ?integer			Year of date of birth (NULL: unknown).
 * @param  array				A map of custom field values (field-id=>value).
 * @param  ?ID_TEXT			The member timezone (NULL: auto-detect).
 * @param  ?GROUP				The member's primary (NULL: default).
 * @param  BINARY				Whether the profile has been validated.
 * @param  ?TIME				When the member joined (NULL: now).
 * @param  ?TIME				When the member last visited (NULL: now).
 * @param  ID_TEXT			The member's default theme.
 * @param  ?URLPATH			The URL to the member's avatar (blank: none) (NULL: choose one automatically).
 * @param  LONG_TEXT			The member's signature (blank: none).
 * @param  BINARY				Whether the member is permanently banned.
 * @param  BINARY				Whether posts are previewed before they are made.
 * @param  BINARY				Whether the member's age may be shown.
 * @param  SHORT_TEXT		The member's title (blank: get from primary).
 * @param  URLPATH			The URL to the member's photo (blank: none).
 * @param  URLPATH			The URL to the member's photo thumbnail (blank: none).
 * @param  BINARY				Whether the member sees signatures in posts.
 * @param  ?BINARY			Whether the member automatically is enabled for notifications for content they contribute to (NULL: get default from config).
 * @param  ?LANGUAGE_NAME	The member's language (NULL: auto detect).
 * @param  BINARY				Whether the member allows e-mails via the site.
 * @param  BINARY				Whether the member allows e-mails from staff via the site.
 * @param  LONG_TEXT			Personal notes of the member.
 * @param  ?IP					The member's IP address (NULL: IP address of current user).
 * @param  SHORT_TEXT		The code required before the account becomes active (blank: already entered).
 * @param  boolean			Whether to check details for correctness.
 * @param  ?ID_TEXT			The compatibility scheme that the password operates in (blank: none) (NULL: none [meaning normal ocPortal salted style] or plain, depending on whether passwords are encrypted).
 * @param  SHORT_TEXT		The password salt (blank: password compatibility scheme does not use a salt / auto-generate).
 * @param  BINARY				Whether the member likes to view zones without menus, when a choice is available.
 * @param  ?TIME				The time the member last made a submission (NULL: set to now).
 * @param  ?AUTO_LINK		Force an ID (NULL: don't force an ID)
 * @param  BINARY				Whether the member username will be highlighted.
 * @param  SHORT_TEXT		Usergroups that may PT the member.
 * @param  LONG_TEXT			Rules that other members must agree to before they may start a PT with the member.
 * @return AUTO_LINK			The ID of the new member.
 */
function ocf_make_member($username, $password, $email_address, $secondary_groups, $dob_day, $dob_month, $dob_year, $custom_fields, $timezone = NULL, $primary_group = NULL, $validated = 1, $join_time = NULL, $last_visit_time = NULL, $theme = '', $avatar_url = NULL, $signature = '', $is_perm_banned = 0, $preview_posts = 0, $reveal_age = 1, $title = '', $photo_url = '', $photo_thumb_url = '', $views_signatures = 1, $auto_monitor_contrib_content = NULL, $language = NULL, $allow_emails = 1, $allow_emails_from_staff = 1, $personal_notes = '', $ip_address = NULL, $validated_email_confirm_code = '', $check_correctness = true, $password_compatibility_scheme = NULL, $salt = '', $zone_wide = 1, $last_submit_time = NULL, $id = NULL, $highlighted_name = 0, $pt_allow = '*', $pt_rules_text = '')
{
    if (is_null($auto_monitor_contrib_content)) {
        $auto_monitor_contrib_content = get_value('no_auto_notifications') === '1' ? 0 : 1;
    }
    if (is_null($password_compatibility_scheme)) {
        if (get_value('no_password_hashing') === '1') {
            $password_compatibility_scheme = 'plain';
        } else {
            $password_compatibility_scheme = '';
        }
    }
    if (is_null($language)) {
        $language = '';
    }
    if (is_null($signature)) {
        $signature = '';
    }
    if (is_null($title)) {
        $title = '';
    }
    if (is_null($timezone)) {
        $timezone = get_site_timezone();
    }
    if (is_null($allow_emails)) {
        $allow_emails = 1;
    }
    if (is_null($allow_emails_from_staff)) {
        $allow_emails_from_staff = 1;
    }
    if (is_null($personal_notes)) {
        $personal_notes = '';
    }
    if (is_null($avatar_url)) {
        if ($GLOBALS['IN_MINIKERNEL_VERSION'] == 1 || !addon_installed('ocf_member_avatars')) {
            $avatar_url = '';
        } else {
            if (get_option('random_avatars') == '1' && !running_script('stress_test_loader')) {
                require_code('themes2');
                $codes = get_all_image_ids_type('ocf_default_avatars/default_set', false, $GLOBALS['FORUM_DB']);
                shuffle($codes);
                $results = array();
                foreach ($codes as $code) {
                    if (strpos($code, 'ocp_fanatic') !== false) {
                        continue;
                    }
                    $count = $GLOBALS['FORUM_DB']->query_value_null_ok_full('SELECT SUM(m_cache_num_posts) FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE ' . db_string_equal_to('m_avatar_url', find_theme_image($code, false, true)));
                    if (is_null($count)) {
                        $count = 0;
                    }
                    $results[$code] = $count;
                }
                @asort($results);
                // @'d as type checker fails for some odd reason
                $found_avatars = array_keys($results);
                $avatar_url = find_theme_image(array_shift($found_avatars), true, true);
            }
            if (is_null($avatar_url)) {
                $GLOBALS['SITE_DB']->query_delete('theme_images', array('id' => 'ocf_default_avatars/default', 'path' => ''));
                // In case failure cached, gets very confusing
                $avatar_url = find_theme_image('ocf_default_avatars/default', true, true);
                if (is_null($avatar_url)) {
                    $avatar_url = '';
                }
            }
        }
    }
    if ($check_correctness) {
        if (!in_array($password_compatibility_scheme, array('ldap', 'httpauth'))) {
            ocf_check_name_valid($username, NULL, $password_compatibility_scheme == '' ? $password : NULL);
        }
        if (!function_exists('has_actual_page_access') || !has_actual_page_access(get_member(), 'admin_ocf_join')) {
            require_code('type_validation');
            if (!is_valid_email_address($email_address) && $email_address != '') {
                warn_exit(do_lang_tempcode('_INVALID_EMAIL_ADDRESS', escape_html($email_address)));
            }
        }
    }
    require_code('ocf_members');
    require_code('ocf_groups');
    if (is_null($last_submit_time)) {
        $last_submit_time = time();
    }
    if (is_null($join_time)) {
        $join_time = time();
    }
    if (is_null($last_visit_time)) {
        $last_visit_time = time();
    }
    if (is_null($primary_group)) {
        $primary_group = get_first_default_group();
        // This is members
    }
    if (is_null($secondary_groups)) {
        $secondary_groups = ocf_get_all_default_groups(false);
    }
    foreach ($secondary_groups as $_g_id => $g_id) {
        if ($g_id == $primary_group) {
            unset($secondary_groups[$_g_id]);
        }
    }
    if (is_null($ip_address)) {
        $ip_address = get_ip_address();
    }
    if ($password_compatibility_scheme == '' && get_value('no_password_hashing') === '1') {
        $password_compatibility_scheme = 'plain';
        $salt = '';
    }
    if ($salt == '' && $password_compatibility_scheme == '') {
        $salt = produce_salt();
        $password_salted = md5($salt . md5($password));
    } else {
        $password_salted = $password;
    }
    // Supplement custom field values given with defaults, and check constraints
    $all_fields = list_to_map('id', ocf_get_all_custom_fields_match($secondary_groups));
    require_code('fields');
    foreach ($all_fields as $field) {
        $field_id = $field['id'];
        if (array_key_exists($field_id, $custom_fields)) {
            if ($check_correctness && $field[array_key_exists('cf_show_on_join_form', $field) ? 'cf_show_on_join_form' : 'cf_required'] == 0 && $field['cf_owner_set'] == 0 && !has_actual_page_access(get_member(), 'admin_ocf_join')) {
                access_denied('I_ERROR');
            }
        } else {
            $custom_fields[$field_id] = '';
        }
    }
    if (!addon_installed('unvalidated')) {
        $validated = 1;
    }
    $map = array('m_username' => $username, 'm_pass_hash_salted' => $password_salted, 'm_pass_salt' => $salt, 'm_theme' => $theme, 'm_avatar_url' => $avatar_url, 'm_validated' => $validated, 'm_validated_email_confirm_code' => $validated_email_confirm_code, 'm_cache_num_posts' => 0, 'm_cache_warnings' => 0, 'm_max_email_attach_size_mb' => 5, 'm_join_time' => $join_time, 'm_timezone_offset' => $timezone, 'm_primary_group' => $primary_group, 'm_last_visit_time' => $last_visit_time, 'm_last_submit_time' => $last_submit_time, 'm_signature' => insert_lang_comcode($signature, 4, $GLOBALS['FORUM_DB']), 'm_is_perm_banned' => $is_perm_banned, 'm_preview_posts' => $preview_posts, 'm_notes' => $personal_notes, 'm_dob_day' => $dob_day, 'm_dob_month' => $dob_month, 'm_dob_year' => $dob_year, 'm_reveal_age' => $reveal_age, 'm_email_address' => $email_address, 'm_title' => $title, 'm_photo_url' => $photo_url, 'm_photo_thumb_url' => $photo_thumb_url, 'm_views_signatures' => $views_signatures, 'm_auto_monitor_contrib_content' => $auto_monitor_contrib_content, 'm_highlighted_name' => $highlighted_name, 'm_pt_allow' => $pt_allow, 'm_pt_rules_text' => insert_lang_comcode($pt_rules_text, 4, $GLOBALS['FORUM_DB']), 'm_language' => $language, 'm_ip_address' => $ip_address, 'm_zone_wide' => $zone_wide, 'm_allow_emails' => $allow_emails, 'm_allow_emails_from_staff' => $allow_emails_from_staff, 'm_password_change_code' => '', 'm_password_compat_scheme' => $password_compatibility_scheme, 'm_on_probation_until' => NULL);
    if (!is_null($id)) {
        $map['id'] = $id;
    }
    $member_id = $GLOBALS['FORUM_DB']->query_insert('f_members', $map, true);
    if ($check_correctness) {
        // If it was an invite/recommendation, award the referrer
        if (addon_installed('recommend')) {
            $inviter = $GLOBALS['FORUM_DB']->query_value_null_ok('f_invites', 'i_inviter', array('i_email_address' => $email_address), 'ORDER BY i_time');
            if (!is_null($inviter)) {
                if (addon_installed('points')) {
                    require_code('points2');
                    require_lang('recommend');
                    system_gift_transfer(do_lang('RECOMMEND_SITE_TO', $username, get_site_name()), intval(get_option('points_RECOMMEND_SITE')), $inviter);
                }
                if (addon_installed('chat')) {
                    require_code('chat2');
                    buddy_add($inviter, $member_id);
                    buddy_add($member_id, $inviter);
                }
            }
        }
    }
    $value = mixed();
    // Store custom fields
    $row = array('mf_member_id' => $member_id);
    $all_fields_types = collapse_2d_complexity('id', 'cf_type', $all_fields);
    foreach ($custom_fields as $field_num => $value) {
        if (!array_key_exists($field_num, $all_fields_types)) {
            continue;
        }
        // Trying to set a field we're not allowed to (doesn't apply to our group)
        $ob = get_fields_hook($all_fields_types[$field_num]);
        list(, , $storage_type) = $ob->get_field_value_row_bits($all_fields[$field_num]);
        if (strpos($storage_type, '_trans') !== false) {
            $value = insert_lang($value, 3, $GLOBALS['FORUM_DB']);
        }
        $row['field_' . strval($field_num)] = $value;
    }
    // Set custom field row
    $all_fields_regardless = $GLOBALS['FORUM_DB']->query_select('f_custom_fields', array('id', 'cf_type'));
    foreach ($all_fields_regardless as $field) {
        if (!array_key_exists('field_' . strval($field['id']), $row)) {
            $ob = get_fields_hook($field['cf_type']);
            list(, , $storage_type) = $ob->get_field_value_row_bits($field);
            $value = '';
            if (strpos($storage_type, '_trans') !== false) {
                $value = insert_lang($value, 3, $GLOBALS['FORUM_DB']);
            }
            $row['field_' . strval($field['id'])] = $value;
        }
    }
    $GLOBALS['FORUM_DB']->query_insert('f_member_custom_fields', $row);
    // Any secondary work
    foreach ($secondary_groups as $g) {
        if ($g != $primary_group) {
            $GLOBALS['FORUM_DB']->query_delete('f_group_members', array('gm_member_id' => $member_id, 'gm_group_id' => $g), '', 1);
            $GLOBALS['FORUM_DB']->query_insert('f_group_members', array('gm_group_id' => $g, 'gm_member_id' => $member_id, 'gm_validated' => 1));
        }
    }
    if ($check_correctness) {
        if (function_exists('decache')) {
            decache('side_stats');
        }
    }
    return $member_id;
}
Пример #2
0
 function DoFollow()
 {
     $rets = buddy_add($this->ID, MEMBER_ID, 1);
     if ($rets && $rets['error']) {
         $msg = wap_iconv($rets['error']);
         $this->Messager($msg);
     }
     if ('follow' == $this->Get['act']) {
         $this->Messager('关注成功', 'index.php?mod=fans');
     } else {
         $this->Messager('取消关注成功', 'index.php?mod=follow');
     }
 }
Пример #3
0
    /**
     * The UI to choose a chat room.
     *
     * @return tempcode		The UI
     */
    function chat_lobby()
    {
        require_javascript('javascript_ajax_people_lists');
        // Starting an IM? The IM will popup by AJAX once the page loads, because it's in the system now
        $enter_im = get_param_integer('enter_im', NULL);
        if (!is_null($enter_im)) {
            require_code('chat2');
            buddy_add(get_member(), $enter_im);
            $you = $GLOBALS['FORUM_DRIVER']->get_username(get_member());
            $them = $GLOBALS['FORUM_DRIVER']->get_username($enter_im);
            attach_message('Instant messaging has been disabled on this site, but you can arrange with members to connect via XMPP software (create a Private Topic, asking them to use XMPP, and tell them your username is ' . escape_html($you) . ' – we have auto-added ' . escape_html($them) . ' as an contact in your XMPP software).', 'warn');
        }
        // Generic stuff: Title, feed URL
        $title = get_page_title('CHAT_LOBBY');
        // Rooms
        $room_url = build_url(array('page' => '_SELF', 'type' => 'room', 'id' => 'room_id'), '_SELF');
        $fields = '
			<ul id="rooms"></ul>
		';
        $seteffectslink = hyperlink(build_url(array('page' => '_SELF', 'type' => 'set_effects'), '_SELF'), do_lang_tempcode('CHAT_SET_EFFECTS'), true);
        $buddies = array();
        $buddy_rows = $GLOBALS['SITE_DB']->query_select('chat_buddies', array('*'), array('member_likes' => get_member()));
        foreach ($buddy_rows as $br) {
            $u = $GLOBALS['FORUM_DRIVER']->get_username($br['member_liked']);
            if (!is_null($u)) {
                $buddies[] = array('USERNAME' => $u);
            }
        }
        $password_hash = $GLOBALS['FORUM_DRIVER']->get_member_row_field(get_member(), 'm_pass_hash_salted');
        return do_template('CHAT_LOBBY_SCREEN', array('_GUID' => 'f82ddfd0dccbd25752dd05a1d87429e2', 'ROOM_URL' => $room_url, 'BUDDIES' => $buddies, 'PASSWORD_HASH' => $password_hash, 'CHAT_SOUND' => get_chat_sound_tpl(), 'TITLE' => $title, 'ROOMS' => $fields, 'SETEFFECTS_LINK' => $seteffectslink));
    }
Пример #4
0
 /**
  * Add a buddy.
  *
  * @return tempcode		The UI
  */
 function buddy_add()
 {
     if (is_guest()) {
         access_denied('NOT_AS_GUEST');
     }
     $title = get_page_title('MAKE_BUDDY');
     $member_id = either_param_integer('member_id', NULL);
     if (is_null($member_id)) {
         $username = post_param('buddy_username');
         $member_id = $GLOBALS['FORUM_DRIVER']->get_member_from_username($username);
         if (is_null($member_id)) {
             warn_exit(do_lang_tempcode('_USER_NO_EXIST', escape_html($username)));
         }
     } else {
         $username = $GLOBALS['FORUM_DRIVER']->get_username($member_id);
     }
     // Can't befriend oneself (yes, this may happen!)
     if ($member_id == get_member()) {
         warn_exit(do_lang_tempcode('CANNOT_BEFRIEND_ONESELF'));
     }
     if (!is_null($GLOBALS['SITE_DB']->query_value_null_ok('chat_buddies', 'date_and_time', array('member_likes' => get_member(), 'member_liked' => $member_id)))) {
         warn_exit(do_lang('ALREADY_FRIENDS', escape_html($username)));
     }
     $test = $this->handle_repost('ADD_BUDDY_ACTION_DESCRIPTION', $username);
     if (!is_null($test)) {
         return $test;
     }
     require_code('chat2');
     buddy_add(get_member(), $member_id);
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('CHAT_LOBBY'))));
     $url = get_param('redirect', '');
     if ($url == '') {
         return inform_screen($title, do_lang_tempcode('NOW_ADDED_AS_FRIEND', escape_html($username)));
     }
     return redirect_screen($title, $url, do_lang_tempcode('NOW_ADDED_AS_FRIEND', escape_html($username)));
 }
Пример #5
0
 function addFollow($uid)
 {
     if ($uid == MEMBER_ID) {
         return 401;
     } else {
         $member = $this->TopicLogic->GetMember($uid);
         if (empty($member)) {
             return 300;
         }
     }
     $info = jlogic('buddy')->info($uid, MEMBER_ID);
     if (!$info) {
         buddy_add($uid, MEMBER_ID);
         return 200;
     }
     return 310;
 }
    if (!empty($usr->buddy_list)) {
        $usr->buddy_list = @unserialize($usr->buddy_list);
    }
    if (!isset($usr->buddy_list[$buddy_id])) {
        $usr->buddy_list = buddy_add(_uid, $buddy_id);
    } else {
        error_dialog('Info', 'You already have this user on your buddy list');
    }
}
/* incomming from message display page (add buddy link) */
if (isset($_GET['add']) && ($_GET['add'] = (int) $_GET['add'])) {
    if (!empty($usr->buddy_list)) {
        $usr->buddy_list = @unserialize($usr->buddy_list);
    }
    if (($buddy_id = q_singleval('SELECT id FROM phpgw_fud_users WHERE id=' . $_GET['add'])) && !isset($usr->buddy_list[$buddy_id])) {
        buddy_add(_uid, $buddy_id);
    }
    check_return($usr->returnto);
}
if (isset($_GET['del']) && ($_GET['del'] = (int) $_GET['del'])) {
    buddy_delete(_uid, $_GET['del']);
    /* needed for external links to this form */
    if (isset($_GET['redr'])) {
        check_return($usr->returnto);
    }
}
ses_update_status($usr->sid, 'Browsing own buddy list');
if ($FUD_OPT_1 & 8388608 || _uid && $FUD_OPT_1 & 4194304) {
    $buddy_member_search = '<br>Or use the <a href="javascript://" class="GenLink" onClick="javascript: window_open(\'/egroupware/fudforum/3814588639/index.php?t=pmuserloc&amp;' . _rsid . '&amp;js_redr=buddy_add.add_login&amp;overwrite=1\', \'user_list\', 250,250);">Find User</a> feature to find a person.';
} else {
    $buddy_member_search = '';
Пример #7
0
 function Do_forward()
 {
     if (MEMBER_ID < 1) {
         response_text("请登录");
     }
     if ($this->MemberHandler->HasPermission('topic', 'forward') == false) {
         response_text("您的角色没有转发的权限");
     }
     $content = strip_tags($this->Post['content']);
     $totid = (int) $this->Post['tid'];
     $imageid = trim($this->Post['imageid']);
     $attachid = trim($this->Post['attachid']);
     $type = $this->Post['topictype'];
     $from = 'web';
     if ($this->Config['seccode_enable']) {
         $YXM_check = jlogic('seccode')->topiccheckYXM($type);
         if ($YXM_check && $this->yxm_title && $this->Config['seccode_pub_key'] && $this->Config['seccode_pri_key']) {
             $YinXiangMa_response = jlogic('seccode')->CheckYXM(@$_POST['YinXiangMa_challenge'], @$_POST['YXM_level'][0], @$_POST['YXM_input_result']);
             if ($YinXiangMa_response != "true") {
                 response_text("验证码输入错误");
             }
         }
     }
     $is_reward = $this->Post['is_reward'];
     $item = trim($this->Post['item']);
     $item_id = intval(trim($this->Post['item_id']));
     #为有奖转发添加小尾巴
     if ($is_reward) {
         $reward = jlogic("reward")->getRewardInfo($is_reward);
         foreach ($reward["rules"]["user"] as $value) {
             $uid = DB::result_first("select uid from `" . TABLE_PREFIX . "members` where nickname = '{$value['nickname']}' ");
             !$uid || buddy_add($uid);
         }
     }
     if (!empty($item_id)) {
         jfunc('app');
         $ret = app_check($item, $item_id);
         if (!$ret) {
             $item = '';
             $item_id = 0;
         } else {
             $from = $item;
         }
     } else {
         $item = '';
         $item_id = 0;
     }
     $data = array('content' => $content, 'totid' => $totid, 'imageid' => $imageid, 'attachid' => $attachid, 'from' => $from, 'type' => $type, 'item' => $item, 'item_id' => $item_id, 'is_reward' => $is_reward);
     $return = $this->TopicLogic->Add($data);
     if (is_array($return) && $return['tid'] > 0) {
         response_text('<success></success>');
     } else {
         $return = is_string($return) ? "[转发失败]" . $return : (is_array($return) ? "[转发成功]但" . implode("", $return) : "未知错误");
         response_text("{$return}");
     }
 }
Пример #8
0
 function add()
 {
     $GLOBALS['disable_show_msg'] = 1;
     $response = '';
     $follow_button = $this->Post['follow_button'];
     if (MEMBER_ID < 1) {
         js_show_login('登录后才能执行此操作');
     }
     $uid = jpost('uid', 'int');
     if ($follow_button == 'channel' || $follow_button == 'channelnav') {
         $isbuddy = jlogic('channel')->channel_isbuddy($uid);
         $can_buddy = jlogic('channel')->can_view_topic($uid);
         if ($isbuddy) {
             jlogic('channel')->buddy_channel($uid, 0);
             $response = follow_channel($uid, 0);
         } else {
             if ($can_buddy) {
                 jlogic('channel')->buddy_channel($uid, 1);
                 $response = follow_channel($uid, 1);
             } else {
                 $response = '';
             }
         }
     } elseif ($this->Config['department_enable'] && $follow_button == 'department') {
         $isbuddy = DB::result_first("SELECT count(*) FROM " . DB::table('buddy_department') . " WHERE uid = '" . MEMBER_ID . "' AND did = '{$uid}'");
         if ($isbuddy) {
             DB::query("DELETE FROM " . DB::table('buddy_department') . " WHERE uid = '" . MEMBER_ID . "' AND did = '{$uid}'");
             $response = follow_department($uid, 0);
         } else {
             DB::query("INSERT INTO " . DB::table('buddy_department') . " (`uid`,`did`) values ('" . MEMBER_ID . "','{$uid}')");
             $response = follow_department($uid, 1);
         }
     } else {
         $rets = buddy_add($uid, MEMBER_ID, 1);
         if ($rets) {
             if ($rets['error']) {
                 js_alert_output($rets['error']);
             } else {
                 if ($follow_button == 'xiao') {
                     $response = follow_html2($uid, 0, 0, 0);
                 } else {
                     $response = follow_html($uid, 0, 0, 0);
                 }
             }
         } else {
             if ($follow_button == 'xiao') {
                 $response = follow_html2($uid, 1, 0, 0);
             } else {
                 $response = follow_html($uid, 1, 0, 0);
             }
         }
         $response .= '<success></success>';
         $u_nickname = DB::result_first("SELECT `nickname` FROM " . DB::table('members') . " WHERE uid = '{$uid}'");
         $response .= $u_nickname;
     }
     response_text($response);
 }
Пример #9
0
 function register_by_invite($invite_uid, $uid = MEMBER_ID, $check_result = array())
 {
     $u = (int) $invite_uid;
     if ($u < 1) {
         return 0;
     }
     $uid = (int) $uid;
     if ($uid < 1) {
         return 0;
     }
     if ($uid == $u) {
         return 0;
     }
     $invite_member = jsg_member_info($u);
     if (!$invite_member) {
         return 0;
     }
     $member = jsg_member_info($uid);
     if (!$member) {
         return 0;
     }
     $timestamp = time();
     $username = $member['nickname'];
     $email = $member['email'];
     $c = $check_result['code'];
     buddy_add($u, $uid);
     if ($check_result) {
         buddy_add($uid, $u);
     }
     if (0 < ($invite_id = $check_result['invite_id'])) {
         $row = DB::fetch_first("select * from `" . TABLE_PREFIX . "invite` where `id`='{$invite_id}'");
         if ($row) {
             DB::query("update `" . TABLE_PREFIX . "invite` set `fuid`='{$uid}',`fusername`='{$username}' where `id`='{$row['id']}'");
         }
     } else {
         DB::query("insert into `" . TABLE_PREFIX . "invite` (`uid`,`code`,`dateline`,`fuid`,`fusername`,`femail`) values ('{$u}','{$c}','{$timestamp}','{$uid}','{$username}','{$email}')");
     }
     DB::query("update `" . TABLE_PREFIX . "members` set `invite_count`=`invite_count`+1 where `uid`='{$u}'");
     DB::query("update `" . TABLE_PREFIX . "members` set `invite_uid`='{$u}' where `uid`='{$uid}'");
     if ($c && $GLOBALS['_J']['config']['invite_limit'] > 0) {
         $code_invite_count = DB::result_first("select count(*) as code_invite_count from `" . TABLE_PREFIX . "invite` where `uid`='{$u}' and `code`='{$c}'");
         if ($code_invite_count > $GLOBALS['_J']['config']['invite_limit']) {
             $this->register_check_invite($u, 1);
         }
     }
     if ($GLOBALS['_J']['config']['extcredits_enable'] && $u > 0) {
         update_credits_by_action('register', $u);
     }
     return 1;
 }
Пример #10
0
 function DoRegister()
 {
     if (MEMBER_ID != 0 and false == $this->IsAdmin) {
         $this->Messager('您已经是注册用户,无需再注册!', -1);
     }
     $regstatus = jsg_member_register_check_status();
     if ($regstatus['error']) {
         $this->Messager($regstatus['error'], null);
     }
     $message = array();
     $timestamp = time();
     $noemail = 0;
     $sms_ckret = 0;
     if ($this->_sms_register()) {
         $sms_bind_num = $this->Post['sms_bind_num'];
         $sms_bind_key = $this->Post['sms_bind_key'];
         $sms_ckret = sms_check_bind_key($sms_bind_num, $sms_bind_key);
         if ($sms_ckret) {
             $this->Messager($sms_ckret, -1);
         }
         $noemail = jconf::get('sms', 'register_verify', 'noemail');
         if ($noemail) {
             $this->Post['email'] = $sms_bind_num . '@139.com';
         }
     }
     $inviter_member = array();
     $invite_code = $this->Post['invite_code'] ? $this->Post['invite_code'] : $this->Get['invite_code'];
     $check_result = jsg_member_register_check_invite($invite_code);
     if ($regstatus['invite_enable'] && !$regstatus['normal_enable']) {
         if (!$invite_code) {
             $this->Messager("本站目前需要有好友邀请链接才能注册。<br><br>看看<a href=\"?mod=topic&code=top\">达人榜</a>中有没有你认识的人,让他给你发一个好友邀请。", null);
         }
         if (!$check_result) {
             $this->Messager("对不起,您访问的邀请链接不正确或者因邀请数已满而失效,请重新与邀请人索取链接。", null);
         }
     }
     if ($check_result['uid'] > 0) {
         $inviter_member = jsg_member_info($check_result['uid']);
     }
     if (!$inviter_member && $this->Config['register_invite_input']) {
         $inviter_member = jsg_member_info($this->Post['inviter_nickname'], 'nickname');
     }
     $this->Post = array_iconv('UTF-8', $this->Config['charset'], $this->Post, 1);
     $password = $this->Post['password'];
     $email = $this->Post['email'];
     $username = $nickname = $this->Post['nickname'];
     if (strlen($password) < 5) {
         $this->Messager("密码过短,请设置至少5位", -1);
     }
     $uid = jsg_member_register($nickname, $password, $email);
     if ($uid < 1) {
         $regconf = jconf::get('register');
         $rets = array('0' => '【注册失败】有可能是站点关闭了注册功能', '-1' => '帐户/昵称 不合法,含有不允许注册的字符,请尝试更换一个。', '-2' => '帐户/昵称 不允许注册,含有被保留的字符,请尝试更换一个。', '-3' => '帐户/昵称 已经存在了,请尝试更换一个。', '-4' => 'Email 不合法,请输入正确的Email地址。', '-5' => 'Email 不允许注册,请尝试更换一个。', '-6' => 'Email 已经存在了,请尝试更换一个。', '-7' => '您的IP地址 ' . $GLOBALS['_J']['client_ip'] . ' 已经被限制注册了(一个IP地址 ' . $regconf['time_html'] . ' 之内,最多只能注册 ' . $regconf['limit'] . ' 个用户),请稍后再试或联系管理员');
         $this->Messager($rets[$uid], null);
     }
     $datas = array();
     $datas['uid'] = $uid;
     $datas['province'] = $this->Post['province'];
     $datas['city'] = $this->Post['city'];
     if ($this->_sms_register()) {
         $datas['phone'] = $sms_bind_num;
     }
     jtable('members')->update($datas);
     if ($this->_sms_register()) {
         $_sms_info = _sms_client_user($sms_bind_num);
         $username = $username ? $username : $this->Post['username'];
         $_sms_sets = array('uid' => $uid, 'username' => $username, 'bind_key' => 0, 'bind_key_time' => 0, 'try_bind_times' => '+1', 'last_try_bind_time' => $timestamp);
         sms_client_user_update($_sms_sets, $_sms_info);
     }
     if ($inviter_member) {
         $u = $inviter_member['uid'];
         $c = $check_result['code'];
         buddy_add($u, $uid);
         buddy_add($uid, $u);
         if (0 < ($invite_id = $check_result['invite_id'])) {
             $row = DB::fetch_first("select * from `" . TABLE_PREFIX . "invite` where `id`='{$invite_id}'");
             if ($row) {
                 DB::query("update `" . TABLE_PREFIX . "invite` set `fuid`='{$uid}',`fusername`='{$username}' where `id`='{$row['id']}'");
             }
         } else {
             DB::query("insert into `" . TABLE_PREFIX . "invite` (`uid`,`code`,`dateline`,`fuid`,`fusername`,`femail`) values ('{$u}','{$c}','{$timestamp}','{$uid}','{$username}','{$email}')");
         }
         $sql = "update `" . TABLE_PREFIX . "members` set `invite_count`=`invite_count`+1 where `uid`='{$u}'";
         $this->DatabaseHandler->Query($sql);
         $sql = "update `" . TABLE_PREFIX . "members` set `invite_uid`='{$inviter_member['uid']}' where `uid`='{$uid}'";
         $this->DatabaseHandler->Query($sql);
         if ($c && $this->Config['invite_limit'] > 0) {
             $code_invite_count = DB::result_first("select count(*) as code_invite_count from `" . TABLE_PREFIX . "invite` where `uid`='{$u}' and `code`='{$c}'");
             if ($code_invite_count > $this->Config['invite_limit']) {
                 jsg_member_register_check_invite($u, 1);
             }
         }
         if ($this->Config['extcredits_enable'] && $u > 0) {
             update_credits_by_action('register', $u);
         }
     }
     $rets = jsg_member_login_set_status($uid);
     $this->Messager(null, 'index.php');
 }