1 | <?php |
---|
2 | /* |
---|
3 | * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved. |
---|
4 | * |
---|
5 | * http://www.lockon.co.jp/ |
---|
6 | */ |
---|
7 | |
---|
8 | // {{{ requires |
---|
9 | require_once(CLASS_PATH . "pages/LC_Page.php"); |
---|
10 | |
---|
11 | /** |
---|
12 | * ファイル管理 のページクラス. |
---|
13 | * |
---|
14 | * @package Page |
---|
15 | * @author LOCKON CO.,LTD. |
---|
16 | * @version $Id$ |
---|
17 | */ |
---|
18 | class LC_Page_Admin_Contents_FileManager extends LC_Page { |
---|
19 | |
---|
20 | // }}} |
---|
21 | // {{{ functions |
---|
22 | |
---|
23 | /** |
---|
24 | * Page を初期化する. |
---|
25 | * |
---|
26 | * @return void |
---|
27 | */ |
---|
28 | function init() { |
---|
29 | parent::init(); |
---|
30 | $this->tpl_mainpage = 'contents/file_manager.tpl'; |
---|
31 | $this->tpl_mainno = 'contents'; |
---|
32 | $this->tpl_subnavi = 'contents/subnavi.tpl'; |
---|
33 | $this->tpl_subno = "file"; |
---|
34 | $this->tpl_subtitle = 'ファイル管理'; |
---|
35 | |
---|
36 | } |
---|
37 | |
---|
38 | /** |
---|
39 | * Page のプロセス. |
---|
40 | * |
---|
41 | * @return void |
---|
42 | */ |
---|
43 | function process() { |
---|
44 | //---- 認証可否の判定 |
---|
45 | $objSess = new SC_Session(); |
---|
46 | SC_Utils_Ex::sfIsSuccess($objSess); |
---|
47 | |
---|
48 | // ルートディレクトリ |
---|
49 | $top_dir = USER_PATH; |
---|
50 | |
---|
51 | $objView = new SC_AdminView(); |
---|
52 | $objQuery = new SC_Query(); |
---|
53 | |
---|
54 | if (!isset($_POST['mode'])) $_POST['mode'] = ""; |
---|
55 | |
---|
56 | $tpl_onload = ""; |
---|
57 | |
---|
58 | // 現在の階層を取得 |
---|
59 | if($_POST['mode'] != "") { |
---|
60 | $now_dir = $_POST['now_file']; |
---|
61 | } else { |
---|
62 | // 初期表示はルートディレクトリ(user_data/)を表示 |
---|
63 | $now_dir = $top_dir; |
---|
64 | } |
---|
65 | |
---|
66 | // ファイル管理クラス |
---|
67 | $objUpFile = new SC_UploadFile($now_dir, $now_dir); |
---|
68 | // ファイル情報の初期化 |
---|
69 | $this->lfInitFile($objUpFile); |
---|
70 | |
---|
71 | switch($_POST['mode']) { |
---|
72 | |
---|
73 | // ファイル表示 |
---|
74 | case 'view': |
---|
75 | // エラーチェック |
---|
76 | $arrErr = $this->lfErrorCheck(); |
---|
77 | if(!is_array($arrErr)) { |
---|
78 | |
---|
79 | // 選択されたファイルがディレクトリなら移動 |
---|
80 | if(is_dir($_POST['select_file'])) { |
---|
81 | ///$now_dir = $_POST['select_file']; |
---|
82 | // ツリー遷移用のjavascriptを埋め込む |
---|
83 | $arrErr['select_file'] = "※ ディレクトリを表示することは出来ません。<br/>"; |
---|
84 | |
---|
85 | } else { |
---|
86 | // javascriptで別窓表示(テンプレート側に渡す) |
---|
87 | // FIXME |
---|
88 | $file_url = ereg_replace(USER_PATH, "", $_POST['select_file']); |
---|
89 | $tpl_onload = "win02('./file_view.php?file=". $file_url ."', 'user_data', '600', '400');"; |
---|
90 | } |
---|
91 | } |
---|
92 | break; |
---|
93 | // ファイルダウンロード |
---|
94 | case 'download': |
---|
95 | |
---|
96 | // エラーチェック |
---|
97 | $arrErr = $this->lfErrorCheck(); |
---|
98 | if(!is_array($arrErr)) { |
---|
99 | if(is_dir($_POST['select_file'])) { |
---|
100 | // ディレクトリの場合はjavascriptエラー |
---|
101 | $arrErr['select_file'] = "※ ディレクトリをダウンロードすることは出来ません。<br/>"; |
---|
102 | } else { |
---|
103 | // ファイルダウンロード |
---|
104 | $this->sfDownloadFile($_POST['select_file']); |
---|
105 | exit; |
---|
106 | } |
---|
107 | } |
---|
108 | break; |
---|
109 | // ファイル削除 |
---|
110 | case 'delete': |
---|
111 | // エラーチェック |
---|
112 | $arrErr = $this->lfErrorCheck(); |
---|
113 | if(!is_array($arrErr)) { |
---|
114 | $this->sfDeleteDir($_POST['select_file']); |
---|
115 | } |
---|
116 | break; |
---|
117 | // ファイル作成 |
---|
118 | case 'create': |
---|
119 | // エラーチェック |
---|
120 | $arrErr = $this->lfCreateErrorCheck(); |
---|
121 | if(!is_array($arrErr)) { |
---|
122 | $create_dir = ereg_replace("/$", "", $now_dir); |
---|
123 | // ファイル作成 |
---|
124 | if(!$this->sfCreateFile($create_dir."/".$_POST['create_file'], 0755)) { |
---|
125 | // 作成エラー |
---|
126 | $arrErr['create_file'] = "※ ".$_POST['create_file']."の作成に失敗しました。<br/>"; |
---|
127 | } else { |
---|
128 | $tpl_onload .= "alert('フォルダを作成しました。');"; |
---|
129 | } |
---|
130 | } |
---|
131 | break; |
---|
132 | // ファイルアップロード |
---|
133 | case 'upload': |
---|
134 | // 画像保存処理 |
---|
135 | $ret = $objUpFile->makeTempFile('upload_file', false); |
---|
136 | if($ret != "") { |
---|
137 | $arrErr['upload_file'] = $ret; |
---|
138 | } else { |
---|
139 | $tpl_onload .= "alert('ファイルをアップロードしました。');"; |
---|
140 | } |
---|
141 | break; |
---|
142 | // フォルダ移動 |
---|
143 | case 'move': |
---|
144 | $now_dir = $_POST['tree_select_file']; |
---|
145 | break; |
---|
146 | // 初期表示 |
---|
147 | default : |
---|
148 | break; |
---|
149 | } |
---|
150 | // トップディレクトリか調査 |
---|
151 | $is_top_dir = false; |
---|
152 | // 末尾の/をとる |
---|
153 | $top_dir_check = ereg_replace("/$", "", $top_dir); |
---|
154 | $now_dir_check = ereg_replace("/$", "", $now_dir); |
---|
155 | if($top_dir_check == $now_dir_check) $is_top_dir = true; |
---|
156 | |
---|
157 | // 現在の階層より一つ上の階層を取得 |
---|
158 | $parent_dir = $this->lfGetParentDir($now_dir); |
---|
159 | |
---|
160 | // 現在のディレクトリ配下のファイル一覧を取得 |
---|
161 | $this->arrFileList = $this->sfGetFileList($now_dir); |
---|
162 | $this->tpl_is_top_dir = $is_top_dir; |
---|
163 | $this->tpl_parent_dir = $parent_dir; |
---|
164 | $this->tpl_now_dir = $now_dir; |
---|
165 | $this->tpl_now_file = basename($now_dir); |
---|
166 | $this->arrErr = isset($arrErr) ? $arrErr : ""; |
---|
167 | $this->arrParam = $_POST; |
---|
168 | |
---|
169 | // ツリーを表示する divタグid, ツリー配列変数名, 現在ディレクトリ, 選択ツリーhidden名, ツリー状態hidden名, mode hidden名 |
---|
170 | $treeView = "fnTreeView('tree', arrTree, '$now_dir', 'tree_select_file', 'tree_status', 'move');"; |
---|
171 | if (!empty($this->tpl_onload)) { |
---|
172 | $this->tpl_onload .= $treeView . $tpl_onload; |
---|
173 | } else { |
---|
174 | $this->tpl_onload = $treeView; |
---|
175 | } |
---|
176 | |
---|
177 | // ツリー配列作成用 javascript |
---|
178 | if (!isset($_POST['tree_status'])) $_POST['tree_status'] = ""; |
---|
179 | $arrTree = $this->sfGetFileTree($top_dir, $_POST['tree_status']); |
---|
180 | $this->tpl_javascript .= "arrTree = new Array();\n"; |
---|
181 | foreach($arrTree as $arrVal) { |
---|
182 | $this->tpl_javascript .= "arrTree[".$arrVal['count']."] = new Array(".$arrVal['count'].", '".$arrVal['type']."', '".$arrVal['path']."', ".$arrVal['rank'].","; |
---|
183 | if ($arrVal['open']) { |
---|
184 | $this->tpl_javascript .= "true);\n"; |
---|
185 | } else { |
---|
186 | $this->tpl_javascript .= "false);\n"; |
---|
187 | } |
---|
188 | } |
---|
189 | |
---|
190 | // 画面の表示 |
---|
191 | $objView->assignobj($this); |
---|
192 | $objView->display(MAIN_FRAME); |
---|
193 | } |
---|
194 | |
---|
195 | /** |
---|
196 | * デストラクタ. |
---|
197 | * |
---|
198 | * @return void |
---|
199 | */ |
---|
200 | function destroy() { |
---|
201 | parent::destroy(); |
---|
202 | } |
---|
203 | |
---|
204 | /* |
---|
205 | * 関数名:lfErrorCheck() |
---|
206 | * 説明 :エラーチェック |
---|
207 | */ |
---|
208 | function lfErrorCheck() { |
---|
209 | $objErr = new SC_CheckError($_POST); |
---|
210 | $objErr->doFunc(array("ファイル", "select_file"), array("SELECT_CHECK")); |
---|
211 | |
---|
212 | return $objErr->arrErr; |
---|
213 | } |
---|
214 | |
---|
215 | /* |
---|
216 | * 関数名:lfCreateErrorCheck() |
---|
217 | * 説明 :ファイル作成処理エラーチェック |
---|
218 | */ |
---|
219 | function lfCreateErrorCheck() { |
---|
220 | $objErr = new SC_CheckError($_POST); |
---|
221 | $objErr->doFunc(array("作成ファイル名", "create_file"), array("EXIST_CHECK", "FILE_NAME_CHECK_BY_NOUPLOAD")); |
---|
222 | |
---|
223 | return $objErr->arrErr; |
---|
224 | } |
---|
225 | |
---|
226 | /* |
---|
227 | * 関数名:lfInitFile() |
---|
228 | * 説明 :ファイル情報の初期化 |
---|
229 | */ |
---|
230 | function lfInitFile(&$objUpFile) { |
---|
231 | $objUpFile->addFile("ファイル", 'upload_file', array(), FILE_SIZE, true, 0, 0, false); |
---|
232 | } |
---|
233 | |
---|
234 | /* |
---|
235 | * 関数名:lfGetParentDir() |
---|
236 | * 引数1 :ディレクトリ |
---|
237 | * 説明 :親ディレクトリ取得 |
---|
238 | */ |
---|
239 | function lfGetParentDir($dir) { |
---|
240 | $dir = ereg_replace("/$", "", $dir); |
---|
241 | $arrDir = split('/', $dir); |
---|
242 | array_pop($arrDir); |
---|
243 | $parent_dir = ""; |
---|
244 | foreach($arrDir as $val) { |
---|
245 | $parent_dir .= "$val/"; |
---|
246 | } |
---|
247 | $parent_dir = ereg_replace("/$", "", $parent_dir); |
---|
248 | |
---|
249 | return $parent_dir; |
---|
250 | } |
---|
251 | |
---|
252 | /* |
---|
253 | * 関数名:sfGetFileList() |
---|
254 | * 説明 :指定パス配下のディレクトリ取得 |
---|
255 | * 引数1 :取得するディレクトリパス |
---|
256 | */ |
---|
257 | function sfGetFileList($dir) { |
---|
258 | $arrFileList = array(); |
---|
259 | $arrDirList = array(); |
---|
260 | |
---|
261 | if (is_dir($dir)) { |
---|
262 | if ($dh = opendir($dir)) { |
---|
263 | $cnt = 0; |
---|
264 | // 行末の/を取り除く |
---|
265 | while (($file = readdir($dh)) !== false) $arrDir[] = $file; |
---|
266 | $dir = ereg_replace("/$", "", $dir); |
---|
267 | // アルファベットと数字でソート |
---|
268 | natcasesort($arrDir); |
---|
269 | foreach($arrDir as $file) { |
---|
270 | // ./ と ../を除くファイルのみを取得 |
---|
271 | if($file != "." && $file != "..") { |
---|
272 | |
---|
273 | $path = $dir."/".$file; |
---|
274 | // SELECT内の見た目を整えるため指定文字数で切る |
---|
275 | $file_name = SC_Utils_Ex::sfCutString($file, FILE_NAME_LEN); |
---|
276 | $file_size = SC_Utils_Ex::sfCutString($this->sfGetDirSize($path), FILE_NAME_LEN); |
---|
277 | $file_time = date("Y/m/d", filemtime($path)); |
---|
278 | |
---|
279 | // ディレクトリとファイルで格納配列を変える |
---|
280 | if(is_dir($path)) { |
---|
281 | $arrDirList[$cnt]['file_name'] = $file; |
---|
282 | $arrDirList[$cnt]['file_path'] = $path; |
---|
283 | $arrDirList[$cnt]['file_size'] = $file_size; |
---|
284 | $arrDirList[$cnt]['file_time'] = $file_time; |
---|
285 | $arrDirList[$cnt]['is_dir'] = true; |
---|
286 | } else { |
---|
287 | $arrFileList[$cnt]['file_name'] = $file; |
---|
288 | $arrFileList[$cnt]['file_path'] = $path; |
---|
289 | $arrFileList[$cnt]['file_size'] = $file_size; |
---|
290 | $arrFileList[$cnt]['file_time'] = $file_time; |
---|
291 | $arrFileList[$cnt]['is_dir'] = false; |
---|
292 | } |
---|
293 | $cnt++; |
---|
294 | } |
---|
295 | } |
---|
296 | closedir($dh); |
---|
297 | } |
---|
298 | } |
---|
299 | |
---|
300 | // フォルダを先頭にしてマージ |
---|
301 | return array_merge($arrDirList, $arrFileList); |
---|
302 | } |
---|
303 | |
---|
304 | /* |
---|
305 | * 関数名:sfGetDirSize() |
---|
306 | * 説明 :指定したディレクトリのバイト数を取得 |
---|
307 | * 引数1 :ディレクトリ |
---|
308 | */ |
---|
309 | function sfGetDirSize($dir) { |
---|
310 | $bytes = 0; |
---|
311 | if(file_exists($dir)) { |
---|
312 | // ディレクトリの場合下層ファイルの総量を取得 |
---|
313 | if (is_dir($dir)) { |
---|
314 | $handle = opendir($dir); |
---|
315 | while ($file = readdir($handle)) { |
---|
316 | // 行末の/を取り除く |
---|
317 | $dir = ereg_replace("/$", "", $dir); |
---|
318 | $path = $dir."/".$file; |
---|
319 | if ($file != '..' && $file != '.' && !is_dir($path)) { |
---|
320 | $bytes += filesize($path); |
---|
321 | } else if (is_dir($path) && $file != '..' && $file != '.') { |
---|
322 | // 下層ファイルのバイト数を取得する為、再帰的に呼び出す。 |
---|
323 | $bytes += $this->sfGetDirSize($path); |
---|
324 | } |
---|
325 | } |
---|
326 | } else { |
---|
327 | // ファイルの場合 |
---|
328 | $bytes = filesize($dir); |
---|
329 | } |
---|
330 | } |
---|
331 | // ディレクトリ(ファイル)が存在しない場合は0byteを返す |
---|
332 | if($bytes == "") $bytes = 0; |
---|
333 | |
---|
334 | return $bytes; |
---|
335 | } |
---|
336 | |
---|
337 | /* |
---|
338 | * 関数名:sfDeleteDir() |
---|
339 | * 説明 :指定したディレクトリを削除 |
---|
340 | * 引数1 :削除ファイル |
---|
341 | */ |
---|
342 | function sfDeleteDir($dir) { |
---|
343 | $arrResult = array(); |
---|
344 | if(file_exists($dir)) { |
---|
345 | // ディレクトリかチェック |
---|
346 | if (is_dir($dir)) { |
---|
347 | if ($handle = opendir("$dir")) { |
---|
348 | $cnt = 0; |
---|
349 | while (false !== ($item = readdir($handle))) { |
---|
350 | if ($item != "." && $item != "..") { |
---|
351 | if (is_dir("$dir/$item")) { |
---|
352 | sfDeleteDir("$dir/$item"); |
---|
353 | } else { |
---|
354 | $arrResult[$cnt]['result'] = @unlink("$dir/$item"); |
---|
355 | $arrResult[$cnt]['file_name'] = "$dir/$item"; |
---|
356 | } |
---|
357 | } |
---|
358 | $cnt++; |
---|
359 | } |
---|
360 | } |
---|
361 | closedir($handle); |
---|
362 | $arrResult[$cnt]['result'] = @rmdir($dir); |
---|
363 | $arrResult[$cnt]['file_name'] = "$dir/$item"; |
---|
364 | } else { |
---|
365 | // ファイル削除 |
---|
366 | $arrResult[0]['result'] = @unlink("$dir"); |
---|
367 | $arrResult[0]['file_name'] = "$dir"; |
---|
368 | } |
---|
369 | } |
---|
370 | |
---|
371 | return $arrResult; |
---|
372 | } |
---|
373 | |
---|
374 | /* |
---|
375 | * 関数名:sfGetFileTree() |
---|
376 | * 説明 :ツリー生成用配列取得(javascriptに渡す用) |
---|
377 | * 引数1 :ディレクトリ |
---|
378 | * 引数2 :現在のツリーの状態開いているフォルダのパスが | 区切りで格納 |
---|
379 | */ |
---|
380 | function sfGetFileTree($dir, $tree_status) { |
---|
381 | |
---|
382 | $cnt = 0; |
---|
383 | $arrTree = array(); |
---|
384 | $default_rank = count(split('/', $dir)); |
---|
385 | |
---|
386 | // 文末の/を取り除く |
---|
387 | $dir = ereg_replace("/$", "", $dir); |
---|
388 | // 最上位層を格納(user_data/) |
---|
389 | if($this->sfDirChildExists($dir)) { |
---|
390 | $arrTree[$cnt]['type'] = "_parent"; |
---|
391 | } else { |
---|
392 | $arrTree[$cnt]['type'] = "_child"; |
---|
393 | } |
---|
394 | $arrTree[$cnt]['path'] = $dir; |
---|
395 | $arrTree[$cnt]['rank'] = 0; |
---|
396 | $arrTree[$cnt]['count'] = $cnt; |
---|
397 | // 初期表示はオープン |
---|
398 | if($_POST['mode'] != '') { |
---|
399 | $arrTree[$cnt]['open'] = $this->lfIsFileOpen($dir, $tree_status); |
---|
400 | } else { |
---|
401 | $arrTree[$cnt]['open'] = true; |
---|
402 | } |
---|
403 | $cnt++; |
---|
404 | |
---|
405 | $this->sfGetFileTreeSub($dir, $default_rank, $cnt, $arrTree, $tree_status); |
---|
406 | |
---|
407 | return $arrTree; |
---|
408 | } |
---|
409 | |
---|
410 | /* |
---|
411 | * 関数名:sfGetFileTree() |
---|
412 | * 説明 :ツリー生成用配列取得(javascriptに渡す用) |
---|
413 | * 引数1 :ディレクトリ |
---|
414 | * 引数2 :デフォルトの階層(/区切りで 0,1,2・・・とカウント) |
---|
415 | * 引数3 :連番 |
---|
416 | * 引数4 :現在のツリーの状態開いているフォルダのパスが | 区切りで格納 |
---|
417 | */ |
---|
418 | function sfGetFileTreeSub($dir, $default_rank, &$cnt, &$arrTree, $tree_status) { |
---|
419 | |
---|
420 | if(file_exists($dir)) { |
---|
421 | if ($handle = opendir("$dir")) { |
---|
422 | while (false !== ($item = readdir($handle))) $arrDir[] = $item; |
---|
423 | // アルファベットと数字でソート |
---|
424 | natcasesort($arrDir); |
---|
425 | foreach($arrDir as $item) { |
---|
426 | if ($item != "." && $item != "..") { |
---|
427 | // 文末の/を取り除く |
---|
428 | $dir = ereg_replace("/$", "", $dir); |
---|
429 | $path = $dir."/".$item; |
---|
430 | // ディレクトリのみ取得 |
---|
431 | if (is_dir($path)) { |
---|
432 | $arrTree[$cnt]['path'] = $path; |
---|
433 | if($this->sfDirChildExists($path)) { |
---|
434 | $arrTree[$cnt]['type'] = "_parent"; |
---|
435 | } else { |
---|
436 | $arrTree[$cnt]['type'] = "_child"; |
---|
437 | } |
---|
438 | |
---|
439 | // 階層を割り出す |
---|
440 | $arrCnt = split('/', $path); |
---|
441 | $rank = count($arrCnt); |
---|
442 | $arrTree[$cnt]['rank'] = $rank - $default_rank + 1; |
---|
443 | $arrTree[$cnt]['count'] = $cnt; |
---|
444 | // フォルダが開いているか |
---|
445 | $arrTree[$cnt]['open'] = $this->lfIsFileOpen($path, $tree_status); |
---|
446 | $cnt++; |
---|
447 | // 下層ディレクトリ取得の為、再帰的に呼び出す |
---|
448 | $this->sfGetFileTreeSub($path, $default_rank, $cnt, $arrTree, $tree_status); |
---|
449 | } |
---|
450 | } |
---|
451 | } |
---|
452 | } |
---|
453 | closedir($handle); |
---|
454 | } |
---|
455 | } |
---|
456 | |
---|
457 | /* |
---|
458 | * 関数名:sfDirChildExists() |
---|
459 | * 説明 :指定したディレクトリ配下にファイルがあるか |
---|
460 | * 引数1 :ディレクトリ |
---|
461 | */ |
---|
462 | function sfDirChildExists($dir) { |
---|
463 | if(file_exists($dir)) { |
---|
464 | if (is_dir($dir)) { |
---|
465 | $handle = opendir($dir); |
---|
466 | while ($file = readdir($handle)) { |
---|
467 | // 行末の/を取り除く |
---|
468 | $dir = ereg_replace("/$", "", $dir); |
---|
469 | $path = $dir."/".$file; |
---|
470 | if ($file != '..' && $file != '.' && is_dir($path)) { |
---|
471 | return true; |
---|
472 | } |
---|
473 | } |
---|
474 | } |
---|
475 | } |
---|
476 | |
---|
477 | return false; |
---|
478 | } |
---|
479 | |
---|
480 | /* |
---|
481 | * 関数名:lfIsFileOpen() |
---|
482 | * 説明 :指定したファイルが前回開かれた状態にあったかチェック |
---|
483 | * 引数1 :ディレクトリ |
---|
484 | * 引数2 :現在のツリーの状態開いているフォルダのパスが | 区切りで格納 |
---|
485 | */ |
---|
486 | function lfIsFileOpen($dir, $tree_status) { |
---|
487 | $arrTreeStatus = split('\|', $tree_status); |
---|
488 | if(in_array($dir, $arrTreeStatus)) { |
---|
489 | return true; |
---|
490 | } |
---|
491 | |
---|
492 | return false; |
---|
493 | } |
---|
494 | |
---|
495 | /* |
---|
496 | * 関数名:sfDownloadFile() |
---|
497 | * 引数1 :ファイルパス |
---|
498 | * 説明 :ファイルのダウンロード |
---|
499 | */ |
---|
500 | function sfDownloadFile($file) { |
---|
501 | // ファイルの場合はダウンロードさせる |
---|
502 | Header("Content-disposition: attachment; filename=".basename($file)); |
---|
503 | Header("Content-type: application/octet-stream; name=".basename($file)); |
---|
504 | Header("Cache-Control: "); |
---|
505 | Header("Pragma: "); |
---|
506 | echo ($this->sfReadFile($file)); |
---|
507 | } |
---|
508 | |
---|
509 | /* |
---|
510 | * 関数名:sfCreateFile() |
---|
511 | * 引数1 :ファイルパス |
---|
512 | * 引数2 :パーミッション |
---|
513 | * 説明 :ファイル作成 |
---|
514 | */ |
---|
515 | function sfCreateFile($file, $mode = "") { |
---|
516 | // 行末の/を取り除く |
---|
517 | if($mode != "") { |
---|
518 | $ret = @mkdir($file, $mode); |
---|
519 | } else { |
---|
520 | $ret = @mkdir($file); |
---|
521 | } |
---|
522 | |
---|
523 | return $ret; |
---|
524 | } |
---|
525 | |
---|
526 | /* |
---|
527 | * 関数名:sfReadFile() |
---|
528 | * 引数1 :ファイルパス |
---|
529 | * 説明 :ファイル読込 |
---|
530 | */ |
---|
531 | function sfReadFile($filename) { |
---|
532 | $str = ""; |
---|
533 | // バイナリモードでオープン |
---|
534 | $fp = @fopen($filename, "rb" ); |
---|
535 | //ファイル内容を全て変数に読み込む |
---|
536 | if($fp) { |
---|
537 | $str = @fread($fp, filesize($filename)+1); |
---|
538 | } |
---|
539 | @fclose($fp); |
---|
540 | |
---|
541 | return $str; |
---|
542 | } |
---|
543 | } |
---|
544 | ?> |
---|