/**
  * @brief 渲染处理
  * @param string $viewFile 要渲染的页面
  * @param string or array $rdata 要渲染的数据
  */
 public function renderView($viewFile, $rdata = null)
 {
     //要渲染的视图
     $renderFile = $viewFile . $this->extend;
     //检查视图文件是否存在
     if (is_file($renderFile)) {
         //控制器的视图(需要进行编译编译并且生成可以执行的php文件)
         if (stripos($renderFile, IWEB_PATH . 'web/view/') === false) {
             //生成文件路径
             $runtimeFile = str_replace($this->getViewPath(), $this->module->getRuntimePath(), $viewFile . $this->defaultExecuteExt);
             //layout文件
             $layoutFile = $this->getLayoutFile() . $this->extend;
             if (!is_file($runtimeFile) || filemtime($renderFile) > filemtime($runtimeFile) || is_file($layoutFile) && filemtime($layoutFile) > filemtime($runtimeFile)) {
                 //获取view内容
                 $viewContent = file_get_contents($renderFile);
                 //处理layout
                 $viewContent = $this->renderLayout($layoutFile, $viewContent);
                 //标签编译
                 $inputContent = $this->tagResolve($viewContent);
                 //创建文件
                 $fileObj = new IFile($runtimeFile, 'w+');
                 $fileObj->write($inputContent);
                 $fileObj->save();
                 unset($fileObj);
             }
         } else {
             $runtimeFile = $renderFile;
         }
         //引入编译后的视图文件
         $this->requireFile($runtimeFile, $rdata);
     } else {
         return false;
     }
 }
Exemple #2
0
	/**
	 * @param IFile
	 */
	public function actionFile(IFile $file)
	{
		$this->sendResponse(new \Nette\Application\Responses\FileResponse(
			$file->getFileinfo()->getRealPath(), //$file->getContent(),
			$file->getFilename(),
			$file->getMimeType()
		));
		$this->terminate();
	}
 public static function load($name, $charset = 'UTF-8')
 {
     if (isset(self::$JSPackages[$name])) {
         if (!isset(self::$createfiles[$name])) {
             $is_file = false;
             $file = null;
             if (is_string(self::$JSPackages[$name])) {
                 if (stripos(self::$JSPackages[$name], '/') === false) {
                     $is_file = true;
                     $file = self::$JSPackages[$name];
                 } else {
                     $file = dirname(self::$JSPackages[$name]);
                 }
             } else {
                 if (is_array(self::$JSPackages[$name]['js'])) {
                     $file = dirname(self::$JSPackages[$name]['js'][0]);
                 } else {
                     $file = dirname(self::$JSPackages[$name]['js']);
                 }
             }
             if (!file_exists(IWeb::$app->getRuntimePath() . 'systemjs/' . $file)) {
                 self::$createfiles[$name] = true;
                 IFile::xcopy(IWEB_PATH . 'web/js/source/' . $file, IWeb::$app->getRuntimePath() . 'systemjs/' . $file);
             }
         }
         $webjspath = IWeb::$app->getWebRunPath() . '/systemjs/';
         if (is_string(self::$JSPackages[$name])) {
             return '<script charset="' . $charset . '" src="' . $webjspath . self::$JSPackages[$name] . '"></script>';
         } else {
             if (is_array(self::$JSPackages[$name])) {
                 $str = '';
                 if (isset(self::$JSPackages[$name]['css'])) {
                     if (is_string(self::$JSPackages[$name]['css'])) {
                         $str .= '<link rel="stylesheet" type="text/css" href="' . $webjspath . self::$JSPackages[$name]['css'] . '"/>';
                     } else {
                         if (is_array(self::$JSPackages[$name]['css'])) {
                             foreach (self::$JSPackages[$name]['css'] as $css) {
                                 $str .= '<link rel="stylesheet" type="text/css" href="' . $webjspath . $css . '"/>';
                             }
                         }
                     }
                 }
                 if (isset(self::$JSPackages[$name]['js'])) {
                     if (is_array(self::$JSPackages[$name]['js'])) {
                         foreach (self::$JSPackages[$name]['js'] as $js) {
                             $str .= '<script charset="' . $charset . '" src="' . $webjspath . $js . '"></script>';
                         }
                     } else {
                         $str .= '<script charset="' . $charset . '" src="' . $webjspath . self::$JSPackages[$name]['js'] . '"></script>';
                     }
                 }
                 return $str;
             }
         }
     } else {
         return '';
     }
 }
Exemple #4
0
 public static function run($title, $key)
 {
     set_time_limit(0);
     $data = array("data" => $title, "respond" => "json", "ignore" => 'yes');
     $data = http_build_query($data);
     $re = IFile::socket("http://www.ftphp.com/scws/api.php", 0, $data);
     if (!$re) {
         return array('words' => array());
     }
     return JSON::decode($re);
 }
