OSDN Git Service

trpgchat ver2.5
[trpgtools-onweb/AjaxChat.git] / pastlog_edit_dir.php
1 <?php
2 /*
3  * Ajax Chat for TRPG ver.2.5
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 require_once './trpgchat-ini.php';
11 require_once './lib/trpgchat.php';
12 require_once './lib/pastlog.php';
13
14 // 受信データの成形
15 if (!$request = request()) {
16     error('リクエストを受信できません', true);
17 }
18
19 // パスワードの照合
20 auth();
21
22 // 設定セット
23 set_config(read_config());
24
25 // 書き込みブロック
26 write_block();
27
28 // アクセスブロック
29 access_block();
30
31 check_name($request['dirname']);
32
33 if ($request['type'] != MASTER_PAST_DIR && $request['type'] != PAST_DIR) {
34     error('リクエストが不正です。');
35 }
36
37 // ディレクトリ作成
38 if ($request['mode'] == '新規作成') {
39     // ディレクトリ名チェック
40     check_name($request['dirname']);
41
42     if ($msg = mk_pastlog_dir($request['dirname'], $request['type'], '0707')) error($msg, true);
43
44     display_finish(CHAT_TITLE.' 過去ログディレクトリ新規作成', $request['dirname']."を作成しました");
45
46     exit;
47
48 // ディレクトリ編集
49 } elseif ($request['mode'] == '変更') {
50
51     // ディレクトリ名チェック
52     check_name($request['dirname_new']);
53
54     // 変更
55     if (file_exists($request['type'].$request['dirname_new'])) {
56         error('同じ名前のディレクトリが存在します', true);
57     }
58
59     if (!rename($request['type'].$request['dirname'], $request['type'].$request['dirname_new'])) {
60         error('ディレクトリ名の変更に失敗しました', true);
61     }
62     display_finish(CHAT_TITLE.' 過去ログディレクトリ名変更', $request['dirname']."を".$request['dirname_new']."に変更しました");
63     exit;
64
65 // ディレクトリ削除
66 } elseif ($request['mode'] == '削除') {
67
68     if (!file_exists($request['type'].$request['dirname'])) {
69         error('指定のディレクトリが存在しません', true);
70     }
71
72     $list = get_dir_contents_list($request['type'].$request['dirname']."/", 'ASC');
73     if (count($list['files']) > 0) {
74         error('削除したいディレクトリの中のファイルを、全て移動または削除してください', true);
75     }
76
77     // 削除
78     @unlink($request['type'].$request['dirname'].'/index.html');
79     if(!rmdir($request['type'].$request['dirname'])) {
80         error('ディレクトリ削除に失敗しました', true);
81     }
82
83     // 完了表示
84     display_finish(CHAT_TITLE.' 過去ログディレクトリ削除完了', $request['dirname']."を削除しました");
85
86 } else {
87     error('アクションが不正です');
88 }
89
90 ?>