Skip to content

Instantly share code, notes, and snippets.

@BenjaminGuV
Created July 18, 2012 23:27
Show Gist options
  • Save BenjaminGuV/3139674 to your computer and use it in GitHub Desktop.
Save BenjaminGuV/3139674 to your computer and use it in GitHub Desktop.
Crear clones en php
<?php
$directorios = array( '****', '***' );
$dir = $_SERVER['DOCUMENT_ROOT'];
$direccion = $dir . rtrim(dirname($_SERVER['PHP_SELF'] ) );
$direccion = preg_replace('/\/\//', '/', $direccion) . "/";
function full_copy( $source, $target ) {
if ( is_dir( $source ) ) {
@mkdir( $target );
$d = dir( $source );
while ( FALSE !== ( $entry = $d->read() ) ) {
if ( $entry == '.' || $entry == '..' ) {
continue;
}
$Entry = $source . '/' . $entry;
if ( is_dir( $Entry ) ) {
full_copy( $Entry, $target . '/' . $entry );
continue;
}
copy( $Entry, $target . '/' . $entry );
}
$d->close();
}else {
copy( $source, $target );
}
}
?>
<html>
<head>
<title></title>
</head>
<body>
<?php
foreach ($directorios as $key) {
$source = $direccion . 'mcr-madre';
$destino = $direccion . $key;
full_copy( $source, $destino );
}
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment