Buon giorno a tutti e grazie per la opportunità,
Ho questo codice che riceve i dati via $_POST apre un database testuale e lo modifica, dopo sposta una cartella e un file, e il rinomina,
il tutto ripetuto diverse volte tramite un ciclo FOR, il problema e que il cilo for si esegue solo una volta mentre dovrebbe ripetere l'operazione due volte in questo specifico caso.
spero possiate aiutarmi grazie.
if(isset($_POST['TipoPag']) && ($_POST['NomePag']) && ($_POST['PosizPag'])){
$TipoPag = $_POST['TipoPag'];
$DB = (int)$_POST['PosizPag'];
$NomePag = $_POST['NomePag'];
$NomePagZ = $_POST['NomePag'];
$filename = "database/CambioIdioma.txt";
if (file_exists($filename)){
$DataBase = file_get_contents($filename);
$DataBase = explode("♥", $DataBase);
$NomePagZ = explode(",", $NomePagZ);
for($e = 0; $e < count($DataBase); ++$e){
$DataBase11 = $DataBase[$e];
$DataBase11 = explode("➤", $DataBase11);
$NomePagA = $NomePagZ[$e];
$filename = "database/".$DataBase11[0]."/dbDataBar.txt";
if (file_exists($filename)){
$DataBase = file_get_contents($filename);
$DataBase1 = explode("♥", $DataBase);
$count = count((array) $DataBase1);
if($DB == 100000){
$DB = 0;
$DataBase1[$DB] = $NomePagZ[$e]."♥".$DataBase1[0];
}elseif($count == $DB){
$DataBase1[$DB] = $NomePagZ[$e];
}else{
$DB1 = $DataBase1[$DB];
$DataBase1[$DB] = $NomePagZ[$e]."♥".$DB1;
}
$DataBaseNaw = implode("♥", $DataBase1);
$DataBase = fopen($filename, "w+");
fwrite($DataBase, $DataBaseNaw);
fclose($DataBase);
}
$path = dirname($_SERVER['PHP_SELF']);
$path = explode("/", $path);
if($path[3] == "Management"){
$path = "/".$path[1]."/".$path[2]."/";
}
if($path[2] == "Management"){
$path = "/".$path[1]."/";
}
if($path[1] == "Management"){
$path = "/";
}
$PathAbsolute = preg_replace("!${_SERVER['SCRIPT_NAME']}$!", '', $_SERVER['SCRIPT_FILENAME']);
define('loc1', $PathAbsolute, true);
$SorgenteA = $path."Management/PagineCampione/html/".$TipoPag;
$DestinoA = $path.$DataBase11[0];
// Copia la cartella e i file, li sposta, e li rinomina.
function dircpyA($Sorgente, $Destino, $NomePag, $overwrite = true){
if($handle = opendir(loc1 . $Sorgente)){
while(false !== ($file = readdir($handle))){
if($file != '.' && $file != '..'){
$path = $Sorgente . '/' . $file;
if(is_file(loc1 . $path)){
if(!is_file(loc1 . $Destino . '/' . $file) || $overwrite)
if(!@copy(loc1 . $path, loc1 . $Destino . '/' . $file)){
echo 'El File ('.$path.') no se pudo copiar, probablemente un problema de permisos';
}
}elseif(is_dir(loc1 . $path)){
if(!is_dir(loc1 . $Destino . '/' . $file))
mkdir(loc1 . $Destino . '/' . $file); // crea una sottodirectory prima di copiarla
dircpyA($path, $Destino . '/' . $file, $overwrite);
}
}
}
$PathAbsolute = preg_replace("!${_SERVER['SCRIPT_NAME']}$!", '', $_SERVER['SCRIPT_FILENAME']); /* /home/mikylohl/www */
rename($PathAbsolute.$Destino."/".$_POST['TipoPag'].".html",$PathAbsolute.$Destino."/".$NomePag.".html"); // rename(/home/mikylohl/www/uned/es/artista/js/1.html,/home/mikylohl/www/uned/es/artista/js/1.html)
rename($PathAbsolute.$Destino."/".$_POST['TipoPag'],$PathAbsolute.$Destino."/".$NomePag); // rename(/home/mikylohl/www/uned/es/artista/js/1,/home/mikylohl/www/uned/es/artista/js/1)
closedir($handle);
}
}
dircpyA($SorgenteA,$DestinoA,$NomePagA);
}
}
}