作者:屈超(Chappell.Wat)
发布时间:July 19, 2007
分类:程式::五代,电动::四谷
[2007-7-19 更新]
很抱歉……
PSP 上这款高质量游戏的汉化进度直到今日才更新……
一直以来陆续有朋友询问我该游戏的进度……
我只能回答他们:“正在汉化中”……
翻译是主要的问题……
因为对于涵盖 DQ 和 FF 两大体系的一些专有知识的本游戏来说……
我可不想草草翻译了事……
有两点我可以保证:
1.汉化正在继续……
2.该游戏的汉化不会烂尾……
说完枯燥的东西……
应该送上一些精彩的了……
那就是来自美工—— Deapho 君的中文 Logo 小样……
我个人非常喜欢……
当场拍板说“富豪街的汉化美工就是你了”……
图,就不多解释了……
直接看图吧……
这是原图:

以下是中文 Logo 小样:


当然……
仅仅是小样……
瑕疵也有一些……
比如正中间那个很大的“ポ”……
(我正寻思着换点儿什么好呢?)
再比如 ALPHA Mask 也出了点儿问题……
这个以后解决吧……
最近一个多月得忙一个项目了……
更新放慢……
见谅……
目录:
[2007-4-7 更新]
说实话……
这次要不是 Kawayide 君带着字库找到我……
可能这个游戏就被我永久地放弃了……
所以很高兴地宣布这个游戏汉化重开……
届时字库将写为简体……
而且自 DH.45 之后便出现的汉化失效的问题(OE系统亦然)亦会解决……
目录:
[2007-6-1 更新]
再次埋怨一下这个游戏的字库:
太不厚道了……
少了很多日文汉字……
导致汉化时“捉衿见肘”……
完美汉化必须期待自写字库的实现……由于上次放出预览版后……
CNGBA 论坛上呼声一直很高……
所以我坚持将主菜部分几乎完全汉化了……
(其实地名和人名也汉化了……
但是由于上面所提及问题……
昨天没有公布……)
由于这几天苦找字库未果……
因此我转向研究同时拥有官方中文和日文双语的几个游戏……
比如三国志、比如移动剧场……
希望能从中看出点端倪……
(PSP 汉化游戏之所以少……
就是因为字库问题迟迟未得到解决……
如果我们能解决这个问题……
PSP 的汉化游戏会大幅增加……)
下面提供 《DQ&FF 富豪街》的 v0.1 汉化版:
CNGBA: http://www.cngba.com/thread-16062318-1-1.html
以上的汉化补丁和 Boot.bin 文件任选其一即可……
推荐使用 Boot.bin 文件进行替换……
成功率高……
下面是一些截图:



