Changeset 8764 for temp/trunk
- Timestamp:
- 2006/11/21 17:20:25 (20 years ago)
- Location:
- temp/trunk
- Files:
-
- 2 edited
-
data/include/file_manager.inc (modified) (previous)
-
html/test/uehara/test.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
temp/trunk/html/test/uehara/test.php
r8763 r8764 1 1 <?php 2 3 $default_dir = "/home/web/test.ec-cube.net/html/user_data/"; 4 $arrCnt = split('/', $default_dir); 5 $default_rank = count($arrCnt); 2 6 3 7 $arrTree = array(); 4 8 $cnt = 0; 5 sfGetFileTree("/home/web/test.ec-cube.net/html/user_data/"); 9 10 sfGetFileTree($default_dir); 6 11 print_r($arrTree); 7 /* 12 13 /* 14 * ´Ø¿ô̾¡§sfGetFileTree() 15 * ÀâÌÀ¡¡¡§¥Ä¥ê¡¼À¸À®ÍÑÇÛÎó¼èÆÀ(javascript¤ËÅϤ¹ÍÑ) 16 * °ú¿ô1 ¡§¥Ç¥£¥ì¥¯¥È¥ê 17 */ 8 18 function sfGetFileTree($dir) { 9 19 global $arrTree; 20 global $cnt; 21 global $default_rank; 10 22 11 23 if(file_exists($dir)) { … … 13 25 while (false !== ($item = readdir($handle))) { 14 26 if ($item != "." && $item != "..") { 15 if (is_dir("$dir/$item")) {16 $arrResult[$cnt]['file_name'] = "$dir/$item";17 $cnt++;18 sfGetFileTree("$dir/$item");19 }20 }21 $cnt++;22 }23 }24 closedir($handle);25 //$arrResult[$cnt]['file_name'] = "$dir/$item";26 }27 28 return $arrResult;29 }30 */31 32 function sfGetFileTree($dir) {33 global $arrTree;34 if(file_exists($dir)) {35 if ($handle = opendir("$dir")) {36 $cnt = 0;37 while (false !== ($item = readdir($handle))) {38 if ($item != "." && $item != "..") {39 27 // ʸËö¤Î/¤ò¼è¤ê½ü¤¯ 40 28 $dir = ereg_replace("/$", "", $dir); 29 $path = $dir/$item; 41 30 // ¥Ç¥£¥ì¥¯¥È¥ê¤Î¤ß¼èÆÀ 42 if (is_dir("$dir/$item")) { 43 $arrTree[]['file_name'] = "$dir/$item"; 31 if (is_dir($path)) { 32 $path; 33 if(sfDirChildExists($path)) { 34 $file_type = "_parent"; 35 } else { 36 $file_type = "_child"; 37 } 38 39 // ³¬Áؤò³ä¤ê½Ð¤¹ 40 $arrCnt = split('/', $path); 41 $rank = count($arrCnt); 42 $rank = $rank - $default_rank; 43 44 // javascript¤Î¥Ä¥ê¡¼À¸À®ÍѤÎÇÛÎó¤òºîÀ® 45 $arrTree[] = array($cnt, $file_type, $path, $rank); 44 46 // ²¼Áإǥ£¥ì¥¯¥È¥ê¼èÆÀ¤Î°Ù¡¢ºÆµ¢Åª¤Ë¸Æ¤Ó½Ð¤¹ 45 sfGetFileTree( "$dir/$item");47 sfGetFileTree($path); 46 48 } 47 49 } … … 53 55 } 54 56 55 57 /* 58 * ´Ø¿ô̾¡§sfDirChildExists() 59 * ÀâÌÀ¡¡¡§»ØÄꤷ¤¿¥Ç¥£¥ì¥¯¥È¥êÇÛ²¼¤Ë¥Õ¥¡¥¤¥ë¤¬¤¢¤ë¤« 60 * °ú¿ô1 ¡§¥Ç¥£¥ì¥¯¥È¥ê 61 */ 62 function sfDirChildExists($dir) { 63 if(file_exists($dir)) { 64 // ¥Ç¥£¥ì¥¯¥È¥ê¤Î¾ì¹ç²¼ÁØ¥Õ¥¡¥¤¥ë¤ÎÁíÎ̤ò¼èÆÀ 65 if (is_dir($dir)) { 66 $handle = opendir($dir); 67 while ($file = readdir($handle)) { 68 // ¹ÔËö¤Î/¤ò¼è¤ê½ü¤¯ 69 $dir = ereg_replace("/$", "", $dir); 70 $path = $dir."/".$file; 71 if ($file != '..' && $file != '.') { 72 return true; 73 } 74 } 75 } 76 } 77 78 return false; 79 } 56 80 ?>
Note: See TracChangeset
for help on using the changeset viewer.