Exemple #5
0
 /**
  * @brief Éú³ÉËõÂÔͼ
  * @param string $image_url ͼƬ·¾¶
  * @param int $width ͼƬ¿í¶È
  * @param int $height ͼƬ¸ß¶È
  */
 public static function get($image_url, $width = 100, $height = 100)
 {
     if ($image_url == '') {
         return '';
     }
     $fileExt = IFile::getFileSuffix($image_url);
     $extName = "_{$width}_{$height}";
     $thumbFileName = str_replace('.' . $fileExt, $extName . '.' . $fileExt, $image_url);
     if (is_file(IWeb::$app->getRuntimePath() . $thumbFileName) == false) {
         PhotoUpload::thumb($image_url, $width, $height, "_{$width}_{$height}", IWeb::$app->getRuntimePath() . dirname($image_url));
     }
     return 'runtime/' . IWeb::$app->controller->theme . '/' . $thumbFileName;
 }
 /**
  * @param IFile $file
  * @param bool $foldersFirst
  * @return int A negative value if the current file should be placed before $file,
  * zero (0) if they are equals, a positive value otherwise.
  */
 public function compareTo(IFile $file, $foldersFirst = false)
 {
     if ($foldersFirst) {
         $isDirThis = $this->isDirectory();
         $isDirFile = $file->isDirectory();
         if ($isDirThis && !$isDirFile) {
             return -1;
         } else {
             if ($isDirFile && !$isDirThis) {
                 return 1;
             }
         }
     }
     $urlParts = $file->getURLComponents();
     $urlParts['path'] = $file->getPathFromRoot();
     //needed to resolve the path (if relative)
     $absolutePathFile = AdvancedPathLib::buildURL($urlParts);
     $urlParts = $this->getURLComponents();
     $urlParts['path'] = $this->getPathFromRoot();
     //needed to resolve the path (if relative)
     $absolutePathThis = AdvancedPathLib::buildURL($urlParts);
     return utf8_strcasecmp($absolutePathThis, $absolutePathFile);
 }
Exemple #7
0
 public function export($csvType, $id, $tao_arr)
 {
     if ($csvType == 'goods_csv') {
         $this->getInstance($csvType);
         $this->csv->export($id);
         $this->DownLoad();
         //生成并下载压缩文件
         IFile::clearDir('backup/goods');
         //删除goods文件夹下的所有文件
         return 0;
     }
     if ($csvType == 'taobao_csv') {
         $this->getInstance($csvType);
         return $this->csv->export($id, $tao_arr);
     }
 }
Exemple #8
0
 /**
  * @brief 生成缩略图
  * @param string  $fileName 原图路径
  * @param int     $width    缩略图的宽度
  * @param int     $height   缩略图的高度
  * @param string  $extName  缩略图文件名附加值
  * @param string  $saveDir  缩略图存储目录
  * @return string 缩略图文件名
  */
 public static function thumb($fileName, $width = 200, $height = 200, $extName = '_thumb', $saveDir = '')
 {
     $GD = new GD($fileName);
     if ($GD) {
         $GD->resize($width, $height);
         $GD->pad($width, $height);
         //存储缩略图
         if ($saveDir && IFile::mkdir($saveDir)) {
             //生成缩略图文件名
             $thumbBaseName = $extName . basename($fileName);
             $thumbFileName = $saveDir . basename($thumbBaseName);
             $GD->save($thumbFileName);
             return $thumbFileName;
         } else {
             return $GD->show();
         }
     }
     return null;
 }
Exemple #9
0
 /**
  * @brief  写日志
  * @param  array  $content loginfo数组
  * @return bool   操作结果
  */
 public function write($logs = array())
 {
     if (!is_array($logs) || empty($logs)) {
         throw new IException('the $logs parms must be array');
     }
     if ($this->path == '') {
         throw new IException('the file path is undefined');
     }
     $content = join("\t", $logs) . "\t\r\n";
     //生成路径
     $fileName = $this->path;
     if (!file_exists($dirname = dirname($fileName))) {
         IFile::mkdir($dirname);
     }
     $result = error_log($content, 3, $fileName);
     if ($result) {
         return true;
     } else {
         return false;
     }
 }
 /**
  * @brief 加载系统的JS方法
  * @param $name    string
  * @param $charset string
  * @return String
  */
 public static function load($name, $charset = 'UTF-8')
 {
     if (!isset(self::$JSPackages[$name])) {
         return '';
     }
     $dir = self::getFileOrDir(self::$JSPackages[$name]);
     $realjspath = IWeb::$app->getBasePath() . 'runtime/_systemjs/' . $dir;
     //如果没有创建就开始拷贝文件
     if (!file_exists($realjspath)) {
         IFile::xcopy(IWEB_PATH . 'web/js/source/' . $dir, $realjspath);
     }
     $webjspath = IUrl::creatUrl('') . 'runtime/_systemjs/';
     $resultString = '';
     foreach (self::$JSPackages[$name] as $key => $val) {
         switch ($key) {
             case "js":
                 if (is_array($val)) {
                     foreach ($val as $file) {
                         $resultString .= self::getJsHtml($webjspath . $file, $charset);
                     }
                 } else {
                     $resultString .= self::getJsHtml($webjspath . $val, $charset);
                 }
                 break;
             case "css":
                 if (is_array($val)) {
                     foreach ($val as $file) {
                         $resultString .= self::getCssHtml($webjspath . $file, $charset);
                     }
                 } else {
                     $resultString .= self::getCssHtml($webjspath . $val, $charset);
                 }
                 break;
             case "callback":
                 $resultString .= call_user_func(array('IJSPackage', $val));
                 break;
         }
     }
     return $resultString;
 }
