/** * 上传文件 * @author 肖飞 * @param array $arrFile 图片文件信息数组$_FILES * @param int $PR 自动压缩的比例 * @param int $intID 内容ID,标示新增还是修改 * @return unknown */ function uploadInfoImage($arrFile, $PR = 0, $intID = 0) { if ($arrFile['name']) { if (!in_array(strtolower($arrFile['type']), array('image/jpg', 'image/jpeg', 'image/gif', 'image/pjpeg', 'image/png', 'image/x-png', 'application/x-shockwave-flash'))) { check::AlertExit('文件类型不符合要求(' . $arrFile['type'] . ')', -1); } } if ($intID == 0) { $intID = $this->getMaxID(); } $strDir = ceil($intID / 1000); $strMakeDir = $this->arrGPic['FileSavePath'] . $strDir; if (!is_dir($this->arrGPic['FileSavePath'])) { @mkdir($this->arrGPic['FileSavePath']); @chmod($this->arrGPic['FileSavePath'], 0777); } if (!is_dir($strMakeDir)) { @mkdir($strMakeDir); @chmod($strMakeDir, 0777); } $FileExt = strrchr($arrFile['name'], "."); //取得上传文件扩展名 $strPhoto = $strDir . "/" . $intID . "_" . time() . $FileExt; //存入数据库的图片访问路径 $strPicName = $strMakeDir . "/" . $intID . "_" . time() . $FileExt; //新图片路径及名称 if ($arrFile['type'] != 'application/x-shockwave-flash' && $arrFile['size'] > $this->arrGPic['FileMaxSize']) { if ($PR != 0) { move_uploaded_file($arrFile['tmp_name'], $strPicName); $objGDImage = new GDImage(); if ($objGDImage->makePRThumb($strPicName, $PR)) { return $strPhoto; } else { check::AlertExit($strPicName . "文件上传错误!", -1); } } else { check::AlertExit("文件大小不符合要求!", -1); } } else { if (move_uploaded_file($arrFile['tmp_name'], $strPicName)) { return $strPhoto; } else { check::AlertExit($strPicName . "文件上传错误!", -1); } } }
exit; } $intID = intval($_GET['id']); $arrInfo = $objWebInit->getInfo($intID, '*', 1, true); include_once 'include/title.php'; include_once 'include/head.php'; $myText = new HAW_text("标题:" . $arrInfo['title']); $objHaw->add_text($myText); if (!empty($arrInfo['photo']) && $intCPage == 1) { $strWapPhoto = $arrGPic['FileSavePath'] . 'wap/' . $arrInfo['photo']; if (!is_file($strWapPhoto)) { //生成压缩图 check::make_dir($strWapPhoto); copy($arrGPic['FileSavePath'] . '/b/' . $arrInfo['photo'], $strWapPhoto); $objGDImage = new GDImage(); if ($objGDImage->makePRThumb($strWapPhoto, 0, $arrMHaw['image_width'], $arrMHaw['image_height'])) { $myImage = new HAW_image("photo.wbmp", $arrGPic['FileCallPath'] . 'wap/' . $arrInfo['photo'], $arrInfo['title']); $myImage->set_br(1); $myImage->set_html_width($arrMHaw['image_width']); $objHaw->add_image($myImage); } } else { $myImage = new HAW_image("photo.wbmp", $arrGPic['FileCallPath'] . 'wap/' . $arrInfo['photo'], $arrInfo['title']); $myImage->set_br(1); $myImage->set_html_width($arrMHaw['image_width']); $objHaw->add_image($myImage); } } $arrData = check::WordPage($arrInfo['intro'], $arrMHaw['detail_charnum'], $intCPage); $myText = new HAW_text($arrData['centent']); $objHaw->add_text($myText);
/** * 上传信息图片 * @author 肖飞 * @param array $arrFile 图片文件信息数组$_FILES * @param int $num 图片的标号(用于多图上传) * @param int $FileListPicSize 缩略图自动压缩的比例(像素) * @param int $PR 原图自动压缩的比例(像素800或者比例0.50) * @param int $intInfoID 素材内容ID,标示新增还是修改 * @param int $intFetch 是否来自采集 * @param bool $blTime 新文件名是否使用时间戳 * @param string $FileExt 文件后缀名 * @return unknown */ function uploadInfoImage($arrFile, $num = null, $FileListPicSize = '', $PR = 0, $intInfoID = 0, $intFetch = 0, $blTime = true, $FileExt = '') { global $arrGCache; if ($arrFile['error'] != 0) { check::AlertExit('文件上传错误!(' . $arrFile['error'] . ')', -1); } if ($arrFile['name']) { $strFileType = strtolower($arrFile['type']); if (!in_array($strFileType, array('image/jpg', 'image/jpeg', 'image/gif', 'image/pjpeg', 'image/png', 'image/x-png'))) { check::AlertExit('文件类型不符合要求(' . $arrFile['type'] . ')', -1); } } if ($intInfoID == 0) { $intID = $this->getMaxID(); } else { $intID = $intInfoID; } $strDir = ceil($intID / $arrGCache['cache_filenum']); if (!is_dir($this->arrGPic['FileSavePath'])) { @mkdir($this->arrGPic['FileSavePath']); @chmod($this->arrGPic['FileSavePath'], 0777); } $strMakeDir = $this->arrGPic['FileSavePath'] . 'b/'; if (!is_dir($strMakeDir)) { @mkdir($strMakeDir); @chmod($strMakeDir, 0777); } $strMakeDir = $strMakeDir . $strDir; if (!is_dir($strMakeDir)) { @mkdir($strMakeDir); @chmod($strMakeDir, 0777); } if ($FileExt == '') { $FileExt = strtolower(strrchr($arrFile['name'], '.')); } //取得上传文件扩展名 if ($blTime) { $strTime = time(); } else { $strTime = ''; } if (!empty($num)) { $strPhoto = $strDir . '/' . $intID . '_' . $strTime . "_{$num}" . $FileExt; //存入数据库的图片访问路径 $strPicName = $strMakeDir . '/' . $intID . '_' . $strTime . "_{$num}" . $FileExt; //新图片路径及名称 } else { $strPhoto = $strDir . '/' . $intID . '_' . $strTime . $FileExt; $strPicName = $strMakeDir . '/' . $intID . '_' . $strTime . $FileExt; } if (!empty($FileListPicSize)) { //所有的图都生成缩略图 $strMakeSmallDir = $this->arrGPic['FileSavePath'] . 's/'; if (!is_dir($strMakeSmallDir)) { @mkdir($strMakeSmallDir); @chmod($strMakeSmallDir, 0777); } $strMakeSmallDir = $strMakeSmallDir . $strDir; if (!is_dir($strMakeSmallDir)) { @mkdir($strMakeSmallDir); @chmod($strMakeSmallDir, 0777); } if (!empty($num)) { $strSmallPicName = $strMakeSmallDir . '/' . $intID . '_' . $strTime . "_{$num}" . $FileExt; } else { $strSmallPicName = $strMakeSmallDir . '/' . $intID . '_' . $strTime . $FileExt; } copy($arrFile['tmp_name'], $strSmallPicName); $objGDImage = new GDImage(); if (!$objGDImage->makePRThumb($strSmallPicName, 0, $FileListPicSize, $FileListPicSize)) { check::AlertExit($strSmallPicName . '缩略图生成错误!', -1); } } if ($arrFile['size'] > $this->arrGPic['FileMaxSize']) { //上传容量大于设定尺寸 if ($PR != 0) { if ($intFetch) { if (!copy($arrFile['tmp_name'], $strPicName)) { echo $strPicName . '文件上传错误!'; exit; } } else { move_uploaded_file($arrFile['tmp_name'], $strPicName); } $objGDImage = new GDImage(); if ($PR > 1) { if ($objGDImage->makePRThumb($strPicName, '', $PR, $PR)) { return $strPhoto; } else { check::AlertExit($strPicName . '文件上传错误!', -1); } } else { if ($objGDImage->makePRThumb($strPicName, $PR)) { return $strPhoto; } else { check::AlertExit($strPicName . '文件上传错误!', -1); } } } else { check::AlertExit('文件容量超过限制的' . $this->arrGPic['FileMaxSize'] / 1024 . 'k', -1); } } else { if ($intFetch) { if (copy($arrFile['tmp_name'], $strPicName)) { return $strPhoto; } else { echo $strPicName . '文件上传错误!'; exit; } } else { if ($PR != 0) { move_uploaded_file($arrFile['tmp_name'], $strPicName); $objGDImage = new GDImage(); if ($PR > 1) { if ($objGDImage->makePRThumb($strPicName, '', $PR, $PR)) { return $strPhoto; } else { check::AlertExit($strPicName . '文件上传错误!', -1); } } else { if ($objGDImage->makePRThumb($strPicName, $PR)) { return $strPhoto; } else { check::AlertExit($strPicName . '文件上传错误!', -1); } } } else { if (move_uploaded_file($arrFile['tmp_name'], $strPicName)) { return $strPhoto; } else { check::AlertExit($strPicName . '文件上传错误!', -1); } } } } }