Exemple #1
0
 function upload()
 {
     //图片上传
     $upObj = new IUpload();
     //目录散列
     $dir = IWeb::$app->config['upload'] . '/' . date('Y') . "/" . date('m') . "/" . date('d');
     $upObj->setDir($dir);
     $upState = $upObj->execute();
     //实例化
     $obj = new IModel('spec_photo');
     //检查上传状态
     foreach ($upState['attach'] as $val) {
         if ($val['flag'] == 1) {
             $insertData = array('address' => $val['dir'] . $val['name'], 'name' => $val['ininame'], 'create_time' => ITime::getDateTime());
             $obj->setData($insertData);
             $obj->add();
         }
     }
     if (count($upState['attach']) == 1) {
         return $upState['attach'][0];
     } else {
         return $upState['attach'];
     }
 }
Exemple #2
0
 function ad_edit_act()
 {
     $id = IFilter::act(IReq::get('id'), 'int');
     $adObj = new IModel('ad_manage');
     $error_message = null;
     //获取content数据
     $type = IReq::get('type', 'post');
     $content = IReq::get('content', 'post');
     $upObj = null;
     switch ($type) {
         case "1":
             //图片上传
             $upObj = new IUpload();
             $attach = 'img';
             break;
         case "2":
             //flash上传
             $upObj = new IUpload('4048', array('flv', 'swf'));
             $attach = 'flash';
             break;
         case "3":
             //文字
             $content = IReq::get('text', 'post');
             break;
         case "4":
             //代码
             $content = IReq::get('code', 'post');
             break;
     }
     if ($upObj != null) {
         //目录散列
         $dir = IWeb::$app->config['upload'] . '/' . date('Y') . "/" . date('m') . "/" . date('d');
         $upObj->setDir($dir);
         $upState = $upObj->execute();
         if (!isset($upState[$attach])) {
             if ($content == '') {
                 $error_message = '没有上传文件';
             }
         } else {
             if ($upState[$attach][0]['flag'] == 1) {
                 $content = $dir . '/' . $upState[$attach][0]['name'];
             } else {
                 $error_message = IUpload::errorMessage($upState[$attach][0]['flag']);
             }
         }
     } else {
         if ($content == '') {
             $error_message = '请填写广告展示类型的内容';
         }
     }
     $dataArray = array('content' => IFilter::addSlash($content), 'name' => IFilter::act(IReq::get('name')), 'position_id' => IFilter::act(IReq::get('position_id')), 'type' => IFilter::act(IReq::get('type')), 'link' => IFilter::addSlash(IReq::get('link')), 'start_time' => IFilter::act(IReq::get('start_time')), 'end_time' => IFilter::act(IReq::get('end_time')), 'description' => IFilter::act(IReq::get('description'), 'text'), 'order' => IFilter::act(IReq::get('order'), 'int'), 'goods_cat_id' => IFilter::act(IReq::get('goods_cat_id'), 'int'));
     //上传错误
     if ($error_message != null) {
         if ($id) {
             $dataArray['id'] = $id;
         }
         $this->adRow = $dataArray;
         $this->redirect('ad_edit', false);
         Util::showMessage($error_message);
     }
     $adObj->setData($dataArray);
     if ($id) {
         $where = 'id = ' . $id;
         $adObj->update($where);
     } else {
         $adObj->add();
     }
     $this->redirect("ad_list");
 }
Exemple #3
0
 /**
  * 导入商品csv
  * */
 function upload_csv()
 {
     $mark = IReq::get('marked');
     $csvType = IReq::get('date_format');
     //调用文件上传类
     $uploadObj = new IUpload(10240, array('csv'));
     $uploadObj->setDir('upload/' . date('Y/m/d'));
     $photo = $uploadObj->execute();
     if (!isset($photo['attach'][0]['flag']) || $photo['attach'][0]['flag'] == '-1') {
         echo "<br /><div align='center'>请选择CSV文件</div>";
         exit;
     }
     //上传路径
     $csvfile = $photo['attach'][0]['fileSrc'];
     //创建csv对象
     $csvObj = new Csv();
     $if_sucee = $csvObj->import($csvType, $csvfile, $mark);
     if ($if_sucee == '0') {
         IFile::unlink($csvfile);
         //导入成功,删除csv文件
         echo "<br /><div align='center'>商品CSV导入成功</div>";
     } else {
         IFile::unlink($csvfile);
         //导入失败,删除csv文件
         echo "<br /><div align='center'>商品CSV导入失败</div>";
     }
 }
