#!/usr/bin/perl

use utf8;
use CGI qw/:standard -no_xhtml -utf8/;

binmode STDIN, ':encoding(utf8)';
binmode STDOUT, ':encoding(utf8)';
binmode STDERR, ':encoding(utf8)';

my $q = new CGI;


my $svurl = $q->param('svurl') || '';
if ($svurl =~ m!http://[\w_=/:@\?\.\-]+$!) {
    my $cookie = $q->cookie(-name=>'SVURL', -value=>$svurl, -expires=>'+100d');
    print $q->header(-type=>'text/html', -status=>200, -cookie=>$cookie, -domain=>'papa.to', -path=>'/', -expires=>-1);
    print start_html('player setup'),
    h1('cookie('.$svurl . ')'),
    a({href=>'/'},'back'),
    end_html;

} else {
    print
	header(-lang=>ja, -charset=>'utf-8'),
	start_html(-title=>'player setup', -bgcolor=>'#ee9'),
	h1('プレイヤーセットアップ'),
	p('対応レコーダを登録すると人気の番組をすぐ再生できます！'),
	start_form(-action=>'/svsetup.pl'),
	textfield(-size=>40, -name=>'svurl'),
	hidden('session', int(rand() * 1000000)),
	submit,
	end_form,
	h2('例: http://192.168.XXX.XXX/player.cgi'),
	a({href=>'/'},'戻る'),
	end_html;
}

1;
