/** * Set user avatar from Avatar Gallery * @param int $user_id User ID * @param int $avatar_id Avatar ID * @return boolean TRUE on success or FALSE on error */ function setAvatarFromGallery($user_id = 0, $avatar_id = 0) { $result = false; if (!empty($user_id) && !empty($avatar_id) && $this->_db_getList('binaryfile_id', 'id = ' . $avatar_id, 'user_id = 0', 1)) { // Avatar exists $binaryfile_id = $this->_db_list[0]['binaryfile_id']; _pcpin_loadClass('user'); $user = new PCPIN_User($this); if ($user->_db_getList('id', 'id = ' . $user_id, 1)) { // User exists $user->_db_freeList(); // Does user has primary avatar if ($this->_db_getList('id', 'user_id = ' . $user_id, 'primary = y', 1)) { // There is already one primary avatar $this->primary = 'n'; $this->_db_freeList(); } else { // This avatar will be primary $this->primary = 'y'; } // Insert avatar $this->id = 0; $this->user_id = $user_id; $this->binaryfile_id = $binaryfile_id; $result = $this->_db_insertObj(); } } return $result; }
if (!empty($preselect_language)) { break; } } } } if (empty($preselect_language)) { $preselect_language = $session->_conf_all['default_language']; } $l->setLanguage($preselect_language); $message = $l->g('access_denied'); if (!isset($activation_code) || !is_scalar($activation_code)) { $activation_code = ''; } _pcpin_loadClass('user'); $user = new PCPIN_User($session); _pcpin_loadClass('message'); $msg = new PCPIN_Message($session); _pcpin_loadClass('pcpintpl'); $tpl = new PcpinTpl(); $tpl->setBasedir('./tpl'); $tpl->readTemplatesFromFile('./dummy.tpl'); if ($activation_code != '') { if (isset($activate_email)) { // New email address activation if ($user->_db_getList('email_new != ', 'email_new_activation_code = ' . md5($activation_code), 1)) { // Requested email address found and activation code is OK $user->_db_setObject($user->_db_list[0]); $user->email = $user->email_new; $user->email_new = ''; $user->email_new_date = '';
/** * Delete category and all contained rooms * @param int $id Category ID * @return boolean TRUE on success or FALSE on error */ function deleteCategory($id = 0) { $result = false; if (!empty($id) && $this->_db_getList('id = ' . $id, 1)) { // Are there rooms in this category? _pcpin_loadClass('room'); $room = new PCPIN_Room($this); if ($room->_db_getList('id', 'category_id = ' . $id)) { // Delete category rooms $rooms = $room->_db_list; $room->_db_freeList(); foreach ($rooms as $room_data) { $room->deleteRoom($room_data['id']); } } // Update "moderated_categories" field by category moderators $moderators = $this->getModerators($id); if (!empty($moderators)) { _pcpin_loadClass('user'); $user = new PCPIN_User($this); foreach ($moderators as $data) { $user->_db_updateRow($data['id'], 'id', array('moderated_categories' => trim(str_replace(',' . $id . ',', ',', ',' . $data['moderated_categories'] . ','), ','))); } } // Delete category $this->_db_deleteRow($id); } return $result; }
* * "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('message'); $msg = new PCPIN_Message($session); if (empty($profile_user_id) || $profile_user_id != $current_user->id && $current_user->is_admin !== 'y') { $profile_user_id = $current_user->id; } if ($profile_user_id != $current_user->id) { $profile_user = new PCPIN_User($session); $profile_user->_db_loadObj($profile_user_id); } else { $profile_user =& $current_user; } $activation_required = ''; if (!empty($profile_user_id)) { if (!isset($email) || !is_scalar($email)) { $email = ''; } else { $email = _pcpin_substr(trim($email), 0, 255); } if (!PCPIN_Common::checkEmail($email, $session->_conf_all['email_validation_level'])) { // Email invalid $xmlwriter->setHeaderStatus(1); $xmlwriter->setHeaderMessage($l->g('email_invalid'));
* * "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/>. */ // Initialize require_once './init.inc.php'; // Get session handler $session =& $_pcpin_init_session; unset($_pcpin_init_session); _pcpin_loadClass('user'); $current_user = new PCPIN_User($session); // Slave mode: need login? if (PCPIN_SLAVE_MODE && empty($session->_s_user_id) && empty($b_id) && empty($external_url) && empty($load_banner) && !defined('PCPIN_NO_SESSION')) { // User is not logged in yet require './mods/slave_mode.inc.php'; } // Current user data $_is_moderator = false; $current_nickname = ''; $current_room_name = ''; if (!empty($session->_s_user_id)) { $current_user->_db_loadObj($session->_s_user_id); if (!empty($session->_s_room_id) && $current_user->moderated_rooms != '') { $_is_moderator = false !== strpos(',' . $current_user->moderated_rooms . ',', ',' . $session->_s_room_id . ','); } _pcpin_loadClass('nickname');
/** * Log the session out and deactivate it * @param boolean $skip_msg If TRUE, then system messages 105 and 115 will be NOT inserted */ function _s_logOut($skip_msg = false) { if ($this->_s_id != '') { if (!empty($this->_s_user_id)) { _pcpin_loadClass('message'); $msg = new PCPIN_Message($this); if (!empty($this->_s_room_id)) { // Session owner was in a room _pcpin_loadClass('room'); $room = new PCPIN_Room($this); $room->putUser($this->_s_user_id, 0, $skip_msg); } // Delete invitations _pcpin_loadClass('invitation'); $invitation = new PCPIN_Invitation($this); $invitation->deleteUserInvitations($this->_s_user_id); // Delete temporary data _pcpin_loadClass('tmpdata'); $tmpdata = new PCPIN_TmpData($this); $tmpdata->deleteUserRecords($this->_s_user_id); // Update session owner stats _pcpin_loadClass('user'); $user = new PCPIN_User($this); if ($user->_db_loadObj($this->_s_user_id)) { if ($user->is_guest == 'y') { // User was a guest. Delete record. $user->deleteUser($this->_s_user_id); } else { // Update registered user stats $user->time_online = $user->calculateOnlineTime($user->id); $user->last_message_id = $user->last_message_id < $this->_s_last_message_id ? $this->_s_last_message_id : $user->last_message_id; $user->_db_updateObj($user->id); } } if (true !== $skip_msg) { $msg->addMessage(105, 'n', 0, '', 0, 0, $this->_s_user_id); } } // Delete session from database $this->_db_deleteRow($this->_s_id, '_s_id'); } }
} else { $xmlwriter->setHeaderMessage($l->g('abuse_report_sent')); $xmlwriter->setHeaderStatus(0); $moderators = $room->getModerators($session->_s_room_id); if (empty($moderators)) { // Room has no moderators. Admin(s) will receive an abuse then. $moderators = $current_user->getAdmins(); } _pcpin_loadClass('nickname'); $nickname = new PCPIN_Nickname($session); $old_language_id = $l->id; // Create message body $body = $current_user->id . '/' . $session->_s_room_id . '/' . $abuse_category * 1 . '/' . trim(str_replace('/', ' ', $abuse_nickname)) . '/' . trim($abuse_description); foreach ($moderators as $data) { _pcpin_loadClass('user'); $tmp_user = new PCPIN_User($session); $tmp_user->_db_loadObj($data['id']); if (!empty($data['is_online'])) { // User is online $msg->addMessage(4001, 'n', $session->_s_user_id, $current_nickname, 0, $data['id'], $body, date('Y-m-d H:i:s'), 2); } else { // Add offline message // $msg->addMessage(4001, 'y', $session->_s_user_id, $current_nickname, 0, $data['id'], $body, date('Y-m-d H:i:s'), 2); } // Load language if ($tmp_user->language_id != $l->id) { if (true !== $l->setLanguage($tmp_user->language_id) && (empty($session->_conf_all['default_language']) || true !== $l->setLanguage($session->_conf_all['default_language']))) { $l->setLanguage($old_language_id); } } $violation_category = '';
* along with this program. If not, see <http://www.gnu.org/licenses/>. */ if (!isset($target_user_id) || !is_scalar($target_user_id)) { $target_user_id = 0; } if (!isset($action)) { $action = 0; } if (empty($post_control_message)) { $post_control_message = false; } if (empty($profile_user_id) || $profile_user_id != $current_user->id && $current_user->is_admin !== 'y') { $profile_user_id = $current_user->id; } if ($profile_user_id != $current_user->id) { $action_user = new PCPIN_User($session); $action_user->_db_loadObj($profile_user_id); } else { $action_user =& $current_user; } if (!empty($action_user->id)) { $xmlwriter->setHeaderMessage('OK'); $xmlwriter->setHeaderStatus(0); if (!empty($target_user_id) && ($action == 1 || $action == 0)) { $action_user->muteUnmuteLocally($target_user_id, $action); if (!empty($post_control_message)) { _pcpin_loadClass('message'); $message = new PCPIN_Message($session); $message->addMessage(10200, 'n', $current_user->id, $current_nickname, 0, $action_user->id, $action_user->id, '', 1, ''); } }
/** * Global mute/unmute user * @param int $user_id User ID * @param int $action Action: (1: mute, 0: unmute) * @param int $mute_time If user will be muted: For how many minutes (0 means permanent mute) * @param string $mute_reason If user will be muted: Mute reason (optional) * @param int $muted_by_user_id If user will be muted: ID of user who muted him * @param int $muted_by_username If user will be muted: Nickname of user who muted him * @return boolean TRUE on success or FALSE on error */ function globalMuteUnmute($user_id, $action = 1, $mute_time = 0, $mute_reason = '', $muted_by_user_id = 0, $muted_by_username = '') { $result = false; _pcpin_loadClass('user'); $user = new PCPIN_User($this); if (!empty($user_id) && $user->_db_getList('id,global_muted_until,global_muted_permanently', 'id = ' . $user_id, 1)) { if ($action == 0) { // Unmute user $result = true; if ($user->_db_list[0]['global_muted_permanently'] == 'y' || $user->_db_list[0]['global_muted_until'] > '0000-00-00 00:00:00') { // User is muted $result = $user->_db_updateRow($user_id, 'id', array('global_muted_until' => '', 'global_muted_permanently' => 'n', 'global_muted_reason' => '')); } } elseif ($action == 1) { // Mute user $mute_reason = trim($mute_reason); $result = $user->_db_updateRow($user_id, 'id', array('global_muted_until' => empty($mute_time) ? '' : date('Y-m-d H:i:s', time() + $mute_time * 60), 'global_muted_permanently' => empty($mute_time) ? 'y' : 'n', 'global_muted_reason' => trim($mute_reason), 'global_muted_by' => trim($muted_by_user_id), 'global_muted_by_username' => trim($muted_by_username))); } } return $result; }
* 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/>. */ define('PCPIN_ADMIN_ACCESS', true); // Initialize require_once './init.inc.php'; // Get session handler $session =& $_pcpin_init_session; unset($_pcpin_init_session); // Current user data _pcpin_loadClass('user'); $current_user = new PCPIN_User($session); if (!empty($session->_s_user_id)) { $current_user->_db_loadObj($session->_s_user_id); if ($current_user->is_admin !== 'y') { $session->_s_logOut(true); header('Location: ' . PCPIN_FORMLINK); die; } } /** * Receive version update information */ if (!empty($sk) && !empty($nv) && !empty($dl)) { _pcpin_loadClass('version'); $version = new PCPIN_Version($session); if ($version->_db_getList(1)) {
// Remember current working directory $pcpin_old_cwd = getcwd(); // Switch to new working directory chdir(dirname(__FILE__)); // Remember current error reporting settings $_pcpin_old_error_reporting = error_reporting(); $_pcpin_old_display_errors = ini_get('display_errors'); // Do not create new session if (!defined('PCPIN_NO_SESSION')) { define('PCPIN_NO_SESSION', true); } // Initialize require './init.inc.php'; // Load required classes _pcpin_loadClass('user'); $_pcpin_user = new PCPIN_User($_pcpin_init_session); _pcpin_loadClass('nickname'); $_pcpin_nickname = new PCPIN_Nickname($_pcpin_init_session); _pcpin_loadClass('room'); $_pcpin_room = new PCPIN_Room($_pcpin_init_session); // Initialize vars $_pcpin_online_users_count = 0; $_pcpin_online_users = array(); $_pcpin_online_users_colored = array(); $_pcpin_registered_users_count = 0; $_pcpin_registered_users = array(); $_pcpin_registered_users_colored = array(); $_pcpin_rooms_count = 0; $_pcpin_rooms = array(); // Get full memberlist $_pcpin_memberlist = $_pcpin_user->getMemberlist(false, 0, 0, 1, 0);
/** * Delete room * @param int $id Room ID * @return boolean TRUE on success or FALSE on error */ function deleteRoom($id = 0) { $result = false; if (!empty($id) && $this->_db_getList('background_image', 'id = ' . $id, 1)) { if ($result = $this->_db_deleteRow($id)) { _pcpin_loadClass('binaryfile'); $binaryfile = new PCPIN_BinaryFile($this); $binaryfile->deleteBinaryFile($this->_db_list[0]['background_image']); } $this->_db_freeList(); // Update "moderated_rooms" field by category and room moderators $moderators = $this->getModerators($id); if (!empty($moderators)) { _pcpin_loadClass('user'); $user = new PCPIN_User($this); foreach ($moderators as $data) { $user->_db_updateRow($data['id'], 'id', array('moderated_rooms' => trim(str_replace(',' . $id . ',', ',', ',' . $data['moderated_rooms'] . ','), ','))); } } } return $result; }
/** * Get default nickname. If user has no nicknames, his username will be returned. * @param int $user_id User ID * @return string */ function getDefaultNickname($user_id) { $nickname = ''; if (!empty($user_id)) { if (!$this->_db_getList('nickname', 'user_id = ' . $user_id, 'default = y', 1)) { $this->_db_getList('nickname', 'user_id = ' . $user_id, 1); } if (!empty($this->_db_list)) { $nickname = $this->_db_list[0]['nickname']; $this->_db_freeList(); } if ($nickname == '') { // User has no nicknames, get username $usr = new PCPIN_User($this); if ($usr->_db_getList('login', 'id =# ' . $user_id, 1)) { $nickname = $usr->_db_list[0]['login']; $usr->_db_freeList(); } } } return $nickname; }