From: Wada Hiroshi Date: 1998-06-05T17:48:30+09:00 Subject: [ruby-list:8199] Web Counter 和田と申します。皆さん、はじめまして。 早速ですが。 今後需要も増えてくると思い、ruby で web counter を作ってみました。 # 仕事で使おうと思って^^; 機能と呼べるものはありませんし、ソースもダサダサですが、一応動いています。 gd1.3.tar.gz と GD-0.6.tar.gz を使ってます。 SSI が使えなくても動くというのを売りにしたかったのですが、 プロバイダに置こうと思ったら cc が使えないと駄目ですね。 で、この時気が付いたのですが、GD のコンパイルに失敗します。 GD.c の 656 行目の RBASIC(self)->class = class; の部分でエラーが出ます。この行をコメントにしたら コンパイルできて、問題無く動いています。ruby-1.1b9_23 です。 # この変更に自信はまったくありませんが。 それでは。 -- ネットワーク応用通信研究所 和田 寛 < hiroshiw@netlab.co.jp > #! /usr/local/bin/ruby # 表示桁数 leng = 6 # カウントを保存するファイル countfile = "/home/hiroshiw/.num" file = open(countfile) count = file.gets().to_i file.close require "GD" # require "cgi-lib" print "Content-type: image/gif\n\n" scount = "" sleng = count.to_s.size if (leng - 1 - sleng) > 0 for i in 0..(leng - 1 - sleng) scount += "0" end else leng = sleng end font = GD::Font.new("Giant") im = GD::Image.new(font.width * leng ,font.height) white = im.colorAllocate(255,255,255) black = im.colorAllocate(0,0,0) bule = im.colorAllocate(0,0,255) im.string(font, 0, 0, scount+count.to_s, bule) im.interlace im.gif STDOUT count += 1 file = open(countfile,"w") file.flock(File::LOCK_EX) printf file,count.to_s file.close