source: branches/dev/html/test/uehara/tree.php @ 17

Revision 17, 3.7 KB checked in by uehara, 16 years ago (diff)
Line 
1<?php
2/*
3 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
4 *
5 * http://www.lockon.co.jp/
6 */
7require_once("../../require.php");
8
9class LC_Page{
10    function LC_Page() {
11    }
12}
13
14$top_dir = USER_PATH;
15
16$objPage = new LC_Page();
17$objView = new SC_UserView("./templates");
18$objQuery = new SC_Query();
19
20// ¸½ºß¤Î³¬Áؤò¼èÆÀ
21if($_POST['mode'] != "") {
22    $now_dir = $_POST['now_file'];
23} else {
24    // ½é´üɽ¼¨¤Ï¥ë¡¼¥È¥Ç¥£¥ì¥¯¥È¥ê(user_data/upload/)¤òɽ¼¨
25    $now_dir = $top_dir;
26}
27
28// ¥Õ¥¡¥¤¥ë´ÉÍý¥¯¥é¥¹
29$objUpFile = new SC_UploadFile($now_dir, $now_dir);
30// ¥Õ¥¡¥¤¥ë¾ðÊó¤Î½é´ü²½
31lfInitFile();
32
33switch($_POST['mode']) {
34
35// ¥Õ¥¡¥¤¥ëɽ¼¨
36case 'view':
37    // ¥¨¥é¡¼¥Á¥§¥Ã¥¯
38    $arrErr = lfErrorCheck();
39    if(!is_array($arrErr)) {
40   
41        // ÁªÂò¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¤¬¥Ç¥£¥ì¥¯¥È¥ê¤Ê¤é°ÜÆ°
42        if(is_dir($_POST['select_file'])) {
43            ///$now_dir = $_POST['select_file'];
44            // ¥Ä¥ê¡¼Á«°ÜÍѤÎjavascript¤òËä¤á¹þ¤à
45            $arrErr['view'] = "¢¨ ¥Ç¥£¥ì¥¯¥È¥ê¤òɽ¼¨¤¹¤ë¤³¤È¤Ï½ÐÍè¤Þ¤»¤ó¡£";
46           
47        } else {
48            // javascript¤ÇÊÌÁëɽ¼¨(¥Æ¥ó¥×¥ì¡¼¥È¦¤ËÅϤ¹)
49            $file_url = ereg_replace(USER_PATH, "", $_POST['select_file']);
50            $objPage->tpl_javascript = "win02('./file_view.php?file=". $file_url ."', 'user_data', '600', '400');";
51        }
52    }
53    break;
54// ¥Õ¥¡¥¤¥ë¥À¥¦¥ó¥í¡¼¥É
55case 'download':
56
57    // ¥¨¥é¡¼¥Á¥§¥Ã¥¯
58    $arrErr = lfErrorCheck();
59    if(!is_array($arrErr)) {
60        if(is_dir($_POST['select_file'])) {
61            // ¥Ç¥£¥ì¥¯¥È¥ê¤Î¾ì¹ç¤Ïjavascript¥¨¥é¡¼
62            $arrErr['download'] = "¢¨ ¥Ç¥£¥ì¥¯¥È¥ê¤ò¥À¥¦¥ó¥í¡¼¥É¤¹¤ë¤³¤È¤Ï½ÐÍè¤Þ¤»¤ó¡£";
63        } else {
64            // ¥Õ¥¡¥¤¥ë¥À¥¦¥ó¥í¡¼¥É
65            sfDownloadFile($_POST['select_file']);
66            exit;           
67        }
68    }
69    break;
70// ¥Õ¥¡¥¤¥ëºï½ü
71case 'delete':
72    // ¥¨¥é¡¼¥Á¥§¥Ã¥¯
73    $arrErr = lfErrorCheck();
74    if(!is_array($arrErr)) {
75        sfDeleteDir($_POST['select_file']);
76    }
77    break;
78// ¥Õ¥¡¥¤¥ëºîÀ®
79case 'create':
80    // ¥¨¥é¡¼¥Á¥§¥Ã¥¯
81    $arrErr = lfCreateErrorCheck();
82    if(!is_array($arrErr)) {
83        $create_dir = ereg_replace("/$", "", $now_dir);
84        // ¥Õ¥¡¥¤¥ëºîÀ®
85        if(!sfCreateFile($create_dir."/".$_POST['create_file'], 0755)) {
86            // ºîÀ®¥¨¥é¡¼
87            $arrErr['create'] = "¢¨ ".$_POST['create_file']."¤ÎºîÀ®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£";
88        } else {
89            $objPage->tpl_javascript = "alert('¥Õ¥©¥ë¥À¤òºîÀ®¤·¤Þ¤·¤¿¡£');";
90        }
91    }
92    break;
93// ¥Õ¥¡¥¤¥ë¥¢¥Ã¥×¥í¡¼¥É
94case 'upload':
95    // ²èÁüÊݸ½èÍý
96    $ret = $objUpFile->makeTempFile('upload_file', false);
97    if($ret != "") {
98        $arrErr['upload_file'] = $ret;
99    } else {
100        $objPage->tpl_javascript = "alert('¥Õ¥¡¥¤¥ë¤ò¥¢¥Ã¥×¥í¡¼¥É¤·¤Þ¤·¤¿¡£');";
101    }
102    break;
103// ¥Õ¥©¥ë¥À°ÜÆ°
104case 'move':
105    $now_dir = $_POST['tree_select_file'];
106    break;
107// ½é´üɽ¼¨
108default :
109    break;
110}
111
112
113// ¸½ºß¤Î¥Ç¥£¥ì¥¯¥È¥êÇÛ²¼¤Î¥Õ¥¡¥¤¥ë°ìÍ÷¤ò¼èÆÀ
114$objPage->arrFileList = sfGetFileList($now_dir);
115$objPage->tpl_now_file = $now_dir;
116$objPage->arrErr = $arrErr;
117$objPage->arrParam = $_POST;
118$objPage->arrTree = sfGetFileTree($top_dir, $_POST['tree_status']);
119$objPage->$tpl_onload .= "fnTreeView('tree', arrTree, '$now_dir')";
120
121$objView->assignobj($objPage);
122$objView->display("tree.tpl");
123
124//-----------------------------------------------------------------------------------------------------------------------------------
125
126/*
127 * ´Ø¿ô̾¡§lfErrorCheck()
128 * ÀâÌÀ¡¡¡§¥¨¥é¡¼¥Á¥§¥Ã¥¯
129 */
130function lfErrorCheck() {
131    $objErr = new SC_CheckError($_POST);
132    $objErr->doFunc(array("¥Õ¥¡¥¤¥ë", "select_file"), array("SELECT_CHECK"));
133   
134    return $objErr->arrErr;
135}
136
137/*
138 * ´Ø¿ô̾¡§lfCreateErrorCheck()
139 * ÀâÌÀ¡¡¡§¥Õ¥¡¥¤¥ëºîÀ®½èÍý¥¨¥é¡¼¥Á¥§¥Ã¥¯
140 */
141function lfCreateErrorCheck() {
142    $objErr = new SC_CheckError($_POST);
143    $objErr->doFunc(array("ºîÀ®¥Õ¥¡¥¤¥ë", "create_file"), array("EXIST_CHECK", "FILE_NAME_CHECK_BY_NOUPLOAD"));
144   
145    return $objErr->arrErr;
146}
147
148/*
149 * ´Ø¿ô̾¡§lfInitFile()
150 * ÀâÌÀ¡¡¡§¥Õ¥¡¥¤¥ë¾ðÊó¤Î½é´ü²½
151 */
152function lfInitFile() {
153    global $objUpFile;
154    $objUpFile->addFile("¥¢¥Ã¥×¥í¡¼¥É¥Õ¥¡¥¤¥ë", 'upload_file', array(), FILE_SIZE, true, 0, 0, false);
155}
156?>
Note: See TracBrowser for help on using the repository browser.