Exemple #11
0
 /**
  * @return bool TRUE if the file has been successfully renamed, FALSE otherwise
  */
 public function renameTo($newName)
 {
     if ($this->realFile === null) {
         throw new EyeUnsupportedOperationException(__METHOD__ . ' on ' . $this->path);
     }
     if (!$this->exists()) {
         throw new EyeFileNotFoundException($this->path . ' does not exist.');
     }
     if ($this->isRoot()) {
         throw new EyeUnsupportedOperationException('Cannot rename the root folder.');
     }
     $oldName = $this->getName();
     $oldPath = $this->getAbsolutePath();
     $this->getParentFile()->checkWritePermission();
     $newFile = FSI::getFile(dirname($oldPath) . '/' . $newName);
     $newFile->checkWritePermission();
     try {
         if ($this->realFile->renameTo($newName)) {
             //change internal name in URL
             $urlParts = $this->getURLComponents();
             $dirname = dirname($urlParts['path']);
             $urlParts['path'] = $dirname . '/' . $newName;
             $this->path = AdvancedPathLib::buildUrl($urlParts);
             //Update URL components cache
             $this->urlParts = $urlParts;
             //update metadata
             MetaManager::getInstance()->updateMeta($this, array('oldName' => $oldName));
             $oldFile = FSI::getFile($oldPath);
             //notify listeners
             $this->fireEvent('fileRenamed', new FileEvent($oldFile, $this));
             return true;
         }
     } catch (EyeFileNotFoundException $e) {
         throw new EyeFileNotFoundException($this->path . ' does not exist.', 0, $e);
     } catch (EyeException $e) {
         throw new EyeIOException('Unable to rename file ' . $this->path . '.', 0, $e);
     }
     throw new EyeIOException('Unable to rename file ' . $this->path . '.');
 }
 /**
  * TODO: a good algorithm with a stack would be much better here...
  * 
  * @param IFile $root
  * @param IFile $leaf
  * @param int $depth
  * @return mixed An array of serialized IFiles (see self::toArray),
  *         or FALSE if the maximum depth has been reached.
  */
 private static function getFilesAsTree_private(IFile $root, IFile $leaf = null, $depth)
 {
     if ($depth < 0) {
         if ($leaf === null || stripos($leaf->getAbsolutePath(), $root->getAbsolutePath()) !== 0) {
             //We're not in the branch leading to the specified leaf: stop recursion here
             return false;
         }
     }
     $folders = array();
     foreach ($root->listFiles('*', AdvancedPathLib::GLOB_ONLY_DIR) as $folder) {
         try {
             $subFolders = self::getFilesAsTree_private($folder, $leaf, $depth - 1);
         } catch (Exception $e) {
             $subFolders = array(self::toArray(false));
         }
         $folder = self::toArray($folder);
         $folder['subFolders'] = $subFolders;
         $folders[] = $folder;
     }
     return $folders;
 }
?>
</td>
</tr>
<tr>

<tr>
<td>
<?php 
echo _("Fichier");
$s = dossier::get();
echo '<A HREF="show_document_modele.php?md_id=' . $doc->md_id . '&' . $s . '">(fichier actuel)</a>';
?>
</td>
<td>
<?php 
$file = new IFile('doc');
echo $file->input();
?>
</td>
</tr>

