#!/usr/bin/perl
require '/home/rexi-jp/public_html/jj/lib/lib.pl';
$mycgi = 'index.cgi';
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use Encode;
$ip = $ENV{'REMOTE_ADDR'};
$host = gethostbyaddr(pack("C4", split(/\./, $ip)), 2);
$host ||= $ENV{'REMOTE_HOST'};
$host ||= $ip;
$referer=$ENV{'HTTP_REFERER'};
$script=$ENV{'SCRIPT_NAME'};
$id = $ENV{'REMOTE_USER'};
$query = CGI->new;
my @params = $query->param();#全てのパラメータ名を取得 なのでこれを$inにしてしまえば$inで使用可能
foreach my $param (@params) {
$in{$param} = $query->param($param);
}
$dbh = &connectDB('name');
#&in_enc;
if ($in{'mode'} eq ''){
⊤
}
elsif ($in{'mode'} eq 'search'){
&search1;
}
elsif ($in{'mode'} eq 'view'){
&view;
}
elsif ($in{'mode'} eq 'declare_conf'){
&declare_conf;
}
elsif ($in{'mode'} eq 'declare_set'){
&declare_set;
}
elsif ($in{'mode'} eq 'usr_post'){
&usr_post;
}
elsif ($in{'mode'} eq 'entry_conf'){
&entry_conf;
}
else{
&name_err("不正なパラメータ");
}
&disconDB($dbh);
exit;
#---------------------------------------
# エラー
#---------------------------------------
sub name_err {
$out{'body'} = $_[0];
# $Ret = &Jcode::getcode( $out{'body'} ) ;
# if ($Ret eq 'euc'){
# &Jcode::convert(\$out{'body'},'sjis');
# }
$header = "Content-type: text/html;charset=\"EUC_JP\"\n\n";
open FILE,"err.html";
print $header;
while(){
s/!(\w+)!/$out{$1}/g;
print;
}
close FILE;
exit;
}
#---------------------------------------
# HTML出力
#---------------------------------------
sub html_out {
$file = $_[0];
$header = "Content-type: text/html;charset=\"EUC_JP\"\n\n";
open FILE,$file;
print $header;
while(){
s/!(\w+)!/$out{$1}/g;
print;
}
close FILE;
exit;
}
#---------------------------------------
#
#---------------------------------------
sub top {
&html_out("top.html");
}
#---------------------------------------
#
#---------------------------------------
sub search1 {
&in_enc;
#姓
$sql = "select a.word from name_master a";
if ($in{'jyogai_1'} eq 1 || $in{'wa_you'} ne ''){$sql .= ",(select word1 from declare_list group by word1) b";}
$sql .= " where ";
if ($in{'kime1_1'} eq ''){
if ($in{'wa_you'} eq 1 || $in{'wa_you'} eq 2){$sql .= "a.wa_you in (0,$in{'wa_you'}) and ";}
elsif ($in{'wa_you_1'} eq 1 || $in{'wa_you_1'} eq 2){$sql .= "a.wa_you in (0,$in{'wa_you_1'}) and ";}
if ($in{'special1_1'} eq 1 || $in{'special2_1'} eq 1 || $in{'special3_1'} eq 1){
$sql .= "a.special in (";
if ($in{'special1_1'} eq 1){$sql .= "0,";}
if ($in{'special2_1'} eq 1){$sql .= "1,";}
if ($in{'special3_1'} eq 1){$sql .= "2,";}
chop $sql;
$sql .= ") and ";
}
}
#&name_err($sql);
if ($in{'char_limit_1'} ne ''){$sql .= "octet_length(a.word) <= ($in{'char_limit_1'} * 2) and ";}
if ($in{'kime1_1'} ne ''){$sql .= "a.word = '$in{'kime1_1'}' and ";}
$sql .= "a.surname in (0,1) and a.state = 0 ";
if ($in{'jyogai_1'} eq 1 || ($in{'wa_you'} ne '' && $in{'wa_you'} ne 0)){
$sql .= "and a.word != b.word1 ";
}
$sql .= "group by a.word order by a.word;";
#&name_err($sql);
$ref = $dbh->selectall_arrayref($sql) or &name_err("エラーが発生しました。");
@ary1 = ();
$i1 = 0;
foreach(@$ref) {
($word)=@{$_};
push ary1,$word;
$i1++;
}
$max1 = $#ary1;
@ary2 = ();
$i = 0;
$x = 0;
while ($i<10 && $x < $max1){
if ($in{'kime1_1'} eq ''){
$rnd = int(rand($max1));
$tmp = @ary1[$rnd];
$flg = 0;
foreach(@ary2){
if ($_ eq $tmp){
$flg = 1;
last;
}
}
if ($flg eq 0){
push ary2,$tmp;
$i++;
}
}
else{
push ary2,$in{'kime1_1'};
$i++;
}
$x++;
if ($x > 9000){&name_err("X ERROR");}
}
@ary_myouji = @ary2;
#名
$sql = "select a.word from name_master a";
if ($in{'jyogai_1'} eq 1 || ($in{'wa_you'} ne '' || $in{'wa_you'} ne 0)){$sql .= ",(select word2 from declare_list group by word2) b";}
$sql .= " where ";
if ($in{'kime1_2'} eq ''){
if ($in{'sex'} ne 0){$sql .= "a.sex in (0,$in{'sex'}) and ";}
if ($in{'wa_you'} eq 1 || $in{'wa_you'} eq 2){$sql .= "a.wa_you in (0,$in{'wa_you'}) and ";}
elsif ($in{'wa_you_2'} eq 1 || $in{'wa_you_2'} eq 2){$sql .= "a.wa_you in (0,$in{'wa_you_2'}) and ";}
if ($in{'special1_2'} eq 1 || $in{'special2_2'} eq 1 || $in{'special3_2'} eq 1){
$sql .= "a.special in (";
if ($in{'special1_2'} eq 1){$sql .= "0,";}
if ($in{'special2_2'} eq 1){$sql .= "1,";}
if ($in{'special3_2'} eq 1){$sql .= "2,";}
chop $sql;
$sql .= ") and ";
}
}
if ($in{'char_limit_2'} ne ''){
$sql .= "octet_length(a.word) <= ($in{'char_limit_2'} * 2) and ";
}
# if ($in{'kime1_2'} ne ''){$sql .= "(a.word like '%" . $in{'kime1_2'} . "%' or a.word = '$in{'kime1_2'}') and ";}
if ($in{'kime1_2'} ne ''){$sql .= "a.word = '$in{'kime1_2'}' and ";}
$sql .= "a.surname in (0,2) and a.state = 0 ";
if ($in{'jyogai_1'} eq 1 || ($in{'wa_you'} ne '' && $in{'wa_you'} ne 0)){
$sql .= "and a.word != b.word2 ";
}
$sql .= "group by a.word order by a.word;";
#&name_err($sql);
$ref = $dbh->selectall_arrayref($sql) or &name_err("エラーが発生しました。");
@ary1 = ();
$i1 = 0;
foreach(@$ref) {
($word)=@{$_};
push ary1,$word;
$i1++;
}
$max1 = $#ary1;
@ary2 = ();
$i = 0;
$x = 0;
while ($i<10 && $x < $max1){
if ($in{'kime1_2'} eq ''){
$rnd = int(rand($max1));
$tmp = @ary1[$rnd];
$flg = 0;
foreach(@ary2){
if ($_ eq $tmp){
$flg = 1;
last;
}
}
if ($flg eq 0){
push ary2,$tmp;
$i++;
}
}
else{
push ary2,$in{'kime1_2'};
$i++;
}
$x++;
if ($x > 9000){&name_err("Y ERROR");}
}
@ary_namae = @ary2;
#ランダムに並べる
$y = 0;
@ary_surname1 = ();
@ary_tmp = ();
$i = 0;
while ($i < 10){
$rnd = int(rand(10));
$flg = 0;
foreach(@ary_tmp){
$tmp = $_;
if ($tmp eq $rnd){
$flg = 1;
last;
}
}
if ($flg eq 0){
push ary_surname1,@ary_myouji[$rnd];
push ary_tmp,$rnd;
$i++;
}
$y++;
if ($y > 3000){&name_err("Y ERROR
$dbg");}
}
@ary_surname2 = ();
@ary_tmp = ();
$i = 0;
while ($i < 10){
$rnd = int(rand(10));
$flg = 0;
foreach(@ary_tmp){
$tmp = $_;
if ($tmp eq $rnd){
$flg = 1;
last;
}
}
if ($flg eq 0){
push ary_surname2,@ary_namae[$rnd];
push ary_tmp,$rnd;
$i++;
}
}
$ZkatakanaExt = '(?:\xA5[\xA1-\xF6]|\xA1[\xA6\xBC\xB3\xB4])'; # EUC-JP
$ZkatakanaExt_sjis = '(?:\x83[\x40-\x96]|\x81[\x45\x5B\x52\x53])'; # SJIS
$Zkatakana = '[^(?:\xA5[\xA1-\xF6])]';
&in_enc;
# $Zkatakana = '(?:\xE3\x82[\xA1-\xBF]|\xE3\x83[\x80-\xB6])'; # UTF-8
if ($in{'kime1_1'} ne '' && $in{'kime1_2'} ne '' && $in{'kime1_1'} !=~ /$ZkatakanaExt/ && $in{'kime1_2'} !=~ /$ZkatakanaExt/){
$in{'wa_you'} = 1;
$in{'wa_you_1'} = 1;
$in{'wa_you_2'} = 1;
}
else{
if ($in{'kime1_1'} ne '' && $in{'kime1_1'} =~ /$ZkatakanaExt/){
$in{'wa_you'} = 2;
$in{'wa_you_1'} = 2;
}
elsif ($in{'kime1_1'} ne ''){
$in{'wa_you'} = 1;
$in{'wa_you_1'} = 1;
}
if ($in{'kime1_2'} ne '' && $in{'kime1_2'} =~ /$ZkatakanaExt/){
$in{'wa_you'} = 2;
$in{'wa_you_2'} = 2;
}
elsif ($in{'kime1_2'} ne ''){
$in{'wa_you'} = 1;
$in{'wa_you_1'} = 1;
}
}
#if ($ip eq '61.27.55.68'){&name_err("wa_you:$in{'wa_you'},wa_you_1:$in{'wa_you_1'},wa_you_2:$in{'wa_you_2'}");}
# if($in{'kime1_1'} ne '' && $in{'kime1_1'} !=~ /$Zkatakana/){
# $in{'wa_you'} = 1;
# $in{'wa_you_1'} = 1;
# }
# if($in{'kime1_2'} ne '' && $in{'kime1_2'} !=~ /$Zkatakana/){
# $in{'wa_you'} = 1;
# $in{'wa_you_2'} = 1;
# }
#&name_err("wa_you:$in{'wa_you'},wa_you_1:$in{'wa_you_1'}");
$k = 1;
for($i=0;$i<10;$i++){
$word1 = @ary_surname1[$i];
$word2 = @ary_surname2[$i];
$spel1 = '';
$spel2 = '';
if ($word1 eq '' && $in{'kime1_1'} ne ''){$word1 = $in{'kime1_1'};}
if ($word2 eq '' && $in{'kime1_2'} ne ''){$word2 = $in{'kime1_2'};}
if ($in{'wa_you'} eq 2 || $in{'wa_you_1'} eq 2 || $in{'wa_you_2'} eq 2){
$name_str = "$word2・$word1";
$sword1 = 'spelling';
$sword2 = 'spelling';
}
else{
$name_str = "$word1 $word2";
$sword1 = 'kana';
$sword2 = 'kana';
}
if ($in{'wa_you_1'} eq 1){$sword2 = 'kana';}
if ($in{'wa_you_2'} eq 1){$sword1 = 'kana';}
if ($in{'kime1_2'} eq ''){
$sql = "select $sword1 from name_master where word = '$word2';";
$ref = $dbh->selectall_arrayref($sql) or &name_err("エラーが発生しました。");
@ary = ();
foreach(@$ref) {
($spelling)=@{$_};
if ($spelling ne ''){
push ary,$spelling;
}
}
$max = $#ary + 1;
$rand = int(rand($max));
$spel1 = @ary[$rand];
}
if ($in{'kime1_1'} eq ''){
$sql = "select $sword2 from name_master where word = '$word1';";
$ref = $dbh->selectall_arrayref($sql) or &name_err("エラーが発生しました。");
@ary = ();
foreach(@$ref) {
($spelling)=@{$_};
if ($spelling ne ''){
push ary,$spelling;
}
}
$max = $#ary + 1;
$rand = int(rand($max));
$spel2 = @ary[$rand];
}
if ($in{'kime1_1'} ne ''){$spel2 = '';}
if ($in{'kime1_2'} ne ''){$spel1 = '';}
if ($spel1 eq ''){$spel1 = '―';}
if ($spel2 eq ''){$spel2 = '―';}
if ($in{'wa_you'} eq 2 || $in{'wa_you_1'} eq 2 || $in{'wa_you_2'} eq 2){
if ($spel1 eq '' && $spel2 eq ''){}
elsif ($spel1 eq '' || $spel2 eq ''){$kana_str = "$spel1$spel2";}
elsif ($spel1 ne '' && $spel2 ne ''){$kana_str = "$spel1 $spel2";}
}
else{
if ($spel1 eq '' && $spel2 eq ''){}
elsif ($spel1 eq '' || $spel2 eq ''){$kana_str = "$spel2$spel1";}
elsif ($spel1 ne '' && $spel2 ne ''){$kana_str = "$spel2 $spel1";}
}
$sql = "select no from name_master where word = '$word1' limit 1;";
$ref = $dbh->selectall_arrayref($sql) or &name_err("エラーが発生しました。");
($seq1)=@{$ref->[0]};
$sql = "select no from name_master where word = '$word2' limit 1;";
$ref = $dbh->selectall_arrayref($sql) or &name_err("エラーが発生しました。");
($seq2)=@{$ref->[0]};
$tmpstr = "Form" . $k;
##from_to($name_str, 'utf8', 'shiftjis');
##from_to($in{'wa_you_1'}, 'utf8', 'shiftjis');
##from_to($in{'wa_you_2'}, 'utf8', 'shiftjis');
$body .=<<"EOT";
|
| ($kana_str) |
EOT
$k++;
}
&access_log_set(1);
$out{'body'} = $body;
&out_enc;
&html_out('search_result.html');
}
#---------------------------------------
#
#---------------------------------------
sub view {
if (($in{'seq1'} eq '' && $in{'kime1'} eq "''") || ($in{'seq2'} eq '' && $in{'kime2'} eq "''") || ($in{'wa_you'} eq '' && $in{'wa_you_1'} eq '' && $in{'wa_you_2'} eq '') || $in{'sex'} eq ''){&name_err("パラメータが不正です。");}
# &in_enc;
# $in{'kime1'} = substr($in{'kime1'},1,-1);
#&name_err($in{'kime1'});
#詳細情報取得
if ($in{'wa_you'} eq 2 || $in{'wa_you_1'} eq 2 || $in{'wa_you_2'} eq 2){
$sword1 = 'spelling';
$sword2 = 'spelling';
if ($in{'wa_you_1'} eq 1){$sword1 = 'kana';}
if ($in{'wa_you_2'} eq 1){$sword2 = 'kana';}
}
else{
$sword1 = 'kana';
$sword2 = 'kana';
if ($in{'wa_you_1'} eq 2){$sword1 = 'spelling';}
if ($in{'wa_you_2'} eq 2){$sword2 = 'spelling';}
}
if ($in{'seq1'} ne ''){
$sql = "select word,$sword1 from name_master where no = $in{'seq1'};";
$ref = $dbh->selectall_arrayref($sql) or &name_err("エラーが発生しました。");
($in{'word1'},$spel2)=@{$ref->[0]};
}
elsif ($in{'kime1'} ne ''){$in{'word1'} = $in{'kime1'};}
if ($in{'seq2'} ne ''){
$sql = "select word,$sword2 from name_master where no = $in{'seq2'};";
$ref = $dbh->selectall_arrayref($sql) or &name_err("エラーが発生しました。");
($in{'word2'},$spel1)=@{$ref->[0]};
}
elsif ($in{'kime2'} ne ''){$in{'word2'} = $in{'kime2'};}
if ($spel1 eq ''){$spel1 = '―';}
if ($spel2 eq ''){$spel2 = '―';}
if ($in{'wa_you'} eq 2 || $in{'wa_you_1'} eq 2 || $in{'wa_you_2'} eq 2){
if ($spel1 eq '' && $spel2 eq ''){}
elsif ($spel1 eq '' || $spel2 eq ''){$kana_str = "$spel1$spel2";}
elsif ($spel1 ne '' && $spel2 ne ''){$kana_str = "$spel1 $spel2";}
}
else{
if ($spel1 eq '' && $spel2 eq ''){}
elsif ($spel1 eq '' || $spel2 eq ''){$kana_str = "$spel2$spel1";}
elsif ($spel1 ne '' && $spel2 ne ''){$kana_str = "$spel2 $spel1";}
}
$out{'kana_str'} = $kana_str;
#姓
#スペル・カナ・国
$nation_str = '';
$spell_str = '';
$kana_str = '';
# if ($in{'kime1'} eq ''){
$sql = "select nation,spelling,kana from name_master where word = '$in{'word1'}' and surname in (0,1) and ";
if ($in{'wa_you_1'} eq 1 || $in{'wa_you_1'} eq 2){$sql .= "wa_you in (0,$in{'wa_you_1'}) and ";}
elsif ($in{'wa_you'} eq 1 || $in{'wa_you'} eq 2){$sql .= "wa_you in (0,$in{'wa_you'}) and ";}
if ($in{'sex'} ne '' && $in{'sex'} ne 0){$sql .= "sex in (0,$in{'sex'}) and ";}
$sql .= "state = '0' group by nation,spelling,kana;";
$ref = $dbh->selectall_arrayref($sql) or &name_err("エラーが発生しました。".$dbh->errstr);
foreach(@$ref) {
($nation,$spelling,$kana)=@{$_};
if ($spelling ne ''){
$spell_str .= $spelling . $nation . '
';
}
if ($kana ne ''){
$kana_str .= $kana . $nation . '
';
}
}
$surname1_spell = $spell_str;
$surname1_kana = $kana_str;
#意味
$meen_str = '';
$sql = "select meen from name_master where word = '$in{'word1'}' and surname in (0,1) and ";
if ($in{'wa_you_1'} eq 1 || $in{'wa_you_1'} eq 2){$sql .= "wa_you in (0,$in{'wa_you_1'}) and ";}
elsif ($in{'wa_you'} eq 1 || $in{'wa_you'} eq 2){$sql .= "wa_you in (0,$in{'wa_you'}) and ";}
if ($in{'sex'} ne '' && $in{'sex'} ne 0){$sql .= "sex in (0,$in{'sex'}) and ";}
$sql .= "state = '0' group by meen;";
$ref = $dbh->selectall_arrayref($sql) or &name_err("エラーが発生しました。".$dbh->errstr);
foreach(@$ref) {
($meen)=@{$_};
if ($meen ne ''){
$meen_str .= $meen . "
";
}
}
$surname1_meen = $meen_str;
# }
#名
#スペル・カナ・国
$nation_str = '';
$spell_str = '';
$kana_str = '';
# if ($in{'kime2'} eq ''){
$sql = "select nation,spelling,kana from name_master where word = '$in{'word2'}' and surname in (0,2) and ";
if ($in{'wa_you_2'} eq 1 || $in{'wa_you_2'} eq 2){$sql .= "wa_you in (0,$in{'wa_you_2'}) and ";}
elsif ($in{'wa_you'} eq 1 || $in{'wa_you'} eq 2){$sql .= "wa_you in (0,$in{'wa_you'}) and ";}
if ($in{'sex'} ne '' && $in{'sex'} ne 0){$sql .= "sex in (0,$in{'sex'}) and ";}
$sql .= "state = '0' group by nation,spelling,kana;";
#&name_err($sql);
$ref = $dbh->selectall_arrayref($sql) or &name_err("エラーが発生しました。".$dbh->errstr);
foreach(@$ref) {
($nation,$spelling,$kana)=@{$_};
if ($spelling ne ''){
$spell_str .= $spelling . $nation . '
';
}
if ($kana ne ''){
$kana_str .= $kana . $nation . '
';
}
}
$surname2_spell = $spell_str;
$surname2_kana = $kana_str;
#意味
$meen_str = '';
$sql = "select meen from name_master where word = '$in{'word2'}' and surname in (0,2) and ";
if ($in{'wa_you_2'} eq 1 || $in{'wa_you_2'} eq 2){$sql .= "wa_you in (0,$in{'wa_you_2'}) and ";}
elsif ($in{'wa_you'} eq 1 || $in{'wa_you'} eq 2){$sql .= "wa_you in (0,$in{'wa_you'}) and ";}
if ($in{'sex'} ne '' && $in{'sex'} ne 0){$sql .= "sex in (0,$in{'sex'}) and ";}
$sql .= "state = '0' group by meen;";
$ref = $dbh->selectall_arrayref($sql) or &name_err("エラーが発生しました。".$dbh->errstr);
foreach(@$ref) {
($meen)=@{$_};
if ($meen ne ''){
$meen_str .= $meen . "
";
}
}
$surname2_meen = $meen_str;
# }
if ($in{'wa_you'} eq 2 || $in{'wa_you_1'} eq 2 || $in{'wa_you_2'} eq 2){
$name_str = "$in{'word2'}・$in{'word1'}";
if ($in{'wa_you'} eq 2 || $in{'wa_you_1'} eq 2){
$out{'spelling1'} = $surname1_spell;
}
else{
$out{'kana1'} = $surname1_kana;
}
if ($in{'wa_you'} eq 2 || $in{'wa_you_2'} eq 2){
$out{'spelling2'} = $surname2_spell;
}
else{
$out{'kana2'} = $surname2_kana;
}
}
else{
$name_str = "$in{'word1'} $in{'word2'}";
$out{'kana1'} = $surname1_kana;
$out{'kana2'} = $surname2_kana;
}
$out{'name_str'} = $name_str;
$out{'meen1'} = $surname1_meen;
$out{'meen2'} = $surname2_meen;
$out{'word1'} = $in{'word1'};
$out{'word2'} = $in{'word2'};
#使用宣言チェック
$sql = "select count(*) from declare_list where word1 = '$in{'word1'}' and word2 = '$in{'word2'}';";
$ref = $dbh->selectall_arrayref($sql) or &name_err("エラーが発生しました。");
($cnt)=@{$ref->[0]};
if ($cnt eq 0 || $cnt eq ''){
$out{'btn'} =<<"EOT";
EOT
}
$out{'seq1'} = $in{'seq1'};
$out{'seq2'} = $in{'seq2'};
$out{'sex'} = $in{'sex'};
$out{'wa_you'} = $in{'wa_you'};
$out{'wa_you_1'} = $in{'wa_you_1'};
$out{'wa_you_2'} = $in{'wa_you_2'};
$out{'kime1'} = $in{'kime1'};
$out{'kime2'} = $in{'kime2'};
# $sql = "select max(declare) from name_master where word = '$in{'word1'}' and surname in (0,1) and ";
# if ($in{'wa_you'} eq 0){$sql .= "wa_you in (0,2) and ";}
# if ($in{'wa_you'} eq 1){$sql .= "wa_you in (0,1) and ";}
# $sql .= "sex in (0,$in{'sex'}) and state = '0' group by nation,meen,spelling,kana;";
# $ref = $dbh->selectall_arrayref($sql) or &name_err("エラーが発生しました。");
# ($cnt)=@{$ref->[0]};
# if ($cnt > 0){
# $out{'body'} .=<<"EOT";
#
# 使用宣言されています。
#EOT
# }
# else{
# $out{'body'} .=<<"EOT";
#
#
#EOT
# }
&access_log_set(3);
&out_enc;
&html_out('search_result02.html');
}
#---------------------------------------
#
#---------------------------------------
sub declare_conf {
# if ($in{'word1'} eq ''){&name_err("「姓」が選択されていません。");}
# if ($in{'word2'} eq ''){&name_err("「名」が選択されていません。");}
if ($in{'seq1'} eq '' && $in{'kime1'} eq "''"){&name_err("「姓」が選択されていません。");}
if ($in{'seq2'} eq '' && $in{'kime2'} eq "''"){&name_err("「名」が選択されていません。");}
if ($in{'seq1'} ne ''){
$sql = "select word from name_master where no = $in{'seq1'};";
$ref = $dbh->selectall_arrayref($sql) or &name_err("エラーが発生しました。");
($in{'word1'})=@{$ref->[0]};
}
else{$in{'word1'} = $in{'kime1'};}
if ($in{'seq2'} ne ''){
$sql = "select word from name_master where no = $in{'seq2'};";
$ref = $dbh->selectall_arrayref($sql) or &name_err("エラーが発生しました。");
($in{'word2'})=@{$ref->[0]};
}
else{$in{'word2'} = $in{'kime2'};}
if ($in{'wa_you'} eq 2 || $in{'wa_you_1'} eq 2 || $in{'wa_you_2'} eq 2){$name_str = "$in{'word2'}・$in{'word1'}";}
# elsif ($in{'wa_you'} eq 1){$name_str = "$in{'word1'} $in{'word2'}";}
else{$name_str = "$in{'word1'} $in{'word2'}";}
$out{'name_str'} = $name_str;
$out{'seq1'} = $in{'seq1'};
$out{'seq2'} = $in{'seq2'};
$out{'sex'} = $in{'sex'};
$out{'wa_you'} = $in{'wa_you'};
$out{'wa_you_1'} = $in{'wa_you_1'};
$out{'wa_you_2'} = $in{'wa_you_2'};
$out{'kime1'} = $in{'kime1'};
$out{'kime2'} = $in{'kime2'};
# $out{'body'} =<<"EOT";
# 下記の名前で使用宣言しますが、よろしいでしょうか?
#
#$name_str
#
#
#EOT
&access_log_set(4);
&out_enc;
&html_out('search_result03.html');
}
#---------------------------------------
#
#---------------------------------------
sub declare_set {
# if ($in{'word1'} eq ''){&name_err("「姓」が選択されていません。");}
# if ($in{'word2'} eq ''){&name_err("「名」が選択されていません。");}
if ($in{'seq1'} eq '' && $in{'kime1'} eq "''"){&name_err("「姓」が選択されていません。");}
if ($in{'seq2'} eq '' && $in{'kime2'} eq "''"){&name_err("「名」が選択されていません。");}
if ($in{'seq1'} ne ''){
$sql = "select word from name_master where no = $in{'seq1'};";
$ref = $dbh->selectall_arrayref($sql) or &name_err("エラーが発生しました。");
($in{'word1'})=@{$ref->[0]};
}
else{$in{'word1'} = $in{'kime1'};}
if ($in{'seq2'} ne ''){
$sql = "select word from name_master where no = $in{'seq2'};";
$ref = $dbh->selectall_arrayref($sql) or &name_err("エラーが発生しました。");
($in{'word2'})=@{$ref->[0]};
}
else{$in{'word2'} = $in{'kime2'};}
$out{'word1'} = $in{'word1'};
$out{'word2'} = $in{'word2'};
if ($in{'wa_you'} eq 2 || $in{'wa_you_1'} eq 2 || $in{'wa_you_2'} eq 2){
$out{'name_str'} = "$in{'word2'}・$in{'word1'}";
$wayou = 2;
}
elsif ($in{'wa_you'} eq 1){
$out{'name_str'} = "$in{'word1'} $in{'word2'}";
$wayou = 1;
}
&in_enc;
$sql = "select count(*) from declare_list where word1 = '$in{'word1'}' and word2 = '$in{'word2'}';";
$ref = $dbh->selectall_arrayref($sql) or &name_err("エラーが発生しました。");
($cnt)=@{$ref->[0]};
if ($cnt eq ''){$cnt = 0;}
if ($cnt > 0){&name_err("指定された組み合わせは既に使用宣言されています。");}
# $sql = "update name_master set declare = 1,declare_ip = '$ip' where word = '$in{'word1'}' and surname in (0,1)";
# if ($in{'sex'} ne 0){$sql .= " and sex in (0,$in{'sex'})";}
# $sql .= " and wa_you in (0,$wa_you);";
# $dbh->do($sql) or &name_err("エラーが発生しました。");
# $sql = "update name_master set declare = 1,declare_ip = '$ip' where word = '$in{'word2'}' and surname in (0,2) ";
# if ($in{'sex'} ne 0){$sql .= " and sex in (0,$in{'sex'})";}
# $sql .= " and wa_you in (0,$wa_you);";
# $dbh->do($sql) or &name_err("エラーが発生しました。");
$sql = "insert into declare_list (word1,word2,wa_you,ip) values ('$in{'word1'}','$in{'word2'}',$wayou,'$ip');";
$dbh->do($sql) or &name_err("エラーが発生しました。");
&access_log_set(5);
&out_enc;
&html_out('declare_end.html');
}
#---------------------------------------
#
#---------------------------------------
sub usr_post {
&html_out('usr_post.html');
}
#---------------------------------------
#
#---------------------------------------
sub entry_conf {
if ($in{'selection_name'} eq ''){$err .= "「セレクション名」が入力されていません。
";}
elsif (length($in{'selection_name'}) > 40){$err .= "「セレクション名」は全角20字までです。
";}
elsif($in{'selection_name'} =~ /[0-9a-zA-Z]/){$err .= "「セレクション名」は全角文字で入力してください。
";}
elsif ($in{'selection_name'} =~ /[!\"\#\$\%\&\'\(\)\=\^\~\\\|\@\`\[\{\]\}\+\;\:\*\<\,\.\>\/\?\_]/ ){$err .= "「セレクション名」は全角文字で入力してください。
";}
if ($in{'password'} eq ''){&name_err("「パスワード」が入力されていません。");}
elsif (length($in{'password'}) ne 8){&name_err("「パスワード」を半角8字入力してください。");}
if ($in{'word'} eq ''){&name_err("「投稿名」が入力されていません。");}
elsif (length($in{'word'}) > 24){$err .= "「投稿名」は全角12字までです。
";}
elsif($in{'word'} =~ /[0-9a-zA-Z]/){$err .= "「投稿名」は全角文字で入力してください。
";}
if ($in{'kana'} ne ''){
if (length($in{'kana'}) > 24){$err .= "「フリガナ」は全角12字までです。
";}
elsif($in{'kana'} =~ /[0-9a-zA-Z]/){$err .= "「フリガナ」は全角文字で入力してください。
";}
}
if ($in{'surname'} eq ''){$err .= "「名字・名前」が選択されていません。
";}
if ($in{'sex'} eq ''){$err .= "「男性・女性」が選択されていません。
";}
if ($in{'wa_you'} eq ''){$err .= "「和名・洋名」が選択されていません。
";}
if ($err ne ''){&name_err($err);}
&html_out('entry_conf.html');
}
sub dataset {
$x=0;
for($i=0;$i<100;$i++){
$sql = "select no,wa_you2 from name_master where wa_you is null order by no limit 100;";
$ref = $dbh->selectall_arrayref($sql) or &admin_err("エラーが発生しました。");
foreach(@$ref) {
($no,$wa_you2)=@{$_};
$sql2 = "update name_master set wa_you = $wa_you2 where no = $no;";
$dbh->do($sql2) or &name_err("エラーが発生しました。$sql2");
$x++;
}
}
$sql = "select count(*) from name_master where wa_you is null;";
$ref = $dbh->selectall_arrayref($sql) or &name_err("エラーが発生しました。$sql");
($y)=@{$ref->[0]};
&name_err("処理:$x件
残り:$y件");
}
#---------------------------------------
#
#---------------------------------------
sub access_log_set {
my $aid = $_[0];
$sql = "insert into access_log (id,ip,host) values ($aid,'$ip','$host');";
$dbh->do($sql) or &name_err("エラーが発生しました。");
}