Exemple #4
0
/runtime/_systemjs/artTemplate/artTemplate.js"></script><script type="text/javascript" charset="UTF-8" src="<?php 
echo BASE_URL;
?>
/runtime/_systemjs/artTemplate/artTemplate-plugin.js"></script>
<script type='text/javascript' src="<?php 
echo IUrl::creatUrl("") . "views/" . $this->theme . "/javascript/admin.js";
?>
"></script>
</head>
<body style="width:500px;min-height:470px;">
	<div class="pop_win">
		<ul class="red_box">
			<li>1、默认的CSV文件编码不是UTF-8编码的,必须要先转换编码,利用工具另存为UTF-8格式</li>
			<li>2、导入的商品必须插入到指定的一个或者多个商品分类中</li>
			<li>3、导入的CSV数据包必须是小于 <?php 
echo IUpload::getMaxSize();
?>
 的.ZIP压缩包,您可以通过修改php.ini中的 &lt;post_max_size&gt;和&lt;upload_max_filesize&gt;选项来修改上传数据包的大小</li>
			<li>4、数据包里面一级目录必须包括CSV文件和与之对应的CSV图片文件夹,且两者的名字必须相同对应起来且必须是英文。例如:&lt;summer.csv&gt; 和 &lt;summer&gt;</li>
		</ul>
		<form action='<?php 
echo IUrl::creatUrl("/goods/importCsvFile");
?>
' method='post' enctype='multipart/form-data' callback='checkForm();'>
			<table class="form_table" width="90%" cellspacing="0" cellpadding="0" border="0">
				<col width="120px" />
				<col />

				<tbody>
					<tr>
						<td>CSV数据类型</td>
Exemple #5
0
 /**
  * @brief 执行图片上传
  * @param boolean $isForge 是否伪造数据提交
  * @return array key:控件名; val:图片路径名;
  */
 public function run($isForge = false)
 {
     //创建图片模型对象
     $photoObj = new IModel('goods_photo');
     //已经存在的图片文件数据
     $photoArray = array();
     //过滤图库中已经存在的图片
     foreach ($_FILES as $key => $val) {
         //上传的所有临时文件
         $tmpFile = isset($_FILES[$key]['tmp_name']) ? $_FILES[$key]['tmp_name'] : null;
         //没有找到匹配的控件
         if ($tmpFile == null) {
             continue;
         }
         if (is_array($tmpFile)) {
             foreach ($tmpFile as $tmpKey => $tmpVal) {
                 $result = $this->checkIterance($tmpVal, $photoObj);
                 if ($result != null) {
                     $photoArray[$key][$tmpKey] = $result;
                     unset($_FILES[$key]['name'][$tmpKey]);
                     unset($_FILES[$key]['tmp_name'][$tmpKey]);
                 }
             }
         } else {
             $result = $this->checkIterance($tmpFile, $photoObj);
             if ($result != null) {
                 $photoArray[$key] = $result;
                 unset($_FILES[$key]);
             }
         }
     }
     //图片上传
     $upObj = new IUpload();
     $upObj->isForge = $isForge;
     $upObj->setDir($this->dir);
     $upState = $upObj->execute();
     //检查上传状态
     foreach ($upState as $key => $rs) {
         if (count($_FILES[$key]['name']) > 1) {
             $isArray = true;
         } else {
             $isArray = false;
         }
         foreach ($rs as $innerKey => $val) {
             if ($val['flag'] == 1) {
                 //上传成功后图片信息
                 $fileName = $val['dir'] . $val['name'];
                 $fileMD5 = md5_file($fileName);
                 $rs[$innerKey]['img'] = $fileName;
                 $insertData = array('id' => $fileMD5, 'img' => $fileName);
                 //将图片信息入库
                 $this->insert($insertData, $photoObj);
                 if ($this->thumbWidth && $this->thumbHeight && $this->thumbKey) {
                     //重新生成系统中不存在的此宽高的缩略图
                     foreach ($this->thumbKey as $thumbKey_key => $thumbKey_val) {
                         $thumbExtName = '_' . $this->thumbWidth[$thumbKey_key] . '_' . $this->thumbHeight[$thumbKey_key];
                         $thumbName = $this->thumb($fileName, $this->thumbWidth[$thumbKey_key], $this->thumbHeight[$thumbKey_key], $thumbExtName);
                         $rs[$innerKey]['thumb'][$this->thumbKey[$thumbKey_key]] = $thumbName;
                     }
                 }
             }
             if ($isArray == true) {
                 $photoArray[$key] = $rs;
             } else {
                 $photoArray[$key] = $rs[0];
             }
         }
     }
     return $photoArray;
 }