目录:
作者:屈超(Chappell.Wat)
发布时间:May 20, 2007
分类:程式::五代
[更新日志]
070520:Norman 君给出了 Dean Edwards 等关于 onDOMLoaded 事件的跨浏览器解决方案……
其实 onDOMLoaded 是 DOM 被载入(图片尚未载入)状态下的一个“不存在的”事件……
由于不同浏览器的支持度不同……
所以需要进行 Hack ……
所幸 Dean 和其他一些朋友反复研究后给出了解决方案……
在此表示感谢……
对于缩图函式本身的改进就是合并了上个版本的两个不同模式(快速和平缓)……
所谓快速模式是用了 while 循环……
速度快但是容易造成假死……
所谓平缓模式则用 setInterval 函式来解决上述问题……
可惜 setInterval 有最短周期限制……
所以速度比较慢……
从快速到平缓模式的切换临界值我设置为 500 ……
也即当一个页面的图片达到 500 时便启用平缓模式来缩图……
大伙儿可以根据自己需求更改……
具体请看 resizeImgs 函式的第二行……
070516:感谢 Norman 君在提升代码性能上的建议……
将遍历所有元素更改为遍历图像数组……
至于 Norman 所提议的在图像读取之前即进行缩图的功能……
未能实现……
一来是因为 Firefox 并不支持 onreadystatechange 事件(只有 onload ?)……
二来则在测试中发现 IE 下在 interactive 状态下调整图像大小也需要刷新以后才能执行……
也就是说都得等到页面加载完毕(或者加载一次)后才能进行操作……
恕鄙人才疏学浅……
如有解决方案望留言教授……
原理呢……
就是遍历图像数组……
如果定义了 resize 属性就进行缩图……
当 resize 的值为数字(而且小于原图宽度)就缩小到该数字宽度……
当 resize 为其它值则缩小到预设宽度……
至于为什么要清除 height 属性……
答曰:为了保持宽、高之比……
以上……
由于代码过长……
暂不贴出……
使用方法请参看 Demo ……
演示:http://Demo.QuChao.com/Resize/
下载:http://www.box.net/shared/semf3lqy2h
补充:
回应某朋友在 IM 上的疑惑……
JS 的缩图是和服务器端语言不同滴……
有锯齿(或者叫“失真”?)是正常滴……
而且把“能耗”转交给客户端是“不负责任”滴……
所以尽量不要在所谓的“杀猫帖”中使用……
因为 JS 去遍历这些图片元素需要时间……
而且“缩略”的动作直到所有图片读取完成才会生效……
完全就没有效果了嘛……
作者:屈超(Chappell.Wat)
发布时间:April 7, 2007
分类:程式::五代
[更新日志]
2007-4-7: 更新到 2.1.3
最近看了最新的 WordPress 2.0.4 ……
还是不支持 MySQL 4.1+ 的字符集特性……
当然……
这也不怪那群老外……
毕竟人家很少用到……
不过对于中文用户就显得很有必要了……
UTF8 当然是首选方案……
我也针对 UTF8 编码下的 PHP 编程写过一篇日志……
而这次对 WordPress 2.0.4 的修改也正是处于这个目的:
为了以正确的 UTF8 编码储存中文字符……
(当然修改过后…… 您也可以使用其它编码…… 这里仅以 UTF8 为例……)
不愿手动修改的朋友可以直接下载我做的 Hack 包……
直接覆盖原版文件即可……
(共修改 4 个文件……)
下载:
插件包:
http://www.live-share.com/files/196216/Charset_Hack_for_WP2.1.3.rar.html目录:
手动修改步骤如下:
1. 为配置文件添加数据库字符集项目:
WordPress 提供有一份 Sample 配置文件……
我们先为其增加字符集项目……
编辑 wp-config-sample.php 文件,
搜索:
define('DB_HOST', 'localhost'); // 99% chance you won't need to change this value
在下方添加:
// ** Charset Selection Hacked By Chappell.Wat (http://QuChao.com) ** //
define('DB_CHAR', 'utf8'); // When using MySQL 4.1+, you'd better set charset for your db
安装 WordPress 时……
程序会由安装向导生成新的配置文件……
为此我们得添加字符集项目的生成过程……
编辑 wp-admin/setup-config.php 文件,
搜索:
<li>Table prefix (if you want to run more than one WordPress in a single database)</li>
在下方添加:
<!-- Charset Selection Hacked By Chappell.Wat -->
<li>Database charset(When using MySQL 4.1+)</li>
继续搜索:
Table Prefix
<input name="prefix" id="prefix" value="wp_" size="25" type="text" /> If you want to run multiple WordPress installations in a single database, change this.
在下方添加:
<!-- Charset Selection Hacked By Chappell.Wat -->Database Charset
<input name="charset" id="charset" value="utf8" size="25" type="text" /> When using MySQL 4.1+ and you're using a charset other than latin1, you can set the charset here.
再搜索:
$dbhost = trim($_POST['dbhost']);
在下方添加:
// ** Charset Selection Hacked By Chappell.Wat ** //
$dbcharset = trim($_POST['charset']);
接着搜索:
define('DB_HOST', $dbhost);
在下方添加:
// ** Charset Selection Hacked By Chappell.Wat ** //
define('DB_CHAR', $dbcharset);
最后搜索:
case "define('DB_HOST'":
fwrite($handle, str_replace("localhost", $dbhost, $line));
break;
在下方添加:
// ** Charset Selection Hacked By Chappell.Wat ** //
case "define('DB_CHAR'":
fwrite($handle, str_replace("utf8", $dbcharset, $line));
break;
目录:
2. 为数据库类添加设置字符集的方法:由于字符集是 MySQL 4.1+ 的特性……
因此我们需要先判断 MySQL 的版本……
然后还需要检查需要的 CodePage 是否被编译进 MySQL ……
处理如下:
编辑 wp-includes/wp-db.php 文件,
搜索:
function wpdb($dbuser, $dbpassword, $dbname, $dbhost) {
return $this->__construct($dbuser, $dbpassword, $dbname, $dbhost);
}
function __construct($dbuser, $dbpassword, $dbname, $dbhost) {
替换为:
function wpdb($dbuser, $dbpassword, $dbname, $dbhost, $dbcharset) {
return $this->__construct($dbuser, $dbpassword, $dbname, $dbhost, $dbcharset);
}
function __construct($dbuser, $dbpassword, $dbname, $dbhost, $dbcharset) {
接下来添加设置字符集的方法:
同样是编辑 wp-includes/wp-db.php 文件,
搜索:
/**
* Escapes content for insertion into the database, for security
在上方添加:
/**
* Charset Selection Hacked By Chappell.Wat (http://QuChao.com)
* Detect the charset
*/
function charset($charset) {
// Check if version of Mysql is 4.1+
$version = mysql_get_server_info($this->dbh);
if($version >= '4.1') {
// Check that if the charset was compiled in
$existCharsets = mysql_query("SHOW CHARACTER SET like '" . $charset . "'", $this->dbh);
if(mysql_num_rows($existCharsets) >= 0) {
if(!mysql_query("SET NAMES '" . $charset . "'", $this->dbh)) {
$this->bail("
<h1>Error setting charset for the database!</h1>
\n"
."
Does your database is 4.1+?"
. "Have you compiled the charset into your mysql?
\n"
."
Refer to the <a href="http://www.quchao.com/">INSTALL</a> document "
."if in doubt
\n");
}
}
}
}
然后在选择数据库之后调用该方法:
仍然是编辑 wp-includes/wp-db.php 文件,
搜索:
$this->select($dbname);
在下方添加:
// ** Charset Selection Hacked By Chappell.Wat (http://QuChao.com) ** //
$this->charset($dbcharset);
目录:
3. 建表添加默认字符集参数:由于服务器环境差异……
并不是所有安装 MySQL 4.1+ 的服务器都以 UTF8 为默认字符集的……
(比如很多米国服务器就是 latin1 的默认字符集……)
而 WordPress 不管你甚么语系就直接往数据库里头灌……
等你发现中文字符变成问号时就只有重新安装了吧……
因此我们必须在建表时添加默认字符集参数来加以控制……
编辑 wp-admin/upgrade-functions.php 文件,
搜索:
$allqueries = array_merge($cqueries, $iqueries);
在上方添加:
// ** Charset Selection Hacked By Chappell.Wat ** //
// Check if version of Mysql is 4.1+
$version = mysql_get_server_info($wpdb->dbh);
if($version >= '4.1') {
// Check that if the charset was compiled in
$existCharsets = mysql_query("SHOW CHARACTER SET like '" . $charset . "'", $wpdb->dbh);
if(mysql_num_rows($existCharsets) >= 0) {
$cqueries = str_replace("\n)", "\n) DEFAULT CHARACTER SET " . DB_CHAR . ';', $cqueries);
}
}
至此……
我们就已经为 WordPress 的数据添加了字符集选项……
这样不管你运行在甚么配置的 MySQL 下都不用担心数据乱码了……
目录:
作者:屈超(Chappell.Wat)
发布时间:January 23, 2007
分类:程式::五代
1. vBulletin 官方中文版春节优惠……
从2007年1月23日00时开始,到2007年2月26日24时止,我们向广大中文用户提供如下价格优惠:
- vBulletin 永久使用许可证:原价人民币 1280 元,现价人民币 400 元。
- vBulletin 许可证更新:原价人民币 240 元,现价人民币 80 元。
2. vBulletin 中文许可协议更新及其它注意事项……
从2007年1月23日00时起,我们对许可协议做了如下修改:
- 增加条款:Jelsoft 对在 vBulletin-China.cn 购买的许可证仅提供中文支持
- 去除所有与按年租用许可证相关的条款,并停止按年租用许可证的销售
需要获得更详细的信息,请访问:
中文官方:http://www.vbulletin-china.cn
活动公告:http://forum.vbulletin-china.cn/showpost.php?p=1900
相关讨论:http://forum.vbulletin-china.cn/showthread.php?t=267
作者:屈超(Chappell.Wat)
发布时间:January 18, 2007
分类:程式::五代
[更新日志]
070118: 再次修正 ChinaRank.org.cn Rank…… 真麻烦啊……
061224: 修正 ChinaRank.org.cn Rank……
061220: 添加中搜 ChinaRank.org.cn 的 Rank 值获取及显示……
061125: 修正 Firefox 显示不正常的 CSS 问题……
Alexa 和
Google 的 Rank 值大伙儿都不会陌生……
前些日子又出来一个
Sogou PR ……
很多查询站点已经推出了它的查询服务……
之前我释出的文件只提供了 Alexa 和 Google 的查询……
恰逢有热心的朋友电邮到我希望我更新……
于是乎花了点时间写了一个类文件来处理以上三种 Rank 值的查询……
(2006-12-20 更新了所谓的
ChinaRank …… 所以是“四”种)
不多说了……
源码释出……
PS:推荐对 Rank 值进行缓存……
否则被谷歌封掉你的 IP 就哭去吧……
(有此惨痛经验的人飘过……)
本类中不含缓存过程……
有兴趣的同学可以看这里……
PS2:默认使用了 curl 系列函式来处理……
如未开启该扩展则进而使用 fopen 方法……
如 allow_url_fopen 未开启……
再进而使用 fsockopen 方式……
如果连它也未开启……
您就不要尝试了……
OTZ .......
PS3:传说 PS3 已经被炒到 RMB 9K ……
我还是玩我的 PSP 去吧……
在线演示:http://Demo.QuChao.com/Rank/
打包下载:http://www.live-share.com/files/196154/rank.rar.html
目录:
给出使用方法……
Usage:
注意:
域名不要带协议,
比如 http://www.quchao.com 请去掉 'http://'
当前仅支持 alexa 、 google 、 sogou 、 chinarank 四个类型名
其它值将被忽略
一下是调用的例子……
< ?php
// +-----------------------------------------------------------------------+
// | Name Rank Fetcher |
// | Version 1.4 |
// | Author Chappell Wat |
// | E-Mail Chappell.Wat@Gmail.com |
// | URL http://www.quchao.com/?p=64 |
// | Date 2007-1-18 |
// +-----------------------------------------------------------------------+
include './class_rank.php';
// set up your domain
$rank = new Rank('www.quchao.com');
// output the alexa rank
echo $rank->process('alexa');
// output the google page rank
echo $rank->process('google');
// output the sogou page rank
echo $rank->process('sogou');
// output the chinarank
echo $rank->process('chinarank');
?>
目录:
这里给出 class_rank.php 文件的代码
// +-----------------------------------------------------------------------+
// | Name Rank Fetcher |
// | Version 1.4 |
// | Author Chappell Wat |
// | E-Mail Chappell.Wat@Gmail.com |
// | URL http://www.quchao.com/?p=64 |
// | Date 2007-1-18 |
// +-----------------------------------------------------------------------+
/**
* Rank class
*/
class Rank
{
// {{{ properties
/**
* Domain to process.
* @var string
*/
var $_domain = 'www.quchao.com';
/**
* Error Message.
* @var string
*/
var $_error = null;
// {{{ constructor
/**
* Constructor.
* @param string Domain to process
* @return void
*/
function Rank($domain = 'www.quchao.com')
{
if(preg_match('/^(?:[^\W_](?:[^\W_]|-){0,61}[^\W_]\.)+[a-zA-Z]{2,6}\.?$/', $domain)) {
$this->_domain = $domain;
} else {
$this->_error = 'Invalid Domain!';
}
}
// }}}
// {{{ destructor
/**
* Destructor.
* @return void
*/
function __destruct()
{
}
// }}}
// {{{ process()
/**
* Fetch the alexa rank.
* @param string Type of rank (alexa, google, sogou)
* @return mixed Rank value
*/
function process($type = 'alexa')
{
if(in_array(strtolower($type), array('alexa', 'google', 'sogou', 'chinarank'))) {
return $this->$type();
} else {
$this->_error = 'Non-supported Rank Type!';
return 0;
}
}
// }}}
// {{{ alexa()
/**
* Fetch the alexa rank.
* @return mixed Rank value
*/
function alexa()
{
$result = $this->fetch('http://data.alexa.com/data/+wQ411en8000lA?cli=10&dat=snba&ver=7.0&cdt=alx_vw%3D20%26wid%3D12206%26act%3D00000000000%26ss%3D1680x16t%3D0%26ttl%3D35371%26vis%3D1%26rq%3D4&url=' . urlencode($this->_domain));
if(preg_match('/TEXT=\"(\d+)\"\/>/', $result, $match)) {
return $match[1];
} else {
$this->_error = 'Failed to fetch alexa rank!';
return 0;
}
}
// }}}
// {{{ google()
/**
* Fetch the google rank.
* @return mixed Rank value
*/
function google()
{
$result = $this->fetch('http://www.google.com/search?client=navclient-auto&ch=6' . $this->GCH($this->strord('info:' . $this->_domain)) . '&ie=UTF-8&oe=UTF-8&features=Rank&q=info:' . urlencode($this->_domain));
if (preg_match('/\d+:\d+:(\d+)/', $result, $match)) {
return $match[1];
} else {
$this->_error = 'Failed to fetch google rank!';
return 0;
}
}
// }}}
// {{{ sogou()
/**
* Fetch the sogou rank.
* @return mixed Rank value
*/
function sogou()
{
$result = $this->fetch('http://www.sogou.com/web?query=link%3A' . urlencode($this->_domain));
if(preg_match('/<\/span>(\d+)<\/dd>/', $result, $match)) {
return $match[1];
} else {
$this->_error = 'Failed to fetch sogou rank!';
return 0;
}
}
// }}}
// {{{ chinarank()
/**
* Fetch the ChinaRank rank.
* @return mixed Rank value
*/
function chinarank()
{
list($msec, $sec) = split(' ', microtime());
$r = $sec . substr($msec, 2, 3);
$result = $this->fetch('http://www.chinarank.org.cn/overview/Info.do?url=' . urlencode($this->_domain) . '&r=' . $r);
if(preg_match('/class=\"domain\">(\d+)<\/span>/', $result, $match)) {
return $match[1];
} else {
$this->_error = 'Failed to fetch chinarank!';
return 0;
}
}
// }}}
// {{{ fetch()
/**
* Fetch the remote content.
* @param string URL of the page
* @return string Content of the page
*/
function fetch($url)
{
$content = '';
if(function_exists('curl_init')) {
//Curl Method
$handle = curl_init();
if(!$handle) {
return false;
}
curl_setopt($handle, CURLOPT_URL, $url);
curl_setopt($handle, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($handle, CURLOPT_FOLLOWLOCATION, 0);
$content = curl_exec($handle);
curl_close($handle);
} elseif(ini_get('allow_url_fopen')) {
//File Method
$handle = @fopen($url, 'r');
if(!$handle) {
return false;
}
while($buffer = fgets($handle, 4096)) {
$content .= $buffer;
}
fclose($handle);
} elseif(function_exists('fsockopen')) {
//Socket Method
$pos = strpos($url, '://');
$host = substr($url, $pos + 3, strpos($url, '/', $pos + 3) - $pos - 3);
$uri = substr($url, strpos($url, '/', $pos + 3));
$request = "GET " . $uri . " HTTP/1.1\r\n"
. "Host: " . $host . "\r\n"
. "Accept: */*\r\n"
. "User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)\r\n"
. "\r\n";
$handle = @fsockopen($host, 80, $errno, $errstr, 30);
if(!$handle) {
return false;
}
@fputs($handle, $request);
while(!feof($handle)) {
$content .= fgets($handle, 4096);
}
fclose($handle);
$separator = strpos($content, "\r\n\r\n");
if($separator === false) {
return $content;
} else {
return substr($content, $separator + 4);
}
}
return $content;
}
// }}}
// {{{ strord()
function strord($string)
{
$strlen = strlen($string);
for($i = 0; $i < $strlen; $i++) {
$result[$i] = ord($string{$i});
}
return $result;
}
// }}}
// {{{ GCH()
function GCH($url, $length=null)
{
$length = sizeof($url);
$a = $b = 0x9E3779B9;
$c = 0xE6359A60;
$k = 0;
$len = $length;
while($len >= 12) {
$a += ($url[$k + 0] + ($url[$k + 1] << 8) + ($url[$k + 2] << 16) + ($url[$k + 3] << 24));
$b += ($url[$k + 4] + ($url[$k + 5] << 8) + ($url[$k + 6] << 16) + ($url[$k + 7] << 24));
$c += ($url[$k + 8] + ($url[$k + 9] << 8) + ($url[$k + 10] << 16) + ($url[$k + 11] << 24));
$mix = $this->mix($a, $b, $c);
$a = $mix[0];
$b = $mix[1];
$c = $mix[2];
$k += 12;
$len -= 12;
}
$c += $length;
//All the case statements fall through
switch($len) {
case 11: $c += ($url[$k + 10] << 24);
case 10: $c += ($url[$k + 9] << 16);
case 9 : $c += ($url[$k + 8] << 8);
//The first byte of c is reserved for the length
case 8 : $b += ($url[$k + 7] << 24);
case 7 : $b += ($url[$k + 6] << 16);
case 6 : $b += ($url[$k + 5] << 8);
case 5 : $b += ($url[$k + 4]);
case 4 : $a += ($url[$k + 3] << 24);
case 3 : $a += ($url[$k + 2] << 16);
case 2 : $a += ($url[$k + 1] << 8);
case 1 : $a += ($url[$k + 0]);
//Case 0: nothing left to add
}
$mix = $this->mix($a, $b, $c);
//Report the result
return $mix[2];
}
// }}}
// {{{ mix()
function mix($a, $b, $c){
$a -= $b;
$a -= $c;
$a ^= ($this->zeroFill($c, 13));
$b -= $c;
$b -= $a;
$b ^= ($a << 8);
$c -= $a;
$c -= $b;
$c ^= ($this->zeroFill($b, 13));
$a -= $b;
$a -= $c;
$a ^= ($this->zeroFill($c, 12));
$b -= $c;
$b -= $a;
$b ^= ($a << 16);
$c -= $a;
$c -= $b;
$c ^= ($this->zeroFill($b, 5));
$a -= $b;
$a -= $c;
$a ^= ($this->zeroFill($c, 3));
$b -= $c;
$b -= $a;
$b ^= ($a << 10);
$c -= $a;
$c -= $b;
$c ^= ($this->zeroFill($b, 15));
return array($a, $b, $c);
}
// }}}
// {{{ zeroFill()
function zeroFill($a, $b)
{
$z = hexdec(80000000);
if($z & $a) {
$a = ($a >> 1);
$a &= (~ $z);
$a |= 0x40000000;
$a = ($a >> ($b - 1));
} else{
$a = ($a>>$b);
}
return $a;
}
// }}}
}
?>
目录:
不记得以前在哪个论坛见过这种 XHTML + CSS 的 Page Rank Bar ……
(好像是
经典?可以通过 XHTML 的验证……)
这次在
CoolCode 那边再次看到使用……
于是存了下来……
现在贴出本部落格使用的样式表……
与传统不同的部分只是添加了一象素的 Padding ……
个人觉得这样处理会好看很多……
不说了……
给出代码……
.rank{margin-left:15px;margin-right:15px;margin-bottom:15px;}
.rank_container {width: 80px;text-align: center;font-size: 12px;}
.rank_border {border: 1px solid #999999;background-color: #FFFFFF;padding: 1px;margin: 0;text-align: left;display: block;}
.rank_bar {width: 80px;height: 6px;border: 0;padding: 0;margin: 0;font-size: 0;display: block;}
.rank_rate {width: 0px;height: 6px;padding: 0;margin: 0;border: 0;background-color: #F58EBD;display: block;}
#alexa_rank {background-color: #F58EBD;}
#google_rank {background-color: #FFBB3C;}
#sogou_rank {background-color: #A2BE1B;}
#chinarank_rank {background-color: #5392CE;}
.clearer{clear:both;}
还是超文本部分:
<p class="rank"> <span class="rank_container" id="alexa_container">Alexa Rank</span>
<span class="rank_bar">
<span class="rank_border">
<span class="rank_rate" id="alexa_rank"></span>
</span>
</span>
<p class="rank"> <span class="rank_container" id="google_container">Google Rank</span>
<span class="rank_bar">
<span class="rank_border">
<span class="rank_rate" id="google_rank"></span>
</span>
</span>
<p class="rank"> <span class="rank_container" id="sogou_container">Sogou Rank</span>
<span class="rank_bar">
<span class="rank_border">
<span class="rank_rate" id="sogou_rank"></span>
</span>
</span>
<p class="rank"> <span class="rank_container" id="chinarank_container">ChinaRank</span>
<span class="rank_bar">
<span class="rank_border">
<span class="rank_rate" id="chinarank_rank"></span>
</span>
</span>
其它的……
大伙儿自己去玩吧……
目录:
写写如何缓存获取到的 Rank 值
我直接用文本方式来储存两个排名值……
然后用 filemtime() 函式来判断更新时间……
最简单的缓存而已嘛……
UNIX 服务器用户甚至可以用 Cron 直接缓存排名值到 JS 文件……
等于每次调用的就只是调用静态文件而已……
而省去了对于更新时间的判断……
岂不更屌?
我的代码:
< ?php
// +-----------------------------------------------------------------------+
// | Name Rank Fetcher |
// | Version 1.4 |
// | Author Chappell Wat |
// | E-Mail Chappell.Wat@Gmail.com |
// | URL http://www.quchao.com/?p=64 |
// | Date 2007-1-18 |
// +-----------------------------------------------------------------------+
if(! function_exists("file_put_contents")) {
function file_put_contents($filename, $text) {
$fp = fopen($filename,"w");
fwrite($fp, $text);
fclose($fp);
}
}
// updated every 24 hours, or use 'force_update = true' to update it manually
if (@filemtime('rank.cache') < time() - 86400 || $_GET['force_update']) {
// write rank cache
include './class_rank.php';
$rank = new Rank('www.quchao.com');
$ranks = array(
$rank->process('alexa'),
$rank->process('google'),
$rank->process('sogou'),
$rank->process('chinarank'),
);
@file_put_contents('rank.cache', implode("\n", $ranks));
} else {
// get rank cache
$ranks = @file('rank.cache');
}
?>
收工……
吃饭……
目录:
- «
- 1
- ...
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- ...
- 11
- »