<tr>
<td>
<?php 
echo _("Dernier numéro utilisé pour ce type de document");
?>
</td>
<td>
<?php 
$last = 0;
if ($cn->exist_sequence("seq_doc_type_" . $doc->md_type)) {
 /**
  * @brief 对字符串进行普通的过滤处理
  * @param string $str      被过滤的字符串
  * @param int    $limitLen 限定字符串的字节数
  * @return string 被过滤后的字符串
  * @note 仅对于部分如:<script,<iframe等标签进行过滤
  */
 public static function text($str, $limitLen = false)
 {
     $str = self::limitLen($str, $limitLen);
     $str = trim($str);
     require_once dirname(__FILE__) . "/htmlpurifier-4.3.0/HTMLPurifier.standalone.php";
     $cache_dir = hopedir . "templates_c/htmlpurifier/";
     if (!file_exists($cache_dir)) {
         IFile::mkdir($cache_dir);
     }
     $config = HTMLPurifier_Config::createDefault();
     //配置 允许flash
     $config->set('HTML.SafeEmbed', true);
     $config->set('HTML.SafeObject', true);
     $config->set('Output.FlashCompat', true);
     //配置 缓存目录
     $config->set('Cache.SerializerPath', $cache_dir);
     //设置cache目录
     //允许<a>的target属性
     $def = $config->getHTMLDefinition(true);
     $def->addAttribute('a', 'target', 'Enum#_blank,_self,_target,_top');
     $purifier = new HTMLPurifier($config);
     //过略掉所有<script>,<i?frame>标签的on事件,css的js-expression、import等js行为,a的js-href
     return $purifier->purify($str);
 }
Exemple #15
0
 /**
  * @brief 对字符串进行普通的过滤处理
  * @param string $str      被过滤的字符串
  * @param int    $limitLen 限定字符串的字节数
  * @return string 被过滤后的字符串
  * @note 仅对于部分如:<script,<iframe等标签进行过滤
  */
 public static function text($str, $limitLen = false)
 {
     $str = self::limitLen($str, $limitLen);
     $str = trim($str);
     require_once FCPATH . 'libs/htmlpurifier/HTMLPurifier.php';
     $cache_dir = IWeb::$app->getRuntimePath() . "htmlpurifier/";
     if (!file_exists($cache_dir)) {
         IFile::mkdir($cache_dir);
     }
     $config = HTMLPurifier_Config::createDefault();
     //配置 允许flash
     $config->set('HTML.SafeEmbed', true);
     $config->set('HTML.SafeObject', true);
     $config->set('Output.FlashCompat', true);
     //配置 缓存目录
     $config->set('Cache.SerializerPath', $cache_dir);
     //设置cache目录
     //允许<a>的target属性
     $def = $config->getHTMLDefinition(true);
     $def->addAttribute('a', 'target', 'Enum#_blank,_self,_target,_top');
     $purifier = new HTMLPurifier($config);
     //过略掉所有<script>,<i?frame>标签的on事件,css的js-expression、import等js行为,a的js-href
     $str = $purifier->purify($str);
     return self::addSlash($str);
 }
Exemple #16
0
 function writeFile($fileName, $content)
 {
     $fileObj = new IFile($fileName, 'a+');
     $fileObj->write($content);
 }
 /**
  * @brief  删除全部缓存
  * @return bool   true:成功;false:失败;
  */
 public function flush()
 {
     return IFile::clearDir($this->cachePath);
 }
Exemple #18
0
 function clearCache()
 {
     $runtimePath = $this->module->getRuntimePath();
     $result = IFile::clearDir($runtimePath);
     if ($result == true) {
         echo 1;
     } else {
         echo -1;
     }
 }
Exemple #19
0
 function delgoodsimg()
 {
     $id = intval(IReq::get('id'));
     $this->checkshoplogin();
     $shopid = ICookie::get('adminshopid');
     if (empty($shopid)) {
         $this->message('未选择店铺');
     }
     $goodsinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "goods where id ='" . $id . "' and shopid ='" . $shopid . "' ");
     if (empty($goodsinfo)) {
         $this->message('商品信息获取失败');
     }
     if (!empty($goodsinfo['img'])) {
         IFile::unlink(hopedir . $goodsinfo['img']);
         $udata['img'] = '';
         $this->mysql->update(Mysite::$app->config['tablepre'] . 'goods', $udata, "id='" . $id . "'");
     }
     $this->success('操作成功');
 }
Exemple #20
0
 /**
  * @brief 生成缩略图
  * @param string  $fileName 生成缩略图的目标文件名
  * @param int     $width    缩略图的宽度
  * @param int     $height   缩略图的高度
  * @param string  $ExtName  缩略图文件名附加值
  * @return string 缩略图文件名
  */
 public static function thumb($fileName, $width = 200, $height = 200, $ExtName = '_thumb')
 {
     if (is_file($fileName)) {
         //获取原图信息
         list($imgWidth, $imgHeight) = getImageSize($fileName);
         //计算宽高比例,获取缩略图的宽度和高度
         if ($imgWidth >= $imgHeight) {
             $thumbWidth = $width;
             $thumbHeight = $width / $imgWidth * $imgHeight;
         } else {
             $thumbWidth = $height / $imgHeight * $imgWidth;
             $thumbHeight = $height;
         }
         //生成$fileName文件图片资源
         $thumbRes = self::createImageResource($fileName);
         $thumbBox = imageCreateTrueColor($width, $height);
         //填充补白
         $padColor = imagecolorallocate($thumbBox, 255, 255, 255);
         imagefilledrectangle($thumbBox, 0, 0, $width, $height, $padColor);
         //拷贝图像
         imagecopyresampled($thumbBox, $thumbRes, ($width - $thumbWidth) / 2, ($height - $thumbHeight) / 2, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight);
         //生成缩略图文件名
         $fileExt = IFile::getFileSuffix($fileName);
         $thumbFileName = str_replace('.' . $fileExt, $ExtName . '.' . $fileExt, $fileName);
         //生成图片文件
         $result = self::createImageFile($thumbBox, $thumbFileName);
         if ($result == true) {
             return $thumbFileName;
         } else {
             return null;
         }
     } else {
         return null;
     }
 }
