Newer
Older
skip-web / minato2014 / admin / delete.rb
@MURAKAMI Masaki MURAKAMI Masaki on 26 Jul 2014 1 KB updated
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-

require 'sqlite3'
require 'cgi'

db = SQLite3::Database.new("../sql/stamp.sq3")
c = CGI.new(:accept_charaset => "UTF-8")

add = ENV["REMOTE_ADDR"]

printf("Content-type: text/html; charset=UTF-8\n\n")

if /^(172\.19\.5\.|172\.17\.54\.|172\.21\.90\.)|118.21.142.107|202.214.125.107/ =~ add
check = c['check']
if check == "OK"
  begin
    db.execute("drop table main;")
    db.extcute("drop table logs;")
    text = "<p>データを削除しました。</p>"
  rescue
    text = "<p>データがありません。</p>"
  end
else
  text = "データは削除されません"
end

printf'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Delete table</title>
<link rel="stylesheet" type="text/css" href="design.css">
</head>
</body>
%s
<p><a href="etsuran.rb">データ閲覧ページへ</a></p>
<p></p>
</body></html>
',text

else  
  printf'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/h
tml4/strict.dtd">
<html>
<head>
<title>Delete table</title>
<link rel="stylesheet" type="text/css" href="design.css">
</head>
</body>
<p>管理者用ページのため閲覧できません。</p>'
end