public function image() { if (filesize($this->path) <= 1024 * 10) { //小于10k 不再生成缩略图 file_put_out($this->path); } load_class('imageThumb'); $image = $this->path; $image_md5 = @md5_file($image); //文件md5 if (strlen($image_md5) < 5) { $image_md5 = md5($image); } $image_thum = DATA_THUMB . $image_md5 . '.png'; if (!is_dir(DATA_THUMB)) { mkdir(DATA_THUMB, "0777"); } if (!file_exists($image_thum)) { //如果拼装成的url不存在则没有生成过 if ($_SESSION['this_path'] == DATA_THUMB) { //当前目录则不生成缩略图 $image_thum = $this->path; } else { $cm = new CreatMiniature(); $cm->SetVar($image, 'file'); //$cm->Prorate($image_thum,72,64);//生成等比例缩略图 $cm->BackFill($image_thum, 72, 64, true); //等比例缩略图,空白处填填充透明色 } } if (!file_exists($image_thum) || filesize($image_thum) < 100) { //缩略图生成失败则用默认图标 $image_thum = STATIC_PATH . 'images/image.png'; } //输出 file_put_out($image_thum); }
public function image() { if (filesize($this->path) <= 1024 * 10) { //Less than 10k longer to generate thumbnails file_put_out($this->path); } load_class('imageThumb'); $image = $this->path; $image_md5 = @md5_file($image); //Md5 file if (strlen($image_md5) < 5) { $image_md5 = md5($image); } $image_thum = DATA_THUMB . $image_md5 . '.png'; if (!is_dir(DATA_THUMB)) { mkdir(DATA_THUMB, "0777"); } if (!file_exists($image_thum)) { //If assembled into the url does not exist, it does not generate too if ($_SESSION['this_path'] == DATA_THUMB) { //Thumbnails will not be generated in the current directory $image_thum = $this->path; } else { $cm = new CreatMiniature(); $cm->SetVar($image, 'file'); //$cm->Prorate($image_thum,72,64);//Thumbnail generation ratio $cm->BackFill($image_thum, 72, 64, true); //Proportional thumbnails, fill the space filled with a transparent color } } if (!file_exists($image_thum) || filesize($image_thum) < 100) { //Thumbnail generation fails with the default icon $image_thum = STATIC_PATH . 'images/image.png'; } //Export file_put_out($image_thum); }
$body=$row1->body; break; case 2: $dsql->SetQuery("Select imgurls From #@__addonimages where aid=$ID"); $dsql->Execute('c2'); $row1=$dsql->GetObject('c2'); $body=$row1->imgurls; break; } $old_cfg_medias_dir = str_replace('/','\/',$cfg_medias_dir); $picname=preg_replace("/.+?".$old_cfg_medias_dir."(.+?)( |\"|').*$/is",$cfg_medias_dir."$1",$body); //$picname = preg_replace("/.+?".$old_cfg_medias_dir."(.*)( |\"|').*$/isU",$cfg_medias_dir."$1",$body); $picname=rtrim($picname); if(eregi("\.(jpg|gif|png)$",$picname)) { $mkimg->SetVar($cfg_basedir.$picname,"file"); $litpic=str_replace('.','_lit.',$picname); $litpic=stripslashes($litpic); switch($maketype) { case 1: $mkimg->Distortion($cfg_basedir.$litpic,$imgwidth,$imgheight); break; case 2: $mkimg->Prorate($cfg_basedir.$litpic,$imgwidth,$imgheight); break; case 3: $mkimg->Cut($cfg_basedir.$litpic,$imgwidth,$imgheight); break; case 4: $mkimg->BackFill($cfg_basedir.$litpic,$imgwidth,$imgheight,$backcolor1,$backcolor2,$backcolor3);
function getdata($sqlstr, $code) { global $db; $sort_list = $db->getlist($sqlstr); foreach ($sort_list as $list) { preg_match_all('/<luocms([\\s\\S]*?)>([\\s\\S]*?)<\\/luocms>/', $code, $block_list); $hreftemp = $block_list[2][0]; $formtemp = $block_list[1][0]; $hreftempnew = $hreftemp; preg_match_all('/src=(\\")(.*?)(\\")/', $formtemp, $srclist); //得到是哪个表的内容 $src_temp = $srclist[2][0]; preg_match_all('/src=(\\")(.*?)(\\")/', $hreftemp, $srclist); //要生成的缩略图的部分 $s_pic_temp = $srclist[2][0]; //echo $s_pic_temp; preg_match_all('/\\[(.*?)\\swidth=(\'|\\")(.*?)(\'|\\")\\sheight=(\'|\\")(.*?)(\'|\\")\\]/', $s_pic_temp, $picturex); //生成缩略图并替换标签 $pxMax = count($picturex[0]); //echo $pxMax; for ($p = 0; $p < $pxMax; $p++) { $pp = $picturex[1][$p]; //echo $picturex[0][$p]; $ppw = $picturex[3][$p]; $pph = $picturex[6][$p]; $p_picture = $this->get_content_row($list['id'], 'picture'); if (!empty($ppw) && !empty($pph)) { $img_ext = strrchr($p_picture, '.'); $p_smallpic = substr($p_picture, 0, strlen($p_picture) - strlen($img_ext)) . "_s" . $img_ext; if (!file_exists($p_smallpic)) { $temp = new CreatMiniature(); $temp->SetVar($p_picture, $img_ext); $temp->BackFill('./' . $p_smallpic, $ppw, $pph, "255", "255", "255"); } $temp_img = "../" . $p_smallpic; } else { $temp_img = "../" . $p_picture; } //echo $picturex[0][$p]; $hreftempnew = str_replace($picturex[0][$p], $temp_img, $hreftempnew); } preg_match_all('/\\[luo\\.(.*?)\\]/', $hreftemp, $tName); //处理截取字符标签[luo.cotnent len='180'] $tArrMax = count($tName[0]); for ($k = 0; $k < $tArrMax; $k++) { $t1 = strtolower($tName[0][$k]); // 属性名称[luo.title] $t2 = strtolower($tName[1][$k]); //字段名title preg_match_all('/(.*?)x\\slen=(\'|\\")(.*?)(\'|\\")/', $t2, $titlex); $txArrMax = count($titlex[0]); for ($w = 0; $w < $txArrMax; $w++) { $ttr = $titlex[1][$w]; $tx = $titlex[0][$w]; $txx = "[luo." . $tx . "]"; $len = $titlex[3][$w]; $temp_c_value = get_html_replace($list[$ttr]); $temp_sub_str = utf_substr(htmlspecialchars(strip_tags(stripslashes($temp_c_value))), $len); $temp_sub_str_ext = strlen($list[$ttr]) > $len ? $temp_sub_str . "..." : $temp_sub_str; $hreftempnew = str_replace($txx, $temp_sub_str_ext, $hreftempnew); } switch ($t2) { //替换内容标签[luo.*] case "url": //链接 switch ($src_temp) { //根据当前表名用不同的链接地址 case "content": //内容表 $urltemp = $this->get_tpl_name($this->getclassid($list['id']), 'templateview') . "_" . $list['id'] . $GLOBALS[rewriteext]; $hreftempnew = str_replace($t1, $urltemp, $hreftempnew); break; case "link": //友情链接表 $urltemp = $list['url']; $hreftempnew = str_replace($t1, $urltemp, $hreftempnew); break; } break; case "classurl": //导航类别中地址 $urltemp = $this->get_tpl_name($list['id'], 'template') . "-" . $list['id'] . $GLOBALS[rewriteext]; $hreftempnew = str_replace($t1, $urltemp, $hreftempnew); break; case "content": //内容 $hreftempnew = str_replace($t1, strip_tags(stripslashes($list[$t2])), $hreftempnew); break; case "contentc": //显示单条内容时不用去除样式 $hreftempnew = str_replace($t1, stripslashes($list["content"]), $hreftempnew); break; case "title": //标题 $title = getstyle("content", $list['id'], $list['title']); $hreftempnew = str_replace($t1, $title, $hreftempnew); break; case "picture": //原始大小图片 $hreftempnew = str_replace($t1, '../' . $this->get_content_row($list['id'], 'picture'), $hreftempnew); break; case "replay": //留言板的回复 $temp_replay = empty($list['replay']) ? "" : "<div class='reply'><div class='gly'><b>管理员回复:</b>" . $list['replaytime'] . "</div><div class='gly_content'>" . $list['replay'] . "</div></div>"; $hreftempnew = str_replace($t1, $temp_replay, $hreftempnew); break; default: //其它,直接显示字段所对应的内容[luo.name]等 $hreftempnew = str_replace($t1, $list[$t2], $hreftempnew); break; } } $str_temp .= $hreftempnew; } return $str_temp; }