2 /***********************************************************************
3 ** Title.........: Insert File Dialog, File Manager
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 ***********************************************************************/
13 function dirs($dir,$abs_path) {
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;
25 $cntDir = count($dirs);
26 for($i=0; $i<$cntDir; $i++) {
28 $current_dir = $abs_path.'/'.$dirs[$name]['name'];
29 echo ", '".sanitize($current_dir)."/'\n";
30 dirs($dirs[$name]['path'],$current_dir);
35 function checkName($name) {
36 $name = str_replace('../', '', $name);
37 $name = str_replace('./', '', $name);
40 function sanitize($name) {
41 return str_replace("'", "\'", $name);
44 function unsanitize($name) {
45 return str_replace("\'", "'", $name);
48 function pathSlashes($path) {
49 if ('/' != substr($path,0,1)) $path = '/'.$path;
50 if ('/' != substr($path,-1,1)) $path = $path.'/';
53 function alertSanitize($path) {
54 return ( sanitize(str_replace("\\", "\\\\", $path)) );