/** * Delete attachment * @param int $id Optional. Attachment ID * @param int $message_id Optional. Message ID * @return boolean TRUE on success or FALSE on error */ function deleteAttachment($id = 0, $message_id = 0) { $result = false; _pcpin_loadClass('binaryfile'); $binaryfile = new PCPIN_BinaryFile($this); if (!empty($id) && $this->_db_getList('binaryfile_id', 'id = ' . $id, 1)) { $result = true; $binaryfile->deleteBinaryFile($this->_db_list[0]['binaryfile_id']); $this->_db_deleteRow($id); } elseif (!empty($message_id) && $this->_db_getList('id,binaryfile_id', 'message_id = ' . $message_id)) { $result = true; $ids = $this->_db_list; foreach ($ids as $data) { $binaryfile->deleteBinaryFile($data['binaryfile_id']); $this->_db_deleteRow($data['id']); } } $this->_db_freeList(); return $result; }
$msg->addMessage(10110, 'n', 0, $l->g('server'), $session->_s_room_id, 0, $current_user->id . '/0/' . $session->_conf_all['flood_protection_mute_time'] / 60 . '/' . $l->g('flooding'), date('Y-m-d H:i:s'), 0, ''); $last_sent_message_repeats_count = 0; $last_sent_message_hash = ''; break; // Ignore further messages } else { // Add message to database $last_sent_message_time = time(); $msg->addMessage($type, $offline, $current_user->id, $current_nickname, $target_room_id, $target_user_id, $body, date('Y-m-d H:i:s'), $privacy, $css_properties); // Attachments? _pcpin_loadClass('attachment'); $attachment = new PCPIN_Attachment($session); _pcpin_loadClass('message_log_attachment'); $message_log_attachment = new PCPIN_Message_Log_Attachment($session); _pcpin_loadClass('binaryfile'); $binaryfile = new PCPIN_BinaryFile($session); if (!empty($tmpdata_list)) { foreach ($tmpdata_list as $tmpdata_data) { $attachment->addAttachment($msg->id, $tmpdata_data['binaryfile_id'], $tmpdata_data['filename']); if (!empty($session->_conf_all['logging_period']) && $binaryfile->_db_getList('body,size,mime_type', 'id = ' . $tmpdata_data['binaryfile_id'], 1)) { $message_log_attachment->addLogRecord($msg->id, $tmpdata_data['filename'], $binaryfile->_db_list[0]['body'], $binaryfile->_db_list[0]['size'], $binaryfile->_db_list[0]['mime_type']); $binaryfile->_db_freeList(); } } } } } } } } }
/** * Get list of gallery avatars * @return array */ function getGalleryAvatars() { $avatars = array(); _pcpin_loadClass('binaryfile'); $binaryfile = new PCPIN_BinaryFile($this); if ($this->_db_getList('id, primary, binaryfile_id', 'user_id = 0', 'id ASC')) { foreach ($this->_db_list as $data) { if ($binaryfile->_db_getList('width, height', 'id = ' . $data['binaryfile_id'])) { $data['width'] = $binaryfile->_db_list[0]['width']; $data['height'] = $binaryfile->_db_list[0]['height']; $avatars[] = $data; } } $this->_db_freeList(); } return $avatars; }
* along with this program. If not, see <http://www.gnu.org/licenses/>. */ /** * Load and output a binary file * @param int $b_id ID of the binary file * @param int $b_x If file is an image: Desired image width. If empty, image will be not resized. * @param int $b_y If file is an image: Desired image height. If empty, image will be not resized. * @param int $bg_r If file is an image and will be resized: Desired red component of image background (0..255). Default value is taken from configuration. * @param int $bg_g If file is an image and will be resized: Desired green component of image background (0..255). Default value is taken from configuration. * @param int $bg_b If file is an image and will be resized: Desired blue component of image background (0..255). Default value is taken from configuration. */ // Use cache (for future purposes) $cache_expires = 31536000; // Cache: 365 days _pcpin_loadClass('binaryfile'); $binaryfile = new PCPIN_BinaryFile($session); if (!empty($b_id) && is_scalar($b_id) && $binaryfile->_db_getList('protected, mime_type, size, body', 'id = ' . $b_id, 1)) { if ($binaryfile->_db_list[0]['protected'] != '') { // Binaryfile is protected $protection_parts = explode('/', $binaryfile->_db_list[0]['protected']); foreach ($protection_parts as $part) { switch ($part) { case 'log': if (empty($current_user->id)) { die; } break; case 'reg': if ($current_user->is_guest == 'y') { die; }
$upload_status = array('code' => 100, 'message' => $l->g('file_upload_error')); break; case PCPIN_IMAGE_CHECK_ERROR_MIME: // MIME not allowed // MIME not allowed case PCPIN_IMAGE_CHECK_ERROR_NOT_IMAGE: // File is not an image or has incompatible format $upload_status = array('code' => 200, 'message' => $l->g('image_type_not_allowed')); 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, '')) { $binaryfile_id = $binaryfile->id; if (!empty($binaryfile->id)) { _pcpin_loadClass('tmpdata'); $tmpdata = new PCPIN_TmpData($session); $tmpdata->_db_deleteRowMultiCond(array('user_id' => $current_user->id, 'type' => 2)); $tmpdata->addRecord(2, $current_user->id, $binaryfile_id, $filename); } } } break; } } } _pcpin_loadClass('pcpintpl');
* 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/>. */ if (function_exists('debug_backtrace')) { $_pcpin_dbt = debug_backtrace(); if (is_array($_pcpin_dbt) && empty($_pcpin_dbt[0])) { die('Access denied'); } unset($_pcpin_dbt); } _pcpin_loadClass('binaryfile'); $binaryfile = new PCPIN_BinaryFile($session); _pcpin_loadClass('avatar'); $avatar = new PCPIN_Avatar($session); _pcpin_loadClass('room'); $room = new PCPIN_Room($session); _pcpin_loadClass('category'); $category = new PCPIN_Category($session); if (PCPIN_SLAVE_MODE && !empty($_pcpin_slave_userdata) && !empty($session) && is_object($session)) { $language_id = $_pcpin_slave_userdata['language']; if ($_pcpin_slave_userdata['is_guest'] !== 'n') { // User is guest $guest_login = 1; } else { // Registered user // Check user if ($current_user->_db_getList('login = '******'login'], 1)) {
* "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('room'); $room = new PCPIN_Room($session); _pcpin_loadClass('category'); $category = new PCPIN_Category($session); _pcpin_loadClass('tmpdata'); $tmpdata = new PCPIN_TmpData($session); _pcpin_loadClass('binaryfile'); $binaryfile = new PCPIN_BinaryFile($session); if (!isset($room_id) || !pcpin_ctype_digit($room_id)) { $room_id = 0; } if (!isset($action) || !is_scalar($action)) { $action = ''; } if (!isset($dir) || !pcpin_ctype_digit($dir)) { $dir = 0; } if (!isset($category_id) || !pcpin_ctype_digit($category_id)) { $category_id = 0; } if (!isset($name) || !is_scalar($name)) { $name = ''; }
/** * Delete smilie * @param int $id Smilie ID * @return boolean TRUE on success or FALSE on error */ function deleteSmilie($id) { $result = false; if (!empty($id) && $this->_db_getList('binaryfile_id', 'id =# ' . $id, 1)) { $result = true; $binaryfile_id = $this->_db_list[0]['binaryfile_id']; $this->_db_freeList(); // Delete binary file _pcpin_loadClass('binaryfile'); $binaryfile = new PCPIN_BinaryFile($this); $binaryfile->deleteBinaryFile($binaryfile_id); // Delete smilie $this->_db_deleteRow($id); } return $result; }
/** * 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; }
/** * Delete all records owned by user * @param int $user_id Avatar owner' User ID * @param int $type Optional. Data type. * @param int $binaryfile_id Optional. Binaryfile ID. * @param boolean $keep_binary Optional. If TRUE, then binaryfile will be not deleted. */ function deleteUserRecords($user_id = 0, $type = 0, $binaryfile_id = 0, $keep_binary = false) { _pcpin_loadClass('binaryfile'); $binaryfile = new PCPIN_BinaryFile($this); if (!empty($user_id)) { if (empty($type)) { $this->_db_getList('id,binaryfile_id', 'user_id = ' . $user_id); } else { $this->_db_getList('id,binaryfile_id', 'user_id = ' . $user_id, 'type = ' . $type); } if (!empty($this->_db_list)) { $list = $this->_db_list; $this->_db_freeList(); foreach ($list as $data) { if (empty($binaryfile_id) || $binaryfile_id == $data['binaryfile_id']) { if (true !== $keep_binary) { // Delete binary file $binaryfile->deleteBinaryFile($data['binaryfile_id']); } // Delete record $this->_db_deleteRow($data['id']); } } } } }