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 70 71 72
| <?php
$src = 'prosilver';
$dst = 'votre_nom_de_thème';
$ln = isset($_SERVER['HTTP_HOST']) ? '<br />' : "\n";
echo 'Copying ', $src, ' to ', $dst, '...', $ln;
$files = array();
get_files($src, '/');
function get_files($base, $dir)
{
global $files;
$res = opendir($base . $dir);
while(($file = readdir($res)) !== false)
{
if($file !== '.' && $file !== '..')
{
if(is_dir($base . $dir . $file))
{
get_files($base, $dir . $file . '/');
}
else
{
$files[] = $dir . $file;
}
}
}
closedir($res);
}
for($i=0; $i<count($files); $i++)
{
clone_file($src, $dst, $files[$i]);
}
function clone_file($src, $dst, $file)
{
$new = $dst . str_replace($src, $dst, $file);
$data = @file_get_contents($src . $file);
$list = explode('.', strtolower($file));
$ext = $list[count($list) - 1];
if($ext === 'html' || $ext === 'cfg' || $ext === 'css' || $ext === 'php' || $ext === 'txt' || $ext === 'js' || $ext === 'htm')
{
$data = str_replace($src, $dst, $data);
}
$dirname = dirname($new);
if(strlen($dirname) && !@file_exists($dirname))
{
$list = explode('/', $dirname);
$str = '';
for($i=0; $i<count($list); $i++)
{
$str .= (strlen($str) ? '/' : '') . $list[$i];
if(!@file_exists($str))
{
if(!@mkdir($str, 0777))
{
echo 'Cannot write cache file "' . $new . '".', $ln;
return;
}
}
}
}
$f = @fopen($new, 'w');
if(!$f)
{
echo 'Cannot write cache file "' . $new . '".', $ln;
return;
}
fputs($f, $data);
fclose($f);
chmod($new, 0777);
touch($new, filemtime($src . $file));
}
echo 'done!';
?> |
Partager