くだらない質問でも偉そうに聞いていいスレat PHP
くだらない質問でも偉そうに聞いていいスレ - 暇つぶし2ch27:nobodyさん
10/04/15 20:51:28
>>20
perlですが、こんな感じでいかがでしょう。DBIx::Simpleを入れてくださいね。

#!/usr/local/bin/perl
use strict;use warnings;use CGI;use DBIx::Simple;use Digest::SHA1 qw(sha1_hex);
my$q=CGI->new;print$q->header(-charset=>'utf-8'),$q->start_html('message'),$q->
start_form(-action=>$q->script_name),$q->textfield(-name=>'value',-size=>64),$q
->submit('leave a secret mess'),$q->end_form,$q->hr;my$db=DBIx::Simple->connect
('dbi:SQLite:dbname=secret_message.db')or die DBIx::Simple->error;$db->query(qq
{CREATE TABLE IF NOT EXISTS message (key, value)});if($q->param('key')){my@mes=
$db->select('message','value',{key=>[$q->param('key')]})->hashes;for my$m(@mes)
{print$m->{'value'},qq{\n<hr>\n};}$db->delete('message',{key=>$q->param('key')}
);}if($q->param('value')){my $key=sha1_hex($q->remote_addr.$q->param('value'));
$db->insert('message',{key=>$key,value=>$q->param('value')});print qq{send URL
to friend<br>},$q->url(),qq{?key=$key<hr>};}print$q->end_html;$db->disconnect;


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch