function create_thumbnail($source, $new_file, $mimetype) { global $attach_config, $imagick; $source = amod_realpath($source); $min_filesize = intval($attach_config['img_min_thumb_filesize']); $img_filesize = @file_exists(@amod_realpath($source)) ? filesize($source) : false; if (!$img_filesize || $img_filesize <= $min_filesize) { return FALSE; } $size = image_getdimension($source); if ($size[0] == 0 && $size[1] == 0) { return FALSE; } $new_size = get_img_size_format($size[0], $size[1]); $tmp_path = ''; $old_file = ''; if (intval($attach_config['allow_ftp_upload'])) { $old_file = $new_file; $tmp_path = explode('/', $source); $tmp_path[count($tmp_path) - 1] = ''; $tmp_path = implode('/', $tmp_path); if ($tmp_path == '') { $tmp_path = '/tmp'; } $value = trim($tmp_path); if ($value[strlen($value) - 1] == '/') { $value[strlen($value) - 1] = ' '; } $new_file = trim($value) . '/t00000'; } $used_imagick = FALSE; if (is_imagick()) { if (is_array($size) && count($size) > 0) { passthru($imagick . ' -quality 85 -antialias -sample ' . $new_size[0] . 'x' . $new_size[1] . ' "' . str_replace('\\', '/', $source) . '" +profile "*" "' . str_replace('\\', '/', $new_file) . '"'); if (@file_exists(@amod_realpath($new_file))) { $used_imagick = TRUE; } } } if (!$used_imagick) { $type = $size[2]; $supported_types = get_supported_image_types(); if (in_array($type, $supported_types)) { switch ($type) { case '1': $im = imagecreatefromgif($source); $new_im = imagecreate($new_size[0], $new_size[1]); imagecopyresized($new_im, $im, 0, 0, 0, 0, $new_size[0], $new_size[1], $size[0], $size[1]); imagegif($new_im, $new_file); break; case '2': $im = imagecreatefromjpeg($source); $new_im = intval($attach_config['use_gd2']) ? @imagecreatetruecolor($new_size[0], $new_size[1]) : imagecreate($new_size[0], $new_size[1]); imagecopyresized($new_im, $im, 0, 0, 0, 0, $new_size[0], $new_size[1], $size[0], $size[1]); imagejpeg($new_im, $new_file, 90); break; case '3': $im = imagecreatefrompng($source); $new_im = intval($attach_config['use_gd2']) ? @imagecreatetruecolor($new_size[0], $new_size[1]) : imagecreate($new_size[0], $new_size[1]); imagecopyresized($new_im, $im, 0, 0, 0, 0, $new_size[0], $new_size[1], $size[0], $size[1]); imagepng($new_im, $new_file); break; } } } if (!@file_exists(@amod_realpath($new_file))) { return FALSE; } if (intval($attach_config['allow_ftp_upload'])) { $result = ftp_file($new_file, $old_file, $this->type, TRUE); // True for disable error-mode if (!$result) { return FALSE; } } else { @chmod($new_file, 0664); } return TRUE; }
if ($row[$i]['cat_id'] == IMAGE_CAT) { $s_assigned_group_images[] = $row[$i]['group_name']; } elseif ($row[$i]['cat_id'] == STREAM_CAT) { $s_assigned_group_streams[] = $row[$i]['group_name']; } elseif ($row[$i]['cat_id'] == SWF_CAT) { $s_assigned_group_flash[] = $row[$i]['group_name']; } } $display_inlined_yes = $new_attach['img_display_inlined'] != '0' ? 'checked="checked"' : ''; $display_inlined_no = $new_attach['img_display_inlined'] == '0' ? 'checked="checked"' : ''; $create_thumbnail_yes = $new_attach['img_create_thumbnail'] != '0' ? 'checked="checked"' : ''; $create_thumbnail_no = $new_attach['img_create_thumbnail'] == '0' ? 'checked="checked"' : ''; $use_gd2_yes = $new_attach['use_gd2'] != '0' ? 'checked="checked"' : ''; $use_gd2_no = $new_attach['use_gd2'] == '0' ? 'checked="checked"' : ''; // Check Thumbnail Support if (!is_imagick() && !@extension_loaded('gd')) { $new_attach['img_create_thumbnail'] = '0'; } else { $template->assign_block_vars('switch_thumbnail_support', array()); } $template->assign_vars(array('L_MANAGE_CAT_TITLE' => $lang['Manage_categories'], 'L_MANAGE_CAT_EXPLAIN' => $lang['Manage_categories_explain'], 'L_SETTINGS_CAT_IMAGES' => $lang['Settings_cat_images'], 'L_SETTINGS_CAT_STREAM' => $lang['Settings_cat_streams'], 'L_SETTINGS_CAT_FLASH' => $lang['Settings_cat_flash'], 'L_ASSIGNED_GROUP' => $lang['Assigned_group'], 'L_DISPLAY_INLINED' => $lang['Display_inlined'], 'L_DISPLAY_INLINED_EXPLAIN' => $lang['Display_inlined_explain'], 'L_MAX_IMAGE_SIZE' => $lang['Max_image_size'], 'L_MAX_IMAGE_SIZE_EXPLAIN' => $lang['Max_image_size_explain'], 'L_IMAGE_LINK_SIZE' => $lang['Image_link_size'], 'L_IMAGE_LINK_SIZE_EXPLAIN' => $lang['Image_link_size_explain'], 'L_CREATE_THUMBNAIL' => $lang['Image_create_thumbnail'], 'L_CREATE_THUMBNAIL_EXPLAIN' => $lang['Image_create_thumbnail_explain'], 'L_MIN_THUMB_FILESIZE' => $lang['Image_min_thumb_filesize'], 'L_MIN_THUMB_FILESIZE_EXPLAIN' => $lang['Image_min_thumb_filesize_explain'], 'L_IMAGICK_PATH' => $lang['Image_imagick_path'], 'L_IMAGICK_PATH_EXPLAIN' => $lang['Image_imagick_path_explain'], 'L_SEARCH_IMAGICK' => $lang['Image_search_imagick'], 'L_BYTES' => $lang['Bytes'], 'L_TEST_SETTINGS' => $lang['Test_settings'], 'L_YES' => $lang['Yes'], 'L_NO' => $lang['No'], 'L_SUBMIT' => $lang['Submit'], 'L_RESET' => $lang['Reset'], 'L_USE_GD2' => $lang['Use_gd2'], 'L_USE_GD2_EXPLAIN' => $lang['Use_gd2_explain'], 'IMAGE_MAX_HEIGHT' => $new_attach['img_max_height'], 'IMAGE_MAX_WIDTH' => $new_attach['img_max_width'], 'IMAGE_LINK_HEIGHT' => $new_attach['img_link_height'], 'IMAGE_LINK_WIDTH' => $new_attach['img_link_width'], 'IMAGE_MIN_THUMB_FILESIZE' => $new_attach['img_min_thumb_filesize'], 'IMAGE_IMAGICK_PATH' => $new_attach['img_imagick'], 'DISPLAY_INLINED_YES' => $display_inlined_yes, 'DISPLAY_INLINED_NO' => $display_inlined_no, 'CREATE_THUMBNAIL_YES' => $create_thumbnail_yes, 'CREATE_THUMBNAIL_NO' => $create_thumbnail_no, 'USE_GD2_YES' => $use_gd2_yes, 'USE_GD2_NO' => $use_gd2_no, 'S_ASSIGNED_GROUP_IMAGES' => implode(', ', $s_assigned_group_images), 'S_ATTACH_ACTION' => append_sid('admin_attachments.' . PHP_EXT . '?mode=cats'))); } // Check Cat Settings if ($check_image_cat) { if ($config['upload_dir'][0] == '/' || $config['upload_dir'][0] != '/' && $config['upload_dir'][1] == ':') { $upload_dir = $config['upload_dir']; } else { $upload_dir = IP_ROOT_PATH . $config['upload_dir']; } $upload_dir = $upload_dir . '/' . THUMB_DIR; $error = false;
/** * Create thumbnail */ function create_thumbnail($source, $new_file, $mimetype) { global $attach_config, $imagick; $source = amod_realpath($source); $min_filesize = (int) $attach_config['img_min_thumb_filesize']; $img_filesize = @file_exists($source) ? @filesize($source) : false; if (!$img_filesize || $img_filesize <= $min_filesize) { return false; } list($width, $height, $type, ) = getimagesize($source); if (!$width || !$height) { return false; } list($new_width, $new_height) = get_img_size_format($width, $height); $tmp_path = $old_file = ''; $used_imagick = false; if (is_imagick()) { passthru($imagick . ' -quality 85 -antialias -sample ' . $new_width . 'x' . $new_height . ' "' . str_replace('\\', '/', $source) . '" +profile "*" "' . str_replace('\\', '/', $new_file) . '"'); if (@file_exists($new_file)) { $used_imagick = true; } } if (!$used_imagick) { $type = get_supported_image_types($type); if ($type['gd']) { switch ($type['format']) { case IMG_GIF: $image = imagecreatefromgif($source); break; case IMG_JPG: $image = imagecreatefromjpeg($source); break; case IMG_PNG: $image = imagecreatefrompng($source); break; case IMG_WBMP: $image = imagecreatefromwbmp($source); break; } if ($type['version'] == 1 || !$attach_config['use_gd2']) { $new_image = imagecreate($new_width, $new_height); imagecopyresized($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); } else { $new_image = imagecreatetruecolor($new_width, $new_height); imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); } switch ($type['format']) { case IMG_GIF: imagegif($new_image, $new_file); break; case IMG_JPG: imagejpeg($new_image, $new_file, 90); break; case IMG_PNG: imagepng($new_image, $new_file); break; case IMG_WBMP: imagewbmp($new_image, $new_file); break; } imagedestroy($new_image); } } if (!@file_exists($new_file)) { return false; } @chmod($new_file, 0664); return true; }
/** * Create thumbnail */ function create_thumbnail($source, $new_file, $mimetype) { global $attach_config, $imagick; $source = amod_realpath($source); $min_filesize = (int) $attach_config['img_min_thumb_filesize']; $img_filesize = @file_exists($source) ? @filesize($source) : false; if (!$img_filesize || $img_filesize <= $min_filesize) { return false; } list($width, $height, $type, ) = getimagesize($source); if (!$width || !$height) { return false; } list($new_width, $new_height) = get_img_size_format($width, $height); $tmp_path = $old_file = ''; if (intval($attach_config['allow_ftp_upload'])) { $old_file = $new_file; $tmp_path = explode('/', $source); $tmp_path[count($tmp_path) - 1] = ''; $tmp_path = implode('/', $tmp_path); if ($tmp_path == '') { $tmp_path = '/tmp'; } $value = trim($tmp_path); if ($value[strlen($value) - 1] == '/') { $value[strlen($value) - 1] = ' '; } // $new_file = tempnam(trim($value), 't00000'); // We remove it now because it gets created again later @unlink($new_file); } $used_imagick = false; if (is_imagick()) { passthru($imagick . ' -quality 85 -antialias -sample ' . $new_width . 'x' . $new_height . ' "' . str_replace('\\', '/', $source) . '" +profile "*" "' . str_replace('\\', '/', $new_file) . '"'); if (@file_exists($new_file)) { $used_imagick = true; } } if (!$used_imagick) { $type = get_supported_image_types($type); if ($type['gd']) { switch ($type['format']) { case IMG_GIF: $image = imagecreatefromgif($source); break; case IMG_JPG: $image = imagecreatefromjpeg($source); break; case IMG_PNG: $image = imagecreatefrompng($source); break; case IMG_WBMP: $image = imagecreatefromwbmp($source); break; } if ($type['version'] == 1 || !$attach_config['use_gd2']) { $new_image = imagecreate($new_width, $new_height); imagecopyresized($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); } else { $new_image = imagecreatetruecolor($new_width, $new_height); imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); } switch ($type['format']) { case IMG_GIF: imagegif($new_image, $new_file); break; case IMG_JPG: imagejpeg($new_image, $new_file, 90); break; case IMG_PNG: imagepng($new_image, $new_file); break; case IMG_WBMP: imagewbmp($new_image, $new_file); break; } imagedestroy($new_image); } } if (!@file_exists($new_file)) { return false; } if (intval($attach_config['allow_ftp_upload'])) { $result = ftp_file($new_file, $old_file, $mimetype, true); // True for disable error-mode @unlink($new_file); if (!$result) { return false; } } else { @chmod($new_file, 0664); } return true; }
if ($row[$i]['cat_id'] == SWF_CAT) { $s_assigned_group_flash[] = $row[$i]['group_name']; } } } } $display_inlined_yes = $new_attach['img_display_inlined'] != '0' ? 'checked="checked"' : ''; $display_inlined_no = $new_attach['img_display_inlined'] == '0' ? 'checked="checked"' : ''; $create_thumbnail_yes = $new_attach['img_create_thumbnail'] != '0' ? 'checked="checked"' : ''; $create_thumbnail_no = $new_attach['img_create_thumbnail'] == '0' ? 'checked="checked"' : ''; $use_gd2_yes = $new_attach['use_gd2'] != '0' ? 'checked="checked"' : ''; $use_gd2_no = $new_attach['use_gd2'] == '0' ? 'checked="checked"' : ''; // // Check Thumbnail Support // if (!is_imagick() && count(get_supported_image_types()) == 0) { $new_attach['img_create_thumbnail'] = '0'; } else { $template->assign_block_vars('switch_thumbnail_support', array()); } $template->assign_vars(array('L_MANAGE_CAT_TITLE' => $lang['Manage_categories'], 'L_MANAGE_CAT_EXPLAIN' => $lang['Manage_categories_explain'], 'L_SETTINGS_CAT_IMAGES' => $lang['Settings_cat_images'], 'L_SETTINGS_CAT_STREAM' => $lang['Settings_cat_streams'], 'L_SETTINGS_CAT_FLASH' => $lang['Settings_cat_flash'], 'L_ASSIGNED_GROUP' => $lang['Assigned_group'], 'L_DISPLAY_INLINED' => $lang['Display_inlined'], 'L_DISPLAY_INLINED_EXPLAIN' => $lang['Display_inlined_explain'], 'L_MAX_IMAGE_SIZE' => $lang['Max_image_size'], 'L_MAX_IMAGE_SIZE_EXPLAIN' => $lang['Max_image_size_explain'], 'L_IMAGE_LINK_SIZE' => $lang['Image_link_size'], 'L_IMAGE_LINK_SIZE_EXPLAIN' => $lang['Image_link_size_explain'], 'L_CREATE_THUMBNAIL' => $lang['Image_create_thumbnail'], 'L_CREATE_THUMBNAIL_EXPLAIN' => $lang['Image_create_thumbnail_explain'], 'L_MIN_THUMB_FILESIZE' => $lang['Image_min_thumb_filesize'], 'L_MIN_THUMB_FILESIZE_EXPLAIN' => $lang['Image_min_thumb_filesize_explain'], 'L_IMAGICK_PATH' => $lang['Image_imagick_path'], 'L_IMAGICK_PATH_EXPLAIN' => $lang['Image_imagick_path_explain'], 'L_SEARCH_IMAGICK' => $lang['Image_search_imagick'], 'L_BYTES' => $lang['Bytes'], 'L_TEST_SETTINGS' => $lang['Test_settings'], 'L_YES' => $lang['Yes'], 'L_NO' => $lang['No'], 'L_SUBMIT' => $lang['Submit'], 'L_RESET' => $lang['Reset'], 'L_USE_GD2' => $lang['Use_gd2'], 'L_USE_GD2_EXPLAIN' => $lang['Use_gd2_explain'], 'IMAGE_MAX_HEIGHT' => $new_attach['img_max_height'], 'IMAGE_MAX_WIDTH' => $new_attach['img_max_width'], 'IMAGE_LINK_HEIGHT' => $new_attach['img_link_height'], 'IMAGE_LINK_WIDTH' => $new_attach['img_link_width'], 'IMAGE_MIN_THUMB_FILESIZE' => $new_attach['img_min_thumb_filesize'], 'IMAGE_IMAGICK_PATH' => $new_attach['img_imagick'], 'DISPLAY_INLINED_YES' => $display_inlined_yes, 'DISPLAY_INLINED_NO' => $display_inlined_no, 'CREATE_THUMBNAIL_YES' => $create_thumbnail_yes, 'CREATE_THUMBNAIL_NO' => $create_thumbnail_no, 'USE_GD2_YES' => $use_gd2_yes, 'USE_GD2_NO' => $use_gd2_no, 'S_ASSIGNED_GROUP_IMAGES' => implode(', ', $s_assigned_group_images), 'S_ATTACH_ACTION' => append_sid('admin_attachments.' . $phpEx . '?mode=cats'))); } // // Check Cat Settings // if ($check_image_cat) { // // Some tests... // $attach_config = array(); $sql = 'SELECT *