OSDN Git Service

original file
[nucleus-jp/nucleus-plugins.git] / trunk / NP_TinyMCE2j / tinymce2j / plugins / filemanager / InsertFile / functions.php
1 <?php
2 /***********************************************************************
3 ** Title.........:    Insert File Dialog, File Manager
4 ** Version.......:    1.1
5 ** Authors.......:    Al Rashid <alrashid@klokan.sk>
6 **                    Xiang Wei ZHUO <wei@zhuo.org>
7 ** Filename......:    functions.php
8 ** URL...........:    http://alrashid.klokan.sk/insFile/
9 ** Last changed..:    23 July 2004
10 ***********************************************************************/
11
12
13 function dirs($dir,$abs_path) {
14         $d = dir($dir);
15         $dirs = array();
16         while (false !== ($entry = $d->read())) {
17                 if(is_dir($dir.'/'.$entry) && substr($entry,0,1) != '.')  {
18                         $path['path'] = $dir.'/'.$entry;
19                         $path['name'] = $entry;
20                         $dirs[$entry] = $path;
21                 }
22         }
23         $d->close();
24         ksort($dirs);
25         $cntDir = count($dirs);
26         for($i=0; $i<$cntDir; $i++) {
27                 $name = key($dirs);
28                 $current_dir = $abs_path.'/'.$dirs[$name]['name'];
29                 echo ", '".sanitize($current_dir)."/'\n";
30                 dirs($dirs[$name]['path'],$current_dir);
31                 next($dirs);
32         }
33 }
34
35 function checkName($name) {
36         $name = str_replace('../', '', $name);
37         $name = str_replace('./', '', $name);
38         return $name;
39 }
40 function sanitize($name) {
41         return str_replace("'", "\'", $name);
42 }
43
44 function unsanitize($name) {
45         return str_replace("\'", "'", $name);
46 }
47
48 function pathSlashes($path) {
49         if ('/' != substr($path,0,1)) $path =  '/'.$path;
50         if ('/' != substr($path,-1,1)) $path = $path.'/';
51         return $path;
52 }
53 function alertSanitize($path) {
54         return ( sanitize(str_replace("\\", "\\\\", $path)) );
55 }
56 ?>