){
s/!(\w+)!/$out{$1}/g;
print;
}
close FILE;
exit;
}
#---------------------------------------
# DEL表示
#---------------------------------------
sub del1 {
if ($in{'id'} eq ''){&stars_err("パラメーターエラー。");}
if ($in{'no'} eq ''){&stars_err("パラメーターエラー。");}
if ($in{'pcid'} eq ''){&stars_err("パラメーターエラー。");}
$sql = "select name from character where pcid = '$in{'pcid'}';";
if(substr($in{'pcid'} ,0,1) eq 'x'){
$game = 'gx';
$ref = $dbh->selectall_arrayref($sql) or &stars_err("CODE:B-012
エラーが発生しました。");
($nm)=@{$ref->[0]};
}elsif(substr($in{'pcid'} ,0,1) eq 's'){
$game = 'si';
($nm) = &si_rtn_db_data('select_line',$sql,'si');
}
$out{'name'} = $nm;
$sql = "select file_name,reg_date ,comment,url from borrowed where pcid = '$in{'pcid'}' and no= $in{'no'} and id = $in{'id'} ;";
$ref = $dbh->selectall_arrayref($sql) or &stars_err("CODE:B-012
エラーが発生しました。");
($file_name,$out{'reg_date'} ,$out{'comment'},$f_url)=@{$ref->[0]};
##
if($file_name ne 'url'){
$out{'fname2'} = "http://rexi.jp/karimono/borrowed/$in{'id'}/".$file_name;
}else{
$out{'fname2'} = $f_url;
}
if ($flg_smartphone ne 1){
$html_file = "borrowed_del.html";
}else{
$html_file = "borrowed_del_sp.html";
}
&out_enc;
&html_out($html_file);
}
#---------------------------------------
# DEL表示
#---------------------------------------
sub del2 {
if ($in{'id'} eq ''){&stars_err("パラメーターエラー。");}
if ($in{'no'} eq ''){&stars_err("パラメーターエラー。");}
if ($in{'pcid'} eq ''){&stars_err("パラメーターエラー。");}
$sql = "delete from borrowed where pcid = '$in{'pcid'}' and no= $in{'no'} and id =$in{'id'};";
$dbh->do($sql) or &stars_err("エラーが発生しました。
".$dbh->errstr);
($file_name,$out{'reg_date'} ,$out{'comment'})=@{$ref->[0]};
$out{'fname2'} = "http://rexi.jp/karimono/borrowed/$in{'pcid'}/".$file_name;
if ($flg_smartphone ne 1){
$html_file = "borrowed_end.html";
}else{
$html_file = "borrowed_end_sp.html";
}
&out_enc;
&html_out($html_file);
}
#---------------------------------------
# TOP表示
#---------------------------------------
sub top {
# if ($uid eq ''){&stars_err("このサービスはログインしないと利用できません。");}
$num = 0;
$prv_id = '';
$idx = 0;
## $sql = "select a.id,a.file_name,a.comment,a.pcid,b.name,a.upd_date from borrowed a,character b where a.no = 2 and a.pcid = b.pcid order by a.id,a.upd_date;";
## $ref = $dbh->selectall_arrayref($sql) or &stars_err("CODE:B-01
エラーが発生しました。");
## foreach(@$ref) {
## ($id,$file_name,$comment,$fpcid,$nm,$upd_date)=@{$_};
## $hash_id{$idx} = $id;
## $hash_file_name{$idx} = $file_name;
## $hash_comment{$idx} = $comment;
## $hash_fpcid{$idx} = $fpcid;
## $hash_nm{$idx} = $nm;
## $hash_upd_date{$idx} = $upd_date;
## $hash_game{$idx} = 'gx';
## $idx++;
## }
## $dbh_jj = &connectDB('jj');
## $sql = "select a.id,a.file_name,a.comment,a.pcid,b.name3 || '/' || b.name1,a.upd_date from borrowed a,character b where a.no = 3 and a.pcid = b.pcid order by a.id,a.upd_date;";
## $ref = $dbh_jj->selectall_arrayref($sql) or &stars_err("CODE:B-01
エラーが発生しました。");
## foreach(@$ref) {
## ($id,$file_name,$comment,$fpcid,$nm,$upd_date)=@{$_};
## $hash_id{$idx} = $id;
## $hash_file_name{$idx} = $file_name;
## $hash_comment{$idx} = $comment;
## $hash_fpcid{$idx} = $fpcid;
## $hash_nm{$idx} = $nm;
## $hash_upd_date{$idx} = $upd_date;
## $hash_game{$idx} = 'jj';
## $idx++;
## }
## @keys = sort {
## $hash_upd_date{$a} cmp $hash_upd_date{$b}
## } keys %hash_upd_date;
# foreach $key ( keys %hash_upd_date ) {
## foreach(@keys){
## $key = $_;
## $id = $hash_id{$key};
## $file_name = $hash_file_name{$key};
## $comment = $hash_comment{$key};
## $fpcid = $hash_fpcid{$key};
## $nm = $hash_nm{$key};
## $upd_date = $hash_upd_date{$key};
## $game = $hash_game{$key};
## if ($i{$id} eq '' || $i{$id} eq 0){$out{$id} .= "";}
# if ($prv_id eq '' || $prv_id ne $id){
# if ($i{$prv_id} > 0){
# for($x=$i{$prv_id};$x<5;$x++){
# $out{$prv_id} .= "
| ";
# }
# $out{$prv_id} .= "
";
# }
# $num = 0;
# }
# $num++;
###
# $sql = "select sinsyun1,sinsyun2,sinsyun3,file1,file2,file3 from borrowed_poll where no = $in{'no'} and id = 0 and uid = $uid;";
# $ref = $dbh->selectall_arrayref($sql) or &stars_err("CODE:B-0141
エラーが発生しました。");
# ($sinsyun1,$sinsyun2,$sinsyun3,$file1,$file2,$file3)=@{$ref->[0]};
##&stars_err("$sql ---- $file1 ");
if ($flg_smartphone ne 1){
$ww_w = 140;
}else{
$ww_w = 91;
}
$out{'comm'} = '';
if($file1 ne ''){
if($sinsyun1 ne 1){
## $img_sum = "http://rexi.jp/karimono/borrowed/$id/sum_$file1";
## $img_big = "http://rexi.jp/karimono/borrowed/$id/$file1";
$img_sum = "http://rexi.jp/karimono/borrowed/$file1";
## $img_big = "http://rexi.jp/karimono/borrowed/$id/$file1";
}else{
$img_sum = $file1;
$img_big = $file1;
}
$out{'comm'} .=<<"EOT";
EOT
}
if($file2 ne ''){
if($sinsyun2 ne 1){
## $img_sum = "http://rexi.jp/karimono/borrowed/$id/sum_$file2";
## $img_big = "http://rexi.jp/karimono/borrowed/$id/$file2";
$img_sum = "http://rexi.jp/karimono/borrowed/$file2";
## $img_big = "http://rexi.jp/karimono/borrowed/$id/$file2";
}else{
$img_sum = $file2;
$img_big = $file2;
}
$out{'comm'} .=<<"EOT";
EOT
}
if($file3 ne ''){
if($sinsyun3 ne 1){
$img_sum = "http://rexi.jp/karimono/borrowed/$file3";
## $img_big = "http://rexi.jp/karimono/borrowed/$id/$file3";
}else{
$img_sum = $file3;
$img_big = $file3;
}
$out{'comm'} .=<<"EOT";
EOT
}
if($out{'comm'} ne ''){
if(($file1 eq '') or ($file2 eq '') or($file3 eq '')){
$out{'comm'} .=<<"EOT";
新春初笑賞は必ず3つ選んで下さい。
EOT
}else{
$out{'comm'} .=<<"EOT";
[投票キャンセル]
EOT
}
$out{'comm'} =<<"EOT";
新春初笑賞
$out{'comm'}
EOT
}
$out{'name1'} = @odai[1];
$out{'name2'} = @odai[2];
$out{'name3'} = @odai[3];
$out{'name4'} = @odai[4];
$out{'name5'} = @odai[5];
$out{'name6'} = @odai[6];
$out{'name7'} = @odai[7];
$out{'name8'} = @odai[8];
$out{'name9'} = @odai[9];
$out{'name10'} = @odai[10];
$out{'name11'} = @odai[11];
$out{'name12'} = @odai[12];
$out{'name13'} = @odai[13];
$out{'name14'} = @odai[14];
$out{'name15'} = @odai[15];
$out{'name16'} = @odai[16];
$out{'name17'} = @odai[17];
$out{'name18'} = @odai[18];
$out{'name19'} = @odai[19];
$out{'name20'} = @odai[20];
$out{'name21'} = @odai[21];
$out{'name22'} = @odai[22];
$out{'name23'} = @odai[23];
$out{'name24'} = @odai[24];
$out{'name25'} = @odai[25];
$out{'name26'} = @odai[26];
$out{'name27'} = @odai[27];
$out{'name28'} = @odai[28];
$out{'name29'} = @odai[29];
$out{'name30'} = @odai[30];
$out{'name31'} = @odai[31];
$out{'name32'} = @odai[32];
$out{'name33'} = @odai[33];
# $sql = "select sinsyun1,sinsyun2,sinsyun3,file1,file2,file3 from borrowed_poll where no = $in{'no'} and id = 0 and uid = $uid;";
# $ref2 = $dbh->selectall_arrayref($sql) or &stars_err("CODE:B-0141
エラーが発生しました。");
# ($sinsyun1,$sinsyun2,$sinsyun3,$file1,$file2,$file3)=@{$ref2->[0]};
$sql = "select a.id,a.file_name,a.comment,a.pcid,a.upd_date,a.uid,a.url from borrowed a where a.no = $in{'no'} order by a.id,a.upd_date;";
$ref = $dbh->selectall_arrayref($sql) or &stars_err("CODE:B-011
エラーが発生しました。$sql");
foreach(@$ref) {
($id,$file_name,$comment,$fpcid,$upd_date,$e_uid,$f_url)=@{$_};
# if($out{$id} eq ''){
# $sql = "select count(*) from borrowed_poll where no = $in{'no'} and id = $id and uid = $uid;";
# $ref = $dbh->selectall_arrayref($sql) or &stars_err("CODE:B-0142
エラーが発生しました。$sql");
# ($ccnt)=@{$ref->[0]};
# }
## $sql = "select name from character where pcid = '$fpcid';";
## if(substr($fpcid,0,1) eq 'x'){
## $game = 'gx';
## $ref = $dbh->selectall_arrayref($sql) or &stars_err("CODE:B-012
エラーが発生しました。");
## ($nm)=@{$ref->[0]};
##
## }elsif(substr($fpcid,0,1) eq 's'){
## $game = 'si';
## ($nm) = &si_rtn_db_data('select_line',$sql,'si');
## }
if ($number{$id} eq ''){$number{$id} = 1;}
else{$number{$id}++;}
$prv_id = $id;
$img_sum = '';
if($file_name ne 'url'){
$img_sum = "http://rexi.jp/karimono/borrowed/$id/sum_$file_name";
$img_big = "http://rexi.jp/karimono/borrowed/$id/$file_name";
}elsif($f_url ne ''){
$img_sum = $f_url;
$img_big = $f_url;
}
if($img_sum ne ''){
## if ($game eq 'si'){
## $myp_link =<<"EOT";
##$fpcid
##EOT
## }elsif ($game eq 'gx'){
## $myp_link =<<"EOT";
##$fpcid
##EOT
## }
$myp_link = $fpcid;
if ("$g_year$g_mon$g_mday$g_hour$g_min$g_sec" <= "20130107130000"){
if($e_uid eq $uid){
$del_btn = <<"EOT";
削除
EOT
if($file_name ne 'url'){
$del_btn .= <<"EOT";
回転
EOT
}
}else{
$del_btn = '
';
}
$del2_btn = '';
}else{
if (("$g_year$g_mon$g_mday$g_hour$g_min$g_sec" > "20130107130000") && ("$g_year$g_mon$g_mday$g_hour$g_min$g_sec" < "20130114130000")){
# $sql = "select post_pcid from borrowed_poll where no = $in{'no'} and id = $id and uid = $uid;";
# $ref2 = $dbh->selectall_arrayref($sql) or &stars_err("CODE:B-0141
エラーが発生しました。");
# ($rpost_pcid)=@{$ref2->[0]};
if($rpost_pcid eq $fpcid){
$del2_btn = <<"EOT";
投票済
EOT
}else{
$del2_btn = <<"EOT";
EOT
}
## $sql = "select sinsyun1,sinsyun2,sinsyun3,file1,file2,file3 from borrowed_poll where no = $in{'no'} and id = 0 and uid = $uid;";
## $ref2 = $dbh->selectall_arrayref($sql) or &stars_err("CODE:B-0141
エラーが発生しました。");
## ($sinsyun1,$sinsyun2,$sinsyun3,$file1,$file2,$file3)=@{$ref2->[0]};
if((($file1 eq $file_name) and ($file1 ne ''))
or (($file2 eq $file_name) and ($file2 ne ''))
or (($file3 eq $file_name) and ($file3 ne ''))
or (($file1 eq $f_url) and ($file1 ne ''))
or (($file2 eq $f_url) and ($file2 ne ''))
or (($file3 eq $f_url) and ($file3 ne '')) ){
$del2_btn .= <<"EOT";
新春初笑賞
EOT
}elsif(($file1 eq '') or ($file2 eq '') or ($file3 eq '')){
$del2_btn .= <<"EOT";
[新春初笑賞投票]
EOT
}else{
$del2_btn .= <<"EOT";
EOT
}
}
$del_btn = '';
}
if ($flg_smartphone ne 1){
$ww_w = 140;
}else{
$ww_w = 91;
}
$out{$id} .=<<"EOT";
$number{$id} |
$del2_btn |
EOT
if ($flg_smartphone ne 1){
$out{$id} .=<<"EOT";
EOT
}else{
$out{$id} .=<<"EOT";
EOT
}
$out{$id} .=<<"EOT";
|
$nm($myp_link) |
$comment |
$del_btn |
|
EOT
$i{$id}++;
if ($flg_smartphone ne 1){
if ($i{$id} eq 5){
$i{$id} = 0;
$out{$id} .= "";
}
}else{
if ($i{$id} eq 3){
$i{$id} = 0;
$out{$id} .= "";
}
}
}
}
if ($flg_smartphone ne 1){
for($y=1;$y<=30;$y++){
if ($out{$y} eq ''){
$out{$y} =<<"EOT";
投稿データはありません。 |
EOT
}
else{
if ("$g_year$g_mon$g_mday$g_hour$g_min$g_sec" > "20130107130000"){
$out{$y} = <<"EOT";
EOT
}else{
$out{$y} .= <<"EOT";
|
EOT
}
}
}
}
}else{
for($y=1;$y<=30;$y++){
if ($out{$y} eq ''){
$out{$y} =<<"EOT";
投稿データはありません。 |
EOT
}
else{
if ("$g_year$g_mon$g_mday$g_hour$g_min$g_sec" > "20130107130000"){
$out{$y} = <<"EOT";
EOT
}else{
$out{$y} .= <<"EOT";
|
EOT
}
}
}
}
}
if ("$g_year$g_mon$g_mday$g_hour$g_min$g_sec" <= "20130107130000"){
if ($flg_smartphone ne 1){
$html_file = "form2013.html";
if ($in{'page'} eq 2){$html_file = "form2013_2.html";}
elsif ($in{'page'} eq 3){$html_file = "form2013_3.html";}
}else{
$html_file = "form2013_sp.html";
if ($in{'page'} eq 2){$html_file = "form2013_2_sp.html";}
elsif ($in{'page'} eq 3){$html_file = "form2013_3_sp.html";}
}
}else{
if ($flg_smartphone ne 1){
$html_file = "form2013_p.html";
if ($in{'page'} eq 2){$html_file = "form2013_p_2.html";}
elsif ($in{'page'} eq 3){$html_file = "form2013_p_3.html";}
}else{
$html_file = "form2013_p_sp.html";
if ($in{'page'} eq 2){$html_file = "form2013_2_p_sp.html";}
elsif ($in{'page'} eq 3){$html_file = "form2013_3_p_sp.html";}
}
}
&out_enc;
&html_out($html_file);
}
#---------------------------------------
# FORM表示
#---------------------------------------
sub form {
$out{'list'} = '';
##$out{'test'} = "[ $ENV{'HTTP_USER_AGENT'} ]";
$sql = "select pcid,name,class,icon from character where uid = $uid and entry = 1 and hidden = 0 and state = 0 order by pcid;";
@si_pc = &si_rtn_db_data('select_rows',$sql,'si');
foreach (@si_pc){
$data = $_;
($pcid,$name,$class,$icon) = split(/\t/,$data);
$sql = "select file_name,comment,pcid from borrowed where no = $in{'no'} and id = $in{'id'} and pcid = '$pcid';";
$ref = $dbh->selectall_arrayref($sql) or &stars_err("エラーが発生しました。");
($file_name,$comment,$rpcid)=@{$ref->[0]};
if ($file_name eq ''){
if ($icon eq ''){$icon = &si_def_icon($class);}
$out{'list'} .=<<"EOT";
($pcid)$name
EOT
}
}
$sql = "select pcid,name,class,icon from character where uid = $uid and admission = 1 and hidden = 0 and state = 0 order by pcid;";
$ref = $dbh->selectall_arrayref($sql) or &stars_err("CODE:R-01
エラーが発生しました。$sql");
foreach(@$ref) {
($pcid,$name,$class,$icon)=@{$_};
$sql = "select file_name,comment from borrowed where no = $in{'no'} and id = $in{'id'} and pcid = '$pcid';";
$ref = $dbh->selectall_arrayref($sql) or &stars_err("エラーが発生しました。");
($file_name,$comment)=@{$ref->[0]};
if ($file_name eq ''){
if ($icon eq ''){
if ($class eq 1){$icon = '00_icon_wolserkr.jpg';}
elsif ($class eq 2){$icon = '00_icon_kybele.jpg';}
elsif ($class eq 3){$icon = '00_icon_padmas.jpg';}
elsif ($class eq 4){$icon = '00_icon_hokeypokey.jpg';}
$icon = 'http://rexi.jp/gx/images/' . $icon;
}
$out{'list'} .=<<"EOT";
($pcid)$name
EOT
}
}
if ($flg_smartphone ne 1){
$html_file = "borrowed01.html";
}else{
if (index($ENV{'HTTP_USER_AGENT'},'iPhone OS 6') > 0){
##iOS6
$out{'file_in'} =<<"EOT";
・画像ファイル
・画像URL
EOT
}elsif (index($ENV{'HTTP_USER_AGENT'},'iPhone') > 0){
##iPhone iOS6以外
$out{'file_in'} =<<"EOT";
・画像URL
EOT
}else{
##アンドロイド
$out{'file_in'} =<<"EOT";
・画像ファイル
・画像URL
EOT
}
$html_file = "borrowed01_sp.html";
}
&out_enc;
&html_out($html_file);
}
#---------------------------------------
# 送信確認
#---------------------------------------
sub send_conf {
if ($in{'comment'} eq ''){&stars_err("コメントが入力されていません。");}
if ($in{'pcid'} eq ''){&stars_err("キャラクターが選択されていません。");}
$sql = "select name from character where pcid = '$in{'pcid'}';";
if(substr($in{'pcid'} ,0,1) eq 'x'){
$game = 'gx';
$ref = $dbh->selectall_arrayref($sql) or &stars_err("CODE:B-012
エラーが発生しました。");
($nm)=@{$ref->[0]};
}elsif(substr($in{'pcid'} ,0,1) eq 's'){
$game = 'si';
($nm) = &si_rtn_db_data('select_line',$sql,'si');
}
$out{'name'} = $nm;
$tmp = length($in{'comment'});
if ($tmp > 40){&stars_err("コメントは全角20字までです。");}
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time);
$yyyymmddJ = sprintf("%04d%02d%02d$hour$min$sec", $year + 1900, $mon +1, $mday);
if($in{'photo'} ne ''){
if ($in{'photo'} eq ''){&stars_err("ファイルが指定されていません。");}
my ($ex) = ($in{'photo'} =~ m|(\.[^./\\]+)$|);
$fname = $in{'pcid'} . "_" . $yyyymmddJ . $ex;
$out{'fname'} = $fname;
$tmp_file = "/home/rexi-jp/public_html/karimono/tmp2013/" . $fname;
# $rtn = &upload($tmp_file,$in{'photo'});
$rtn = &upload($tmp_file,$photo);
if ($rtn ne 0){&stars_err($rtn);}
($format,$width,$height) = &GetImageSize($tmp_file);
$out{'fname2'} = "http://rexi.jp/karimono/tmp2013/".$fname;
}elsif($in{'url'} ne ''){
$out{'url'} = $in{'url'};
$out{'fname2'} = $in{'url'};
}else{
&stars_err("ファイルが指定されていません。");
}
if ($flg_smartphone ne 1){
$html_file = "borrowed02.html";
}else{
$html_file = "borrowed02_sp.html";
}
&out_enc;
&html_out($html_file);
}
#---------------------------------------
# 送信
#---------------------------------------
sub sending {
if ($in{'fname'} ne ''){
$sql = "select reg_date from borrowed where no = $in{'no'} and id = $in{'id'} and pcid = '$in{'pcid'}';";
$ref = $dbh->selectall_arrayref($sql) or &stars_err("エラーが発生しました。".$dbh->errstr);
($reg_date)=@{$ref->[0]};
if ($reg_date eq ''){
$sql = "insert into borrowed (no,id,pcid,file_name,comment,uid) values ($in{'no'},$in{'id'},'$in{'pcid'}','$in{'fname'}','$in{'comment'}',$uid);";
}else{
$sql = "update borrowed set file_name = '$in{'fname'}',comment = '$in{'comment'}',upd_date = now() where no = $in{'no'} and id = $in{'id'} and pcid = '$in{'pcid'}';";
}
$dbh->do($sql) or &stars_err("エラーが発生しました。
".$dbh->errstr);
$tmp_file = "/home/rexi-jp/public_html/karimono/tmp2013/" . $in{'fname'};
$sum_file = $entry_dir . "sum_" . $in{'fname'};
#リサイズ
$rtn = 0;
($format,$width,$height) = &GetImageSize($tmp_file);
if ($width > $height){
$rtn = &img_resize($tmp_file,$sum_file,140);
}
else{
$rtn = &img_resize($tmp_file,$sum_file,undef,140);
}
if ($rtn ne 0){&stars_err("リサイズ処理にてエラーが発生しました。$rtn");}
#ファイル移動
$mv_file = $entry_dir . $in{'fname'};
move $tmp_file, $mv_file or die &stars_err("ファイル処理にてエラーが発生しました。
$tmp_file, $mv_file");
}elsif ($in{'url'} ne ''){
$sql = "select reg_date from borrowed where no = $in{'no'} and id = $in{'id'} and pcid = '$in{'pcid'}';";
$ref = $dbh->selectall_arrayref($sql) or &stars_err("エラーが発生しました。".$dbh->errstr);
($reg_date)=@{$ref->[0]};
if ($reg_date eq ''){
$sql = "insert into borrowed (no,id,pcid,file_name,url,comment,uid) values ($in{'no'},$in{'id'},'$in{'pcid'}','url','$in{'url'}','$in{'comment'}',$uid);";
}else{
$sql = "update borrowed set url = '$in{'url'}',comment = '$in{'comment'}',upd_date = now() where no = $in{'no'} and id = $in{'id'} and pcid = '$in{'pcid'}';";
}
$dbh->do($sql) or &stars_err("エラーが発生しました。
".$dbh->errstr);
## $icm = rindex($in{'url'}, '/') +1;
## $ii = length($in{'url'}) - $icm;
#3 $w_file = substr($in{'url'},$icm,$ii);
## $tmp_file = "/home/rexi-jp/public_html/karimono/tmp/".$w_file;
## #ファイル移動
## move $in{'url'} , $tmp_file or die &stars_err("ファイル処理にてエラーが発生しました。
$tmp_file, $in{'url'}");
## #リサイズ
## $rtn = 0;
## ($format,$width,$height) = &GetImageSize($tmp_file);
## if ($width > $height){
## $rtn = &img_resize($tmp_file,$sum_file,140);
## }
## else{
## $rtn = &img_resize($tmp_file,$sum_file,undef,140);
## }
## if ($rtn ne 0){&stars_err("リサイズ処理にてエラーが発生しました。$rtn");}
## #ファイル移動
## $mv_file = $entry_dir . $in{'fname'};
## move $tmp_file, $mv_file or die &stars_err("ファイル処理にてエラーが発生しました。
$tmp_file, $mv_file");
##&err("$tmp_file -- $tmp_file, $mv_file");
}else{
&stars_err("ファイルが指定されていません。");
}
## print "Location: ./borrowed_end.html\n\n";
if ($flg_smartphone ne 1){
$html_file = "borrowed_end.html";
}else{
$html_file = "borrowed_end_sp.html";
}
&out_enc;
&html_out($html_file);
}
#---------------------------------------
# 画像アップロード
#---------------------------------------
sub upload {
#ファイル名確定(ここでは一時ファイル)
$outputfile = $_[0];
$chkfile = $_[1];
#サイズ等確認表示のため、一時読み込み
open(FILE, ">$outputfile") or die &stars_err("ファイルアップロードでエラーが発生しました。$outputfile");
flock(FILE, 2);#読み込み中ロック
if (defined $chkfile) { #NULLにならない限り繰り返し(と考えとこう)
while (<$chkfile>) {
print FILE $_; #受け取ったものを書込み
}
}
close FILE;
#サイズ取得
my @chksize = stat $outputfile;
$chksize=@chksize[7];
($format,$width,$height) = &GetImageSize($outputfile);
if(substr($format,0,4) ne 'JPEG' && substr($format,0,3) ne 'GIF' && substr($format,0,3) ne 'PNG'){
return "アップロード出来るファイル形式ではありません。$format"; #アップロード出来るファイル形式ではありません。
}
if($chksize <= 0){
$unlinkcount = unlink $outputfile;
&stars_err("アップロード時にエラーが発生しました。");
}
return 0;
}
#---------------------------------------
# 投票
#---------------------------------------
sub post_form {
$out{'title'} = @odai[$in{'id'}];
$num = 0;
$tid = 1;
$sql = "select a.oid,a.id,a.file_name,a.comment,a.pcid,b.name,a.upd_date from borrowed a,character b where a.no = $in{'no'}";
if ($in{'id'} ne 0){$sql .= " and a.id = $in{'id'}";}
$sql .= " and a.pcid = b.pcid order by a.id,a.upd_date;";
$ref = $dbh->selectall_arrayref($sql) or &stars_err("CODE:B-013
エラーが発生しました。");
foreach(@$ref) {
($oid,$id,$file_name,$comment,$fpcid,$nm,$upd_date)=@{$_};
$hash_id{$idx} = $id;
$hash_file_name{$idx} = $file_name;
$hash_comment{$idx} = $comment;
$hash_fpcid{$idx} = $fpcid;
$hash_nm{$idx} = $nm;
$hash_upd_date{$idx} = $upd_date;
$hash_game{$idx} = 'gx';
$hash_oid{$idx} = 'gx' . $oid;
$idx++;
}
## $dbh_jj = &connectDB('jj');
## $sql = "select a.oid,a.id,a.file_name,a.comment,a.pcid,b.name3 || '/' || b.name1,a.upd_date from borrowed a,character b where a.no = $in{'no'}";
## if ($in{'id'} ne 0){$sql .= " and a.id = $in{'id'}";}
## $sql .= " and a.pcid = b.pcid order by a.id,a.upd_date;";
## $ref = $dbh_jj->selectall_arrayref($sql) or &stars_err("CODE:B-01
エラーが発生しました。");
## foreach(@$ref) {
## ($oid,$id,$file_name,$comment,$fpcid,$nm,$upd_date)=@{$_};
## $hash_id{$idx} = $id;
## $hash_file_name{$idx} = $file_name;
## $hash_comment{$idx} = $comment;
## $hash_fpcid{$idx} = $fpcid;
## $hash_nm{$idx} = $nm;
## $hash_upd_date{$idx} = $upd_date;
## $hash_game{$idx} = 'jj';
## $hash_oid{$idx} = 'jj' . $oid;
## $idx++;
## }
@keys = sort {
$hash_upd_date{$a} cmp $hash_upd_date{$b}
} keys %hash_upd_date;
# $sql = "select a.file_name,a.comment,a.pcid,b.name1,b.name3,b.attribute from borrowed a,character b where a.no = 1 and a.id = $in{'id'} and a.state = 0 and a.pcid = b.pcid order by a.id,a.upd_date;";
if ($in{'id'} eq 0){
$out{'title'} = '新春初笑賞';
$out{'cout'} = '
※「新春初笑賞」は必ず3つ選択してください。
';
# $sql = "select a.file_name,a.comment,a.pcid,b.name1,b.name3,b.attribute,a.id,a.oid from borrowed a,character b where a.no = 1 and a.state = 0 and a.pcid = b.pcid order by a.id,a.upd_date;";
}
# $ref = $dbh->selectall_arrayref($sql) or &stars_err("CODE:PF-01
エラーが発生しました。");
# foreach(@$ref) {
# ($file_name,$comment,$fpcid,$nm1,$nm3,$atb,$id,$oid)=@{$_};
foreach(@keys){
$key = $_;
$id = $hash_id{$key};
$file_name = $hash_file_name{$key};
$comment = $hash_comment{$key};
$fpcid = $hash_fpcid{$key};
$nm = $hash_nm{$key};
$upd_date = $hash_upd_date{$key};
$game = $hash_game{$key};
$oid = $hash_oid{$key};
# ($format,$width,$height) = &GetImageSize("/home/rexi-jp/public_html/jj/scenario/jw09/borrowed/$id/sum_$file_name");
if ($game eq 'jj'){
$img_sum = "http://rexi.jp/jj/scenario/gi/gi10/borrowed/$id/sum_$file_name";
$img_big = "http://rexi.jp/jj/scenario/gi/gi10/borrowed/$id/$file_name";
$myp_link = "mypage('http://rexi.jp/jj/mypage.cgi?pcid=$fpcid','mypage','scrollbars=yes,width=680,height=800')";
}
elsif ($game eq 'gx'){
$img_sum = "./borrowed/$id/sum_$file_name";
$img_big = "./borrowed/$id/$file_name";
$myp_link = "MypageOpen('$fpcid');";
}
$atb = @atb_str[$atb];
if ($in{'id'} ne 0){$id_dir = $in{'id'};}
elsif ($in{'id'} eq 0){$id_dir = $id;}
if ($num eq 0){$out{'list'} .= "";}
$out{'list'} .=<<"EOT";
|
EOT
}
else{
$out{'list'} .=<<"EOT";
|
EOT
}
$num++;
$tid++;
if ($num eq 5){
$num = 0;
$out{'list'} .= "";
}
}
if ($num > 0){
for($x=$num;$x<5;$x++){
$out{'list'} .= "
| ";
}
$out{'list'} .= "";
}
$html_file = "borrowed_post01.html";
&out_enc;
&html_out($html_file);
}
#---------------------------------------
# 投票確認(初笑)
#---------------------------------------
sub post_conf2 {
if($in{'post_pcid'} eq ''){
&stars_err("投票する画像を選択していません。");
}
if($in{'no'} eq ''){
&stars_err("パラメーターエラー15");
}
if($in{'id'} eq ''){
&stars_err("パラメーターエラー25。");
}
$sql = "select count(*) from borrowed_poll where no = $in{'no'} and id = 0 and uid = $uid;";
$ref = $dbh->selectall_arrayref($sql) or &stars_err("CODE:B-0141
エラーが発生しました。");
($cc_cnt)=@{$ref->[0]};
if($cc_cnt eq 0){
$sql = "insert into borrowed_poll (no,id,uid,post_pcid,ip,host) values ($in{'no'},0,$uid,NULL,'$ip','$host');";
$dbh->do($sql) or &stars_err("エラー4が発生しました$sql");
}
$sql = "select sinsyun1,sinsyun2,sinsyun3,file1,file2,file3 from borrowed_poll where no = $in{'no'} and id = 0 and uid = $uid;";
$ref = $dbh->selectall_arrayref($sql) or &stars_err("CODE:B-0141
エラーが発生しました。");
($sinsyun1,$sinsyun2,$sinsyun3,$file1,$file2,$file3)=@{$ref->[0]};
$sql = "select id,file_name,comment,pcid,upd_date,url from borrowed where no = $in{'no'}";
$sql .= " and id = $in{'id'}";
$sql .= " and pcid = '$in{'post_pcid'}' ;";
$ref = $dbh->selectall_arrayref($sql) or &stars_err("CODE:B-01454
エラーが発生しました。");
($id,$file_name,$comment,$fpcid,$nm,$upd_date,$f_url)=@{$ref->[0]};
#######&stars_err("$sql。$id,$file_name,$comment,$fpcid,$upd_date,$f_url");
$iic = length($file_name) * -1;
if( substr($file1,$iic) eq $file_name){
&stars_err("この画像はすでに登録されています。");
}
if( substr($file2,$iic) eq $file_name){
&stars_err("この画像はすでに登録されています。");
}
if( substr($file3,$iic) eq $file_name){
&stars_err("この画像はすでに登録されています。");
}
$sql = "update borrowed_poll set ";
if($file1 eq ''){
if($file_name ne 'url'){
$sql .= "file1 = '$in{'id'}/sum_$file_name' ";
}else{
$sql .= "file1 = '$f_url' , sinsyun1 = 1 ";
}
}elsif($file2 eq ''){
if($file_name ne 'url'){
$sql .= "file2 = '$in{'id'}/sum_$file_name' ";
}else{
$sql .= "file2 = '$f_url' , sinsyun2 = 1 ";
}
}elsif($file3 eq ''){
if($file_name ne 'url'){
$sql .= "file3 = '$in{'id'}/sum_$file_name' ";
}else{
$sql .= "file3 = '$f_url' , sinsyun3 = 1 ";
}
}else{
&stars_err("新春初笑賞は3つまでしか選べません。");
}
$sql .= " where no = $in{'no'} and id = 0 and uid = $uid;";
$dbh->do($sql) or &stars_err("エラーが発生しました2。$sql");
$in{'mode'} = '';
$in{'page'} = $in{'page'};
⊤
}
#---------------------------------------
# 投票確認(初笑)
#---------------------------------------
sub post_can2 {
if($in{'no'} eq ''){
&stars_err("パラメーターエラー55");
}
$sql = "delete from borrowed_poll where no = $in{'no'} and id = 0 and uid = $uid;";
$dbh->do($sql) or &stars_err("エラーが発生しました2。$sql");
$in{'mode'} = '';
$in{'page'} = $in{'page'};
⊤
}
#---------------------------------------
# 投票確認
#---------------------------------------
sub post_conf {
if($in{'post_pcid'} eq ''){
&stars_err("投票する画像を選択していません。");
}
if($in{'no'} eq ''){
&stars_err("パラメーターエラー15");
}
if($in{'id'} eq ''){
&stars_err("パラメーターエラー25。");
}
$sql = "select a.id,a.file_name,a.comment,a.pcid,a.upd_date from borrowed a where a.no = $in{'no'}";
$sql .= " and a.id = $in{'id'}";
$sql .= " and a.pcid = '$in{'post_pcid'}';";
$ref = $dbh->selectall_arrayref($sql) or &stars_err("CODE:B-01454
エラーが発生しました。");
($id,$file_name,$comment,$fpcid,$upd_date)=@{$ref->[0]};
$sql = "select count(*) from borrowed_poll where no = $in{'no'} and id = $in{'id'} and uid = $uid;";
$ref = $dbh->selectall_arrayref($sql) or &stars_err("CODE:B-01455
エラーが発生しました。$sql");
($ccnt)=@{$ref->[0]};
if($ccnt eq 0){
$sql = "insert into borrowed_poll (no,id,uid,post_pcid,ip,host) values ($in{'no'},$in{'id'},$uid,'$in{'post_pcid'}','$ip','$host');";
}else{
$sql = "update borrowed_poll set post_pcid = '$in{'post_pcid'}' where no = $in{'no'} and id = $in{'id'} and uid = $uid;";
}
$dbh->do($sql) or &stars_err("エラーが発生しました。");
$in{'page'} = $in{'page'};
⊤
$ref = $dbh->selectall_arrayref($sql) or &stars_err("CODE:B-0146
エラーが発生しました。");
foreach(@$ref) {
($id,$file_name,$comment,$fpcid,$nm,$upd_date)=@{$_};
$hash_id{$fpcid} = $id;
$hash_file_name{$fpcid} = "./borrowed/$id/sum_$file_name";
$hash_comment{$fpcid} = $comment;
$hash_fpcid{$fpcid} = $fpcid;
$hash_nm{$fpcid} = $nm;
$hash_upd_date{$fpcid} = $upd_date;
$hash_game{$fpcid} = 'gx';
$idx++;
}
## $dbh_jj = &connectDB('jj');
## $sql = "select a.id,a.file_name,a.comment,a.pcid,b.name3 || '/' || b.name1,a.upd_date from borrowed a,character b where a.no = 3";
## if ($in{'id'} ne 0){$sql .= " and a.id = $in{'id'}";}
#3 $sql .= " and a.pcid = '$in{'post_pcid'}' and a.pcid = b.pcid order by a.id,a.upd_date;";
## $ref = $dbh_jj->selectall_arrayref($sql) or &stars_err("CODE:B-01B
エラーが発生しました。");
## foreach(@$ref) {
## ($id,$file_name,$comment,$fpcid,$nm,$upd_date)=@{$_};
## $hash_id{$fpcid} = $id;
## $hash_file_name{$fpcid} = "http://rexi.jp/jj/scenario/gi/gi10/borrowed/$id/sum_$file_name";
## $hash_comment{$fpcid} = $comment;
## $hash_fpcid{$fpcid} = $fpcid;
## $hash_nm{$fpcid} = $nm;
## $hash_upd_date{$fpcid} = $upd_date;
## $hash_game{$fpcid} = 'jj';
## $idx++;
## }
if ($in{'id'} ne 0){
$out{'title'} = @odai[$in{'id'}];
# $sql = "select a.file_name,a.comment,a.pcid,b.name1,b.name3,b.attribute from borrowed a,character b where a.no = 1 and a.id = $in{'id'} and a.state = 0 and a.pcid = '$in{'post_pcid'}' and a.pcid = b.pcid;";
# $ref = $dbh->selectall_arrayref($sql) or &stars_err("エラーが発生しました。");
# ($out{'file_name'},$out{'comment'},$out{'fpcid'},$out{'nm1'},$out{'nm3'},$atb,$id,$oid)=@{$ref->[0]};
$out{'file_name'} = $hash_file_name{$in{'post_pcid'}};
$out{'comment'} = $hash_comment{$in{'post_pcid'}};
$out{'fpcid'} = $hash_fpcid{$in{'post_pcid'}};
$out{'nm'} = $hash_nm{$in{'post_pcid'}};
if ($out{'file_name'} eq ''){&stars_err("不正な指定です。");}
$out{'atb'} = @atb_str[$atb];
}
else{
$out{'title'} = '新春初笑賞';
$k = 0;
$dbh_jj = &connectDB('jj');
foreach $key ( keys( %in ) ) {
if (substr($key,0,4) eq 'oid_' && $in{$key} ne '' && $in{$key} ne 0){
$k++;
$oid = $in{$key};
$game = substr($oid,0,2);
$oid = substr($oid,2);
if ($game eq 'jj'){
$sql = "select a.file_name,a.comment,a.pcid,b.name3 || '/' || b.name1,b.attribute,a.id from borrowed a,character b where a.no = $in{'no'} and a.oid = $oid and a.state = 0 and a.pcid = b.pcid;";
$ref = $dbh_jj->selectall_arrayref($sql) or &stars_err("エラーが発生しました。");
($file_name,$comment,$fpcid,$nm,$atb,$id)=@{$ref->[0]};
$atb = @atb_str[$atb];
$img_sum = "http://rexi.jp/jj/scenario/gi/gi10/borrowed/$id/sum_$file_name";
$img_big = "http://rexi.jp/jj/scenario/gi/gi10/borrowed/$id/sum_$file_name";
$myp_link = "mypage('http://rexi.jp/jj/mypage.cgi?pcid=$fpcid','mypage','scrollbars=yes,width=680,height=800')";
}
elsif ($game eq 'gx'){
$sql = "select a.file_name,a.comment,a.pcid,b.name,'―',a.id from borrowed a,character b where a.no = $in{'no'} and a.oid = $oid and a.state = 0 and a.pcid = b.pcid;";
$ref = $dbh->selectall_arrayref($sql) or &stars_err("エラーが発生しました。");
($file_name,$comment,$fpcid,$nm,$atb,$id)=@{$ref->[0]};
$img_sum = "./borrowed/$id/sum_$file_name";
$img_big = "./borrowed/$id/sum_$file_name";
$myp_link = "MypageOpen('$fpcid');";
}
$out{'file_img'} .=<<"EOT";
$nm($fpcid)
EOT
}
}
if ($k > 3){&stars_err("新春初笑賞は3つまでしか選べません。");}
elsif ($k < 3){&stars_err("新春初笑賞は必ず3つ選んでください。");}
}
if ($in{'id'} ne 0){
$out{'id_dir'} = $in{'id'};
$html_file = "borrowed_post02.html";
}
elsif ($in{'id'} eq 0){
$out{'id_dir'} = $id;
$out{'fpcid'} = $oid;
$html_file = "borrowed_post02a.html";
}
&out_enc;
&html_out($html_file);
}
#---------------------------------------
# 投票実行
#---------------------------------------
sub post_send {
if ($in{'id'} ne 0 && $in{'fpcid'} eq ''){&stars_err("投票する画像が選択されていません。");}
if ($in{'id'} eq ''){&stars_err("お題が選択されていません。");}
if ($in{'pcid'} eq ''){&stars_err("キャラクターが選択されていません。");}
if ($in{'id'} ne 0){
$sql = "insert into borrowed_poll (no,id,uid,post_pcid,ip,host) values ($in{'no'},$in{'id'},$uid,'$in{'fpcid'}','$ip','$host');";
}
elsif ($in{'id'} eq 0){
$sql = "insert into borrowed_poll (no,id,uid,ip,host,sinsyun1,sinsyun2,sinsyun3) values ($in{'no'},$in{'id'},$uid,'$ip','$host',$in{'oid_1'},$in{'oid_2'},$in{'oid_3'});";
#&stars_err($sql);
}
$dbh->do($sql) or &stars_err("エラーが発生しました。");
print "Location: ./borrowed_post_end.html\n\n";
}
#---------------------------------------
# デフォルトアイコン
#---------------------------------------
sub si_def_icon {
my $cl = $_[0]; #クラス
my $icon = '';
if ($cl eq 1){$icon = 'exo.jpg';}
elsif ($cl eq 2){$icon = 'pal.jpg';}
elsif ($cl eq 3){$icon = 'ang.jpg';}
elsif ($cl eq 4){$icon = 'han.jpg';}
else{$icon = 'nor.jpg';}
$icon = 'http://pbws.jp/img/icon/' . $icon;
return $icon;
}
#---------------------------------------
# 画像回転
#---------------------------------------
sub roll {
use Image::Magick;
my $image = Image::Magick->new;
if ($in{'id'} eq ''){&stars_err("パラメーターエラー。");}
if ($in{'no'} eq ''){&stars_err("パラメーターエラー。");}
if ($in{'pcid'} eq ''){&stars_err("パラメーターエラー。");}
$sql = "select name from character where pcid = '$in{'pcid'}';";
if(substr($in{'pcid'} ,0,1) eq 'x'){
$game = 'gx';
$ref = $dbh->selectall_arrayref($sql) or &stars_err("CODE:B-012
エラーが発生しました。");
($nm)=@{$ref->[0]};
}elsif(substr($in{'pcid'} ,0,1) eq 's'){
$game = 'si';
($nm) = &si_rtn_db_data('select_line',$sql,'si');
}
$out{'name'} = $nm;
$sql = "select file_name,reg_date ,comment,url from borrowed where pcid = '$in{'pcid'}' and no= $in{'no'} and id = $in{'id'} ;";
$ref = $dbh->selectall_arrayref($sql) or &stars_err("CODE:B-012
エラーが発生しました。");
($file_name,$out{'reg_date'} ,$out{'comment'},$f_url)=@{$ref->[0]};
if($file_name ne 'url'){
## $fname2 = "http://rexi.jp/karimono/borrowed/$in{'id'}/".$file_name;
## $fname2s = "http://rexi.jp/karimono/borrowed/$in{'id'}/sum_".$file_name;
####$file_name = substr($file_name,0,-4).'1'.substr($file_name,-4);
if(length($file_name) eq 24){
$file_name2w = substr($file_name,0,-4).'1'.substr($file_name,-4);
#######&stars_err("$file_name - $file_name2 ");
}else{
$file_name2w = substr($file_name,0,-4);
$file_cnt = substr($file_name2w,-1);
$file_cnt ++;
$file_name2w = substr($file_name,0,-5).$file_cnt.substr($file_name,-4);;
#####&stars_err("$file_name - $file_name2 55 ");
}
$fname2 = "/home/rexi-jp/public_html/karimono/borrowed/$in{'id'}/".$file_name;
$fname2s = "/home/rexi-jp/public_html/karimono/borrowed/$in{'id'}/sum_".$file_name;
$fname3 = "/home/rexi-jp/public_html/karimono/borrowed/$in{'id'}/".$file_name2w;
$fname3s = "/home/rexi-jp/public_html/karimono/borrowed/$in{'id'}/sum_".$file_name2w;
##$r1 = "convert -rotate 90 ".$fname2." ".$fname3;
##$r2 = " convert -rotate 90 ".$fname2s." ".$fname3s;
## $sql = "update borrowed set file_name = '$file_name2w' where pcid = '$in{'pcid'}' and no= $in{'no'} and id = $in{'id'};";
##&stars_err("$r1 ***** $r2 ))) $sql");
## $dbh->do($sql) or &stars_err("エラーが発生しました。");
}else{
$fname2 = $f_url;
}
## system "convert -resize $resize_str +profile iptc -quality 100% $src_img $out_img";
## system "convert -rotate -90 /home/rexi-jp/public_html/karimono/borrowed/5/sf7352_2012122820333.jpg /home/rexi-jp/public_html/karimono/borrowed/5/sf7352_2012122820333.jpg ";
##&stars_err("$fname2 --");
system "convert -rotate 90 ".$fname2s." ".$fname3s;
$sql = "update borrowed set file_name = '$file_name2w' where pcid = '$in{'pcid'}' and no= $in{'no'} and id = $in{'id'};";
$dbh->do($sql) or &stars_err("エラーが発生しました。");
system "convert -rotate 90 ".$fname2." ".$fname3;
## $image->Read($fname2);
## $image->rotate(degrees => 90);
## $image->Write($fname2);
## $image->Read($fname2s);
## $image->rotate(90);
## $image->Write($fname2s);
##
print "Location: ./form2013.cgi?page=$in{'page'}&no=$in{'no'}\n\n";
## &out_enc;
## &html_out('roll_end.html');
}
#---------------------------------------
# スマホ参照
#---------------------------------------
sub view {
$out{'fname2'} = "http://rexi.jp/karimono/borrowed/$in{'id'}/".$in{'file'};
&out_enc;
&html_out('view_sp.html');
}