umqの日記: ishavingamassage.com
日記 by
umq
百式の記事
http://www.100shiki.com/archives/2005/04/_ishavingmassagecom.html
を見て、どうやってるんだろうという質問があったので、
手許でも試してみた。
DNS サーバに
ishavingamassage.example.com
*.ishavingamassage.example.com
の A レコードを設定。
いわゆるワイルドカード A レコードですね。
「どうやって」というのは、ここがキモかと。
手許の Apache でテストしたときは Name Based Virtual Host
でやったので httpd.conf に
<VirtualHost ishavingamassage.example.com>
DocumentRoot /var/www/ishavingamassage
ServerName IsHavingAMassage.example.com
ErrorLog /var/log/ishavingamassage.lab-error_log
CustomLog /var/log/ishavingamassage.lab-access_log common
</VirtualHost>
<Directory /var/www/ishavingamassage>
DirectoryIndex index.cgi
Options +ExecCGI
</Directory>
みたいな感じで設定。
以下は、手許で使ったスクリプト。
Perl なり、C なり、使いやすいので書けばいいと思う。
#! /usr/local/bin/gosh
(use gauche.regexp)
(use srfi-13)
(use text.html-lite)
(use text.tree)
(use www.cgi)
(define mydomain "\\.ishavingamassage.example.com$")
(define yourname
(regexp-replace-all
"\\."
(regexp-replace
"^(www|)$"
(string-trim-right
(regexp-replace mydomain (sys-getenv "HTTP_HOST") "") #\.)
"flickr")
" "))
(define namelength
(- (string-length yourname) 1))
(define (main args)
(cgi-main
(lambda (params)
(tree->string
`(,(cgi-header :content-type "text/html; charset=utf-8")
,(html-doctype :type :xhtml-1.0)
,(html:html :lang "en"
(html:head
(html:meta :http-equiv "Content-Type"
:content "text/html; charset=utf-8")
(html:style :type "text/css"
(string-append
"body{"
"font-family:Arial,Helvetica,sans-serif;"
"width: 400px; padding-top:30px;"
"margin-left: auto; margin-right: auto;}"
"h2 { font-size : xx-large;"
"font-weight : 900;"
"color : #0063dc;}"
"#lastletter { color : #ff0084; }"
"h1 { font-size: 32px;"
"color: rgb(0, 0, 0);"
"margin-top: 0px; margin-bottom: 20px; }"
"#content { text-align : center; }"
".description { font-size: 16px; }"
"img { padding-bottom : 30px; }"
))
(html:title
(string-append
(string-titlecase yourname)
" is Having A Massage"))
)
(html:body
(html:div :id "content"
(html:h2
(html:span :id "basename"
(substring yourname 0 namelength))
(html:span :id "lastletter"
(string-ref yourname namelength)))
(html:h1 (string-append
yourname
" is having a massage."))
(html:p
:class "description"
yourname
" is getting a massage and will return soon."))
)
))))))
http://www.100shiki.com/archives/2005/04/_ishavingmassagecom.html
を見て、どうやってるんだろうという質問があったので、
手許でも試してみた。
DNS サーバに
ishavingamassage.example.com
*.ishavingamassage.example.com
の A レコードを設定。
いわゆるワイルドカード A レコードですね。
「どうやって」というのは、ここがキモかと。
手許の Apache でテストしたときは Name Based Virtual Host
でやったので httpd.conf に
<VirtualHost ishavingamassage.example.com>
DocumentRoot /var/www/ishavingamassage
ServerName IsHavingAMassage.example.com
ErrorLog /var/log/ishavingamassage.lab-error_log
CustomLog /var/log/ishavingamassage.lab-access_log common
</VirtualHost>
<Directory /var/www/ishavingamassage>
DirectoryIndex index.cgi
Options +ExecCGI
</Directory>
みたいな感じで設定。
以下は、手許で使ったスクリプト。
Perl なり、C なり、使いやすいので書けばいいと思う。
#! /usr/local/bin/gosh
(use gauche.regexp)
(use srfi-13)
(use text.html-lite)
(use text.tree)
(use www.cgi)
(define mydomain "\\.ishavingamassage.example.com$")
(define yourname
(regexp-replace-all
"\\."
(regexp-replace
"^(www|)$"
(string-trim-right
(regexp-replace mydomain (sys-getenv "HTTP_HOST") "") #\.)
"flickr")
" "))
(define namelength
(- (string-length yourname) 1))
(define (main args)
(cgi-main
(lambda (params)
(tree->string
`(,(cgi-header :content-type "text/html; charset=utf-8")
,(html-doctype :type :xhtml-1.0)
,(html:html :lang "en"
(html:head
(html:meta :http-equiv "Content-Type"
:content "text/html; charset=utf-8")
(html:style :type "text/css"
(string-append
"body{"
"font-family:Arial,Helvetica,sans-serif;"
"width: 400px; padding-top:30px;"
"margin-left: auto; margin-right: auto;}"
"h2 { font-size : xx-large;"
"font-weight : 900;"
"color : #0063dc;}"
"#lastletter { color : #ff0084; }"
"h1 { font-size: 32px;"
"color: rgb(0, 0, 0);"
"margin-top: 0px; margin-bottom: 20px; }"
"#content { text-align : center; }"
".description { font-size: 16px; }"
"img { padding-bottom : 30px; }"
))
(html:title
(string-append
(string-titlecase yourname)
" is Having A Massage"))
)
(html:body
(html:div :id "content"
(html:h2
(html:span :id "basename"
(substring yourname 0 namelength))
(html:span :id "lastletter"
(string-ref yourname namelength)))
(html:h1 (string-append
yourname
" is having a massage."))
(html:p
:class "description"
yourname
" is getting a massage and will return soon."))
)
))))))
ishavingamassage.com More ログイン