en labs/mkdir/
index.php
Código PHP:
<?php
global $username;
$username = $_GET["username"];
$pathname = $username;
mkdirr ($pathname);
$arch = "/home/matussal/public_html/labs/mkdir/$username/index.txt"; //creamos el archivo
$fp = fopen( $arch, "w+" ); //lo abrimos modo escritura
$dato1 = '<?php
include("http://www.matussalen.com/ver.php?cat=usuarios&propietario=';
$dato2 = "$username";
$dato3 = '");?>';
fputs( $fp, "$dato1$dato2$dato3" ); //escribimos en el archivo
fclose($fp);
rename("/home/matussal/public_html/labs/mkdir/$username/index.txt" , "/home/matussal/public_html/labs/mkdir/$username/index.php" );
echo "ok $username<br>arch: $arch<br><br>$dato1";
function mkdirr($pathname, $mode = 755)
{
// Check if directory already exists
if (is_dir($pathname) || empty($pathname)) {
return true;
}
// Ensure a file does not already exist with the same name
$pathname = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $pathname);
if (is_file($pathname)) {
trigger_error('mkdirr() File exists', E_USER_WARNING);
return false;
}
// Crawl up the directory tree
$next_pathname = substr($pathname, 755, strrpos($pathname, DIRECTORY_SEPARATOR));
if (mkdirr($next_pathname, $mode)) {
if (!file_exists($pathname)) {
return mkdir($pathname, $mode);
}
}
return false;
}
?>
como ves, aquí se ve que index se mete en la carpeta que se crea...