changeset 807:c110d66cb0d9

cookie img
author ARAKI Tsuyohito <c113007@e.koeki-u.ac.jp>
date Fri, 17 Jul 2015 14:58:40 +0900
parents 3ba6fee591d7
children 3147f6e92f0a
files oasis2015/cookie.rb oasis2015/img/qr/cookie.png oasis2015/retry.rb
diffstat 3 files changed, 147 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/oasis2015/cookie.rb	Fri Jul 17 14:58:40 2015 +0900
@@ -0,0 +1,43 @@
+#!/usr/bin/env ruby22
+# -*- coding: utf-8 -*-
+
+require 'sqlite3'
+require 'kconv'
+require 'cgi'
+
+c = CGI.new(:tag_maker => "html5", :accept_charest => "UTF-8")
+db = SQLite3::Database.new("sql/main.sq3")
+
+id = c.cookies["id"][0]
+id = nil
+expires = Time.now + 1
+if id == nil
+end 
+
+
+printf("Content-type: text/html; charset=UTF-8
+Set-Cookie:id=%s ;expires=%s\n\n", id, expires)
+
+printf(<<_EOS_)
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+<head>
+
+<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
+<meta name="format-detection" content="telephone=no">
+<link media="only screen and (max-device-width:480px)" href="smart.css" type="text/css" rel="stylesheet" />
+<link media="screen and (min-device-width:481px)" href="profeel.css" type="text/css" rel="stylesheet" />
+
+
+
+
+<link rel="shortcut icon" href="./img/cabage.png"/>
+<title>Registering Account</title>
+
+</head>
+<body>
+<h1>さかたっち</h1>
+<h2>cookieを削除しました!</h2>
+<a href="index.html">とうろくがめんへ!</a>
+</body></html>
+_EOS_
Binary file oasis2015/img/qr/cookie.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/oasis2015/retry.rb	Fri Jul 17 14:58:40 2015 +0900
@@ -0,0 +1,104 @@
+#!/usr/bin/env ruby22
+# -*- coding: utf-8 -*-
+
+require 'sqlite3'
+require 'kconv'
+require 'cgi'
+
+c = CGI.new(:tag_maker => "html5", :accept_charest => "UTF-8")
+db = SQLite3::Database.new("sql/main.sq3")
+
+
+sql = "insert into test values(?, ?, ?, ?, ?, ?, ?, ?, ?)"
+
+toi = "insert into toi values (?, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)"
+item = "insert into goods values (?, 0, 0, 0, 0, 0, 0)"
+
+name = c["name"]
+
+cle1 = "CREATE TABLE IF NOT EXISTS test(id, name, cal, age, sex, aria, exp, pt, lv)"
+cle2 = "CREATE TABLE IF NOT EXISTS toi(id, q1, q2, q3, q4, q5, q6, q7, q8, q9, q10)"
+cle3 = "CREATE TABLE IF NOT EXISTS goods(id, g1, g2, g3, g4, g5, g6)"
+cle4 = "CREATE TABLE IF NOT EXISTS time(cd, now, id)"
+cle5 = "CREATE TABLE IF NOT EXISTS num(cd, id)"
+
+ins4 = 'insert into time values(?, 61, "n")'
+ins5 = 'insert into num values("aa",0)'
+num = "select id from num where cd = ?"
+numup = "update num set id = ? where cd = ?"
+
+db.execute(cle1)
+db.execute(cle2)
+db.execute(cle3)
+db.execute(cle4)
+db.execute(cle5)
+
+name = c["name"]
+namae = "#{name}"
+cal = c["cal"]
+age = c["age"]
+sex = c["sex"]
+aria = c["aria"]
+
+id = c.cookies["id"][0]
+if id == nil
+#  srand
+#  id = rand(1000)
+  number = db.execute(num, "aa")
+  id = number[0][0].to_i + 1
+  exp = 0
+  pt = 0
+  lv = 1
+  cd = "aa"
+  db.execute(sql, id, name, cal, age, sex, aria, exp, pt, lv)
+
+  db.execute(toi, id)
+  db.execute(item, id)
+  db.execute(numup, id, cd)
+end
+  srand(id.to_i)  
+  id2 = rand(1000000)
+
+
+
+
+expires = 10
+
+printf("Content-type: text/html; charset=UTF-8
+Set-Cookie:id=%s ;expires=%s
+Set-Cookie:pass=%s ;expires=%s\n\n", id, expires, id2, expires)
+
+printf(<<_EOS_, name, id.to_i)
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+<head>
+
+<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
+<meta name="format-detection" content="telephone=no">
+<link media="only screen and (max-device-width:480px)" href="smart.css" type="text/css" rel="stylesheet" />
+<link media="screen and (min-device-width:481px)" href="profeel.css" type="text/css" rel="stylesheet" />
+
+
+
+
+<link rel="shortcut icon" href="./img/cabage.png"/>
+<title>Registering Account</title>
+
+</head>
+<body>
+<h1>さかたっち</h1>
+<h2>登録が完了しました!</h2>
+<p>ようこそ_ %s _さん!</p>
+<p>あなたのIDは%04dです。抽選はこのIDを元に行われます。</p>
+<div class="f1"><a href="prof.rb"><div class="lets"><span>始めよう!</span></div></a></div>
+<form method="POST" type="text">
+</form>
+</body></html>
+_EOS_
+
+
+if name == "createman987987987"
+  `rm sql/main.sq3`
+#  `touch sql/main.sq3`
+#  `chmod a+w sql/main.sq3`
+end

yatex.org