$value )
if( $value['eid'] == $eid )
return $value;
return null;
}
function RecommendedEntry_updateIndexFile( $eid_updated, $eid, $direction ) {
$filename = '/var/www/VirtualDomain/kenji00.com/blog/recommend_data';
is_dir( $filename ) || mkdir( $filename );
$filename .= '/'. substr( $eid_updated, -1 );
is_dir( $filename ) || mkdir( $filename );
$filename .= sprintf( '/%d.txt', $eid_updated);
file_exists( $filename ) || touch( $filename );
$fp = @fopen( $filename, 'r+' );
if( $fp ) {
if( flock( $fp, LOCK_EX | LOCK_NB )) {
$ret = '';
$not_found = 1;
while( !feof( $fp ) && ( $buf = fgets( $fp ))) {
list( $_eid, $_n0, $_n1 ) = split( "[\t\r\n]", $buf );
if( $eid == $_eid ) {
$not_found = 0; $direction ? $_n1++ : $_n0++;
}
$ret .= sprintf( "%d\t%d\t%d\n", $_eid, $_n0, $_n1 );
}
if( $not_found )
$ret .= sprintf( "%d\t%d\t%d\n", $eid, 1 - $direction, $direction);
rewind( $fp );
fwrite( $fp, $ret, strlen( $ret ));
}
fclose( $fp );
}
}
function RecommendedEntry_incoming() {
$eid_prev = $_COOKIE['mtrcmnd_eid'];
if( isset( $eid_prev )) {
if( $eid_prev != 155 && RecommendedEntry_getEntryData( $eid_prev )) {
RecommendedEntry_updateIndexFile( 155, $eid_prev, 0 /*incoming_from*/ );
RecommendedEntry_updateIndexFile( $eid_prev, 155, 1 /*outgoing_to*/ );
}
} else {
RecommendedEntry_updateIndexFile( 155, 155, 0 /*incoming_from*/ );
}
}
RecommendedEntry_incoming();
function RecommendedEntry_outgoing() {
setcookie( 'mtrcmnd_eid', 155, time() + 2592000, '/' );
}
RecommendedEntry_outgoing();
function RecommendedEntry_initialize( $mode = 0 ) {
global $RecommendedEntry_table;
$RecommendedEntry_table = array();
$filename = '/var/www/VirtualDomain/kenji00.com/blog/recommend_data/'. substr( '155', -1 ). '/155.txt';
$fp = @fopen( $filename, 'r' );
if( $fp ) {
if( flock( $fp, LOCK_SH | LOCK_NB )) {
while( !feof( $fp ) && ( $buf = fgets( $fp ))) {
list( $_eid, $_n0, $_n1 ) = split( "[\t\r\n]", $buf );
if( 155 == $_eid ) continue;
else if( $mode == 1 ) $RecommendedEntry_table{$_eid} = $_n0;
else if( $mode == 2 ) $RecommendedEntry_table{$_eid} = $_n1;
else $RecommendedEntry_table{$_eid} = $_n0 + $_n1;
}
arsort( $RecommendedEntry_table, SORT_NUMERIC );
}
fclose( $fp );
}
}
function RecommendedEntry_GetEntry( $_index ) {
global $RecommendedEntry_table;
foreach( $RecommendedEntry_table as $eid => $count ) {
if( --$_index ) continue;
$entry = RecommendedEntry_getEntryData( $eid );
if( $entry )
$entry['count'] = $count;
return $entry;
}
}
?>
[memo]XenのDomUで時刻合わせ ~未完~ - 寝不足にて候(仮)
Dom0からしか時刻を更新できないというXenの仕様で、ずっと嵌りっぱなし。
今日もタイムゾーンはCDTのまま。
パラメタの変更が必要らしいですが。
# echo 1 >/proc/sys/xen/independent_wallclock
or
vi /etc/sysctl.conf
xen.independent_wallclock = 1
してから
/usr/sbin/timeconfig
だの
cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
しても、
# date
Sat Aug 16 15:00:03 CDT 2008
何故でしょう。
関連ファイルのほうは、
# md5sum /etc/localtime /usr/share/zoneinfo/Asia/Tokyo
6540624294b1193e22ed7a15692f2de7 /etc/localtime
6540624294b1193e22ed7a15692f2de7 /usr/share/zoneinfo/Asia/Tokyo
# cat /etc/sysconfig/clock
# The ZONE parameter is only evaluated by system-config-date.
# The timezone of the system is defined by the contents of /etc/localtime.
ZONE="Asia/Tokyo"
UTC=false
ARC=false
こんな感じ。
ちなみに、hwclock コマンドがエラーを吐きますが、このせいでしょうか?
# /sbin/hwclock
Cannot access the Hardware Clock via any known method.
Use the --debug option to see the details of our search for an access method.
嵌り道。
トラックバックURL: http://blog.kenji00.com/MT/mt-tb.cgi/154
コメントする