#!/usr/bin/perl
require '/home/rexi-jp/public_html/jj/lib/lib.pl';
$mycgi = 'mypage_gallery.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'};
$id = $ENV{'REMOTE_USER'};
$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;
$out{'pcid'} = $pcid;
$dbh = &connectDB($mainDB);
$out{'rex'} = &get_rex($pcid);
if ($in{'mode'} eq ''){
&list;
}
elsif ($in{'mode'} eq 'detailed'){
&detailed;
}
elsif ($in{'mode'} eq 'setting'){
&setting;
}
elsif ($in{'mode'} eq 'setdata'){
&setdata;
}
elsif ($in{'mode'} eq 'comment_input'){
&comment_input;
}
elsif ($in{'mode'} eq 'comment_set'){
&comment_set;
}
elsif ($in{'mode'} eq 'zensin_setting'){
&zensin_setting;
}
elsif ($in{'mode'} eq 'zensin_set'){
&zensin_set;
}
else{
&mypage_err("不正なパラメータ");
}
&disconDB($dbh);
exit;
#---------------------------------------
# エラー
#---------------------------------------
sub mypage_err {
$out{'err'} = $_[0];
$Ret = &Jcode::getcode( $out{'err'} ) ;
if ($Ret eq 'euc'){
&Jcode::convert(\$out{'err'},'sjis');
}
open FILE,"mypage_err.html";
print $header;
while(){
s/!(\w+)!/$out{$1}/g;
print;
}
close FILE;
exit;
}
#---------------------------------------
# HTML出力
#---------------------------------------
sub html_out {
$out{'body'} = $_[0];
$file = $_[1];
$Ret = &Jcode::getcode( $out{'body'} ) ;
if ($Ret eq 'euc'){
&Jcode::convert(\$out{'body'},'sjis');
}
open FILE,$file;
print $header;
while(){
s/!(\w+)!/$out{$1}/g;
print;
}
close FILE;
exit;
}
#---------------------------------------
# 一覧
#---------------------------------------
sub list {
if ($in{'pcid'} eq ''){$in{'pcid'} = $pcid;}
$sql = "select pdname,crname,file_name,substr(reg_date,1,10) from stars_data where pcid = '$in{'pcid'}' order by reg_date;";
$ref = $dbh->selectall_arrayref($sql) or &mypage_err("エラーが発生しました。");
$out{'list'} =<<"EOT";
EOT
$i = 1;
foreach(@$ref) {
($pdname,$crname,$file_name,$reg_date)=@{$_};
($format,$width,$height) = &GetImageSize("/home/rexi-jp/public_html/stars/data/jj/$file_name");
if ($width < 100 && $height < 100){$th_file = "http://rexi.jp/stars/data/jj/$file_name";}
else{$th_file = "http://rexi.jp/stars/data/jj_thumbnail/$file_name"}
if ($i eq 0){
$out{'list'} .=<<"EOT";
EOT
}
$out{'list'} .=<<"EOT";
|
$crname |
$reg_date |
|
EOT
if ($i eq 6){
$out{'list'} .=<<"EOT";
EOT
$i = 0;
}
$i++;
}
$out{'list'} .=<<"EOT";
EOT
&out_enc;
&html_out($body,'mypage_gallery02.html');
}
#---------------------------------------
# 詳細
#---------------------------------------
sub detailed {
$sql = "select pdname,crname,substr(reg_date,1,10),plural_pcid from stars_data where file_name = '$in{'file'}' order by reg_date;";
$ref = $dbh->selectall_arrayref($sql) or &mypage_err("エラーが発生しました。");
($out{'pdname'},$out{'crname'},$out{'reg_date'},$plural_pcid)=@{$ref->[0]};
$out{'img'} = "http://rexi.jp/stars/data/jj/$in{'file'}";
$out{'reg_date'} =~ s/\-/\//g;
if ($plural_pcid ne ''){
@mem_pcid = split(/\,/,$plural_pcid);
@mem_pcid = sort @mem_pcid;
foreach (@mem_pcid){
$mpcid = $_;
$sql = "select name1,name3 from character where pcid = '$mpcid';";
$ref = $dbh->selectall_arrayref($sql) or &mypage_err("エラーが発生しました。");
($m_name1,$m_name3)=@{$ref->[0]};
$mem .= "$mpcid $m_name1/$m_name3
";
}
}
if ($mem ne ''){
$out{'member'} = <<"EOT";
参加キャラクター:
$mem
EOT
}
&out_enc;
&html_out($body,'mypage_gallery03.html');
}
#---------------------------------------
# コメント入力
#---------------------------------------
sub comment_input {
$sql = "select pdname,crname,comment,substr(reg_date,1,10) from stars_data where file_name = '$in{'file'}' and pcid = '$pcid';";
$ref = $dbh->selectall_arrayref($sql) or &mypage_err("エラーが発生しました。");
($out{'pdname'},$out{'crname'},$out{'comment'},$out{'reg_date'})=@{$ref->[0]};
if ($out{'pdname'} eq ''){&mypage_err("指定されたイラストは、現在ログインしているキャラクターの所有ではありません。");}
$out{'img'} = "http://rexi.jp/stars/data/jj/$in{'file'}";
$out{'reg_date'} =~ s/\-/\//g;
$out{'file'} = $in{'file'};
&out_enc;
&html_out($body,'mypage_gallery04.html');
}
#---------------------------------------
# コメント設定
#---------------------------------------
sub comment_set {
&in_enc;
$len = length ($in{'comment'});
if ($len > 100){&mypage_err("コメントは全角50字までです。");}
$in{'comment'} =~ s/\'/\\'/g;
$sql = "update stars_data set comment = ";
if ($in{'comment'} eq ''){$sql .= "NULL";}
else{$sql .= "'$in{'comment'}'";}
$sql .= " where pcid = '$pcid' and file_name = '$in{'file'}';";
$dbh->do($sql) or &mypage_err("エラーが発生しました。");
print "Location: ./mypage.cgi?pcid=$pcid&mode=gallery\n\n";
}
#---------------------------------------
# 設定
#---------------------------------------
sub setting {
$sql = "select bustup1,bustup2,standard_bustup from character where pcid = '$pcid';";
$ref = $dbh->selectall_arrayref($sql) or &mypage_err("エラーが発生しました。");
($out{'bustup1'},$out{'bustup2'},$out{'standard_bustup'})=@{$ref->[0]};
if ($out{'bustup1'} eq '' || $out{'bustup1'} eq "http://rexi.jp/jj/images/mypage_bu_defalt.gif"){$out{'bustup1'} = "http://rexi.jp/jj/images/mypage_bu_defalt.gif";}
else{
@a = ();
@a = split(/\//, $out{'bustup1'});
$max_a = $#a;
$out{'bustup1'} = "http://rexi.jp/jj/bustup_thumbnail/" . @a[$max_a];
}
if ($out{'bustup2'} eq '' || $out{'bustup2'} eq "http://rexi.jp/jj/images/mypage_bu_defalt.gif"){$out{'bustup2'} = "http://rexi.jp/jj/images/mypage_bu_defalt.gif";}
else{
@a = ();
@a = split(/\//, $out{'bustup2'});
$max_a = $#a;
$out{'bustup2'} = "http://rexi.jp/jj/bustup_thumbnail/" . @a[$max_a];
}
if ($out{'standard_bustup'} eq '' || $out{'standard_bustup'} eq "http://rexi.jp/jj/images/mypage_bu_defalt.gif"){$out{'standard_bustup'} = "http://rexi.jp/jj/images/mypage_bu_defalt.gif";}
else{
@a = ();
@a = split(/\//, $out{'standard_bustup'});
$max_a = $#a;
$out{'standard_bustup'} = "http://rexi.jp/jj/bustup_thumbnail/" . @a[$max_a];
}
$out{'list1'} =<<"EOT";
|
EOT
$out{'list2'} =<<"EOT";
|
EOT
$out{'list3'} =<<"EOT";
|
EOT
$sql = "select crname,url from stars_data where pcid = '$pcid' and pdid in ('C01','C10') order by reg_date;";
$ref = $dbh->selectall_arrayref($sql) or &mypage_err("エラーが発生しました。");
$i = 1;
foreach(@$ref) {
($crname,$url)=@{$_};
@a = ();
@a = split(/\//, $url);
$max_a = $#a;
# $thm = "http://rexi.jp/jj/bustup_thumbnail/" . @a[$max_a];
$thm = "http://rexi.jp/stars/data/jj_thumbnail/" . @a[$max_a];
if ($i eq 0){
$out{'list1'} .=<<"EOT";
EOT
$out{'list2'} .=<<"EOT";
EOT
$out{'list3'} .=<<"EOT";
EOT
}
$out{'list1'} .=<<"EOT";
|
EOT
$out{'list2'} .=<<"EOT";
|
EOT
$out{'list3'} .=<<"EOT";
|
EOT
$i++;
if ($i eq 7){
$out{'list1'} .=<<"EOT";
EOT
$out{'list2'} .=<<"EOT";
EOT
$out{'list3'} .=<<"EOT";
EOT
$i = 0;
}
}
$out{'list1'} .=<<"EOT";
EOT
$out{'list2'} .=<<"EOT";
EOT
$out{'list3'} .=<<"EOT";
EOT
&out_enc;
&html_out($body,'mypage_gallery01.html');
}
#---------------------------------------
#
#---------------------------------------
sub setdata {
if ($in{'setbust1'} eq ''){&mypage_err("人間時の姿が選択されていません。");}
if ($in{'setbust2'} eq ''){&mypage_err("変身後の姿が選択されていません。");}
if ($in{'setbust3'} eq ''){&mypage_err("ログインバストアップが選択されていません。");}
$sql = "update character set bustup1 = '$in{'setbust1'}',bustup2 = '$in{'setbust2'}',standard_bustup = '$in{'setbust3'}' where pcid = '$pcid';";
$dbh->do($sql) or &mypage_err("エラーが発生しました。");
print "Location: ./mypage.cgi\n\n";
}
#---------------------------------------
# 透過全身図設定
#---------------------------------------
sub zensin_setting {
$sql = "select zensin,zensin2,zensin_switch,zensin_chat from character where pcid = '$pcid';";
$ref = $dbh->selectall_arrayref($sql) or &mypage_err("エラーが発生しました。");
($zensin,$zensin2,$zensin_switch,$zensin_chat)=@{$ref->[0]};
$i = 0;
$sql = "select crname,url from stars_data where pcid = '$pcid' and pdid in ('J05','C16') order by reg_date;";
$ref = $dbh->selectall_arrayref($sql) or &mypage_err("エラーが発生しました。");
foreach(@$ref) {
($crname,$url)=@{$_};
$checked1 = '';
$checked2 = '';
if ($url eq $zensin){$checked1 = "checked";}
if ($url eq $zensin2){$checked2 = "checked";}
if ($url eq $zensin_chat){$checked3 = "checked";}
if ($i eq 0){
$out{'zensin_list1'} .=<<"EOT";
EOT
$out{'zensin_list2'} .=<<"EOT";
EOT
$out{'zensin_list3'} .=<<"EOT";
EOT
}
$out{'zensin_list1'} .=<<"EOT";
|
EOT
$out{'zensin_list2'} .=<<"EOT";
|
EOT
$out{'zensin_list3'} .=<<"EOT";
|
EOT
$i++;
if ($i eq 4){
$out{'zensin_list1'} .=<<"EOT";
EOT
$out{'zensin_list2'} .=<<"EOT";
EOT
$out{'zensin_list3'} .=<<"EOT";
EOT
$i = 0;
}
}
$out{'zensin_list1'} =<<"EOT";
EOT
$out{'zensin_list2'} =<<"EOT";
EOT
$out{'zensin_list3'} =<<"EOT";
EOT
&out_enc;
&html_out($body,'mypage_zensin01.html');
}
#---------------------------------------
# 透過全身図設定
#---------------------------------------
sub zensin_set {
if ($in{'switch'} eq ''){&mypage_err("表示設定が選択されていません。");}
# if ($in{'switch'} eq 1 && ($in{'zensin1'} eq '' || $in{'zensin2'} eq '' || $in{'zensin3'} eq '')){&mypage_err("透過全身図が選択されていません。");}
if ($in{'switch'} eq 1 && ($in{'zensin1'} eq '' || $in{'zensin2'} eq '')){&mypage_err("透過全身図が選択されていません。");}
if ($in{'switch'} eq 1){
$sql = "update character set zensin = '$in{'zensin1'}',zensin2 = '$in{'zensin2'}',zensin_chat = '$in{'zensin3'}',zensin_switch = 1 where pcid = '$pcid';";
}
else{
$sql = "update character set zensin_switch = 0 where pcid = '$pcid';";
}
$dbh->do($sql) or &mypage_err("エラーが発生しました。");
print "Location: ./mypage.cgi\n\n";
}