Exemple #6
0
 /**
  * @brief 更新支付方式插件
  */
 function payment_update()
 {
     //获取Post数据
     $payId = IFilter::act(IReq::get("pay_id"));
     $field['name'] = IFilter::act(IReq::get("name"));
     $field['type'] = IFilter::act(IReq::get("type"));
     $field['description'] = IFilter::act(IReq::get("description"), 'text');
     $field['poundage_type'] = IFilter::act(IReq::get("poundage_type"));
     $poundage_rate = IFilter::act(IReq::get("poundage_rate"));
     $poundage_fix = IFilter::act(IReq::get("poundage_fix"));
     if ($field['poundage_type'] == 1) {
         $field['poundage'] = $poundage_rate;
     } else {
         $field['poundage'] = $poundage_fix;
     }
     $field['plugin_id'] = IFilter::act(IReq::get("id"));
     $field['order'] = IFilter::act(IReq::get("order"));
     $pay_type = IFilter::act(IReq::get("pay_type"));
     $setting = IFilter::act(IReq::get("setting"));
     $field['note'] = IFilter::act(IReq::get('note'), 'text');
     //上传文件处理
     if ($_FILES) {
         //是否有文件上传
         $extend = array('key', 'crt', 'pem', 'cer');
         $upload = new IUpload(1024, $extend);
         $upload->setDir(IWEB::$app->config['upload'] . '/payment/' . $pay_type);
         $file = $upload->execute();
         foreach ($file['config'] as $key => $item) {
             $setting[$key] = $item['dir'] . $item['name'];
         }
     }
     $field['config'] = serialize($setting);
     //添加、修改已配置的支付插件
     $payment = new Payment();
     $result = $payment->Update($field, $payId);
     if ($result === false) {
         if ($payId) {
             $url = 'payment_edit/payid/' . $payId;
         } else {
             $url = 'payment_edit/id/' . $field['plugin_id'];
         }
         $this->redirect($url);
     } else {
         $logObj = new log('db');
         $logObj->write('operation', array("管理员:" . $this->admin['admin_name'], "修改了支付方式", '修改的支付方式为:' . $field['name']));
         $list = $payment->paymentList();
         $this->setRenderData(array("payment_list" => $list));
         $this->redirect('payment_list');
     }
 }
 /**
  * @brief 开始运行
  */
 public static function run()
 {
     set_time_limit(0);
     ini_set("max_execution_time", 0);
     $csvType = IReq::get('csvType');
     $category = IFilter::act(IReq::get('category'), 'int');
     $pluginDir = IWeb::$app->getBasePath() . 'plugins/csvPacketHelper/';
     if (!file_exists($pluginDir)) {
         die('此功能仅供授权版本使用,请您购买商业授权');
     }
     if (!class_exists('ZipArchive')) {
         die('服务器环境中没有安装zip扩展,无法使用此功能');
     }
     if (extension_loaded('mbstring') == false) {
         die('服务器环境中没有安装mbstring扩展,无法使用此功能');
     }
     //处理上传
     $uploadInstance = new IUpload(9999999, array('zip'));
     $uploadCsvDir = 'runtime/cvs/' . date('YmdHis');
     $uploadInstance->setDir($uploadCsvDir);
     $result = $uploadInstance->execute();
     if (!isset($result['csvPacket'])) {
         die('请上传指定大小的csv数据包');
     }
     if (($packetData = current($result['csvPacket'])) && $packetData['flag'] != 1) {
         $message = $uploadInstance->errorMessage($packetData['flag']);
         die($message);
     }
     $zipPath = $packetData['fileSrc'];
     $zipDir = dirname($zipPath);
     $imageDir = IWeb::$app->config['upload'] . '/' . date('Y/m/d');
     file_exists($imageDir) ? '' : IFile::mkdir($imageDir);
     //解压缩包
     $zipObject = new ZipArchive();
     $zipObject->open($zipPath);
     $isExtract = $zipObject->extractTo($zipDir);
     $zipObject->close();
     if ($isExtract == false) {
         $message = '解压缩到目录' . $zipDir . '失败!';
         die($message);
     }
     //实例化商品
     $goodsObject = new IModel('goods');
     $photoRelationDB = new IModel('goods_photo_relation');
     $photoDB = new IModel('goods_photo');
     $cateExtendDB = new IModel('category_extend');
     //获得配置文件中的数据
     $config = new Config("site_config");
     $dirHandle = opendir($zipDir);
     while ($fileName = readdir($dirHandle)) {
         if (strpos($fileName, '.csv') !== false) {
             //创建解析对象
             switch ($csvType) {
                 case "taobao":
                     include_once $pluginDir . 'taoBaoPacketHelper.php';
                     $helperInstance = new taoBaoPacketHelper($zipDir . '/' . $fileName, $imageDir);
                     $titleToCols = taoBaoTitleToColsMapping::$mapping;
                     break;
                 default:
                     $message = "请选择csv数据包的格式";
                     die($message);
             }
             //从csv中解析数据
             $collectData = $helperInstance->collect();
             //插入商品表
             foreach ($collectData as $key => $val) {
                 $collectImage = isset($val[$titleToCols['img']]) ? $val[$titleToCols['img']] : '';
                 //有图片处理
                 if ($collectImage) {
                     //图片拷贝
                     $_FILES = array();
                     foreach ($collectImage as $image) {
                         foreach ($image as $from => $to) {
                             if (!is_file($from)) {
                                 continue;
                             }
                             IFile::xcopy($from, $to);
                             //构造$_FILES全局数组
                             $_FILES[] = array('size' => 100, 'tmp_name' => $to, 'name' => basename($to), 'error' => 0);
                         }
                     }
                     //调用文件上传类
                     $photoObj = new PhotoUpload();
                     $uploadImg = $photoObj->run(true);
                     $showImg = current($uploadImg);
                 }
                 //处理商品详情图片
                 $toDir = IUrl::creatUrl() . dirname($to);
                 $goodsContent = preg_replace("|src=\".*?(?=/contentPic/)|", "src=\"{$toDir}", trim($val[$titleToCols['content']], "'\""));
                 $insertData = array('name' => IFilter::act(trim($val[$titleToCols['name']], '"\'')), 'goods_no' => goods_class::createGoodsNo(), 'sell_price' => IFilter::act($val[$titleToCols['sell_price']], 'float'), 'market_price' => IFilter::act($val[$titleToCols['sell_price']], 'float'), 'up_time' => ITime::getDateTime(), 'create_time' => ITime::getDateTime(), 'store_nums' => IFilter::act($val[$titleToCols['store_nums']], 'int'), 'content' => IFilter::addSlash($goodsContent), 'img' => isset($showImg['img']) ? $showImg['img'] : '', 'seller_id' => self::$seller_id);
                 $goodsObject->setData($insertData);
                 $goods_id = $goodsObject->add();
                 //处理商品分类
                 if ($category) {
                     foreach ($category as $catId) {
                         $cateExtendDB->setData(array('goods_id' => $goods_id, 'category_id' => $catId));
                         $cateExtendDB->add();
                     }
                 }
                 //处理商品图片
                 if ($uploadImg) {
                     $imgArray = array();
                     foreach ($uploadImg as $temp) {
                         if (isset($temp['img']) && $temp['img']) {
                             $imgArray[] = $temp['img'];
                         }
                     }
                     if ($imgArray) {
                         $photoData = $photoDB->query('img in ("' . join('","', $imgArray) . '")', 'id');
                         if ($photoData) {
                             foreach ($photoData as $item) {
                                 $photoRelationDB->setData(array('goods_id' => $goods_id, 'photo_id' => $item['id']));
                                 $photoRelationDB->add();
                             }
                         }
                     }
                 }
             }
         }
     }
     //清理csv文件数据
     IFile::rmdir($uploadCsvDir, true);
     die('<script type="text/javascript">parent.artDialogCallback();</script>');
 }
