//if ($session->_s_online_status!=1) { // $session->_s_setOnlineStatus(1, $l->g('online_status_1')); //} if ($session->_s_online_status == 2 || $session->_s_online_status == 3) { $session->_s_setOnlineStatus(1, $l->g('online_status_1')); } foreach ($new_messages as $data) { if (isset($data['body'])) { // Attachments? _pcpin_loadClass('tmpdata'); $tmpdata = new PCPIN_TmpData($session); $tmpdata->_db_getList('user_id = ' . $current_user->id, 'type = 3'); $tmpdata_list = $tmpdata->_db_list; $tmpdata->_db_freeList(); if (!empty($tmpdata_list)) { $tmpdata->deleteUserRecords($current_user->id, 3, 0, true); } $data['body'] = trim($data['body']); if ($data['body'] != '' || !empty($tmpdata_list)) { $type = isset($data['type']) ? $data['type'] : 0; $offline = isset($data['offline']) ? $data['offline'] : 'n'; $target_room_id = isset($data['target_room_id']) ? $data['target_room_id'] : $session->_s_room_id; $target_user_id = isset($data['target_user_id']) ? $data['target_user_id'] : 0; $body = _pcpin_substr($data['body'], 0, $session->_conf_all['message_length_max']); $privacy = isset($data['privacy']) ? $data['privacy'] : 0; $css_properties = isset($data['css_properties']) ? $data['css_properties'] : ''; // Initial state: User must be not global muted $message_ok = $current_user->global_muted_until < date('Y-m-d H:i:s') && $current_user->global_muted_permanently == 'n'; if (empty($type)) { $message_ok = false; continue;
$xmlwriter->setHeaderStatus(1); if ($code == '') { $errortext[] = $l->g('smilie_code_empty_error'); } $tmpdata->_db_getList('id, binaryfile_id', 'user_id = ' . $current_user->id, 'type = 2', 1); if (empty($tmpdata->_db_list)) { $errortext[] = $l->g('smilie_image_empty_error'); } else { $tmpdata_id = $tmpdata->_db_list[0]['id']; $binaryfile_id = $tmpdata->_db_list[0]['binaryfile_id']; $tmpdata->_db_freeList(); } if ($smilie->_db_getList('code = ' . $code, 1)) { $errortext[] = $l->g('smilie_code_already_exists_error'); $smilie->_db_freeList(); } if (empty($errortext)) { // Save smilie if ($smilie->addSmilie($binaryfile_id, $code, $description)) { // Delete temporary data $tmpdata->_db_freeList(); $tmpdata->deleteUserRecords($session->_s_user_id, 2, 0, true); $xmlwriter->setHeaderStatus(0); $xmlwriter->setHeaderMessage($l->g('smilie_added')); } else { $xmlwriter->setHeaderMessage($l->g('error')); } } else { $xmlwriter->setHeaderMessage(implode("\n", $errortext)); } }
/** * 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'); } }
// Image file size larger than allowed $upload_status = array('code' => 400, 'message' => str_replace('[SIZE]', $session->_conf_all['room_img_max_filesize'], $l->g('file_too_large'))); break; } if ($upload_status['code'] === 0) { // Image OK $width = $img_data['width']; $height = $img_data['height']; _pcpin_loadClass('binaryfile'); $binaryfile = new PCPIN_BinaryFile($session); if ($binaryfile->newBinaryFile(file_get_contents($f_data['tmp_name']), $img_data['mime'], $width, $height, 'log')) { $binaryfile_id = $binaryfile->id; if (!empty($binaryfile->id)) { _pcpin_loadClass('tmpdata'); $tmpdata = new PCPIN_TmpData($session); $tmpdata->deleteUserRecords($current_user->id, 1); $tmpdata->addRecord(1, $current_user->id, $binaryfile_id, $filename); } } } break; case 'smilie_image': // New smilie image if ($current_user->is_admin !== 'y') { break; } // Smilie image will be saved into tmpdata table // Check image data $img_data = null; switch (PCPIN_Image::checkImage($img_data, $f_data['tmp_name'], '', 0, 0, 0, false)) { case PCPIN_IMAGE_CHECK_OK:
* This file is part of "PCPIN Chat 6". * * "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/>. */ /** * Delete temporary message attachment * @param int $binaryfile_id Binaryfile ID of the attachment */ if (!isset($binaryfile_id) || !pcpin_ctype_digit($binaryfile_id)) { $binaryfile_id = 0; } _pcpin_loadClass('tmpdata'); $tmpdata = new PCPIN_TmpData($session); if (!empty($current_user->id)) { $xmlwriter->setHeaderStatus(0); $xmlwriter->setHeaderMessage('OK'); if (!empty($binaryfile_id)) { $tmpdata->deleteUserRecords($current_user->id, 3, $binaryfile_id); } }
/** * Put user into/out of a room * @param int $user_id User ID * @param int $target_room_id ID of room where to put user into * @param boolean $skip_msg If TRUE, then system message 115 will be NOT inserted * @param string $stealth_mode "Stealth" mode flag ("y"/"n") * @return boolean TRUE on success or FALSE on error */ function putUser($user_id = 0, $target_room_id = 0, $skip_msg = false, $stealth_mode = 'n') { $ok = false; _pcpin_loadClass('message'); $message = new PCPIN_Message($this); _pcpin_loadClass('session'); $session = new PCPIN_Session($this, '', true); // Get user's session if (!empty($user_id) && $session->_db_getList('_s_user_id = ' . $user_id, 1)) { // Session exists if ($target_room_id != $session->_db_list[0]['_s_room_id']) { if (!empty($session->_db_list[0]['_s_room_id'])) { // Put user out of a room $ok = true; if ($this->_db_getList('users_count', 'id = ' . $session->_db_list[0]['_s_room_id'], 1)) { $this->updateRoom($session->_db_list[0]['_s_room_id'], false, true, null, null, null, null, $this->_db_list[0]['users_count'] - 1, null, null, null, date('Y-m-d H:i:s')); } if (true !== $skip_msg) { $message->addMessage(115, 'n', 0, '', $session->_db_list[0]['_s_room_id'], 0, $user_id . '/' . $session->_db_list[0]['_s_room_id']); } } if (!empty($target_room_id)) { // Put user into a room if ($this->_db_getList('users_count', 'id = ' . $target_room_id, 1)) { $ok = true; $this->updateRoom($target_room_id, false, true, null, null, null, null, $this->_db_list[0]['users_count'] + 1, null, null, null, date('Y-m-d H:i:s')); } else { // Room does not exists $target_room_id = 0; } if (true !== $skip_msg) { $message->addMessage(111, 'n', 0, '', $target_room_id, 0, $user_id . '/' . $target_room_id); } } // Update session $session->_s_updateSession($session->_db_list[0]['_s_id'], false, true, null, null, $target_room_id, null, null, null, null, !empty($target_room_id) ? date('Y-m-d H:i:s') : '', null, null, null, $stealth_mode, null, null, '0000-00-00 00:00:00', ''); if ($session->_db_list[0]['_s_online_status'] != 1) { $session->_db_setObject($session->_db_list[0]); $session->_s_setOnlineStatus(1); } } else { $ok = true; } // Delete temporary message attachments _pcpin_loadClass('tmpdata'); $tmpdata = new PCPIN_TmpData($this); $tmpdata->deleteUserRecords($user_id, 3); } return $ok; }