⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sbc.pl

📁 稀饭伊人相册系统继承了新天堂多用户相册系统的功能
💻 PL
字号:
# package SBC;## use vars qw( $VERSION );# $VERSION = '0.10';#商业版专用模块#建立日期 2006.2.7#修改日期2006.2.8# require Exporter;# @ISA = qw(Exporter);# @EXPORT = qw();# @EXPORT_OK = qw(%INFO);#use strict;# sub new {#     my $class = shift;#     my $this = $class->SUPER::new( @_ );#        $this ->_initCGI(); #('gb2312');##     if ($CGI::MOD_PERL) {#         if ($CGI::MOD_PERL == 1) {#         my $r = Apache->request;#             $r->register_cleanup(\&LBCGI::_reset_globals);#         } elsif ($CGI::MOD_PERL == 2) {#             my $r = Apache2::RequestUtil->request;#             $r->pool->cleanup_register(\&LBCGI::_reset_globals);#         }#     }#     $class->_reset_globals if $CGI::PERLEX;##     return bless $this, $class;# }# require "config.pl";eval("use GD;");#水印模块 png格式未知可否加取#2006.3.23 中文水印支持sub image_water{# 字符转换# use encoding "euc-cn", STDOUT => "utf8";# use encoding "BIG5", STDOUT => "utf8";use encoding "gb2312", STDOUT => "utf8";my $file = shift;      #要被加取水印的文件名my $dir_path=shift;   #源文件的位置my $fileext = shift ;  #文件类型$file="$albumdir/$dir_path/$file\.$fileext";my $imagefile= $file;  #保存文件的位置my $image;my $picwaterplace1="no"; # 水印位置:左上角my $watername1 = '测试';  #左上角水印内容my $picwaterplace2="yes"; # 水印位置:左下角my $watername2 = "pic.sakuras.cn";  #左下角水印内容my $picwaterplace3="yes"; # 水印位置:右上角my $watername3 = 'pic.sakuras.cn';  #右上角水印内容my $picwaterplace4="yes"; # 水印位置:右下角my $watername4 = "pic.sakuras.cn";  #右下角水印内容my @colour =(255,255,255);my @colour1=(250,144,199);        if ($@ eq "")        {#         my $filesize = (stat("$file"))[7]; #取得文件大小        if ($fileext eq 'jpeg'||'jpg') {              eval { $image = GD::Image->newFromJpeg($file, 1); };               $image = GD::Image->newFromJpeg($file) if ($@);        } else {              eval { $image = GD::Image->newFromPng($file, 1); };              $image = GD::Image->newFromPng($file) if ($@);          }        my ($imwidth, $imheight) = $image->getBounds ();        my $font = GD::gdLargeFont();        my $font_path = "D:/web/123.ttf";  #字体文件绝对路径#         #计算字体大小#         my $fontwidth = $font->width * length $watername;#         my $fontwidth3 = $font->width * length $watername3;#         my $fontwidth4 = $font->width * length $watername4;        #计算中文字体大小        my $fontwidth = $font->width * 2 * length $watername ;        my $fontwidth3 = $font->width * length $watername3;        my $fontwidth4 = $font->width * length $watername4;        my $txt1 = $image->colorAllocate(@colour[0],@colour[1],@colour[2]);    # 主体字体颜色        my $txt2 = $image->colorAllocate(@colour1[0],@colour1[1],@colour1[2]);    # 字体阴影颜色        if ($imheight > 40 && $imwidth > 200) {  # 小于 200*40 的图片不加水印if ($picwaterplace1 eq "yes") { # 左上角$image->stringFT($txt2,$font_path,12,0, 10 , 11, $watername1, {charmap => 'Unicode',});$image->stringFT($txt2,$font_path,12,0, 11 , 11, $watername1, {charmap => 'Unicode',});#$image->string($font, 10, 11, $watername1, $txt2);#$image->string($font, 11, 11, $watername1, $txt2);$image->stringFT($txt1,$font_path,12,0, 9 , 10, $watername1, {charmap => 'Unicode',});$image->stringFT($txt1,$font_path,12,0, 10 ,10, $watername1, {charmap => 'Unicode',});# $image->string($font, 9, 10, $watername1, $txt1);# $image->string($font, 10, 10, $watername1, $txt1);            }if ($picwaterplace2 eq "yes") { # 左下角$image->stringFT($txt2,$font_path,12,0, 10, $imheight - 20 + 1  , $watername2, {charmap => 'Unicode',});$image->stringFT($txt2,$font_path,12,0, 11, $imheight - 20 + 1  , $watername2, {charmap => 'Unicode',});# $image->string($font, 10, $imheight - 20 + 1, $watername2, $txt2);#$image->string($font, 11, $imheight - 20 + 1, $watername2, $txt2);$image->stringFT($txt1,$font_path,12,0, 9, $imheight - 20  , $watername2, {charmap => 'Unicode',});$image->stringFT($txt1,$font_path,12,0, 10, $imheight - 20 , $watername2, {charmap => 'Unicode',});# $image->string($font, 9, $imheight - 20, $watername2, $txt1);# $image->string($font, 10, $imheight - 20, $watername2, $txt1);            }if ($picwaterplace3 eq "yes") { # 右上角$image->stringFT($txt2,$font_path,12,0, $imwidth - $fontwidth3 - 9 + 1 , 11, $watername3, {charmap => 'Unicode',});$image->stringFT($txt2,$font_path,12,0, $imwidth - $fontwidth3 - 10 + 1 , 11, $watername3, {charmap => 'Unicode',});# $image->string($font, $imwidth - $fontwidth3 - 9 + 1, 11, $watername3, $txt2);# $image->string($font, $imwidth - $fontwidth3 - 10 + 1, 11, $watername3, $txt2);$image->stringFT($txt1,$font_path,12,0, $imwidth - $fontwidth3 - 9  , 10, $watername3, {charmap => 'Unicode',});$image->stringFT($txt1,$font_path,12,0, $imwidth - $fontwidth3 - 10 , 10, $watername3, {charmap => 'Unicode',});# $image->string($font, $imwidth - $fontwidth3 - 9, 10, $watername3, $txt1);# $image->string($font, $imwidth - $fontwidth3 - 10, 10, $watername3, $txt1);            }            if ($picwaterplace4 eq "yes") { # 右下角$image->stringFT($txt2,$font_path,12,0, $imwidth - $fontwidth4 - 9 + 1 , $imheight - 20 + 1 , $watername4, {charmap => 'Unicode',});$image->stringFT($txt2,$font_path,12,0, $imwidth - $fontwidth4 - 10 + 1 , $imheight - 20 + 1 , $watername4, {charmap => 'Unicode',});#                 $image->string($font, $imwidth - $fontwidth4 - 9 + 1, $imheight - 20 + 1, $watername4, $txt2);#                 $image->string($font, $imwidth - $fontwidth4 - 10 + 1, $imheight - 20 + 1, $watername4, $txt2);$image->stringFT($txt1,$font_path,12 , 0 , $imwidth - $fontwidth4 - 9 , $imheight - 20 , $watername4, {charmap => 'Unicode',});$image->stringFT($txt1,$font_path,12 , 0 , $imwidth - $fontwidth4 - 10 , $imheight - 20 , $watername4, {charmap => 'Unicode',});                # $image->string($font, $imwidth - $fontwidth4 - 9, $imheight - 20, $watername4, $txt1);#                 $image->string($font, $imwidth - $fontwidth4 - 10, $imheight - 20, $watername4, $txt1);            }        }        &image_type($fileext,$image,$imagefile);    }}#图片格式检测模块sub image_type{if ($_[0] eq 'jpeg'||'jpg') {            my $images= $_[1] ->jpeg();            &image_file($images,$_[2]);                                 }            else {            my $images= $_[1] ->png();            &image_file($images,$_[2]);        }}#缩略图模块sub image_thumb{my $file =shift;      #要被缩略的文件名my $dir_path=shift;   #源文件的位置my $fileext=shift||'temp'; #文件格式my $Width=80;   #缩略图的长度my $Height=60;  #缩略图的宽度my($width,$height);my $im = newFromJpeg GD::Image("$conf{base_path}/$conf{pic_url}/$conf{album_dir}/$dir_path/$file\.$fileext");unlink("$conf{base_path}/$conf{pic_url}/$conf{album_dir}/$dir_path/$file\.$fileext") if ($fileext eq 'temp');my ($width,$height) = $im->getBounds();my ($new_width,$new_height) = newSize($width,$height,$Width,$Height);$$im2 = new GD::Image($new_width,$new_height);$$im2->copyResized($im,0,0,0,0,$new_width,$new_height,$width,$height);image_type($fileext,$$im2,"$conf{base_path}/$conf{pic_url}/$conf{thumb_dir}/$dir_path/$file\.jpg");return 1;#缩略图只能是JPG文件}#JPG文件缩略sub image_JpgThumb{return &image_thumb($_[0],$_[1],$_[2])?1:0;}#Gif文件缩略(如果是动画的画只取第一帧)sub image_GifThumb{my $file =shift;      #要被缩略的文件名my $dir_path=shift;   #源文件的位置my $fileext='jpg';    #文件格式$$im = newFromGif GD::Image("$conf{base_path}/$conf{pic_url}/$conf{album_dir}/$dir_path/$file\.gif");&image_type("$fileext",$$im,"$conf{base_path}/$conf{pic_url}/$conf{album_dir}/$dir_path/$file\.temp");return (&image_thumb("$file","$dir_path")?1:0);}sub image_PngThumb{my $file =shift;      #要被缩略的文件名my $dir_path=shift;   #源文件的位置my $fileext='jpg';    #文件格式   $$im = newFromPng GD::Image("$conf{base_path}/$conf{pic_url}/$conf{album_dir}/$dir_path/$file\.png");&image_type("$fileext",$$im,"$conf{base_path}/$conf{pic_url}/$conf{album_dir}/$dir_path/$file\.temp");return (&image_thumb("$file","$dir_path")?1:0);}sub newSize($$$$){        my $width=shift();        my $height=shift();        my $Width=shift();        my $Height=shift();        my ($new_width, $new_height);        if($Width<=0 && $Height>0)        {                $Width=1000;        }else{                if($Height<=0 && $Width>0)                {                        $Height=1000;                }        }        if($Width<=0 && $Height<=0)        {                return ($width,$height);        }        if($Width/$width > $Height/$height)        {                $new_height=$Height;                $new_width=int(($Height/$height)*$width);        }        if($Width/$width <= $Height/$height)        {                $new_width=$Width;                $new_height=int(($Width/$width)*$height);        }        return ($new_width,$new_height);}#图片写入模块sub image_file{open( FILE, ">$_[1]" ) or return 0;    binmode FILE;    print FILE "$_[0]";    close(FILE);}#文件解压缩sub file_unzip{      my $zip_file=shift; #待解压文件名       my @allfiles;       eval ("use Archive::Zip qw(:ERROR_CODES)");#        use File::Path;       if($@) {return 0;}       my $zip = Archive::Zip->new();       chdir("$file_path/pic_temp");       my $status = $zip->read( $zip_file );       return 0 if $status != 0;    #统计解压后文件的大小    #    foreach my $member ($zip->members()){$totalSize += $member->uncompressedSize;}       $zip->extractTree("","zip_",'11');       opendir (DIRS, "$file_path/pic_temp/11");       foreach my $dir(readdir(DIRS))       {       push(@allfiles,$dir) if(!-d $dir);       }       closedir (DIRS);       &image_check(@allfiles);#        rmtree("$file_path/pic_temp/11",0,1);# mkpath 0,0755}#图片检测模块sub image_check{use File::Copy qw(cp);my @allfiles=@_;foreach my $image(@allfiles) {  my ($tmpfilename) = $image =~ m|([^/:\\]+)$|; #注意,获取文件名字的形式变化    #     $tmpfilename =~s/([^\w.-])/_/g;    #     $tmpfilename =~s/(^[-.]+)//;          my @filename = split(/\./,$tmpfilename); #注意          my $up_name = $filename[0];          my $up_ext = $filename[-1];             $up_ext = lc($up_ext); my($Width,$Height) = imgsize("$file_path/pic_temp/11/$up_name\.$up_ext"); if($Width ne '' && $Height ne '' && $up_ext eq 'jpg'|| $up_ext eq 'jpeg'||$up_ext eq 'gif'||$up_ext eq 'png'||$up_ext eq 'bmp') {cp("$file_path/pic_temp/11/$up_name\.$up_ext","$albumdir/default");  print "$file_path/pic_temp/11/$up_name\.$up_ext";}}}#文件压缩# sub file_zip# {# eval ("use Archive::Zip qw(:ERROR_CODES);");# my $zip = Archive::Zip->new();#                     chdir($$pUSER{'dir'});#                     my $memberName = "$sel[$a]";#                     if (-d $memberName ){#                         $subs -> mesaj("$$pTEXT{'hata'}","$$pTEXT{'nozip'}","",$pUSER,$pTEXT,$pFORM,$pGLOBAL) if $zip->addTree( $memberName, $memberName ) != 0; # AZ_OK#                     }#                     else {#                         $zip->addFile( $memberName ) || $subs -> mesaj("$$pTEXT{'hata'}","$$pTEXT{'nozip'}","",$pUSER,$pTEXT,$pFORM,$pGLOBAL);#                     }##                     my $status = $zip->writeToFileNamed($zipName);# }1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -