changeset 444:71de51d25137

add entry2.rb
author SUZUKI Takehisa <c110128@e.koeki-u.ac.jp>
date Fri, 24 Jan 2014 15:22:07 +0900
parents 78edd2897bac
children e562af758216
files coop/entry2.rb
diffstat 1 files changed, 42 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/coop/entry2.rb	Fri Jan 24 15:22:07 2014 +0900
@@ -0,0 +1,42 @@
+#!/usr/bin/env ruby
+# coding: euc-jp
+
+require 'cgi'
+#require 'digest'
+
+c = CGI.new('html4Tr')
+me = File.basename(c.script_name)
+
+c0 = c.cookies['id']
+ip = ENV['REMOTE_ADDR']
+i = 0
+
+
+srand(56384679263254687)
+10000.times {rand(1000000)}
+idlist = (1..100).collect{rand(10000000)}
+
+cookie = CGI::Cookie.new({'name' => 'id',
+                           'value' => "#{ip}",
+                           'domain' => c.server_name,
+                           'path' => c.script_name})
+
+cookie.expires = Time.now + 10
+
+c.out({'cookie' => cookie}) do
+  c.html({'PRETTY' => ' '}) do
+    c.head do
+      c.title {'サンプル'}
+    end + c.body do
+      if idlist.index(ARGV[0].to_i)
+        c.p{'おめでとう'} +
+          c.p{
+          c.code{cookie[0]}}
+      elsif i >= 50
+        c.p{'ごめんなさい'}
+      else 
+        c.p{'error'}
+      end
+    end
+  end
+end

yatex.org