Exemplo n.º 1
0
}
/*检验验证码*/
if ($_SESSION['rand'] != $_POST['code']) {
    $url = 'login.php?pass=reg';
    Header("Location: {$url}");
    exit;
}
$data = $user->_autoFill($_POST);
// 自动填充
$data = $user->_facade($data);
// 自动过滤
$data['nickname'] = '野人';
$data['head_img'] = 'templates/images/default.jpg';
$ori_img = $data['head_img'];
//缩略图
if ($ori_img) {
    $ori_img = ROOT . $ori_img;
    // 加上绝对路径
    $goods_img = dirname($ori_img) . '/small_' . basename($ori_img);
    if (ImageTool::thumb($ori_img, $goods_img, 93)) {
        $data['hd_small_img'] = str_replace(ROOT, '', $goods_img);
    }
}
if ($user->reg($data)) {
    $msg = '用户注册成功';
} else {
    $msg = '用户注册失败';
}
// 引入view
$url = 'login.php?pass=log';
Header("Location: {$url}");
Exemplo n.º 2
0
    echo "<script>alert('表单填写错误," . implode('', $goods->getError()) . "');history.back()</script>";
    exit;
}
/**
 * 上传图片
 */
$uptool = new UpTool();
$ori_img = $uptool->up('ori_img');
if ($ori_img) {
    $data['ori_img'] = $ori_img;
    /**
     * 如果上传成功  则生成缩略图 300*400
     * 再生成浏览时的小图 160*220
     */
    $ori_img = ROOT . $ori_img;
    $goods_image = dirname($ori_img) . '/goods_' . basename($ori_img);
    if (ImageTool::thumb($ori_img, $goods_image, 300, 400)) {
        $data['goods_img'] = str_replace(ROOT, '', $goods_image);
    }
    $thumb_image = dirname($ori_img) . '/thumb_' . basename($ori_img);
    if (ImageTool::thumb($ori_img, $thumb_image, 300, 400)) {
        $data['thumb_img'] = str_replace(ROOT, '', $thumb_image);
    }
}
if ($goods->add($data)) {
    echo "<script>alert('商品添加成功');history.back();</script>";
    exit;
} else {
    echo "<script>alert('商品添加失败');history.back();</script>";
    exit;
}
Exemplo n.º 3
0
    exit;
}
// 2012年12月4日 上传图片
$uptool = new UpTool();
$ori_img = $uptool->up('ori_img');
if ($ori_img) {
    $data['ori_img'] = $ori_img;
}
// 如果$ori_img上传成功,再次生成中等大小缩略图 300*400
// 根据原始地址 定 中等图的地址
// 例:aa.jpeg --> goods_aa.jpeg
if ($ori_img) {
    $ori_img = ROOT . $ori_img;
    // 加上绝对路径
    $goods_img = dirname($ori_img) . '/goods_' . basename($ori_img);
    if (ImageTool::thumb($ori_img, $goods_img, 300, 400)) {
        $data['goods_img'] = str_replace(ROOT, '', $goods_img);
    }
    // 再次生成浏览时用缩略图 160*220
    // 定好缩略图的地址
    // aa.jpeg --> thumb_aa.jpeg
    $thumb_img = dirname($ori_img) . '/thumb_' . basename($ori_img);
    if (ImageTool::thumb($ori_img, $thumb_img, 160, 220)) {
        $data['thumb_img'] = str_replace(ROOT, '', $thumb_img);
    }
}
if ($goods->add($data)) {
    echo '商品发布成功';
} else {
    echo '商品发布失败';
}
Exemplo n.º 4
0
        $color = imagecolorallocate($dim, 255, 255, 255);
        //填充颜色
        imagefill($dim, 0, 0, $color);
        //创建要缩略的图像
        $dfunc = 'imagecreatefrom' . $sinfo['ext'];
        $sim = $dfunc($src);
        //上下或者两边留白设置
        $dst_x = (int) ($width - (int) $sinfo['width'] * $calc) / 2;
        $dst_y = (int) ($height - (int) $sinfo['height'] * $calc) / 2;
        //缩略
        imagecopyresampled($dim, $sim, $dst_x, $dst_y, 0, 0, $sinfo['width'] * $calc, $sinfo['height'] * $calc, $sinfo['width'], $sinfo['height']);
        //保存图片如果没有传保存地址则覆盖原图
        if (!$save) {
            $save = $src;
        }
        $createfunc = 'image' . $sinfo['ext'];
        $createfunc($dim, $save);
        imagedestroy($dim);
        imagedestroy($sim);
        return true;
    }
}
// $dst = './1.png';
// $water = './1.jpg';
// //[加水印的位置:1=左上;2=上中;3=右上;4=左中;5=中中;6=右中;7=左下;8=中下;9=右下]
// ImageTool::water($dst, $water,2);
$src = './2222.jpg';
ImageTool::thumb($src, './thumb4.jpg', 200, 200);
ImageTool::thumb($src, './thumb5.jpg', 300, 200);
ImageTool::thumb($src, './thumb6.jpg', 200, 300);
Exemplo n.º 5
0
$word = new WordModel();
$data = array();
$data = $word->_facade($_POST);
// 自动过滤
$data = $word->_autoFill($data);
// 自动填充
$data['user_id'] = $_SESSION['id'];
$ori_img = $_POST['source_img'];
//缩略图
if ($ori_img) {
    $ori_img = ROOT . $ori_img;
    // 加上绝对路径
    $goods_img = dirname($ori_img) . '/small_' . basename($ori_img);
    if (ImageTool::thumb($ori_img, $goods_img, 230)) {
        $data['small_img'] = str_replace(ROOT, '', $goods_img);
    }
    // 再次生成浏览时用缩略图 160*220
    // 定好缩略图的地址
    // aa.jpeg --> thumb_aa.jpeg
    $thumb_img = dirname($ori_img) . '/center_' . basename($ori_img);
    if (ImageTool::thumb($ori_img, $thumb_img, 316)) {
        $data['center_img'] = str_replace(ROOT, '', $thumb_img);
    }
}
if ($word->add($data)) {
    $url = 'index.php';
    Header("Location: {$url}");
} else {
    $url = 'login.php?status=fial';
    Header("Location: {$url}");
}