#!/usr/bin/perl
$lib_db_flg = 1;
require '/home/rexi-jp/public_html/jj/lib/lib.pl';
$mycgi = 'event.cgi';
use CGI;
use CGI::Carp qw(fatalsToBrowser);
$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'};
$query = CGI->new;
my @params = $query->param();#全てのパラメータ名を取得 なのでこれを$inにしてしまえば$inで使用可能
foreach my $param (@params) {
$in{$param} = $query->param($param);
}
$uid = &get_usr_cookie;
$pcid = &get_pcid_cookie;
$dbh = &connectDB($mainDB);
#&death_check($pcid,$dbh,1);
&in_enc;
%out = %in;
$out{'pdname'} = '透過全身図';
if ($in{'no'} eq 1){
$out{'title'} = 'パーティコン';
if ($in{'type'} eq 1){$out{'title'} .= '紳士部門';}
if ($in{'type'} eq 2){$out{'title'} .= '淑女部門';}
if ($in{'type'} eq 3){$out{'title'} .= 'ピエロ部門';}
}
elsif ($in{'no'} eq 2){
$out{'title'} = 'ファイナルフォームコンテスト';
if ($in{'type'} eq 1){$out{'title'} .= '最強部門';}
if ($in{'type'} eq 2){$out{'title'} .= '最兇部門';}
if ($in{'type'} eq 3){$out{'title'} .= '最Cute部門';}
}
elsif ($in{'no'} eq 3){
$out{'title'} = 'J&J記念集合イラスト企画';
}
&date_rtn;
if ($in{'mode'} eq 'entry'){
&entry;
}
elsif ($in{'mode'} eq 'entry_conf'){
&entry_conf;
}
elsif ($in{'mode'} eq 'entry_exe'){
&entry_exe;
}
elsif ($in{'mode'} eq 'list'){
&list;
}
elsif ($in{'mode'} eq 'poll_list'){
&poll_list;
}
elsif ($in{'mode'} eq 'poll_conf'){
&poll_conf;
}
elsif ($in{'mode'} eq 'poll_reg'){
&poll_reg;
}
elsif ($in{'mode'} eq 'roll_list'){
&roll_list;
}
else{
&err("不正なパラメータ");
}
&disconDB($dbh);
exit;
#---------------------------------------
# ロール一覧
#---------------------------------------
sub roll_list {
$cnt = 0;
$sql = "select pcid,name1 || '/' || name2,url,file_name,comment from contest_entry where no = $in{'no'}";
if ($in{'type'} ne ''){$sql .= " and type = $in{'type'}";}
$sql .= " and state = 0 order by reg_date;";
$ref = $dbh->selectall_arrayref($sql) or $err=1;
foreach(@$ref) {
($epcid,$ename,$url,$file_name,$comment)=@{$_};
$cnt++;
$n_file = "/home/rexi-jp/public_html/" . substr($url,15);
$t_file = "/home/rexi-jp/public_html/gx/event/con_thumbnail/" . $file_name;
if (!-e $t_file){
system "convert -resize x400 +profile iptc -quality 100 $n_file $t_file";
}
$s_file = "../../gx/event/con_thumbnail/$file_name";
($format,$width,$height) = &GetImageSize($s_file);
$body .=<<"EOT";
EOT
}
if ($in{'no'} eq 1){
$dbh_gx = &connectDB('gx');
$sql2 = "select pcid,name,url,file_name,comment from contest_entry where no = 5";
if ($in{'type'} ne '' && $in{'type'} > 0){$sql2 .= " and type = $in{'type'}";}
$sql2 .= " order by reg_date;";
$ref2 = $dbh_gx->selectall_arrayref($sql2) or $err=1;
foreach(@$ref2) {
($epcid,$ename,$url,$file_name,$comment)=@{$_};
$cnt++;
$n_file = "/home/rexi-jp/public_html/" . substr($url,15);
$t_file = "/home/rexi-jp/public_html/gx/event/con_thumbnail/" . $file_name;
if (!-e $t_file){
system "convert -resize x400 +profile iptc -quality 100 $n_file $t_file";
}
$s_file = "../../gx/event/con_thumbnail/$file_name";
($format,$width,$height) = &GetImageSize($s_file);
$body .=<<"EOT";
EOT
}
&disconDB($dbh_gx);
}
chomp $body;
# if ($body eq ''){exit;}
$body =<<"EOT";
$body
EOT
$c = int($cnt / 2);
if (($cnt / 2) > $c){$c++;}
if ($c < 2){$c=2;}
$out{'cnt'} = $c;
$out{'body'} = $body;
if ($in{'iframe'} eq 1){$htmlfile = "event_entry_roll2.html";}
else{$htmlfile = "event_entry_roll.html";}
&out_enc;
&html_out($htmlfile);
}
#---------------------------------------
# ミスコンエントリー
#---------------------------------------
sub entry {
if ($pcid eq ''){&err("このコンテンツはキャラクターを選択していないとご利用できません。");}
if ($in{'no'} eq ''){&err("開催回数が選択されていません。");}
if ($in{'no'} eq 1 && $in{'type'} eq ''){&err("エントリータイプが指定されていません。");}
$sql = "select count(*) from contest_entry where no = $in{'no'} and pcid = '$pcid'";
if ($in{'type'} ne '' && $in{'type'} > 0){$sql .= " and type = $in{'type'}";}
$sql .= ";";
$ref = $dbh->selectall_arrayref($sql) or &err("CODE:S-01
エラーが発生しました。");
($cnt)=@{$ref->[0]};
# if ($cnt ne '' && $cnt > 0){&err("エントリー済みの為、新たにエントリーできません。");}
if ($in{'no'} >= 1){$where = "and pdid in ('J05','C14','C16')";}
$i = 0;
# $sql = "select file_name,url from stars_data where pcid = '$pcid' $where and crid != 'rexi' and state = 0 order by reg_date desc;";
$sql = "select file_name,url from stars_data where pcid = '$pcid' $where and crid != 'rexi' order by reg_date desc;";
$ref = $dbh->selectall_arrayref($sql) or &err("CODE:S-02
エラーが発生しました。");
foreach(@$ref) {
($file_name,$url)=@{$_};
# if ($in{'no'} eq 4 && $in{'type'} eq 3){
# $th_url = "../../stars/data/jj/$file_name";
# $w = 50;
# $h = 50;
# }
# else{
$th_url = "../../stars/data/jj_thumbnail/$file_name";
$w = 50;
$h = 100;
($format,$w,$h) = &GetImageSize($th_url);
# }
if ($i eq 0){
$out{'body'} .=<<"EOT";
EOT
}
$sql2 = "select count(*) from contest_entry where no = $in{'no'} and pcid = '$pcid' and url = '$url';";
$ref2 = $dbh->selectall_arrayref($sql2) or &err("CODE:S-01
エラーが発生しました。");
($cnt)=@{$ref2->[0]};
if ($cnt ne '' && $cnt > 0){$opt = "×";}
else{
$opt =<<"EOT";
EOT
}
$out{'body'} .=<<"EOT";
|
$opt |
|
EOT
$i++;
if ($i >= 5){
$out{'body'} .=<<"EOT";
EOT
$i = 0;
}
}
&out_enc;
&html_out("event_entry01.html");
}
#---------------------------------------
# ミスコンエントリー確認
#---------------------------------------
sub entry_conf {
if ($pcid eq ''){&err("このコンテンツはキャラクターを選択していないとご利用できません。");}
if ($in{'no'} eq ''){&err("開催回数が選択されていません。");}
if ($in{'no'} eq 1 && $in{'type'} eq ''){&err("エントリータイプが指定されていません。");}
$sql = "select count(*) from contest_entry where no = $in{'no'} and pcid = '$pcid'";
if ($in{'type'} ne '' && $in{'type'} > 0){$sql .= " and type = $in{'type'}";}
$sql .= ";";
$ref = $dbh->selectall_arrayref($sql) or &err("CODE:S-01
エラーが発生しました。");
($cnt)=@{$ref->[0]};
# if ($cnt ne '' && $cnt > 0){&err("エントリー済みの為、新たにエントリーできません。");}
if (length($in{'comment'}) > 60){&err("エントリーコメントは全角30字までです。");}
if ($in{'no'} >= 1){$where = "and pdid in ('J05','C14','C16')";}
$sql = "select file_name,url from stars_data where pcid = '$pcid' $where and url = '$in{'con_entry'}';";
$ref = $dbh->selectall_arrayref($sql) or &err("CODE:S-01
エラーが発生しました。");
($file_name,$url)=@{$ref->[0]};
if ($file_name eq ''){&err("指定されたイラストは現在ログインされているキャラクターのイラストではありません。");}
$out{'zensin'} = $url;
($format,$out{'w'},$out{'h'}) = &GetImageSize("/home/rexi-jp/public_html/stars/data/jj/$file_name");
&out_enc;
&html_out("event_entry02.html");
}
#---------------------------------------
# ミスコンエントリー実行
#---------------------------------------
sub entry_exe {
if ($pcid eq ''){&err("このコンテンツはキャラクターを選択していないとご利用できません。");}
if ($in{'no'} eq ''){&err("開催回数が選択されていません。");}
if ($in{'no'} eq 1 && $in{'type'} eq ''){&err("エントリータイプが指定されていません。");}
$sql = "select count(*) from contest_entry where no = $in{'no'} and pcid = '$pcid'";
if ($in{'type'} ne '' && $in{'type'} > 0){$sql .= " and type = $in{'type'}";}
$sql .= ";";
$ref = $dbh->selectall_arrayref($sql) or &err("CODE:S-01
エラーが発生しました。");
($cnt)=@{$ref->[0]};
# if ($cnt ne '' && $cnt > 0){&err("エントリー済みの為、新たにエントリーできません。");}
if (length($in{'comment'}) > 60){&err("エントリーコメントは全角30字までです。");}
if ($in{'no'} eq 1){
$where = "and pdid = 'J05'";
}
$sql = "select file_name,url from stars_data where pcid = '$pcid' $where and url = '$in{'url'}';";
$ref = $dbh->selectall_arrayref($sql) or &err("CODE:S-02
エラーが発生しました。");
($file_name,$url)=@{$ref->[0]};
if ($file_name eq ''){&err("指定されたイラストは現在ログインされているキャラクターのイラストではありません。");}
$sql = "select name1,name3,class,birth,sex,attribute from character where pcid = '$pcid';";
$ref = $dbh->selectall_arrayref($sql) or &err("エラーが発生しました。");
($name1,$name3,$class,$birth,$sex,$attribute)=@{$ref->[0]};
if ($in{'type'} eq ''){$in{'type'} = 0;}
$sql = "insert into contest_entry (no,pcid,name1,name2,class,birth,sex,attribute,file_name,url,comment,type) values ($in{'no'},'$pcid','$name1','$name3',$class";
if ($birth eq ''){$sql .= ",NULL";}
else{$sql .= ",$birth";}
$sql .= ",$sex,$attribute,'$file_name','$url','$in{'comment'}',$in{'type'});";
# $dbh->do($sql) or &err("CODE:RE-04
エラーが発生しました。
$sql
".$dbh->errstr);
$dbh->do($sql) or &err("CODE:RE-04
エラーが発生しました。");
print "Location: ./event_entry_end.html\n\n";
}
#---------------------------------------
# エントリー一覧
#---------------------------------------
sub list {
if ($in{'no'} eq ''){&err("開催回数が選択されていません。");}
if ($in{'no'} eq 1 && $in{'type'} eq ''){&err("エントリータイプが指定されていません。");}
$i1 = 0;
$i2 = 0;
$i = 0;
$sql = "select pcid,name2 || '/' || name1,class,birth,sex,attribute,file_name,url,comment from contest_entry where no = $in{'no'}";
if ($in{'type'} ne '' && $in{'type'} > 0){$sql .= " and type = $in{'type'}";}
$sql .= " order by reg_date;";
$ref = $dbh->selectall_arrayref($sql) or &err("エラーが発生しました。");
foreach(@$ref) {
($epcid,$ename,$class,$birth,$sex,$attribute,$file_name,$url,$comment)=@{$_};
$th_url = "../../stars/data/jj_thumbnail/$file_name";
$ma_url = "../../stars/data/jj/$file_name";
$bdn = 'body';
if ($i eq 0){
$out{$bdn} .=<<"EOT";
EOT
}
if (!-e $th_url){$th_url = $ma_url;}
($format,$width,$height) = &GetImageSize($th_url);
$out{$bdn} .=<<"EOT";
|
$epcid |
$ename |
@atb_str2[$attribute] |
@class_str2[$class] |
$comment |
|
EOT
if ($in{'mode2'} eq 'all'){
$bdn = 'list';
($format,$width,$height) = &GetImageSize("/home/rexi-jp/public_html/stars/data/jj/$file_name");
$out{$bdn} .=<<"EOT";
EOT
}
if ($sex eq 1){$i1++;}
elsif ($sex eq 2){$i2++;}
$i++;
if ($i >= 4){
$out{'body'} .=<<"EOT";
EOT
$i = 0;
}
}
if ($in{'no'} eq 1){
@class_str = ('?'
,'ヴォルセルク' #1
,'キュベレー' #2
,'パドマ' #3
,'ホーキポーキ' #4
);
@standpoint_str = ('?'
,'1年生' #1
,'2年生' #2
,'3年生' #3
,'4年生' #4
,'教師' #5
,'その他' #6
);
$dbh_gx = &connectDB('gx');
$sql2 = "select pcid,name,race,class,birth,sex,lumina,file_name,url,standpoint,comment from contest_entry where no = 5";
if ($in{'type'} ne '' && $in{'type'} > 0){$sql2 .= " and type = $in{'type'}";}
$sql2 .= " order by reg_date;";
$ref2 = $dbh_gx->selectall_arrayref($sql2) or &err("エラーが発生しました。");
foreach(@$ref2) {
($epcid,$ename,undef,$class,$birth,$sex,undef,$file_name,$url,$standpoint,$comment)=@{$_};
$th_url = "../../stars/data/gx_thumbnail/$file_name";
$ma_url = "../../stars/data/gx/$file_name";
$bdn = 'body';
if ($i eq 0){
$out{$bdn} .=<<"EOT";
EOT
}
if (!-e $th_url){$th_url = $ma_url;}
($format,$width,$height) = &GetImageSize($th_url);
$out{$bdn} .=<<"EOT";
|
$epcid |
$ename |
@standpoint_str[$standpoint] |
@class_str[$class] |
$comment |
|
EOT
if ($in{'mode2'} eq 'all'){
$bdn = 'list';
($format,$width,$height) = &GetImageSize("/home/rexi-jp/public_html/stars/data/jj/$file_name");
$out{$bdn} .=<<"EOT";
EOT
}
if ($sex eq 1){$i1++;}
elsif ($sex eq 2){$i2++;}
$i++;
if ($i >= 4){
$out{'body'} .=<<"EOT";
EOT
$i = 0;
}
}
&disconDB($dbh_gx);
}
if ($in{'mode2'} eq ''){$htmlfile = 'event_entry_deflist.html';}
elsif ($in{'mode2'} eq 'all'){
$htmlfile = 'event_entry_list2.html';
}
&out_enc;
&html_out($htmlfile);
}
#---------------------------------------
# 投票一覧
#---------------------------------------
sub poll_list {
if ($in{'no'} eq 1){
if ("$g_year$g_mon$g_mday$g_hour$g_min" > "201001050000"){&err("投票期間を過ぎています。");}
$html_file = "event_poll01_gi05.html";
}
elsif ($in{'no'} eq 2){
if ("$g_year$g_mon$g_mday$g_hour$g_min" >= "201101180000"){&err("投票期間を過ぎています。");}
$html_file = "event_poll01_gi10.html";
}
else{&err("不正なパラメーター");}
if ($pcid eq ''){&err("このコンテンツはキャラクターを選択していないとご利用できません。");}
$sql = "select pcid,name2 || '/' || name1,class,birth,sex,attribute,file_name,url,comment,type from contest_entry where no = $in{'no'} order by reg_date;";
$ref = $dbh->selectall_arrayref($sql) or &err("エラーが発生しました。");
foreach(@$ref) {
($epcid,$ename,$class,undef,$sex,$attribute,$file_name,$url,$comment,$type)=@{$_};
$th_url = "../../stars/data/jj_thumbnail/$file_name";
$ma_url = "../../stars/data/jj/$file_name";
if ($in{'no'} eq 1){
$hname1 = 'list' . $type;
$hname2 = 'ary' . $type;
$out{$hname1} .=<<"EOT";