| 前往頁面 ←上一頁 1 ... 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 ... 560 下一頁→
|
讚阿!
一定很至少有有兩次 C.C.F Special 吧!?(2014-07-02 11:26) |
|
GOAL: Convert old gallery v1 (or even v2) .dat serialized data to SQL data
Gallery v1.0: About 2001 ~ 2002, which used PHP serialized data as DB
Gallery v1.x: About 2002 ~ 2004, which I still used PHP serialized data as Database
These codes are to parse & convert legacy Gallery V1 DB *.dat file into SQL
in order to build them as static HTML pages (or Dynamic Pages Integration, yet in fact static archive).
Of course, only some of fields were retrieved/parse.
Note: Main stream Gallery v2/v3+ has integrated with MySQL, no such issues any more!
Q: What fields were reterieved from Gallery v1/v1.x album.dat?
A:
gallery_type => For my internal usage. (e.g. I got many different Gallery v1/1.x ... repositories)
albumname => Gallery v1 album folder name
imgitem => Album Caption or Album Title
imgtype => I set it as "RDIR" for root album, 'DIR' for sub-album
caption => Detail Description of this album(sub-album)
datetime => Creation date of this album
comment => Only useful for 'ROOT Album", contains all sub-album in CSV format. Empty if this is a sub-album
Q: What fields were reterieved from Gallery v1/v1.x photos.dat?
A:
gallery_type => For my internal usage. (e.g. I got many seperated/different Gallery v1/1.x ... repositories)
albumname => Gallery v1 album folder name
imgitem => Image Name
imgtype => Image Type (jpg/png/gif/...)
caption => Detail Description of this IMAGE (Image title)
datetime => Creation date of this album (== uploadDate)
comment => The comment of this Image, only include "username/datetime/comment", use some big5-utf8 translate.
Q: It looks like that you combined "photos.dat & album.dat" into single Database Table?
A: Yes, because my requirement is very simple,
make gallery v1 photo repositories into static pages.
(though the "static pages" are in fact dynamic generated from PHP + DB)
Q: Didn't see your code parsing sub-album(DIR) CSV into root album comment field?
A: To make the conversion faster, and, my root album are not that many,
so I did that __manually__.
Q: Why not using Gallery Project's Import Tool? Do you ever use official tools to import v1.0 into v2.x
A: True, I ever tried it years ago around 2007 ~ 2011;
yet, futile; the Gallery v1.x album.dat & photos.dat looked too legacy to be imported.
Q: I got lots of SPAM messages in my Gallery v1 photos.dat, what I can do?
A: I have the same issue,
but since you cloud make them into database,
SPAM-comment removal will be much easier by using something like
代碼:
SELECT * from gallery_database_table where comment
like '%some bad words%' or comment like '%another bad words%'
compared digging into thousands of photos.dat
Convert USAGE Example:
代碼:
$ find /var/www/gallery-v1/ -name "album.dat" | xargs parse_album_dat_to_database_sql.php
[h1]parse_album_dat_to_database_sql.php[/h1]
代碼:
<?PHP
/*
Goal: Convert Gallery v1 album.dat format into DataBase SQL
*/
/* data */
$title = array();
$desc = array();
$dtime = array();
function is_line_still_value($line_str)
{
if (strstr($line_str, "' => "))
return false;
else
return true;
}
function get_val($str, $is_str = true, $multiple_lines = false)
{
if ($multiple_lines == false)
list($a, $b) = explode("' => ", str_replace("\r", "", $str));
else
$b = str_replace("\r", "", $str);
if ($is_str)
{
/* 字串要去掉頭尾 quote */
if (substr($b, 0, 1) == "'" && $multiple_lines == false)
{
$b = substr($b, 1, strlen($b) - 1);
}
$b = str_replace("',\n", '', $b);
}
else
{
$b = intval(str_replace(',', '', $b));
}
return $b;
}
function get_photosdat_pass_1($str, $idx)
{
global $title, $desc;
$done_1 = 0;
$done_2 = 0;
foreach(preg_split("/((\r?\n)|(\r\n?))/", $str) as $line)
{
$line .= "\n";
if ($done_1 == 0 && strstr($line, "'title' => "))
{
$title[$idx] = get_val($line);
$done_1++;
}
if ($done_2 == 0 && strstr($line, "'description' => "))
{
$desc[$idx] = get_val($line);
$done_2++;
}
if ($done_2 == 0 && strstr($line, "'description' => "))
{
$desc[$idx] = get_val($line);
$done_2++;
}
if ($done_1 && $done_2)
break;
}
/*
* Optional
*/
$title[$idx] = mb_convert_encoding($title[$idx], 'UTF-8', 'BIG-5');
$desc[$idx] = mb_convert_encoding($desc[$idx], 'UTF-8', 'BIG-5');
if (trim($desc[$idx]) == 'No description')
{
$desc[$idx] = '';
}
}
/*
* BEGIN
*/
if (isset($argv[1]) && file_exists($argv[1]))
{
echo "CHECK albums.dat Integrity and Parse it, file count=".count($argv)." ...\n";
for ($i=1; $i<(count($argv)); $i++)
{
$str = file_get_contents($argv[$i]);
$var = unserialize($str);
// echo "[$i] Checking ".$argv[$i]."\n";
if ($var === false || strlen($str) <= 3) {
echo "_____ERROR_____ @ ". $argv[$i] . "\n";
echo "ABORT: Please Fix this first! You could restore it from backup album.dat.[1~N]\n";
exit;
}
//echo "[$i] Parsing ".$argv[$i]."\n";
$str = var_export($var, true);
get_photosdat_pass_1($str, $i);
// echo $argv[$i].' => '.$title[$i].'_'.$desc[$i]."__EOF\n";
list($a, $folder, $c) = explode('/', $argv[$i]);
echo "Insert into gallery_database_table (gallery_type, albumname, imgitem, imgtype, caption, datetime, comment)
values(0, '".$folder."', '".$title[$i]."', 'DIR', '".$desc[$i]."', 0, '');\n";
// "Insert into gallery_database_table (gallery_type, albumname, imgtype, imgitem, caption)
// values(1, '$argv[$i]', '$title[$i]', 'DIR', '0', '$desc[$i]')"
}
}
else
{
echo 'find /gallery-folder/ -name "album.dat" | xargs php parse_album_dat.php';
}
exit;
[h1]parse_photos_dat_to_database_sql.php[/h1]
代碼:
<?PHP
/*
Goal: Convert Gallery v1 photos.dat format into DataBase SQL
*/
/*
找法:
1. 先 parse var export 一行一行找,找到關鍵字
2. 如果下一行,沒有 '=>' '[' ']' 那麼下一行還是資料
資料欄位
auto-idx, folder, imgname, imgtype, caption, date, comment(serialized)
*/
/* data */
$imgname = array();
$imgtype = array();
$caption = array();
$dateint = array(); /* int */
$comment = array(); /* three diementional array */
function is_line_still_value($line_str)
{
if (strstr($line_str, "' => "))
return false;
else
return true;
}
function get_val($str, $is_str = true, $multiple_lines = false)
{
// 'name' => 'waidai_05',
// 'type' => 'jpg',
//
// 'uploadDate' => 123124312,
if ($multiple_lines == false)
list($a, $b) = explode("' => ", str_replace("\r", "", $str));
else
$b = str_replace("\r", "", $str);
if ($is_str)
{
/* 字串要去掉頭尾 quote */
if (substr($b, 0, 1) == "'" && $multiple_lines == false)
{
$b = substr($b, 1, strlen($b) - 1);
}
$b = str_replace("',\n", '', $b);
}
else
{
$b = intval(str_replace(',', '', $b));
}
return $b;
}
/*
Pass #1 從零開始找
*/
function get_photosdat_pass_1($str, $idx)
{
global $imgname, $imgtype, $caption, $dateint;
$done_1 = 0;
$done_2 = 0;
$done_3 = 0;
$done_4 = 0;
foreach(preg_split("/((\r?\n)|(\r\n?))/", $str) as $line)
{
$line .= "\n";
if ($done_1 == 0 && strstr($line, "'name' => "))
{
$imgname[$idx] = get_val($line);
$done_1++;
}
if ($done_2 == 0 && strstr($line, "'type' => "))
{
$imgtype[$idx] = get_val($line);
$done_2++;
}
if (($done_3 < 31 && $done_3 > 0) || strstr($line, "'caption' => "))
{
if ($done_3 == 0)
$caption[$idx] = get_val($line);
else
{
if (is_line_still_value($line) == true)
$caption[$idx] .= get_val($line, true, true);
else
$done_3 = 31;
}
$done_3++;
}
if ($done_4 == 0 && strstr($line, "'uploadDate' => "))
{
$dateint[$idx] = get_val($line, false);
$done_4++;
}
if ($done_1 && $done_2 && $done_3 >= 31 && $done_4)
break;
}
/*
* Optional
*/
$imgname[$idx] = mb_convert_encoding($imgname[$idx], 'UTF-8', 'BIG-5');
$caption[$idx] = mb_convert_encoding($caption[$idx], 'UTF-8', 'BIG-5');
}
/*
Pass #2 從 ["comments"]=> 往後找下列三個
["commentText"]=>
["datePosted"]=>
["name"]=>
*/
function get_photosdat_pass_2($str, $idx)
{
global $comment;
$done_1 = 0;
$done_2 = 0;
$done_3 = 0;
$done_4 = 0;
$comment_count = 0;
$comment[$idx] = array();
$comment[$idx][$comment_count] = array(3);
list($tmp, $str) = explode("'comments' => ", $str);
foreach(preg_split("/((\r?\n)|(\r\n?))/", $str) as $line)
{
$line .= "\n";
if ($done_1 == 0 && strstr($line, "'name' => "))
{
$comment[$idx][$comment_count][0] = get_val($line);
$done_1++;
}
if ($done_2 == 0 && strstr($line, "'datePosted' => "))
{
$comment[$idx][$comment_count][1] = get_val($line, false);
$done_2++;
}
if (($done_3 < 31 && $done_3 > 0) || strstr($line, "'commentText' => "))
{
if ($done_3 == 0)
$comment[$idx][$comment_count][2] = get_val($line);
else
{
if (is_line_still_value($line) == true)
$comment[$idx][$comment_count][2] .= get_val($line, true, true);
else
$done_3 = 31;
}
$done_3++;
}
if ($done_3 >= 31 && $done_1 && $done_2)
{
$done_1 = 0;
$done_2 = 0;
$done_3 = 0;
/*
* Clean Gallery's SPAM comments
*/
if ( (stristr($comment[$idx][$comment_count][2], "url="))
|| (stristr($comment[$idx][$comment_count][2], "url:"))
|| (substr_count($comment[$idx][$comment_count][2], 'http') >= 2)
|| (strlen(trim($comment[$idx][$comment_count][2])) <= 2)
|| ($comment[$idx][$comment_count][2] == $comment[$idx][$comment_count][0])
|| (mb_detect_encoding($comment[$idx][$comment_count][0]) == 'ASCII'
&& mb_detect_encoding($comment[$idx][$comment_count][2]) == 'ASCII')
)
{
$comment[$idx][$comment_count] = null;
continue;
}
/*
* Optional: convert BIG-5 --> UTF-8
*/
$comment[$idx][$comment_count][0] = mb_convert_encoding($comment[$idx][$comment_count][0], 'UTF-8', 'BIG-5');
$comment[$idx][$comment_count][2] = mb_convert_encoding($comment[$idx][$comment_count][2], 'UTF-8', 'BIG-5');
$comment_count++;
$comment[$idx][$comment_count] = array(3);
}
}
}
/*
* BEGIN
*/
if (isset($argv[1]) && file_exists($argv[1]))
{
echo "CHECK Photos.dat Integrity and Parse it, file count=".count($argv)." ...\n";
for ($i=1; $i<(count($argv)); $i++)
{
$str = file_get_contents($argv[$i]);
$var = unserialize($str);
// echo "[$i] Checking ".$argv[$i]."\n";
if ($var === false || strlen($str) <= 3) {
echo "_____ERROR_____ @ ". $argv[$i] . "\n";
echo "ABORT: Please Fix this first! You could restore it from backup photos.dat.[1~N]\n";
exit;
}
// echo "[$i] Parsing ".$argv[$i]."\n";
for ($j=0; $j<count($var); $j++)
{
$str = var_export($var[$j], true);
get_photosdat_pass_1($str, $j);
get_photosdat_pass_2($str, $j);
/*
var_dump($imgname[$j]);
var_dump($imgtype[$j]);
var_dump($caption[$j]);
var_dump($dateint[$j]);
var_dump($comment[$j]);
*/
$comment[$j] = serialize($comment[$j]);
list($a, $folder, $c) = explode('/', $argv[$i]);
echo "Insert into gallery_database_table (gallery_type, albumname, imgitem, imgtype, caption, datetime, comment)
values(0, '".$folder."', '".$imgname[$j]."', '".$imgtype[$j]."', '".$caption[$j]."', ".$dateint[$j].",
'".$comment[$j]."');\n";
}
}
}
else
{
echo 'find /gallery-folder/ -name "photos.dat" | xargs php parse_photos_dat.php';
}
exit;
(2014-06-30 00:25) |
|
[h1]PHP + ImageMagick Codes: PNG2JPG, JPG Quality, Shrink JPG Quality[/h1]
PHP Read All files in this directory and the proceed the following Image processing
1. convert_PNG_to_JPG($source): Convert PNG image files to JPG image files within this directory
2. convert_jpg_to_quality_90($source): Convert JPG quality to 90 within same folder
3. shrink_to_goolge_800($source): Shrink all images files in this folder to max 800 width or 800 height
代碼:
<?PHP
function convert_PNG_to_JPG($source)
{
// $source = "1.jpg";
$convert = "D:\ImageMagick-6.6.3-Q16\convert.exe"; // define in constant.php
/* 一律 90 品質 */
if (filesize($source) > 524288)
{
$dest = str_replace('.png', '.jpg', $source);
echo "Q90 $dest \n";
exec($convert.' '.$source.' -strip -quality 90 '.$dest);
}
else
{
echo ".";
}
}
function convert_jpg_to_quality_90($source)
{
// $source = "1.jpg";
$convert = "D:\ImageMagick-6.6.3-Q16\convert.exe"; // define in constant.php
/* 一律 90 品質 */
if (filesize($source) > 524288)
{
echo "Q90 $source \n";
exec($convert.' '.$source.' -strip -quality 90 '.$source);
}
else
{
echo ".";
}
}
function shrink_to_goolge_800($source)
{
// $source = "1.jpg";
$mid = 800;
$convert = "D:\ImageMagick-6.6.3-Q16\convert.exe"; // define in constant.php
$size = getimagesize($source);
if ($size[0] > 800 || $size[1] > 800)
{
echo $source."\n";
usleep(10);
if ($size[0] > $size[1])
{
$toWWW = ( $size[0] >= $mid ? $mid : $size[0] );
//echo $convert.' '.$source.' -strip -resize '.$toWWW.'x '.$source;
exec($convert.' '.$source.' -resize '.$toWWW.'x '.$source);
}
else
{
$toHHH = ( $size[1] >= $mid ? $mid : $size[1] );
// echo $convert.' '.$source.' -strip -resize x'.$toHHH.' '.$source;
exec($convert.' '.$source.' -resize x'.$toHHH.' '.$source);
}
}
else
{
echo "-";
}
}
function prepare_readidr($pid)
{
/* 準備清單 */
$file_list = array();
if ($handle = opendir("."))
{
while (false !== ($filedir = readdir($handle)))
{
/* 確定目錄 */
if (is_dir($filedir))
{
/* 再從目錄讀出檔案 */
if ($handle2 = opendir($filedir))
while (false !== ($files = readdir($handle2)))
{
/* 不能是目錄 */
if (!is_dir($files))
{
$z = $filedir.'\\'.$files;
//if (filemtime($z) > (time() - 100))
// echo '.';
//else
shrink_to_goolge_800($z);
// convert_jpg_to_quality_90($z)
// convert_PNG_to_JPG($z)
}
}
}
}
}
}
/* main */
prepare_readidr();
?>
(2014-06-29 16:15) |
|
[h1]Fedora 17: Fedorax2017x20x86_64 does not exist - Install Failed[/h1]
[h2]症狀 Symptoms[/h2]
代碼:
ERROR: could not insert 'floppy': No such device
Loading Fedora 17 x86_64 installer...
dracut Warning: Unable to process initqueue
dracut Warning: /dev/disk/by-label/Fedorax2017x20x86_64 does not exist
dracut Warning: /dev/mapper/live-rw does not exist
Dropping to debug shell.
dracut:/#
[h2]解決方式[/h2]
1. 燒錄 FC17 DVD 時,請將 DVD Label 設定為 "FC17" ,也就是「不要有空格!」 "Label No Space (x20)"
(這有可能是 BIOS bug 的問題,也有可能是 Fedora Dracut 本身的 bug )
2. 然後在 Boot Disk Menu 畫面按下 "Tab",把 LABEL 從 "Fedora\x2017\x20x86_64" 改成 "FC17"
*NOTE*: 如果你用 USB 當成 ISO-DVD Boot Disk,那更簡單,使用 mtools/mlabel 改 USB Label,參考下面
代碼:
$ yum install mtools (or, apt-get install mtools)
$ sudo echo "mtools_skip_check=1" > ~/.mtoolsrc
$ sudo mlabel -i /dev/sdX1 ::FC17 (the '::' prefix is a must!)
(2014-06-29 16:02) |
|
[h1]嗶...戰鬥力只有5?雜碎![/h1](2014-06-25 00:37) |
|
[h1]X Window System 歡慶 30 週年 (June 2014)[/h1]
廣泛使用於 Linux, *BSD, SunOS, Iris, Solaris, Unix, 甚至是 Microsoft Windows 的「視窗主從架構系統」 "X"
或稱為 X-Windows, X Window System
在這個月 19 日 (2014/06/19) 正式歡慶 30 週年。
30 年前的這個時候 (1984/06/19),MIT 的 Bob Scheifler 宣布了 X Window System 的誕生。
X 視窗系統可說是最早期 Open Software / Free Software 的先驅者,
甚至比 Linux / BSD / Solaris / GPL / FSF / Apache / POSIX / C89 / C99 這些系統、標準、組織等,都來得早!
至今,經過三十年的演化,基於 X 視窗系統衍生出了 GNOME, KDE, XFCE, Unity, Enlightment 這麼多種的桌面環境,
廣泛的服務著數百萬以上的 Desktop GUI 桌面環境使用者。
(然而,這麼多 Desktop env 不知是好是壞...)
目前最新的 X Window System 版本為: X11 Release 7.7, 下個版本是 R7.8, 使用的是 MIT License
目前是由 X.org 基金會維護:
Xorg官網 => http://x.org/
Google+ => https://plus.google.com/102057777074369211973
(2014-06-23 15:56) |
|
Dear Kelly
麻煩請補一下薪資範圍!
Thank you
(2014-06-22 20:34) |
|
[h1]UI Template for the above Perl Codes[/h1]
代碼:
<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="http://vovo2000.Com/" target="_blank" class="nounderline">Vovo2000.Com</a>
| <a href="http://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="http://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="http://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="http://vovo2000.com/phpbb2/forum-{A_FORUM}.html" target="_rankit">Forum</a>
/
<a href="http://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="http://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="/phpbb2/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="http://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="http://vovo2000.com/phpbb2/forum-{A_FORUM}.html" target="_self" alt="個人討論區 Personel Forum">Forum</a>
</font> /
<font color=blue>
<a href="http://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>
(2014-06-22 18:26) |
|
[h1]stat_Gallery_Top10.pl[/h1]
應該是取出 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;
(2014-06-22 18:24) |
|
[h1]Perl Code: Perl Web Utilities decades ago (3) [/h1]
看不太懂這段的目的了...應該是當時駐站畫家的處理;
總之一樣和土法煉鋼 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 = "http://vovo2000.com/vovo-gallery/data/VovoCG";
$gala_ha2 = "http://vovo2000.com/vovo-gallery/VovoCG";
}
elsif ( $auth[$i] eq "VovoSFX" )
{
$gala_ha = "http://vovo2000.com/vovo-gallery/data/sfx";
$gala_ha2 = "http://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;
}
(2014-06-22 18:21) |
|
[h1]Perl Code: 十幾年前的 Vovo2000.Com Perl Web Utilities (2)[/h1]
[h2]stat_Gallery_HotPic[/h2]
這是 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;
(2014-06-22 18:17) |
|
[h1]Perl 維護 Web 程式碼: Vovo2000.Com Perl Web Utilities (1) [/h1]
這些 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 已經十幾年...目前完全沒使用了,若要拿去參考請小心。
[h2]Windows Server 備份 Apache Backup[/h2]
代碼:
#!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 );
}
[h2]Windows deltempfile.bat[/h2]
因為 Session File 會存在 Temp,定時清一下
代碼:
del /f /q c:\winnt\temp\*.*
[h2]Windows deltempfile.bat[/h2]
Goal: 因為 PHP/Apache2 Session File 會存在 Temp,定時清一下
代碼:
del /f /q c:\winnt\temp\*.*
[h2]Replace String in Files Perl Code[/h2]
這段 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 "=>不改".$/;
}
}
}
}
[h2]DailyArist.pl Perl Code[/h2]
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;
[h2]Apache Log Rotate and Restart Perl Code[/h2]
這段 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" );
(2014-06-22 18:10) |
| |
[h1]升級: Ubuntu 12.04 Upgrade 14.04 設定注意事項[/h1]
Ubuntu 12.04 LTS: Apache 2 Httpd 2.2.X with PHP 5.3
Ubuntu 14.04 LTS: Apache 2 Httpd 2.4.X with PHP 5.5
Ubuntu 14.04 LTS default package
(1) Apache2 Httpd: 由 2.2.X 升級為 2.4.X
(2) PHP5: 由 PHP 5.3 升級為 PHP5.5 (但,沒有守護神)
所以當你從 Ubuntu 12.04 LTS --> 升級 --> 14.04 LTS,
你馬上就面臨 Apache2 HTTPD 的大改版
請先看這幾份文件
參考文件
=> https://library.linode.com/web-servers/apache/2.2-2.4-upgrade
=> http://httpd.apache.org/docs/2.4/upgrading.html
=> http://tw.php.net/migration54
=> http://tw.php.net/migration55
幾個重點要注意! Main effort 在 Apache 2.2 -> 2.4 因為改的不算少
1. 先備份 /etc/apache2/* + /etc/php5/* BACKUP FIRST!
2. Apache 2.2 有些本來在 apache2.conf ,Apache 2.4 移到了 conf-available
3. Apache 2.4 sites-available/* 要多加 .conf 附檔名
4. Apache 2.4 Rewrite Rules 有點小修改,如果你的寫法比較老式,要多注意!
5. Apache 2.2 的 Allow/Disallow,在 Apache 2.4 寫法改成 Require ... Granted
6. PHP 5.3 --> 5.5 如果你 Code 寫法偏向保守,沒有用太多功能,則可無痛升級,注意一下 php.ini 即可。
(2014-06-21 21:45) |
|
[h1]讓 /bin/dd 有進度 (dd with progress Ubuntu/Fedora)[/h1]
有兩種方式達成:
[h2]1. 配合 "pv" 或 "pv -s SIZE" 使用[/h2]
代碼:
$ apt-get install pv (or, yum install pv)
$ dd if=/dev/zero bs=4096 | pv -s 2G | of=/tmp/file
(這裡的 -s 2G 取代 count=524288)
[h2]2. 或者直接安裝 "dcfldd" 配合 "time"[/h2]
代碼:
$ apt-get install dcfldd (or, yum install dcfldd)
$ man dcfldd
$ dcfldd if=/dev/zero bs=4096 of=/tmp/file count=524288 statusinterval=1
$ time dcfldd if=/dev/zero bs=4096 of=/tmp/file count=524288 statusinterval=1
(2014-06-21 21:29) |
|
[h1]手機版 Android/iOS 遊戲畫面[/h1]
手機版玩起來...
(1) 畫面比 PC 精緻(e.g. 場景景深)
(2) 處理碰撞比較寬鬆(也就是比較「不容易死 + 容易觸發加速」)
(3) 但,還是用玩 PC + 滑鼠玩比較有樂趣,容易得到高分。
(2014-06-21 21:28) |
|
[h1]2014 June Record[/h1]
Without any C.F.F. Special(2014-06-21 21:04) |
|
[h1]2014 June Record[/h1]
Without any Nanaca C.F.F. Special(2014-06-21 21:04) |
|
[h1]Linux Task Manager / IO Monitor / Network Monitor: "top, htop, iotop, jnettop"[/h1]
Common-Seen Task Manager: "top"
Interactive TaskManager: "htop"
I/O Monitor / Disk Monitor: "iotop"
Network Traffic Monitor: "jnettop"
[h2]1. Install tools at Fedora 20 / Ubuntu 14.04[/h2]
代碼:
$ ################################ Ubuntu 14.04
$ sudo apt-get install top
$ sudo apt-get install iotop
$ sudo apt-get install jnettop
$ sudo apt-get install htop
Or
$ ################################ Fedora 20
$
$ sudo yum install iotop
$ sudo yum install jnettop
$ sudo yum install top
$ sudo yum install htop
[h2]2. Just run them (iotop & jnettop require root permission)[/h2]
代碼:
$ htop
$ top
$ sudo jnettop
$ sudo iotop
(2014-06-20 15:05) |
|
[h1]日本語「乙」「xxx乙」是什麼意思(おつれさま)[/h1]
おつれさま = お疲れ様 = 辛苦了 = おつ (簡)
不管是微軟輸入法,或者 Google 輸入法,
只打「おつ」第一個選項就是「乙」
久而久之,偷懶的網友,對於辛苦奉獻的稱讚,
就變成打「某某某乙」或者「1F 乙」
(2014-06-20 00:02) |
| 前往頁面 ←上一頁 1 ... 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 ... 560 下一頁→
|
|