_pcpin_loadClass('badword'); $badword = new PCPIN_Badword($session); _pcpin_loadClass('disallowed_name'); $disallowed_name = new PCPIN_Disallowed_Name($session); $nicknames_xml = array(); $new_nickname_id = 0; if (empty($profile_user_id) || $profile_user_id != $current_user->id && $current_user->is_admin !== 'y') { $profile_user_id = $current_user->id; } if (!isset($nickname_id) || !is_scalar($nickname_id)) { $nickname_id = 0; } if (!isset($new_nickname) || !is_scalar($new_nickname)) { $new_nickname = ''; } if (!empty($nickname_id) && !$nickname->_db_getList('id', 'id = ' . $nickname_id, 'user_id = ' . $profile_user_id, 1)) { // Nickname does not exists or not belongs to user $nickname_id = 0; } if (!empty($profile_user_id) && !empty($nickname_id)) { $new_nickname = trim($new_nickname); if (!empty($nickname_id) && $new_nickname != '') { $new_nickname = $nickname->optimizeColored('^' . $session->_conf_all['default_nickname_color'] . $new_nickname); $new_nickname_plain = $nickname->coloredToPlain($new_nickname, false); // Check nickname if ($new_nickname_plain == '') { // Nickname is empty $xmlwriter->setHeaderStatus(1); $xmlwriter->setHeaderMessage($l->g('nickname_empty_error')); } elseif (_pcpin_strlen($new_nickname_plain) < $session->_conf_all['nickname_length_min']) { // Nickname is too short
/** * Insert new user into database * @param string $login Login name * @param string $password Password (NOT encoded!!!) * @param string $email E-Mail address * @param int $hide_email Hide E-Mail address? (0: No, 1: Yes) * @param string $guest Flag: "y" if user is a guest, "n" if user was registered * @param string $activation_code If new account activation enabled: Activation code (MD5-encoded) * @param int $language_id Language ID. If empty: language ID from current session will be used * @return boolean TRUE on success or FALSE on error */ function newUser($login, $password = '', $email = '', $hide_email = 0, $guest = 'n', $activation_code = '', $language_id = 0) { $result = false; $this->id = 0; $login = trim($login); $email = trim($email); if ($login != '' && $password != '') { $this->id = 0; $this->login = $login; $this->password = md5($password); $this->password_new = md5(PCPIN_Common::randomString(mt_rand(100, 255))); $this->email = $email; $this->email_new = ''; $this->email_new_date = ''; $this->email_new_activation_code = ''; $this->hide_email = $hide_email; $this->joined = date('Y-m-d H:i:s'); $this->activated = $activation_code == '' ? 'y' : 'n'; $this->activation_code = $activation_code; $this->last_login = ''; $this->previous_login = ''; $this->time_online = 0; $this->date_format = $this->_conf_all['date_format']; $this->last_message_id = 0; $this->moderated_rooms = ''; $this->moderated_categories = ''; $this->is_admin = 'n'; $this->banned_by = 0; $this->banned_by_username = ''; $this->banned_until = ''; $this->banned_permanently = 'n'; $this->ban_reason = ''; $this->muted_users = ''; $this->global_muted_by = 0; $this->global_muted_by_username = ''; $this->global_muted_until = ''; $this->global_muted_permanently = 'n'; $this->global_muted_reason = ''; $this->time_zone_offset = 0; $this->is_guest = $guest; $this->show_message_time = ''; $this->outgoing_message_color = ''; $this->language_id = !empty($language_id) ? $language_id : $this->_s_language_id; $this->allow_sounds = ''; $this->room_selection_view = $this->_conf_all['room_selection_display_type']; // Insert row if ($this->_db_insertObj()) { $result = true; $this->id = $this->_db_lastInsertID(); $this_id = $this->id; // Add new nickname _pcpin_loadClass('nickname'); $nickname = new PCPIN_Nickname($this); if (!$nickname->_db_getList('id', 'nickname_plain = ' . $login, 1)) { $nickname->addNickname($this_id, '^' . $this->_conf_all['default_nickname_color'] . $login); } $this->id = $this_id; } } return $result; }
* * "PCPIN Chat 6" is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * "PCPIN Chat 6" is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ _pcpin_loadClass('nickname'); $nickname = new PCPIN_Nickname($session); if (empty($profile_user_id) || $profile_user_id != $current_user->id && $current_user->is_admin !== 'y') { $profile_user_id = $current_user->id; } if (empty($nickname_id) || !is_scalar($nickname_id)) { $nickname_id = 0; } if (!empty($nickname_id) && $nickname->_db_getList('id,default', 'id = ' . $nickname_id, 'user_id = ' . $profile_user_id, 1)) { // Nickname exists $xmlwriter->setHeaderMessage('OK'); $xmlwriter->setHeaderStatus(0); if ($nickname->_db_list[0]['default'] != 'y') { $nickname->setDefault($nickname_id, $profile_user_id); } $nickname->_db_freeList(); }
$disallowed_name = new PCPIN_Disallowed_Name($session); $nicknames_xml = array(); $new_nickname_id = 0; if (empty($profile_user_id) || $profile_user_id != $current_user->id && $current_user->is_admin !== 'y') { $profile_user_id = $current_user->id; } if (!empty($profile_user_id)) { if (!isset($new_nickname) || !is_scalar($new_nickname)) { $new_nickname = ''; } $new_nickname = trim($new_nickname); $new_nickname = $nickname->optimizeColored('^' . $session->_conf_all['default_nickname_color'] . $new_nickname); $new_nickname_plain = $nickname->coloredToPlain($new_nickname, false); // Check nicknames limit $xmlwriter->setHeaderStatus(0); if ($nickname->_db_getList('COUNT', 'user_id = ' . $profile_user_id)) { if ($nickname->_db_list_count > $session->_conf_all['nicknames_max_count']) { $xmlwriter->setHeaderStatus(1); $xmlwriter->setHeaderMessage(str_replace('[NUMBER]', $session->_conf_all['nicknames_max_count'], $l->g('nicknames_limit_reached'))); } } if ($xmlwriter->get('header_status') == 0) { // Check nickname if ($new_nickname_plain == '') { // Nickname is empty $xmlwriter->setHeaderStatus(1); $xmlwriter->setHeaderMessage($l->g('nickname_empty_error')); } elseif (_pcpin_strlen($new_nickname_plain) < $session->_conf_all['nickname_length_min']) { // Nickname is too short $xmlwriter->setHeaderStatus(1); $xmlwriter->setHeaderMessage(str_replace('[LENGTH]', $session->_conf_all['nickname_length_min'], $l->g('nickname_too_short_error')));