Line | |
---|
1 | <?php |
---|
2 | /***************************************\ |
---|
3 | | PHP OPTIMISATEUR | |
---|
4 | | Plugin CretaFoldersAlpha | |
---|
5 | \***************************************/ |
---|
6 | |
---|
7 | ## Crée une arborescence alphanumérique dans la dossier source |
---|
8 | ## Ne supporte pas une arborescence pré-existante |
---|
9 | |
---|
10 | # PluginsBefore => 'create_folders_alpha' => array('active' => true) |
---|
11 | |
---|
12 | $handle = opendir($DIRsource); |
---|
13 | |
---|
14 | while ($file = readdir($handle)) { |
---|
15 | if ($file != '.' && $file != '..' && !is_dir($DIRsource.'/'.$file)) { |
---|
16 | // Récupère le parties du nom servant à créer les dossiers |
---|
17 | preg_match('#(.{1})([0-9A-Za-z.-]*)_(.*)#', $file, $matches); |
---|
18 | |
---|
19 | // Crée les dossier |
---|
20 | if (!file_exists($DIRsource.strtoupper($matches[1]).'/'.$matches[1].$matches[2])) { |
---|
21 | mkdir($DIRsource.strtoupper($matches[1]).'/'.$matches[1].$matches[2], 0777, true); |
---|
22 | } |
---|
23 | |
---|
24 | // Déplace le fichier |
---|
25 | rename($DIRsource.$file, $DIRsource.strtoupper($matches[1]).'/'.$matches[1].$matches[2].'/'.$file); |
---|
26 | } |
---|
27 | } |
---|
28 | ?> |
---|
Note: See
TracBrowser
for help on using the repository browser.