#!/usr/local/ymir/perl/bin/perl use lib '/home/mikage/usr/TmmLib7/TL/lib'; use TL qw(/home/www/res/mikage.ini); $TL->startCgi(-main => \&Main); sub Main { $TL->dispatch($TL->CGI->get('Command') // 'Input') or $TL->print('Command Error'); } sub DoInput { &DispInput(); } sub DispInput { my $error = shift; my $t = $TL->newTemplate('input.html'); if($TL->CGI->exists('zip')) { $t->setForm($TL->newForm->set(zip => $TL->CGI->get('zip'))); } $t->addHiddenForm($TL->newForm->set(Command => 'Conf')); if($error) { $t->node($error)->add; } $t->flush; } sub DoConf { my ($error, $zip) = &CheckZip(); if($error) { &DispInput($error); } else { &DispConf; } } sub DispConf { my $t = $TL->newTemplate('conf.html'); $t->expand(ZIP => $TL->CGI->get('zip')); $t->addHiddenForm($TL->newForm->set(Command => 'End', zip => $TL->CGI->get('zip'))); $t->flush; } sub CheckZip { my $zip = $TL->newValue->set($TL->CGI->get('zip'))->convNarrow; if($zip->isZipCode) { return (undef, $zip->get); } elsif($zip->isEmpty) { return 'zipnull'; } else { return 'ziperror'; } } sub DoEnd { if($TL->CGI->get('SubmitMode') eq '次へ') { my ($error, $zip) = &CheckZip(); if($error) { &DispInput($error); } else { &DispEnd($zip); } } else { &DispInput(); } } sub DispEnd { my $zip = shift; my $t = $TL->newTemplate('end.html'); $t->expand(ZIP => $zip); $t->flush; }