以下是代码:
//count.php
$recdir="rec/"; //计数文件目录
$rfile=".txt"; //计数文件扩展名
if ($len=="") $int_width=6;
else $int_width=$len; //位数
$count_width=8; //单个数字宽度
$count_height=16; //高度
$bitmap =array(
"0xff", "0xff", "0xff", "0xc3", "0x99", "0x99", "0x99", "0x99", /* rows 1-8 of 0 */
"0x99", "0x99", "0x99", "0x99", "0xc3", "0xff", "0xff", "0xff", /* rows 9-16 of 0 */
"0xff", "0xff", "0xff", "0xcf", "0xc7", "0xcf", "0xcf", "0xcf", /* rows 1-8 of 1 */
"0xcf", "0xcf", "0xcf", "0xcf", "0xcf", "0xff", "0xff", "0xff", /* rows 9-16 of 1 */
"0xff", "0xff", "0xff", "0xc3", "0x99", "0x9f", "0x9f", "0xcf", /* rows 1-8 of 2 */
"0xe7", "0xf3", "0xf9", "0xf9", "0x81", "0xff", "0xff", "0xff", /* rows 9-16 of 2 */
"0xff", "0xff", "0xff", "0xc3", "0x99", "0x9f", "0x9f", "0xc7", /* rows 1-8 of 3 */
"0x9f", "0x9f", "0x9f", "0x99", "0xc3", "0xff", "0xff", "0xff", /* rows 9-16 of 3 */
"0xff", "0xff", "0xff", "0xcf", "0xcf", "0xc7", "0xc7", "0xcb", /* rows 1-8 of 4 */
"0xcb", "0xcd", "0x81", "0xcf", "0x87", "0xff", "0xff", "0xff", /* rows 9-16 of 4 */
"0xff", "0xff", "0xff", "0x81", "0xf9", "0xf9", "0xf9", "0xc1", /* rows 1-8 of 5 */
"0x9f", "0x9f", "0x9f", "0x99", "0xc3", "0xff", "0xff", "0xff", /* rows 9-16 of 5 */
"0xff", "0xff", "0xff", "0xc7", "0xf3", "0xf9", "0xf9", "0xc1", /* rows 1-8 of 6 */
"0x99", "0x99", "0x99", "0x99", "0xc3", "0xff", "0xff", "0xff", /* rows 9-16 of 6 */
"0xff", "0xff", "0xff", "0x81", "0x99", "0x9f", "0x9f", "0xcf", /* rows 1-8 of 7 */
"0xcf", "0xe7", "0xe7", "0xf3", "0xf3", "0xff", "0xff", "0xff", /* rows 9-16 of 7 */
"0xff", "0xff", "0xff", "0xc3", "0x99", "0x99", "0x99", "0xc3", /* rows 1-8 of 8 */
"0x99", "0x99", "0x99", "0x99", "0xc3", "0xff", "0xff", "0xff", /* rows 9-16 of 8 */
"0xff", "0xff", "0xff", "0xc3", "0x99", "0x99", "0x99", "0x99", /* rows 1-8 of 9 */
"0x83", "0x9f", "0x9f", "0xcf", "0xe3", "0xff", "0xff", "0xff" /* rows 9-16 of 9 */
);
if ($id)
{
if (file_exists("$recdir$id$rfile"))
{
$file=fopen("$recdir$id$rfile","r");
$num=fread($file,$int_width);
fclose($file);
$counter = $num+1;
$plusfile=fopen("$recdir$id$rfile","w");
fwrite($plusfile,$counter);
fclose($plusfile);
}
else
{
$num=0;
}
for ($i = 0; $i < $int_width; ++$i)
{
$j = $num % 10;
$count[$int_width - 1 - $i] = $j;
$num /= 10;
}
printf("#define counter_width %drn",$count_width * $int_width);
printf("#define counter_height %drn",$count_height);
printf("static unsigned char counter_bits[] = {rn");
for ($i = 0; $i < $count_height; ++$i)
{
for ($j = 0; $j < $int_width; ++$j)
{
printf("%s", $bitmap[($count[$j] * $count_height) + $i]);
if (( $i < $count_height - 1) || ($j < $int_width - 1)) printf(", ");
}
}
printf("rn};");
}
?>
请用这种方法调用:<img src="count.php?id=username&len=length">
id就是用户名,len就是长度。
|