Exemple #21
0
 /**
  * @brief  开始执行上传
  * @return array 包含上传成功信息的数组
  *		$file = array(
  *			 name    如果上传成功,则返回上传后的文件名称,如果失败,则返回客户端名称
  *			 size    上传附件大小
  *           fileSrc 上传文件完整路径
  *			 dir     上传目录
  *			 ininame 上传图片名
  *			 flag    -1:上传的文件超出服务器限制; -2:上传的文件超出浏览器限制; -3:上传的文件被部分上传; -4:没有找到上传的文件; -5:上传的文件丢失;
  *                   -6:上传的临时文件没有正确写入; -7:扩展名不允许上传; -8:上传的文件超出了程序的限制; -9:上传的文件中有木马病毒 ; 1:上传成功;
  *			 ext     上传附件扩展名
  *		);
  */
 public function execute()
 {
     //总的文件上传信息
     $info = array();
     foreach ($_FILES as $field => $file) {
         $fileInfo = array();
         //不存在上传的文件名
         if (!isset($_FILES[$field]['name']) || $_FILES[$field]['name'] == '') {
             continue;
         }
         //上传控件为数组格式 file[]格式
         if (is_array($_FILES[$field]['name'])) {
             $keys = array_keys($_FILES[$field]['name']);
             foreach ($keys as $key) {
                 $fileInfo[$key]['name'] = $_FILES[$field]['name'][$key];
                 //上传出现错误
                 if (isset($_FILES[$field]['error'][$key]) && $_FILES[$field]['error'][$key] != 0) {
                     $fileInfo[$key]['flag'] = 0 - $_FILES[$field]['error'][$key];
                 } else {
                     //获取扩展名
                     $fileext = IFile::getFileType($_FILES[$field]['tmp_name'][$key]);
                     if (is_array($fileext) || $fileext == null) {
                         $fileext = IFile::getFileSuffix($_FILES[$field]['name'][$key]);
                     }
                     //图片木马检测
                     if (in_array($fileext, $this->checkType) && !IFilter::checkHex($_FILES[$field]['tmp_name'][$key])) {
                         $fileInfo[$key]['flag'] = -9;
                     } else {
                         /*开始上传文件*/
                         //(1)上传类型不符合
                         if (!in_array($fileext, $this->allowType)) {
                             $fileInfo[$key]['flag'] = -7;
                         } else {
                             if ($_FILES[$field]['size'][$key] > $this->maxsize) {
                                 $fileInfo[$key]['flag'] = -8;
                             } else {
                                 //修改图片状态值
                                 $fileInfo[$key]['name'] = ITime::getDateTime('Ymdhis') . mt_rand(100, 999) . '.' . $fileext;
                                 $fileInfo[$key]['dir'] = $this->dir;
                                 $fileInfo[$key]['size'] = $_FILES[$field]['size'][$key];
                                 $fileInfo[$key]['ininame'] = $_FILES[$field]['name'][$key];
                                 $fileInfo[$key]['ext'] = $fileext;
                                 $fileInfo[$key]['fileSrc'] = $fileInfo[$key]['dir'] . $fileInfo[$key]['name'];
                                 $fileInfo[$key]['flag'] = 1;
                                 if ($this->isForge == false) {
                                     if (is_uploaded_file($_FILES[$field]['tmp_name'][$key])) {
                                         IFile::mkdir($this->dir);
                                         move_uploaded_file($_FILES[$field]['tmp_name'][$key], $this->dir . $fileInfo[$key]['name']);
                                     }
                                 } else {
                                     IFile::xcopy($_FILES[$field]['tmp_name'][$key], $this->dir . $fileInfo[$key]['name']);
                                 }
                             }
                         }
                     }
                 }
             }
         } else {
             $fileInfo[0]['name'] = $_FILES[$field]['name'];
             //上传出现错误
             if (isset($_FILES[$field]['error']) && $_FILES[$field]['error'] != 0) {
                 $fileInfo[0]['flag'] = 0 - $_FILES[$field]['error'];
             } else {
                 //获取扩展名
                 $fileext = IFile::getFileType($_FILES[$field]['tmp_name']);
                 if (is_array($fileext) || $fileext == null) {
                     $fileext = IFile::getFileSuffix($_FILES[$field]['name']);
                 }
                 //图片木马检测
                 if (in_array($fileext, $this->checkType) && !IFilter::checkHex($_FILES[$field]['tmp_name'])) {
                     $fileInfo[0]['flag'] = -9;
                 } else {
                     /*开始上传文件*/
                     //(1)上传类型不符合
                     if (!in_array($fileext, $this->allowType)) {
                         $fileInfo[0]['flag'] = -7;
                     } else {
                         if ($_FILES[$field]['size'] > $this->maxsize) {
                             $fileInfo[0]['flag'] = -8;
                         } else {
                             //修改图片状态值
                             $fileInfo[0]['name'] = ITime::getDateTime('YmdHis') . mt_rand(100, 999) . '.' . $fileext;
                             $fileInfo[0]['dir'] = $this->dir;
                             $fileInfo[0]['size'] = $_FILES[$field]['size'];
                             $fileInfo[0]['ininame'] = $_FILES[$field]['name'];
                             $fileInfo[0]['ext'] = $fileext;
                             $fileInfo[0]['fileSrc'] = $fileInfo[0]['dir'] . $fileInfo[0]['name'];
                             $fileInfo[0]['flag'] = 1;
                             if ($this->isForge == false) {
                                 if (is_uploaded_file($_FILES[$field]['tmp_name'])) {
                                     IFile::mkdir($this->dir);
                                     move_uploaded_file($_FILES[$field]['tmp_name'], $this->dir . $fileInfo[0]['name']);
                                 }
                             } else {
                                 IFile::xcopy($_FILES[$field]['tmp_name'], $this->dir . $fileInfo[0]['name']);
                             }
                         }
                     }
                 }
             }
         }
         $info[$field] = $fileInfo;
     }
     return $info;
 }
