-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.php
executable file
·69 lines (51 loc) · 1.51 KB
/
utils.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
function checkFileName($dossier){
if (($dir=opendir($dossier))===false)
return;
while($name=readdir($dir)){
if($name==='.' or $name==='..')
continue;
$full_name = $dossier.'/'.$name;
if(is_dir($full_name)) {
$newName = iconv('cp437', 'iso-8859-1', $full_name);
$newName = trim($newName, chr(0xC2).chr(0xA0));
rename($full_name,$newName);
checkFileName($newName);
} else {
$newName = iconv('cp437', 'iso-8859-1', $name);
rename($full_name,$dossier.'/'.$newName);
}
}
}
function deltree($dossier) {
if(($dir=@opendir($dossier))===false)
return;
while($name=readdir($dir)){
if($name==='.' or $name==='..')
continue;
$full_name=$dossier.'/'.$name;
if(is_dir($full_name))
deltree($full_name);
else unlink($full_name);
}
closedir($dir);
@rmdir($dossier);
}
function CheckDirectory($empresa,$basePath) {
$result = array();
$path = $basePath.$empresa;
if (is_dir(substr($path,0,-1)))
$path = substr($path,0,-1);
if (is_dir($path)) {
if ($filesEmpresa = opendir($path)) {
$j = 0;
while($file = @readdir($filesEmpresa))
if($file != '..' && $file != '.') {
$dirName = str_replace($basePath,'',$path);
$url = $basePath.rawurlencode($dirName).'/'.rawurlencode($file);
$result[$j++] = '<li><a href="'.$url.'" >'.$file.'</a></li>';
}
}
}
return $result;
}