1. #!/usr/local/bin/perl

  2. # ######################
  3. # PET ROOM
  4. $ver = 2.5;
  5. # Copyright (C) 2000-2004 Missing Link.
  6. # All rights reserved.
  7. # 作成者 Sho
  8. # E-mail: sho@area-s.com
  9. # Home Page: http://www.area-s.com/
  10. # このスクリプトはフリーウェアです。
  11. # 本スクリプトを利用する方は以下のURLに記載された
  12. # 利用既定に同意したものとみなします。
  13. # http://www.area-s.com/main/rule.html
  14. # 著作権はMISSING LINKが保有します。
  15. # 質問等はサポート掲示板まで。
  16. # http://www.area-s.com/main/support.html
  17. # ######################

  18. # #################設定はここから############

  19. # ↓Pet Roomで使用する全ての画像を格納するディレクトリです。
  20. # 絶対パス(http://から始まるパス)でも相対パスでも構いません。
  21. # 初期値はpet.cgiと同じ場所に配置するようになっています。
  22. # プロバイダ(サーバ)によってはcgi-binの下に画像ディレクトリを
  23. # 置くことを禁止している場合があります。その場合は、
  24. # cgi-binより上層に画像ディレクトリを配置しパスを変更してください。
  25. # swfファイルと角画像もこのフォルダの中に格納します。
  26. $img = './img/';

  27. $lockkey = 1; # ファイルのロック(0=no 1=mkdir 2=symlink) Amend Ver 2.2
  28. # symlinkが上手くいかない場合はrmdirを使用して下さい。

  29. $bgcolor = '#FFFFFF'; # 背景色
  30. $txcolor = '#000000'; # テキストの色
  31. $nlcolor = '#000000'; # リンク色(未)
  32. $alcolor = '#999999'; # リンク色(現)
  33. $vlcolor = '#000000'; # リンク色(既)

  34. $tbsize = 240; # テーブルのサイズ
  35. $tbcolor = '#FF9999'; # テーブルの色
  36. $tbbcground = ''; # テーブルの背景画像(フルパス)

  37. $barcolor = '#FF3333'; # バーの色
  38. $font1 = '#000000'; # バー内に表示させる文字の色
  39. $font2 = '#880000'; # データタイトルやボタンに使用する色

  40. $fontsize = '8pt'; # フォントサイズ(通常)
  41. $but_sze = 10; # フォントサイズ(ボタン)
  42. $txb_sze = 10; # フォントサイズ(テキスト入力欄)

  43. $txc_bdr = '#FF9999'; # テキスト入力欄とボタンのボーダーの色 (IE)
  44. $txc_bcg = '#FFCCCC'; # テキスト入力欄の背景の色 (IE)
  45. $btc_bcg = '#FFCCCC'; # ボタンの背景の色 (IE)
  46. $txs_bdr = '1pt'; # テキスト入力欄のボーダーサイズ (IE)

  47. $printtitle = 1; # タイトルを画面内に表示するかどうか(yes=1,no=0)
  48. # タイトルの副題:ペット名の後に続く(〜の部屋、〜わんぱく日記etc)
  49. $titlesub = 'の生活';
  50. # ペットが住んでいないときのタイトル名
  51. $nopet = '空部屋';
  52. # タイトルのフォントサイズ
  53. $t_size = 3;

  54. # フォーム内のスペース
  55. $f_space = 3;

  56. # 画面下部に戻るボタンを表示するか(yes=1,no=0)
  57. $printback = 1;
  58. # 戻り先URL http:// から記入(絶対パス)
  59. $backurl = 'http://xxx.co.jp/~user/xxx.html';
  60. # 戻り先URLのラベル
  61. $backword = 'ホーム';
  62. # 戻り先のターゲット _self _blank _top など
  63. $backtarget = '_self';

  64. # 何日訪れないと飼い主ランキングから削除されるか。
  65. $goodbye = '5';
  66. # ペットが死んだとき前回と同じ名前を付けられるようにするか。(yes=1,no=0)
  67. $samename = 0;

  68. # ------------------------- #
  69. # ペットの設定
  70. # ------------------------- #

  71. # ペットの鳴き声を鳴らす場合は1、鳴らさない場合は0
  72. # ショックウェーブがうまく動作しない方は0にしてください。
  73. $voice = 1;

  74. # 何時間おきに遊べるか(コマンドを受け付けるか)。
  75. # 一時間より短くする場合、$playtime を0にしてください。
  76. $playtime = 1;
  77. # 一時間より短くする場合、$playminute を 分単位で入力
  78. $playminute = 0; # 例:0分

  79. $deadline = 3; # 何日以上餌を食べないと死ぬか。
  80. $comeback = 1; # ペットを一回外に出すと何時間したら戻ってくるか。
  81. $novisit = 1; # 来客が一人も来ない日が何日続くとペットが不機嫌になるか。
  82. $loved = 7; # ラブポイントを何点以上取るとペットになつかれているか。
  83. $disliked = 0; # ラブポイントが何点以下だとペットに嫌われているか。
  84. $special1 = 7; # ラブポイントが何点以上だとスペシャル画像1を表示するか。
  85. $specialtime1a = 2; # 食後何時間でその画像を表示させるか。
  86. $specialtime1b = 8; # 二つまで設定可能。一つでいい場合は上と同じにする。
  87. $special2 = 9; # ラブポイントが何点以上だとスペシャル画像2を表示するか。
  88. $specialtime2a = 20; # 食後何時間でその画像を表示させるか。
  89. $specialtime2b = 21; # 二つまで設定可能。一つでいい場合は上と同じにする。

  90. # ↓ペットは時に予想もつかない行動を取ります。
  91. $rnd_border = 5; # 何%かの確率で違う(マイナス)アクションを起こさせます。
  92. $rnd_img = 'keikai.gif'; # その時の画像
  93. $rnd_msg = '今日はいつもと違って様子が変です'; # その時のメッセージ

  94. # ↓一日の予定を組みます(餌を与えられてから24時間のスケジュール)
  95. # 上から順に0〜1時間、1〜2時間となっています。
  96. # その間に表示させたい画像を以下に指定します。
  97. # ただし、画像は全て同じ大きさのものを使用してください。
  98. # 変更する場合は→'画像ファイル名',でワンセットですので、
  99. # 点を間違って削除したりしないよう注意してください。
  100. # かならず24時間分指定してください。
  101. # 24時間以上経つとペットはお腹を空かせ、後はずっと鳴いた画像が表示されます。
  102. @scheduleimg = (
  103. 'name.gif',
  104. 'tume.gif',
  105. 'neteru.gif',
  106. 'neteru.gif',
  107. 'boo.gif',
  108. 'nobi.gif',
  109. 'soto.gif',
  110. 'naku.gif',
  111. 'naku.gif',
  112. 'unko.gif',
  113. 'name.gif',
  114. 'tume.gif',
  115. 'maru.gif',
  116. 'neteru.gif',
  117. 'boo.gif',
  118. 'tume.gif',
  119. 'soto.gif',
  120. 'naku.gif',
  121. 'naku.gif',
  122. 'maru.gif',
  123. 'maru.gif',
  124. 'unko.gif',
  125. 'boo.gif',
  126. 'maru.gif',
  127. );

  128. # ↓上の画像のリストと対になっています。
  129. # 画像が表示される時の説明文です。
  130. # かならず24個用意してください。
  131. @schedulemsg = (
  132. '自分の体をなめています',
  133. '爪をといでいます',
  134. '寝ているようです',
  135. 'いびきをかいて寝ています',
  136. 'ぼーっとしています',
  137. 'のびをしています',
  138. '外の様子が気になるようです',
  139. 'うるさく鳴いています',
  140. 'ヒステリックに鳴いています',
  141. 'ペット用トイレでうんこしています',
  142. '毛繕いしているようです',
  143. '壁一面、バリバリ掻いてます',
  144. 'タンスの上で丸まっています',
  145. '夢をみているようです',
  146. 'ヒマそうです',
  147. '暴れています',
  148. '窓の外を眺めています',
  149. 'ニャーニャー鳴いています',
  150. 'ひたすら鳴いています',
  151. '部屋の隅っこで丸まっています。',
  152. '布団の上で丸まっています',
  153. '部屋の中にウンコをしました・・・',
  154. '何もやることがなさそうです',
  155. 'テーブルの上で丸まっています',
  156. );

  157. # ↓更に上と対になっています。
  158. # その時間帯にペットが一番やってほしいこと(もしくは効果があること)。
  159. # play = 遊ぶ,pat = なでる,feed = 餌をやる,hit = しかる,out = 外に出す。
  160. # ない場合は点の間を空白。
  161. # 複数ある場合は'play_pat',のように間を_で繋ぐ。
  162. @scheduledsr = (
  163. 'pat',
  164. 'play',
  165. 'pat',
  166. 'pat',
  167. 'pat',
  168. 'pat',
  169. 'out',
  170. 'out',
  171. 'out',
  172. '',
  173. 'pat',
  174. 'hit',
  175. '',
  176. 'pat',
  177. 'play',
  178. 'hit',
  179. 'out',
  180. 'out',
  181. 'out',
  182. '',
  183. 'pat',
  184. 'hit',
  185. 'play',
  186. '',
  187. );

  188. # 更に続きます。
  189. # その時間帯に来客者がやっては行けないことです。
  190. # ただし、やってほしい事とやってはいけないことを重複させないようにしてください。
  191. @schedulednt = (
  192. 'hit_out_feed',
  193. 'hit_pat_out_feed',
  194. 'hit_out_feed',
  195. 'hit_out_feed',
  196. 'hit_out',
  197. 'hit',
  198. 'hit',
  199. 'hit',
  200. 'hit',
  201. 'hit_pat_play_out',
  202. 'hit_out',
  203. 'pat_play',
  204. 'hit',
  205. 'hit_out_feed',
  206. 'hit',
  207. 'pat_play',
  208. 'hit',
  209. '',
  210. '',
  211. 'hit_out_pat',
  212. 'hit_out',
  213. 'pat_play',
  214. 'hit',
  215. 'hit',
  216. );

  217. # もうすぐ終わりです。
  218. # アクションを起こした後のそれぞれの反応を設定します。

  219. # ↓良いときの画像。左辺は変更しないでください。
  220. %good_img = (
  221. 'feed' , 'esa.gif',
  222. 'pat' , 'jare.gif',
  223. 'play' , 'fun.gif',
  224. 'hit' , 'keikai.gif',
  225. 'out' , 'dash.gif',
  226. );
  227. # ↓悪い時の画像。
  228. %bad_img = (
  229. 'feed' , 'tukare.gif',
  230. 'pat' , 'bite.gif',
  231. 'play' , 'tukare.gif',
  232. 'hit' , 'dash.gif',
  233. 'out' , 'soppo.gif',
  234. );
  235. # ↓どっちでもないときの画像。
  236. %else_img = (
  237. 'feed' , 'soppo.gif',
  238. 'pat' , 'soppo.gif',
  239. 'play' , 'boo.gif',
  240. 'hit' , 'bite.gif',
  241. 'out' , 'soppo.gif',
  242. );
  243. # ↓良いときのメッセージ。
  244. %good_msg = (
  245. 'feed' , 'おいしそうに食べてます♪',
  246. 'pat' , 'お腹をみせて喜んでいます♪',
  247. 'play' , 'とても楽しそうに遊んでいます♪',
  248. 'hit' , 'ちょっといじけてますが、大丈夫でしょう',
  249. 'out' , '喜んで外に飛び出していきました♪',
  250. );
  251. # ↓悪いときのメッセージ。
  252. %bad_msg = (
  253. 'feed' , 'いくらなんでも与え過ぎですよ',
  254. 'pat' , '触れられるのを嫌がっています',
  255. 'play' , 'とてもそんな気分じゃないようです',
  256. 'hit' , '脱兎のごとく逃げていきました',
  257. 'out' , '無理やり外に放り出しました',
  258. );
  259. # ↓どっちでもないときのメッセージ。
  260. %else_msg = (
  261. 'feed' , 'あんまり食べたくないみたいです',
  262. 'pat' , 'ダルそうにあっちに行ってしまいました',
  263. 'play' , '全く興味なさそうです',
  264. 'hit' , 'ムカついて噛み付いてきました',
  265. 'out' , 'しぶしぶ外へ出て行きました',
  266. );


  267. ### その他の画像 ###
  268. $dead_img = 'dead.gif'; # 死んだ画像
  269. $cry_img = 'naku.gif'; # 鳴いてる画像
  270. $tired_img = 'tukare.gif'; # 餓死寸前(死亡一日前)
  271. $gone_img = 'gone.gif'; # 外出中の画像
  272. $angry_img = 'ikaku.gif'; # 威嚇している画像
  273. $caution_img = 'keikai.gif'; # 警戒している画像

  274. ### その他のメッセージ ###
  275. $out_msg = '外出中のようです'; # 外出中
  276. $hungry_msg = 'うるさく鳴いています'; # 空腹時
  277. $tired_msg = 'なんだかぐったりしていますよ'; # 餓死寸前(死亡一日前)
  278. $enemy_msg = 'はあなたを敵とみなしています'; # 敵視
  279. $caution_msg = 'はあなたを警戒しています'; # 警戒時

  280. ### スペシャル画像&メッセージ ###
  281. # スペシャル画像1
  282. $delight_img = 'love.gif'; # (サンプル)来訪者を喜んでいる画像
  283. $delight_msg = 'あなたが来たことをすごく喜んでいます'; # その時のメッセージ
  284. # スペシャル画像2
  285. $friend_img = 'friend.gif'; # (サンプル)友達と遊んでいる画像
  286. $friend_msg = '今日はお友達のピヨちゃんと遊んでいます'; # その時のメッセージ

  287. $imgw = '200'; # ペットの画像の横幅(ピクセル)
  288. $imgh = '150'; # ペットの画像の縦幅(ピクセル)
  289. # サンプル画像を使用する場合
  290. # petimg ⇒ w=250 h=250 petimg2 ⇒w=200 h=150

  291. # 角画像 ファイル名
  292. $ltimg = 'lt.gif';
  293. $rtimg = 'rt.gif';
  294. $lbimg = 'lb.gif';
  295. $rbimg = 'rb.gif';
  296. # 角画像 一辺のピクセルサイズ
  297. $ris = '8';

  298. # 終了時に画像を表示する(yes = 1,no = 0)
  299. $ending = 1;
  300. # 終了画像
  301. $endimg = 'neteru.gif';
  302. # 終了時のメッセージ
  303. $endmsg = 'お疲れ様でした';

  304. # Ver2.2 追加分
  305. $namefixed = ''; # ペットの名前を固定する(yes=名前を入力)
  306. $sexfixed = ''; # ペットの性別を固定する(yes='オス'か'メス'を入力)

  307. # ########################設定はここまで############################
  308. # ここから先を変更する場合はご自分の責任において変更してください。

  309. # このCGIの名前
  310. $cgiurl = './pet.cgi';

  311. # jcodeパールのパス
  312. require 'jcode.pl';

  313. # データファイル名
  314. $userdata = './user.cgi'; # 来客者情報が入ってるデータ
  315. $petdata = './petd.cgi'; # ペットの情報が入ってるデータ
  316. $lockfile = './petlock'; # ロックファイル名
  317. $method = 'POST'; # POSTかGETを選択

  318. # ボディーの設定
  319. $body = "<body bgcolor=$bgcolor text=$txcolor link=$nlcolor vlink=$vlcolor alink=$alcolor>";
  320. # テーブルの設定
  321. $table = "<table width=$tbsize border=0 cellspacing=0 cellpadding=0 align=center background=\"$tbbcground\" bgcolor=$tbcolor>";
  322. # 一日は86400秒
  323. $daysec = 86400;
  324. # 秒を時間に変換
  325. @dayhour = (0, 3600, 7200, 10800, 14400, 18000, 21600, 25200, 28800, 32400, 36000, 39600, 43200, 46800, 50400, 54000, 57600, 61200, 64800, 68400, 72000);
  326. # 空腹変数初期化
  327. $hungry = 0;
  328. # 日本時間にあわせる
  329. $ENV{'TZ'} = "JST-9";

  1. # ------------------------- #
  2. # Main Program
  3. # メイン処理
  4. # ------------------------- #
  5. &decode;
  6. &openinpetdata;
  7. &titlecheck;
  8. if ($FORM{'mode'} eq "end") { &error("$endmsg") }
  9. elsif ($FORM{'mode'} eq "newpet") { &newpet }
  10. elsif ($FORM{'mode'} eq "nopet") { &nopet }
  11. elsif ($FORM{'mode'} eq "owner") { &ownerlist }
  12. elsif ($FORM{'mode'} eq "entername") { &petform }
  13. elsif ($FORM{'mode'} eq "back") { &petform }
  14. elsif (!$FORM{'mode'}) { &entername }
  15. else { &action }
  16. exit;

  1. # ------------------------- #
  2. # Sub Title Check
  3. # タイトルチェック
  4. # ------------------------- #
  5. sub titlecheck {
  6. if ($FORM{'mode'} eq "nopet") { $title = "$nopet" } # Add Ver 2.2
  7. elsif ($FORM{'petname'} ne "") { $title = "$FORM{'petname'}$titlesub" } # Amend Ver 2.2
  8. elsif ($petname ne "") { $title = "$petname$titlesub" }
  9. else { $title = "$nopet" }
  10. }

  1. # ------------------------- #
  2. # Sub Enter Name
  3. # 名前入力画面
  4. # ------------------------- #
  5. sub entername {
  6. $playmsg = "$playtime時間" if $playtime != 0;
  7. $playmsg = "$playminute分" if $playtime == 0;

  8. &get_cookie;
  9. &header;
  10. &bodytop('名前入力');
  11. &tabletop;

  12. print "お名前を入力してください(半角カナ禁止)。<br>\n";
  13. &input('text','name',$c_name,' class=text','<br>');
  14. print "データ保存用にパスワードを入力してください。<br>\n";
  15. &input('password','pass',$c_pass,' class=text','<br><br>');
  16. print "</td>\n";
  17. print "</tr>\n";
  18. print "<tr>\n";
  19. print "<td align=\"right\">\n";
  20. &input('checkbox','cook','on',' checked','入力情報を保存');
  21. &input('submit','','OK!',' class=button','');
  22. &input('hidden','mode','entername','','<br>');
  23. &tablebottom;
  24. print "</td>\n";
  25. print "</tr>\n";

  26. &bar('','ペット育成ゲームの遊び方');

  27. print "<tr>\n";
  28. print "<td>\n";
  29. &tabletop;
  30. print "まずお名前とパスワードを入力してください。<br>\n";
  31. print "OKを押すとペットの部屋に入室できます。<br>\n";
  32. print "部屋にはペットが住みついています。<br>\n";
  33. print "初めての方には警戒しますが、<br>\n";
  34. print "慣れてくるとなつくようになります。<br>\n";
  35. print "餌をあげたり遊んであげたりしてください。<br>\n";
  36. &tablebottom;
  37. print "</td>\n";
  38. print "</tr>\n";

  39. &bar('','注意');

  40. print "<tr>\n";
  41. print "<td>\n";
  42. &tabletop;
  43. print "ペットは$deadline日以上餌を食べないと死にます。<br>\n";
  44. print "一回の来室後、$playmsgは見るだけになります。<br>\n";
  45. print "$goodbye日間訪問がない場合、データから削除されます。\n";

  46. &tablebottom;
  47. &bodybottom;
  48. &footer;
  49. exit;
  50. }

  1. # ------------------------- #
  2. # Sub Check Name
  3. # ユーザー情報をチェック
  4. # ------------------------- #
  5. sub checkname {
  6. local($flag) = 0;

  7. # 未入力をチェック
  8. if (!$FORM{'name'}) { &error("名前がありません") }
  9. if (!$FORM{'pass'}) { &error("パスワードがありません") }

  10. &openinuserdata('checkname');

  11. # 新規ユーザーを登録
  12. if ($flag == 0) {
  13. $gdate = time - $dayhour[$playtime + 1];
  14. @new = @lines;
  15. push(@new,"$FORM{'name'}<>$FORM{'pass'}<>$gdate<>0<>\n");
  16. &openoutuserdata;
  17. $love = 0; # Add Ver 2.2
  18. }
  19. # 既存ユーザーの場合入室チェック
  20. else {
  21. $enter = 1 if time - $gdate < $dayhour[$playtime] && $playtime != 0;
  22. $enter = 1 if time - $gdate < $playminute * 60 && $playtime == 0;
  23. }

  24. # クッキーを保存
  25. if ($FORM{'cook'} eq "on") { &set_cookie }
  26. }

  1. # ------------------------- #
  2. # Sub Condition
  3. # ペットのコンディション
  4. # ------------------------- #
  5. sub condition {
  6. print "</td>\n";
  7. print "</tr>\n";
  8. # 一定期間餌をあげないと死んでしまう。
  9. if (time >= $lastfeed + $daysec * $deadline) {
  10. $noaction = 1;
  11. $deadover = &checkday($lastfeed);

  12. print "<tr>\n";
  13. print "<td>\n";
  14. &tabletop;
  15. &petnow($dead_img,"$petnameは死にました。<br>死後$deadover日経っています。");

  16. print "<tr>";
  17. print "<td align=\"right\">\n";
  18. &input('hidden','mode','nopet','','');
  19. &input('hidden','name',$FORM{'name'},'','');
  20. &input('hidden','pass',$FORM{'pass'},'','');
  21. print "新しいペットを飼う\n";
  22. &input('submit','','OK',' class=button','');
  23. &tablebottom;
  24. print "</td>\n";
  25. print "</tr>\n";
  26. return;
  27. }

  28. # 外出中の処理
  29. if ($out == 1 && (time - $outdate) < $dayhour[$comeback]) {
  30. &petnow($gone_img,$out_msg);
  31. $noaction = 1;
  32. return;
  33. } else {$out = 0;}

  34. # お腹が空いている時の処理
  35. if ($hungry > 0) {
  36. # お腹が空いて餓死寸前
  37. if ($hungry >= $deadline - 1) { &petnow($tired_img,$tired_msg) }
  38. else { &petnow($cry_img,$hungry_msg);
  39. $swfurl = $img . 'catvoice.swf';
  40. if ($voice == 1) { &flash($swfurl) }
  41. }
  42. $plusfeed = 'feed';
  43. $minusfeed = 'hit_pat_play_out';
  44. return;
  45. }

  46. # 食後の経過時間を$timeafterに代入
  47. $timeafter = int((time - $lastfeed)/3600);

  48. # ラブポイントがある基準以下の場合、威嚇画像を表示
  49. if ($bad - $good - $love > 5) {
  50. &petnow($angry_img,"$petname$enemy_msg");
  51. $swfurl = $img . 'catvoicerage.swf';
  52. if ($voice == 1) { &flash($swfurl) }
  53. return;
  54. }
  55. # スペシャル画像1
  56. if ($love > $special1) {
  57. if ($timeafter == $specialtime1a || $timeafter == $specialtime1b) {
  58. &petnow($delight_img,$delight_msg);
  59. return;
  60. }
  61. }
  62. # スペシャル画像2
  63. if ($love > $special2) {
  64. if ($timeafter == $specialtime2a || $timeafter == $specialtime2b) {
  65. &petnow($friend_img,$friend_msg);
  66. return;
  67. }
  68. }

  69. # ラブポイントが一定以上でノーマル画像
  70. if ( $love >= $bad - $good ) {
  71. &petnow($scheduleimg[$timeafter],$schedulemsg[$timeafter]);
  72. return;
  73. }

  74. # どれにも当てはまらない場合、警戒画像を表示
  75. &petnow($caution_img,"$petname$caution_msg");
  76. }

  1. # ------------------------- #
  2. # Sub Pet Form
  3. # ペットフォーム
  4. # ------------------------- #
  5. sub petform {
  6. &checkname;
  7. if (!$petname) { &nopet;exit }
  8. &header;
  9. &title;
  10. &bodytop("ペットデータ($num代目)");
  11. &petdata;
  12. &condition;
  13. if ($noaction == 0 && $enter != 1) {
  14. print "<tr>\n";
  15. print "<td>\n";
  16. &tabletop;
  17. &input('radio','mode','feed',' checked','餌をあげる<br>');
  18. &input('radio','mode','pat','','<br>');
  19. &input('radio','mode','out','','外に出す');
  20. print "</td>\n";
  21. print "<td>\n";
  22. &input('radio','mode','play','','遊ぶ<br>');
  23. &input('radio','mode','hit','','しかる<br>');
  24. &input('radio','mode','owner','','飼い主ランキング');
  25. print "</td>\n";
  26. print "</tr>\n";

  27. print "<tr>\n";
  28. print "<td colspan=\"2\">\n";
  29. print "<div align=\"right\">\n";
  30. &input('hidden','name',$FORM{'name'},'','');
  31. &input('hidden','pass',$FORM{'pass'},'','');
  32. &input('hidden','good',"$scheduledsr[$timeafter]$plusfeed",'','');
  33. &input('hidden','bad',"$schedulednt[$timeafter]$minusfeed",'','');
  34. &input('submit','','OK!',' class=button','<br>');
  35. print "</div>\n";
  36. &tablebottom;
  37. } else { $actionflag = 1 }
  38. &bodybottom;
  39. &openoutpetdata;
  40. &footer;
  41. }

  1. # ------------------------- #
  2. # Sub Pet Data
  3. # ペットデータ
  4. # ------------------------- #
  5. sub petdata {
  6. # 何日以上か面会がない場合、ペットの機嫌が下がる
  7. if (&checkday($lastvisit) >= $novisit) { $good-- }
  8. # 何日間食べていないか。
  9. $hungry = &checkday($lastfeed);

  10. # ゲストが何日ぶりの来訪かをチェックし、ラブ数を減らす
  11. # $love-- if &checkday($gdate) > 1; # 簡単モード
  12. $love = $love - &checkday($gdate);

  13. $agetotalday = &checkday($birth);
  14. &gettime($lastfeed);

  15. &tabletop;
  16. print "名前:<font color=$font2>$petname</font></td>\n";
  17. print "<td>性別:<font color=$font2>$sex</font></td>\n";
  18. print "</tr>\n";

  19. print "<tr>\n";
  20. print "<td>名付け親:<font color=$font2>$godfather</font></td>\n";
  21. print "<td>年齢:<font color=$font2>生後$agetotalday日</font></td>\n";
  22. print "</tr>\n";

  23. print "<tr>\n";
  24. print "<td colspan=2>最後に餌を食べた日:<font color=$font2>$date</font>\n";
  25. &tablebottom;
  26. }

  1. # ------------------------- #
  2. # Sub No Pet
  3. # 新規ペット登録
  4. # ------------------------- #
  5. sub nopet {
  6. &checkname;
  7. &header;
  8. &title;
  9. &bodytop('新しくペットを飼う');
  10. &tabletop;
  11. print "現在、まだここにペットは住んでいません。<br>\n";
  12. print "あなたが名付け親となって新しいペットを飼いましょう!\n";
  13. &tablebottom;
  14. print "</td>\n";
  15. print "</tr>\n";

  16. &bar('','新しいペットの情報を登録してください');

  17. print "<tr>\n";
  18. print "<td>\n";
  19. &tabletop;
  20. print "名前:";
  21. # Amend Ver 2.2 #
  22. if ($namefixed) { print "$namefixed\n"; &input('hidden','petname',$namefixed,'','') }
  23. else { &input('text','petname','',' maxlength="10" class=text','') }
  24. # End Amend #
  25. print "</td>\n";
  26. print "</tr>\n";

  27. print "<tr>\n";
  28. print "<td>\n";
  29. print "性別:";
  30. # Amend Ver 2.2 #
  31. if ($sexfixed) { print "$sexfixed" }
  32. else {
  33. &input('radio','sex','0',' checked','オス');
  34. &input('radio','sex','1','','メス');
  35. }
  36. # End Amend #
  37. print "</td>\n";
  38. print "</tr>\n";

  39. print "<tr>\n";
  40. print "<td align=\"right\">\n";
  41. &input('hidden','mode','newpet','','');
  42. &input('hidden','name',$FORM{'name'},'','');
  43. &input('hidden','pass',$FORM{'pass'},'','');
  44. print "OKを押すと新しくペットが住みつきます。\n";
  45. &input('submit','','OK',' class=button','');
  46. &tablebottom;

  47. &bodybottom;
  48. &footer;
  49. }

  1. # ------------------------- #
  2. # Sub New Pet
  3. # 新規ペット登場
  4. # ------------------------- #
  5. sub newpet {
  6. $deadname = $petname;
  7. $petname = $FORM{'petname'};
  8. &error("不正があります") if time < $lastfeed + $daysec * $deadline; # Add Ver 2.2
  9. if ($namefixed) { $petname = $namefixed; $deadname = '' } # Add Ver 2.2
  10. if ($petname eq "") { &error("ペットに名前をつけてください") }
  11. if ($petname eq $deadname && $samename == 0) { &error("前と同じ名前はつけられません") }
  12. if ( $FORM{'sex'} == 1 ) { $sex = 'メス' } else { $sex = 'オス' }
  13. $sex = $sexfixed if $sexfixed; # Add Ver 2.2
  14. $godfather = $FORM{'name'};
  15. $birth = time;
  16. $dead = 0;
  17. $lastfeed = time;
  18. $lastplay = time;
  19. $good = 0;
  20. $bad = 0;
  21. $out = 0;
  22. $outdate = 0;
  23. $num++;
  24. &openoutpetdata;
  25. $gdate = time - $dayhour[$playtime + 1];
  26. @new = "$FORM{'name'}<>$FORM{'pass'}<>$gdate<>$loved<>\n";
  27. &openoutuserdata;
  28. &petform;
  29. }

  1. # ------------------------- #
  2. # Sub Action
  3. # アクション
  4. # ------------------------- #
  5. sub action {
  6. $playmsg = "$playtime時間" if $playtime != 0;
  7. $playmsg = "$playminute分" if $playtime == 0;

  8. &checkname;
  9. &error("まだ$playmsg経過していません") if $enter == 1;

  10. &header;
  11. &title;
  12. &bodytop("ペットデータ($num代目)");
  13. &petdata;
  14. srand(time);
  15. $rnd = int(rand(100) + 1); # Amend Ver 2.2
  16. $fa = $FORM{'mode'};

  17. if ($fa eq 'play') { $lastplay = time }
  18. if ($fa eq 'out') { $out = 1; $outdate = time }

  19. if ($rnd <= $rnd_border) {
  20. &petnow($rnd_img,$rnd_msg);
  21. $love--;
  22. }
  23. elsif ($FORM{'good'} =~ /$fa/) {
  24. &petnow($good_img{$fa},$good_msg{$fa});
  25. $love++;$good++;
  26. if ($fa eq "feed") { $lastfeed = time }
  27. }
  28. elsif ($FORM{'bad'} =~ /$fa/) {
  29. &petnow($bad_img{$fa},$bad_msg{$fa});
  30. $love--;$bad++;
  31. }
  32. else {
  33. &petnow($else_img{$fa},$else_msg{$fa});
  34. }

  35. &openoutpetdata;

  36. $goodbye = time - (60 * 60 * 24 * $goodbye);
  37. $newlove = $love;
  38. &openinuserdata('action');
  39. &openoutuserdata;
  40. $actionflag = 1; # 飼い主ランキングのリンクを表示
  41. &bodybottom;
  42. &footer;
  43. }

  1. # ------------------------- #
  2. # Sub Owner List
  3. # 飼い主ランキング
  4. # ------------------------- #
  5. sub ownerlist {
  6. &header;
  7. &title;
  8. $bestlove = $lovenum = $hatenum = $othernum = 0;
  9. &openinuserdata('ownerlist');

  10. &bodytop('飼い主ランキング');
  11. &tabletop;

  12. print "<font color=$font2>$petnameが一番なついている人は</font><br>";
  13. if ($bestlove < $loved) { print "いません<br>\n" }
  14. else { print "$bestownerさんです<br>\n" }
  15. print "<br>\n";

  16. print "<font color=$font2>$petnameがなついている人は</font><br>";
  17. if ($lovenum == 0) { print "<br>" }
  18. else { foreach $owner (@lovelist) { print "$ownerさん<br>\n" } }
  19. print "<br>\n";

  20. print "<font color=$font2></font><br>";
  21. if ($hatenum == 0) { print "いません<br>";}
  22. else { foreach $owner (@hatelist) { print "$ownerさん<br>\n" } }
  23. print "<br>\n";

  24. print "<font color=$font2>それ以外の人</font><br>";
  25. if ($othernum == 0) { print "いません<br>" }
  26. else { foreach $owner (@otherlist) { print "$ownerさん<br>\n" } }

  27. &tablebottom;
  28. &bodybottom;
  29. &footer;
  30. }

  1. # ------------------------- #
  2. # Sub Pet Now
  3. # ペットの現在の状況
  4. # ------------------------- #
  5. sub petnow {
  6. print "<tr>\n";
  7. print "<td align=\"center\">";
  8. print "<img src=\"$img$_[0]\" width=\"$imgw\" height=\"$imgh\" border=\"0\">\n";
  9. print "</td>";
  10. print "</tr>\n";
  11. &bar('',$_[1]);
  12. }

  13. ##### 以下、内部、及びHTML処理 #####

  1. # ------------------------- #
  2. # Sub Header
  3. # ヘッダー
  4. # ------------------------- #
  5. sub header {
  6. print "Content-type: text/html\n\n";
  7. print "<html>\n<head>\n";
  8. print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=Shift_JIS\">\n";
  9. print "<title>$title</title>\n";
  10. &style;
  11. print "</head>\n";
  12. print "$body\n";
  13. $headflag = 1;
  14. }

  1. # ------------------------- #
  2. # Sub Title
  3. # タイトル
  4. # ------------------------- #
  5. sub title {
  6. if ($printtitle == 1) {
  7. print "<div align=\"center\"><b><font size=\"$t_size\">$title</font></b></div>";
  8. }
  9. }

  1. # ------------------------- #
  2. # Sub Footer
  3. # フッター
  4. # ------------------------- #
  5. sub footer {
  6. print "<br>\n";
  7. print "<center><font color=$font2>";
  8. # 著作権表示。絶対に消さないで下さい!
  9. print "PET ROOM Ver $ver <br>\n";
  10. print '■ <a href="http://www.area-s.com/" target="_blank" title="Pet Roomの本家配布元">MISSING LINK</a> ■';
  11. print "</font>\n</center>\n</body>\n</html>\n";
  12. }

  1. # ------------------------- #
  2. # Sub Style
  3. # スタイルシート
  4. # ------------------------- #
  5. sub style {
  6. print "<STYLE TYPE=\"text/css\">\n";
  7. print "<!--\n";
  8. print "A:link {text-decoration:none;color:$nlcolor}\n";
  9. print "A:visited {text-decoration:none;color:$vlcolor}\n";
  10. print "A:hover {text-decoration:none;color:$alcolor}\n";
  11. print "body,tr,td,th { font-size:$fontsize }\n";
  12. print ".button {font-size:$but_sze;border:solid;border-width:$txs_bdr;border-color:$txc_bdr;background-color:$btc_bcg}\n";
  13. print ".text {font-size:$txb_sze;border:solid;border-width:$txs_bdr;border-color:$txc_bdr;background-color:$txc_bcg}\n";
  14. print "-->\n";
  15. print "</STYLE>\n";
  16. }

  1. # ------------------------- #
  2. # Sub Body Top
  3. # ボディ上部
  4. # ------------------------- #
  5. sub bodytop {
  6. print "<div align=\"center\">\n";
  7. print "$table\n";
  8. print "<form method=\"$method\" action=\"$cgiurl\">\n";
  9. print "<tr>\n";
  10. print "<td>\n";
  11. print "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" bgcolor=\"$barcolor\">\n";
  12. print "<tr>\n";
  13. print "<td valign=\"top\"><img src=\"$img$ltimg\" width=\"$ris\" height=\"$ris\"></td>\n";
  14. print "<td><div align=\"center\"><font color=$font1>$_[0]</font></div></td>";
  15. print "<td valign=\"top\"><div align=\"right\"><img src=\"$img$rtimg\" width=\"$ris\" height=\"$ris\"></div></td>\n";
  16. print "</tr>\n";
  17. print "</table>\n";
  18. print "</td>";
  19. print "</tr>\n";
  20. print "<tr>\n";
  21. print "<td>\n";
  22. }

  1. # ------------------------- #
  2. # Sub Body Bottom
  3. # ボディ下部
  4. # ------------------------- #
  5. sub bodybottom {
  6. print "</td>\n";
  7. print "</tr>\n";
  8. print "<tr>\n";
  9. print "<td>\n";
  10. print "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" bgcolor=\"$barcolor\">\n";
  11. print "<tr>\n";
  12. print "<td valign=\"bottom\"><img src=\"$img$lbimg\" width=\"$ris\" height=\"$ris\"></td>\n";
  13. print "<td><div align=\"center\">";
  14. print "<a href=\"$backurl\" target=\"$backtarget\">[$backword]</a>\n" if $printback == 1;
  15. print " <a href=\"$cgiurl?mode=owner&name=$FORM{'name'}&pass=$FORM{'pass'}\">[飼い主ランキング]</a>\n" if $actionflag == 1;
  16. if ($FORM{'mode'} eq "owner") {
  17. print " <a href=\"$cgiurl?mode=back&name=$FORM{'name'}&pass=$FORM{'pass'}\">[戻る]</a>\n";
  18. }
  19. elsif ($FORM{'mode'} ne "end") {
  20. print " <a href=\"$cgiurl?mode=end\">[終了]</a>\n";
  21. }
  22. print "</div></td>";
  23. print "<td valign=\"bottom\"><div align=\"right\"><img src=\"$img$rbimg\" width=\"$ris\" height=\"$ris\"></div></td>\n";
  24. print "</tr>\n";
  25. print "</table>\n";
  26. print "</td>";
  27. print "</tr>\n";
  28. print "</form>\n";
  29. print "</table>\n";
  30. print "</div>\n";
  31. }

  1. # ------------------------- #
  2. # Sub tabletop
  3. # テーブル上部
  4. # ------------------------- #
  5. sub tabletop {
  6. print "<table width=\"100%\" border=\"0\" cellspacing=\"$f_space\" cellpadding=\"0\">\n";
  7. print "<tr>\n";
  8. print "<td>\n";
  9. }

  1. # ------------------------- #
  2. # Sub tablebottom
  3. # テーブル下部
  4. # ------------------------- #
  5. sub tablebottom {
  6. print "</td>";
  7. print "</tr>\n";
  8. print "</table>\n";
  9. }

  1. # ------------------------- #
  2. # Sub Bar
  3. # バー
  4. # ------------------------- #
  5. sub bar {
  6. print "<tr align=\"center\" bgcolor=\"$barcolor\"><td $_[0]><font color=$font1>$_[1]</font></td></tr>\n";
  7. }

  1. # ------------------------- #
  2. # Sub Input
  3. # インプット
  4. # ------------------------- #
  5. sub input {
  6. print "<input type=\"$_[0]\" name=\"$_[1]\" value=\"$_[2]\"$_[3]>$_[4]\n";
  7. }

  1. # ------------------------- #
  2. # Sub Open In Pet Data
  3. # ペットデータの読みこみ
  4. # ------------------------- #
  5. sub openinpetdata {
  6. &lock;
  7. open(IN,"$petdata") || &error("Can't open $petdata");
  8. $line = <IN>;
  9. close(IN);
  10. ($petname, $godfather, $birth, $sex, $dead, $lastfeed, $lastplay, $lastvisit, $good, $bad, $out, $outdate, $num)
  11. = split(/<>/, $line);
  12. &unlock;
  13. }

  1. # ------------------------- #
  2. # Sub Open Out Pet Data
  3. # ペットデータの更新
  4. # ------------------------- #
  5. sub openoutpetdata {
  6. $lastvisit = time;
  7. $line = "$petname<> $godfather<> $birth<> $sex<> $dead<> $lastfeed<> $lastplay<> $lastvisit<> $good<> $bad<> $out<> $outdate<> $num";
  8. &lock;
  9. open(OUT,">$petdata") || &error("Can't write $petdata");
  10. print OUT $line;
  11. close(OUT);
  12. &unlock;
  13. }

  1. # ------------------------- #
  2. # Sub Open In User Data
  3. # ユーザーデータの読みこみ
  4. # ------------------------- #
  5. sub openinuserdata {
  6. &lock;
  7. open(IN,"$userdata") || &error("Can't open $userdata");
  8. @lines = <IN>;
  9. close(IN);
  10. &unlock;
  11. undef @new; # Amend Ver 2.4

  12. foreach $line (@lines) {
  13. ($name,$pass,$gdate,$love) = split(/<>/,$line);
  14. if ($_[0] eq 'checkname') {
  15. if ($FORM{'name'} eq $name) {
  16. $flag = 1; # データの中にユーザーを確認
  17. if ($FORM{'pass'} ne $pass) { &error("パスワードが間違っています") }
  18. last;
  19. }
  20. }
  21. if ($_[0] eq 'action') {
  22. if ($FORM{'name'} eq $name) {
  23. $gdate = time;
  24. push(@new,"$FORM{'name'}<>$FORM{'pass'}<>$gdate<>$newlove<>\n");
  25. } else {
  26. if ($gdate >= $goodbye) { push(@new,$line) }
  27. }
  28. }
  29. if ($_[0] eq 'ownerlist') {
  30. if ($love >= $loved) {
  31. @lovelist[$lovenum] = "$name";
  32. $lovenum++;
  33. if ($bestlove < $love)
  34. { $bestowner = "$name"; $bestlove = $love }
  35. } elsif ($love <= $disliked) {
  36. @hatelist[$hatenum] = "$name";
  37. $hatenum++;
  38. } else {
  39. @otherlist[$othernum] = "$name";
  40. $othernum++;
  41. }
  42. }
  43. }
  44. }

  1. # ------------------------- #
  2. # Sub Open Out User Data
  3. # ユーザーデータの書きこみ
  4. # ------------------------- #
  5. sub openoutuserdata {
  6. &lock;
  7. open(OUT,">$userdata") || &error("Can't write $userdata");
  8. print OUT @new;
  9. close(OUT);
  10. &unlock;
  11. }

  1. # ------------------------- #
  2. # Sub Error
  3. # エラー
  4. # ------------------------- #
  5. sub error {
  6. $_[1] || &unlock; # Amend Ver 2.2
  7. if ($headflag == 0) { &header }
  8. print "<center><hr width='80%'><P>\n";
  9. if ($FORM{'mode'} eq 'end' && $ending == 1) {
  10. print "<center>\n";
  11. print "<img src=\"$img$endimg\"><br><br>\n"; # Amend Ver2.2
  12. print "<a href=$backurl target=\"$backtarget\">$backword</a></center>\n"; # Amend Ver2.2
  13. }
  14. print "<P><font color=$font2><B>$_[0]</B></font>\n";
  15. print "<P><hr width='80%'></center>\n";
  16. &footer;
  17. exit;
  18. }

  1. # ------------------------- #
  2. # Sub Lock
  3. # ロック
  4. # Amend for Ver 2.2
  5. # ------------------------- #
  6. sub lock {
  7. return if !$lockkey;
  8. if ($lockkey == 1) {
  9. local($flag) = 10;
  10. rmdir($lockfile) if (time - (stat($lockfile))[9] > 60);
  11. while (!mkdir($lockfile,606)) {
  12. --$flag or &error('現在、他の人が使用しています');
  13. select(undef,undef,undef,1);
  14. }
  15. }
  16. elsif ($lockkey == 2) {
  17. local($flag) = 5;
  18. unlink($lockfile) if (time - (stat($lockfile))[9] > 60);
  19. while (!symlink(".",$lockfile)) {
  20. --$flag or &error('現在、他の人が使用しています');
  21. sleep(1);
  22. }
  23. }
  24. }

  1. # ------------------------- #
  2. # Sub Unlock
  3. # アンロック
  4. # Amend for Ver 2.2
  5. # ------------------------- #
  6. sub unlock {
  7. if ($lockkey == 1) { rmdir($lockfile) }
  8. elsif ($lockkey == 2) { unlink($lockfile) }
  9. }

  1. # ------------------------- #
  2. # Sub Check Day
  3. # 日付のチェック
  4. # ------------------------- #
  5. sub checkday {
  6. $answer = int((time - $_[0])/$daysec);
  7. }

  1. # ------------------------- #
  2. # Sub Flash
  3. # フラッシュ
  4. # ------------------------- #
  5. sub flash {
  6. print "<tr>\n";
  7. print "<td align=\"center\">\n";
  8. print "<param name=movie value=\"$_[0]\">";
  9. print '<param name=quality value=high>';
  10. print "<embed src=\"$_[0]\" quality=high pluginspage=";
  11. print '"http://www.macromedia.com/jp/shockwave/download/index.cgi';
  12. print '?P1_Prod_Version=ShockwaveFlash" type="application/';
  13. print 'x-shockwave-flash" width="50" height="20">';
  14. print '</embed>';
  15. print "</td>\n";
  16. print "</tr>\n";
  17. }

  1. # ------------------------- #
  2. # Sub Set Cookie
  3. # クッキーの保存
  4. # ------------------------- #

  5. sub set_cookie {
  6. # クッキーは90日間有効
  7. ($secg,$ming,$hourg,$mdayg,$mong,$yearg,$wdayg,$ydayg,$isdstg) = gmtime(time + 90*24*60*60);
  8. $yearg += 1900;
  9. if ($secg < 10) { $secg = "0$secg" }
  10. if ($ming < 10) { $ming = "0$ming" }
  11. if ($hourg < 10) { $hourg = "0$hourg" }
  12. if ($mdayg < 10) { $mdayg = "0$mdayg" }
  13. $month = ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec')[$mong];
  14. $youbi = ('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday')[$wdayg];
  15. $date_gmt = "$youbi, $mdayg\-$month\-$yearg $hourg:$ming:$secg GMT";
  16. $cook = "name\:$FORM{'name'}\,pass\:$FORM{'pass'}";
  17. print "Set-Cookie: PETROOM2=$cook; expires=$date_gmt\n";
  18. }


  1. # ------------------------- #
  2. # Sub Get Cookie
  3. # クッキーの読みこみ
  4. # ------------------------- #
  5. sub get_cookie {
  6. @pairs = split(/\;/,$ENV{'HTTP_COOKIE'});
  7. foreach $pair (@pairs) {
  8. local($name, $value) = split(/\=/, $pair);
  9. $name =~ s/ //g;
  10. $DUMMY{$name} = $value;
  11. }
  12. @pairs = split(/\,/,$DUMMY{'PETROOM2'});
  13. foreach $pair (@pairs) {
  14. local($name, $value) = split(/\:/, $pair);
  15. $COOKIE{$name} = $value;
  16. }
  17. $c_name = $COOKIE{'name'};
  18. $c_pass = $COOKIE{'pass'};
  19. }

  1. # ------------------------- #
  2. # Sub Decode
  3. # デコード
  4. # ------------------------- #
  5. sub decode {
  6. # フォームからのデータを取得
  7. if ($ENV{'REQUEST_METHOD'} eq "POST") {
  8. read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
  9. @pairs = split(/&/, $buffer);
  10. } else { @pairs = split(/&/, $ENV{'QUERY_STRING'}) }

  11. # フォームからのデータを連想配列に格納
  12. foreach $pair (@pairs) {
  13. ($name, $value) = split(/=/, $pair);
  14. $name =~ tr/+/ /;
  15. $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
  16. $value =~ tr/+/ /;
  17. $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

  18. &jcode'convert(*name,'sjis');
  19. &jcode'convert(*value,'sjis');

  20. # 入力データのチェック
  21. # タグが入力されていれば、それを無効にする。<などに置き換え表示してる
  22. $value =~ s/</</g;
  23. $value =~ s/>/>/g;
  24. # 区切り文字の”,”があれば”,”に変換
  25. $value =~ s/\,/,/g;
  26. # 改行コードを<br>に変換(上からWin、Mac、Unix用の処理)
  27. $value =~ s/\r\n/<br>/g;
  28. $value =~ s/\r/<br>/g;
  29. $value =~ s/\n/<br>/g;

  30. # 連想配列に格納
  31. $FORM{$name} = $value;
  32. }
  33. }

  1. # ------------------------- #
  2. # Sub Get Time
  3. # 時間の取得
  4. # ------------------------- #
  5. sub gettime {
  6. ($sec,$min,$hour,$dy,$mon,$year,$wday,$yday,$isdst) = localtime($_[0]);
  7. $year += 1900 ;
  8. $mon = $mon + 1;
  9. @week = ('日','月','火','水','木','金','土');

  10. $date = "$year年$mon月$dy日\($week[$wday]\)";
  11. }