Exemple #22
0
 private function checkIterance($file, $photoObj)
 {
     //如果关闭了图片重复提交机制
     if ($this->iterance == false) {
         return null;
     }
     $fileMD5 = null;
     //上传图片的md5值(默认)
     $photoRow = array();
     //图库里照片信息(默认)
     $result = array();
     //结果
     if (is_file($file)) {
         //生成文件md5码
         $fileMD5 = md5_file($file);
     }
     if ($fileMD5 != null) {
         //根据md5值取得图像数据
         $where = "id = '" . $fileMD5 . "'";
         $photoRow = $photoObj->getObj($where);
     }
     //设置了缩略图
     if (isset($photoRow['img'])) {
         if (is_file($photoRow['img'])) {
             $result['img'] = $photoRow['img'];
             $result['flag'] = 1;
             if ($this->thumbWidth && $this->thumbHeight && $this->thumbKey) {
                 foreach ($this->thumbWidth as $thumbWidth_Key => $thumbWidth_Val) {
                     //获取此宽度和高度应有的缩略图名
                     $fileExt = IFile::getFileSuffix($photoRow['img']);
                     $thumbFileName = str_replace('.' . $fileExt, '_' . $this->thumbWidth[$thumbWidth_Key] . '_' . $this->thumbHeight[$thumbWidth_Key] . '.' . $fileExt, $photoRow['img']);
                     if (is_file($thumbFileName)) {
                         $result['thumb'][$this->thumbKey[$thumbWidth_Key]] = $thumbFileName;
                         unset($this->thumbKey[$thumbWidth_Key]);
                     }
                 }
                 //重新生成系统中不存在的此宽高的缩略图
                 foreach ($this->thumbKey as $thumbKey_key => $thumbKey_val) {
                     $thumbExtName = '_' . $this->thumbWidth[$thumbKey_key] . '_' . $this->thumbHeight[$thumbKey_key];
                     $thumbName = $this->thumb($photoRow['img'], $this->thumbWidth[$thumbKey_key], $this->thumbHeight[$thumbKey_key], $thumbExtName);
                     $result['thumb'][$this->thumbKey[$thumbKey_key]] = $thumbName;
                 }
             }
             return $result;
         } else {
             $photoObj->del('id = "' . $photoRow['id'] . '"');
             return null;
         }
     } else {
         return null;
     }
 }
Exemple #23
0
 public function setFileContents(IFile $file, $content)
 {
     $this->fs->writeFile($this->fileDir . $file->getFileMappedName(), $content);
 }
</ul>
    <div id="modele_div_id">
        <?php 
echo Pre_operation::save_propose();
?>
    </div>
    <div id="reverse_div_id" style="display:none;height:185px;height:10rem">
    <?php 
