计数器源代码
<img SRC="http://mcgi.163.com/cgi-bin/Count.cgi?ft=6&frgb=255;215;0&dd=A|df=ktjxg" NOSAVE BORDER=0 HEIGHT=26 WIDTH=96>
Re:计数器源代码
现在一般大家的网络空间都是可以支持CGI,PHP,ASP等技术的,大家可以自己做个
计数器,上面那位兄弟提供的其实不是计数器源代码,而是163.com提供的调用他们
CGI程序的代码!
Re:计数器源代码
计数器?太......................................简单了
文本的::用法:<script src =.....
#!/usr/bin/perl
print "Content-type: text/html\n\n";
open (CNT,"count.dat"
;
$cont = <CNT>;
close (CNT);
$cont ++;
print "document.write(\'$cont\')\;";
open (CNT,">count.dat"
;
print CNT ($cont);
图形计数器的源代码:用法<IMG src= .....
#!/usr/bin/perl
# 设置数据文件名
$counter_file='count.dat';
if (-T $counter_file) {
open(FILE, $counter_file) || die $!;
$count = <FILE>;
close (FILE);
$count+=1;
} else {
$count=1;
}
open (FILE, ">$counter_file"
;
print FILE $count;
close (FILE);
&initialize;
&generateBitmap;
&writeBitmap;
exit;
sub initialize {
$minLen = 1; #最小长度
$isHigh = 0; #等于0时,数字10位高;等于1时,数字16位高,加了边界
$isInverse = 1; #0时白底黑字,1时黑底白字
@invdigits = ("c3 99 99 99 99 99 99 99 99 c3","cf c7 cf cf cf cf cf cf cf c7","c3 99 9f 9f cf e7 f3 f9 f9 81","c3 99 9f 9f c7 9f 9f 9f 99 c3","cf cf c7 c7 cb cb cd 81 cf 87", "81 f9 f9 f9 c1 9f 9f 9f 99 c3","c7 f3 f9 f9 c1 99 99 99 99 c3","81 99 9f 9f cf cf e7 e7 f3 f3","c3 99 99 99 c3 99 99 99 99 c3", "c3 99 99 99 99 83 9f 9f cf e3"
;
@digits = ("3c 66 66 66 66 66 66 66 66 3c", # 0
"30 38 30 30 30 30 30 30 30 30","3c 66 60 60 30 18 0c 06 06 7e","3c 66 60 60 38 60 60 60 66 3c", "30 30 38 38 34 34 32 7e 30 78", "7e 06 06 06 3e 60 60 60 66 3c","38 0c 06 06 3e 66 66 66 66 3c","7e 66 60 60 30 30 18 18 0c 0c","3c 66 66 66 3c 66 66 66 66 3c","3c 66 66 66 66 7c 60 60 30 1c"
;
}
sub generateBitmap {
@bytes = ();
$len = length($count) > $minLen ? length($count) : $minLen;
$formattedCount = sprintf("%0${len}d",$count);
if ($isHigh) {
for ($i = 0; $i < $len*4; $i++ ) {
if ($isInverse) {
push(@bytes,"ff"
;
}
else {
push(@bytes,"00"
;
}
}
}
for ($y=0; $y < 10; $y++) {
for ($x=0; $x < $len; $x++) {
$digit = substr($formattedCount,$x,1);
if ($isInverse) {
$byte = substr(@invdigits[$digit],$y*3,2);
}
else {
$byte = substr(@digits[$digit],$y*3,2);
}
push(@bytes,$byte);
}
}
if ($isHigh) {
for ($i = 0; $i < $len*4; $i++ ) {
if ($isInverse) {
push(@bytes,"ff"
;
}
else {
push(@bytes,"00"
;
}
}
}
}
sub writeBitmap {
print "Content-type: image/x-xbitmap\n\n";
if ($isHigh) {
printf ("#define count_width %d\n#define count_height 16\n",
$len*8);
}
else {
printf ("#define count_width %d\n#define count_height 10\n",
$len*8);
}
printf STDOUT "static char count_bits[] = {\n";
for($i = 0; $i < ($#bytes + 1); $i++) {
print("0x$bytes[$i]"
;
if ($i != $#bytes) {
print(",");
if (($i+1) % 7 == 0) {
print("\n");
}
}
}
print("};\n");
}
Re:计数器源代码
~~好~~~像~~~~是挺简单的??!!
Re:Re:计数器源代码
引用:原文由 阿小 发表:
~~好~~~像~~~~是挺简单的??!!
怎么还好像,就是
Re:计数器源代码
哈哈,这种东西老师高兴的话不用想就出来了
这就是高手跟我们菜鸟之间的差别啊!
Re:计数器源代码
老师什么时候也教教我们这群菜鸟啊,让我们也学点什么,现在肚子里什么都拿不出来啊!你在水木混的,把那的精华都拿到这没人看的懂,你就弄些粗浅的好吗?
欢迎光临
空网论坛 (http://bbs.kongweb.net/)
作者:
丸子
时间:
2001-8-2 01:11