* 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('avatar'); $avatar = new PCPIN_Avatar($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($avatar_id) || !is_scalar($avatar_id)) { $avatar_id = 0; } if (!empty($profile_user_id) && !empty($avatar_id) && $avatar->_db_getList('id,binaryfile_id', 'id = ' . $avatar_id, 'user_id = 0', 1)) { $binaryfile_id = $avatar->_db_list[0]['binaryfile_id']; // Check avatars limit $avatar->_db_getList('COUNT', 'user_id = ' . $profile_user_id); if ($avatar->_db_list_count >= $session->_conf_all['avatars_max_count']) { // Limit reached $xmlwriter->setHeaderMessage(str_replace('[NUMBER]', $session->_conf_all['avatars_max_count'], $l->g('avatars_limit_reached'))); $xmlwriter->setHeaderStatus(1); } elseif ($avatar->_db_getList('id', 'user_id = ' . $profile_user_id, 'binaryfile_id = ' . $binaryfile_id, 1)) { // Selected avatar already exists $xmlwriter->setHeaderMessage($l->g('avatar_already_exists')); $xmlwriter->setHeaderStatus(1); } else { // Set avatar if ($avatar->setAvatarFromGallery($profile_user_id, $avatar_id)) { $xmlwriter->setHeaderMessage('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/>. */ if (empty($avatar_id) || !pcpin_ctype_digit($avatar_id)) { $avatar_id = 0; } _pcpin_loadClass('avatar'); $avatar = new PCPIN_Avatar($session); if (!empty($current_user->id) && $current_user->is_admin === 'y' && !empty($avatar_id) && $avatar->_db_getList('primary', 'id = ' . $avatar_id, 'user_id = 0', 1)) { // Avatar exists $xmlwriter->setHeaderMessage('OK'); $xmlwriter->setHeaderStatus(0); if ($avatar->_db_list[0]['primary'] != 'y') { $avatar->setDefaultAvatarGallery($avatar_id); } $avatar->_db_freeList(); }
* 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('avatar'); $avatar = new PCPIN_Avatar($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($avatar_id) || !is_scalar($avatar_id)) { $avatar_id = 0; } if (!empty($avatar_id) && $avatar->_db_getList('id,primary', 'id = ' . $avatar_id, 'user_id = ' . $profile_user_id, 1)) { // Avatar exists and belongs to user $xmlwriter->setHeaderMessage('OK'); $xmlwriter->setHeaderStatus(0); if ($avatar->_db_list[0]['primary'] != 'y') { $avatar->setPrimaryAvatar($profile_user_id, $avatar_id); _pcpin_loadClass('message'); $msg = new PCPIN_Message($session); $msg->addMessage(1010, 'n', 0, '', $session->_s_room_id, 0, $profile_user_id); } $avatar->_db_freeList(); }
$filename = $f_data['name']; $upload_status = array('code' => 10, 'message' => $l->g('error')); if ($f_data['error'] == UPLOAD_ERR_NO_FILE || $f_data['error'] == UPLOAD_ERR_OK && empty($f_data['size'])) { // No file was uploaded or file is empty $upload_status = array('code' => -1, 'message' => $l->g('file_upload_error')); } elseif ($f_data['error'] != UPLOAD_ERR_OK) { // File upload error $upload_status = array('code' => 100, 'message' => $l->g('file_upload_error')); } else { switch ($f_target) { case 'avatar': // New Avatar // Check avatars number limit _pcpin_loadClass('avatar'); $avatar = new PCPIN_Avatar($session); $avatar->_db_getList('COUNT', 'user_id = ' . $profile_user_id); if ($avatar->_db_list_count >= $session->_conf_all['avatars_max_count']) { // Limit reached $upload_status = array('code' => 10, 'message' => str_replace('[NUMBER]', $session->_conf_all['avatars_max_count'], $l->g('avatars_limit_reached'))); } else { // Check image data $img_data = null; switch (PCPIN_Image::checkImage($img_data, $f_data['tmp_name'], $session->_conf_all['avatar_image_types'], $session->_conf_all['avatar_max_width'], $session->_conf_all['avatar_max_height'], $session->_conf_all['avatar_max_filesize'], false)) { case PCPIN_IMAGE_CHECK_OK: // Image OK $upload_status = array('code' => 0, 'message' => $l->g('avatar_uploaded')); break; case PCPIN_IMAGE_CHECK_ERROR_FILE: // File does not exists / not readable $upload_status = array('code' => 100, 'message' => $l->g('file_upload_error')); break;
$languages = array(); if (!empty($session->_conf_all['allow_language_selection'])) { $languages = $l->getLanguages(false); } if (empty($profile_user_id)) { $profile_user_id = $current_user->id; } if ($profile_user_id != $current_user->id && ($current_user->is_admin !== 'y' || !$current_user->_db_getList('login', 'id =# ' . $profile_user_id, 1))) { $profile_user_id = $current_user->id; } // Display "Avatar gallery" link? $show_avatar_gallery_link = false; if (!empty($session->_conf_all['avatar_gallery'])) { _pcpin_loadClass('avatar'); $avatar = new PCPIN_Avatar($session); if ($avatar->_db_getList('COUNT', 'user_id = 0')) { if ($avatar->_db_list_count > 1) { // There are more that one default avatar $show_avatar_gallery_link = true; } $avatar->_db_freeList(); } } $_body_onload[1000000] = 'initProfile(' . $session->_conf_all['nickname_length_min'] . ',' . $session->_conf_all['nickname_length_max'] . ',' . '\'' . $session->_conf_all['default_nickname_color'] . '\',' . $session->_conf_all['avatars_max_count'] . ',' . $session->_conf_all['nicknames_max_count'] . ',' . $profile_user_id . ',' . ($show_avatar_gallery_link ? 'true' : 'false') . ',' . ($session->_conf_all['allow_language_selection'] ? 'true' : 'false') . ',' . ($session->_conf_all['allow_account_unsubscribe'] && $profile_user_id == $current_user->id ? 'true' : 'false') . ')'; // Init template _pcpin_loadClass('pcpintpl'); $tpl = new PcpinTpl(); $tpl->setBasedir('./tpl'); $tpl->readTemplatesFromFile('./profile_main.tpl'); // JS files $_js_files[] = './js/profile.js';
* 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 avatar * @param int $avatar_id Avatar ID */ if (empty($avatar_id) || !pcpin_ctype_digit($avatar_id)) { $avatar_id = 0; } _pcpin_loadClass('avatar'); $avatar = new PCPIN_Avatar($session); if (!empty($current_user->id) && $current_user->is_admin === 'y' && !empty($avatar_id)) { // Check for other gallery avatars if ($avatar->_db_getList('id', 'user_id = 0', 'id != ' . $avatar_id, 1)) { $avatar->_db_freeList(); // Delete avatar if ($avatar->deleteGalleryAvatar($avatar_id)) { $xmlwriter->setHeaderMessage($l->g('avatar_deleted')); $xmlwriter->setHeaderStatus(0); } else { $xmlwriter->setHeaderMessage($l->g('error')); $xmlwriter->setHeaderStatus(1); } } else { $xmlwriter->setHeaderMessage($l->g('delete_last_avatar_error')); $xmlwriter->setHeaderStatus(1); } }