order('id asc')->select(); foreach ($s as $v) {$seo[$v['varname']] = $v['value'];} if($seo['webstatus']=='0'){$this->redirect('Home/public/close');} $this->assign('seo', $seo); $this->ss=$seo; if($_SESSION['msg_id'] != ''){ $admin = M("msg") -> where("id = ".$_SESSION['msg_id']."") -> find(); $this -> assign("admin",$admin); } } //LRC俱乐部线下实体店 function store(){ $sid = $_GET['sid']; $fid = $_GET['fid']; $as1 = M("store_sf") -> where("id = ".$sid."") -> find(); $as2 = M("store_sq") -> where("id = ".$fid."") -> find(); $this -> assign("sid",$sid); $this -> assign("sidname",$as1['title']); $this -> assign("fid",$fid); $this -> assign("fidname",$as2['title']); if($sid != '') $where['sid'] = $sid; if($fid != '') $where['fid'] = $fid; //省份 $store_sf = M("store_sf") -> order("px desc,id desc") -> select(); $this -> assign("store_sf",$store_sf); //市区 if($sid == '') $sid = $store_sf[0]['id']; $store_sq = M("store_sq") -> where("fid = '".$sid."'") -> order("px desc,id desc") -> select(); $this -> assign("store_sq",$store_sq); import('ORG.Util.Page'); $count = M("store") -> where($where) -> count(); $Page = new Page($count,6); $show = $Page->show(); $news = M("store") -> where($where) -> order("px desc,id desc") -> limit($Page->firstRow.','.$Page->listRows) -> select(); $this->assign('news',$news); $this->assign('page',$show); $seo2['title'] = "LRC俱乐部线下实体店"; $seo2['seo_key'] = "LRC俱乐部线下实体店"; $seo2['seo_des'] = "LRC俱乐部线下实体店"; $this -> assign("seo2",$seo2); $this -> display(); } //LRC俱乐部会员作品展示 function work(){ import('ORG.Util.Page'); $count = M("msg_zuopin") -> where("zt = 2") -> count(); $Page = new Page($count,18); $show = $Page->show(); $news = M("msg_zuopin") -> where("zt = 2") -> order("px desc,id desc") -> limit($Page->firstRow.','.$Page->listRows) -> select(); foreach($news as $key=>$rs){ $url=explode("/",$rs['pic']); $thumbPath=trim("/data/www/tamron/html/data/suoluo/".$url['3']); $orcPath=trim("/data/www/tamron/html/data/gerber/".$url['3']); if(!file_exists($thumbPath)){ $pic = $this -> imgZoom("290x290w",$orcPath,$thumbPath); $news[$key]['picen'] = "/data/suoluo/".$url['3']; }else{ $news[$key]['picen'] = "/data/suoluo/".$url['3']; } } $this->assign('news',$news); $this->assign('page',$show); $seo2['title'] = "LRC俱乐部线下实体店"; $seo2['seo_key'] = "LRC俱乐部线下实体店"; $seo2['seo_des'] = "LRC俱乐部线下实体店"; $this -> assign("seo2",$seo2); $this -> display(); } function work_(){ $news = M("msg_zuopin") -> where("id = ".$_GET['id']."") -> find(); $this -> assign("news",$news); if($_SESSION['msg_id'] != ''){ $msg = M("msg") -> where("id = ".$_SESSION['msg_id']."") -> find(); $this -> assign("msg",$msg); } import('ORG.Util.Page'); $count = M("msg_zuopinly") -> where("zp_id = ".$_GET['id']." and zt = 2") -> count(); $Page = new Page($count,10); $show = $Page->show(); $liuyan = M("msg_zuopinly") -> where("zp_id = ".$_GET['id']." and zt = 2") -> order("id desc") -> limit($Page->firstRow.','.$Page->listRows) -> select(); foreach($liuyan as $key=>$rs){ $msg = M("msg") -> where("id = ".$rs['msg_id']."") -> find(); $liuyan[$key]['pic'] = $msg['pic']; $liuyan[$key]['user'] = $msg['user']; } $this -> assign("liuyan",$liuyan); $this -> assign("page",$show); $seo2['title'] = "LRC俱乐部线下实体店"; $seo2['seo_key'] = "LRC俱乐部线下实体店"; $seo2['seo_des'] = "LRC俱乐部线下实体店"; $this -> assign("seo2",$seo2); $this -> display(); } //LRC俱乐部会员活动 function newa(){ import('ORG.Util.Page'); $count = M("activity") -> where($where) -> count(); $Page = new Page($count,18); $show = $Page->show(); $news = M("activity") -> where($where) -> order("px desc,id desc") -> limit($Page->firstRow.','.$Page->listRows) -> select(); $this->assign('news',$news); $this->assign('page',$show); $seo2['title'] = "LRC俱乐部会员活动"; $seo2['seo_key'] = "LRC俱乐部会员活动"; $seo2['seo_des'] = "LRC俱乐部会员活动"; $this -> assign("seo2",$seo2); $this -> display(); } function newa_(){ $news = M("activity") -> where("id = ".$_GET['id']."") -> find(); $this -> assign("news",$news); $seo2['title'] = $news['title']; $seo2['seo_key'] = $news['seo_key']; $seo2['seo_des'] = $news['seo_des']; $this -> assign("seo2",$seo2); $this -> display(); } //延保服务 function service(){ $news = M("service") -> order("px desc,id desc") -> find(); $this -> assign("news",$news); $seo2['title'] = $news['title']; $seo2['seo_key'] = $news['seo_key']; $seo2['seo_des'] = $news['seo_des']; $this -> assign("seo2",$seo2); $this -> display(); } //产品注册 function pgist(){ $this -> display(); } //LRC俱乐部会员活动 function classr(){ import('ORG.Util.Page'); $count = M("ketang") -> where($where) -> count(); $Page = new Page($count,18); $show = $Page->show(); $news = M("ketang") -> where($where) -> order("px desc,id desc") -> limit($Page->firstRow.','.$Page->listRows) -> select(); $this->assign('news',$news); $this->assign('page',$show); $seo2['title'] = "腾龙摄影课堂"; $seo2['seo_key'] = "腾龙摄影课堂"; $seo2['seo_des'] = "腾龙摄影课堂"; $this -> assign("seo2",$seo2); $this -> display(); } function classr_(){ $news = M("ketang") -> where("id = ".$_GET['id']."") -> find(); $this -> assign("news",$news); $seo2['title'] = $news['title']; $seo2['seo_key'] = $news['seo_key']; $seo2['seo_des'] = $news['seo_des']; $this -> assign("seo2",$seo2); $this -> display(); } public static $convert = 'convert'; //static $convert = '/usr/bin/convert'; /** * @todo 裁切指定尺寸图片 */ public function imgZoom($sizeStr, $orcPath, $thumbPath) { if (!$sizeStr || !$orcPath || !$thumbPath) return false; if (!preg_match("/\d+x\d+/", $sizeStr, $match)) return false; $quality = 100; #图片的压缩品质 $size = $match[0]; $lastChar = substr($sizeStr, -1, 1); #获得最后一个字符,从而进一步处理 if ("c" == $lastChar) { #正方形的压缩 $flag = $this->makeThumbPicBySquare(array( 'srcPath' => $orcPath, #要转换的图片路径 'desPath' => $thumbPath, #生成的图片路径 'size' => $size, #要压缩的尺寸 'isCenter' => 1, #是否居中 'quality' => $quality, #图片品质 'stripExif' => 1, #是否去掉Exif信息 )); } elseif ("w" == $lastChar) { #限制宽的压缩 $flag = $this->makeThumbPicByWidth(array( 'srcPath' => $orcPath, #要转换的图片路径 'desPath' => $thumbPath, #生成的图片路径 'size' => $size, #要压缩的尺寸 'quality' => $quality, #图片品质 'stripExif' => 1, #是否去掉Exif信息 )); } elseif ("h" == $lastChar) { #限制高的压缩 $flag = $this->makeThumbPicByHeight(array( 'srcPath' => $orcPath, #要转换的图片路径 'desPath' => $thumbPath, #生成的图片路径 'size' => $size, #要压缩的尺寸 'quality' => $quality, #图片品质 'stripExif' => 1, #是否去掉Exif信息 )); } else { #普通的压缩模式 $flag = $this->makeThumbPicBySize(array( 'srcPath' => $orcPath, #要转换的图片路径 'desPath' => $thumbPath, #生成的图片路径 'size' => $size, #要压缩的尺寸 'quality' => $quality, #图片品质 'stripExif' => 1, #是否去掉Exif信息 )); } return $flag ? $thumbPath : false; } /** * 压缩图片 定宽定高 */ private function makeThumbPicBySize($paramArr) { $options = array( 'srcPath' => '', #源文件路径 'desPath' => '', #目标文件路径 'size' => '', #要压缩的图片尺寸,如100x80 'quality' => 100, #图片品质 'stripExif' => true, #是否去掉Exif信息 拍摄相机信息等,除非显示拍摄相机的需求,否则无用 ); if (is_array($paramArr)) $options = array_merge($options, $paramArr); extract($options); $sign = false; $info = self::getImgInfo(array('path' => $srcPath)); $sizeArr = explode('x', $size); $scaleW = $sizeArr[0] / $info['width']; //对比宽度 $scaleH = $sizeArr[1] / $info['height']; if ($scaleW < 1 || $scaleH < 1) { $sys = "convert -resize {$size} {$srcPath} {$desPath}"; system($sys); $sign = file_exists($desPath); #对图片进行优化 self::optimizeJpg(array('srcPath' => $desPath, 'stripExif' => $stripExif)); } else { //当要压的图比想要的缩略图还小时,不压了 $sign = copy($srcPath, $desPath); } return $sign; } /** * 压缩图片,定宽 */ private function makeThumbPicByWidth($paramArr) { $options = array( 'srcPath' => '', #源文件路径 'desPath' => '', #目标文件路径 'size' => '', #要压缩的图片尺寸,如100x80 'quality' => 100, #图片品质 'stripExif' => true, #是否去掉Exif信息 拍摄相机信息等,除非显示拍摄相机的需求,否则无用 ); if (is_array($paramArr)) $options = array_merge($options, $paramArr); extract($options); $sign = false; $info = self::getImgInfo(array('path' => $srcPath)); $sizeArr = explode('x', $size); $scale = $sizeArr[0] / $info['width']; //对比宽度 if ($scale < 1) { $sys = "convert -geometry " . $sizeArr[0] . "x -quality $quality +profile '*' $srcPath $desPath"; system($sys); $sign = file_exists($desPath); #对图片进行优化 self::optimizeJpg(array('srcPath' => $desPath, 'stripExif' => $stripExif)); } else { //当要压的图比想要的缩略图还小时,不压了 $sign = copy($srcPath, $desPath); } return $sign; } /** * 压缩图片,定高 */ private function makeThumbPicByHeight($paramArr) { $options = array( 'srcPath' => '', #源文件路径 'desPath' => '', #目标文件路径 'size' => '', #要压缩的图片尺寸,如100x80 'quality' => 100, #图片品质 'stripExif' => true, #是否去掉Exif信息 拍摄相机信息等,除非显示拍摄相机的需求,否则无用 ); if (is_array($paramArr)) $options = array_merge($options, $paramArr); extract($options); $sign = false; $info = self::getImgInfo(array('path' => $srcPath)); $sizeArr = explode('x', $size); $scale = $sizeArr[1] / $info['height']; //对比高度 if ($scale < 1) { $sys = "convert -geometry x" . $sizeArr[1] . " -quality $quality +profile '*' $srcPath $desPath"; system($sys); $sign = file_exists($desPath); #对图片进行优化 self::optimizeJpg(array('srcPath' => $desPath, 'stripExif' => $stripExif)); } else { //当要压的图比想要的缩略图还小时,不压了 $sign = copy($srcPath, $desPath); } return $sign; } /** * 取方图 */ private function makeThumbPicBySquare($paramArr) { $options = array( 'srcPath' => '', #源文件路径 'desPath' => '', #目标文件路径 'size' => '', #要压缩的图片尺寸,如100x80 'position' => 0, #是否从中部中截取 'offset' => -1, #裁图 'quality' => 100, #图片品质 'stripExif' => true, #是否去掉Exif信息 拍摄相机信息等,除非显示拍摄相机的需求,否则无用 ); if (is_array($paramArr)) $options = array_merge($options, $paramArr); extract($options); if (!$srcPath || !$size || !$desPath) return false; $posArr = array('leftUp', 'middleUp', 'rightUp', 'leftMiddle', 'middleMiddle', 'rightMiddle', 'leftBottom', 'middleBottom', 'rightBottom'); $pos = $position == 0 ? 'middleMiddle' : $posArr[$position - 1]; if (!$pos) $pos = 'middleMiddle'; #获得图片的信息 $info = self::getImgInfo(array('path' => $srcPath)); $imgHeight = $info["height"]; $imgWidth = $info["width"]; list($zoomWidth, $zoomHeight) = explode("x", $size); #要压缩的尺寸 $srcSize = $imgWidth . 'x' . $imgHeight; $newSize = $size; $newSizeArr = explode('x', $newSize); if ($imgWidth < $zoomWidth || $imgHeight < $zoomHeight) { //这里比较特殊 copy($srcPath, $desPath); return true; } $scale = min($zoomWidth / $imgWidth, $zoomHeight / $imgHeight); #原图比例 $srcCate = $imgWidth / $imgHeight; #目标图比例 $newSrcCate = $zoomWidth / $zoomHeight; #截取位置 $offset = $offset; $beishu = 1; #切割 if ($offset >= 0) { if ($imgWidth >= $zoomWidth && $imgHeight >= $zoomHeight) { if ($imgWidth <= $imgHeight) { $sHeight = round($zoomWidth * $imgHeight / $imgWidth); $newSize = $zoomWidth . 'x' . $zoomHeight; if ($imgHeight >= $offset) { $sys = ' -resize ' . $zoomWidth . 'x' . $sHeight . ' -crop ' . $newSize . '+0+' . $offset . ' -quality ' . $quality . ' ' . $srcPath . ' ' . $desPath; } } } if ($sys) { exec(self::$convert . $sys, $rtn); #对图片进行优化 self::optimizeJpg(array('srcPath' => $desPath, 'stripExif' => $stripExif)); } else { return false; } return true; } if ($scale < 1) { if ($srcCate > 1) { #原图宽大于高 #压缩的宽度 $ywidth = round(($zoomHeight / $imgHeight) * $imgWidth); if ($ywidth >= $zoomWidth && $zoomHeight != $imgHeight) { $imgInfo = array($ywidth, $zoomHeight); $imgPostion = self::getCoordinatesPostion(array('imgArr' => $imgInfo, 'imgHandArr' => array($zoomWidth, $zoomHeight), 'type' => $pos)); $sys = ' -resize ' . $ywidth . 'x' . $zoomHeight . ' -crop ' . $newSize . '+' . $imgPostion['0'] . '+' . $imgPostion['1'] . ' -quality ' . $quality . ' ' . $srcPath . ' ' . $desPath; } else if ($zoomHeight != $imgHeight) { $yhight = round(($zoomWidth / $imgWidth) * $imgHeight); $imgInfo = array($zoomWidth, $yhight); $imgPostion = self::getCoordinatesPostion(array('imgArr' => $imgInfo, 'imgHandArr' => array($zoomWidth, $zoomHeight), 'type' => $pos)); $sys = ' -resize ' . $zoomWidth . 'x' . $yhight . ' -crop ' . $newSize . '+' . $imgPostion['0'] . '+' . $imgPostion['1'] . ' -quality ' . $quality . ' ' . $srcPath . ' ' . $desPath; } else { $imgInfo = array($imgWidth, $imgHeight); $imgPostion = self::getCoordinatesPostion(array('imgArr' => $imgInfo, 'imgHandArr' => array($zoomWidth, $zoomHeight), 'type' => $pos)); $sys = ' -resize ' . $srcSize . ' -crop ' . $newSize . '+' . $imgPostion['0'] . '+' . $imgPostion['1'] . ' -quality ' . $quality . ' ' . $srcPath . ' ' . $desPath; } } else if ($srcCate < 1) { #原图宽小于高 $yheight = round(($zoomWidth / $imgWidth) * $imgHeight); if ($yheight >= $zoomHeight && $zoomWidth != $imgWidth) { $imgInfo = array($zoomWidth, $yheight); $imgPostion = self::getCoordinatesPostion(array('imgArr' => $imgInfo, 'imgHandArr' => array($zoomWidth, $zoomHeight), 'type' => $pos)); $sys = ' -resize ' . $zoomWidth . 'x' . $yheight . ' -crop ' . $newSize . '+' . $imgPostion['0'] . '+' . $imgPostion['1'] . ' -quality ' . $quality . ' ' . $srcPath . ' ' . $desPath; } else if ($zoomHeight != $imgHeight) { $ywidth = round(($zoomHeight / $imgHeight) * $imgWidth); $imgInfo = array($ywidth, $zoomHeight); $imgPostion = self::getCoordinatesPostion(array('imgArr' => $imgInfo, 'imgHandArr' => array($zoomWidth, $zoomHeight), 'type' => $pos)); $sys = ' -resize ' . $ywidth . 'x' . $zoomHeight . ' -crop ' . $newSize . '+' . $imgPostion['0'] . '+' . $imgPostion['1'] . ' -quality ' . $quality . ' ' . $srcPath . ' ' . $desPath; } else { $imgInfo = array($imgWidth, $imgHeight); $imgPostion = self::getCoordinatesPostion(array('imgArr' => $imgInfo, 'imgHandArr' => array($zoomWidth, $zoomHeight), 'type' => $pos)); $sys = ' -resize ' . $srcSize . ' -crop ' . $newSize . '+' . $imgPostion['0'] . '+' . $imgPostion['1'] . ' -quality ' . $quality . ' ' . $srcPath . ' ' . $desPath; } } else { #原图宽等于高 $ywidth = round(($zoomHeight / $imgHeight) * $imgWidth); $yheight = round(($zoomWidth / $imgWidth) * $imgHeight); if ($newSrcCate > 1) { $imgInfo = array($zoomWidth, $zoomWidth); $imgPostion = self::getCoordinatesPostion(array('imgArr' => $imgInfo, 'imgHandArr' => array($zoomWidth, $zoomHeight), 'type' => $pos)); $sys = ' -resize ' . $zoomWidth . 'x' . $yheight . ' -crop ' . $newSize . '+' . $imgPostion['0'] . '+' . $imgPostion['1'] . ' -quality ' . $quality . ' ' . $srcPath . ' ' . $desPath; } else if ($newSrcCate < 1) { $imgInfo = array($zoomHeight, $zoomHeight); $imgPostion = self::getCoordinatesPostion(array('imgArr' => $imgInfo, 'imgHandArr' => array($zoomWidth, $zoomHeight), 'type' => $pos)); $sys = ' -resize ' . $ywidth . 'x' . $zoomHeight . ' -crop ' . $newSize . '+' . $imgPostion['0'] . '+' . $imgPostion['1'] . ' -quality ' . $quality . ' ' . $srcPath . ' ' . $desPath; } else { $sys = ' -resize ' . $zoomWidth . 'x' . $zoomHeight . ' -crop ' . $newSize . '+0+0 -quality ' . $quality . ' ' . $srcPath . ' ' . $desPath; } } exec(self::$convert . $sys, $rtn); #对图片进行优化 self::optimizeJpg(array('srcPath' => $desPath, 'stripExif' => $stripExif)); } else { copy($srcPath, $desPath); } return true; } /** * 获得图片的详细信息(仅限图片) * 服务器必须安装ImageMagick */ public static function getImgInfo($paramArr) { $options = array( 'path' => '', #地址 ); if (is_array($paramArr)) $options = array_merge($options, $paramArr); extract($options); // $imagesize = getimagesize($path); // $data = array( // 'width' => $imagesize[0], // 'height' => $imagesize[1], // ); // return $data; //以下的暂时跑不通 php.ini禁用系统函数了 #exec("identify -verbose ${path}",$rtnArr); #参数说明,请详细见:http://www.imagemagick.org/script/escape.php @exec('identify -format "%b|%m|%w|%h|%r|%q " ' . $path, $rtnArr); $data = array(); if ($rtnArr && isset($rtnArr[0])) { list($data['size'], $ext, $data['width'], $data['height'], $data['colorsp'], $data['depth']) = explode("|", $rtnArr[0]); #扩展名处理 $ext = strtolower($ext); if ($ext == "jpeg") $ext = "jpg"; $data['ext'] = $ext; } return $data; } /** * 进行优化图片,对图片进行压缩 */ public static function optimizeJpg($paramArr) { $options = array( 'srcPath' => '', #源文件路径 'stripExif' => true, #是否去掉Exif信息 ); if (is_array($paramArr)) $options = array_merge($options, $paramArr); extract($options); $ext = substr($srcPath, strrpos($srcPath, ".") + 1); if ("jpg" != strtolower($ext)) return false; $cmdSubStr = $stripExif ? " --strip-exif " : ""; exec("/usr/local/bin/jpegoptim --strip-com ".$cmdSubStr." --strip-iptc --max=100 ".$srcPath."", $rtn); return true; } /** * 获取坐标 * @param imgArr 需要处理的图像数组 array(0=>width,1=>height) * @param imgHandArr 处理之后的图像大小数组 array(0=>width,1=>height) * @param type 截图类型 */ public static function getCoordinatesPostion($paramArr) { $options = array( 'imgArr' => '', #imgArr 需要处理的图像数组 array(0=>width,1=>height) 'imgHandArr' => '', #imgHandArr 处理之后的图像大小数组 array(0=>width,1=>height) 'type' => 'middleMiddle' #截取位置 ); if (is_array($paramArr)) $options = array_merge($options, $paramArr); extract($options); if (!is_array($imgArr) || !is_array($imgHandArr)) return false; switch ($type) { case 'leftUp': return array(0, 0); break; case 'middleUp': $startX = round(($imgArr[0] - $imgHandArr[0]) / 2); return array($startX, 0); break; case 'rightUp': $startX = $imgArr[0] - $imgHandArr[0]; return array($startX, 0); break; case 'leftMiddle': $startY = round(($imgArr[1] - $imgHandArr[1]) / 2); return array(0, $startY); break; case 'middleMiddle': $startX = round(($imgArr[0] - $imgHandArr[0]) / 2); $startY = round(($imgArr[1] - $imgHandArr[1]) / 2); return array($startX, $startY); break; case 'rightMiddle': $startX = $imgArr[0] - $imgHandArr[0]; $startY = round(($imgArr[1] - $imgHandArr[1]) / 2); return array($startX, $startY); break; case 'leftBottom': $startY = $imgArr[1] - $imgHandArr[1]; return array(0, $startY); break; case 'middleBottom': $startX = round(($imgArr[0] - $imgHandArr[0]) / 2); $startY = $imgArr[1] - $imgHandArr[1]; return array($startX, $startY); break; case 'rightBottom': $startX = $imgArr[0] - $imgHandArr[0]; $startY = $imgArr[1] - $imgHandArr[1]; return array($startX, $startY); break; } } } ?>