[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path Zen Cart 源代码 ih_manager.php
$data['imgExtension'] = substr( $_FILES['default_image']['name'],
strrpos($_FILES['default_image']['name'], '.'));
/* Nigel fix here
This basically converts the extension of the uploaded file to match the main image, PROVIDED they are the same file type
*/
$sm_imgExtension = strtolower($data['imgExtension']);
$df_extension = strtolower($_GET['imgExtension']); // file extension of base original file
//ugly but effective code
if ($sm_imgExtension == $df_extension) { // this should get rid of any capitilisation issues for files with the same extensions
$data['imgExtension'] = $_GET['imgExtension'];
} // This deals with any jpg that have differing extensions eg jpeg and jpg
elseif ((($sm_imgExtension == ".jpeg") && ($df_extension == ".jpg")) || (($sm_imgExtension == ".jpg") && ($df_extension == ".jpeg")) )
{// this is where they don't match eg original image is a gif and additional image is a jpg or png
$data['imgExtension'] = $_GET['imgExtension'];
} else
{
//file mismatch really should put a warning in here that the additional image won't show
// or a call to convert the actual image to a compatible format
}
// Check the data
if ((isset($_GET['newImg']) && $_GET['newImg'] == 1) || (isset($_GET['imgEdit']) && ($_GET['imgEdit'] == 1) && ($_GET['imgSuffix'] == '') && ($_POST['imgNaming'] != 'keep_name') && ($_FILES['default_image']['name'] != ''))) {
// New Image Name and Base Dir
if ( ($_POST['imgBase'] != '') ) {
$data['imgBase'] = $_POST['imgBase'];
echo "<!-- point 12 - ".$_POST['imgBase']."-->";
} else {
// Extract the name from the default file
if ($_FILES['default_image']['name'] != '') {
preg_match("/(.+)\.[^\.]+$/", $_FILES['default_image']['name'], $matches);
$data['imgBase'] = $matches[1];
} else {
$messageStack->add(TEXT_MSG_AUTO_BASE_ERROR, 'error');
$check = 1;
}
}
if ($_POST['imgNaming'] == 'new_copy') {
// need to copy/rename additional images for new default image
// this will be implemented in a future release
}
} else if (isset($_GET['imgEdit']) && $_GET['imgEdit'] == 1) {
$data['imgBaseDir'] = $_GET['imgBaseDir'];
$data['imgBase'] = $_GET['imgBase'];
//$data['imgExtension'] = $_GET['imgExtension'];
$data['imgSuffix'] = $_GET['imgSuffix'];
} else {
// An additional image is being added
$data['imgBaseDir'] = $_GET['imgBaseDir'];
$data['imgBase'] = $_GET['imgBase'];
//$data['imgExtension'] = $_GET['imgExtension'];
// Image Suffix (if set)
if ($_POST['imgSuffix'] != '') {
$data['imgSuffix'] = '_'.$_POST['imgSuffix'];
} else {
// get directory list
$array = array();
find_additional_images($array, DIR_FS_CATALOG . DIR_WS_IMAGES . $data['imgBaseDir'],
$data['imgExtension'], $data['imgBase'] );
echo "<!-- point 1".$data['imgExtension']."-->";
$c = sizeof( $array );
if ($c > 1) {
sort($array);
}
// calculate the next suffix
// (This is lame, unscalable, and inefficient, but effective)
$suffix = 1;
$m = 0;
while ($m != 1) {
if ($check == 1) {
if ($_GET['imgEdit'] == 1) {
$action = "layout_edit";
} else {
$action = "layout_new";
}
$repeat_check = 1;
} else {
// Data has been saved
// show the new image information
$messageStack->add( TEXT_MSG_IMAGE_SAVED, 'success' );
// we might need to clear the cache if filenames are kept
if (isset($_GET['imgEdit']) && $_GET['imgEdit'] == 1) {
$error = bmz_clear_cache();
if (!$error) {
$messageStack->add(IH_CACHE_CLEARED, 'success');
}
}
$_GET['imgName'] = $data['imgBase'] . $data['imgSuffix'];
$action = "layout_info";
}
}
if ($action == 'quick_delete') {
$img_name = $_GET['imgName'];
$img_name_full = DIR_FS_CATALOG . $img_name;
if (is_file($img_name_full)) {
if (unlink($img_name_full)) {
// file successfully deleted
$messageStack->add_session(TEXT_MSG_IMAGE_DELETED, 'success');
} else {
// couldn't delete file
$messageStack->add_session(TEXT_MSG_IMAGE_NOT_DELETED, 'error');
}
} else {
// could not find file to delete
$messageStack->add_session(TEXT_MSG_IMAGE_NOT_FOUND, 'error');
}
zen_redirect(zen_href_link(FILENAME_IMAGE_HANDLER, 'products_filter=' . $_GET['products_filter'] . '&current_category_id=' . $current_category_id));
}