| 1 | <?php |
|---|
| 2 | /* |
|---|
| 3 | * Copyright(c) 2000-2006 LOCKON CO.,LTD. All Rights Reserved. |
|---|
| 4 | * |
|---|
| 5 | * http://www.lockon.co.jp/ |
|---|
| 6 | */ |
|---|
| 7 | require_once("../../require.php"); |
|---|
| 8 | |
|---|
| 9 | class 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 | // ¸½ºß¤Î³¬Áؤò¼èÆÀ |
|---|
| 21 | if($_POST['mode'] != "") { |
|---|
| 22 | $now_dir = $_POST['now_file']; |
|---|
| 23 | } |
|---|
| 24 | |
|---|
| 25 | switch($_POST['mode']) { |
|---|
| 26 | |
|---|
| 27 | case 'view': |
|---|
| 28 | // ¥¨¥é¡¼¥Á¥§¥Ã¥¯ |
|---|
| 29 | if(!is_array(lfErrorCheck())) { |
|---|
| 30 | |
|---|
| 31 | // ÁªÂò¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¤¬¥Ç¥£¥ì¥¯¥È¥ê¤Ê¤é°Üư |
|---|
| 32 | if(is_dir($_POST['select_file'])) { |
|---|
| 33 | $now_dir = $_POST['select_file']; |
|---|
| 34 | } else { |
|---|
| 35 | // javascript¤ÇÊÌÁëɽ¼¨(¥Æ¥ó¥×¥ì¡¼¥È¦¤ËÅϤ¹) |
|---|
| 36 | //$file_url = ereg_replace(USER_PATH, USER_URL, $_POST['select_file']); |
|---|
| 37 | $objPage->tpl_javascript = "win02('./file_view.php?file=". $_POST['select_file'] ."', 'user_data', '600', '400');"; |
|---|
| 38 | } |
|---|
| 39 | } |
|---|
| 40 | break; |
|---|
| 41 | |
|---|
| 42 | case 'download': |
|---|
| 43 | |
|---|
| 44 | // ¥¨¥é¡¼¥Á¥§¥Ã¥¯ |
|---|
| 45 | if(!is_array(lfErrorCheck())) { |
|---|
| 46 | if(is_dir($_POST['select_file'])) { |
|---|
| 47 | // ¥Ç¥£¥ì¥¯¥È¥ê¤Î¾ì¹ç¤Ïjavascript¥¨¥é¡¼ |
|---|
| 48 | $objPage->tpl_javascript = "alert('¢¨¡¡¥Ç¥£¥ì¥¯¥È¥ê¤ò¥À¥¦¥ó¥í¡¼¥É¤¹¤ë¤³¤È¤Ï½ÐÍè¤Þ¤»¤ó¡£');"; |
|---|
| 49 | } else { |
|---|
| 50 | // ¥Õ¥¡¥¤¥ë¤Î¾ì¹ç¤Ï¥À¥¦¥ó¥í¡¼¥É¤µ¤»¤ë |
|---|
| 51 | header('Content-Disposition: attachment; filename="'. basename($_POST['select_file']) .'"'); |
|---|
| 52 | } |
|---|
| 53 | } |
|---|
| 54 | break; |
|---|
| 55 | |
|---|
| 56 | case 'delete': |
|---|
| 57 | break; |
|---|
| 58 | |
|---|
| 59 | default : |
|---|
| 60 | // ½é´üɽ¼¨¤Ï¥ë¡¼¥È¥Ç¥£¥ì¥¯¥È¥ê(user_data/upload/)¤òɽ¼¨ |
|---|
| 61 | $now_dir = $top_dir; |
|---|
| 62 | break; |
|---|
| 63 | } |
|---|
| 64 | // ¸½ºß¤Î¥Ç¥£¥ì¥¯¥È¥êÇÛ²¼¤Î¥Õ¥¡¥¤¥ë°ìÍ÷¤ò¼èÆÀ |
|---|
| 65 | $objPage->arrFileList = lfGetFileList($now_dir); |
|---|
| 66 | $objPage->tpl_now_file = $now_dir; |
|---|
| 67 | |
|---|
| 68 | sfprintr($now_dir); |
|---|
| 69 | |
|---|
| 70 | $objView->assignobj($objPage); |
|---|
| 71 | $objView->display("tree.tpl"); |
|---|
| 72 | |
|---|
| 73 | //----------------------------------------------------------------------------------------------------------------------------------- |
|---|
| 74 | |
|---|
| 75 | /* |
|---|
| 76 | * ´Ø¿ô̾¡§lfGetFileList() |
|---|
| 77 | * ÀâÌÀ¡¡¡§»ØÄê¥Ñ¥¹ÇÛ²¼¤Î¥Ç¥£¥ì¥¯¥È¥ê¼èÆÀ |
|---|
| 78 | * °ú¿ô1 ¡§¥Ä¥ê¡¼¤ò³ÊǼÇÛÎó |
|---|
| 79 | * °ú¿ô2 ¡§¼èÆÀ¤¹¤ë¥Ç¥£¥ì¥¯¥È¥ê¥Ñ¥¹ |
|---|
| 80 | */ |
|---|
| 81 | function lfGetFileList($dir) { |
|---|
| 82 | $arrFileList = array(); |
|---|
| 83 | if (is_dir($dir)) { |
|---|
| 84 | if ($dh = opendir($dir)) { |
|---|
| 85 | $cnt = 0; |
|---|
| 86 | while (($file = readdir($dh)) !== false) { |
|---|
| 87 | // ./ ¤È ../¤ò½ü¤¯¥Õ¥¡¥¤¥ë¤Î¤ß¤ò¼èÆÀ |
|---|
| 88 | if($file != "." && $file != "..") { |
|---|
| 89 | // ¹ÔËö¤Î/¤ò¼è¤ê½ü¤¯ |
|---|
| 90 | $dir = ereg_replace("\/$", "", $dir); |
|---|
| 91 | $path = $dir."/".$file; |
|---|
| 92 | $arrFileList[$cnt]['file_name'] = $file; |
|---|
| 93 | $arrFileList[$cnt]['file_path'] = $path; |
|---|
| 94 | $arrFileList[$cnt]['file_size'] = getDirSize($path); |
|---|
| 95 | $arrFileList[$cnt]['file_time'] = date("Y/m/d", filemtime($path)); |
|---|
| 96 | $cnt++; |
|---|
| 97 | } |
|---|
| 98 | } |
|---|
| 99 | closedir($dh); |
|---|
| 100 | } |
|---|
| 101 | } |
|---|
| 102 | |
|---|
| 103 | return $arrFileList; |
|---|
| 104 | } |
|---|
| 105 | |
|---|
| 106 | /* |
|---|
| 107 | * ´Ø¿ô̾¡§getDirSize() |
|---|
| 108 | * ÀâÌÀ¡¡¡§»ØÄꤷ¤¿¥Ç¥£¥ì¥¯¥È¥ê¤Î¥Ð¥¤¥È¿ô¤ò¼èÆÀ |
|---|
| 109 | * °ú¿ô1 ¡§¥Õ¥¡¥¤¥ë³ÊǼÇÛÎó |
|---|
| 110 | */ |
|---|
| 111 | function getDirSize($dir) { |
|---|
| 112 | if(file_exists($dir)) { |
|---|
| 113 | // ¥Ç¥£¥ì¥¯¥È¥ê¤Î¾ì¹ç²¼ÁØ¥Õ¥¡¥¤¥ë¤ÎÁíÎ̤ò¼èÆÀ |
|---|
| 114 | if (is_dir($dir)) { |
|---|
| 115 | $handle = opendir($dir); |
|---|
| 116 | while ($file = readdir($handle)) { |
|---|
| 117 | $path = $dir."/".$file; |
|---|
| 118 | if ($file != '..' && $file != '.' && !is_dir($path)) { |
|---|
| 119 | $bytes += filesize($path); |
|---|
| 120 | } else if (is_dir($path) && $file != '..' && $file != '.') { |
|---|
| 121 | $bytes += getDirSize($path); |
|---|
| 122 | } |
|---|
| 123 | } |
|---|
| 124 | } else { |
|---|
| 125 | // ¥Õ¥¡¥¤¥ë¤Î¾ì¹ç |
|---|
| 126 | $bytes = filesize($dir); |
|---|
| 127 | } |
|---|
| 128 | } else { |
|---|
| 129 | // ¥Ç¥£¥ì¥¯¥È¥ê¤¬Â¸ºß¤·¤Ê¤¤¾ì¹ç¤Ï0byte¤òÊÖ¤¹ |
|---|
| 130 | $bytes = 0; |
|---|
| 131 | } |
|---|
| 132 | |
|---|
| 133 | if($bytes == "") $bytes = 0; |
|---|
| 134 | |
|---|
| 135 | return $bytes; |
|---|
| 136 | } |
|---|
| 137 | |
|---|
| 138 | /* |
|---|
| 139 | * ´Ø¿ô̾¡§lfErrorCheck() |
|---|
| 140 | * ÀâÌÀ¡¡¡§¥¨¥é¡¼¥Á¥§¥Ã¥¯ |
|---|
| 141 | */ |
|---|
| 142 | function lfErrorCheck() { |
|---|
| 143 | |
|---|
| 144 | if($_POST['select_file'] == '') { |
|---|
| 145 | $arrErr['select_file'] = "¢¨¡¡¥Õ¥¡¥¤¥ë¤¬ÁªÂò¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£"; |
|---|
| 146 | } |
|---|
| 147 | return $arrErr; |
|---|
| 148 | } |
|---|
| 149 | ?> |
|---|