$reverse_date = new IDate('reverse_date');
$reverse_ck = new ICheckBox('reverse_ck');
echo _('Extourne opération') . " " . $reverse_ck->input() . " ";
echo $reverse_date->input();
?>
    </div>
    <div id="document_div_id" style="display:none;height:185px;height:10rem">
      <?php 
$file = new IFile();
$file->table = 0;
echo '<p class="decale">';
echo _("Ajoutez une pièce justificative ");
echo $file->input("pj", "");
echo '</p>';
?>
    </div>
</div>
<?php 
echo HtmlInput::submit("save", _("Confirmer"));
echo HtmlInput::submit("correct", _("Corriger"));
?>
</FORM>
Exemple #25
0
 function ticket_excel_del()
 {
     $id = IFilter::act(IReq::get('id'));
     if ($id) {
         if (is_array($id)) {
             foreach ($id as $val) {
                 IFile::unlink($this->ticketDir . '/' . $val);
             }
         } else {
             IFile::unlink($this->ticketDir . '/' . $id);
         }
         $this->ticket_excel_list();
     } else {
         $this->ticket_excel_list();
         Util::showMessage('请选择要删除的文件');
     }
 }
Exemple #26
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 #27
0
 /**
  * @brief 修改配置文件信息
  * @param string 配置文件名
  * @param array  写入的配置内容 key:配置信息里面key值; value:配置信息里面的value值
  */
 public static function edit($configFile, $inputArray)
 {
     //安全过滤要写入文件的内容
     $configStr = "";
     //读取配置信息内容
     if (file_exists($configFile)) {
         $configStr = file_get_contents($configFile);
         $configArray = (include $configFile);
     } else {
         @fopen($configFile, "w");
     }
     if (trim($configStr) == "") {
         $configStr = "<?php return array( \r\n);?>";
         $configArray = array();
     }
     //表单中存在但是不进行录用的键值
     $except = array('form_index');
     foreach ($except as $value) {
         unset($inputArray[$value]);
     }
     $inputArray = array_merge($configArray, $inputArray);
     $configData = var_export($inputArray, true);
     $configStr = "<?php return {$configData}?>";
     //写入配置文件
     $fileObj = new IFile($configFile, 'w+');
     $fileObj->write($configStr);
 }
Exemple #28
0
 /**
  * @brief 修改配置文件信息
  * @param string 配置文件名
  * @param array  写入的配置内容 key:配置信息里面key值; value:配置信息里面的value值
  * @return boolean
  */
 public static function edit($configFile, $inputArray)
 {
     //安全过滤要写入文件的内容
     foreach ($inputArray as $key => $val) {
         if (!in_array($key, self::$safeKey)) {
             $inputArray[$key] = IFilter::act($val, 'text');
         }
     }
     $configStr = "";
     //读取配置信息内容
     if (file_exists($configFile)) {
         $configStr = file_get_contents($configFile);
         $configArray = (require $configFile);
     }
     if (trim($configStr) == "") {
         $configStr = "<?php return array( \r\n);?>";
         $configArray = array();
     }
     //表单中存在但是不进行录用的键值
     $except = array('form_index');
     foreach ($except as $value) {
         unset($inputArray[$value]);
     }
     $inputArray = array_merge($configArray, $inputArray);
     $configData = var_export($inputArray, true);
     $configStr = "<?php return {$configData}?>";
     //写入配置文件
     $fileObj = new IFile($configFile, 'w+');
     $writeResult = $fileObj->write($configStr);
     return $writeResult;
 }
