#!/usr/bin/perl
$lib_db_flg = 1;
require '/home/rexi-jp/public_html/gx/lib/lib.pl';
require '/home/rexi-jp/public_html/jj/lib/mobile.pl';
$mid = $uid;
$uid = '';
$mycgi = 'chat.cgi';
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use File::Basename;
$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'};
@class_str_m = ('?'
,'W' #1
,'K' #2
,'P' #3
,'H' #4
);
$uid = &get_usr_cookie;
$pcid = &get_pcid_cookie;
if ($uid eq ''){$pcid = '';}
#if ($uid eq '' || $pcid eq '' || substr($pcid,0,1) ne 'j'){&err("ログインしないと、利用できません。");}
$query = CGI->new;
my @params = $query->param();#全てのパラメータ名を取得 なのでこれを$inにしてしまえば$inで使用可能
foreach my $param (@params) {
$in{$param} = $query->param($param);
}
if ($in{'id'} eq ''){&err("パラメータが不正です。");}
$out{'id'} = $in{'id'};
$out{'flg'} = $in{'flg'};
$out{'type'} = $in{'type'};
$dbh = &connectDB($mainDB);
#PC情報取得
#if ($pcid ne ''){
$pcname = &get_pcname_cookie;
if (($pcid ne '' && $in{'mode'} ne 'read_chat' && $in{'saybody'} ne '') || $in{'mode'} eq ''){
$sql = "select name,class,sex,birth,zensin,lumina,race,standpoint from character where pcid = '$pcid';";
$ref = $dbh->selectall_arrayref($sql) or &err("CODE:C-01 エラーが発生しました。");
($pcname,$pcclass,$pcsex,$pcbirth,$pczensin,$pclumina,$pcrace,$pc_standpoint)=@{$ref->[0]};
$out{'pcname'} = $pcname;
# $pcicon = &def_icon($pcclass);
if($pcrace eq 6 && substr($pcid,0,2) ne 'xz' && $pczensin ne ''){
$sql = "select pdid from stars_data where url = '$pczensin';";
$ref = $dbh->selectall_arrayref($sql) or &err("CODE:C-01 エラーが発生しました。");
($s_pdid)=@{$ref->[0]};
if(($s_pdid eq 'G01') or ($s_pdid eq 'C14')){
$pczensin = 'http://rexis.jp/stars/data/gx_shefool/'.substr($pczensin,28);
}
}
if($pcrace ne 6){
if ($pcbirth eq ''){
$pcage = '?';
}
else{
$pcage = &calcAge($pcbirth);
}
}else{
$pcage = '?';
}
}
$out{'pcid'} = $pcid;
##クロスチャットチェック
if($in{'type'} eq 'cross'){
$sql = "select cross_no from chat_control where id = $in{'id'};";
$ref = $dbh->selectall_arrayref($sql) or &err("CODE:C-02c エラーが発生しました。");
($si_id)=@{$ref->[0]};
if($si_id eq ''){
&err("パラメータが不正です。");
}
if($si_id eq '0'){
&err("パラメータが不正です。");
}
$sql = "select count(*) from chat_control where id = $si_id;";
($si_cnt) = &si_rtn_db_data('select_line',$sql,'si');
if($si_cnt eq 0){
&err("パラメータが不正です。");
}
}else{
$sql = "select cross_no from chat_control where id = $in{'id'};";
$ref = $dbh->selectall_arrayref($sql) or &err("CODE:C-02c エラーが発生しました。");
($si_id)=@{$ref->[0]};
if($si_id eq ''){
}elsif($si_id eq '0'){
}else{
$in{'type'} = 'cross';
## &err("パラメータが不正です。");
}
}
if($in{'id'} eq 203){
if($uid eq 1717){
}elsif($uid eq 2729){
}elsif($uid eq 58){
}elsif($uid eq 535){
}elsif($uid eq 2){
}else{
&err("パラメータが不正です。");
}
}
&ini_chk;
#&err("$in{'mode'}");
if ($in{'mode'} eq ''){
#発言フォーム・ログ表示
⊤
}
elsif ($in{'mode'} eq 'say_form'){
#発言フォーム表示
if ($pcid eq '' || $uid eq ''){&err("ログインされていない為、このサービスはご利用できません。ログインを行ってください。");}
&say_form;
}
elsif ($in{'mode'} eq 'write_chat'){
#発言
if ($death_flg eq 1){&err("死亡している為、このサービスはご利用できません。");}
if ($pcid eq '' || $uid eq ''){&err("ログインされていない為、このサービスはご利用できません。ログインを行ってください。");}
&write_chat;
}
elsif ($in{'mode'} eq 'read_chat'){
#ログ表示
&read_chat;
}
elsif ($in{'mode'} eq 'log_show'){
#ログ表示
&read_chat;
}
elsif ($in{'mode'} eq 'date_log_list'){
#ログ表示
&date_log_list;
}
elsif ($in{'mode'} eq 'dt'){
#詳細表示
&dt;
}
elsif ($in{'mode'} eq 'icon' && $uid eq 2){
#アイコンのみ表示
&icon;
}
elsif ($in{'mode'} eq 'yatai_item_list'){
#詳細表示
if ($pcid eq '' || $uid eq ''){&err("ログインされていない為、このサービスはご利用できません。");}
&yatai_item_list;
}
elsif ($in{'mode'} eq 'buy_yatai'){
#詳細表示
if ($pcid eq '' || $uid eq ''){&err("ログインされていない為、このサービスはご利用できません。");}
&buy_yatai;
}
elsif ($in{'mode'} eq 'buy_yatai2'){
#詳細表示
if ($pcid eq '' || $uid eq ''){&err("ログインされていない為、このサービスはご利用できません。");}
&buy_yatai2;
}
else{
&err_in("不正なパラメータ");
}
&disconDB($dbh);
exit;
#---------------------------------------
# 屋台フレーバーアイテムリスト
#---------------------------------------
sub yatai_item_list {
$out{'name'} = $name;
$sql = "select id,name,text,cp from yatai_sell_list where chat_id = $in{'id'} order by id;";
$ref = $dbh->selectall_arrayref($sql) or &err("エラーが発生しました。");
foreach(@$ref) {
($item_id,$item_name,$item_text,$cp)=@{$_};
$cp = $cp / 10;
$item_text = &newline_change($item_text);
$out{'list'} .=<<"EOT";
$item_name $cp
EOT
}
&out_enc;
&html_out("chat_yatai_list.html");
}
#---------------------------------------
# 購入確認
#---------------------------------------
sub buy_yatai {
$sql = "select name,class,sex,race,lumina,lumina_lv,cp from character where pcid = '$pcid';";
$ref = $dbh->selectall_arrayref($sql) or &err("エラーが発生しました。");
($out{'pcname'},$class,$sex,$race,$lumina,$lumina_lv,$pc_cp)=@{$ref->[0]};
$out{'pc_cp'} = $pc_cp / 10;
$out{'item_id'} = $in{'item_id'};
$out{'id'} = $in{'id'};
$sql = "select name,cp from yatai_sell_list where id = $in{'item_id'} and chat_id = $in{'id'};";
$ref = $dbh->selectall_arrayref($sql) or &err("CODE:Y-03 エラーが発生しました。");
($out{'item_name'},$cp)=@{$ref->[0]};
$out{'ncp'} = ($cp) / 10;
$pc_cp = $pc_cp / 10;
if ($out{'item_name'} eq ''){&err("指定されたアイテムは存在しません。");}
if ($pc_cp < $out{'ncp'}){
&cp_rp_yatai($pc_cp,$out{'ncp'});
}
&out_enc;
&html_out("chat_yatai_buy_conf.html");
}
#---------------------------------------
# 購入
#---------------------------------------
sub buy_yatai2 {
$sql = "select name,class,sex,race,lumina,lumina_lv,cp from character where pcid = '$pcid';";
$ref = $dbh->selectall_arrayref($sql) or &err("エラーが発生しました。");
($out{'pcname'},$class,$sex,$race,$lumina,$lumina_lv,$pc_cp)=@{$ref->[0]};
$out{'pc_cp'} = $pc_cp / 10;
$sql = "select name,cp from yatai_sell_list where id = $in{'item_id'} and chat_id = $in{'id'};";
$ref = $dbh->selectall_arrayref($sql) or &err("CODE:S-04 エラーが発生しました。");
($item_name,$cp)=@{$ref->[0]};
if ($item_name eq ''){&err("指定されたアイテムは存在しません。");}
$ncp = ($cp) / 10;
$pc_cp = $pc_cp / 10;
if ($pc_cp < $ncp){
&cp_rp_yatai2($pc_cp,$ncp);
$sql = "update character set cp = 0 where pcid = '$pcid';";
$dbh->do($sql) or &err("CODE:Y-05 エラーが発生しました。");
$use_cp = $pc_cp * 10;
if ($uid ne 4 && $uid ne 10 && $uid ne 8){
$use_rex_p = ($ncp - $pc_cp) * 100;
if ($use_rex_p eq ''){$use_rex_p = 0;}
}
else{
$use_rex_p = 0;
}
}
else{
$sql = "update character set cp = cp - ($cp) where pcid = '$pcid';";
$dbh->do($sql) or &err("CODE:Y-06 エラーが発生しました。");
$use_cp = $cp;
$use_rex_p = 0;
}
&log_write($pcid,'チャット屋台アイテム購入',"id:$in{'id'},item_id:$in{'item_id'},name:$item_name");
$sql = "insert into yatai_sell_log (pcid,id,use_cp,use_rex,chat_id) values ('$pcid',$in{'item_id'},$use_cp,$use_rex_p,$in{'id'});";
$dbh->do($sql) or &err("CODE:Y-08 エラーが発生しました。");
$out{'urex'} = &get_rex($pcid);
$sql = "select cp from character where pcid = '$pcid';";
$ref = $dbh->selectall_arrayref($sql) or &err("エラーが発生しました。");
($pc_cp)=@{$ref->[0]};
$out{'pc_cp'} = $pc_cp / 10;
&out_enc;
# &html_out("shop_buy_end.html");
print "Location: ./chat.cgi?id=$in{'id'}\n\n";
}
#---------------------------------------
# CP不足処理
#---------------------------------------
sub cp_rp_yatai {
my $usr_cp = $_[0];
my $need_cp = $_[1];
my $hcp = $need_cp - $usr_cp; #不足CP
my $rcp = $hcp * 100; #補填REX
my $rp = &get_rex($pcid);
if ($rp < $rcp && $uid ne 4 && $uid ne 10 && $uid ne 8){&err("CPが不足しているため、購入できません。");}
$out{'need_cp'} = $need_cp;
$out{'usr_cp'} = $usr_cp;
$out{'hcp'} = $hcp;
$out{'rcp'} = $rcp;
$out{'rp'} = $rp;
&out_enc;
&html_out("chat_yatai_buy_conf2.html");
exit;
}
#---------------------------------------
# CP不足購入処理
#---------------------------------------
sub cp_rp_yatai2 {
my $usr_cp = $_[0];
my $need_cp = $_[1];
my $hcp = $need_cp - $usr_cp; #不足CP
my $rcp = $hcp * 100; #補填REX
my $rp = &get_rex($pcid);
if ($rp < $rcp && $uid ne 4 && $uid ne 10 && $uid ne 8){&err("CPが不足しているため、購入できません。");}
my $trex = $rcp * -1;
if ($uid ne 4 && $uid ne 10 && $uid ne 8){
&use_rex($pcid,'',$trex,'チャット屋台購入REX補填',$id);
}
}
#---------------------------------------
# 設定ファイルチェック
#---------------------------------------
sub ini_chk {
$out{'b'} = 0;
# if ($uid eq 2){$out{'b'} = 1;}
&date_rtn;
#設定ファイルを取得
if ($in{'id'} eq ''){&err("ルームの指定がありません。");}
## if ($in{'type'} eq 'cross'){
## ## $dbh_x = &connectDB($plDB);
## $sql = "select name,start_time,end_time,npc_limit,look_limit,'','',bg_img,kasou_flg,item from chat_control where ";
## if ($in{'mode2'} ne 'all' && $in{'flg'} ne 1){
## }
## $sql .= "id = $in{'id'};";
## ## $ref = $dbh_x->selectall_arrayref($sql) or &err("CODE:C-021q エラーが発生しました。$sql");
## ($name,$start_time,$end_time,$npc_limit,$look_limit,$type,$scenario_seq,$flg_name_change,$flg_sex_change,$flg_class_change,$flg_lumina_change,$flg_tale_change,$flg_member,$out{'comment'},$school_flg,$bg_img,$kasou_flg,$item_list) = &rtn_db_data('select_line',$sql,'si');
## }
## else{
$sql = "select name,start_time,end_time,npc_limit,look_limit,type,scenario_seq,flg_name_change,flg_sex_change,flg_class_change,flg_lumina_change,flg_tale_change,flg_member,comment,school_flg,bg_img,kasou_flg,item from chat_control where ";
# if ($in{'mode2'} ne 'all' && $in{'flg'} ne 1 && $uid ne 2){
if($uid ne 86 && $uid ne 1717 && $uid ne 2729 && $uid ne 535 && $uid ne 241){
if ($in{'mode2'} ne 'all' && $in{'flg'} ne 1){
$sql .= "(start_time is null or (start_time is not null and start_time <= now())) and (end_time is null or (end_time is not null and end_time >= now())) and (switch = 1 or switch = 2) and ";
}
}
$sql .= "id = $in{'id'};";
$ref = $dbh->selectall_arrayref($sql) or &err("CODE:C-022 エラーが発生しました。");
($name,$start_time,$end_time,$npc_limit,$look_limit,$type,$scenario_seq,$flg_name_change,$flg_sex_change,$flg_class_change,$flg_lumina_change,$flg_tale_change,$flg_member,$out{'comment'},$school_flg,$bg_img,$kasou_flg,$item_list)=@{$ref->[0]};
## }
if ($out{'comment'} ne ''){
$out{'comment'} =<<"EOT";
EOT
}
## if(($uid ne 1717) and ($uid ne 2729) and ($uid ne 241)){
if($uid ne 86 && $uid ne 1717 && $uid ne 2729 && $uid ne 535 && $uid ne 241){
## if ($name eq '' && $in{'type'} ne 'cross'){&err("指定されたルームは入室できません。");}
if ($name eq ''){&err("指定されたルームは入室できません。");}
}
if ($flg_member ne ''){
$say_change_flg = 0;
@mem_list = split(/\,/,$flg_member);
foreach (@mem_list){
if ($_ eq $pcid){
$say_change_flg = 1;
last;
}
}
}
$s_flg = 1;
if ($school_flg ne ''){
$stand_flg = 0;
@ary_school = ();
@ary_school = split(/\,/,$school_flg);
foreach (@ary_school){
if ($pc_standpoint eq $_){
$stand_flg = 1;
last;
}
}
# if ($uid eq 2){&err("$pc_standpoint");}
if ($stand_flg eq 0){$s_flg = 0;}
}
if ($type eq 'scenario'){
$sql = "select pcid from scenario_member where pcid = '$pcid' and scenario_seq = $scenario_seq and entry_state in (1,11);";
$ref = $dbh->selectall_arrayref($sql) or &err("CODE:CS-01 エラーが発生しました。");
($temp)=@{$ref->[0]};
if ($temp eq ''){$s_flg = 0;}
}
if ($pcid ne '' && $uid eq 0){
if ($mid ne ''){
$tsize = 30;
}
else{
$tsize = 66;
}
$autotxt =<<"EOT";
自動リロード
EOT
chomp $autotxt;
$out{'say_txt'} =<<"EOT";
EOT
$out{'say_btn'} =<<"EOT";
$autotxt
EOT
$out{'say_btn2'} =<<"EOT";
EOT
$out{'say_btn3'} =<<"EOT";
リロード
文字数
EOT
$out{'name_str'} =<<"EOT";
$pcname
EOT
}
if (substr($pcid,0,2) ne 'xz' && $npc_limit eq 1){
$out{'say_txt'} = '';
$out{'name_str'} = '';
$out{'say_btn'} = '';
$out{'say_btn2'} = '';
$out{'say_btn3'} = '';
}
if (substr($pcid,0,2) ne 'xz' && $s_flg eq 0){
$out{'say_txt'} = '';
$out{'name_str'} = '';
$out{'say_btn'} = '';
$out{'say_btn2'} = '';
$out{'say_btn3'} = '';
}
# if ($ip ne '14.3.203.23'){
# $out{'say_txt'} = '';
# $out{'name_str'} = '';
# $out{'say_btn'} = '';
# $out{'say_btn2'} = '';
# $out{'say_btn3'} = '';
# }
# if ($type eq 'standing'){$out{'img'} = 'chat_title01.jpg';}
# if ($type eq 'standing'){$out{'img'} = 'chat_title01_halloween.jpg';}
# elsif ($type eq 'jw'){$out{'img'} = '../scenario/gi/gi01/gi01_formbana.jpg';}
# elsif ($type eq 'scenario'){$out{'img'} = 'chat_title02.jpg';}
# if ($another_flg eq 2){$out{'img'} = '../scenario/jw09/jw9_bana_spica.jpg';}
if($bg_img ne ''){
$out{'back_img'} = $bg_img;
}
$out{'room_name'} = $name;
}
#---------------------------------------
# TOP表示
#---------------------------------------
sub top {
if ($pcid ne '' && $out{'say_txt'} ne ''){
&date_rtn;
# if ($in{'id'} eq 38 && $uid eq 2 && substr($pcid,1,1) eq 'z'){
# if ($in{'id'} eq 38){
# $out{'iconlist'} = &icon_list1($pcid,'chat',$dbh,'halloween');
# }
# if ($uid eq 2){
if ($in{'id'} >= 42 && $in{'id'} <= 67){
$out{'iconlist'} = &icon_list1($pcid,'chat',$dbh,'halloween');
}
# elsif ($in{'id'} eq 115 && "$g_year$g_mon$g_mday$g_hour$g_min" >= "201010282000" && "$g_year$g_mon$g_mday$g_hour$g_min" <= "201011010200"){
elsif ($in{'id'} eq 115 && "$g_year$g_mon$g_mday$g_hour$g_min" <= "201011010200"){
$out{'iconlist'} = &icon_list1($pcid,'chat',$dbh,'halloween');
}
# elsif ($in{'id'} >= 99){
# $out{'iconlist'} = &icon_list1($pcid,'chat',$dbh,'halloween');
# }
elsif ($in{'id'} >= 181 && $in{'id'} <= 192){
$out{'iconlist'} = &icon_list1($pcid,'chat',$dbh,'halloween');
}
elsif ($in{'id'} >= 201 && $in{'id'} <= 202){ ##
$out{'iconlist'} = &icon_list1($pcid,'chat',$dbh,'halloween');
}
else{
if($kasou_flg ne 1){
$out{'iconlist'} = &icon_list1($pcid,'chat',$dbh);
}else{
$out{'iconlist'} = &icon_list1($pcid,'chat',$dbh,'halloween');
}
}
$sql = "select pet_flg,pet_list from chat_control where id= $in{'id'}";
$ref = $dbh->selectall_arrayref($sql) or &err("CODE:LI-028 エラーが発生しました。");
($pet_flg,$pet_list)=@{$ref->[0]};
if(($pet_flg eq 1) or ($pet_flg eq 2)){
$out{'iconlist'} .=&icon_list_p($pcid,'chat',$dbh,$pet_list);
}
}
#if($uid eq 2 || $uid eq 10){
$sql = "select count(*) from yatai_sell_list where chat_id = $in{'id'};";
$ref = $dbh->selectall_arrayref($sql) or &err("CODE:CS-01 エラーが発生しました。");
($temp)=@{$ref->[0]};
if ($temp ne '' && $temp > 0){
$out{'yatai_link'} =<<"EOT";
販売ブース
EOT
}
#}
if ($mid ne ''){$roomtop_html = "chat_room_top_m.html";}
else{
$roomtop_html = "chat_room_top_new.html";
if ($in{'type'} eq ''){
# $roomtop_html = "chat_room_top.html";
$roomtop_html = "chat_room_top_new.html";
# if ($uid eq 2){$roomtop_html = "chat_room_top_new_test.html";}
if ($in{'id'} eq 1){$out{'back_img'} = 'bg_chat_dormitory.jpg';}
elsif ($in{'id'} eq 39){$out{'back_img'} = 'bg_chat_dormitory.jpg';}
elsif ($in{'id'} eq 2){$out{'back_img'} = 'bg_chat_lib.jpg';}
elsif ($in{'id'} eq 3){$out{'back_img'} = 'bg_chat_art.jpg';}
elsif ($in{'id'} eq 6 || $in{'id'} eq 310){
if ($g_hour >= 7 && $g_hour < 18){$out{'back_img'} = 'bg_chat_spa_day.jpg';}
else{$out{'back_img'} = 'bg_chat_spa_night.jpg';}
}
elsif ($in{'id'} eq 113){
if ($g_hour >= 7 && $g_hour < 18){$out{'back_img'} = 'bg_chat_seika_day.jpg';}
else{$out{'back_img'} = 'bg_chat_seika_night.jpg';}
}
elsif ($in{'id'} eq 86){$out{'back_img'} = 'bg_chat_ent.jpg';}
elsif ($in{'id'} eq 87){$out{'back_img'} = 'bg_chat_xh09.jpg';}
elsif ($in{'id'} >= 100 && $in{'id'} <= 109){$out{'back_img'} = 'bg_chat_xh10.jpg';}
elsif ($in{'id'} eq 110){$out{'back_img'} = 'bg_chat_xh10_2.jpg';}
elsif ($in{'id'} eq 111){$out{'back_img'} = 'bg_chat_autumn.jpg';}
elsif ($in{'id'} eq 114){$out{'back_img'} = 'bg_chat_club.jpg';}
elsif ($in{'id'} eq 115){$out{'back_img'} = 'bg_chat_ent.jpg';}
elsif ($in{'id'} eq 116){$out{'back_img'} = 'bg_chat_ent.jpg';}
elsif ($in{'id'} eq 154){$out{'back_img'} = 'bg_chat_kyo.jpg';}
elsif ($in{'id'} >= 118 && $in{'id'} <= 153){$out{'back_img'} = 'bg_chat_gakuensai.jpg';}
elsif ($in{'id'} eq 5){$out{'back_img'} = 'bg_chat_kyo_pan.jpg';}
elsif ($in{'id'} eq 156){$out{'back_img'} = 'bg_chat_dormitory.jpg';}
elsif ($in{'id'} eq 157 || $in{'id'} eq 158){$out{'back_img'} = 'bg_chat_kaizoku.jpg';}
elsif ($in{'id'} eq 75){$out{'back_img'} = 'bg_chat_usokabe.jpg';}
elsif ($in{'id'} eq 160 || $in{'id'} eq 161 || $in{'id'} eq 162){$out{'back_img'} = 'bg_chat_ent.jpg';}
elsif ($in{'id'} eq 163){$out{'back_img'} = 'bg_chat_ent.jpg';}
elsif ($in{'id'} >= 169 && $in{'id'} <= 171){$out{'back_img'} = 'bg_chat_xh09.jpg';}
elsif ($in{'id'} eq 172){$out{'back_img'} = 'bg_chat_xh16.jpg';}
elsif ($in{'id'} eq 173){$out{'back_img'} = 'bg_chat_xh16.jpg';}
elsif ($in{'id'} eq 175 || $in{'id'} eq 176 || $in{'id'} eq 177 || ($in{'id'} >= 181 && $in{'id'} <= 189)){$out{'back_img'} = 'bg_chat_xh17.jpg';}
elsif ($in{'id'} eq 193){$out{'back_img'} = 'bg_chat_xh17_2.jpg';}
elsif ($in{'id'} eq 199){$out{'back_img'} = 'bg_chat_kyo.jpg';}
elsif ($in{'id'} eq 201){$out{'back_img'} = 'bg_chat_xh18_2.jpg';}
elsif ($in{'id'} eq 202){$out{'back_img'} = 'bg_chat_xh18.jpg';}
elsif ($in{'id'} eq 239){$out{'back_img'} = 'bg_chat_xh18.jpg';}
else{
# $roomtop_html = "chat_room_top.html";
}
}
else{
## $roomtop_html = "chat_room_top_new_none.html";
## $roomtop_html = "chat_room_top_m.html";
}
}
# $roomtop_html = "chat_room_top.html";
&out_enc;
&html_out($roomtop_html);
}
#---------------------------------------
# 発言フォーム
#---------------------------------------
sub say_form {
$sql = "";
}
#---------------------------------------
# 日付まとめ
#---------------------------------------
sub date_log_list {
## if ($in{'type'} eq 'cross'){
## $dbh_x = &connectDB($plDB);
## $sql = "select substr(say_time,1,10),count(*) from chat_log where id = $in{'id'} group by substr(say_time,1,10) order by substr(say_time,1,10) desc;";
## $ref = $dbh_x->selectall_arrayref($sql) or &err("エラーが発生しました。");
## }
## else{
$sql = "select substr(say_time,1,10),count(*) from chat_log where id = $in{'id'} group by substr(say_time,1,10) order by substr(say_time,1,10) desc;";
$ref = $dbh->selectall_arrayref($sql) or &err("エラーが発生しました。");
## }
foreach(@$ref) {
($ldate,$cnt)=@{$_};
$ldate2 = $ldate;
$ldate =~ s/\-/\//g;
if ($look_limit eq 1){
$lk =<<"EOT";
$mycgi?mode=read_chat&id=$in{'id'}&mode2=date&date=$ldate2&flg=1&type=$in{'type'}
EOT
}
else{
$lk =<<"EOT";
$mycgi?mode=read_chat&id=$in{'id'}&mode2=date&date=$ldate2&type=$in{'type'}
EOT
}
if ($in{'id'} eq 1 || $in{'id'} eq 3 || $in{'id'} eq 6){
$out{'body'} .=<<"EOT";
$ldate $cnt
EOT
}else{
$out{'body'} .=<<"EOT";
$ldate
EOT
}
}
if ($in{'type'} ne 'cross'){
$sql = "select substr(say_time,1,10),count(*) from chat_log_old where id = $in{'id'}";
# if ($in{'id'} eq 1){$sql .= " and say_time >= now() + '-1 weeks'";}
# $sql .= " and say_time <= now() + '-1 months'";
# else{$sql .= " and say_time <= now() + '-1 months'";}
# elsif{$in{'id'} eq 3 || $in{'id'} eq 6){$sql .= " and say_time >= now() + '-1 months'";}
$sql .= " group by substr(say_time,1,10) order by substr(say_time,1,10) desc;";
$ref = $dbh->selectall_arrayref($sql) or &err("エラーが発生しました。");
foreach(@$ref) {
($ldate,$cnt)=@{$_};
$ldate2 = $ldate;
$ldate =~ s/\-/\//g;
if ($look_limit eq 1){
$lk =<<"EOT";
$mycgi?mode=read_chat&id=$in{'id'}&mode2=date&date=$ldate2&flg=1&type=$in{'type'}&old=1
EOT
}
else{
$lk =<<"EOT";
$mycgi?mode=read_chat&id=$in{'id'}&mode2=date&date=$ldate2&type=$in{'type'}&old=1
EOT
}
if ($in{'id'} eq 1 || $in{'id'} eq 3 || $in{'id'} eq 6){
$out{'body'} .=<<"EOT";
$ldate $cnt
EOT
}else{
$out{'body'} .=<<"EOT";
$ldate
EOT
}
}
# if ($in{'id'} eq 1 || $in{'id'} eq 3 || $in{'id'} eq 6){
# }
# else{
use Net::FTP;
if ($server_name eq ''){$server_name = 'rexis.jp';}
if ($server_user eq ''){$server_user = 'rexis-jp';}
if ($server_pass eq ''){$server_pass = 'Ouv5zepJ';}
$ftp = Net::FTP->new($server_name, Debug => 0)
or die &err("Cannot connect to some.host.name: $@");
$ftp->login($server_user,$server_pass)
or die &err("Cannot login " . $ftp->message);
$ftp->binary;
$flg = 0;
$ftp->cwd("/public_html/gx/chat_log/" . $in{'id'})
# or die &err("Cannot change working directory " . $ftp->message . " ");
or $flg = 1;
if ($flg eq 0){
@filelist = ();
@filelist = $ftp->dir(); # ファイルリストを獲得
$ftp->quit;
@dlist = ();
foreach (@filelist){
$tmp = $_;
chomp $tmp;
$dbg .= $tmp . " ";
@b = ();
@b = split(/\ /,$tmp);
$tmp = @b[$#b];
$dbg .= $tmp . " " . substr($tmp,-4) . " ";
if (substr($tmp,-4) eq 'html'){push dlist,$tmp;}
}
# if ($uid eq 2){&err($dbg);}
# $fdir = "/home/rexi-jp/public_html/gx/chat_log/" . $in{'id'} . "/";
# @dlist = ();
# opendir(DIR,$fdir);
# foreach(readdir(DIR)){
# next if /^\.{1,2}$/; # '.'や'..'をスキップ
# $tmp = $_;
# if (substr($tmp,-4) eq 'html'){push dlist,$_;}
# }
@sortedarray = ();
@sortedarray = sort { $b cmp $a } @dlist;
foreach (@sortedarray){
$dname = $_;
$dir_name = "/home/rexi-jp/public_html/gx/chat_log/" . $in{'id'} . "/" . $dname;
# if (-e $dir_name){
$ldate = substr($dname,-13,4) . "/" . substr($dname,-9,2) . "/" . substr($dname,-7,2);
$out{'body'} .=<<"EOT";
$ldate
EOT
}
# }
# closedir DIR;
}
# }
}else{
##cross
$sql = "select substr(say_time,1,10),count(*) from chat_log_old where id = $in{'id'}";
# if ($in{'id'} eq 1){$sql .= " and say_time >= now() + '-1 weeks'";}
# else{$sql .= " and say_time <= now() + '-1 months'";}
# $sql .= " and say_time <= now() + '-1 months'";
# elsif{$in{'id'} eq 3 || $in{'id'} eq 6){$sql .= " and say_time >= now() + '-1 months'";}
$sql .= " group by substr(say_time,1,10) order by substr(say_time,1,10) desc;";
$ref = $dbh->selectall_arrayref($sql) or &err("エラーが発生しました。");
foreach(@$ref) {
($ldate,$cnt)=@{$_};
$ldate2 = $ldate;
$ldate =~ s/\-/\//g;
if ($look_limit eq 1){
$lk =<<"EOT";
$mycgi?mode=read_chat&id=$in{'id'}&mode2=date&date=$ldate2&flg=1&type=$in{'type'}&old=1
EOT
}
else{
$lk =<<"EOT";
$mycgi?mode=read_chat&id=$in{'id'}&mode2=date&date=$ldate2&type=$in{'type'}&old=1
EOT
}
if ($in{'id'} eq 1 || $in{'id'} eq 3 || $in{'id'} eq 6){
$out{'body'} .=<<"EOT";
$ldate $cnt
EOT
}else{
$out{'body'} .=<<"EOT";
$ldate
EOT
}
}
if ($in{'id'} eq 1 || $in{'id'} eq 3 || $in{'id'} eq 6){
}
else{
use Net::FTP;
if ($server_name eq ''){$server_name = 'rexis.jp';}
if ($server_user eq ''){$server_user = 'rexis-jp';}
if ($server_pass eq ''){$server_pass = 'Ouv5zepJ';}
$ftp = Net::FTP->new($server_name, Debug => 0)
or die &err("Cannot connect to some.host.name: $@");
$ftp->login($server_user,$server_pass)
or die &err("Cannot login " . $ftp->message);
$ftp->binary;
$flg = 0;
$ftp->cwd("/public_html/gx/chat_log/" . $in{'id'})
# or die &err("Cannot change working directory " . $ftp->message . " ");
or $flg = 1;
if ($flg eq 0){
@filelist = ();
@filelist = $ftp->dir(); # ファイルリストを獲得
$ftp->quit;
@dlist = ();
foreach (@filelist){
$tmp = $_;
chomp $tmp;
$dbg .= $tmp . " ";
@b = ();
@b = split(/\ /,$tmp);
$tmp = @b[$#b];
$dbg .= $tmp . " " . substr($tmp,-4) . " ";
if (substr($tmp,-4) eq 'html'){push dlist,$tmp;}
}
# if ($uid eq 2){&err($dbg);}
# $fdir = "/home/rexi-jp/public_html/gx/chat_log/" . $in{'id'} . "/";
# @dlist = ();
# opendir(DIR,$fdir);
# foreach(readdir(DIR)){
# next if /^\.{1,2}$/; # '.'や'..'をスキップ
# $tmp = $_;
# if (substr($tmp,-4) eq 'html'){push dlist,$_;}
# }
@sortedarray = ();
@sortedarray = sort { $b cmp $a } @dlist;
foreach (@sortedarray){
$dname = $_;
$dir_name = "/home/rexi-jp/public_html/gx/chat_log/" . $in{'id'} . "/" . $dname;
# if (-e $dir_name){
$ldate = substr($dname,-13,4) . "/" . substr($dname,-9,2) . "/" . substr($dname,-7,2);
$out{'body'} .=<<"EOT";
$ldate
EOT
}
# }
# closedir DIR;
}
}
}
&out_enc;
if ($mid ne ''){$html_file = "chat_all_log_date_m.html";}
else{$html_file = "chat_all_log_date.html";}
&html_out($html_file);
}
#---------------------------------------
# アイコン表示
#---------------------------------------
sub icon {
# if ($in{'mode2'} eq 'date' && $in{'date'} ne ''){$where = " and substr(say_time,1,10) = '$in{'date'}' ";}
$sql = "select distinct pcid,pcname from chat_log where id = $in{'id'} and icon like '%synthesis_icon%' and (icon like '%_jpg.%' or icon like '%_JPG.%' or icon like '%_gif.%' or icon like '%_GIF.%' or icon like '%_png.%' or icon like '%_PNG.%') $where group by pcid,pcname order by pcid;";
$ref = $dbh->selectall_arrayref($sql) or &err("エラーが発生しました。");
foreach(@$ref) {
($lpcid,$lpcname)=@{$_};
$ary_pc{$lpcid} = $lpcname;
}
$sql = "select distinct pcid,pcname from chat_log_old where id = $in{'id'} and icon like '%synthesis_icon%' and (icon like '%_jpg.%' or icon like '%_JPG.%' or icon like '%_gif.%' or icon like '%_GIF.%' or icon like '%_png.%' or icon like '%_PNG.%') $where group by pcid,pcname order by pcid;";
$ref = $dbh->selectall_arrayref($sql) or &err("エラーが発生しました。");
foreach(@$ref) {
($lpcid,$lpcname)=@{$_};
$ary_pc{$lpcid} = $lpcname;
}
foreach $lpcid ( sort keys %ary_pc ){
$lpcname = $ary_pc{$lpcid};
$num = 1;
$i = 0;
@ary_licon = ();
$body2 = '';
$body .=<<"EOT";
・$lpcname($lpcid)
EOT
$sql2 = "select distinct icon from chat_log where id = $in{'id'} and pcid = '$lpcid' and icon like '%synthesis_icon%' and (icon like '%_jpg.%' or icon like '%_JPG.%' or icon like '%_gif.%' or icon like '%_GIF.%' or icon like '%_png.%' or icon like '%_PNG.%') and icon is not null group by icon order by icon;";
$ref2 = $dbh->selectall_arrayref($sql2) or &err("エラーが発生しました。");
foreach(@$ref2) {
($licon)=@{$_};
push ary_licon,$licon;
}
$sql2 = "select distinct icon from chat_log_old where id = $in{'id'} and pcid = '$lpcid' and icon like '%synthesis_icon%' and (icon like '%_jpg.%' or icon like '%_JPG.%' or icon like '%_gif.%' or icon like '%_GIF.%' or icon like '%_png.%' or icon like '%_PNG.%') and icon is not null group by icon order by icon;";
$ref2 = $dbh->selectall_arrayref($sql2) or &err("エラーが発生しました。");
foreach(@$ref2) {
($licon)=@{$_};
push ary_licon,$licon;
}
$prv_icon = '';
%seen = ();
@uniq = ();
foreach $item (@ary_licon) {
$seen{$item}++;
}
@uniq = keys %seen;
@uniq = sort {$a cmp $b} @uniq;
foreach(@uniq){
$licon = $_;
if ($i eq 0){
$body .=<<"EOT";
EOT
$body2 .=<<"EOT";
EOT
}
$body .=<<"EOT";
EOT
$body2 .=<<"EOT";
$num
EOT
$num++;
$i++;
if ($i >= 13){
$i = 0;
$body .=<<"EOT";
$body2
EOT
$body2 = '';
}
}
if ($i > 0){
$k = 13 - $i;
$body .=<<"EOT";
$body2
EOT
}
$body .=<<"EOT";
EOT
}
$out{'body'} = $body;
$out{'id'} = $in{'id'};
$out{'mode'} = $in{'mode'};
$out{'mode2'} = $in{'mode2'};
$out{'date'} = $in{'date'};
$out{'old'} = $in{'old'};
&out_enc;
&out_enc;
&html_out('chat_all_log.html');
}
#---------------------------------------
# ログ表示
#---------------------------------------
sub read_chat {
if ($in{'mode2'} eq 'date' && $in{'date'} ne ''){
$ldate = $in{'date'};
$ldate =~ s/\-//g;
$fname = "/home/rexi-jp/public_html/gx/chat_log/" . $in{'id'} . "/" . $in{'id'} . "_" . $ldate . ".html";
if (-e $fname){
print "Location: http://rexi.jp/gx/chat_log/$in{'id'}/$in{'id'}_$ldate.html\n\n";
if ($dbh ne ''){&disconDB($dbh);}
exit;
}
}
if ($in{'mode2'} eq ''){
$start_pos = 0;
$lmt = 15;
if ($mid ne ''){$lmt = 10;}
}
else{
if ($in{'p'} eq ''){$in{'p'} = 1;}
# $pcn = 200;
$pcn = 50;
if ($mid ne ''){$pcn = 30;}
$start_pos = ($in{'p'} - 1) * $pcn;
$lmt = $pcn;
}
$i = 0;
$where = '';
if ($in{'mode2'} eq 'date' && $in{'date'} ne ''){$where = " and substr(say_time,1,10) = '$in{'date'}' ";}
if ($in{'old'} eq 1){$tbl = "chat_log_old";}
else{$tbl = "chat_log";}
#最新発言者の全身図表示
$sql = "select pcid,pcname,sex,age,class,icon,say,say_time,lumina,item,numbering,clumina,cclass,race,zensin from $tbl where id = $in{'id'} $where order by ";
if (($in{'mode2'} eq 'date' && $in{'date'} ne '') || ($in{'mode'} eq 'log_show' && $in{'mode2'} eq 'all')){
$sql .= "say_time,pcid ";
}else{$sql .= "say_time desc,pcid ";}
$sql .= "offset $start_pos limit $lmt;";
$ref = $dbh->selectall_arrayref($sql) or &err("エラーが発生しました。");
if ($in{'mode'} eq 'read_chat' && $in{'mode2'} eq 'date'){
$sql_cnt = "select count(*) from $tbl where id = $in{'id'} $where;";
$ref_cnt = $dbh->selectall_arrayref($sql_cnt) or &err("CODE:C-11 エラーが発生しました。");
($say_log_cnt)=@{$ref_cnt->[0]};
$all_p_num = int($say_log_cnt / $lmt);
if (($say_log_cnt / $lmt) - int($say_log_cnt / $lmt) > 0){$all_p_num++;}
for ($pcnt=1;$pcnt<=$all_p_num;$pcnt++){
if ($in{'p'} eq $pcnt){
$pstr .=<<"EOT";
$pcnt
EOT
}else{
$pstr .=<<"EOT";
$pcnt
EOT
}
chomp $pstr;
}
chop $pstr;
$pstr1 = '<' . $pstr . "> ";
$pstr2 = " <" . $pstr . '>';
}
foreach(@$ref) {
($lpcid,$lpcname,$lsex,$lage,$lclass,$licon,$lsay,$lsay_time,$lumina,$item,$numbering,$clumina,$cclass,$crace,$zensin)=@{$_};
if($crace eq 6 && substr($lpcid,0,2) ne 'xz' && $zensin ne ''){
$sql2 = "select pdid from stars_data where url = '$zensin';";
$ref2 = $dbh->selectall_arrayref($sql) or &err("CODE:C-01 エラーが発生しました。");
($s_pdid)=@{$ref2->[0]};
if(($s_pdid eq 'G01') or ($s_pdid eq 'C14')){
$zensin = 'http://rexis.jp/stars/data/gx_shefool/'.substr($zensin,38);
}
}
if ($in{'type'} ne 'cross'){ #クロスの場合、ルミナ、レースを取得しない(処理軽減)
if ($lumina eq '' || $crace eq ''){
$sql2 = "select lumina,race from character where pcid = '$lpcid';";
$ref2 = $dbh->selectall_arrayref($sql2) or &err("CODE:C-01A エラーが発生しました。");
($lumina,$crace)=@{$ref2->[0]};
}
if ($cclass eq ''){$class_name = @class_str2[$lclass];}
elsif ($cclass ne ''){$class_name = $cclass;}
if ($class_name eq ''){$class_name = '?';}
}else{
$class_name ='';
}
$lsay_time2 = $lsay_time;
$lsay_time =~ s/\-/\//g;
$lsay_time = substr($lsay_time,0,19);
$myp_link1 =<<"EOT";
EOT
$myp_link2 = ' ';
if ($mid ne ''){
$myp_link1 = '';
$myp_link2 = '';
$class_name = @class_str_m[$lclass];
}
if ($in{'type'} eq 'cross'){ #クロスの場合、ルミナ、レースを取得しない(処理軽減)
$class_name = '';
}
if (int($lsex) eq 1 || int($lsex) eq 2){$sex_str = @sex_mark[$lsex];}
else{$sex_str = $lsex;}
if ($in{'type'} eq 'cross'){
if (substr($lpcid,0,1) eq 'j'){
$myp_link1 =<<"EOT";
EOT
$myp_link2 = ' ';
}elsif (substr($lpcid,0,1) eq 's'){
$myp_link1 =<<"EOT";
EOT
$myp_link2 = ' ';
}
}else{
$lumina_name = @lumina_str[$lumina];
$race_name = @race_str2[$crace];
if ($clumina ne ''){$lumina_name = $clumina;}
## if (int($lsex) eq 1 || int($lsex) eq 2){$sex_str = @sex_mark[$lsex];}
## else{$sex_str = $lsex;}
}
if ($numbering ne ''){$numbering .= " ";}
if ($item ne ''){$item = ' ' . $item . ' ';}
$lsay_time = substr($lsay_time,5);
$i_w = 50;
$i_h = 50;
if ($mid ne ''){
$licon = &mb_img_rtn($licon,25,25);
$i_w = 25;
$i_h = 25;
$lsay_time = substr($lsay_time,6);
}
$style = '';
if (&death_check($lpcid,$dbh) eq 1){
# $style = 'STYLE="filter: alpha(opacity=50); -moz-opacity:0.50; opacity:0.50;"';
$style = "STYLE=\\'filter: alpha(opacity=50); -moz-opacity:0.50; opacity:0.50;\\'";
## $style = ' id=toumei ';
}
if ($zensin ne ''){
$szensin = " ";
if ($i eq 0 && $mid eq ''){
$out{'say_zensin'} = $szensin;
$zen_file = substr($zensin,15);
($format,$width,$height) = &GetImageSize("/home/rexi-jp/public_html/$zen_file");
# $style = '';
# if (&death_check($zpcid,$dbh) eq 1){$style = 'STYLE="filter: alpha(opacity=50); -moz-opacity:0.50; opacity:0.50;"';}
$out{'say_zensin'} =<<"EOT";
EOT
chomp $out{'say_zensin'};
}
}
else{$szensin = "";}
if (($in{'mode2'} eq 'all' or $in{'mode2'} eq 'date')){
if ($zensin eq ''){$zensin = 'http://rexi.jp/gx/images/00_click.gif';}
if ($i eq 0 && $zensin ne ''){
# if (&death_check($lpcid,$dbh) eq 1){$style = 'STYLE="filter: alpha(opacity=50); -moz-opacity:0.50; opacity:0.50;"';}
$out{'say_zensin'} =<<"EOT";
EOT
chomp $out{'say_zensin'};
}
if(substr($lpcid,0,2) ne 'xp'){
$body .=<<"EOT";
$myp_link1$lpcid$myp_link2 $lpcname $numbering$sex_str $lage歳 $race_name $class_name $lumina_name $item
$lsay_time
$lsay
EOT
}else{
$uidx = index($lpcname,'xc');
if($uidx < 0){
$uidx = index($lpcname,'xz');
}
if($uidx < 0){
$uidx = index($lpcname,'xb');
}
if($uidx < 0){
$uidx = index($lpcname,'xa');
}
if($uidx < 0){
$uidx = index($lpcname,'xd');
}
if($uidx < 0){
$uidx = index($lpcname,'xe');
}
if($uidx < 0){
$uidx = index($lpcname,'xf');
}
if($uidx >0){
$upcid = substr($lpcname,$uidx,6);
$upcid_j =<<"EOT";
$upcid
EOT
$lpcname =~ s/$upcid/$upcid_j/i; #// abc を 123 に
}
$body .=<<"EOT";
$lpcid
$lpcname
$lsay_time
$lsay
EOT
}
}
else{
if(substr($lpcid,0,2) ne 'xp'){
#######icon
$body .=<<"EOT";
$myp_link1$lpcid$myp_link2 $lpcname $numbering$sex_str $lage歳 $race_name $class_name $lumina_name $item
$lsay_time
$lsay
EOT
}else{
$uidx = index($lpcname,'xc');
if($uidx < 0){
$uidx = index($lpcname,'xz');
}
if($uidx < 0){
$uidx = index($lpcname,'xb');
}
if($uidx < 0){
$uidx = index($lpcname,'xa');
}
if($uidx < 0){
$uidx = index($lpcname,'xd');
}
if($uidx < 0){
$uidx = index($lpcname,'xe');
}
if($uidx < 0){
$uidx = index($lpcname,'xf');
}
if($uidx >0){
$upcid = substr($lpcname,$uidx,6);
$upcid_j =<<"EOT";
$upcid ))
EOT
$lpcname =substr($lpcname,0,$uidx).$upcid_j; #// abc を 123 に
}
$body .=<<"EOT";
$lpcid $lpcname
$lsay_time
$lsay
EOT
}
}
$i++;
}
$out{'bd'} = 0;
# if ($uid eq 2){$out{'bd'} = 1;}
if ($i eq 0){$out{'body'} = '発言はありません。';}
else{
$out{'body'} =<<"EOT";
$pstr1
$pstr2
EOT
}
$out{'id'} = $in{'id'};
$out{'mode'} = $in{'mode'};
$out{'mode2'} = $in{'mode2'};
$out{'date'} = $in{'date'};
$out{'old'} = $in{'old'};
&out_enc;
if($in{'mode2'} eq 1){
print $header;
print $out{'body'};
}
elsif ($in{'mode2'} eq 'all' || $in{'mode2'} eq 'date'){
$out{'nxt'} = $in{'p'} + 1;
if ($mid ne ''){$htmlfile = "chat_all_log_m.html";}
else{$htmlfile = "chat_all_log.html";}
# $htmlfile = "chat_all_log.html";
&html_out($htmlfile);
}
else{
if ($mid ne ''){$htmlfile = "chat_log_m.html";}
else{$htmlfile = "chat_log.html";}
# $htmlfile = "chat_log.html";
&html_out($htmlfile);
}
}
#---------------------------------------
# 発言
#---------------------------------------
sub write_chat {
&in_enc;
if ($in{'pcid'} ne $pcid){&err_in("発言しようとしているキャラクターと、現在ログインしているキャラクターが一致しません。");}
if ($in{'say_icon'} eq ''){&err_in("アイコンが選択されていません。");}
if ($in{'saybody'} eq ''){
print "Location: ./$mycgi?mode=read_chat&id=$in{'id'}&type=$in{'type'}\n\n";
exit;
}
$len = length($in{'saybody'});
if ($len > 200){&err_in("発言は全角100文字までです。");}
if(($in{'say_icon'} eq 'http://rexi.jp/gx/images/npc/_pet.jpg') or(rindex($in{'say_icon'},'_C18_') ne -1)){
$pet_flg= 1;
$sql = "select xpid,pet_name,zensin,free_setting from pet where walk_pcid = '$pcid' and walk_end > now() order by walk_start desc ;";
$ref = $dbh->selectall_arrayref($sql) or &err("CODE:SP4-0e4 エラーが発生しました。$sql");
($xpid,$pet_name,$p_zensin,$free_setting)=@{$ref->[0]};
if($xpid eq ''){
&err_in("ペットのお散歩時間が終了しました。");
}
}else{
$pet_flg= 0;
}
if ($in{'type'} eq 'cross'){
# $sql = "select name from
}
else{
$sql = "select name,start_time,end_time,npc_limit,look_limit,type,scenario_seq,flg_name_change,flg_sex_change,flg_class_change,flg_lumina_change,flg_tale_change,flg_member,comment,school_flg,item from chat_control where ";
if($in{'id'} ne 203){
if($uid ne 1717){
if ($in{'mode2'} ne 'all' && $in{'flg'} ne 1){
$sql .= "(start_time is null or (start_time is not null and start_time <= now())) and (end_time is null or (end_time is not null and end_time >= now())) and (switch = 1 or switch = 2) and ";
}
}
}
$sql .= "id = $in{'id'};";
$ref = $dbh->selectall_arrayref($sql) or &err("CODE:C-024 エラーが発生しました。");
($name,$start_time,$end_time,$npc_limit,$look_limit,$type,$scenario_seq,$flg_name_change,$flg_sex_change,$flg_class_change,$flg_lumina_change,$flg_tale_change,$flg_member,$out{'comment'},$school_flg,$item_list)=@{$ref->[0]}
}
##if(($uid ne 1717) and ($uid ne 241)){
if($uid ne 86 && $uid ne 1717 && $uid ne 2729 && $uid ne 535 && $uid ne 241){
if ($name eq '' ){&err("指定されたルームは入室できません。");}
}
if ($flg_member ne ''){
$say_change_flg = 0;
@mem_list = split(/\,/,$flg_member);
foreach (@mem_list){
if ($_ eq $pcid){
$say_change_flg = 1;
last;
}
}
}
$s_flg = 1;
if($uid eq 1717){
$say_change_flg = 1;
}
if ($school_flg ne ''){
$stand_flg = 0;
@ary_school = ();
@ary_school = split(/\,/,$school_flg);
foreach (@ary_school){
if ($pc_standpoint eq $_){
$stand_flg = 1;
last;
}
}
if ($stand_flg eq 0){$s_flg = 0;}
}
if ((substr($pcid,0,2) ne 'xz' && $npc_limit eq 1) || (substr($pcid,0,2) ne 'xz' && $s_flg eq 0)){
&err("現在ログインされているキャラクターでは、このチャットで発言出きません。");
}
if ($type eq 'scenario'){
$sql = "select pcid from scenario_member where pcid = '$pcid' and scenario_seq = $scenario_seq and entry_state in (1,11);";
$ref = $dbh->selectall_arrayref($sql) or &err("CODE:CS-01 エラーが発生しました。");
($temp)=@{$ref->[0]};
if ($temp eq ''){$s_flg = 0;}
}
#ダイスシステム
$d100_1 = index($in{'saybody'},'[D100]');
$d100_2 = index($in{'saybody'},'[d100]');
$d10_1 = index($in{'saybody'},'[D10]');
$d10_2 = index($in{'saybody'},'[d10]');
$d10_3 = index($in{'saybody'},'[1D10]');
$d10_4 = index($in{'saybody'},'[1d10]');
$d6_1 = index($in{'saybody'},'[D6]');
$d6_2 = index($in{'saybody'},'[d6]');
$d3_1 = index($in{'saybody'},'[D3]');
$d3_2 = index($in{'saybody'},'[d3]');
if (($d100_1 ne -1 && $d100_1 ne '') || ($d100_2 ne -1 && $d100_2 ne '')){
$rnd = int(rand(100));
$in{'saybody'} =~ s/\[D100\]//g;
$in{'saybody'} =~ s/\[d100\]//g;
$in{'saybody'} = '[D100] → ' . $rnd . ' ' . $in{'saybody'};
# $sql = "select text from chat_control_dice where id = $in{'id'} and dice = 100 and num = $rnd;";
# $ref = $dbh->selectall_arrayref($sql) or &err("CODE:CD-01 エラーが発生しました。");
# ($dtext)=@{$ref->[0]};
# if ($dtext ne ''){
# $in{'saybody'} .= ":" . $dtext;
# if ($in{'id'} eq 68){
# $f_idx = index ($dtext,'「');
# $e_idx = index ($dtext,'」',$f_idx+2);
# if ($f_idx >= 0 && $e_idx >= 0){
# $e_idx2 = (length($dtext) - $e_idx) * -1;
# $flaver = substr($dtext,$f_idx+2,$e_idx2);
# if ($flaver ne ''){
# $sql = "insert into chat_flavor (id,pcid,name) values ($in{'id'},'$pcid','$flaver');";
# $dbh->do($sql) or &err("CODE:C01X エラーが発生しました。");
# }
# }
# }
# }
$max_d = 100;
}
elsif (($d6_1 ne -1 && $d6_1 ne '') || ($d6_2 ne -1 && $d6_2 ne '')){
$rnd = int(rand(6)) + 1;
$in{'saybody'} =~ s/\[D6\]//g;
$in{'saybody'} =~ s/\[d6\]//g;
$in{'saybody'} = '[D6] → ' . $rnd . ' ' . $in{'saybody'};
$max_d = 6;
}
elsif (($d3_1 ne -1 && $d3_1 ne '') || ($d3_2 ne -1 && $d3_2 ne '')){
$rnd = int(rand(3)) + 1;
$in{'saybody'} =~ s/\[D3\]//g;
$in{'saybody'} =~ s/\[d3\]//g;
$in{'saybody'} = '[D3] → ' . $rnd . ' ' . $in{'saybody'};
$max_d = 3;
}
elsif (($d10_1 ne -1 && $d10_1 ne '') || ($d10_2 ne -1 && $d10_2 ne '') || ($d10_3 ne -1 && $d10_3 ne '') || ($d10_4 ne -1 && $d10_4 ne '')){
$rnd = int(rand(10)) + 1;
$in{'saybody'} =~ s/\[D10\]//g;
$in{'saybody'} =~ s/\[d10\]//g;
$in{'saybody'} =~ s/\[1d10\]//g;
$in{'saybody'} =~ s/\[1D10\]//g;
$sql = "select text from chat_control_dice where id = $in{'id'} and dice = 10 and num = $rnd;";
$ref = $dbh->selectall_arrayref($sql) or &err("CODE:CD-01 エラーが発生しました。");
($dtext)=@{$ref->[0]};
$in{'saybody'} = '[D10] → ' . $rnd . ' ' . $in{'saybody'};
if ($dtext ne ''){
$in{'saybody'} .= ":" . $dtext;
if ($in{'id'} eq 68){
$f_idx = index ($dtext,'「');
$e_idx = index ($dtext,'」',$f_idx+2);
if ($f_idx >= 0 && $e_idx >= 0){
$e_idx2 = (length($dtext) - $e_idx) * -1;
$flaver = substr($dtext,$f_idx+2,$e_idx2);
if ($flaver ne ''){
$sql = "insert into chat_flavor (id,pcid,name) values ($in{'id'},'$pcid','$flaver');";
$dbh->do($sql) or &err("CODE:C01X エラーが発生しました。");
}
}
}
}
$max_d = 10;
}
elsif ((substr($in{'saybody'},0,2) eq '[D' || substr($in{'saybody'},0,2) eq '[d') && substr($in{'saybody'},-1) eq ']'){
#1個
if (substr($in{'saybody'},-2,1) eq 'A'){
$max_d = substr($in{'saybody'},2,-2);
}
else{
$max_d = substr($in{'saybody'},2,-1);
}
if ($max_d eq 4 || $max_d eq 6 || $max_d eq 8 || $max_d eq 10 || $max_d eq 12 || $max_d eq 20 || $max_d eq 30 || $max_d eq 50 || $max_d eq 100){
if (substr($in{'saybody'},-2,1) eq 'A'){
$rnd = int(rand($max_d));
if ($max_d eq 6){$rnd++;}
}
else{
$rnd = int(rand($max_d)) + 1;
}
$in{'saybody'} = $in{'saybody'} . ' → ' . $rnd;
}
}
elsif (substr($in{'saybody'},0,1) eq '[' && substr($in{'saybody'},-1) eq ']'){
#複数
$per_d = substr($in{'saybody'},1,1);
$max_d = substr($in{'saybody'},3,-1);
if (($max_d eq 4 || $max_d eq 6 || $max_d eq 10 || $max_d eq 30 || $max_d eq 50 || $max_d eq 100 || $max_d eq 13) && ($per_d > 0 && $per_d <10)){
for ($i=1;$i<=$per_d;$i++){
$rnd = int(rand($max_d)) + 1;
$rnd_str .= $rnd . ' + ';
$rnd_sum += $rnd;
}
$rnd_str = substr($rnd_str,0,-3);
$in{'saybody'} = $in{'saybody'} . ' → ' . $rnd_str . ' = ' . $rnd_sum;
}
}
$ctype = 0;
if (substr($in{'saybody'},0,5) eq '[名前' && ($say_change_flg eq 1 || $pcid eq 'xz0001' || $pcid eq 'xz0000')){ #[名前xa0000→○○○○○○○○○]
$c_target = substr($in{'saybody'},5,6);
$c_body = substr($in{'saybody'},13,30);
if (substr($c_body,-1) eq ']'){chop $c_body;}
$sql = "insert into chat_change_ctl (id,type,pcid,target,cbody) values ($in{'id'},1,'$pcid','$c_target','$c_body');";
$dbh->do($sql) or &err("CODE:C01 エラーが発生しました。");
$ctype = 1;
}
elsif (substr($in{'saybody'},0,5) eq '[性別' && ($say_change_flg eq 1 || $pcid eq 'xz0001' || $pcid eq 'xz0000')){ #[性別xa0000→○]
$c_target = substr($in{'saybody'},5,6);
$c_body = substr($in{'saybody'},13,2);
if (substr($c_body,-1) eq ']'){chop $c_body;}
$sql = "insert into chat_change_ctl (id,type,pcid,target,cbody) values ($in{'id'},2,'$pcid','$c_target','$c_body');";
$dbh->do($sql) or &err("CODE:C02 エラーが発生しました。");
$ctype = 2;
}
elsif (substr($in{'saybody'},0,7) eq '[クラス' && ($say_change_flg eq 1 || $pcid eq 'xz0001' || $pcid eq 'xz0000')){ #[クラスxa0000→○]
$c_target = substr($in{'saybody'},7,6);
$c_body = substr($in{'saybody'},15,1);
$sql = "insert into chat_change_ctl (id,type,pcid,target,cbody) values ($in{'id'},3,'$pcid','$c_target','$c_body');";
$dbh->do($sql) or &err("CODE:C03 エラーが発生しました。");
$ctype = 3;
}
elsif (substr($in{'saybody'},0,5) eq '[属性' && ($say_change_flg eq 1 || $pcid eq 'xz0001' || $pcid eq 'xz0000')){ #[属性xa0000→○]
$c_target = substr($in{'saybody'},5,6);
$c_body = substr($in{'saybody'},13,2);
if (substr($c_body,-1) eq ']'){chop $c_body;}
$sql = "insert into chat_change_ctl (id,type,pcid,target,cbody) values ($in{'id'},4,'$pcid','$c_target','$c_body');";
$dbh->do($sql) or &err("CODE:C04 エラーが発生しました。");
$ctype = 4;
}
elsif (substr($in{'saybody'},0,5) eq '[種族' && ($say_change_flg eq 1 || $pcid eq 'xz0001' || $pcid eq 'xz0000')){ #[種族xa0000→○]
$c_target = substr($in{'saybody'},5,6);
$c_body = substr($in{'saybody'},13,2);
if (substr($c_body,-1) eq ']'){chop $c_body;}
$sql = "insert into chat_change_ctl (id,type,pcid,target,cbody) values ($in{'id'},7,'$pcid','$c_target','$c_body');";
$dbh->do($sql) or &err("CODE:C04 エラーが発生しました。");
$ctype = 7;
}
elsif (substr($in{'saybody'},0,5) eq '[語尾' && ($say_change_flg eq 1 || $pcid eq 'xz0001' || $pcid eq 'xz0000')){ #[語尾xa0000→○○○○○○]
$c_target = substr($in{'saybody'},5,6);
if ($pcid eq 'xz0000' || $pcid eq 'xz0001'){$c_body = substr($in{'saybody'},13);}
else{$c_body = substr($in{'saybody'},13,12);}
if (substr($c_body,-1) eq ']'){chop $c_body;}
$sql = "insert into chat_change_ctl (id,type,pcid,target,cbody) values ($in{'id'},5,'$pcid','$c_target','$c_body');";
$dbh->do($sql) or &err("CODE:C05 エラーが発生しました。");
$ctype = 5;
}
# elsif (substr($in{'saybody'},0,5) eq '[番号' && ($say_change_flg eq 1 || $pcid eq 'xz0001' || $pcid eq 'xz0000' || $pcid eq 'xz0017' || $pcid eq 'xz0016')){ #[番号xa0000→○]
elsif (substr($in{'saybody'},0,5) eq '[番号' && (($pcid eq 'xz0001' || $pcid eq 'xz0000' || $pcid eq 'xz0016' || $pcid eq 'xz0038') || ($in{'id'} eq 115 && $say_change_flg eq 1))){ #[番号xa0000→○]
if (substr($in{'saybody'},5,8) eq 'AllReset'){
# $sql = "delete from chat_change_ctl where type = 6 and id = $in{'id'};";
$sql = "delete from chat_change_ctl where type = 6;";
$dbh->do($sql) or &err("CODE:C06 エラーが発生しました。");
}
else{
$c_target = substr($in{'saybody'},5,6);
$c_body = substr($in{'saybody'},13);
if (substr($c_body,-1) eq ']'){chop $c_body;}
$sql = "insert into chat_change_ctl (id,type,pcid,target,cbody) values ($in{'id'},6,'$pcid','$c_target','$c_body');";
$dbh->do($sql) or &err("CODE:C06 エラーが発生しました。");
$ctype = 2;
}
}
elsif (substr($in{'saybody'},0,11) eq '[コメント→' && ($say_change_flg eq 1 || $pcid eq 'xz0001' || $pcid eq 'xz0000')){ #[コメントxa0000→○]
$c_body = substr($in{'saybody'},11,-1);
$c_body = substr($c_body,0,60);
$sql = "update chat_control set comment = '$c_body' where id = $in{'id'};";
$dbh->do($sql) or &err("CODE:C0X エラーが発生しました。");
}
elsif (substr($in{'saybody'},0,5) eq '[配布'){ #[配布xa0000→○○○○○○]
$c_target = substr($in{'saybody'},5,6);
$c_body = substr($in{'saybody'},13);
if (substr($c_body,-1) eq ']'){chop $c_body;}
$sql = "select a.seq,a.id from item a,item_master b where a.pcid = '$pcid' and a.original_info is null and a.club_seq is null and a.state = 0 and a.id = b.id and b.name = '$c_body';";
$ref = $dbh->selectall_arrayref($sql) or &err("CODE:C-024 エラーが発生しました。");
($iseq,$iid)=@{$ref->[0]};
if ($iseq eq ''){$in{'saybody'} .= "→指定されたアイテムを所持していません[$c_body]。";}
elsif ($say_change_flg eq 1 && $in{'id'} >= 99 && ($iid eq 1280 or $iid eq 302 or $iid eq 1384 or $iid eq 682 or $iid eq 683 or $iid eq 1180 or $iid eq 1369 or $iid eq 346 or $iid eq 276 or $iid eq 1479 or $iid eq 1024 or $iid eq 563)){
$sql = "update item set pcid = '$c_target',equip = 0 where pcid = '$pcid' and seq = $iseq and state = 0;";
$dbh->do($sql) or &err("CODE:C06AA エラーが発生しました。");
$in{'saybody'} .= '→配布完了';
}
elsif ($say_change_flg eq 1 && $type eq 'school_festival'){
if($in{'id'} < 203){
if (($iid >= 1900 && $iid <= 1986) || $iid eq 653 || $iid eq 681 || $iid eq 1364 || $iid eq 1372 || $iid eq 1377){
$sql = "update item set pcid = '$c_target',equip = 0 where pcid = '$pcid' and seq = $iseq and state = 0;";
$dbh->do($sql) or &err("CODE:C06AA エラーが発生しました。");
$in{'saybody'} .= '→配布完了';
}
elsif (substr($pcid,0,2) ne 'xz' && $iid ne 284){
$in{'saybody'} .= "→指定されたアイテムの配布は許可されていません[$c_body]。";
}
}else{
$haifu_ok = 1;
if(substr($pcid,0,2) ne 'xz' && $iid ne 284) {
$item_key = ','.$iid.',';
if(index($item_list, $item_key) < 0){
$haifu_ok = 0;
}
}
if($haifu_ok eq 1){
$sql = "update item set pcid = '$c_target',equip = 0 where pcid = '$pcid' and seq = $iseq and state = 0;";
$dbh->do($sql) or &err("CODE:C06AA エラーが発生しました。");
$in{'saybody'} .= '→配布完了';
}else{
$in{'saybody'} .= "→指定されたアイテムの配布は許可されていません[$c_body]。";
}
}
}
elsif ($say_change_flg eq 1 && $type eq 'summer_festival'){
$haihu_flg = 0;
if ($in{'id'} eq 181 && ($c_body eq '植物の種[園芸部1010]' || $c_body eq 'ソックスのぬいぐるみ')){$haihu_flg = 1;}
elsif ($in{'id'} eq 182 && ($c_body eq 'ぬいぐるみ[空っぽの卵]' || $c_body eq '魔法のクイズ王ハット' || $c_body eq 'ミドルドラゴンの鱗')){$haihu_flg = 1;}
elsif ($in{'id'} eq 183 && ($c_body eq '琥珀の指輪' || $c_body eq '魔法の箒[グリフォンEX]' || $c_body eq '上着[ターゲットウェア]')){$haihu_flg = 1;}
elsif ($in{'id'} eq 185 && ($c_body eq 'ケット・シーヘッド')){$haihu_flg = 1;}
elsif ($in{'id'} eq 186 && ($c_body eq 'Mascot[パオ]' || $c_body eq '大きなアルのぬいぐるみ')){$haihu_flg = 1;}
elsif ($in{'id'} eq 190 && ($c_body eq 'フープ[曲技研]' || $c_body eq 'ナタクのぬいぐるみ')){$haihu_flg = 1;}
elsif ($in{'id'} eq 190 && ($c_body eq 'フープ[曲技研]' || $c_body eq 'ナタクのぬいぐるみ')){$haihu_flg = 1;}
elsif ($in{'id'} eq 267 && ($c_body eq 'マジパン[薔薇]')){$haihu_flg = 1;}
elsif ($in{'id'} eq 267 && ($c_body eq 'マジパン[はーと]')){$haihu_flg = 1;}
elsif ($in{'id'} eq 267 && ($c_body eq 'キャンディ[はーと]')){$haihu_flg = 1;}
elsif ($in{'id'} eq 268 && ($c_body eq '探偵ナイフ')){$haihu_flg = 1;}
elsif ($in{'id'} eq 268 && ($c_body eq '探偵の鍋')){$haihu_flg = 1;}
elsif ($in{'id'} eq 269 && ($c_body eq '女神の羽衣[レプリカ]')){$haihu_flg = 1;}
elsif ($in{'id'} eq 269 && ($c_body eq 'メンタルリング')){$haihu_flg = 1;}
elsif ($in{'id'} eq 269 && ($c_body eq 'ターゲットクッション')){$haihu_flg = 1;}
elsif ($in{'id'} eq 270 && ($c_body eq 'ウエストバックリボン')){$haihu_flg = 1;}
elsif ($in{'id'} eq 270 && ($c_body eq 'クッキー[ボガートの鼻]')){$haihu_flg = 1;}
elsif ($in{'id'} eq 270 && ($c_body eq 'ブルーム')){$haihu_flg = 1;}
elsif ($in{'id'} eq 271 && ($c_body eq 'マスコット[ヒマワリ]')){$haihu_flg = 1;}
elsif ($in{'id'} eq 271 && ($c_body eq 'ラベンダーのポプリ')){$haihu_flg = 1;}
elsif ($in{'id'} eq 271 && ($c_body eq '植物の種[園芸部1010]')){$haihu_flg = 1;}
elsif ($in{'id'} eq 272 && ($c_body eq 'どうぶつクッキー[Love]')){$haihu_flg = 1;}
elsif ($in{'id'} eq 273 && ($c_body eq 'ルバンニ先生のぬいぐるみ')){$haihu_flg = 1;}
elsif ($in{'id'} eq 273 && ($c_body eq '帽子[ルバンニ]')){$haihu_flg = 1;}
if ($haihu_flg eq 1){
$sql = "update item set pcid = '$c_target',equip = 0 where pcid = '$pcid' and seq = $iseq and state = 0;";
$dbh->do($sql) or &err("CODE:C06AA エラーが発生しました。");
$in{'saybody'} .= '→配布完了';
}
else{$in{'saybody'} .= "→指定されたアイテムの配布は許可されていません1[$c_body]。";}
}
elsif (substr($pcid,0,2) ne 'xz' && $iid ne 284){$in{'saybody'} .= "→指定されたアイテムの配布は許可されていません2[$c_body]。";}
else{
$sql = "update item set pcid = '$c_target',equip = 0 where pcid = '$pcid' and seq = $iseq and state = 0;";
$dbh->do($sql) or &err("CODE:C06A エラーが発生しました。");
$in{'saybody'} .= '→配布完了';
}
}
elsif (($say_change_flg eq 1 || $pcid eq 'xz0001' || $pcid eq 'xz0000') && substr($in{'saybody'},0,4) eq '[○]'){
$sql = "update chat_control set open_flg = '○' where id = $in{'id'};";
$dbh->do($sql) or &err("CODE:COC-01 エラーが発生しました。");
}
elsif (($say_change_flg eq 1 || $pcid eq 'xz0001' || $pcid eq 'xz0000') && substr($in{'saybody'},0,4) eq '[△]'){
$sql = "update chat_control set open_flg = '△' where id = $in{'id'};";
$dbh->do($sql) or &err("CODE:COC-02 エラーが発生しました。");
}
elsif (($say_change_flg eq 1 || $pcid eq 'xz0001' || $pcid eq 'xz0000') && substr($in{'saybody'},0,4) eq '[−]'){
$sql = "update chat_control set open_flg = '−' where id = $in{'id'};";
$dbh->do($sql) or &err("CODE:COC-03 エラーが発生しました。");
}
$value = $pcage;
#文字コードチェック
$buffer1 = $pcage;
$buffer1 =~ s/%([0-9a-fA-F][0-9a-fA-F])/pack("C", hex($1))/eg;
$kcode = &jcode::getcode(*buffer1);
$value =~ tr/+/ /;
$value =~ s/%([0-9a-fA-F][0-9a-fA-F])/pack("C", hex($1))/eg;
&jcode::convert(*value, 'euc',$kcode);
$pcage = $value;
#ログ書き込み
$in{'saybody'} =~ s/\n//g;
$in{'saybody'} =~ s/\'/\\'/g;
$in{'saybody'} =~ s/\"/\\"/g;
$in{'saybody'} =~ s/\_/\\_/g;
$in{'saybody'} =~ s/\-/\\-/g;
$in{'saybody'} =~ s/\./\\./g;
$in{'saybody'} =~ s/\!/\\!/g;
$in{'saybody'} =~ s/\゙/\\゙/g;
$in{'saybody'} =~ s/</g;
$in{'saybody'} =~ s/>/>/g;
if ($position eq ''){$position = 0;}
if($pet_flg eq 1){
## if(($in{'say_icon'} eq 'http://rexi.jp/gx/images/npc/_pet.jpg') or(rindex($in{'say_icon'},'_C18_') ne -1)){
# $pet_flg = 1;
## $sql = "select xpid,pet_name,zensin,free_setting from pet where walk_pcid = '$pcid' order by walk_start desc ;";
## $ref = $dbh->selectall_arrayref($sql) or &err("CODE:SP4-0e4 エラーが発生しました。");
## ($xpid,$pet_name,$p_zensin,$free_setting)=@{$ref->[0]};
$wpcid = $pcid;
$pcid = 'xp'.substr('0000'.$xpid,-4);
$pcname = $pet_name.' ('.$pcname.'('.$wpcid.'))';
$pcsex = " ";
$pczensin = $p_zensin;
$c_zensin = $p_zensin;
## }else{
## $pet_flg = 0;
}
## if ($in{'type'} eq 'cross'){
## $dbh_x = &connectDB($plDB);
## $sql = "insert into chat_log (id,pcid,pcname,sex,icon,say,game,zensin) values ($in{'id'},'$pcid','$pcname','$pcsex','$in{'say_icon'}','$in{'saybody'}','GX','$pczensin');";
## $dbh_x->do($sql) or &err("CODE:W0Z エラーが発生しました。");
## &disconDB($dbh_x);
## }
## else{
if($pet_flg eq 0){
$sql = "select name from chat_flavor where id = $in{'id'} and pcid = '$pcid' and end_time >= now() and start_time <= now() order by end_time desc limit 1;";
$ref = $dbh->selectall_arrayref($sql) or &err("CODE:C-025 エラーが発生しました。");
($iname)=@{$ref->[0]};
$sql = "select b.name from yatai_sell_log a,yatai_sell_list b where a.pcid = '$pcid' and a.sell_time >= now() + '-18 minute' and a.id = b.id order by a.sell_time desc limit 1;";
$ref = $dbh->selectall_arrayref($sql) or &err("CODE:C-026 エラーが発生しました。");
($iname)=@{$ref->[0]};
$sql = "select cbody from chat_change_ctl where type = 6 and target = '$pcid' order by end_date desc limit 1;";
$ref = $dbh->selectall_arrayref($sql) or &err("CODE:C-027 エラーが発生しました。");
($numbering)=@{$ref->[0]};
$sql = "select cbody from chat_change_ctl where id = $in{'id'} and type = 1 and target = '$pcid' and end_date >= now() order by end_date desc limit 1;";
$ref = $dbh->selectall_arrayref($sql) or &err("CODE:C-028 エラーが発生しました。");
($cname)=@{$ref->[0]};
$sql = "select cbody from chat_change_ctl where id = $in{'id'} and type = 2 and target = '$pcid' and end_date >= now() order by end_date desc limit 1;";
$ref = $dbh->selectall_arrayref($sql) or &err("CODE:C-029 エラーが発生しました。");
($csex)=@{$ref->[0]};
$sql = "select cbody from chat_change_ctl where id = $in{'id'} and type = 3 and target = '$pcid' and end_date >= now() order by end_date desc limit 1;";
$ref = $dbh->selectall_arrayref($sql) or &err("CODE:C-02a エラーが発生しました。");
($cclass)=@{$ref->[0]};
$sql = "select cbody from chat_change_ctl where id = $in{'id'} and type = 4 and target = '$pcid' and end_date >= now() order by end_date desc limit 1;";
$ref = $dbh->selectall_arrayref($sql) or &err("CODE:C-02b エラーが発生しました。");
($clumina)=@{$ref->[0]};
$sql = "select cbody from chat_change_ctl where id = $in{'id'} and type = 5 and target = '$pcid' and end_date >= now() order by end_date desc limit 1;";
$ref = $dbh->selectall_arrayref($sql) or &err("CODE:C-02c エラーが発生しました。");
($ctail)=@{$ref->[0]};
if ($cname ne ''){$pcname = $cname;}
if ($csex ne ''){$pcsex = $csex;}
if ($ctail ne ''){$in{'saybody'} .= $ctail;}
if ($type eq 'dormitory'){
$c_zensin = &zensin_ctl_rtn('dormitory',undef,$pcid);
}
elsif ($type eq 'etc' && $in{'id'} eq 6){
$c_zensin = &zensin_ctl_rtn('spa',undef,$pcid);
}
elsif ($type eq 'etc'){
$c_zensin = &zensin_ctl_rtn('etc',undef,$pcid);
}
elsif ($type eq 'school_festival'){
$c_zensin = &zensin_ctl_rtn('school_festival',undef,$pcid);
}
if ($c_zensin eq ''){$c_zensin = $pczensin;}
if($pcrace eq 6 && substr($pcid,0,2) ne 'xz' && $c_zensin ne ''){
$sql = "select pdid from stars_data where url = '$c_zensin';";
$ref = $dbh->selectall_arrayref($sql) or &err("CODE:C-01 エラーが発生しました。");
($s_pdid)=@{$ref->[0]};
if(($s_pdid eq 'G01') or ($s_pdid eq 'C14')){
$c_zensin = 'http://rexis.jp/stars/data/gx_shefool/'.substr($c_zensin,28);
}
}
}
if($pet_flg eq 0){
if ($in{'id'} >= 99 && $in{'id'} <= 99){
@say_tale_item = (451,452,453,454,455,456,457,458,459,460,461,462,463,464,465,466,467,468,469);
@say_tale_str = ('なのだよー','ワン!','ばうわう!','にゃん!','にゃごー(怒)','ごぶ','ほぶごぶ','みのー','おーく','おーが','べあ','ふんどら','あと褌も!','ザマス','ごわす','ただし褌にかぎる!','あと女王様とお呼びっ!','(←でも心中はえろえろだ)','女将を呼べ(怒!)');
$sql = "select id from item where pcid = '$pcid' and equip = 4 and state = 0;";
$ref = $dbh->selectall_arrayref($sql) or &err("CODE:C-02d エラーが発生しました。");
($tail_id)=@{$ref->[0]};
if ($tail_id ne ''){
$i = 0;
foreach(@say_tale_item){
if ($_ eq $tail_id){
$in{'saybody'} .= @say_tale_str[$i];
last;
}
$i++;
}
}
}
}
if (substr($in{'say_icon'},0,26) eq 'http://rexi.jp/stars/data/'){$in{'say_icon'} =~ s/rexi\.jp/rexis\.jp/g;}
# $rnd = int(rand(100) + 1);
# if ($rnd <= 10){
# $in{'say_icon'} = 'http://rexi.jp/stars/data/jj/icon_kumokama_01.gif';
# $c_zensin = 'http://rexi.jp/jj/npc/png_zensin/kumokama.png';
# }
if (substr($c_zensin,0,26) eq 'http://rexi.jp/stars/data/'){$c_zensin =~ s/rexi\.jp/rexis\.jp/g;}
$sql = "insert into chat_log (id,pcid,pcname,sex,age,class,icon,say,ip,host,lumina,item,numbering,clumina,cclass,zensin,race) values ($in{'id'},'$pcid','$pcname','$pcsex'";
$sql .= ",'$pcage',$pcclass,'$in{'say_icon'}','$in{'saybody'}','$ip','$host',$pclumina";
if ($iname eq ''){$sql .= ",NULL";}
else{$sql .= ",'$iname'";}
if ($numbering eq ''){$sql .= ",NULL";}
else{$sql .= ",'$numbering'";}
if ($clumina eq ''){$sql .= ",NULL";}
else{$sql .= ",'$clumina'";}
if ($cclass eq ''){$sql .= ",NULL";}
else{$sql .= ",'$cclass'";}
if ($c_zensin eq ''){$sql .= ",NULL";}
else{$sql .= ",'$c_zensin'";}
$sql .= ",$pcrace);";
$dbh->do($sql) or &err("CODE:W0Z エラーが発生しました。");
##sinn側に記入
if ($in{'type'} eq 'cross'){
### ($si_id) = &si_rtn_db_data('select_line',$sql,'si');
$sql = "insert into chat_log (id,pcid,pcname,sex,age,class,icon,say,ip,host,elemental,item,numbering,celemental,cclass,zensin,race) values ($si_id,'$pcid','$pcname','$pcsex'";
$sql .= ",'$pcage',$pcclass,'$in{'say_icon'}','$in{'saybody'}','$ip','$host',$pclumina";
if ($iname eq ''){$sql .= ",NULL";}
else{$sql .= ",'$iname'";}
if ($numbering eq ''){$sql .= ",NULL";}
else{$sql .= ",'$numbering'";}
if ($clumina eq ''){$sql .= ",NULL";}
else{$sql .= ",'$clumina'";}
if ($cclass eq ''){$sql .= ",NULL";}
else{$sql .= ",'$cclass'";}
if ($c_zensin eq ''){$sql .= ",NULL";}
else{$sql .= ",'$c_zensin'";}
$sql .= ",$pcrace);";
&si_rtn_db_data('insert_data',$sql,'si');
}
## }
print "Location: ./$mycgi?mode=read_chat&id=$in{'id'}&type=$in{'type'}\n\n";
}
#---------------------------------------
# インライン中身エラー画面
#---------------------------------------
sub err_in {
$out{'body'} = $_[0];
&out_enc;
&html_out("chat_log.html");
}
#---------------------------------------
# 属性変更コマンド
# フォーマット [呪→PCID:属]
#---------------------------------------
sub atb_change {
my $tmp_id = $_[0];
my $tmp_message = $_[1];
my $r_flg = 0;
my $c_flg1 = index($tmp_message,'[呪→');
my $c_flg2 = index($tmp_message,']');
# if ($uid eq 4){&err_in("$c_flg1,$c_flg2");}
if ($c_flg1 ne -1 && $c_flg2 ne -1){
my $c_pcid = substr($tmp_message,$c_flg1+5,6);
my $c_atb = substr($tmp_message,$c_flg1+5+8,2);
if ($c_atb eq '善' || $c_atb eq '悪' || $c_atb eq '?'){return 0;}
# if ($uid eq 4){&err_in("$c_pcid,$c_atb");}
my $l_dir = "/home/rexi-jp/public_html/jj/r_chat/zc/" . $tmp_id . "/";
if (!-d $l_dir){
mkdir("$l_dir", 0755);
}
&date_rtn;
$lc_file = $l_dir . "$g_year$g_mon$g_mday$g_hour$g_min$g_sec" . $c_pcid . ".dat";
open FILE,">$lc_file";
print FILE $pcid . "\n";
print FILE $c_atb . "\n";
close FILE;
$r_flg = 1;
}
return $r_flg;
}
#---------------------------------------
# ランダムリスト登録
# フォーマット [登→D10:番号:登録内容]
#---------------------------------------
sub regist_list {
my $tmp_id = $_[0];
my $tmp_message = $_[1];
my $r_flg = 0;
# my $c_flg1 = index($tmp_message,'[登→D');
# my $c_flg2 = index($tmp_message,']');
# if ($c_flg1 ne -1 && $c_flg2 ne -1){
if (substr($tmp_message,0,6) eq '[登→D' && substr($tmp_message,-1) eq ']'){
my @a = split(/\:/,substr($tmp_message,6,-1));
my $l_dir = "/home/rexi-jp/public_html/jj/r_chat/list/" . $tmp_id . "/";
if (!-d $l_dir){
mkdir("$l_dir", 0755);
}
&date_rtn;
$lc_file = $l_dir . @a[0] . "_" . @a[1] . ".dat";
open FILE,">$lc_file";
print FILE @a[2] . "\n";
close FILE;
$r_flg = 1;
}
return $r_flg;
}
#---------------------------------------
# NPC専用waitコマンド
# 引数1:発言内容
#---------------------------------------
sub wait_command {
my $tmp_message = $_[0];
if (substr($pcid,0,2) ne 'jz'){return;}
my $w_flg1 = index($tmp_message,'[wait]');
my $w_flg2 = index($tmp_message,'[cancellation]');
if ($w_flg1 eq -1 && $w_flg2 eq -1){return;}
my $wait_file = "/home/rexi-jp/public_html/jj/chat/wait_" . $in{'id'} . ".dat";
if ($w_flg1 ne -1){
open FILEW,">$wait_file";
print FILEW "1";
close FILEW;
}
if ($w_flg2 ne -1){
unlink($wait_file);
}
}
#---------------------------------------
# NPC専用OpenCloseコマンド
# 引数1:発言内容
#---------------------------------------
sub openclose_command {
my $tmp_message = $_[0];
if (substr($pcid,0,2) ne 'jz'){return;}
my $w_flg1 = index($tmp_message,'[開会]');
my $w_flg2 = index($tmp_message,'[閉会]');
if ($w_flg1 eq -1 && $w_flg2 eq -1){return;}
if ($w_flg1 ne -1){
my $sql_t = "update chat_control set npc_limit = 0 where id = $in{'id'};";
$dbh->do($sql_t) or &err("エラーが発生しました。");
}
elsif ($w_flg2 ne -1){
my $sql_t = "update chat_control set npc_limit = 1 where id = $in{'id'};";
$dbh->do($sql_t) or &err("エラーが発生しました。");
}
}
#---------------------------------------
# NPC専用強制付与コマンド
# 引数1:発言内容
#---------------------------------------
sub forcewords_command {
my $tmp_message = $_[0];
if (substr($pcid,0,2) ne 'jz'){return;}
my $w_flg1 = index($tmp_message,'[付与→');
my $w_flg2 = index($tmp_message,']');
if ($w_flg1 eq -1 && $w_flg2 eq -1){return;}
if ($w_flg1 ne -1 && $w_flg ne -1){
my $t_pcid = substr($tmp_message,7,6);
my $t_word = substr($tmp_message,14,16);
if ($t_word eq ''){
$sql_t = "delete from chat_force_word where id = $in{'id'} and target_pcid = '$t_pcid';";
}
else{
$sql_t = "insert into chat_force_word (id,pcid,target_pcid,word) values ($in{'id'},'$pcid','$t_pcid','$t_word');";
}
$dbh->do($sql_t) or &err("エラーが発生しました。");
}
}
#---------------------------------------
# ログ表示オンリーモード
#---------------------------------------
sub log_show {
# if ($in{'id'} ne '0020' && $in{'id'} ne '0019' && $in{'id'} ne '0021' && $in{'id'} ne '0022' && $in{'id'} ne '0023'){&err("指定されたルームでの利用は行えません。");}
if ($in{'p'} eq ''){$in{'p'} = 1;}
$start_pos = ($in{'p'} - 1) * 100;
$end_pos = $in{'p'} * 100;
$sql = "";
foreach (@ddat){
$fname = $_;
$fname2 = $rc_log . $fname;
@ddd = ();
$aname = substr($fname,0,14);
if ($aname eq $in{'alink'}){$aflg2 = 1;}
if ($aname eq $in{'alink2'}){$aflg = 1;}
open FILE,$fname2;
while(){
$tmp = $_;
chomp $tmp;
push ddd,$tmp;
}
$time_str = substr($fname,0,4) . '/' . substr($fname,4,2) . '/' . substr($fname,6,2) . ' ' . substr($fname,8,2) . ':' . substr($fname,10,2) . ':' . substr($fname,12,2);
if ($in{'mode2'} ne 'all' || ($in{'mode2'} eq 'all' && $i >= $start_pos)){
$a_str = @atb_str[@ddd[5]];
if ($a_str eq '' || $a_str eq 0){$a_str = '中';}
# &date_rtn;
if (@ddd[3] eq '-7992'){@ddd[3] = '?';}
if ($in{'alink'} ne '' && $aflg eq 0){
}
else{
$body .=<<"EOT";
@ddd[0] @ddd[1]・@sex_mark[@ddd[2]]・@ddd[3]歳・@class_str2[@ddd[4]]・$a_str
$time_str
@ddd[8]@ddd[9]
EOT
}
}
#ログ表示
if ($in{'alink'} ne '' && $aflg eq 0){
}
else{
$i++;
}
if ($in{'alink'} ne '' && $aflg eq 0){
}
elsif ($in{'alink'} ne '' && $aflg eq 1 && $aflg2 eq 0){
}
elsif ($in{'alink'} ne '' && $aflg eq 1 && $aflg2 eq 1){
last;
}
elsif ($i >= $end_pos){last;}
}
if ($i eq 0){$out{'body'} = '発言はありません。';}
else{
$out{'body'} =<<"EOT";
EOT
}
$out{'id'} = $in{'id'};
&out_enc;
$out{'nxt'} = $in{'p'} + 1;
if ($in{'mode2'} eq 'all' && $in{'alink'} ne '' && $aflg eq 1 && $aflg2 eq 1){
&html_out("r_chat_all_log3.html");
}
else{
&html_out("r_chat_all_log2.html");
}
}
#---------------------------------------
# 詳細表示
#---------------------------------------
sub dt {
## if ($in{'type'} eq 'cross'){
## $dbh_x = &connectDB($plDB);
## $sql = "select name,explanation from chat_control where id = $in{'id'};";
## $ref = $dbh_x->selectall_arrayref($sql) or &err("エラーが発生しました。");
## ($name,$explanation)=@{$ref->[0]};
## &disconDB($dbh_x);
## }else{
$sql = "select name,explanation,flg_member,substr(start_time,1,16),substr(end_time,1,16) from chat_control where id = $in{'id'};";
$ref = $dbh->selectall_arrayref($sql) or &err("エラーが発生しました。");
($name,$explanation,$flg_member,$start_time,$end_time)=@{$ref->[0]};
## }
$explanation =~ s/\n/ /g;
$out{'body'} = $explanation;
if ($out{'body'} eq ''){$out{'body'} = ' ';}
$start_time =~ s/\-/\//g;
$end_time =~ s/\-/\//g;
if ($start_time ne '' || $end_time ne ''){
$out{'body'} .=<<"EOT";
■開催期間
$start_time 〜 $end_time
EOT
}
if ($flg_member ne ''){
@mem_list = split(/\,/,$flg_member);
foreach (@mem_list){
$sql = "select name from character where pcid = '$_';";
$ref = $dbh->selectall_arrayref($sql) or &err("エラーが発生しました。");
($pcname)=@{$ref->[0]};
$member .=<<"EOT";
$pcname($_)
EOT
}
$out{'body'} .=<<"EOT";
■メンバー
$member
EOT
}
&out_enc;
&html_out('chat_dt.html');
}
#---------------------------------------
# ペット アイコンリスト作成
#---------------------------------------
sub icon_list_p{
my $tpcid = $_[0];
my $list_type = $_[1];
my $dbh_flg = 0;
## $dbh_lib = $_[2];
## if ($dbh_lib eq ''){
## $dbh_lib = &connectDB($mainDB);
## $dbh_flg = 1;
## }
my $pet_list = $_[3];
my $cdef = "";
$rtn_data ='';
$sql = "select xpid,pet_name,zensin,icon from pet where walk_start <= now() and walk_end > now() and walk_pcid ='$tpcid'";
$ref_lib = $dbh->selectall_arrayref($sql) or &err("CODE:LI-028 エラーが発生しました。");
($txpid,$tname,$tpet_zensin,$tpet_icon)=@{$ref_lib->[0]};
if(($txpid eq '') or ($txpid eq 0)){
return $rtn_data;
}
## if ($mid ne ''){$wh = 'WIDTH="25" HEIGHT="25"';}
## else{
$wh = 'WIDTH="50" HEIGHT="50"';
## }
my $deficon = 'http://rexi.jp/gx/images/npc/_pet.jpg';
$deficon2 = $deficon;
## if ($mid ne ''){
## $deficon2 = &mb_img_rtn($deficon,25,25);
## }
$rtn_data =<<"EOT";
EOT
return $rtn_data;
}
#---------------------------------------
# rexi.jpDBデータ取得
#---------------------------------------
sub rtn_db_data {
my $in_mode = $_[0];
my $lib_sql = $_[1];
my $lib_db = $_[2];
if ($lib_db eq ''){$lib_db = 'si';}
my $rtn = '';
my @rtn_ary = ();
use lib qw(/home/rexi-jp/public_html/gx/lib);
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Response;
$URL = "http://pbws.jp/lib/data.cgi?db=$lib_db&sql=$lib_sql&mode=$in_mode"; # アクセスする URL
my $proxy = new LWP::UserAgent;
my $req = HTTP::Request->new('GET' => $URL); # HTTP リクエストを作成
my $res = $proxy->request($req); # $res に HTTP レスポンスが返ってくる
if ($in_mode eq 'select_line'){
my $data = $res->content; # HTML を表示
chomp $data;
@rtn_ary = split(/\t/,$data);
}
elsif ($in_mode eq 'select_rows'){
my $data = $res->content; # HTML を表示
chomp $data;
@rtn_ary = split(/\n/,$data);
}
# elsif ($in_mode eq 'insert_data' || $in_mode eq 'update_data' || $in_mode eq 'delete_data'){
# }
}
#SINN
#---------------------------------------
# pbws.jpDBデータ取得
#---------------------------------------
sub si_rtn_db_data {
my $in_mode = $_[0];
my $lib_sql = $_[1];
my $lib_db = $_[2];
my $lib_dbg = $_[3];
my $lib_type = $_[4];
if ($lib_db eq ''){$lib_db = 'si';}
my $rtn = '';
my @rtn_ary = ();
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Response;
if ($in_mode eq 'select_line' || $in_mode eq 'select_rows'){
if ($lib_type eq 'file'){
&date_rtn;
my $rnd_1 = int(rand(1000) + 1);
my $rnd_2 = int(rand(1000) + 1);
my $lib_file_name = "select_$g_year$g_mon$g_mday$g_hour$g_min$g_sec$rnd_1$rnd_2" . ".dat";
my $lib_file = "/home/rexi-jp/public_html/lib/sql/" . $lib_file_name;
open FILE,">$lib_file";
print FILE $lib_sql;
close FILE;
&sv_copy("pbws.jp","pbws-jp","taisuki","/public_html/lib/sql/",$lib_file);
$URL = "http://pbws.jp/lib/data.cgi?db=$lib_db&file=$lib_file_name&mode=$in_mode"; # アクセスする URL
#&err($URL);
}
else{
$URL = "http://pbws.jp/lib/data.cgi?db=$lib_db&sql=$lib_sql&mode=$in_mode"; # アクセスする URL
}
my $proxy = new LWP::UserAgent;
my $req = HTTP::Request->new('GET' => $URL); # HTTP リクエストを作成
my $res = $proxy->request($req); # $res に HTTP レスポンスが返ってくる
if ($in_mode eq 'select_line'){
my $data = $res->content; # HTML を表示
chomp $data;
@rtn_ary = split(/\t/,$data);
}
elsif ($in_mode eq 'select_rows'){
my $data = $res->content; # HTML を表示
#&err("$URL $data " . $res->content);
chomp $data;
@rtn_ary = split(/\n/,$data);
}
# elsif ($in_mode eq 'insert_data' || $in_mode eq 'update_data' || $in_mode eq 'delete_data'){
# }
#if ($lib_dbg eq 1){&err($res->content);}
}
else{
#一旦ファイル格納
&date_rtn;
my $rnd_1 = int(rand(1000) + 1);
my $rnd_2 = int(rand(1000) + 1);
my $lib_file_name = "$g_year$g_mon$g_mday$g_hour$g_min$g_sec$rnd_1$rnd_2" . ".dat";
my $lib_file = "/home/rexi-jp/public_html/lib/sql/" . $lib_file_name;
open FILE,">$lib_file";
print FILE $lib_sql;
close FILE;
&sv_copy("pbws.jp","pbws-jp","taisuki","/public_html/lib/sql/",$lib_file);
$URL = "http://pbws.jp/lib/data.cgi?db=$lib_db&file=$lib_file_name&mode=$in_mode"; # アクセスする URL
my $proxy = new LWP::UserAgent;
my $req = HTTP::Request->new('GET' => $URL); # HTTP リクエストを作成
my $res = $proxy->request($req); # $res に HTTP レスポンスが返ってくる
my $data = $res->content; # HTML を表示
#if ($msid eq 'system'){&err($data);}
return $res;
}
}
#---------------------------------------
# サーバ間ファイルコピー(PUT)
#---------------------------------------
sub sv_copy {
my $server_name = $_[0];
my $server_user = $_[1];
my $server_pass = $_[2];
my $server_dir = $_[3]; #送信先サーバーディレクトリ
my $sorce_file = $_[4]; #送信元ファイル
my $server_file = $_[5]; #送信先ファイル名 省略時は送信元ファイルと同じ
# if ($server_file eq ''){
# @temp = ();
# @temp = split(/\//,$sorce_file);
# $server_file = @temp[$#temp];
# }
if ($server_name eq ''){$server_name = 'rexis.jp';}
if ($server_user eq ''){$server_user = 'rexis-jp';}
if ($server_pass eq ''){$server_pass = 'Ouv5zepJ';}
if ($server_dir eq ''){return 'server_dir NULL';}
if ($sorce_file eq ''){return 'sorce_file NULL';}
use Net::FTP;
$ftp = Net::FTP->new($server_name, Debug => 0)
or die &err("Cannot connect to some.host.name: $@");
$ftp->login($server_user,$server_pass)
or die &err("Cannot login " . $ftp->message);
$ftp->cwd($server_dir)
or die &err("Cannot change working directory " . $ftp->message . " server_name:$server_name server_user:$server_user,server_dir:$server_dir,sorce_file:$sorce_file,server_file:$server_file");
$ftp->binary
or die &err("binary failed " . $ftp->message);
$ftp->put($sorce_file)
or die &err("put failed " . $ftp->message . " " . $sorce_file);
# &err($ftp->ls);
# $ftp = Net::FTP->new($server_name);
# $ftp->login($server_user,$server_pass);
# $ftp->pasv();
# $ftp->cwd($server_dir);
# $ftp->put($sorce_file);
$ftp->quit;
return;
}