$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:
             // Image OK
             $upload_status = array('code' => 0, 'message' => 'OK');
             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;
         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 (PCPIN_CLIENT_AGENT_NAME == 'IE') {
     header('Cache-Control: Public');
     header('Pragma: Public');
 } else {
     header('Pragma: Public');
 }
 $thumb_loaded = false;
 if (true === $session->_conf_all['allow_gd'] && !empty($b_x) && pcpin_ctype_digit($b_x) && !empty($b_y) && pcpin_ctype_digit($b_y)) {
     // Thumbnail
     if (!isset($bg_r) || !pcpin_ctype_digit($bg_r) || $bg_r < 0 || $bg_r > 255 || !isset($bg_g) || !pcpin_ctype_digit($bg_g) || $bg_g < 0 || $bg_g > 255 || !isset($bg_b) || !pcpin_ctype_digit($bg_b) || $bg_b < 0 || $bg_b > 255) {
         $bg_r = hexdec(substr($session->_conf_all['thumb_background'], 0, 2));
         $bg_g = hexdec(substr($session->_conf_all['thumb_background'], 2, 2));
         $bg_b = hexdec(substr($session->_conf_all['thumb_background'], 4, 2));
     }
     $thumb_img = '';
     if (PCPIN_Image::makeThumb($thumb_img, null, null, $binaryfile->_db_list[0]['body'], $b_y, $b_x, 'jpg', $bg_r, $bg_g, $bg_b)) {
         $thumb_loaded = true;
         header('Content-type: image/jpeg');
         $etag = md5($thumb_img);
         header('Etag: ' . $etag);
         if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] === $etag) {
             header('HTTP/1.1 304 Not Modified');
         } else {
             echo $thumb_img;
         }
     }
 }
 if (!$thumb_loaded) {
     if (!empty($filename)) {
         header('Content-Disposition: inline; filename="' . $filename . '"');
     }
 *    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/>.
 */
/**
 * GD Version
 */
define('PCPIN_GD_VERSION', PCPIN_Image::whichGD());
/**
 * Image check results
 */
define('PCPIN_IMAGE_CHECK_OK', 0);
// Image OK
define('PCPIN_IMAGE_CHECK_ERROR_FILE', 1);
// File is not an image or file does not exists / not readable
define('PCPIN_IMAGE_CHECK_ERROR_MIME', 2);
// MIME not allowed
define('PCPIN_IMAGE_CHECK_ERROR_WIDTH', 3);
// Image width larger than allowed
define('PCPIN_IMAGE_CHECK_ERROR_HEIGHT', 4);
// Image height larger than allowed
define('PCPIN_IMAGE_CHECK_ERROR_FILESIZE', 5);
// Image file size larger than allowed
            // Userdata
            $current_userdata->_db_getList('user_id = ' . $current_user->id, 1);
            $current_userdata_set = $current_userdata->_db_list[0];
            $current_userdata->_db_freeList();
            $update_args = array();
            foreach ($_pcpin_slave_userdata as $key => $val) {
                if (!is_null($val) && isset($current_userdata_set[$key]) && $current_userdata_set[$key] != $val) {
                    $update_args[$key] = $val;
                }
            }
            if (!empty($update_args)) {
                $current_userdata->_db_updateRow($current_user->id, 'user_id', $update_args);
            }
            // Avatar
            if (!empty($_pcpin_slave_userdata['avatar'])) {
                $new_avatar_data = null;
                if (PCPIN_IMAGE_CHECK_OK === PCPIN_Image::checkImage($new_avatar_data, $_pcpin_slave_userdata['avatar'], $session->_conf_all['avatar_image_types'], 0, 0, 0, true)) {
                    if ($binaryfile->newBinaryFile(file_get_contents($_pcpin_slave_userdata['avatar']), $new_avatar_data['mime'], $new_avatar_data['width'], $new_avatar_data['height'], 'log')) {
                        $avatar->addAvatar($binaryfile->id, $current_user->id);
                    }
                }
            }
        }
    }
    // Log user in
    require './inc/ajax/do_login.inc.php';
    if ($status == 0) {
        header('Location: ' . PCPIN_FORMLINK . '?s_id=' . urlencode($session->_s_id));
        die;
    }
}