$pic_exists = true;
    } else {
        if (@file_exists(array_shift(explode('?', basename($pic_localpath))))) {
            $pic_exists = true;
        }
    }
}
if (!$pic_exists && any_url_exists($pic_fullpath)) {
    $pic_exists = true;
}
if (!$pic_exists) {
    image_no_thumbnail('thumb_' . $pic_title_reg . '.' . $pic_filetype);
    exit;
}
if ($image_processed == false) {
    $pic_size = get_full_image_info($pic_fullpath, null, $pic_local);
    if (empty($pic_size)) {
        image_no_thumbnail('thumb_' . $pic_title_reg . '.' . $pic_filetype);
        exit;
    }
    $pic_width = $pic_size['width'];
    $pic_height = $pic_size['height'];
    $pic_filetype = strtolower($pic_size['type']);
}
// ------------------------------------
// Send Thumbnail to browser
// ------------------------------------
if ($pic_width < $config['thumbnail_size'] && $pic_height < $config['thumbnail_size']) {
    if ($config['thumbnail_cache'] == true) {
        $copy_success = @copy($pic_fullpath, $pic_thumbnail_fullpath);
        @chmod($pic_thumbnail_fullpath, 0777);
Example #2
0
			$topic_desc = request_post_var('topic_desc', '', true);
			$message = !empty($draft_message) ? $draft_message : htmlspecialchars_decode(request_post_var('message', '', true), ENT_COMPAT);
			$notes = htmlspecialchars_decode(request_post_var('notes', '', true), ENT_COMPAT);
			$notes_mod = '';
			if (($user->data['user_level'] == ADMIN) || $is_auth['auth_mod'])
			{
				$notes_mod = htmlspecialchars_decode(request_post_var('notes_mod', '', true), ENT_COMPAT);
			}
			$post_images = request_post_var('post_images', '', true);
			if (!empty($post_images) && (substr($post_images, 0, 4) == 'http'))
			{
				if (!function_exists('get_full_image_info'))
				{
					require(IP_ROOT_PATH . 'includes/class_image.' . PHP_EXT);
				}
				$pic_size = get_full_image_info($post_images);
				if(empty($pic_size))
				{
					$post_images = '';
				}
			}
			else
			{
				$post_images = '';
			}
			$post_data['post_images'] = $post_images;

			$poll_title = (isset($_POST['poll_title']) && $is_auth['auth_pollcreate']) ? request_post_var('poll_title', '', true) : '';
			$poll_options = (isset($_POST['poll_option_text']) && $is_auth['auth_pollcreate']) ? request_post_var('poll_option_text', array(0 => ''), true) : array();
			$poll_start = time();
			$poll_length = (isset($_POST['poll_length']) && $is_auth['auth_pollcreate']) ? request_post_var('poll_length', 0) : 0;
Example #3
0
function create_thumb($source_pic, $allowed_extensions, $t_width, $t_height, $t_suffix = '', $t_path = '', $t_quality = '75', $force_size = false)
{
    if (!class_exists('class_files')) {
        include_once IP_ROOT_PATH . 'includes/class_files.' . PHP_EXT;
    }
    $class_files = new class_files();
    if (!empty($allowed_extensions)) {
        $allowed_extensions = is_array($allowed_extensions) ? $allowed_extensions : array($allowed_extensions);
        $allowed_extensions = array_map('strtolower', $allowed_extensions);
    }
    $file_details = array();
    $pic_fullpath = str_replace(array(' '), array('%20'), $source_pic);
    $file_details = $class_files->get_file_details($source_pic);
    $pic_filename = $file_details['name_full'];
    $pic_title = $file_details['filename'];
    $pic_filetype = $file_details['extension'];
    $pic_title_reg = $class_files->clean_string($pic_title, false);
    $pic_thumbnail = $pic_title . $t_suffix . '.' . $pic_filetype;
    if (!empty($allowed_extensions) && !in_array($pic_filetype, $allowed_extensions)) {
        return false;
    }
    $pic_size = get_full_image_info($source_pic, null, true);
    if ($pic_size == false) {
        return false;
    }
    $pic_width = $pic_size['width'];
    $pic_height = $pic_size['height'];
    $pic_filetype_new = strtolower($pic_size['type']);
    $pic_thumbnail_fullpath = ($t_path == '' ? '' : $t_path . '/') . $pic_thumbnail;
    switch ($pic_filetype_new) {
        case 'gif':
            $img_tmp = @imagecreatefromgif($source_pic);
            break;
        case 'jpg':
            $img_tmp = @imagecreatefromjpeg($source_pic);
            break;
        case 'png':
            $img_tmp = @imagecreatefrompng($source_pic);
            break;
        default:
            return false;
            break;
    }
    $pic_ratio = $pic_width / $pic_height;
    $t_ratio = $t_width / $t_height;
    $x_offset = 0;
    $y_offset = 0;
    $dest_width = $t_width;
    $dest_height = $t_height;
    if (!empty($force_size)) {
        if ($pic_ratio > $t_ratio) {
            $dest_width = $t_height * $pic_ratio;
        } else {
            $dest_height = $t_width / $pic_ratio;
        }
        $x_mid = $dest_width / 2;
        $y_mid = $dest_height / 2;
        $x_offset = round($x_mid - $t_width / 2, 0);
        $y_offset = round($y_mid - $t_height / 2, 0);
        // If we want to crop the image, we need an intermediate image... and we need to reset final width and height
        $img_new = @imagecreatetruecolor($dest_width, $dest_height);
        if (!$img_new) {
            return false;
        }
        @imagealphablending($img_new, false);
        @imagecopyresampled($img_new, $img_tmp, 0, 0, 0, 0, $dest_width, $dest_height, $pic_width, $pic_height);
        @imagesavealpha($img_new, true);
        @imagedestroy($img_tmp);
        $img_tmp = $img_new;
        $dest_width = $t_width;
        $dest_height = $t_height;
        $pic_width = $t_width;
        $pic_height = $t_height;
    } else {
        if ($pic_width <= $t_width && $pic_height <= $t_height) {
            $dest_width = $pic_width;
            $dest_height = $pic_height;
            if ($t_path != '' && !file_exists($t_path)) {
                @mkdir($t_path, 0777);
            }
            @copy($source_pic, $pic_thumbnail_fullpath);
            @chmod($pic_thumbnail_fullpath, 0755);
            return true;
        } else {
            if ($pic_ratio > $t_ratio) {
                $dest_width = round($t_height * $pic_ratio, 0);
            } else {
                $dest_height = round($t_width / $pic_ratio, 0);
            }
        }
    }
    $img_new = @imagecreatetruecolor($dest_width, $dest_height);
    if (!$img_new) {
        return false;
    }
    @imagealphablending($img_new, false);
    @imagecopyresampled($img_new, $img_tmp, 0, 0, $x_offset, $y_offset, $dest_width, $dest_height, $pic_width, $pic_height);
    @imagesavealpha($img_new, true);
    @imagedestroy($img_tmp);
    if ($t_path != '' && !file_exists($t_path)) {
        @mkdir($t_path, 0777);
    }
    // If you want all thumbnails to be forced as JPG you can decomment these lines
    /*
    imagejpeg ($img_new, $pic_thumbnail_fullpath, '75');
    return true;
    exit;
    */
    switch ($pic_filetype) {
        case 'jpg':
            @imagejpeg($img_new, $pic_thumbnail_fullpath, '75');
            break;
        case 'png':
            @imagepng($img_new, $pic_thumbnail_fullpath);
            break;
        case 'gif':
            @imagegif($img_new, $pic_thumbnail_fullpath);
            break;
        default:
            return false;
            exit;
    }
    @chmod($pic_thumbnail_fullpath, 0755);
    @imagedestroy($img_new);
    return true;
}