#!/usr/bin/perl
require '/home/rexi-jp/public_html/tg/lib/lib.pl';
require '/home/rexi-jp/public_html/tg/lib/scenario.pl';
require '/home/rexi-jp/public_html/jj/lib/mobile.pl';
$mycgi = 'index.cgi';
$mid = $uid;
$uid = '';
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'};
#if ($ip ne '180.28.72.219'){exit;}
$uid = &get_usr_cookie;
$pcid = &get_pcid_cookie;
$query = CGI->new;
my @params = $query->param();#全てのパラメータ名を取得 なのでこれを$inにしてしまえば$inで使用可能
foreach my $param (@params) {
$in{$param} = $query->param($param);
}
$tmp = &CHECK_UA;
$flg_smartphone = 0;
if ($tmp >=70 && $tmp <= 86){$flg_smartphone = 1;}
$dbh = &connectDB($mainDB);
#PC情報取得
#$sql = "select name,class,sex,birth,zensin from character where pcid = '$pcid';";
#$ref = $dbh->selectall_arrayref($sql) or &err("エラーが発生しました。");
#($out{'name'},$pcclass,$pcsex,$pcbirth,$zensin)=@{$ref->[0]};
$out{'name'} = &get_pcname_cookie;
&date_rtn;
chomp $out{'zensin'};
if ($in{'mode'} eq ''){
⊤
}
elsif ($in{'mode'} eq 'favorite_del'){
&favorite_del;
}
elsif ($in{'mode'} eq 'sort_list'){
&sort_list;
}
elsif ($in{'mode'} eq 'search'){
&search;
}
elsif ($in{'mode'} eq 'month_list'){
&month_list;
}
else{
&err("不正なパラメータ");
}
&disconDB($dbh);
exit;
#---------------------------------------
# TOP表示
#---------------------------------------
sub top {
# &html_out("scenario_top.html");
# exit;
if ($in{'p'} eq ''){$in{'p'} = 1;}
$out{'np'} = $in{'p'} + 1;
$start_pos = ($in{'p'} - 1) * 50;
$end_pos = $in{'p'} * 50 - 1;
$i_cnt = 0;
$offset = "offset $start_pos";
if ($uid ne 2 && $uid ne 10 && $uid ne 535 && $uid ne 1490){$nwhere = "a.msid != 'system' and";}
if ($in{'sort'} eq ''){
$sql = "select a.msid,b.name,substr(b.last_update,3,8) from poll a,master b where a.pcid = '$pcid' and a.msid = b.id order by a.reg_date;";
$ref = $dbh->selectall_arrayref($sql) or &err("CODE:0A
エラーが発生しました。");
foreach(@$ref) {
($msid,$msname,$last_update)=@{$_};
$last_update =~ s/\-/\//g;
$out{'fav'} .=<<"EOT";
$last_update更新 | $msname |
EOT
}
}
#参加中一覧
if ($in{'sort'} eq ''){
# $sql = "select a.seq,a.title,a.apply_state,substr(a.playing_close + '-1 days',3,8),c.name,a.scenario_state,a.type from scenario a,scenario_member b,master c where a.open_date <= current_timestamp and a.apply_state < 5 and a.state = 0 and a.seq = b.scenario_seq and b.pcid = '$pcid' and (b.entry_state = 1 or b.entry_state = 11 or b.reserve = 1) and a.msid = c.id order by a.playing_close;";
$sql = "select a.seq,a.title,a.apply_state,substr(a.playing_close + '-1 days',6,5),c.name,a.scenario_state,a.type,a.msid from scenario a,scenario_member b,master c where a.apply_state < 5 and a.state = 0 and a.seq = b.scenario_seq and b.pcid = '$pcid' and (b.entry_state = 1 or b.entry_state = 11 or b.reserve = 1) and a.msid = c.id order by a.playing_close;";
$ref = $dbh->selectall_arrayref($sql) or &err("CODE:0A1
エラーが発生しました。");
foreach(@$ref) {
($s_seq,$title,$apply_state,$pdate,$ms_name,$scenario_state,$type,$smsid)=@{$_};
$pdate =~ s/\-/\//g;
$s_state = '';
if ($scenario_state eq 0){$s_state = '予約中';}
elsif ($scenario_state eq 1 && $type ne 5 && $type ne 12 && $type ne 7){$s_state = "相談中";}
elsif ($scenario_state eq 1 && ($type eq 5 || $type eq 12)){$s_state = "参加中";}
elsif ($scenario_state eq 1 && $type ne 5 && $type ne 12 && $type eq 7){$s_state = "参加中";}
elsif ($scenario_state eq 2 && $type ne 7){$s_state = "執筆中";}
elsif ($scenario_state eq 2 && $type eq 7){$s_state = "参加中";}
elsif ($apply_state >= 3 && $apply_state <= 4){$s_state = "執筆中";}
$out{'entry_list'} .=<<"EOT";
$pdate開始 $title | $ms_name | $s_state |
EOT
$out{'entry_list_sp'} .=<<"EOT";
$pdate開始 | $title | $ms_name | $s_state |
EOT
}
if ($out{'entry_list'} eq ''){$out{'entry_list'} = '参加中のシナリオはありません。 |
';}
}
&date_rtn;
if ($in{'sort'} eq ''){
$sql = "select a.msid,a.seq,a.type,a.title,a.reserve_close,a.playing_close,a.member_max,b.name,a.option1,a.option2,a.option3,a.option4,a.option5,a.option6,a.option7,a.op_illust,b.icon,a.difficulty,a.category,a.club_seq,a.npc,'','',a.npc_icon1,a.npc_icon2,'','',a.another,a.cmid,a.stage ";
$sql .= "from scenario a,master b where $nwhere a.apply_state = 1 and (a.scenario_state = 0 or a.scenario_state = 1) and a.state = 0 and a.open_date <= current_timestamp and a.msid = b.id order by a.open_date,a.seq;";
if ($flg_smartphone eq 0){$ofile = "index_pc.html";}
else{$ofile = "index_sp.html";}
}
elsif ($in{'sort'} eq 'wait'){
$sql = "select a.msid,a.seq,a.type,a.title,a.reserve_close,a.playing_close,a.member_max,b.name,a.option1,a.option2,a.option3,a.option4,a.option5,a.option6,a.option7,a.op_illust,b.icon,a.difficulty,a.category,a.club_seq,a.npc,'','',a.npc_icon1,a.npc_icon2,'','',a.another,a.cmid,a.stage ";
$sql .= "from scenario a,master b where $nwhere a.scenario_state = 2 and a.state = 0 and a.msid = b.id";
$sql .= " order by a.playing_close desc $offset limit 50;";
if ($flg_smartphone eq 0){$ofile = "wait_list_pc.html";}
else{$ofile = "wait_list_sp.html";}
}
elsif ($in{'sort'} eq 'replay' || $in{'sort'} eq 'series'){
$sql = "select a.msid,a.seq,a.type,a.title,a.reserve_close,a.playing_close,a.member_max,b.name,a.option1,a.option2,a.option3,a.option4,a.option5,a.option6,a.option7,a.op_illust,b.icon,a.difficulty,a.category,a.club_seq,a.npc,'','',a.npc_icon1,a.npc_icon2,'','',a.another,a.cmid,a.stage,a.apply_effect,substr(a.playing_close + '2 days',1,10),substr(a.replay_open_date,1,10) ";
$sql .= "from scenario a,master b where $nwhere a.apply_state = 5 and a.type != 10 and a.type != 11 and a.scenario_state = 3 and a.replay_open_date is not null and a.state = 0 and a.msid = b.id";
if ($in{'sort'} eq 'series'){$sql .= " and (a.main_id = $in{'seq'} or a.seq = $in{'seq'})";}
if ($in{'month'} ne ''){
$sql .= " and substr(a.replay_open_date,0,8) = '$in{'month'}' order by a.replay_open_date desc;";
$ofile = "replay_list_month.html";
}
else{
$sql .= " order by a.replay_open_date desc $offset limit 50;";
if ($flg_smartphone eq 1){$ofile = "replay_list_sp.html";}
else{$ofile = "replay_list_pc.html";}
}
$sql2 = "select substr(replay_open_date,0,8),count(*) from scenario where scenario_state = 3 and replay_open_date is not null and state = 0 group by substr(replay_open_date,0,8) order by substr(replay_open_date,0,8) desc;";
$ref2 = $dbh->selectall_arrayref($sql2) or &err("CODE:0A3
エラーが発生しました。
");
foreach(@$ref2) {
($replay_open_date,$cnt)=@{$_};
$month = $replay_open_date;
$replay_open_date =~ s/\-/\//g;
if ($in{'month'} ne '' && $in{'month'} eq $month){$chk = 'selected';}
else{$chk = '';}
$out{'month_select'} .=<<"EOT";