ランキング
順位 名前 軍資金額
END_OF_TEXT
my @true_ranks=sort{ $member_moneys{$b}<=>$member_moneys{$a} }keys %member_moneys;
my $i=1;
my $j;
my $k;
foreach(@true_ranks){
if($turn==0){
if($member_moneys{$true_ranks[$k]}<$member_moneys{$true_ranks[$k-1]}){
$i=$i+1+$j;
$j=0;
}
else{
$j++ if($k!=0);
}
}
else{
if($member_moneys{$true_ranks[$k]}>$member_moneys{$true_ranks[$k-1]}){
$i=$i+1+$j;
$j=0;
}
else{
$j++ if($k!=0);
}
}
print('',$i, '位 ', $member_names{$_}, ' ', $member_moneys{$_}, ' ',"\n");
$k++;
}
print('
');
print <
END_OF_TEXT
}
#################前回の結果htmlを表示#################
sub result_list{
print("$resultmessage
");
print('
');
print('',$race_comment,' ') if($race_comment ne '');
my @horse_num=sort{
if($horse_results{$a}!=$horse_results{$b}){
$horse_results{$a}<=>$horse_results{$b}
}
else{
$a<=>$b
}
}keys %horse_results;
my @true_num=&hat_color_num($allhorse_num);#枠番と枠色を取得
print('着順 馬番 枠番 馬名 ') if(@horse_num>0);
foreach(@horse_num){
my $temp_num=$_-1;
my $hat_color=$hat_color[$true_num[$temp_num]-1];
if($horse_results{$_}==100){
$horse_results{$_}=$torikesi_mark;
}
print('',$horse_results{$_},' ',$_,' ',$true_num[$temp_num],' ',$horse_names{$_},' ');
}
print('
');
print('
払い戻し金 ');
for($i=0;$i<@result_vote;$i++){
my @vote=split(/::/,$result_vote[$i]);
my $kind=$vote_array[$vote[0]];
my $num1=$vote[1];
my $num2=$vote[2];
my $num3=$vote[3];
my $money=$vote[4];
if($num2 ne '0' && $num3 ne '0'){
$num1="$num1-$num2-$num3";
}#3連複
elsif($num2 ne '0'){
$num1="$num1-$num2";
}#馬連・馬単・枠連
print('',$kind,' ',$num1,' ',$money,$yen,' ');
}
print('
');
my @true_ranks=sort{ $vote_addmoneys{$b}<=>$vote_addmoneys{$a} }keys %vote_addmoneys;
my $top_ranks;
$top_ranks=@true_ranks-$page*$top_max if($top_max>@true_ranks-$page*$top_max);
$top_ranks=$top_max if($top_max<=@true_ranks-$page*$top_max);
$tdground='background="'.$tdground.'"' if($tdground ne '');
for($i=0;$i<$top_ranks;$i++){
my $name=$vote_names{$true_ranks[$i+$page*$top_max]};
my $addmoney=$vote_addmoneys{$true_ranks[$i+$page*$top_max]};
my $soneki=$vote_sonekis{$true_ranks[$i+$page*$top_max]};
my $comment=$vote_comments{$true_ranks[$i+$page*$top_max]};
my @vote_save=split(/,/,$vote_saves{$true_ranks[$i+$page*$top_max]});
my @mymark_save=split(/=/,$vote_marks{$true_ranks[$i+$page*$top_max]});
$addmoney=0 if($addmoney eq '');
$soneki=0 if($soneki eq '');
$soneki='+'.$soneki if($soneki>0);
print('
',$name,' (払戻金:',$addmoney,$yen,') ');
for($j=0;$j<@vote_save;$j++){
my $one;
my @one=split(/::/,$vote_save[$j]);
$one[1]='全' if($one[1]>90);
$one[2]='全' if($one[2]>90);
$one[3]='全' if($one[3]>90);
if($one[0]==0 || $one[0]==7){
$one="$vote_array[$one[0]]:$one[1]-$one[2]-$one[3]☆☆ $one[4]$yen";
}
elsif($one[0]>=1 && $one[0]<5){
$one="$vote_array[$one[0]]:$one[1]-$one[2]☆☆ $one[4]$yen";
}
else{
$one="$vote_array[$one[0]]:$one[1]☆☆ $one[4]$yen";
}
print('',$one,' ');
}
if($week_money==0){
print('収支:',$soneki,$yen,' ');
}
elsif($week_money>0 && $pool==1){
print('収支:',$soneki,$yen,' ');
}
print('');
for($j=0;$j<@mymark_save;$j++){
next if($mymark_save[$j] eq '');
print('',$mark[$j],':',$befor_names{$mymark_save[$j]},' ');
}
if(@mymark_save==0){
print(' ');
}
print(' ');
print('',$comment,' ') if($comment ne '');
print('
');
}
print('
') if($page>0);
print('') if(@true_ranks>$top_ranks+$top_max*$page);
print <
END_OF_TEXT
}
####################投票一覧html####################
sub vote_list{
print("$votemessage
");
my @true_ranks=sort{ $vote_times{$b}<=>$vote_times{$a} }keys %vote_times;
my $top_ranks;
$top_ranks=@true_ranks-$page*$top_max if($top_max>@true_ranks-$page*$top_max);
$top_ranks=$top_max if($top_max<=@true_ranks-$page*$top_max);
$tdground='background="'.$tdground.'"' if($tdground ne '');
for($i=0;$i<$top_ranks;$i++){
my $name=$vote_names{$true_ranks[$i+$page*$top_max]};
my $date=$vote_dates{$true_ranks[$i+$page*$top_max]};
my $comment=$vote_comments{$true_ranks[$i+$page*$top_max]};
my $total_money=$vote_total_moneys{$true_ranks[$i+$page*$top_max]};
my @vote_save=split(/,/,$vote_saves{$true_ranks[$i+$page*$top_max]});
my @mymark_save=split(/=/,$vote_marks{$true_ranks[$i+$page*$top_max]});
print('
',$name,' ',$date,' ');
for($j=0;$j<@vote_save;$j++){
my $one;
my @one=split(/::/,$vote_save[$j]);
$one[1]='全' if($one[1]>90);
$one[2]='全' if($one[2]>90);
$one[3]='全' if($one[3]>90);
if($one[0]==0 || $one[0]==7){
$one="$vote_array[$one[0]]:$one[1]-$one[2]-$one[3]☆☆ $one[4]$yen";
}
elsif($one[0]>=1 && $one[0]<5){
$one="$vote_array[$one[0]]:$one[1]-$one[2]☆☆ $one[4]$yen";
}
else{
$one="$vote_array[$one[0]]:$one[1]☆☆ $one[4]$yen";
}
print('',$one,' ');
}
print('合計:',$total_money,$yen,' ') if(@vote_save>0);
print(' ');
print('');
for($j=0;$j<@mymark_save;$j++){
next if($mymark_save[$j] eq '');
print('',$mark[$j],':',$horse_names{$mymark_save[$j]},' ');
}
if(@mymark_save==0){
print(' ');
}
print(' ');
print('',$comment,' ') if($comment ne '');
print('
');
}
print('
') if($page>0);
print('') if(@true_ranks>$top_ranks+$top_max*$page);
print <
END_OF_TEXT
}
####################予想一覧html####################
sub mark_list{
print("$markmessage");
my @horse_num=sort{ $a<=>$b }keys %horse_names;
my $allhorse_num=@horse_num;#出走頭数
my @true_num=&hat_color_num($allhorse_num);#枠番と枠色を取得
if(@horse_num>0){
print('
枠番 ');
foreach(@horse_num){
my $temp_num=$_-1;
my $hat_color=$hat_color[$true_num[$temp_num]-1];
print('',$true_num[$temp_num],' ');
}
print('馬番 ');
for($i=0;$i<@horse_num;$i++){
print('',$horse_num[$i],' ');
}
print('名前 ');
my $change1='ー';
my $change2='|';
for($i=0;$i<@horse_num;$i++){
$horse_names{$horse_num[$i]}=~s/\Q$change1\E/$change2/go;
if($torikesi_mark ne '' && $horse_names{$horse_num[$i]}=~/$torikesi_mark/){
$horse_names{$horse_num[$i]}=~s/$torikesi_mark//go;
$horse_names{$horse_num[$i]}=''.$horse_names{$horse_num[$i]}.' ';
}#出走取り消し馬には横線を引く
print('',$horse_names{$horse_num[$i]},' ');
}
print(' ');
my @true_ranks=sort{ $vote_times{$b}<=>$vote_times{$a} }keys %vote_times;
my $top_ranks;
$top_ranks=@true_ranks-$page*$top_max if($top_max>@true_ranks-$page*$top_max);
$top_ranks=$top_max if($top_max<=@true_ranks-$page*$top_max);
my $window_size="width=517,height=167,resizable";
$window_size="\'".$window_size."\'";
for($i=0;$i<$top_ranks;$i++){
my $name=$vote_names{$true_ranks[$i+$page*$top_max]};
my $num=$vote_nums{$true_ranks[$i+$page*$top_max]};
my @mymark_save=split(/=/,$vote_marks{$true_ranks[$i+$page*$top_max]});
print('');
print("◆ $name ");
for($j=0;$j<@horse_num;$j++){
my $check;
my $mark_rank;
for($k=0;$k<@mymark_save;$k++){
if($horse_num[$j] eq $mymark_save[$k]){
$check=1;
$mark_rank=$k;
last;
}
}
if($check==1){
print('',$mark[$mark_rank],' ');
}
else{
print(' ');
}
}
print(' ');
}
print('
◆ をクリックしますと、投票内容が表示されます ');
print('
') if($page>0);
print('') if(@true_ranks>$top_ranks+$top_max*$page);
}
print <
END_OF_TEXT
}
####################システム説明html####################
sub info_list{
if($pool==0){
$pool='軍資金に加算されない';
}
elsif($pool==1){
$pool='軍資金に加算される';
}
if($max_money==0){
if($week_money>0){
$max_money='現軍資金+レース毎に配布される軍資金';
}
else{
$max_money='現軍資金';
}
}
elsif($max_money>0){
$max_money="$max_money $yen";
}
print <
システム説明
◆新規登録時に配布される軍資金 $regist_money $yen
◆レース毎に配布される軍資金 $week_money $yen
◆レース毎に配布される軍資金の残りは? $pool
◆レースに賭ける事の出来る軍資金上限 $max_money
◆レースに賭ける事の出来る軍資金下限 $minimum_money $yen ($minimum_money $yen単位)
レース毎に配布される軍資金が0$yenの場合は、現軍資金内で投票する事になります。
また、レースに賭ける事の出来る軍資金上限が、○○○○$yenと決まっている場合は・・・
たとえ、軍資金がマイナスであっても、○○○○$yenまでなら投票する事が可能\です。
しかし、○○○○$yenと決まっていない場合は、軍資金がなくなった時点で、投票不可能\となります。
(そう言う場合は、管理人さんに頼み込んで軍資金を融通してもらうしかありません)
レース毎に配布される軍資金の残りが、次回のレースに加算されない場合は・・・
レース毎に配布される軍資金を使い切った方が、お得です!
また、次回レースに加算される場合は・・・
自信のあるレースやG1等の重賞レースの為に、少しずつ貯金するのも良いでしょう!
(但し、レースに投票しないと、軍資金の配布を受ける事は出来ませんので、ご注意下さい)
補足説明
◆まずは、会員登録し、パスワードを入手して下さい。
◆レース表\が作成されていて、投票締め切り時刻を過ぎていない場合は、投票する事が出来ます。
◆投票は、締め切り時刻内なら、何度でもやり直す事が出来ます。
◆投票内容は、「今回の投票内容」のコーナーで、見る事が出来ます。
◆予\想内容は、「今回の予\想内容」のコーナーで、見る事が出来ます。
◆投票馬券が的中すると、払戻金をもらう事が出来ます。
◆除外等で、投票馬券が無効の際も、払戻金をもらう事が出来ます。
◆払戻金は、「前回の結果」のコーナーに表\示されます。
◆前回の結果に表\示される「収支」は、レース毎に配布される軍資金等も含めたトータル収支です。
◆軍資金の多寡は、「ランキング」のコーナーで見る事が出来ます。
◆すべての権限は、管理人さんにありますので、管理人さんの指示に従って下さい。
END_OF_TEXT
}
##################個別投票内容html##################
sub call_list{
foreach(keys %vote_nums){
if($call_num eq $vote_nums{$_}){
$call_pass=$_;
last;
}
}
if($call_pass ne ''){
my $name=$vote_names{$call_pass};
my $date=$vote_dates{$call_pass};
my $comment=$vote_comments{$call_pass};
my @vote_save=split(/,/,$vote_saves{$call_pass});
my @mymark_save=split(/=/,$vote_marks{$call_pass});
print('',$name,' ',$date,' ');
for($j=0;$j<@vote_save;$j++){
my $one;
my @one=split(/::/,$vote_save[$j]);
$one[1]='全' if($one[1]>90);
$one[2]='全' if($one[2]>90);
$one[3]='全' if($one[3]>90);
if($one[0]==0 || $one[0]==7){
$one="$vote_array[$one[0]]:$one[1]-$one[2]-$one[3]☆☆ $one[4]$yen";
}
elsif($one[0]>=1 && $one[0]<5){
$one="$vote_array[$one[0]]:$one[1]-$one[2]☆☆ $one[4]$yen";
}
else{
$one="$vote_array[$one[0]]:$one[1]☆☆ $one[4]$yen";
}
print('',$one,' ');
}
print('合計:',$total_money,$yen,' ') if(@vote_save>0);
print(' ');
print('');
for($j=0;$j<@mymark_save;$j++){
next if($mymark_save[$j] eq '');
print('',$mark[$j],':',$horse_names{$mymark_save[$j]},' ');
}
if(@mymark_save==0){
print(' ');
}
print(' ');
print('',$comment,' ') if($comment ne '');
print('
');
}
else{
print('該当する投票データがありません');
}
}
##################レース結果作成html##################
sub make_result{
print <
注:間違った結果を送信してしまった場合は・・・
管理人コマンドの『バックアップデータロード』を使って
すぐに元のデータに戻し、やり直して下さい。
END_OF_TEXT
}
####################管理人専用html####################
sub target_list{
my @horse_num=sort{ $a<=>$b }keys %horse_names;
my $torikesi_comment="出走取消しの場合は、馬名の横に「$torikesi_mark」と記入して下さい。" if($torikesi_mark ne '');
print <管理人専用コマンド
$torikesi_comment
予\想レース作成フォーム
レース名・レース総評等
$race_comment
発走日時(締切時刻)
END_OF_TEXT
if($timelocal_use==0){
$deadline_time=$now_time if($deadline_time eq '');
my ($sec,$minute,$hour,$day,$month,$year) = localtime($deadline_time);
my ($sec2,$minute2,$hour2,$day2,$month2,$year2) = localtime($now_time);
$year2+=1900;
$month+=1;
print ('');
if($year ne ''){
if($year==$year2-1900){
print (' ',$year2);
}
else{
print (' ',$year2);
}
if($year==$year2+1-1900){
print (' ',$year2+1);
}
else{
print (' ',$year2+1);
}
}
else{
print (' ',$year2);
print (' ',$year2+1);
}
print (' 年');
print ('');
for($i=0;$i<12;$i++){
print (' ',$i+1) if($month==$i+1);
print (' ',$i+1) if($month!=$i+1);
}
print (' 月');
print ('');
for($i=0;$i<31;$i++){
print (' ',$i+1) if($day==$i+1);
print (' ',$i+1) if($day!=$i+1);
}
print (' 日 ');
print ('');
for($i=0;$i<24;$i++){
print (' ',$i) if($hour==$i);
print (' ',$i) if($hour!=$i);
}
print (' 時');
print ('');
for($i=0;$i<60;$i++){
print (' ',$i) if($minute==$i);
print (' ',$i) if($minute!=$i);
}
print (' 分');
}
else{
$deadline_time=$now_time if($deadline_time eq '');
my ($sec,$minute,$hour,$day,$month,$year) = localtime($deadline_time);
$month+=1;
$minute=int($minute/5)*5;
print ('現在時刻(',$month,'月',$day,'日',$hour,'時',$minute,'分)に ');
print ('プラスマイナスして発走日時を決めて下さい ');
print ('現在のまま');
print (' 1日後');
print (' 2日後');
print (' 3日後');
print (' 4日後');
print (' 5日後');
print (' 6日後');
print (' 1週間後');
print (' 1日前');
print (' 2日前');
print (' ');
print ('現在のまま');
print (' 1時間後');
print (' 2時間後');
print (' 3時間後');
print (' 4時間後');
print (' 5時間後');
print (' 6時間後');
print (' 7時間後');
print (' 8時間後');
print (' 9時間後');
print (' 10時間後');
print (' 11時間後');
print (' 12時間後');
print (' 1時間前');
print (' 2時間前');
print (' 3時間前');
print (' 4時間前');
print (' 5時間前');
print (' 6時間前');
print (' 7時間前');
print (' 8時間前');
print (' 9時間前');
print (' 10時間前');
print (' 11時間前');
print (' 12時間前');
print (' ');
print ('現在のまま');
print (' 1分後');
print (' 5分後');
print (' 10分後');
print (' 15分後');
print (' 20分後');
print (' 25分後');
print (' 30分後');
print (' 35分後');
print (' 40分後');
print (' 45分後');
print (' 50分後');
print (' 55分後');
print (' 1分前');
print (' 5分前');
print (' 10分前');
print (' 15分前');
print (' 20分前');
print (' 25分前');
print (' 30分前');
print (' 35分前');
print (' 40分前');
print (' 45分前');
print (' 50分前');
print (' 55分前');
print (' ');
}
print <
馬番 馬名 $subcomment
END_OF_TEXT
for($i=1;$i<$max_horse+1;$i++){
print('',$i,' ') ;
}
print <
END_OF_TEXT
}
###################会員名簿一覧html###################
sub member_list{
print <
修正or退会させるデータを指定し、修正or退会ボタンを選択してから・・・
送信ボタンを押して下さい
(退会の場合は、一度に複数のデータを指定可能\です)
会員名簿一覧
指定 名前 メールアドレス パスワード 登録日
END_OF_TEXT
my @true_ranks=sort{ $member_times{$b}<=>$member_times{$a} }keys %member_times;
for($i=0;$i<@true_ranks;$i++){
my $name=$member_names{$true_ranks[$i]};
my $email=$member_mails{$true_ranks[$i]};
my $pass=$member_passs{$true_ranks[$i]};
my $date=$member_times{$true_ranks[$i]};
my ($sec,$min,$hour,$day,$month) = localtime($date);
$month = ($month + 1);
if($month < 10) { $month = "0$month"; }
if($day < 10) { $day = "0$day"; }
$date = "$month月$day日";
print(
'',
'',
' ',' ',
'',$name,' ',$email,' ',$pass,' ',$date,' ',
) ;
}
print < 修正 退会
END_OF_TEXT
}
###################会員データ修正html###################
sub repair_list{
print <
データを書き換えて、送信ボタンを押して下さい
END_OF_TEXT
}
###############新規登録html###############
sub regist_list{
print <
名前とメールアドレスを記入して下さい
(半角カナや特殊文字等は、使用しないで下さい)
$error_code
END_OF_TEXT
}
###############会員削除html###############
sub delete_list{
($cookie_name,$cookie_pass) = get_cookie();
($c_cook,$c_name)=split(/:/,$cookie_name);
($c_cook,$c_pass)=split(/:/,$cookie_pass);
print <
$error_code
END_OF_TEXT
}
###############新規登録成功html###############
sub regist_success_list{
if($userregist==0){
print <
会員登録ありがとうございます
◆名前 $name
◆メールアドレス $email
◆パスワード $new_password
上記事項は、重要ですので忘れないようにして下さい。
END_OF_TEXT
}
elsif($userregist==1){
print <
会員登録しました!!
◆名前 $name
◆メールアドレス $email
◆パスワード $new_password
END_OF_TEXT
}
}
###############新規登録成功html(メール版)###############
sub regist_success_list2{
if($userregist==0){
print <
会員登録ありがとうございます
◆名前 $name
◆メールアドレス $email
パスワードは、上記メールアドレス宛に送付させてもらいましたので・・・
メールボックスを確認してみて下さいませ。
(サーバの調子によっては、数時間要する事もありますので、ご注意下さい)
(また、メールの件名は『$default_subject』となっています)
END_OF_TEXT
}
elsif($userregist==1){
print <
会員登録しました!!
◆名前 $name
◆メールアドレス $email
パスワードは、上記メールアドレス宛に送付しました!!
END_OF_TEXT
}
}
###############新規登録失敗html###############
sub regist_success_list3{
print <
$error_code
END_OF_TEXT
}
###############登録削除成功html###############
sub delete_success_list{
print <
削除成功
◆登録名 $name
◆パスワード $pass
END_OF_TEXT
}
####################投票OPEN####################
sub vote_open{
unless(-f $vote_file){ open(DATA,">$vote_file");close(DATA); }
if(open(DATA,"$vote_file")){
my @line = ;
close(DATA);
for($i=0;$i<@line;$i++){
chomp($line[$i]);
my ($pass,$name,$comment,$last_time,$date_total_money,$mymark,@vote_save) = split(/,/,$line[$i]);
my ($date,$total_money) = split(/==/,$date_total_money);
my $vote_save=join(',',@vote_save);
$vote_names{$pass}=$name;
$vote_comments{$pass}=$comment;
$vote_times{$pass}=$last_time;
$vote_dates{$pass}=$date;
$vote_saves{$pass}=$vote_save;
$vote_marks{$pass}=$mymark;
$vote_total_moneys{$pass}=$total_money;
$vote_nums{$pass}=$i;
}
}
else{
$error_code='データファイルへのアクセスに失敗しました!!';
}
}
####################投票SAVE####################
sub vote_save{
my $vote_save=join(',',@save);#投票内容
my $mymark_save=join('=',@mymark);#予想内容
my ($sec,$min,$hour,$day,$month,$year,$wday) = localtime($now_time);
$month = ($month + 1);
if($month < 10) { $month = "0$month"; }
if($day < 10) { $day = "0$day"; }
if($hour < 10) { $hour = "0$hour"; }
if($min < 10) { $min = "0$min"; }
my $date;
if($date_way==0){
$date = "";
}
elsif($date_way==1){
$date = "($month月$day日 $hour時$min分)";
}
elsif($date_way==2){
$date = "($month月$day日)";
}
elsif($date_way==3){
$date = "$month月$day日$wday[$wday]$hour時$min分";
}
elsif($date_way==4){
$date = "$month月$day日$wday[$wday]";
}
elsif($date_way==5){
$date = "$month/$day$wday2[$wday]$hour:$min";
}
elsif($date_way==6){
$date = "$month/$day$wday2[$wday]";
}
my $date_total_money=$date.'=='.$total_money;
$comment =~ s/\r\n/ /g;
$comment =~ s/\r/ /g;
$comment =~ s/\n/ /g;
$comment =~ s/\t/ /g;
$comment=~ s/ / /g;
if($tag==0 && $inlinelink==1){
$comment=~s/(http:\/\/[!#-9A-~]+)/$1<\/a>/g;
$comment=~s/([0-9a-z_\.\-]+\@([0-9a-z_\-]+\.)+[0-9a-z_\-]+)/ $1<\/a>/ig;
}
elsif($tag==0 && $inlinelink==2){
$comment=~s/(http:\/\/[!#-9A-~]+)/ $inline_word<\/a>/g;
$comment=~s/([0-9a-z_\.\-]+\@([0-9a-z_\-]+\.)+[0-9a-z_\-]+)/ $inline_word<\/a>/ig;
}
elsif($tag==0 && $inlinelink==3){
$comment=~s/(http:\/\/[!#-9A-~]+)/ $inline_image<\/a>/g;
$comment=~s/([0-9a-z_\.\-]+\@([0-9a-z_\-]+\.)+[0-9a-z_\-]+)/ $inline_image<\/a>/ig;
}
unless(-f $vote_file){ open(DATA,">$vote_file");close(DATA); }
if(open(DATA,"$vote_file")){
my @line = ;
close(DATA);
my $check;
for($i=0;$i<@line;$i++){
if($line[$i]=~/^$pass,/){
$line[$i]="$pass,$name,$comment,$now_time,$date_total_money,$mymark_save,$vote_save\n";
$check=1;
last;
}
}
if($check==0){
push(@line,"$pass,$name,$comment,$now_time,$date_total_money,$mymark_save,$vote_save\n");
}
if(open(DATA, ">$vote_file")){
for($i=0;$i<@line;$i++){
print DATA "$line[$i]";
}
close(DATA);
}
}
}
####################データ収集####################
sub data_open{
unless(-f $data_file){ open(DATA,">$data_file");close(DATA); }
if(open(DATA,"$data_file")){
my @line = ;
close(DATA);
for($i=0;$i<@line;$i++){
chomp($line[$i]);
if($i==0){
$deadline_time=$line[$i];
}
elsif($i==1){
$race_comment=$line[$i];
}
else{
my ($horse_num,$horse_name,$horse_comment) = split(/,/,$line[$i]);
$horse_names{$horse_num}=$horse_name;
$horse_comments{$horse_num}=$horse_comment;
}
}
}
else{
$error_code='データファイルへのアクセスに失敗しました!!';
}
}
####################データセーブ####################
sub data_save{
$race_comment =~ s/\r\n/ /g;
$race_comment =~ s/\r/ /g;
$race_comment =~ s/\n/ /g;
$race_comment =~ s/\t/ /g;
$race_comment =~ s/ / /g;
if($timelocal_use==1){
if(open(DATA,"$data_file")){
my @line = ;
close(DATA);
for($i=0;$i<@line;$i++){
chomp($line[$i]);
if($i==0){
$deadline_time=$line[$i];
last;
}
}
}
$deadline_time=$now_time if($deadline_time eq '');
$deadline_time=int($deadline_time/(60*5))*(60*5);
$permit_time=$deadline_time+60*60*24*$p_day+60*60*$p_hour+60*$p_minute;
}#発走時刻の計算(@niftyの場合)
if(open(DATA,">$data_file")){
print DATA "$permit_time\n";
print DATA "$race_comment\n";
for($i=0;$i<$max_horse;$i++){
next if($horse_name[$i] eq '');
my $num=$i+1;
print DATA "$num,$horse_name[$i],$horse_comment[$i]\n";
}
close(DATA);
}
else{
$error_code='データファイルへのアクセスに失敗しました!!';
}
}
####################結果データ収集####################
sub result_open{
unless(-f $result_file){ open(DATA,">$result_file");close(DATA); }
if(open(DATA,"$result_file")){
my @line = ;
close(DATA);
for($i=0;$i<@line;$i++){
chomp($line[$i]);
if($i==0){
$race_comment=$line[$i];
}
elsif($i==1){
$allhorse_num=$line[$i];
}
elsif($i==2){
my @before_race=split(/,/,$line[$i]);
foreach(@before_race){
my ($horse_num,$horse_name)=split(/=/,$_);
$befor_names{$horse_num}=$horse_name;
}
}
elsif($i==3){
@result_vote=split(/,/,$line[$i]);
}
elsif($i==4){
my @result_rank=split(/,/,$line[$i]);
foreach(@result_rank){
my ($horse_num,$horse_result,$horse_name)=split(/=/,$_);
$horse_names{$horse_num}=$horse_name;
$horse_results{$horse_num}=$horse_result;
}
}
else{
my ($pass,$name,$comment,$addmoney_soneki,$mymark,@vote_save) = split(/,/,$line[$i]);
my ($addmoney,$soneki) = split(/==/,$addmoney_soneki);
my $vote_save=join(',',@vote_save);
$vote_names{$pass}=$name;
$vote_comments{$pass}=$comment;
$vote_addmoneys{$pass}=$addmoney;
$vote_saves{$pass}=$vote_save;
$vote_marks{$pass}=$mymark;
$vote_sonekis{$pass}=$soneki;
}
}
}
else{
$error_code='データファイルへのアクセスに失敗しました!!';
}
}
####################結果データセーブ####################
sub result_save{
$race_comment =~ s/\r\n/ /g;
$race_comment =~ s/\r/ /g;
$race_comment =~ s/\n/ /g;
$race_comment =~ s/\t/ /g;
$race_comment =~ s/ / /g;
my $allhorse_num=@horse_name;#参加頭数
my $rentan_plus;#勝ち馬投票券に3連単を加える場合の変数
for($i=0;$i<@vote_num1;$i++){
next if($vote_num1[$i] eq '');
$vote_money[$i]=~s/$yen//go;
$vote_money[$i]=~s/0/0/go;
$vote_money[$i]=~s/1/1/go;
$vote_money[$i]=~s/2/2/go;
$vote_money[$i]=~s/3/3/go;
$vote_money[$i]=~s/4/4/go;
$vote_money[$i]=~s/5/5/go;
$vote_money[$i]=~s/6/6/go;
$vote_money[$i]=~s/7/7/go;
$vote_money[$i]=~s/8/8/go;
$vote_money[$i]=~s/9/9/go;
if($doutyaku==0){
$rentan_plus=1 if($rentan==1);
if($i==0){
push(@win,"0::$vote_num1[$i]::$vote_num2[$i]::$vote_num3[$i]::$vote_money[$i]");
}#3連複
elsif($i==1 && $rentan==1){
push(@win,"7::$vote_num1[$i]::$vote_num2[$i]::$vote_num3[$i]::$vote_money[$i]");
}#3連単
elsif($i==1+$rentan_plus){
push(@win,"1::$vote_num1[$i]::$vote_num2[$i]::0::$vote_money[$i]");
}#馬連
elsif($i==2+$rentan_plus){
push(@win,"2::$vote_num1[$i]::$vote_num2[$i]::0::$vote_money[$i]");
}#馬単
elsif($i==3+$rentan_plus){
push(@win,"3::$vote_num1[$i]::$vote_num2[$i]::0::$vote_money[$i]");
}#枠連
elsif($i>=4+$rentan_plus && $i<=6+$rentan_plus){
push(@win,"4::$vote_num1[$i]::$vote_num2[$i]::0::$vote_money[$i]");
}#ワイド
elsif($i==7+$rentan_plus){
push(@win,"5::$vote_num1[$i]::0::0::$vote_money[$i]");
}#単勝
elsif($i>=8+$rentan_plus && $i<=10+$rentan_plus){
push(@win,"6::$vote_num1[$i]::0::0::$vote_money[$i]");
}#複勝
}#通常時
else{
$rentan_plus=3 if($rentan==1);
if($i>=0 && $i<3){
push(@win,"0::$vote_num1[$i]::$vote_num2[$i]::$vote_num3[$i]::$vote_money[$i]");
}#3連複
elsif($i>=3 && $i<6 && $rentan==1){
push(@win,"7::$vote_num1[$i]::$vote_num2[$i]::$vote_num3[$i]::$vote_money[$i]");
}#3連単
elsif($i>=3+$rentan_plus && $i<6+$rentan_plus){
push(@win,"1::$vote_num1[$i]::$vote_num2[$i]::0::$vote_money[$i]");
}#馬連
elsif($i>=6+$rentan_plus && $i<9+$rentan_plus){
push(@win,"2::$vote_num1[$i]::$vote_num2[$i]::0::$vote_money[$i]");
}#馬単
elsif($i>=9+$rentan_plus && $i<12+$rentan_plus){
push(@win,"3::$vote_num1[$i]::$vote_num2[$i]::0::$vote_money[$i]");
}#枠連
elsif($i>=12+$rentan_plus && $i<18+$rentan_plus){
push(@win,"4::$vote_num1[$i]::$vote_num2[$i]::0::$vote_money[$i]");
}#ワイド
elsif($i>=18+$rentan_plus && $i<21+$rentan_plus){
push(@win,"5::$vote_num1[$i]::0::0::$vote_money[$i]");
}#単勝
elsif($i>=21+$rentan_plus && $i<27+$rentan_plus){
push(@win,"6::$vote_num1[$i]::0::0::$vote_money[$i]");
}#複勝
}#同着時
}
for($i=0;$i<@vote_kind;$i++){
if($doutyaku==1){
$vote_kind[$i]=~s/0/0/go;
$vote_kind[$i]=~s/1/1/go;
$vote_kind[$i]=~s/2/2/go;
$vote_kind[$i]=~s/3/3/go;
$vote_kind[$i]=~s/4/4/go;
$vote_kind[$i]=~s/5/5/go;
$vote_kind[$i]=~s/6/6/go;
$vote_kind[$i]=~s/7/7/go;
$vote_kind[$i]=~s/8/8/go;
$vote_kind[$i]=~s/9/9/go;
}
if($vote_kind[$i]==100){
my $num=$i+1;
push(@modosi_num,$num);
}
}#除外馬の番号
if(@modosi_num>0){
my @true_num=&hat_color_num($allhorse_num);
foreach(@true_num){
$double_nums{$_}++;
}
foreach(@modosi_num){
$double_nums{$_}--;
}
foreach(@modosi_num){
if($double_nums{$_}==0){
push(@modosi_baken,"3::${_}::0::0::100");
}
elsif($double_nums{$_}==1){
push(@modosi_baken,"3::${_}::${_}::0::100");
}
push(@modosi_baken,"0::${_}::0::0::100");
push(@modosi_baken,"1::${_}::0::0::100");
push(@modosi_baken,"2::${_}::0::0::100");
push(@modosi_baken,"4::${_}::0::0::100");
push(@modosi_baken,"5::${_}::0::0::100");
push(@modosi_baken,"6::${_}::0::0::100");
push(@modosi_baken,"7::${_}::0::0::100");
}
}#除外馬のある場合の処理
&vote_open;
my @keys=keys %vote_saves;
foreach(@keys){
my @check_vote=split(/,/,$vote_saves{$_});
for($i=0;$i<@check_vote;$i++){
my @vote=split(/::/,$check_vote[$i]);
for($j=0;$j<@win;$j++){
my @win_vote=split(/::/,$win[$j]);
if($vote[0] eq $win_vote[0]){
if($vote[0] eq '0'){
if($vote[1] > 90 && $vote[2] > 90 && $vote[3] > 90){
$add_moneys{$_}+=$vote[4]*$win_vote[4]/100;
last;
}
elsif($vote[2] > 90 && $vote[3] > 90){
if($vote[1] eq $win_vote[1] || $vote[1] eq $win_vote[2] || $vote[1] eq $win_vote[3]){
$add_moneys{$_}+=$vote[4]*$win_vote[4]/100;
last;
}
}
elsif($vote[3] > 90){
if($vote[1] eq $win_vote[1] && $vote[2] eq $win_vote[2]){
$add_moneys{$_}+=$vote[4]*$win_vote[4]/100;
last;
}
elsif($vote[1] eq $win_vote[1] && $vote[2] eq $win_vote[3]){
$add_moneys{$_}+=$vote[4]*$win_vote[4]/100;
last;
}
elsif($vote[1] eq $win_vote[2] && $vote[2] eq $win_vote[3]){
$add_moneys{$_}+=$vote[4]*$win_vote[4]/100;
last;
}
}
}#3連複で全流しがある場合専用
elsif($vote[0] eq '1' || $vote[0] eq '3' || $vote[0] eq '4'){
if($vote[1] > 90 && $vote[2] > 90){
$add_moneys{$_}+=$vote[4]*$win_vote[4]/100;
last;
}
elsif($vote[2] > 90){
if($vote[1] eq $win_vote[1] || $vote[1] eq $win_vote[2]){
$add_moneys{$_}+=$vote[4]*$win_vote[4]/100;
last;
}
}
}#馬番・枠連・ワイドで全流しがある場合専用
if($vote[1] eq $win_vote[1] && $vote[2] eq $win_vote[2] && $vote[3] eq $win_vote[3]){
$add_moneys{$_}+=$vote[4]*$win_vote[4]/100;
last;
}#通常
elsif($vote[1] > 90 && $vote[2] eq $win_vote[2] && $vote[3] eq $win_vote[3]){
$add_moneys{$_}+=$vote[4]*$win_vote[4]/100;
last;
}#全流しがある場合↓
elsif($vote[1] eq $win_vote[1] && $vote[2] > 90 && $vote[3] eq $win_vote[3]){
$add_moneys{$_}+=$vote[4]*$win_vote[4]/100;
last;
}
elsif($vote[1] eq $win_vote[1] && $vote[2] eq $win_vote[2] && $vote[3] > 90){
$add_moneys{$_}+=$vote[4]*$win_vote[4]/100;
last;
}
elsif($vote[1] > 90 && $vote[2] > 90 && $vote[3] eq $win_vote[3]){
$add_moneys{$_}+=$vote[4]*$win_vote[4]/100;
last;
}
elsif($vote[1] > 90 && $vote[2] eq $win_vote[2] && $vote[3] > 90){
$add_moneys{$_}+=$vote[4]*$win_vote[4]/100;
last;
}
elsif($vote[1] eq $win_vote[1] && $vote[2] > 90 && $vote[3] > 90){
$add_moneys{$_}+=$vote[4]*$win_vote[4]/100;
last;
}
elsif($vote[1] > 90 && $vote[2] > 90 && $vote[3] > 90){
$add_moneys{$_}+=$vote[4]*$win_vote[4]/100;
last;
}
}
}
}
}
#3連複、返還計算:(($allhorse_num-2)+1)*(($allhorse_num-2)/2)
#3連単、返還計算:(($allhorse_num-2)+1)*(($allhorse_num-2)/2)*2
my $allwaku_num;#総枠数
if(@modosi_baken>0){
foreach(@keys){
my @check_vote=split(/,/,$vote_saves{$_});
for($i=0;$i<@check_vote;$i++){
my @vote=split(/::/,$check_vote[$i]);
for($j=0;$j<@modosi_baken;$j++){
my @modosi_vote=split(/::/,$modosi_baken[$j]);
if($vote[0] eq '3' && $modosi_vote[0] eq '3'){
if($modosi_vote[2] ne ''){
if($vote[1] eq $modosi_vote[1] && $vote[2] eq $modosi_vote[2]){
$add_moneys{$_}+=$vote[4];
last;
}
elsif($vote[1]>90 && $vote[2]>90){
$add_moneys{$_}+=$vote[4];
last;
}
elsif($vote[1]>90 && $vote[2] eq $modosi_vote[2]){
$add_moneys{$_}+=$vote[4];
last;
}
elsif($vote[1] eq $modosi_vote[1] && $vote[2]>90){
$add_moneys{$_}+=$vote[4];
last;
}
}#3-3等のゾロ目のみ払い戻し
else{
if($vote[1]>90 && $vote[2]>90){
$allwaku_num=$allhorse_num if($allhorse_num<=8);
$allwaku_num=8 if($allhorse_num>8);
if($double_nums{$modosi_vote[1]}==0){
$allwaku_num--;
}
$add_moneys{$_}+=$vote[4]*$allwaku_num;
last;
}
elsif($vote[1] eq $modosi_vote[1] && $vote[2]>90){
$allwaku_num=$allhorse_num if($allhorse_num<=8);
$allwaku_num=8 if($allhorse_num>8);
if($double_nums{$modosi_vote[1]}==0){
$allwaku_num--;
}
$add_moneys{$_}+=$vote[4]*$allwaku_num;
last;
}
elsif($vote[1]>90 || $vote[2]>90){
$add_moneys{$_}+=$vote[4];
last;
}
elsif($vote[1] eq $modosi_vote[1] || $vote[2] eq $modosi_vote[1]){
$add_moneys{$_}+=$vote[4];
last;
}
}
}
elsif($vote[0] eq '0' || $vote[0] eq '7'){
if($vote[0] eq '0' && $modosi_vote[0] eq '0'){
}
elsif($vote[0] eq '7' && $modosi_vote[0] eq '7'){
}
else{
next;
}
if($vote[1]<90 && $vote[2]<90 && $vote[3]<90){
if($vote[1] eq $modosi_vote[1] || $vote[2] eq $modosi_vote[1] || $vote[3] eq $modosi_vote[1]){
$add_moneys{$_}+=$vote[4];
last;
}
}#全流しがない場合↓
elsif($vote[1]>90 && $vote[2]<90 && $vote[3]<90){
if($vote[2] eq $modosi_vote[1] || $vote[3] eq $modosi_vote[1]){
$add_moneys{$_}+=$vote[4]*($allhorse_num-2);
last;
}
else{
$add_moneys{$_}+=$vote[4];
last;
}
}#全流しが1つの場合↓
elsif($vote[1]<90 && $vote[2]>90 && $vote[3]<90){
if($vote[1] eq $modosi_vote[1] || $vote[3] eq $modosi_vote[1]){
$add_moneys{$_}+=$vote[4]*($allhorse_num-2);
last;
}
else{
$add_moneys{$_}+=$vote[4];
last;
}
}#全流しが1つの場合↓
elsif($vote[1]<90 && $vote[2]<90 && $vote[3]>90){
if($vote[1] eq $modosi_vote[1] || $vote[2] eq $modosi_vote[1]){
$add_moneys{$_}+=$vote[4]*($allhorse_num-2);
last;
}
else{
$add_moneys{$_}+=$vote[4];
last;
}
}#全流しが1つの場合↓
elsif($vote[1]>90 && $vote[2]>90 && $vote[3]<90){
if($vote[3] eq $modosi_vote[1]){
if($vote[0] eq '0'){
$add_moneys{$_}+=$vote[4]*(($allhorse_num-2)+1)*(($allhorse_num-2)/2);
}
elsif($vote[0] eq '7'){
$add_moneys{$_}+=$vote[4]*(($allhorse_num-2)+1)*(($allhorse_num-2)/2)*2;
}
last;
}
else{
if($vote[0] eq '0'){
$add_moneys{$_}+=$vote[4]*($allhorse_num-2);
}
elsif($vote[0] eq '7'){
$add_moneys{$_}+=$vote[4]*($allhorse_num-2)*2;
}
last;
}
}#全流しが2つの場合
elsif($vote[1]>90 && $vote[2]<90 && $vote[3]>90){
if($vote[2] eq $modosi_vote[1]){
if($vote[0] eq '0'){
$add_moneys{$_}+=$vote[4]*(($allhorse_num-2)+1)*(($allhorse_num-2)/2);
}
elsif($vote[0] eq '7'){
$add_moneys{$_}+=$vote[4]*(($allhorse_num-2)+1)*(($allhorse_num-2)/2)*2;
}
last;
}
else{
if($vote[0] eq '0'){
$add_moneys{$_}+=$vote[4]*($allhorse_num-2);
}
elsif($vote[0] eq '7'){
$add_moneys{$_}+=$vote[4]*($allhorse_num-2)*2;
}
last;
}
}#全流しが2つの場合
elsif($vote[1]<90 && $vote[2]>90 && $vote[3]>90){
if($vote[1] eq $modosi_vote[1]){
if($vote[0] eq '0'){
$add_moneys{$_}+=$vote[4]*(($allhorse_num-2)+1)*(($allhorse_num-2)/2);
}
elsif($vote[0] eq '7'){
$add_moneys{$_}+=$vote[4]*(($allhorse_num-2)+1)*(($allhorse_num-2)/2)*2;
}
last;
}
else{
if($vote[0] eq '0'){
$add_moneys{$_}+=$vote[4]*($allhorse_num-2);
}
elsif($vote[0] eq '7'){
$add_moneys{$_}+=$vote[4]*($allhorse_num-2)*2;
}
last;
}
}#全流しが2つの場合
elsif($vote[1]>90 && $vote[2]>90 && $vote[3]>90){
if($vote[0] eq '0'){
$add_moneys{$_}+=$vote[4]*(($allhorse_num-2)+1)*(($allhorse_num-2)/2);
}
elsif($vote[0] eq '7'){
$add_moneys{$_}+=$vote[4]*(($allhorse_num-2)+1)*(($allhorse_num-2)/2)*2;
}
last;
}#全流しが3つの場合
}#3連複&3連単
elsif($vote[0] eq $modosi_vote[0]){
if($vote[1]<90 && $vote[2]<90){
if($vote[1] eq $modosi_vote[1] || $vote[2] eq $modosi_vote[1]){
$add_moneys{$_}+=$vote[4];
last;
}
}#全流しがない場合↓
elsif($vote[1]>90 && $vote[2]<90){
if($vote[2] eq $modosi_vote[1]){
$add_moneys{$_}+=$vote[4]*($allhorse_num-1);
last;
}
else{
$add_moneys{$_}+=$vote[4];
last;
}
}#全流しが1つの場合↓
elsif($vote[1]<90 && $vote[2]>90){
if($vote[1] eq $modosi_vote[1]){
$add_moneys{$_}+=$vote[4]*($allhorse_num-1);
last;
}
else{
$add_moneys{$_}+=$vote[4];
last;
}
}#全流しが1つの場合↓
elsif($vote[1]>90 && $vote[2]>90){
if($vote[0] eq '2'){
$add_moneys{$_}+=$vote[4]*($allhorse_num-1)*2;
last;
}#馬単
else{
$add_moneys{$_}+=$vote[4]*($allhorse_num-1);
last;
}
}#全流しが2つの場合↓
}#単・複・馬番・馬単
}
}
}
}#除外馬のある場合の処理
foreach(@keys){
my $pool_money;
my $week_pool_money;
if($week_money>0){
$pool_money=$week_money-$vote_total_moneys{$_};
if($pool==1){
if($pool_money<=0){
$week_pool_money=$week_money;
}#残りがない場合
else{
$week_pool_money=$pool_money+$vote_total_moneys{$_};
}#残りがある場合
}#小遣いの残りを加算する
else{
if($pool_money<=0){
$week_pool_money=$week_money;
}#残りがない場合
else{
$week_pool_money=$vote_total_moneys{$_};
print"1";
}#残りがある場合
}#小遣いの残りを加算しない
}#レース毎に小遣いが配布される場合
$soneki_moneys{$_}=$week_pool_money+$add_moneys{$_}-$vote_total_moneys{$_};
}
&money_save;
my @win_rank;
for($i=0;$i<@vote_kind;$i++){
next if($vote_kind[$i] eq '');
my $num=$i+1;
push(@win_rank,"$num=$vote_kind[$i]=$horse_name[$i]");
}
my @before_horse;
foreach(sort{ $a<=>$b }keys %horse_names){
push(@before_horse,"$_=$horse_names{$_}");
}
my $before_horse=join(',',@before_horse);
my $win_rank=join(',',@win_rank);
my $win_save=join(',',@win);
unless(-f $result_file){ open(DATA,">$result_file");close(DATA); }
if(open(DATA,">$result_file")){
print DATA "$race_comment\n";
print DATA "$allhorse_num\n";
print DATA "$before_horse\n";
print DATA "$win_save\n";
print DATA "$win_rank\n";
my @bingo_rank=sort{ $add_moneys{$b}<=>$add_moneys{$a} } @keys;
foreach(@bingo_rank){
my $add_money_soneki_money=$add_moneys{$_}.'=='.$soneki_moneys{$_};
print DATA "$_,$vote_names{$_},$vote_comments{$_},$add_money_soneki_money,$vote_marks{$_},$vote_saves{$_}\n";
}
close(DATA);
}
else{
$error_code='データファイルへのアクセスに失敗しました!!';
}
}
####################データ収集####################
sub member_open{
unless(-f $member_file){
srand;
if($code_select==1){
foreach(0..9){
push(@member_codeword,$_);
}
}
elsif($code_select==2){
foreach(a..z){
push(@member_codeword,$_);
}
}
elsif($code_select==3){
foreach(A..Z){
push(@member_codeword,$_);
}
}
else{
foreach(a..z,0..9){
push(@member_codeword,$_);
}
}
for($i=0;$i<@member_codeword;$i++){
my $n=int(rand @member_codeword);
($member_codeword[$i],$member_codeword[$n])=($member_codeword[$n],$member_codeword[$i]);
}
my $member_codeword=join('',@member_codeword);
open(DATA,">$member_file");
print DATA "$member_codeword\n";
close(DATA);
$new_number=$first_number;
}
elsif(open(DATA,"$member_file")){
my @line = ;
close(DATA);
$new_number=$first_number;
for($i=0;$i<@line;$i++){
chomp($line[$i]);
if($i==0 && $command eq 'member_regist2'){
(@member_codeword) = split(//,$line[$i]);
}
elsif($i>0){
my ($number,$pass,$name,$email,$last_time,$money) = split(/,/,$line[$i]);
$member_names{$pass}=$name;
$member_passs{$pass}=$pass;
$member_mails{$pass}=$email;
$member_times{$pass}=$last_time;
$member_moneys{$pass}=$money;
$new_number=$number if($new_number<=$number);
}
$new_number+=int(rand $rand_number)+1;
}
}
else{
$error_code='アクセスエラーです。お手数ですが、リロードをして下さいませ。';
}
}
##################新規会員データセーブ##################
sub member_save{
my $temp_number=$new_number;
if(@member_codeword>1){
while(1){
$new_password.=$member_codeword[$temp_number%@member_codeword];
$temp_number =int($temp_number/@member_codeword);
last unless($temp_number>0);
}
}
if(open(DATA, ">>$member_file")){
print DATA "$new_number,$new_password,$name,$email,$now_time,$regist_money\n";
close(DATA);
}
else{
$error_code='アクセスエラーです。お手数ですが、リロードをして下さいませ。';
}
}
##################軍資金額リセット##################
sub ranking_reset{
if(open(DATA,"$member_file")){
my @line = ;
close(DATA);
if(open(DATA,">$member_file")){
for($i=0;$i<@line;$i++){
chomp($line[$i]);
if($i>0){
my ($number,$pass,$name,$email,$last_time,$money) = split(/,/,$line[$i]);
$money=0;
$line[$i]="$number,$pass,$name,$email,$last_time,$money";
}
print DATA"$line[$i]\n";
}
close(DATA);
}
}
}
####################払戻金追加####################
sub money_save{
if(open(DATA,"$member_file")){
my @line = ;
close(DATA);
if(open(DATA,">$member_file")){
for($i=0;$i<@line;$i++){
chomp($line[$i]);
if($i>0){
my ($number,$pass,$name,$email,$last_time,$money) = split(/,/,$line[$i]);
$money+=$soneki_moneys{$pass};
$line[$i]="$number,$pass,$name,$email,$last_time,$money";
}
print DATA"$line[$i]\n";
}
}
}
else{
$error_code='アクセスエラーです。お手数ですが、リロードをして下さいませ。';
}
}
####################会員データ修正####################
sub member_repair{
if(open(DATA,"$member_file")){
my @line = ;
close(DATA);
if(open(DATA, ">$member_file")){
for($i=0;$i<@line;$i++){
my ($number,$temp_pass,$temp_name,$temp_email,$last_time,$temp_money) = split(/,/,$line[$i]);
if($temp_pass eq $pass){
$line[$i]="$number,$repair_pass,$name,$email,$last_time,$my_money\n";
}
print DATA "$line[$i]";
}
close(DATA);
}
}
}
####################会員データ消去####################
sub member_delete{
my (@target)=@_;
if(open(DATA,"$member_file")){
my @line = ;
close(DATA);
if(open(DATA, ">$member_file")){
for($i=0;$i<@line;$i++){
my $delete_check=0;
foreach(@target){
if($line[$i]=~/\Q,$_,$member_names{$_},\E/){
delete $member_times{$_};
$delete_check=1;
last;
}
}
if($delete_check==0){
print DATA "$line[$i]";
}
}
close(DATA);
}
}
}
###################バックアップSAVE###################
sub backup_save{
my($file)=@_;
if(open(DATA,"$file")){
my @line = ;
close(DATA);
my $backupfile=$file;
$backupfile=~s/.cgi/back.cgi/;
if(@line>0 && open(DATA,">$backupfile")){
for($i=0;$i<@line;$i++){
print DATA"$line[$i]";
}
}
}
else{
$error_code='アクセスエラーです。';
}
}
###################バックアップLOAD###################
sub backup_load{
my($file)=@_;
my $backupfile=$file;
$backupfile=~s/.cgi/back.cgi/;
if(open(DATA,"$backupfile")){
my @line = ;
close(DATA);
if(@line>0 && open(DATA,">$file")){
for($i=0;$i<@line;$i++){
print DATA"$line[$i]";
}
}
}
else{
$error_code='アクセスエラーです。';
}
}
####################ヘッダー部分####################
sub html_header{
my ($title,$name,$pass) = @_;
my $header='';
$header.="HTTP/1.0 200 OK\n" if($ENV{'PERLXS'} eq 'PerlIS');
$header.="Content-type: text/html; charset=Shift_JIS\n";
$header.= &set_cookie($name,$pass) if($name ne '' && $pass ne '');
$header.="\n";
$header.=''."\n";
$header.=''."\n";
$header.=''."\n";
$header.= &html_style();
$header.="${title} "."\n";
$header.=''."\n";
$header.='
'."\n";
$header.=''."\n";
return $header;
}
####################フッター部分####################
sub html_footer{
my $menustr = '';
$menustr.=<
$hooter
[PR]動画
END_OF_TEXT
return $menustr;
}
####################クッキー取得####################
sub get_cookie{
my ($name,$pass);
if(defined $ENV{'HTTP_COOKIE'}){
my $cook=$ENV{'HTTP_COOKIE'};
(@cook) = split(/;/,$cook);
foreach(@cook){
if($_=~/$C_NAME/){
my ($cookie_name,$value) = split(/=/,$_);
($name,$pass) = split(/,/,$value);
return ($name,$pass);
}
}
}
}
####################クッキーセット####################
sub set_cookie{
my ($name,$pass) = @_;
return "Set-Cookie: ${C_NAME}=name:${name},pass:${pass}; ${expires}\n\n";
}
###############クッキーの有効期限を取得###############
sub expires {
my($day) = @_;
my(@date);
my(@week) = ('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
my(@month) = ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
@date = gmtime($now_time+ $day * 60 * 60 * 24);
$date[5] = $date[5] + 1900;
foreach (0..3) {
$date[$_] = sprintf("%.2d",$date[$_]);
}
return "$week[$date[6]], $date[3]-$month[$date[4]]-$date[5] $date[2]:$date[1]:$date[0] GMT";
}
####################排他制御開始####################
# $id = LockOn(filename);
sub LockOn{
my ($filename)=@_;
# 古いディレクトリを削除
rmdir($filename) if(-d $filename && ($now_time-(stat($filename))[9])>$expire);
# 排他制御用ディレクトリ生成
my $retry;
for($retry=$num_retry; $retry>0 && mkdir($filename,0755)!=1; $retry--){
sleep($retry_time);
}
return $filename if($retry>0); # 成功
return undef; # 失敗
}
####################排他制御終了####################
# LockOff($id);
sub LockOff{
my ($filename)=@_;
rmdir ($filename) if(defined $filename);
}
####################排他制御失敗####################
sub lock_error{
my $body = <しばらくお待ち下さい
只今、込み合ってるようです。
しばらくしてから、リロード(再読み込み)してみて下さい
リロードしても繋がらない場合は・・・
3分間ほど待ってから、もう一度トライしてみて下さい。
注:新規設置の管理人様へ・・・
新規設置時に、このコメントばかり表示される時は・・・
DATAのパーミッションが777(707の場合もあり)以外になっていないか・・・
DATAが、Dataやdataになっていないかを確認してみて下さいませ≦(._.)≧
(詳しくは、HPサービスのFAQを参照して下さい)
END_OF_BODY
return $body;
}
####################登録メール送信####################
sub mailsend{
my $mail_comment=<$b } @true_num;
}
elsif($hat==2){
@true_num=@hat_num;
for($i=0;$i<8;$i++){
push(@true_num,$hat_num[-1-$i]);
}
for($i=0;$i<$hat2;$i++){
push(@true_num,$hat_num[-1-$i]);
}
@true_num=sort{ $a<=>$b } @true_num;
}
return(@true_num);
}
####################スタイルシートhtml####################
sub style_list{
my $style;
if(open(DATA,"$style_file")){
my @line = ;
close(DATA);
for($i=0;$i<@line;$i++){
$style.=$line[$i];
}
}
print <スタイルシートを利用する
END_OF_TEXT
}
####################スタイルシート部分####################
sub html_style{
my $style;
unless(-f $style_file){
open(DATA,">$style_file");
$style.="\n";
print DATA "$style";
close(DATA);
}
elsif(open(DATA,"$style_file")){
my @line = ;
close(DATA);
for($i=0;$i<@line;$i++){
$style.=$line[$i];
}
}
return($style);
}
####################スタイルシートをセーブする####################
sub style_save{
my ($style)=@_;
$style=~ s/\r\n/ /g;
$style=~ s/\r/ /g;
$style=~ s/\n/ /g;
$style=~ s/\t/ /g;
$style=~s/ /\n/g;#改行コードを変換
if(open(DATA,">$style_file")){
print DATA "$style";
close(DATA);
}
}