3 * Ajax Chat for TRPG ver.2.3
4 * (c)2007-2008 Cake All rights reserved.
5 * Mail : cake_67@users.sourceforge.jp
6 * Home : http://trpgtools-onweb.sourceforge.jp/
10 require_once './trpgchat-ini.php';
11 require_once './lib/trpgchat.php';
12 require_once './lib/admin.php';
13 require_once './lib/config.php';
20 set_config(read_config_one(CONFIG_IMPORTANT));
29 if (!$request = request()) {
30 error('データを受信できません', true);
34 $lines = config_mode($request['mode']);
36 if ($request['mode'] =='重要な') {
37 $target = CONFIG_IMPORTANT;
38 } elseif ($request['mode'] == '全般') {
39 $target = CONFIG_MAIN;
40 } elseif ($request['mode'] == 'TRPG機能関連') {
41 $target = CONFIG_TRPG;
42 } elseif ($request['mode'] == 'タグ') {
44 } elseif ($request['mode'] == '全体の配色') {
45 $target = CONFIG_BASE_COLOR;
46 } elseif ($request['mode'] == 'チャット画面の配色') {
47 $target = CONFIG_MAIN_COLOR;
48 } elseif ($request['mode'] == 'アイコン') {
49 foreach ($request as $k => $v) {
50 if ($k != 'mode') check_name2($v);
52 $target = CONFIG_ICON;
56 foreach ($lines as $k1 => $v1) {
59 $config = explode("<>", $v1);
64 if ($config[3] == 1) {
65 for ($i=0;$i<count($request[$config[2]]);$i++) {
66 if ($request[$config[2]] && trim($request[$config[2]][$i])) {
67 if ($i!=0) $data .= "</>";
68 $data .= htmlspecialchars($request[$config[2]][$i]);
72 } elseif ($config[3] == 2) {
73 foreach ($request['tag'] as $k2 => $v2) {
74 if ($k2 != "b") $data .= "<>";
76 for ($i=1;$i<count($v2)+1;$i++) {
78 $data .= htmlspecialchars($v2[$i]);
83 if (trim($request[$config[2]])) {
84 // テキストエリアの場合タグ可(<>は変換)、改行コードは<br>に変換
85 if ($config[4] == 1) {
86 $data .= str_replace(array("<>","\n","\r","\l"), array("<>","","",""), nl2br($request[$config[2]]));
88 $data .= htmlspecialchars(str_replace("\n", "", $request[$config[2]]));
92 $lines[$k1] = $config[0]."<>".$config[1]."<>".$config[2]."<>".$config[3]."<>".$config[4]."<>".$config[5].$data."\n";
97 error('設定ファイルが読みだせません', true);
102 $lfp = fopen(LOCK,"w");
103 stream_set_write_buffer($lfp, 0);
107 $fp = @fopen($target, "w") or error("設定ファイルを開けません。", true);
109 foreach($lines as $v) {
119 $url = str_replace('write_config.php', 'admin.php', 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']).'?msg='.urlencode($request['mode']."設定を変更しました");
120 header('Location: '. $url);