コード例 #1
0
ファイル: post.php プロジェクト: skyverd/heis
<?php

require_once 'config.php';
if (!defined('IN_APP')) {
    exit('Access Deny');
}
$allowTypeList = array('image/gif', 'image/jpeg', 'image/png');
$uploadType = $_FILES['file']['type'];
if (!in_array($uploadType, $allowTypeList)) {
    exit('非法格式文件');
}
$pathInfo = pathinfo($_FILES['file']['name']);
$ts = md5(time());
$newfileName = $ts . $config['fileType'];
move_uploaded_file($_FILES['file']['tmp_name'], $config['path'] . "/" . $newfileName);
require_once dirname(__FILE__) . '/Driver/ThinkImage.class.php';
$img = new ThinkImage(THINKIMAGE_GD, $config['path'] . '/' . $newfileName);
$img->thumb(200, 200, THINKIMAGE_THUMB_CENTER)->save($config['path'] . '/' . $newfileName);
header('Location:gen.php?name=' . $ts);
コード例 #2
0
ファイル: common.php プロジェクト: project-store/phpsite
/**
 * 生成缩略图
 * @param string $imageFile
 */
function makeThumb($imageFile)
{
    if (!file_exists($imageFile)) {
        return false;
    }
    if (!yd_is_image($imageFile)) {
        return false;
    }
    $data = YdCache::readThumb();
    if ($data['THUMB_ENABLE'] == 1) {
        $w = $data['THUMB_WIDTH'];
        //缩略图宽度
        $h = $data['THUMB_HEIGHT'];
        //缩略图高度
        $type = $data['THUMB_TYPE'];
        //缩略图类型
        $filename = './Upload/thumb' . basename($imageFile);
        import('ORG.Util.Image.ThinkImage');
        $img = new ThinkImage(THINKIMAGE_GD, $imageFile);
        $img->thumb($w, $h, $type)->save($filename);
        if ($data['THUMB_WATER_ENABLE'] == 1) {
            //是否添加水印
            addWater($filename);
        }
        return $filename;
    } else {
        return $imageFile;
    }
}
コード例 #3
0
ファイル: ItemAction.class.php プロジェクト: lz1988/lejing
 public function item_edit()
 {
     //资讯编辑
     if ($_POST) {
         $item = D("item");
         $item_id = $_POST['item_id'];
         $_POST['content'] = str_replace('src="/Uploads/Attached/', 'src="http://' . $_SERVER[SERVER_NAME] . '/Uploads/Attached/', $_POST['content']);
         //$_POST['color']=implode(',',array_filter(array_unique($_POST['color'])));
         //print_r($_POST[style]);exit;
         /*$_POST['style']=implode(',',$_POST[style]);
         		$_POST['titanium_id']=implode(',',$_POST[titanium_id]);*/
         $_POST['item_type'] = implode(',', $_POST['item_type']);
         $_POST['shop_type'] = implode(',', $_POST['shop_type']);
         //echo '<pre>';print_r($_POST);
         //die();
         if ($vo = $item->create()) {
             /*print_r($vo);*/
             $list = $item->save();
             /*echo $item->getLastSql();
               die();*/
             if ($list !== false) {
                 //添加关联商品
                 $gruop_item_id = array_filter(array_unique($_POST['gruop_item_id']));
                 $str_group_id = implode(',', $gruop_item_id);
                 $item_brother = M('item_brother');
                 $group_del['item_id'] = array('eq', $item_id);
                 $resg = $item_brother->where($group_del)->delete();
                 for ($ik = 0; $ik < count($gruop_item_id); $ik++) {
                     $data_gruop[] = array('item_id' => $item_id, 'brother_item_id' => $gruop_item_id[$ik]);
                 }
                 if (!empty($data_gruop)) {
                     $item_brother->addAll($data_gruop);
                 }
                 $item_images = M('item_images');
                 $item_images->where(array('item_id' => array('eq', $item_id)))->delete();
                 //添加商品图片
                 import('ORG.Util.Image.ThinkImage');
                 $images_thumb = $_POST['item_pic'];
                 $arraythumb = C('ITEM_THUMB');
                 $i = 0;
                 //print_r($images_thumb);exit;
                 foreach ($images_thumb as $key => $val) {
                     $filename = substr($val, strrpos($val, '/') + 1);
                     $filenamearr = explode('.', $filename);
                     if ($val == "") {
                         continue;
                     }
                     foreach ($arraythumb as $key1 => $val1) {
                         $filenamethumb = $_SERVER['DOCUMENT_ROOT'] . $val . '_' . $val1[0] . 'X' . $val1[1] . '.jpg';
                         $img = new ThinkImage(THINKIMAGE_GD, $_SERVER['DOCUMENT_ROOT'] . $val);
                         $img->thumb($val1[0], $val1[1], THINKIMAGE_THUMB_SCALING)->save($filenamethumb);
                     }
                     $data_image[] = array('item_id' => $item_id, 'img_path' => "{$val}", 'sort' => ++$i);
                 }
                 if (!empty($data_image)) {
                     $item_images->addAll($data_image);
                     $save_data['icon'] = $data_image[0]['img_path'];
                     $item->where("item_id={$item_id}")->save($save_data);
                 }
                 $this->success('数据保存成功!', "__APP__/Item/item_list/");
                 exit;
             } else {
                 $this->error("没有更新任何数据!", "__APP__/Item/item_list/");
             }
         } else {
             $this->error($item->getError());
         }
         exit;
     }
     /**新闻分类**/
     $newstype = M("newstype");
     $newstypeinfo = $newstype->where("is_del='0'")->order('sort ASC')->select();
     $this->assign('newstypearr', $newstypeinfo);
     //echo '<pre>';print_r($newstypeinfo);
     $item = M("item");
     $id = $_GET["_URL_"][2];
     $condition['item_id'] = $id;
     //使用查询条件
     $infoAll = $item->where($condition)->find();
     //$infoAll['style']=explode(',',$infoAll['style']);
     //$infoAll['titanium_id']=explode(',',$infoAll['titanium_id']);
     $this->assign('arr', $infoAll);
     // $color_arr=explode(',',$infoAll['color']);
     //print_r($color_arr);exit;
     //$this->assign('color_arr',$color_arr);
     $item_images = M('item_images');
     $list_image = $item_images->where("item_id=" . $infoAll[item_id])->order('img_id ASC')->select();
     $this->assign('list_image', $list_image);
     $item_brother = M('item_brother');
     $br_where['b.item_id'] = array('eq', $infoAll[item_id]);
     $brother_list = $item_brother->join('as b LEFT JOIN cms_item as i ON i.item_id=b.brother_item_id')->field('i.item_name,i.color,i.item_id')->where($br_where)->select();
     $this->assign('brother_list', $brother_list);
     $this->display();
 }