OSDN Git Service

PHP Notice対応
[trpgtools-onweb/AjaxChat.git] / cookie_save.php
1 <?php
2 /*
3  Ajax Chat for TRPG ver.2.6.2
4  (c)2007-2009 Cake All Rights Reserved.
5  Mail : cake_67@users.sourceforge.jp
6  Home : http://trpgtools-onweb.sourceforge.jp/
7  */
8
9 /* クッキーファイル保存 */
10
11 // SSL&IE対策
12 session_cache_limiter('public');
13
14 // デバッグ用設定
15 ini_set('log_errors', false);
16 ini_set('error_log', "./php_error.log");
17
18 // 設定ファイルの読み込み
19 require_once './trpgchat-ini.php';
20 require_once './lib/trpgchat.php';
21
22 // 設定セット
23 set_config(read_config());
24
25 // クッキー無効
26 if (!COOKIE || !intval(COOKEI_EXPIRE)) {
27     error("クッキー無効のため、保存できません");
28 }
29
30 // ユーザの情報
31 if (REC_UA) {
32     $host = gethostbyaddr($_SERVER['REMOTE_ADDR']);
33     $ua = getenv("HTTP_USER_AGENT");
34 }
35
36 // 書き込みブロック
37 write_block();
38
39 // アクセスブロック
40 access_block();
41
42 // リクエスト受信
43 if (!$request = $_GET) {
44     error('データを受信できません');
45 }
46
47 // クッキー情報がない
48 if (!$request['c']) {
49     error("データがありません");
50 }
51
52 // このチャットのクッキー情報か
53 if(strpos($request['c'], 'name_off=', 0) === false) {
54     error("このデータは保存できません");
55 }
56
57 // ファイル名処理
58 if ($request['f']) {
59     $filename = $request['f'];
60 } else {
61     $filename = 'AjaxChatForTRPG';
62 }
63
64  // IEの場合
65 if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) {
66     // ファイル名を SJIS に変換
67     $filename = mb_convert_encoding($filename, 'SJIS', 'UTF-8');
68 }
69 $filename = str_replace(array("\r", "\n"), '', $filename);
70 $filename .= '.txt';
71
72 // 出力
73 header("Content-type: text/plain");
74 header("Content-Disposition: attachment; filename=$filename");
75 header("Content-length: ".strlen($request['c']));
76 print $request['c'];
77
78 exit;
79
80 ?>