function wp_new_user_notification($user_id, $notify = '') { $user = new WP_User($user_id); $sflogin = sp_get_option('sflogin'); $eol = "\r\n"; $user_login = $user->user_login; $user_email = $user->user_email; $message = ''; $message .= sp_text_noesc('New user registration on your website') . ': ' . get_option('blogname') . $eol . $eol; $message .= sp_text_noesc('Username') . ': ' . $user_login . $eol; $message .= sp_text_noesc('E-mail') . ': ' . $user_email . $eol; $message .= sp_text_noesc('Registration IP') . ': ' . sp_get_ip() . $eol; $address = apply_filters('sph_admin_new_user_email_addrress', get_option('admin_email'), $user_id); $subject = apply_filters('sph_admin_new_user_email_subject', get_option('blogname') . ' ' . sp_text_noesc('New User Registration'), $user_id); $msg = apply_filters('sph_admin_new_user_email_msg', $message, $user_id); sp_send_email($address, $subject, $msg); if ('admin' === $notify || empty($notify)) { return; } # Generate something random for a password reset key. $key = wp_generate_password(20, false); /** This action is documented in wp-login.php */ do_action('retrieve_password_key', $user_login, $key); # Now insert the key, hashed, into the DB. if (empty($wp_hasher)) { require_once ABSPATH . WPINC . '/class-phpass.php'; $wp_hasher = new PasswordHash(8, true); } $hashed = time() . ':' . $wp_hasher->HashPassword($key); global $wpdb; $wpdb->update($wpdb->users, array('user_activation_key' => $hashed), array('user_login' => $user_login)); $mailoptions = sp_get_option('sfnewusermail'); $subject = stripslashes($mailoptions['sfnewusersubject']); $body = stripslashes($mailoptions['sfnewusertext']); if (empty($subject) || empty($body)) { $subject = get_option('blogname') . ' ' . sp_text_noesc('Your username') . $eol . $eol; $body = sp_text_noesc('Username') . ': ' . $user_login . $eol; $body .= sp_text_noesc('Login URL') . ': ' . $sflogin['sfloginemailurl'] . $eol; $body .= sp_text_noesc('Password Reset URL') . ': ' . network_site_url("wp-login.php?action=rp&key={$key}&login="******"wp-login.php?action=rp&key={$key}&login="******"wp-login.php?action=rp&key={$key}&login=" . rawurlencode($user_login), 'login'), $body); $body = str_replace('%NEWLINE%', $eol, $body); } str_replace('<br />', $eol, $body); $address = apply_filters('sph_user_new_user_email_addrress', $user_email, $user_id); $subject = apply_filters('sph_user_new_user_email_subject', get_option('blogname') . ' ' . sp_text_noesc('New User Registration'), $user_id); $msg = apply_filters('sph_user_new_user_email_msg', $body, $user_id, $user_pass); sp_send_email($user_email, $subject, $msg); }
function wp_new_user_notification($user_id, $user_pass = '') { $user = new WP_User($user_id); $sflogin = sp_get_option('sflogin'); $eol = "\r\n"; $user_login = $user->user_login; $user_email = $user->user_email; $message = ''; $message .= sp_text_noesc('New user registration on your website') . ': ' . get_option('blogname') . $eol . $eol; $message .= sp_text_noesc('Username') . ': ' . $user_login . $eol; $message .= sp_text_noesc('E-mail') . ': ' . $user_email . $eol; $message .= sp_text_noesc('Registration IP') . ': ' . sp_get_ip() . $eol; $address = apply_filters('sph_admin_new_user_email_addrress', get_option('admin_email'), $user_id); $subject = apply_filters('sph_admin_new_user_email_subject', get_option('blogname') . ' ' . sp_text_noesc('New User Registration'), $user_id); $msg = apply_filters('sph_admin_new_user_email_msg', $message, $user_id); sp_send_email($address, $subject, $msg); if (empty($user_pass)) { return; } $mailoptions = sp_get_option('sfnewusermail'); $subject = stripslashes($mailoptions['sfnewusersubject']); $body = stripslashes($mailoptions['sfnewusertext']); if (empty($subject) || empty($body)) { $subject = get_option('blogname') . ' ' . sp_text_noesc('Your username and password') . $eol . $eol; $body = sp_text_noesc('Username') . ': ' . $user_login . $eol; $body .= sp_text_noesc('Password') . ': ' . $user_pass . $eol . $eol; $body .= $sflogin['sfloginemailurl'] . $eol; } else { $blogname = get_bloginfo('name'); $subject = str_replace('%USERNAME%', $user_login, $subject); $subject = str_replace('%PASSWORD%', $user_pass, $subject); $subject = str_replace('%BLOGNAME%', $blogname, $subject); $subject = str_replace('%SITEURL%', sp_url(), $subject); $subject = str_replace('%LOGINURL%', $sflogin['sfloginemailurl'], $subject); $body = str_replace('%USERNAME%', $user_login, $body); $body = str_replace('%PASSWORD%', $user_pass, $body); $body = str_replace('%BLOGNAME%', $blogname, $body); $body = str_replace('%SITEURL%', sp_url(), $body); $body = str_replace('%LOGINURL%', $sflogin['sfloginemailurl'], $body); $body = str_replace('%NEWLINE%', $eol, $body); } str_replace('<br />', $eol, $body); $address = apply_filters('sph_user_new_user_email_addrress', $user_email, $user_id); $subject = apply_filters('sph_user_new_user_email_subject', get_option('blogname') . ' ' . sp_text_noesc('New User Registration'), $user_id); $msg = apply_filters('sph_user_new_user_email_msg', $body, $user_id, $user_pass); sp_send_email($user_email, $subject, $msg); }
function sp_set_cache_type($type) { global $spThisUser; $t = array(); switch ($type) { case 'search': case 'url': case 'bookmark': $t['datakey'] = sp_get_ip(); $t['lifespan'] = 3600; $t['deleteBefore'] = true; $t['deleteAfter'] = false; break; case 'group': $t['datakey'] = $spThisUser->ID; $t['lifespan'] = 3600; $t['deleteBefore'] = false; $t['deleteAfter'] = false; break; case 'post': $t['datakey'] = sp_get_ip(); $t['lifespan'] = 120; $t['deleteBefore'] = true; $t['deleteAfter'] = true; break; case 'topic': $t['datakey'] = sp_get_ip(); $t['lifespan'] = 120; $t['deleteBefore'] = true; $t['deleteAfter'] = false; break; case 'floodcontrol': $t['datakey'] = sp_get_ip(); $t['lifespan'] = sp_get_option('floodcontrol'); $t['deleteBefore'] = true; $t['deleteAfter'] = false; break; } $t['datakey'] .= '*' . $type; return $t; }
function __construct($ident = 0, $current = false, $small = false) { global $spStatus, $spGlobals; $id = 0; if (is_numeric($ident)) { $w = "ID={$ident}"; } else { if ($ident != false) { $w = "user_login='******'"; } } if ($ident) { # Users data $d = spdb_table(SFUSERS, $w, 'row'); if ($d) { $this->ID = $d->ID; $id = $d->ID; } } $includeList = spUser_build_filter_list(); if ($id) { # Others $this->member = true; $this->guest = 0; $this->guest_name = ''; $this->guest_email = ''; $this->offmember = false; $this->usertype = 'User'; # Users data foreach ($d as $key => $item) { if (array_key_exists($key, $includeList)) { $this->{$key} = $item; } } $this->user_registered = sp_member_registration_to_server_tz($this->user_registered); # usermeta data $d = spdb_table(SFUSERMETA, "user_id={$id}"); if ($d) { foreach ($d as $m) { $t = $m->meta_key; if (array_key_exists($t, $includeList)) { $this->{$t} = maybe_unserialize($m->meta_value); } } } # If awaiting installation then dive out now to avoid errors if ($spStatus == 'Install') { return; } # sfmembers data $d = spdb_table(SFMEMBERS, "user_id={$id}", 'row'); #check for ghost user if (empty($d)) { #create the member sp_create_member_data($id); $d = spdb_table(SFMEMBERS, "user_id={$id}", 'row'); } if ($d) { foreach ($d as $key => $item) { if ($key == 'admin_options' && !empty($item)) { $opts = unserialize($item); foreach ($opts as $opt => $set) { $this->{$opt} = $set; } } else { if ($key == 'user_options' && !empty($item)) { $opts = unserialize($item); foreach ($opts as $opt => $set) { $this->{$opt} = $set; } } else { if ($key == 'lastvisit') { $this->lastvisit = $item; } else { $this->{$key} = maybe_unserialize($item); } } } } } # Check for new post list size if (!isset($this->unreadposts) || empty($this->unreadposts)) { $controls = sp_get_option('sfcontrols'); $this->unreadposts = empty($controls['sfunreadposts']) ? 50 : $controls['sfunreadposts']; } # usertype for moderators if ($this->moderator) { $this->usertype = 'Moderator'; } # check for super admins and make admin a moderator as well if ($this->admin || is_multisite() && is_super_admin($id)) { $this->admin = true; $this->moderator = true; $this->usertype = 'Admin'; $ins = sp_get_option('spInspect'); if (!empty($ins) && array_key_exists($id, $ins)) { $this->inspect = $ins[$id]; } else { $this->inspect = ''; } } # plugins can add iterms for members... if (!$small) { do_action_ref_array('sph_user_class_member', array(&$this)); } else { do_action_ref_array('sph_user_class_member_small', array(&$this)); } } else { # some basics for guests $this->ID = 0; $this->guest = true; $this->member = 0; $this->admin = false; $this->moderator = false; $this->display_name = 'guest'; $this->guest_name = ''; $this->guest_email = ''; $this->usertype = 'Guest'; $this->offmember = sp_check_unlogged_user(); $this->timezone = 0; $this->timezone_string = ''; $this->posts = 0; $this->avatar = ''; $this->user_email = ''; $this->auths = sp_get_option('sf_guest_auths'); $this->memberships = sp_get_option('sf_guest_memberships'); # plugins can add iterms for guests... if (!$small) { do_action_ref_array('sph_user_class_guest', array(&$this)); } else { do_action_ref_array('sph_user_class_guest_small', array(&$this)); } } # Only perform this last section if forum is operational if ($spStatus == 'ok') { # Ranking $this->rank = sp_get_user_forum_rank($this->usertype, $id, $this->posts); $this->special_rank = $this->member ? sp_get_user_special_ranks($id) : array(); # if no memberships rebuild them and save if (empty($this->memberships)) { $memberships = array(); if (!empty($id)) { if (!$this->admin) { # get the usergroup memberships for the user and save in sfmembers table $memberships = sp_get_user_memberships($id); sp_update_member_item($id, 'memberships', $memberships); } } else { # user is a guest or unassigned member so get the global permissions from the guest usergroup and save as option $value = sp_get_sfmeta('default usergroup', 'sfguests'); $memberships[] = spdb_table(SFUSERGROUPS, 'usergroup_id=' . $value[0]['meta_value'], 'row', '', '', ARRAY_A); sp_update_option('sf_guest_memberships', $memberships); } # put in the data $this->memberships = $memberships; } # if no auths rebuild them and save if (empty($this->auths)) { $this->auths = sp_rebuild_user_auths($id); } } $this->ip = sp_get_ip(); $this->trackid = -1; # Things to do if user is current user if ($current) { # Set up editor type $spGlobals['editor'] = 0; # for a user... if ($this->member && !empty($this->editor)) { $spGlobals['editor'] = $this->editor; } # and if not defined or is for a guest... if ($spGlobals['editor'] == 0) { $defeditor = sp_get_option('speditor'); if (!empty($defeditor)) { $spGlobals['editor'] = $defeditor; } } # final check to ensure selected editor type is indeed available if ($spGlobals['editor'] == 0 || $spGlobals['editor'] == 1 && !defined('RICHTEXT') || $spGlobals['editor'] == 2 && !defined('HTML') || $spGlobals['editor'] == 3 && !defined('BBCODE')) { $spGlobals['editor'] = PLAINTEXT; if (defined('BBCODE')) { $spGlobals['editor'] = BBCODE; } if (defined('HTML')) { $spGlobals['editor'] = HTML; } if (defined('RICHTEXT')) { $spGlobals['editor'] = RICHTEXT; } } # Grab any notices present if ($this->guest && !empty($this->guest_email)) { $this->user_notices = spdb_table(SFNOTICES, "guest_email='" . $this->guest_email . "'", '', $order = 'notice_id'); } elseif ($this->member && !empty($this->user_email)) { $this->user_notices = spdb_table(SFNOTICES, "user_id=" . $this->ID, '', $order = 'notice_id'); } # plugins can add iterms for the current user (so no small allowed here) do_action_ref_array('sph_current_user_class', array(&$this)); } # Finally filter the data for display foreach ($includeList as $item => $filter) { if (property_exists($this, $item)) { $this->{$item} = spUser_filter_item($this->{$item}, $filter); } } # allow plugins to add items to user class - regardless small or otherwise, current or otherwise do_action_ref_array('sph_user_class', array(&$this)); }
} # Both if ($spThisUser->guest) { if (!empty($_POST['guestname'])) { $p->newpost['guestname'] = $_POST['guestname']; } if (!empty($_POST['guestemail'])) { $p->newpost['guestemail'] = $_POST['guestemail']; } } else { $p->newpost['postername'] = $spThisUser->display_name; $p->newpost['posteremail'] = $spThisUser->user_email; $p->newpost['userid'] = $spThisUser->ID; } $p->newpost['postcontent'] = $_POST['postitem']; $p->newpost['posterip'] = sp_get_ip(); if (isset($_POST['topiclock'])) { $p->newpost['topicstatus'] = 1; } if (!empty($_POST['editTimestamp'])) { $yy = sp_esc_int($_POST['tsYear']); $mm = sp_esc_int($_POST['tsMonth']); $dd = sp_esc_int($_POST['tsDay']); $hh = sp_esc_int($_POST['tsHour']); $mn = sp_esc_int($_POST['tsMinute']); $ss = sp_esc_int($_POST['tsSecond']); $dd = $dd > 31 ? 31 : $dd; $hh = $hh > 23 ? $hh - 24 : $hh; $mn = $mn > 59 ? $mn - 60 : $mn; $ss = $ss > 59 ? $ss - 60 : $ss; $p->newpost['postdate'] = sprintf('%04d-%02d-%02d %02d:%02d:%02d', $yy, $mm, $dd, $hh, $mn, $ss);
function sp_track_login() { # if user was logged as guest before logging in, remove the guest entry $ip = sp_get_ip(); spdb_query("DELETE FROM " . SFTRACK . " WHERE trackname='" . $ip . "'"); }