当前位置: 首页>>代码示例>>PHP>>正文


PHP cls_image::get_filetype方法代码示例

本文整理汇总了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);
                }
            }
        }
    }
}
开发者ID:YangZeSummer,项目名称:NanJingSecond-Hand,代码行数:101,代码来源:picture_batch.php


注:本文中的cls_image::get_filetype方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。