#!/usr/bin/perl
#===============================================================================
# 2013/02/15 EDITED BY KIYA
#===============================================================================
require '/home/rexi-jp/public_html/tg/lib/lib.pl';
require '/home/rexi-jp/public_html/tg/entry/making.pl';
$mycgi = 'index.cgi';
use Jcode;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use Time::Local;
$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'};
#-- 全身図コピー先サーバー
$sv_name = 'rexis.jp';
$sv_user = 'rexis-jp';
$sv_pass = 'Ouv5zepJ';
$sv_dir = '/public_html/stars/data/tg/';
$flg_smartphone = 0;
$imode = &CHECK_UA;
if ($imode >=70 && $imode <= 86){$flg_smartphone = 1;}
if($imode < 70){
$top_html = "top.html";
$admission_html = "entry00_pc.html";
$login_html = "entry01.html";
$kiyaku_html = "entry02.html";
$entry01_html = "entry03_pc.html";
$entry02_html = "entry04_pc.html";
$entry03_html = "entry05_pc.html";
$entry04_html = "entry06_pc.html";
$name_html = "entry07_pc.html";
$entry05_html = "entry08_pc.html";
$class_html = "entry09_pc.html";
$entry06_html = "entry10_pc.html";
$entry_html = "entry11_pc.html";
$admisgo_html = "admission_go_pc.html";
$mtcheck_html = "entry_mtch_pc.html";
$err_html = "entry_err.html";
$mtsel_html = "mt_select.html";
$mtcheck2_html = "material_check_pc.html";
$pcconv_html = "pcconv_pc.html";
$illust_chk_pc_html = "illust_pc.html";
}elsif($imode > 69){
$top_html = "top.html";
$admission_html = "entry00_sp.html";
$login_html = "entry01.html";
$kiyaku_html = "entry02.html";
$entry01_html = "entry03_sp.html";
$entry02_html = "entry04_sp.html";
$entry03_html = "entry05_sp.html";
$entry04_html = "entry06_sp.html";
$name_html = "entry07_sp.html";
$entry05_html = "entry08_sp.html";
$class_html = "entry09_sp.html";
$entry06_html = "entry10_sp.html";
$entry_html = "entry11_sp.html";
$admisgo_html = "admission_go_sp.html";
$mtcheck_html = "entry_mtch_sp.html"; #-- 汎用使う
$err_html = "entry_err.html";
$mtsel_html = "mt_select.html";
$mtcheck2_html = "material_check_sp.html";
$pcconv_html = "pcconv_sp.html";
$illust_chk_pc_html = "illust_pc.html";
}
else{
$top_html = "top.html";
$admission_html = "entry00_sp.html";
$login_html = "entry01.html";
$kiyaku_html = "entry02.html";
$entry01_html = "entry03_sp.html";
$entry02_html = "entry04_sp.html";
$entry03_html = "entry05_sp.html";
$entry04_html = "entry06_sp.html";
$name_html = "entry07_sp.html";
$entry05_html = "entry08_sp.html";
$class_html = "entry09_sp.html";
$entry06_html = "entry10_sp.html";
$entry_html = "entry11_sp.html";
$admisgo_html = "admission_go_sp.html";
$mtcheck_html = "entry_mtch_sp.html"; #-- 汎用使う
$err_html = "entry_err.html";
$mtsel_html = "mt_select.html";
$mtcheck2_html = "material_check_sp.html";
$pcconv_html = "pcconv_sp.html";
$illust_chk_pc_html = "illust_pc.html";
}
#-- コマンドライン引数取得
$query = CGI->new;
my @params = $query->param();#全てのパラメータ名を取得 なのでこれを$inにしてしまえば$inで使用可能
foreach my $param (@params) { $in{$param} = $query->param($param); }
################################################################################
#
# MAIN
#
################################################################################
$dbh = &connectDB($mainDB);
$uid = &get_usr_cookie;
$pcname = &get_pcname_cookie;
$pcid = &get_pcid_cookie;
if($imode eq 26 && $pcid ne ''){
$sql="SELECT name FROM character WHERE uid = $uid and pcid = '$pcid';";
$ref = $dbh->selectrow_arrayref($sql)||&entry_err("CODE:COOKIE ERROR / エラーが発生しました。" . $dbh->errstr);
$pcname = @$ref->[0] . "(" . $pcid . ")";
}
#$uid = $in{'uid'};
#---- 登録中のブラウザ切り替え対策 使えない…(泣)
if($uid eq ''){ #-- uidが無い(ログインしていない)
# print "Location: ./$login_html\n\n";
# &html_out($top_html);
# exit;
}
#if($cookuid eq '' && $uid ne ''){ #継承は在るがクッキーが無い
# &entry_err("COOKIE_LOST_ERROR: エラーが起こりました。
申し訳ございませんが、トップページより LOGIN してからやり直して下さい。");
#}
#if($cookuid ne '' && $uid eq ''){ #クッキーは在るが継承が無い(COOKIE優先)
# $uid = $cookuid;
#}
#if($cookuid ne '' && $uid ne ''){ #両方ある
# if($cookuid ne $uid){ #両方あるが双方が合致しない
# &entry_err("COOKIE_UNMATCH_ERROR: エラーが起こりました。
申し訳ございませんが、LOGINからやり直してください。");
# print "Location: ./index_entry.html\n\n";
# }
#}
#-- インプットを全部アウトプットへ…
if($in{'mode'} ne 'name_check'){
$out{'data'} = "";
foreach $key ( keys %in ) {
if (substr($key,0,7) ne "ex_list" && $key ne 'bt.x' && $key ne 'err' && $key ne 'mode' && $key ne 'bkflg' && $key ne 'bt' && $key ne 'bkpage' && $key ne 'wkpage' && $key ne 'bt.y'){
$out{'data'} .="\n";
}
}
}
#---------------------------------------
$out{'uid'} = $uid;
#$out{'pcname'} = $pcname;
&date_rtn; #-- 日付参照
&in_enc; #-- 文字コード変換
if ($in{'mode'} eq "top0"){ &top0;
}elsif ($in{'mode'} eq 'top'){ ⊤
}elsif ($in{'mode'} eq 'select_entry'){ print "Location: http://rexi.jp/tg/entry/?mode=admission\n\n";
}elsif ($in{'mode'} eq 'kiyaku'){ &kiyaku;
}elsif ($in{'mode'} eq 'matselect'){ &matselect;
}elsif ($in{'mode'} eq 'new_entry1'){
if ($in{'check'} ne 'ok'){ &entry_err("規約に同意していないため、登録できません。"); }
&new_entry1;
}elsif ($in{'mode'} eq 'new_entry2'){ &new_entry2;
}elsif ($in{'mode'} eq 'new_entry3'){ &new_entry3;
}elsif ($in{'mode'} eq 'new_entry4'){ &new_entry4;
}elsif ($in{'mode'} eq 'name_check'){ &name_check;
}elsif ($in{'mode'} eq 'new_entry5'){ &new_entry5;
}elsif ($in{'mode'} eq 'new_entry6'){ &new_entry6;
}elsif ($in{'mode'} eq 'pcconv'){ &pcconv;
}elsif ($in{'mode'} eq 'admission'){ &admission;
}elsif ($in{'mode'} eq 'name_change'){ &name_change;
}elsif ($in{'mode'} eq 'pc_del'){ &pc_del;
}elsif ($in{'mode'} eq 'admission_go'){ &admission_go;
}elsif ($in{'mode'} eq 'class_check'){ &class_check;
}elsif ($in{'mode'} eq 'charisma'){ &charisma;
}elsif ($in{'mode'} eq 'dormitory_select'){ &dormitory_select;
}elsif ($in{'mode'} eq 'conf'){ &conf;
}elsif ($in{'mode'} eq 'entry'){ &entry;
}elsif ($in{'mode'} eq 'illust_check'){ &illust_check;
}elsif ($in{'mode'} eq 'admission_dbg' && $uid eq 2){ &admission_dbg;
}else{ ⊤}
&disconDB($dbh);
exit;
################################################################################
#
# キャラクター登録FIRST STEP
#
# 登録か空中都市案内かを選択する受付画面。(ログインしてる場合の初期画面)
#
################################################################################
sub top{
print "Set-Cookie: MODE=top\n"; #--今のMODEセット
&html_out($top_html);
}
################################################################################
#
# 登録規約表示
#
################################################################################
sub kiyaku {
print "Set-Cookie: MODE=kiyaku\n"; #--今のMODEセット
&back_btn("top");
if($in{'job'} eq "material"){
$out{'oklist'} =<<"EOM";
EOM
}elsif($in{'job'} eq "pcconv"){
$out{'oklist'} =<<"EOM";
EOM
}else{
$out{'oklist'} =<<"EOM";
EOM
}
$out{'list'} = $bt_str;
&html_out($kiyaku_html);
}
################################################################################
#
# マテリアルセレクト画面
#
################################################################################
sub matselect{
#-- ユーザーIDでマテリアルを拾う
print "Set-Cookie: MODE=matselect\n"; #--今のMODEセット
&back_btn("top");
$dbh_s = &connectDB('stars');
$sql ="select count(*) from provisional WHERE uid = $uid and state in(0,2,3,4) and pdid in('C13','G01','C02');";
$ref = $dbh_s->selectrow_arrayref($sql)||&entry_err("CODE:MAT_00 " . $dbh->errstr);
$count = @$ref->[0];
if($count < 1){
&back_btn("top");
&entry_err("利用できるマテリアルがありません。
マテリアルを購入してからご利用下さい。");
}
$sql = "SELECT mtseq,crid,pdid,sex,race,age,price,add_price,state,fname1,file_name1,file_name2,file_name3,uid,provid,buy_time,game from provisional ";
$sql .="WHERE uid = $uid and state in(0,2,3,4) and pdid in('C13','G01','C02');";
$ref = $dbh_s->selectall_arrayref($sql)||&entry_err("CODE:MAT_01/エラーが発生しました。" . $dbh->errstr);
&disconDB($dbh_s);
$count = 1; #-- 段組み用
foreach(@$ref){
($mtseq,$crid,$pdid,$pd_sex,$pd_race,$pd_age,$pd_price,$pd_add_price,$state,$fname1,$file_name1,$file_name2,$file_name3,$pd_uid,$provid,$buy_time,$game) = @{$_};
#if ($ip eq '180.28.75.184'){&err("$mtseq,$crid,$pdid,$pd_sex,$pd_race,$pd_age,$pd_price,$pd_add_price");}
#-- 画像の整理
$img_list = ''; #-- イメージリスト初期化
$l_file = "$file_name1";
if ($pdid eq 'C13'){ #-- スタートセット
$img_list =" \n";
}elsif ($pdid eq 'G01'){ #-- 透過全身図
$img_list ="\n";
}elsif ($pdid eq 'C02'){ #-- アイコンセット
$img_list =" \n";
}
#--
# #-- 一覧表示ようサムネイルが無い場合には作る
# if ($l_file ne '' && !-e $l_file){
# $img1 = "$file_name1";
# system "convert -resize 170x380 +profile iptc -quality 100 $img1 $l_file";
# }
$btn_str ="";
#--表示実態
$buytime = substr($buy_time,0,10);
if($count == 1){
$out{'list'} .="
\n";
$flg = 1;
}
if($count >= 4){
$count = 1;
}else{
++$count;
}
}
if($flg ne 1){ $out{'list'} .="
\n"; }
&html_out($mtsel_html);
}
################################################################################
#
# 新規PC登録・1頁目(種族・性別)
# entry_t01.html
#
# iOS6の再読み込み防止のため、各頁ブラウザバック禁止。
# 所定のバックボタンでのバックのみ受付。
#
################################################################################
sub new_entry1 {
print "Set-Cookie: MODE=new_entry1\n"; #--今のMODEセット
&back_btn("kiyaku");
#-- 処理本体
# 何かと初期化
$race = $in{'race'};
$chk_race = "race_chk" . $race;
if($race ne ''){
$out{$chk_race} = "checked";
}
if($in{'sex'} eq 2){
$out{'chk_m'} ="";
$out{'chk_f'} ="checked";
}elsif($in{'sex'} eq 1){
$out{'chk_m'} ="checked";
$out{'chk_f'} ="";
}else{ #-- デフォルト
$out{'chk_m'} ="";
$out{'chk_f'} ="";
}
$in{'bkflg'} = "";
&html_out($entry01_html);
}
################################################################################
#
# 新規PC登録・2頁目(ルミナ・年齢・性別)
#
# entry_02t.html
#
################################################################################
sub new_entry2 {
print "Set-Cookie: MODE=new_entry2\n"; #--今のMODEセット
if($in{'job'} eq "material"){
&back_btn("matselect");
}elsif($in{'job'} eq "pcconv"){
&back_btn("kiyaku");
}else{
&back_btn("new_entry1");
}
#-- 処理本体
if ($in{'sex'} eq ''){&entry_err("性別が選択されていません。");}
if ($in{'race'} eq ''){&entry_err("種族が選択されていません。");}
# 何かと初期化
$out{'age'} = $in{'age'};
$out{'race_str'} = @race_str[$in{'race'}];
$out{'sex_str'} = @sex_str[$in{'sex'}];
$out{'birth_m'} = "";
$out{'birth_d'} = "";
$out{'origin'} = "";
$out{'lumina'} = "";
#-- 右側の人イメージの選択
#
# if ($in{'race'} eq 1){ $out{'npc_img'} = '../images/npc/human.png';
# }elsif ($in{'race'} eq 2){ $out{'npc_img'} = '../images/npc/fegel.png';
# }elsif ($in{'race'} eq 3){ $out{'npc_img'} = '../images/npc/para.png';
# }elsif ($in{'race'} eq 4){ $out{'npc_img'} = '../images/npc/elf_.png';
# }elsif ($in{'race'} eq 5){ $out{'npc_img'} = '../images/npc/dwarf.png';
# }elsif ($in{'race'} eq 6){ $out{'npc_img'} = '../images/npc/shefool.png';
# }elsif ($in{'race'} eq 7){ $out{'npc_img'} = '../images/npc/caitsith.png';
# }elsif ($in{'race'} eq 8){ $out{'npc_img'} = '../images/npc/';
# }elsif ($in{'race'} eq 9){ $out{'npc_img'} = '../images/npc/mellow.png';
# }elsif ($in{'race'} eq 10){ $out{'npc_img'} = '../images/npc/brownie.png';
# }else{ $out{'npc_img'} = '../images/npc/human.png'; }
#
$pc_img = "\n";
if($in{'job'} eq "material" or $in{'job'} eq "pcconv"){ $out{'npc_img'} = $pc_img; }
#-- birth_m
if($in{'birth_m'} > 1 ){
$bmsel = "sel_bm" . $in{'birth_m'};
$out{$bmsel} ="selected";
}else{
$out{'sel_bm1'} ="selected";
}
#-- birth_d
if($in{'birth_d'} > 1 ){
$bdsel = "sel_bd" . $in{'birth_d'};
$out{$bdsel} ="selected";
}else{
$out{'sel_bd1'} ="selected";
}
#-- age
#-- age マテリアル・コンバート用
if($in{'job'} eq "material" or $in{'job'} eq "pcconv"){
$min_age = $in{'age'} - 5;
if($min_age < 15){$min_age = 15; }
$max_age = $in{'age'} + 6;
if($max_age > 50){$max_age = 50; }
# $out{'age'} = "