Exemple #29
0
 /**
  * @brief  开始执行上传
  * @return array 包含上传成功信息的数组
  *		$file = array(
  *			 name    如果上传成功,则返回上传后的文件名称,如果失败,则返回客户端名称
  *			 size    上传附件大小
  *           fileSrc 上传文件完整路径
  *			 dir     上传目录
  *			 ininame 上传图片名
  *			 flag    -1:文件类型不允许; -2:文件大小超出限制; 1:上传成功
  *			 ext     上传附件扩展名
  *		);
  */
 public function execute()
 {
     //总的文件上传信息
     $info = array();
     foreach ($_FILES as $field => $file) {
         $fileInfo = array();
         //不存在上传的文件名
         if (!isset($_FILES[$field]['name']) || $_FILES[$field]['name'] == '' || !isset($_FILES[$field]['tmp_name'])) {
             continue;
         }
         //上传控件为数组格式 file[]格式
         if (is_array($_FILES[$field]['name'])) {
             $keys = array_keys($_FILES[$field]['name']);
             foreach ($keys as $key) {
                 if (!isset($_FILES[$field]['name'][$key]) || $_FILES[$field]['name'][$key] == '') {
                     continue;
                 }
                 //获取扩展名
                 $fileext = IFile::getFileType($_FILES[$field]['tmp_name'][$key]);
                 if (is_array($fileext) || $fileext == null) {
                     $fileext = IFile::getFileSuffix($_FILES[$field]['name'][$key]);
                 }
                 /*开始上传文件*/
                 //(1)上传类型不符合
                 if (!in_array($fileext, $this->allowType)) {
                     $fileInfo[$key]['name'] = $_FILES[$field]['name'][$key];
                     $fileInfo[$key]['flag'] = -1;
                 } else {
                     if ($_FILES[$field]['size'][$key] > $this->maxsize) {
                         $fileInfo[$key]['name'] = $_FILES[$field]['name'][$key];
                         $fileInfo[$key]['flag'] = -2;
                     } else {
                         //修改图片状态值
                         $fileInfo[$key]['name'] = ITime::getDateTime('Ymdhis') . mt_rand(100, 999) . '.' . $fileext;
                         $fileInfo[$key]['dir'] = $this->dir;
                         $fileInfo[$key]['size'] = $_FILES[$field]['size'][$key];
                         $fileInfo[$key]['ininame'] = $_FILES[$field]['name'][$key];
                         $fileInfo[$key]['ext'] = $fileext;
                         $fileInfo[$key]['fileSrc'] = $fileInfo[$key]['dir'] . $fileInfo[$key]['name'];
                         if (is_uploaded_file($_FILES[$field]['tmp_name'][$key])) {
                             if (move_uploaded_file($_FILES[$field]['tmp_name'][$key], $this->dir . $fileInfo[$key]['name'])) {
                                 if (file_exists($_FILES[$field]['tmp_name'][$key])) {
                                     IFile::unlink($_FILES[$field]['tmp_name'][$key]);
                                 }
                                 $fileInfo[$key]['flag'] = 1;
                             }
                         }
                     }
                 }
             }
         } else {
             if ($_FILES[$field]['name'] == '' || $_FILES[$field]['tmp_name'] == '') {
                 continue;
             }
             //获取扩展名
             $fileext = IFile::getFileType($_FILES[$field]['tmp_name']);
             if (is_array($fileext) || $fileext == null) {
                 $fileext = IFile::getFileSuffix($_FILES[$field]['name']);
             }
             /*开始上传文件*/
             //(1)上传类型不符合
             if (!in_array($fileext, $this->allowType)) {
                 $fileInfo[0]['name'] = $_FILES[$field]['name'];
                 $fileInfo[0]['flag'] = -1;
             } else {
                 if ($_FILES[$field]['size'] > $this->maxsize) {
                     $fileInfo[0]['name'] = $_FILES[$field]['name'];
                     $fileInfo[0]['flag'] = -2;
                 } else {
                     //修改图片状态值
                     $fileInfo[0]['name'] = ITime::getDateTime('Ymdhis') . mt_rand(100, 999) . '.' . $fileext;
                     $fileInfo[0]['dir'] = $this->dir;
                     $fileInfo[0]['size'] = $_FILES[$field]['size'];
                     $fileInfo[0]['ininame'] = $_FILES[$field]['name'];
                     $fileInfo[0]['ext'] = $fileext;
                     $fileInfo[0]['fileSrc'] = $fileInfo[0]['dir'] . $fileInfo[0]['name'];
                     if (is_uploaded_file($_FILES[$field]['tmp_name'])) {
                         if (move_uploaded_file($_FILES[$field]['tmp_name'], $this->dir . $fileInfo[0]['name'])) {
                             if (file_exists($_FILES[$field]['tmp_name'])) {
                                 IFile::unlink($_FILES[$field]['tmp_name']);
                             }
                             $fileInfo[0]['flag'] = 1;
                         }
                     }
                 }
             }
         }
         $info[$field] = $fileInfo;
     }
     return $info;
 }
 /**
  * @brief 订单打印模板修改保存
  */
 public function print_template_update()
 {
     // 获取POST数据
     $con_shop = IReq::get("con_shop");
     $con_pick = IReq::get("con_pick");
     //获取根目录路径
     $path = IWeb::$app->getBasePath() . 'views/' . $this->theme . '/order';
     //保存 购物清单模板
     $ifile_shop = new IFile($path . '/shop_template.html', 'w');
     if (!$ifile_shop->write($con_shop)) {
         $this->redirect('print_template', false);
         Util::showMessage('保存购物清单模板失败!');
     }
     //保存 配货单模板
     $ifile_pick = new IFile($path . "/pick_template.html", 'w');
     if (!$ifile_pick->write($con_pick)) {
         $this->redirect('print_template', false);
         Util::showMessage('保存配货单模板失败!');
     }
     //保存 合并单模板
     $ifile_merge = new IFile($path . "/merge_template.html", 'w');
     if (!$ifile_merge->write($con_shop . $con_pick)) {
         $this->redirect('print_template', false);
         Util::showMessage('购物清单和配货单模板合并失败!');
     }
     $this->setRenderData(array('where' => ''));
     $this->redirect('order_list');
 }