diff --git a/2014OC/accountcheck.rb b/2014OC/accountcheck.rb index c802ae1..ed794c7 100755 --- a/2014OC/accountcheck.rb +++ b/2014OC/accountcheck.rb @@ -45,7 +45,7 @@ db.execute(sql,name,sex,age,aria,job,'000010000','n,n,n,n,kamo1,n,n,n,n',0,0,mg); #初期値 end -expires = "SUN, 3 Aug 2014 24:00:00 GMT" +expires = "SUN, 17 Aug 2014 24:00:00 GMT" printf("Content-type: text/html; charset=UTF-8 Set-Cookie:id=%s ;expires=%s diff --git "a/2014OC/admin/\043drawLots.rb\043" "b/2014OC/admin/\043drawLots.rb\043" new file mode 100755 index 0000000..95c7c84 --- /dev/null +++ "b/2014OC/admin/\043drawLots.rb\043" @@ -0,0 +1,87 @@ +#!/usr/bin/env ruby +# -*- coding: utf-8 -*- + +require 'sqlite3' +require 'cgi' +require 'date' + +c = CGI.new(:tag_maker => "html5", :accept_charest => "UTF-8") +db = SQLite3::Database.new("../sql/stamp.sq3") + +add = ENV["REMOTE_ADDR"] + +if /^(172\.19\.5\.|172\.17\.54\.|172\.21\.90\.)|118.21.142.107|202.214.125.107/ =~ add +check = c['check'] + +printf("Content-type: text/html; charset=UTF-8\n\n") + +sum = 'SELECT SUM(rank) FROM main WHERE NOT id=1;' +rank_sum = db.execute(sum).flatten(2)[0].to_i + +t = Time.now +expires = Time.local(2014, 8, 3, 8, 50) +expires2 = Time.local(2014, 8, 3, 17, 00) +if t > expires && t < expires2 +else + check = "" + puts check +end + +if check == "OK" + begin + result = db.execute("select id,exp,rank from main;") + rescue + exit + end + all = Array.new + for id,lv,rank in result + if id == 1 || lv == 0 || rank.to_i != 0 + next + end + lv.to_i.times do + all << id + end + end + + tousen = Array.new(0) + atari1 = rand(all.length) + tousen << all[atari1] + all.delete_if {|x| x == tousen[0]} + + sql = "update main set rank = 1 where id = ?;" + db.execute(sql,tousen[0]) + + sql = "update main set rank = 2 where id = ?;" + while tousen.length < 4 + srand + atari2 = rand(all.length) + hoge = all[atari2] + tousen << all[atari2] + all.delete_if {|x| x == hoge} + db.execute(sql,hoge) + end + + i=0 + + printf("
1等はIDが%04dの方!おめでとー!
\n",tousen[i].to_i-1) + printf("2等はIDが%04dと%04dと%04dの方!おめでとー!
\n",tousen[i+=1].to_i-1,tousen[i+=1].to_i-1,tousen[i+=1].to_i-1) +print'\n + +' +else + print"抽選はまだ行いませんよ
\n" +end +else + printf("Content-type: text/html; charset=UTF-8\n\n") + + printf' + + +管理者用ページのため閲覧できません。
' +end +print'