本文整理匯總了PHP中cls_image::get_filetype方法的典型用法代碼示例。如果您正苦於以下問題:PHP cls_image::get_filetype方法的具體用法?PHP cls_image::get_filetype怎麽用?PHP cls_image::get_filetype使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cls_image
的用法示例。
在下文中一共展示了cls_image::get_filetype方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: process_image
//.........這裏部分代碼省略.........
/* 出錯處理 */
if (!$goods_thumb) {
$msg = sprintf($GLOBALS['_LANG']['error_pos'], $row['goods_id']) . "\n" . $GLOBALS['image']->error_msg();
if ($silent) {
$GLOBALS['err_msg'][] = $msg;
continue;
} else {
make_json_error($msg);
}
}
/* 重新格式化圖片名稱 */
$goods_thumb = reformat_image_name('goods_thumb', $row['goods_id'], $goods_thumb, 'thumb');
if ($change || empty($row['goods_thumb'])) {
if ($row['goods_thumb'] != $goods_thumb) {
$sql = "UPDATE " . $GLOBALS['ecs']->table('goods') . " SET goods_thumb = '{$goods_thumb}' WHERE goods_id = '" . $row['goods_id'] . "'";
$GLOBALS['db']->query($sql);
/* 防止原圖被刪除 */
if ($row['goods_thumb'] != $row['original_img']) {
@unlink(ROOT_PATH . $row['goods_thumb']);
}
}
} else {
replace_image($goods_thumb, $row['goods_thumb'], $row['goods_id'], $silent);
}
}
}
} else {
/* 遍曆商品相冊 */
$sql = "SELECT album.goods_id, album.img_id, album.img_url, album.thumb_url, album.img_original FROM " . $GLOBALS['ecs']->table('goods_gallery') . " AS album " . $GLOBALS['album_where'];
$res = $GLOBALS['db']->SelectLimit($sql, $page_size, ($page - 1) * $page_size);
while ($row = $GLOBALS['db']->fetchRow($res)) {
$thumb_url = '';
$image = '';
/* 水印 */
if ($watermark && file_exists(ROOT_PATH . $row['img_original'])) {
if (empty($row['img_url'])) {
$dir = dirname(ROOT_PATH . $row['img_original']) . '/';
} else {
$dir = dirname(ROOT_PATH . $row['img_url']) . '/';
}
$file_name = cls_image::unique_name($dir);
$file_name .= cls_image::get_filetype(empty($row['img_url']) ? $row['img_original'] : $row['img_url']);
copy(ROOT_PATH . $row['img_original'], $dir . $file_name);
$image = $GLOBALS['image']->add_watermark($dir . $file_name, '', $GLOBALS['_CFG']['watermark'], $GLOBALS['_CFG']['watermark_place'], $GLOBALS['_CFG']['watermark_alpha']);
if (!$image) {
@unlink($dir . $file_name);
$msg = sprintf($GLOBALS['_LANG']['error_pos'], $row['goods_id']) . "\n" . $GLOBALS['image']->error_msg();
if ($silent) {
$GLOBALS['err_msg'][] = $msg;
continue;
} else {
make_json_error($msg);
}
}
/* 重新格式化圖片名稱 */
$image = reformat_image_name('gallery', $row['goods_id'], $image, 'goods');
if ($change || empty($row['img_url']) || $row['img_original'] == $row['img_url']) {
if ($image != $row['img_url']) {
$sql = "UPDATE " . $GLOBALS['ecs']->table('goods_gallery') . " SET img_url='{$image}' WHERE img_id='{$row['img_id']}'";
$GLOBALS['db']->query($sql);
if ($row['img_original'] != $row['img_url']) {
@unlink(ROOT_PATH . $row['img_url']);
}
}
} else {
replace_image($image, $row['img_url'], $row['goods_id'], $silent);
}
}
/* 縮略圖 */
if ($thumb) {
if (empty($row['thumb_url'])) {
$dir = dirname(ROOT_PATH . $row['img_original']) . '/';
} else {
$dir = dirname(ROOT_PATH . $row['thumb_url']) . '/';
}
$thumb_url = $GLOBALS['image']->make_thumb(ROOT_PATH . $row['img_original'], $GLOBALS['_CFG']['thumb_width'], $GLOBALS['_CFG']['thumb_height'], $dir);
if (!$thumb_url) {
$msg = sprintf($GLOBALS['_LANG']['error_pos'], $row['goods_id']) . "\n" . $GLOBALS['image']->error_msg();
if ($silent) {
$GLOBALS['err_msg'][] = $msg;
continue;
} else {
make_json_error($msg);
}
}
/* 重新格式化圖片名稱 */
$thumb_url = reformat_image_name('gallery_thumb', $row['goods_id'], $thumb_url, 'thumb');
if ($change || empty($row['thumb_url'])) {
if ($thumb_url != $row['thumb_url']) {
$sql = "UPDATE " . $GLOBALS['ecs']->table('goods_gallery') . " SET thumb_url='{$thumb_url}' WHERE img_id='{$row['img_id']}'";
$GLOBALS['db']->query($sql);
@unlink(ROOT_PATH . $row['thumb_url']);
}
} else {
replace_image($thumb_url, $row['thumb_url'], $row['goods_id'], $silent);
}
}
}
}
}