Exemple #8
0
 function ad_edit_act()
 {
     $id = IFilter::act(IReq::get('id'), 'int');
     $content = IReq::get('content');
     //附件上传
     if (isset($_FILES) && $_FILES) {
         $upType = isset($_FILES['img']) ? array("gif", "png", "jpg") : array('flv', 'swf');
         $upObj = new IUpload("5000", $upType);
         $dir = IWeb::$app->config['upload'] . '/' . date('Y') . "/" . date('m') . "/" . date('d');
         $upObj->setDir($dir);
         $upState = $upObj->execute();
         $result = $upState ? current($upState) : "";
         if ($result && isset($result[0]['flag']) && $result[0]['flag'] == 1) {
             //最终附件路径
             $content = $dir . '/' . $result[0]['name'];
         } else {
             if (!$content) {
                 IError::show(403, "请上传正确的附件数据");
             }
         }
     }
     $adObj = new IModel('ad_manage');
     $dataArray = array('content' => IFilter::addSlash($content), 'name' => IFilter::act(IReq::get('name')), 'position_id' => IFilter::act(IReq::get('position_id')), 'type' => IFilter::act(IReq::get('type')), 'link' => IFilter::addSlash(IReq::get('link')), 'start_time' => IFilter::act(IReq::get('start_time')), 'end_time' => IFilter::act(IReq::get('end_time')), 'description' => IFilter::act(IReq::get('description'), 'text'), 'order' => IFilter::act(IReq::get('order'), 'int'), 'goods_cat_id' => IFilter::act(IReq::get('goods_cat_id'), 'int'));
     $adObj->setData($dataArray);
     if ($id) {
         $where = 'id = ' . $id;
         $adObj->update($where);
     } else {
         $adObj->add();
     }
     $this->redirect("ad_list");
 }