質問編集履歴

7

追記

2016/01/07 08:44

投稿

orange0190
orange0190

スコア1698

test CHANGED
File without changes
test CHANGED
@@ -112,13 +112,13 @@
112
112
 
113
113
  array (size=2)
114
114
 
115
- 0 =>
115
+ 0 => (ソフトフォルダの情報)
116
116
 
117
117
  array (size=0)
118
118
 
119
119
  empty
120
120
 
121
- 1 =>
121
+ 1 => (テストフォルダの情報)
122
122
 
123
123
  array (size=4)
124
124
 

6

実行結果を追記

2016/01/07 08:43

投稿

orange0190
orange0190

スコア1698

test CHANGED
File without changes
test CHANGED
@@ -89,3 +89,51 @@
89
89
 
90
90
 
91
91
  ```
92
+
93
+
94
+
95
+ ###再追記 具体的な実行例
96
+
97
+ 列挙対象のフォルダ
98
+
99
+ \\hoge\fuga\6
100
+
101
+
102
+
103
+ 対象フォルダ内には「ソフト」「テスト」という2のフォルダが存在している
104
+
105
+
106
+
107
+ 実行結果
108
+
109
+ $sharedFilesの中身
110
+
111
+ ```
112
+
113
+ array (size=2)
114
+
115
+ 0 =>
116
+
117
+ array (size=0)
118
+
119
+ empty
120
+
121
+ 1 =>
122
+
123
+ array (size=4)
124
+
125
+ 'FILE_TYPE' => string 'dir' (length=3)
126
+
127
+ 'FILE_NM' => string 'eスト' (length=7)
128
+
129
+ 'PARENT_DIR' => string '\\hoge\fuga\6' (length=17)
130
+
131
+ 'SUB_FILES' =>
132
+
133
+ array (size=0)
134
+
135
+ empty
136
+
137
+
138
+
139
+ ```

5

コード修正

2016/01/07 07:30

投稿

orange0190
orange0190

スコア1698

test CHANGED
File without changes
test CHANGED
@@ -74,7 +74,7 @@
74
74
 
75
75
  $data['PARENT_DIR'] = mb_convert_encoding($pathInfo['dirname'], 'utf-8', 'sjis-win');
76
76
 
77
- $data['SUB_FILES'] = $this->__getSharedFiles($file);
77
+ $data['SUB_FILES'] = getSharedFiles($file);
78
78
 
79
79
  }
80
80
 

4

コード修正

2016/01/07 07:01

投稿

orange0190
orange0190

スコア1698

test CHANGED
File without changes
test CHANGED
@@ -60,9 +60,9 @@
60
60
 
61
61
  $data['FILE_TYPE'] = 'file';
62
62
 
63
- $data['FILE_NM'] = mb_convert_encoding($pathInfo['basename'], 'utf-8', 'sjis');
63
+ $data['FILE_NM'] = mb_convert_encoding($pathInfo['basename'], 'utf-8', 'sjis-win');
64
64
 
65
- $data['PARENT_DIR'] = mb_convert_encoding($pathInfo['dirname'], 'utf-8', 'sjis');
65
+ $data['PARENT_DIR'] = mb_convert_encoding($pathInfo['dirname'], 'utf-8', 'sjis-win');
66
66
 
67
67
  $data['SUB_FILES'] = '';
68
68
 
@@ -70,9 +70,9 @@
70
70
 
71
71
  $data['FILE_TYPE'] = 'dir';
72
72
 
73
- $data['FILE_NM'] = mb_convert_encoding($pathInfo['basename'], 'utf-8', 'sjis');
73
+ $data['FILE_NM'] = mb_convert_encoding($pathInfo['basename'], 'utf-8', 'sjis-win');
74
74
 
75
- $data['PARENT_DIR'] = mb_convert_encoding($pathInfo['dirname'], 'utf-8', 'sjis');
75
+ $data['PARENT_DIR'] = mb_convert_encoding($pathInfo['dirname'], 'utf-8', 'sjis-win');
76
76
 
77
77
  $data['SUB_FILES'] = $this->__getSharedFiles($file);
78
78
 

3

コード修正

2016/01/07 07:00

投稿

orange0190
orange0190

スコア1698

test CHANGED
File without changes
test CHANGED
@@ -44,7 +44,7 @@
44
44
 
45
45
  setlocale(LC_ALL, 'ja_JP.UTF-8');
46
46
 
47
- $search = str_replace(DS, '/', rtrim($path, DS) . DS . '*');
47
+ $search = str_replace(DS, '/', rtrim($path, DS) . DS . '*'); //DSはDIRECTORY_SEPARATOR
48
48
 
49
49
  $files = glob($search);
50
50
 
@@ -56,29 +56,25 @@
56
56
 
57
57
  $pathInfo = pathinfo($file);
58
58
 
59
- if(is_file($fileSjis)) {
59
+ if(is_file($file)) {
60
60
 
61
61
  $data['FILE_TYPE'] = 'file';
62
62
 
63
63
  $data['FILE_NM'] = mb_convert_encoding($pathInfo['basename'], 'utf-8', 'sjis');
64
64
 
65
- $data['PARENT_DIR'] = mb_convert_encoding($pathInfo['dirname'], 'utf8', 'sjis');
65
+ $data['PARENT_DIR'] = mb_convert_encoding($pathInfo['dirname'], 'utf-8', 'sjis');
66
66
 
67
67
  $data['SUB_FILES'] = '';
68
68
 
69
- } else if(is_dir($fileSjis)) {
69
+ } else if(is_dir($file)) {
70
70
 
71
71
  $data['FILE_TYPE'] = 'dir';
72
72
 
73
73
  $data['FILE_NM'] = mb_convert_encoding($pathInfo['basename'], 'utf-8', 'sjis');
74
74
 
75
- $data['PARENT_DIR'] = mb_convert_encoding($pathInfo['dirname'], 'utf8', 'sjis');
75
+ $data['PARENT_DIR'] = mb_convert_encoding($pathInfo['dirname'], 'utf-8', 'sjis');
76
76
 
77
77
  $data['SUB_FILES'] = $this->__getSharedFiles($file);
78
-
79
- } else {
80
-
81
- var_dump('else');
82
78
 
83
79
  }
84
80
 

2

ソースコード追記

2016/01/07 06:58

投稿

orange0190
orange0190

スコア1698

test CHANGED
File without changes
test CHANGED
@@ -27,3 +27,69 @@
27
27
 
28
28
 
29
29
  以上、よろしくお願いします。
30
+
31
+
32
+
33
+ ###追記 ソースコード
34
+
35
+ ```PHP
36
+
37
+ $path = SHARED_FOLDER . $no; // SHARED_FOLDERは列挙するフォルダのパス,$noはIDのようなもの
38
+
39
+ $sharedFiles = getSharedFiles($path);
40
+
41
+
42
+
43
+ function getSharedFiles($path){
44
+
45
+ setlocale(LC_ALL, 'ja_JP.UTF-8');
46
+
47
+ $search = str_replace(DS, '/', rtrim($path, DS) . DS . '*');
48
+
49
+ $files = glob($search);
50
+
51
+ $info = array ();
52
+
53
+ foreach($files as $file) {
54
+
55
+ $data = array ();
56
+
57
+ $pathInfo = pathinfo($file);
58
+
59
+ if(is_file($fileSjis)) {
60
+
61
+ $data['FILE_TYPE'] = 'file';
62
+
63
+ $data['FILE_NM'] = mb_convert_encoding($pathInfo['basename'], 'utf-8', 'sjis');
64
+
65
+ $data['PARENT_DIR'] = mb_convert_encoding($pathInfo['dirname'], 'utf8', 'sjis');
66
+
67
+ $data['SUB_FILES'] = '';
68
+
69
+ } else if(is_dir($fileSjis)) {
70
+
71
+ $data['FILE_TYPE'] = 'dir';
72
+
73
+ $data['FILE_NM'] = mb_convert_encoding($pathInfo['basename'], 'utf-8', 'sjis');
74
+
75
+ $data['PARENT_DIR'] = mb_convert_encoding($pathInfo['dirname'], 'utf8', 'sjis');
76
+
77
+ $data['SUB_FILES'] = $this->__getSharedFiles($file);
78
+
79
+ } else {
80
+
81
+ var_dump('else');
82
+
83
+ }
84
+
85
+ $info[] = $data;
86
+
87
+ }
88
+
89
+ return $info;
90
+
91
+ }
92
+
93
+
94
+
95
+ ```

1

誤字修正

2016/01/07 06:39

投稿

orange0190
orange0190

スコア1698

test CHANGED
File without changes
test CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  現在、仕事上でPHP(CakePHP)を用いてwebアプリケーションを作成しています。
4
4
 
5
- そのwebアプリケーションの中で、実行するPHPファイルが置かれているサーバとは、別のサーバに共有フォルダを置き、そのフルダ内のファイルおよびフォルダを列挙する機能があります。
5
+ そのwebアプリケーションの中で、実行するPHPファイルが置かれているサーバとは、別のサーバに共有フォルダを置き、そのフルダ内のファイルおよびフォルダを列挙する機能があります。
6
6
 
7
7
 
8
8