人氣點閱:6405 |
發表人 |
Perl Code: 十幾年前的 Vovo2000.Com Perl Web Utilities 2014-06-22 18:10 分類: ✔️print ✔️print ✔️print ✔️print 個人: ✔️print ✔️print ✔️print ✔️print |
/ / /
|
|
Perl 維護 Web 程式碼: Vovo2000.Com Perl Web Utilities (1)
這些 Perl code 是大約 2003 年使用 Windows Server 2003 + Apache 的 Web Server 維護程式 ... 各種老舊!
不過當時可 works,有部分還都一直用到 2007~2008 年左右!
貼出來的原因是,整理房間時,發現一個 8MB CF Card 裡面存了這些 code
(沒看錯, 8MB CF Made in Japan, Canon PowerShot A5Z 送的...)
這些 code 已經十幾年...目前完全沒使用了,若要拿去參考請小心。
Windows Server 備份 Apache Backup
代碼:
#!c:/perl/bin/perl
use File::NCopy qw(copy);
use Time:😜iece;
$file_toBackup = "D:/Vovoutil/BackupUtil/toBackup.txt";
$pathTarget = "E:/backup/".localtime->wday;
$pathTarget = "E:\\backup\\".localtime->wday;
print $pathTarget;
if( open( FILE, $file_toBackup ) )
{
foreach( <FILE> )
{
$a = $_;
system( "mkdir $_" );
print "備份: ".$a.$/;
copy \1, $_, $pathTarget;
}
close( FILE );
}
Windows deltempfile.bat
因為 Session File 會存在 Temp,定時清一下
代碼:
del /f /q c:\winnt\temp\*.*
Windows deltempfile.bat
Goal: 因為 PHP/Apache2 Session File 會存在 Temp,定時清一下
代碼:
del /f /q c:\winnt\temp\*.*
Replace String in Files Perl Code
這段 code 目的很簡單,就是把所有 Files 裡面的 "web.vovo.idv.tw" & "www.vovo2000.com" 改成 "vovo2000.com"
代碼:
#!C:/perl/bin/perl
use File::Find;
sub mysub(); # Our custom subroutine
@directories = ("D:/apache2/htdocs/");
$tar1 = "web.vovo.idv.tw";
$tar2 = "www.vovo.idv.tw";
find(\&mysub, @directories);
sub mysub()
{
my ($filename) = $_;
if ( ($filename =~ /\.htm$/) || ($filename =~ /\.html$/) || ($filename =~ /\.php$/) )
{
print "$filename ";
if( open( FILE, $filename ) )
{
$a = join( "", <FILE> );
close( FILE );
$r = 0;
if ( $a =~ /$tar1/ )
{
$r = 1;
}
if ( $a =~ /$tar2/ )
{
$r = 1;
}
if ( $r == 1 )
{
### 先備份
if ( open( FILE, ">$filename".".orig" ) )
{
print FILE ($a);
close(FILE);
}
### 至換
$a =~ s/$tar1/vovo2000.com/g;
$a =~ s/$tar2/vovo2000.com/g;
if ( open( FILE, ">$filename" ) )
{
print FILE ($a);
close(FILE);
}
print "=============>改".$/;
}
else
{
print "=>不改".$/;
}
}
}
}
DailyArist.pl Perl Code
2000 ~ 2005 年,Vovo2000.com 還是採用 Gallery 1 or Gallery 2
這是產生每日投稿的 Perl Code(從 Gallery 目錄裡面硬 parse)
代碼:
#!C:/Perl/bin/Perl.exe
use File::Find;
use Time:😜iece;
use POSIX qw(strftime);
use Switch;
$timeOneDay = 86400;
$dayMultipler = 1;
$ByteCount = 0;
$fileAll = 0;
$fileJpg = 0;
$fileYes = 0;
$pathToTra = "D:/Apache2/htdocs/gallery/albums/";
$pathWebPreFix = "/gallery/albums/";
$thumbExt = ".thumb.jpg";
$contrib = "distrib";
$roomerlist = "D:/Apache2/htdocs/friend/roomer_list.txt";
$targetPath = "D:/Apache2/htdocs/news/";
$targetExt = "dailyArtist.htm";
$template = "D:/vovoutil/template-dailyArtist.tpl";
@fname=();
@roomer_list=();
if ( open(FILE, $template) )
{
$strTpl = join( "", <FILE>);
close( FILE );
}
if ( open(FILE, $roomerlist) )
{
@roomer_list = <FILE>;
close( FILE );
}
$roomer_count = scalar(@roomer_list);
## 產生 YYYYMMDD.htm
srand;
$intLuckGuy = int(rand()*$roomer_count);
( $a, $b, $c ) = split( ",", $roomer_list[$intLuckGuy] );
( $e, $f ) = split( "\/", $c );
print $e.$/;
print $e.$/;
print $e.$/;
$pathToTra = $pathToTra.$e;
find(\&fileHighLight, $pathToTra);
$img_high = $fname[int(rand()*scalar(@fname))];
print "We show this...: ".$img_high.$/;
$strTpl =~ s/{AUTH}/$e/g;
$strTpl =~ s/{RNAME}/$a/g;
$strTpl =~ s/{HIGHLIGHT}/$img_high/g;
$strTpl =~ s/{FNUM}/$b/g;
$strTpl =~ s/{FIDX}/$c/g;
#print $strTpl.$/;
if( open(FILE, ">$targetPath".$targetExt ) )
{
print FILE ($strTpl);
close( FILE );
}
exit;
sub fileHighLight
{
if ((/$thumbExt/) )
{
$tmp = $File::Find::name;
$tmp2 = $tmp;
$tmp2 =~ s/$pathToTra//g;
#($auth[$fileYes], $fnam[$fileYes])=split( "\/", $tmp2 );
#print $auth[$fileYes].$/;
$fname[$fileYes++] = $tmp2;
print $tmp.$/;
}
}
代碼:
#!C:/perl/bin/perl.exe
$directory2004 = "D:\\Apache2\\htdocs\\news\\2004\\2004*.htm";
$file_tmp = "D:/VovoUtil/tmparch.file";
$file_newsarchive = "D:/Apache2/htdocs/news/news_archives.htm";
$file_template1 = "template-newsArchives.tpl";
$file_roomer_list = "D:/Apache2/Htdocs/friend/roomer_list.txt";
system( "dir $directory2004 > $file_tmp" );
$i = 0;
$j = 0;
$template_str2003 = "[ <a href=\"/news/2004/{HTML}\" title=\"Vovo2000.Com Site News {DATE}\">{DATE}</a> ]";
#####################################
# 取出新聞
#####################################
if ( open( FILE, "<$file_tmp" ) )
{
@a = <FILE>;
foreach( @a )
{
#print $_;
if ( index( $_, ".htm" ) > 0 )
{
$strbuf = $template_str2003;
($c1,$c2,$c3,$c4) = split( / +/, $_ );
$c1 = $c4;
$c1 =~ s/-m//g;
$c1 =~ s/.htm//g;
$c1 = substr( $c1, 0, 4)."-".substr( $c1, 4, 2 )."-".substr( $c1, 6, 2 );
$strbuf =~ s/{DATE}/$c1/g;
$strbuf =~ s/{HTML}/$c4/g;
$strAll .= $strbuf;
if ( $i++ > 8 ) { $i = 0; $strAll .= "<BR />"; }
}
}
close( FILE );
}
print $strAll;
########################################## 把 template 讀進來,然後至換
if ( open( FILE, "<$file_template1" ) )
{
$strTpl1 = join( "", <FILE> );
close( FILE );
}
$loct = localtime();
$strTpl1 =~ s/{V2K_NEWS_THISYEAR_DAYBYDAY}/$strAll/;
$strTpl1 =~ s/{UPDATE_TIME}/$loct/;
#print $strTpl1;
########################################## 寫進去
if ( open( FILE, ">$file_newsarchive" ) )
{
print FILE ($strTpl1);
close( FILE );
}
exit;
Apache Log Rotate and Restart Perl Code
這段 Code 是因為 2003 ~ 2004 年左右的 Apache "for Windows" LogRotate
功能還是很爛! 所以只好自己寫。
代碼:
#!C:/Perl/bin/Perl.exe
($sec,$min,$hour,$mday,$mon,$year,$wday)=(localtime)[0,1,2,3,4,5,6];
$year += 1900;
$mon += 1;
$logg = $year."-".$mon."-".$mday.".log";
print "Stopping APACHE2!\n";
system( "D:\\Apache2\\bin\\apache -k stop" );
print "Renaming!...\n";
system( "move D:\\Apache2\\logs\\access.log D:\\Apache2\\logs\\$logg" );
print "Restarting APACHE2!\n";
system( "D:\\Apache2\\bin\\apache -k start" );
________________
美術插畫設計案子報價系統 v0.1 Beta
爪哇禾雀
|
|
Type
繪圖畫廊 設計藝廊 攝影相簿 留言板 最愛收藏 分類標籤
暱稱: Type 註冊: 2002-11-30 發表: 11173 來自: vovo2000.com
V幣: 901761
|
|
|
Re: Perl Code: 十幾年前的 Vovo2000.Com Perl Web Utilities 2014-06-22 18:17 |
/ / /
|
|
Perl Code: 十幾年前的 Vovo2000.Com Perl Web Utilities (2)
stat_Gallery_HotPic
這是 2003 年,土法煉鋼硬讀取 Gallery 1 資料庫,取出「最熱門作品」的 Perl Code
代碼:
#!C:/perl/bin/perl.exe
$directory = "D:/Apache2/htdocs/gallery/albums/";
$directory2 = "D:\\Apache2\\htdocs\\gallery\\albums\\";
$file_tmp = "D:/VovoUtil/tmp2.file";
$file_hotpicHit = "D:/Apache2/Htdocs/friend/rank_hotestPic{NUM}.htm";
$file_template1 = "template-hotpicrank.tpl";
$file_template2 = "template-hotpicrank-detail.tpl";
$file_roomer_list = "D:/Apache2/Htdocs/friend/roomer_list.txt";
#@not_in_list = ( "18", "ClubTWCP" , "friend", "distrib" );
@not_in_list = ( "friend", "distrib" );
system( "dir $directory2 > $file_tmp" );
$i = 0;
$j = 0;
$hot_gap = 5;
$stop_gap = 300;
$per_page = 15;
$hot_imgrsc = "<img src=\"/image/hot.gif\"></img>";
$null_imgrsc = "<img src=\"/image/null.gif\"></img>";
#####################################
# 娶作家
#####################################
if ( open( FILE, "<$file_tmp" ) )
{
@a = <FILE>;
foreach( @a )
{
if ( index( $_, "<DIR>" ) > 0 )
{
($c1,$c2) = split( "<DIR>", $_ );
$c2 =~ s/^ //g;
$c2 =~ s/$\///g;
$addit = 1;
for ( $j=0; $j<scalar(@not_in_list); $j++)
{
if ( lc($not_in_list[$j]) eq lc($c2) )
{
$addit=0;
}
}
if ( $addit == 1 )
{
$subdirs[$i++] = $c2;
}
#print $_;
}
else
{
}
}
close( FILE );
}
$dfile = "photos.dat";
$dlimt = "clicks\";";
$plimt = "\"image\":12:{s:4:\"name\";s:";
$fileBuf = "";
$strbuf = "";
$strtmp = "";
@fdata = ();
%auth_kname;
%auth_rname;
%auth_pcount;
%auth_clicks;
####################################
# 名字到 %auth_rname,
# Forum 到 %auth_fnum,
# index 到 %auth_index
####################################
if ( open( FILE, "<$file_roomer_list" ) )
{
my @a=<FILE>;
$total_roomer = $.;
foreach( @a )
{
( $rname, $fnum, $com1 ) = split( ",", $_ );
( $kname, $com2 ) = split( "\/", $com1 );
$kname = lc($kname);
$auth_rname{$kname} = $rname;
$auth_fnum{$kname} = $fnum;
$auth_index{$kname} = $com1;
}
close( FILE );
}
#####################################
# 讀取 ClickCount / PCOUNT
#####################################
$total_pics = 0;
foreach( @subdirs )
{
$df = $_;
$fileBuf = $directory.$df."/".$dfile;
$df = lc($df);
if ( -e $fileBuf )
{
print $fileBuf.$/;
if ( open( FILE, $fileBuf ) )
{
$strbuf = join("",<FILE>);
$strtmp = "";
( $i, $l, $k ) = split( ":", $strbuf );
$i = 0;
$a = "";
for( $k=0; $k<$l; $k++ )
{
$total_pics++;
##### 讀取作品數 到 %auth_pcount
$strtmp = "";
$i = index( $strbuf, $plimt, $i );
$i += length($plimt);
$strspc = substr( $strbuf, $i, 2 ); ## 取最多兩位
$strspc =~ s/://g;
$zz = ( $strspc eq substr( $strbuf, $i, 2 ) ? 2 : 1 );
$i += 2 + $zz;
for( $j=0; $j<int($strspc); $j++ )
{
$a = substr($strbuf, $i+$j, 1 );
if ( $a ne ";" )
{
$strtmp .= $a;
}
else
{
$j = 10;
}
}
$strtmp =~ s/\"//g;
$strtmp =~ s/://g;
#print "檔名: ".$strtmp.$/;
$fname = $strtmp;
##### 讀取總點擊數 到 %auth_clicks
$i = index( $strbuf, $dlimt, $i );
$i += length($dlimt);
$strtmp = "";
$a = "";
if ( substr($strbuf, $i, 1 ) ne "N" )
{
for( $j=2; $j<8; $j++ )
{
$a = substr($strbuf, $i+$j, 1 );
if ( $a ne ";" )
{
$strtmp .= $a;
}
else
{
$j = 10;
}
}
}
else
{
$strtmp = "0";
}
#print "點點: ".$strtmp.$/;
$auth_clicks{$df.":".$fname} = $strtmp;
close( FILE );
}
}
}
}
########################################## 把 template 讀進來,然後至換
$strbuf = "";
$strall = "";
@strAll = ();
if ( open( FILE, "<$file_template1" ) )
{
$strTpl1 = join( "", <FILE> );
close( FILE );
}
if ( open( FILE, "<$file_template2" ) )
{
$strTpl2 = join( "", <FILE> );
close( FILE );
}
#print $strTpl2;
$j = 1;
$l = 1;
$k = 0;
foreach $key (sort {$auth_clicks{$b} <=> $auth_clicks{$a}} keys %auth_clicks)
{
$strbuf = $strTpl2;
( $key1, $key2 ) = split( ":", $key );
$clicks = $auth_clicks{$key};
$pica = $key2.".thumb.jpg";
if ( $auth_rname{$key1} ne "" )
{
$strbuf =~ s/{A_REALNAME}/$auth_rname{$key1}/g;
}
else
{
$strbuf =~ s/{A_REALNAME}/[CLUB]-$key1/g;
}
#$strbuf =~ s/{A_PCOUNT}/$auth_pcount{$key1}/g;
$strbuf =~ s/{A_CLICKS}/$clicks/g;
$strbuf =~ s/{A_GALLERY}/$key1/g;
$strbuf =~ s/{A_FORUM}/$auth_fnum{$key1}/g;
$strbuf =~ s/{A_INDEX}/$auth_index{$key1}/g;
$strbuf =~ s/{A_PIC_THUMB}/$pica/g;
$strbuf =~ s/{NUM}/$j/;
$strbuf =~ s/{A_PIC}/$key2/g;
if ( $j <= $hot_gap )
{
$strbuf =~ s/{HOT_IMG}/$hot_imgrsc/g;
}
else
{
$strbuf =~ s/{HOT_IMG}//g;
}
$j++;
$l++;
$strAll .= $strbuf;
if ( $l > $per_page )
{
$strAll[$k] = $strAll;
$l = 1;
$k++;
$strAll = "";
}
if ( $j > $stop_gap ) { last; }
}
$loct = localtime();
$strbuf = "";
$strtmp = "";
$i = 1;
foreach (@strAll)
{
$strbuf = $strTpl1;
#print $_;
$strbuf =~ s/{RANK_LIST}/$_/;
$strbuf =~ s/{TOTAL_PICS}/$total_pics/;
$strbuf =~ s/{HOWMUCH}/$stop_gap/;
$strbuf =~ s/{UPDATE_TIME}/$loct/;
########################################## 寫進去
$strtmp = $file_hotpicHit;
$strtmp =~ s/{NUM}/$i/g;
$i++;
print "產生: $strtmp".$/;
if ( open( FILE, ">$strtmp" ) )
{
print FILE ($strbuf);
close( FILE );
}
}
exit;
代碼:
#!C:/perl/bin/perl.exe
$directory = "D:/Apache2/htdocs/gallery/albums/";
$directory2 = "D:\\Apache2\\htdocs\\gallery\\albums\\";
$file_tmp = "D:/VovoUtil/tmp.file";
$file_artistHit = "D:/Apache2/Htdocs/friend/rank_artistHit{NUM}.htm";
$file_artistHit2 = "D:/Apache2/Htdocs/friend/rank_artistHit.txt";
$file_template1 = "template-artisthitrank.tpl";
$file_template2 = "template-artisthitrank-detail.tpl";
$file_roomer_list = "D:/Apache2/Htdocs/friend/roomer_list.txt";
@not_in_list = ( "18", "ClubTWCP", "friend", "distrib", "vovo2000" );
$per_page = 25; # 分頁
system( "dir $directory2 > $file_tmp" );
$i = 0;
$j = 0;
$hot_gap = 5;
$hot_imgrsc = "<img src=\"/image/hot.gif\"></img>";
$null_imgrsc = "<img src=\"/image/null.gif\"></img>";
#####################################
# 娶作家
#####################################
if ( open( FILE, "<$file_tmp" ) )
{
@a = <FILE>;
foreach( @a )
{
if ( index( $_, "<DIR>" ) > 0 )
{
($c1,$c2) = split( "<DIR>", $_ );
$c2 =~ s/^ //g;
$c2 =~ s/$\///g;
#if ( !($c2 in @not_in_list) )
#{
$addit = 1;
for ( $j=0; $j<scalar(@not_in_list); $j++)
{
if ( lc($not_in_list[$j]) eq lc($c2) )
{
$addit=0;
}
}
if ( $addit == 1 )
{
$subdirs[$i++] = $c2;
print "o";
}
print ".";
}
else
{
}
}
close( FILE );
}
$dfile = "photos.dat";
$dlimt = "clicks\";i:";
$plimt = "cached_photo_count\";i:";
$fileBuf = "";
$strbuf = "";
$strtmp = "";
@fdata = ();
%auth_kname;
%auth_rname;
%auth_pcount;
%auth_clicks;
####################################
# 名字到 %auth_rname,
# Forum 到 %auth_fnum,
# index 到 %auth_index
####################################
if ( open( FILE, "<$file_roomer_list" ) )
{
my @a=<FILE>;
$total_roomer = $.;
foreach( @a )
{
( $rname, $fnum, $com1 ) = split( ",", $_ );
( $kname, $com2 ) = split( "\/", $com1 );
$kname = lc($kname);
$auth_rname{$kname} = $rname;
$auth_fnum{$kname} = $fnum;
$auth_index{$kname} = $com1;
}
close( FILE );
}
#####################################
# 讀取 ClickCount / PCOUNT / # "clicks";i:XXXX;
#####################################
foreach( @subdirs )
{
$df = $_;
$fileBuf = $directory.$df."/".$dfile;
$df = lc($df);
if ( -e $fileBuf )
{
print $fileBuf.$/;
if ( open( FILE, $fileBuf ) )
{
$cntBuf = 0;
$artBuf = 0;
if ( open( FILE, $fileBuf ) )
{
$strbuf = join( "", <FILE> );
$strbuf =~ s/;/\n/g;
@a = split( "\n", $strbuf );
foreach( @a )
{
$zBuf = 0;
if ( index( $_, "i\:" ) != -1 && index( $last, "clicks" ) != -1 )
{
($zBuf,$zBuf) = split( ":", $_ );
$cntBuf += $zBuf;
++$artBuf;
}
$last = $_;
}
#print $cntBuf.$/;
#print $artBuf.$/;
}
$auth_pcount{$df} = $artBuf;
$auth_tclicks{$df} = $cntBuf;
$auth_clicks{$df} = sprintf( "%.2f", ($cntBuf/$artBuf));
close( FILE );
}
}
}
########################################## 把 template 讀進來,然後至換
$strbuf = "";
$strAll = "";
if ( open( FILE, "<$file_template1" ) )
{
$strTpl1 = join( "", <FILE> );
close( FILE );
}
if ( open( FILE, "<$file_template2" ) )
{
$strTpl2 = join( "", <FILE> );
close( FILE );
}
#print $strTpl2;
$j = 1;
$k = 0;
$l = 1;
$strAltAll="";
foreach $key (sort {$auth_clicks{$b} <=> $auth_clicks{$a}} keys %auth_clicks)
{
$strbuf = $strTpl2;
$strbuf =~ s/{A_REALNAME}/$auth_rname{$key}/g;
$strbuf =~ s/{A_PCOUNT}/$auth_pcount{$key}/g;
$strbuf =~ s/{A_CLICKS}/$auth_clicks{$key}/g;
$strbuf =~ s/{A_GALLERY}/$key/g;
$strbuf =~ s/{A_FORUM}/$auth_fnum{$key}/g;
$strbuf =~ s/{A_INDEX}/$auth_index{$key}/g;
$strbuf =~ s/{NUM}/$j/g;
$strbuf =~ s/{T_CLICKS}/$auth_tclicks{$key}/g;
$strAltAll .= $key.",".$auth_clicks{$key}.$/;
if ( $j <= $hot_gap )
{
$strbuf =~ s/{HOT_IMG}/$hot_imgrsc/g;
}
else
{
$strbuf =~ s/{HOT_IMG}//g;
}
$j++;
$l++;
$strAll .= $strbuf;
if ( $l > $per_page )
{
print " 換頁...$k ".$/;
$strAll[$k] = $strAll;
$l = 1;
$k++;
$strAll = "";
}
}
$strAll[$k] = $strAll;
print "========> ".$j.$/;
########################################## 寫進去
#if ( open( FILE, ">$file_artistHit" ) )
#{#
# print FILE ($strTpl1);
# close( FILE );
#}
print "========> ".scalar(@strAll).$/;
$strbuf = "";
$strtmp = "";
$i = 1;
foreach (@strAll)
{
$strbuf = $strTpl1;
$loct = localtime();
$strbuf =~ s/{RANK_LIST}/$_/;
$strbuf =~ s/{TOTAL_ROOMER}/$total_roomer/;
$strbuf =~ s/{UPDATE_TIME}/$loct/;
########################################## 寫進去
$strtmp = $file_artistHit;
$strtmp =~ s/{NUM}/$i/g;
$i++;
print "產生: $strtmp".$/;
if ( open( FILE, ">$strtmp" ) )
{
print FILE ($strbuf);
close( FILE );
}
}
#########################################
if ( open( FILE, ">$file_artistHit2" ) )
{
print FILE ($strAltAll);
close( FILE );
}
exit;
________________
美術插畫設計案子報價系統 v0.1 Beta
爪哇禾雀
|
|
Type
繪圖畫廊 設計藝廊 攝影相簿 留言板 最愛收藏 分類標籤
暱稱: Type 註冊: 2002-11-30 發表: 11173 來自: vovo2000.com
V幣: 901761
|
|
|
Re: Perl Code: 十幾年前的 Vovo2000.Com Perl Web Utilities 2014-06-22 18:21 |
/ / /
|
|
Perl Code: Perl Web Utilities decades ago (3)
看不太懂這段的目的了...應該是當時駐站畫家的處理;
總之一樣和土法煉鋼 Image Gallery 有關。
代碼:
#!C:/Perl/bin/Perl.exe
use File::Find;
use Time:😜iece;
use LWP::Simple;
use POSIX qw(strftime);
$timeOneDay = 86400;
$dayMultipler = 1;
$ByteCount = 0;
$fileAll = 0;
$fileJpg = 0;
$fileYes = 0;
####### 總共查三個目錄 ToTra / ToHa (CG) / ToSFX (SFX)
$pathToTra = "D:/Apache2/htdocs/gallery/albums/";
$pathToHa = "D:/Apache2/htdocs/vovo-gallery/data/VovoCG/";
$pathToSFX = "D:/Apache2/htdocs/vovo-gallery/data/sfx/";
$thumbExt = ".thumb.jpg";
$contrib = "distrib";
$roomerlist = "D:/Apache2/htdocs/friend/roomer_list.txt";
$targetPath = "D:/Apache2/htdocs/news/2005/";
$targetExt = ".htm";
$template = "D:/vovoutil/template-gala.tpl";
$template_img = "D:/vovoutil/template-img.tpl";
$template_welcome = "D:/vovoutil/news_wordlist_welcome.tpl";
@auth=();
@fnam=();
@roomer_list=();
if ( open(FILE, $template_img) )
{
$strImg = join( "", <FILE>);
close( FILE );
}
if ( open(FILE, $roomerlist) )
{
@roomer_list = <FILE>;
close( FILE );
}
$roomer_count = scalar(@roomer_list);
$gt = localtime;
$t1 = $gt->epoch;
@ppp = ( $pathToHa, $pathToTra, $pathToSFX );
find(\&fileThumb, @ppp );
$gt = localtime;
$t2 = $gt->epoch;
print "Total KByte: ".($ByteCount/1024)."\n";
print "Total Scan: ".$fileAll."\n";
print "Total Jpeg: ".$fileJpg."\n";
print "Total Match: ".$fileYes."\n";
print "Total TimeCost: ".($t2-$t1)."\n";
## 產生 YYYYMMDD.htm
$strAll = "";
$bbCount = 0;
$lastAuth = "";
$piccount = 0;
for ( $i = 0; $i < scalar(@auth); $i++ )
{
print $auth[$i].$/;
if ( $bbCount == 0 )
{
$strAll .= "<tr>\n";
}
$strBuf = $strImg;
if ( $auth[$i] ne "VovoCG" && $auth[$i] ne "VovoSFX" )
{
$g_imag = "/gallery/albums/$auth[$i]/$fnam[$i]"."$thumbExt";
$g_view = "/gallery/view_photo.php?set_albumName=$auth[$i]&id=$fnam[$i]";
$strBuf =~ s/{NEWS-IMG-SRC}/$g_imag/g;
$strBuf =~ s/{NEWS-HREF}/$g_view/g;
$authBuf = findRealAuth($auth[$i]);
print $authBuf;
if ( $auth[$i] eq $contrib )
{
$strBuf =~ s/{AUTH}/$auth[$i]/g;
$strBuf =~ s/駐站畫家//g;
$strBuf =~ s/{RNAME}/投稿園地/g;
$strAll .= $strBuf;
$switch = 1;
}
else
{
$strBuf =~ s/{AUTH}/$auth[$i]/g;
$strBuf =~ s/{RNAME}/$authBuf/g;
if ( $lastAuth eq $auth[$i] )
{
$switch = 0;
$piccount++;
}
else
{
$strAll .= $strBuf;
$switch = 1;
$piccount=0;
}
}
}
else
{
if ( $auth[$i] eq "VovoCG" )
{
$gala_ha = "https://vovo2000.com/vovo-gallery/data/VovoCG";
$gala_ha2 = "https://vovo2000.com/vovo-gallery/VovoCG";
}
elsif ( $auth[$i] eq "VovoSFX" )
{
$gala_ha = "https://vovo2000.com/vovo-gallery/data/sfx";
$gala_ha2 = "https://vovo2000.com/vovo-gallery/sfx";
}
$g_imag = $gala_ha."/".$ha_p;
$g_view = $gala_ha2;
$strBuf =~ s/{NEWS-IMG-SRC}/$g_imag/g;
$strBuf =~ s/http:\/\/artist.vovo2000.com\/{AUTH}/$g_view/g;
$strBuf =~ s/駐站畫家//g;
$strBuf =~ s/{RNAME}/小哈美術插畫/g;
$strAll .= $strBuf;
$switch = 1;
print "=======".$fname[$i]."=========".$/;
}
$lastAuth = $auth[$i];
if ( $switch == 1 )
{
$bbCount++;
if ( $bbCount >= 4 )
{
$strAll .= "</tr>\n";
$bbCount = 0;
}
}
}
if ( $i >= 1 && ($bbCount != 0 && $bbCount !=4 ) )
{
$strAll .= "</tr>";
}
if ( $strAll ne "" )
{
$strAll .= "<\!-- ".scalar(localtime)." AutoCreated end-(thwu) \/\/-->";
if ( open(FILE, $template) )
{
$strTpl = join( "", <FILE>);
close( FILE );
}
$strTpl =~ s/{NEWS-IMG-ONLY}/$strAll/g;
$strBuf = $gt->ymd;
$strBuf =~ s/-//g;
$strToday = "<li>".($gt->ymd("/"))." (".$gt->wdayname.")</li><br>";
$strTpl =~ s/{NEWS-DATE-TIME}/$strToday/g;
### 歡迎 {WELCOME}
srand;
if ( open( FILE, "<$template_welcome" ) )
{
@tmp=<FILE>;
$strTpl =~ s/{WELCOME}/$tmp[rand($.)]/g;
close( FILE );
}
if( open(FILE, ">$targetPath".$strBuf.$targetExt ) )
{
print FILE ($strTpl);
close( FILE );
}
}
exit;
sub fileThumb
{
$fileAll++;
if ( (/thumb\.jpg$/) )
{
$fileJpg++;
my $lt = 0;
$lt = localtime;
my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks) = stat($_) or die "Unable to stat $_\n";
my $ctime_str = strftime "%Y-%m-%d", localtime($mtime);
my $nowcp_str = $lt->ymd("-");
if ( $ctime_str eq $nowcp_str )
{
my $tmp = $File::Find::name;
if ( index( $tmp, "VovoCG" ) == -1 )
{
if ( index( $tmp, "sfx" ) == -1 )
{
## 駐站
$tmp =~ s/$pathToTra//g;
($auth[$fileYes], $fnam[$fileYes])=split( "\/", $tmp );
$fnam[$fileYes] =~ s/$thumbExt//g;
$fileYes++;
print "駐站===".$tmp.$/;
}
else
{
## SFX
$tmp =~ s/$pathToSFX//g;
($auth[$fileYes], $fnam[$fileYes])=split( "\/", $tmp );
$ha_p = $auth[$fileYes];
$auth[$fileYes] = "VovoSFX";
$fileYes++;
print "哈哈===SFX".$tmp.$/;
}
}
else
{
$tmp =~ s/$pathToHa//g;
($auth[$fileYes], $fnam[$fileYes])=split( "\/", $tmp );
$ha_p = $auth[$fileYes];
$auth[$fileYes] = "VovoCG";
$fileYes++;
print "哈哈===".$tmp.$/;
}
}
}
}
sub findRealAuth
{
local($par) = shift(@_);
my $j=0;
for( $j = 0; $j < $roomer_count; $j++ )
{
$roomer_list[$j] =~ s/\n//g;
$roomer_list[$j] =~ s/\r//g;
( $a, $b, $c ) = split( ",", $roomer_list[$j] );
( $e, $f ) = split( "\/", $c );
if ( $par eq $e )
{
return $a;
}
}
return $par;
}
________________
美術插畫設計案子報價系統 v0.1 Beta
爪哇禾雀
|
|
Type
繪圖畫廊 設計藝廊 攝影相簿 留言板 最愛收藏 分類標籤
暱稱: Type 註冊: 2002-11-30 發表: 11173 來自: vovo2000.com
V幣: 901761
|
|
|
Re: Perl Code: 十幾年前的 Vovo2000.Com Perl Web Utilities 2014-06-22 18:24 |
/ / /
|
|
stat_Gallery_Top10.pl
應該是取出 Top10 Gallery Hits
代碼:
#!C:/perl/bin/perl.exe
$directory = "D:/Apache2/htdocs/gallery/albums/";
$directory2 = "D:\\Apache2\\htdocs\\gallery\\albums\\";
$file_tmp = "D:/VovoUtil/tmp.file";
$file_artistHit = "D:/Apache2/Htdocs/friend/rank_artistHit{NUM}.htm";
$file_artistHit2 = "D:/Apache2/Htdocs/friend/rank_artistHit.txt";
$file_template1 = "template-artisthitrank.tpl";
$file_template2 = "template-artisthitrank-detail.tpl";
$file_roomer_list = "D:/Apache2/Htdocs/friend/roomer_list.txt";
@not_in_list = ( "18", "ClubTWCP", "friend", "distrib", "vovo2000" );
$per_page = 25; # 分頁
system( "dir $directory2 > $file_tmp" );
$i = 0;
$j = 0;
$hot_gap = 5;
$hot_imgrsc = "<img src=\"/image/hot.gif\"></img>";
$null_imgrsc = "<img src=\"/image/null.gif\"></img>";
#####################################
# 娶作家
#####################################
if ( open( FILE, "<$file_tmp" ) )
{
@a = <FILE>;
foreach( @a )
{
if ( index( $_, "<DIR>" ) > 0 )
{
($c1,$c2) = split( "<DIR>", $_ );
$c2 =~ s/^ //g;
$c2 =~ s/$\///g;
#if ( !($c2 in @not_in_list) )
#{
$addit = 1;
for ( $j=0; $j<scalar(@not_in_list); $j++)
{
if ( lc($not_in_list[$j]) eq lc($c2) )
{
$addit=0;
}
}
if ( $addit == 1 )
{
$subdirs[$i++] = $c2;
print "o";
}
print ".";
}
else
{
}
}
close( FILE );
}
$dfile = "photos.dat";
$dlimt = "clicks\";i:";
$plimt = "cached_photo_count\";i:";
$fileBuf = "";
$strbuf = "";
$strtmp = "";
@fdata = ();
%auth_kname;
%auth_rname;
%auth_pcount;
%auth_clicks;
####################################
# 名字到 %auth_rname,
# Forum 到 %auth_fnum,
# index 到 %auth_index
####################################
if ( open( FILE, "<$file_roomer_list" ) )
{
my @a=<FILE>;
$total_roomer = $.;
foreach( @a )
{
( $rname, $fnum, $com1 ) = split( ",", $_ );
( $kname, $com2 ) = split( "\/", $com1 );
$kname = lc($kname);
$auth_rname{$kname} = $rname;
$auth_fnum{$kname} = $fnum;
$auth_index{$kname} = $com1;
}
close( FILE );
}
#####################################
# 讀取 ClickCount / PCOUNT / # "clicks";i:XXXX;
#####################################
foreach( @subdirs )
{
$df = $_;
$fileBuf = $directory.$df."/".$dfile;
$df = lc($df);
if ( -e $fileBuf )
{
print $fileBuf.$/;
if ( open( FILE, $fileBuf ) )
{
$cntBuf = 0;
$artBuf = 0;
if ( open( FILE, $fileBuf ) )
{
$strbuf = join( "", <FILE> );
$strbuf =~ s/;/\n/g;
@a = split( "\n", $strbuf );
foreach( @a )
{
$zBuf = 0;
if ( index( $_, "i\:" ) != -1 && index( $last, "clicks" ) != -1 )
{
($zBuf,$zBuf) = split( ":", $_ );
$cntBuf += $zBuf;
++$artBuf;
}
$last = $_;
}
#print $cntBuf.$/;
#print $artBuf.$/;
}
$auth_pcount{$df} = $artBuf;
$auth_tclicks{$df} = $cntBuf;
$auth_clicks{$df} = sprintf( "%.2f", ($cntBuf/$artBuf));
close( FILE );
}
}
}
########################################## 把 template 讀進來,然後至換
$strbuf = "";
$strAll = "";
if ( open( FILE, "<$file_template1" ) )
{
$strTpl1 = join( "", <FILE> );
close( FILE );
}
if ( open( FILE, "<$file_template2" ) )
{
$strTpl2 = join( "", <FILE> );
close( FILE );
}
#print $strTpl2;
$j = 1;
$k = 0;
$l = 1;
$strAltAll="";
foreach $key (sort {$auth_clicks{$b} <=> $auth_clicks{$a}} keys %auth_clicks)
{
$strbuf = $strTpl2;
$strbuf =~ s/{A_REALNAME}/$auth_rname{$key}/g;
$strbuf =~ s/{A_PCOUNT}/$auth_pcount{$key}/g;
$strbuf =~ s/{A_CLICKS}/$auth_clicks{$key}/g;
$strbuf =~ s/{A_GALLERY}/$key/g;
$strbuf =~ s/{A_FORUM}/$auth_fnum{$key}/g;
$strbuf =~ s/{A_INDEX}/$auth_index{$key}/g;
$strbuf =~ s/{NUM}/$j/g;
$strbuf =~ s/{T_CLICKS}/$auth_tclicks{$key}/g;
$strAltAll .= $key.",".$auth_clicks{$key}.$/;
if ( $j <= $hot_gap )
{
$strbuf =~ s/{HOT_IMG}/$hot_imgrsc/g;
}
else
{
$strbuf =~ s/{HOT_IMG}//g;
}
$j++;
$l++;
$strAll .= $strbuf;
if ( $l > $per_page )
{
print " 換頁...$k ".$/;
$strAll[$k] = $strAll;
$l = 1;
$k++;
$strAll = "";
}
}
$strAll[$k] = $strAll;
print "========> ".$j.$/;
########################################## 寫進去
#if ( open( FILE, ">$file_artistHit" ) )
#{#
# print FILE ($strTpl1);
# close( FILE );
#}
print "========> ".scalar(@strAll).$/;
$strbuf = "";
$strtmp = "";
$i = 1;
foreach (@strAll)
{
$strbuf = $strTpl1;
$loct = localtime();
$strbuf =~ s/{RANK_LIST}/$_/;
$strbuf =~ s/{TOTAL_ROOMER}/$total_roomer/;
$strbuf =~ s/{UPDATE_TIME}/$loct/;
########################################## 寫進去
$strtmp = $file_artistHit;
$strtmp =~ s/{NUM}/$i/g;
$i++;
print "產生: $strtmp".$/;
if ( open( FILE, ">$strtmp" ) )
{
print FILE ($strbuf);
close( FILE );
}
}
#########################################
if ( open( FILE, ">$file_artistHit2" ) )
{
print FILE ($strAltAll);
close( FILE );
}
exit;
________________
美術插畫設計案子報價系統 v0.1 Beta
爪哇禾雀
|
|
Type
繪圖畫廊 設計藝廊 攝影相簿 留言板 最愛收藏 分類標籤
暱稱: Type 註冊: 2002-11-30 發表: 11173 來自: vovo2000.com
V幣: 901761
|
|
|
Re: Perl Code: 十幾年前的 Vovo2000.Com Perl Web Utilities 2014-06-22 18:26 |
/ / /
|
|
UI Template for the above Perl Codes
代碼:
<h2>新增美術&插畫作品,歡迎參觀~</h2>
<h2>新增美術&插畫作品,一定要看看~</h2>
<h2>新增美術&插畫作品,讚的唷,要看喔!</h2>
<h2>新增美術&插畫作品,不看可惜!</h2>
<h2>新增美術&插畫作品,點選進入觀賞~</h2>
代碼:
<html>
<head>
<title>過去的事::美術、插畫、美術數位內容/News Archives/Fine Art Illustration/Fine Art Content</title>
<meta http-equiv="content-type" content="text/html; charset=big5">
<meta name="keywords" content="News Archives,Fine Art Content,Fine Art Illustration,插畫,小說插畫">
<meta name="description" content="Vovo2000.Com: 包含竹吟個人之插畫、漫畫、同人誌;駐站畫家之美術、藝術作品;另有線上繪圖版 PaintBBS, 繪圖聊天室 PaintChat, 討論區 PHPBB, 投稿區">
<meta name="ROBOTS" CONTENT="ALL">
<base target="_self">
<link rel="stylesheet" href="/style.css" type="text/css">
<STYLE TYPE='text/css'>
<!-- TextRollover-1 -->
a:link { color:#000000; text-decoration:none}
a:visited { color:#000000; text-decoration:none}
a:hover { color:#000000; text-decoration:none; background:#33CCFF}
a:active { color:#000000; text-decoration:none}
</STYLE>
</head>
<body background="/image/backround-1.gif" text="#000000" link="#000000" vlink="#000000" alink="#000000">
<table border="0" cellspacing="2" cellpadding="1">
<tr>
<td nowrap>
<H3>[ <a href="news.php" target="_self">Latest News Archive 最新動向過去的事</a> ] </H3>
<H2>News-2004</H2>
{V2K_NEWS_THISYEAR_DAYBYDAY}
<hr>
<H2><a href="/news/2003.htm">Vovo2000.Com News Archive :: News-2003</a></H2>
<H2><a href="/news/2002.htm">Vovo2000.Com News Archive :: News-2002</a></H2>
<H2><a href="/news/2001.htm">Vovo2000.Com News Archive :: News-2001</a></H2>
</td>
</tr>
</table>
<div>
<div align="center"><font color="333333">©All Rights Reserved by
<a href="https://vovo2000.Com/" target="_blank" class="nounderline">Vovo2000.Com</a>
| <a href="https://vovo2000.com/friend/about.php" target="_self" class="nounderline">About
Vovo2000</a>
| Last Update {UPDATE_TIME}</font> </div>
</div>
</body>
</html>
代碼:
<td>
<div align=center>
<a href='http://artist.vovo2000.com/{AUTH}#new'
title="Artist:{AUTH} {RNAME}, 插畫,美術插畫,美術數位內容, Image of Fine Art Artwork/Illustration/Content"
target='_self' onclick="window.open( 'http://artist.vovo2000.com/{AUTH}#new', '_self' )">
<table width=85 height=100 border=1 background="{NEWS-IMG-SRC}" class="everydaynews">
<tr><td> </td></tr>
</table>
</a>
<font size=-1>駐站畫家「<a href='http://artist.vovo2000.com/{AUTH}#new' target='_self'>{RNAME}</a>」
</font>
</div>
</td>
代碼:
<h2><a href="https://vovo2000.com/gallery/{A_GALLERY}/{A_PIC}"
target="_blank">
<img src="/gallery/albums/{A_GALLERY}/{A_PIC_THUMB}" border="1" width="100">
</a>
...<strong>#{NUM}</strong> by <a href="https://vovo2000.com/friend/{A_INDEX}" target="_rankit"><font color=black size=+1>{A_REALNAME}</font></a>
<font size="-1"> [
點閱 {A_CLICKS} 次 /
<a href="http://artist.vovo2000.com/{A_GALLERY}" target="_rankit">Gallery</a>
/
<a href="https://vovo2000.com/f/forum-{A_FORUM}.html" target="_rankit">Forum</a>
/
<a href="https://vovo2000.com/friend/{A_INDEX}" target="_rankit">Profile</a>
]</font> {HOT_IMG}</h2>
代碼:
<div align="center">
<table width="80%" border="0" cellpadding="8">
<tr>
<td>
<div align="right">
<p><font size="+2" face="Verdana, Arial, Helvetica, sans-serif"> [Artwork
Hits Rank] 作品點閱統計</font><br>
<font size=-1>(投稿園地排除)</font>
<br>
<strong>畫廊取樣作品:取 <font color=red>{HOWMUCH}</font> / 共 <font color=red>{TOTAL_PICS}</font> 張</strong><br>
最後更新時間:
<!-- #BeginDate format:Am1 --> {UPDATE_TIME} <!-- #EndDate -->
<br />
本名次排行依據畫廊點閱次數逐日自動統計,工作坊並不以此數據做為任何其他用途<br />
<font size="-1">This rank stat is just A-Gallery-FYR. Vovo2000.Com does not and will not use it for alternative usage.</font>
</p>
</div>
</td>
</tr>
<tr>
<td bgcolor="#FFFFFF" class="but1"> <br>
{RANK_LIST}
</td>
</tr>
</table>
</div>
代碼:
<div align='left'>
{NEWS-DATE-TIME}
{WELCOME}
<table width='100%' border='0'>
{NEWS-IMG-ONLY}
</table>
<hr>
<div align="center"><font size="-1" face="Courier New, Courier, mono">
<a href="https://vovo2000.com/" style="color:#0000ff" target="_blank">(C)Vovo2000.Com</a></font>
</div>
</div>
代碼:
<tr><td>
<table width="100%">
<tr>
<td>
<a href="http://artist.vovo2000.com/{AUTH}" title="{AUTH}'s Art Gallery">
<img width="80" src="/gallery/albums/{AUTH}{HIGHLIGHT}">
</a>
</td>
<td>
<font size=-1>
<strong><a href="/gallery/{AUTH}">Artist: {RNAME}</a></strong><br>
<b></b>
<a href="http://artist.vovo2000.com/{AUTH}" alt="{AUTH}'s Art Gallery">個人畫廊</a><br />
<b></b>
<a href="/f/forum-{FNUM}.html" alt="{AUTH}'s Forum">個人論壇</a><br />
<b></b>
<a href="/friend/{FIDX}" alt="Intro to {AUTH}">畫家介紹</a><br />
</font>
</td>
</tr>
</table>
</td></tr>
</td></tr>
代碼:
<li><h2><font color="blue" size="+0" face="Verdana, Arial, Helvetica, sans-serif">
<a href="https://vovo2000.com/friend/{A_INDEX}" target="_blank" alt="Artist {A_REALNAME}">
<strong>{A_REALNAME}</strong></font> <font size=-2>(#{NUM}-畫家,插畫家,美術工作者)</font></a>
<br>
<font size="-2" face="Verdana, Arial, Helvetica, sans-serif"> [
美術、漫畫、插畫作品 {A_PCOUNT} 張 /
平均 {A_CLICKS} Hits /
總點閱 {T_CLICKS} Hits /
<font color=blue>
<a href="http://artist.vovo2000.com/{A_GALLERY}#new" target="_self" alt="個人畫廊 Personel Gallery">Gallery</a>
</font> /
<font color=blue>
<a href="https://vovo2000.com/f/forum-{A_FORUM}.html" target="_self" alt="個人討論區 Personel Forum">Forum</a>
</font> /
<font color=blue>
<a href="https://vovo2000.com/friend/{A_INDEX}" target="_self" alt="個人資訊 Personel Profile">Profile</a>
</font> ]</font> {HOT_IMG}</h2>
</li>
代碼:
<div align="center">
<table width="80%" border="0" cellpadding="8">
<tr>
<td>
<div align="right">
<p><font size="+2" face="Verdana, Arial, Helvetica, sans-serif"> [Artist
Hits Rank] 駐站畫家點閱統計</font><font size=-2>(投稿園地、社團排除)</font><br>
駐站畫家總數:共 {TOTAL_ROOMER} 位<br>
最後更新時間:
<!-- #BeginDate format:Am1 --> {UPDATE_TIME} <!-- #EndDate -->
<br />
本名次排行依據畫廊點閱次數逐日自動統計,工作坊並不以此數據做為任何其他用途<br />
<font size="-1">This rank stat is just A-Gallery-FYR. Vovo2000.Com does not and will not use it for alternative usage.</font>
</p>
</div>
</td>
</tr>
<tr>
<td bgcolor="#FFFFFF" class="but1"> <br>
{RANK_LIST}
</td>
</tr>
</table>
</div>
________________
美術插畫設計案子報價系統 v0.1 Beta
爪哇禾雀
|
|
Type
繪圖畫廊 設計藝廊 攝影相簿 留言板 最愛收藏 分類標籤
暱稱: Type 註冊: 2002-11-30 發表: 11173 來自: vovo2000.com
V幣: 901761
|
|
|
|
|