source: extensions/PHP_Optimisateur/plugins/create_folders_alpha/main.php

Last change on this file was 12819, checked in by mistic100, 12 years ago

fix detection regex and watermark position

File size: 1.2 KB
Line 
1<?php
2/***************************************\
3|            PHP OPTIMISATEUR           |
4|      Plugin CreateFoldersAlpha 1.2    |
5\***************************************/
6
7## Crée une arborescence alphanumérique dans la dossier source
8## Ne supporte pas une arborescence pré-existante
9
10$handle = opendir($CONF['DIRsource']);
11
12while ($file = readdir($handle)) {
13  if ($file != '.' && $file != '..' && !is_dir($CONF['DIRsource'].'/'.$file)) {
14    // Récupère le parties du nom servant à créer les dossiers
15    if (preg_match('#^(.{1})([^_.]*)_(.*)#', $file, $matches)) {
16      $Letter = strtoupper($matches[1]);
17      $FolderName = $matches[1].$matches[2];
18
19      // Crée les dossier
20      if (!file_exists($CONF['DIRsource'].$Letter.'/'.$FolderName)) {
21        mkdir_log($CONF['DIRsource'].$Letter.'/'.$FolderName);
22      }
23     
24      // Déplace le fichier
25      rename_log($CONF['DIRsource'].$file, $CONF['DIRsource'].$Letter.'/'.$FolderName.'/'.$file, true);
26   
27    } else {
28      $LOG[] = 'The file '.$CONF['DIRsource'].$file.' doesn\'t match the patern #^(.{1})([^_.]*)_(.*)#, not moved';
29    }
30   
31    $done = true;
32  }
33}
34
35if (isset($done)) $LOG[] = "\r\n";
36
37?>
Note: See TracBrowser for help on using the repository browser.