Dear yuraupt.
You don't need to flame me. I have just made a mistake 😃
The right code comes below but it is rather complicated.
function upload_flat_file($theme, $topic, $lastID, $fname, $dchoice)
{global $urlroot;
$fname=wfilter($fname);
if ($dchoice == "p") {$dlink = $urlroot. "/index.php?action=vthread&subject=$theme&topic=$topic&post=$lastID";$filename = "p". $lastID.".php";
$flat_path1 = "../pages/f".$theme; $flat_path = $flat_path1."/t". $topic;
if (!is_dir($flat_path1)) mkdir ($flat_path1, 0777);
if (!is_dir($flat_path)) mkdir ($flat_path, 0777);
if (!is_dir("$flat_path/p".$lastID)) mkdir ("$flat_path/p".$lastID, 0777);
}
if ($dchoice == "t") {$dlink = $urlroot. "/index.php?action=vthread&theme=$theme&topic=$topic"; $filename = "t". $topic. ".php";
$flat_path = "../pages/f".$theme; if (!is_dir($flat_path)) mkdir ($flat_path, 0777);
}
if ($dchoice == "f") {$dlink = $urlroot. "/index.php?action=vtopic&theme=$theme"; $filename = "f". $theme. ".php";
$flat_path = "../pages";
if (!is_dir($flat_path)) mkdir ($flat_path, 0777);
if (!is_dir("../$fname")) mkdir("../$fname", 0777);
write_to_file("../$fname/index.php", $dlink, "h");
}
$filename = "$flat_path/$filename";
$filename = (string)$filename;
write_to_file($filename, $dlink, "d");
if (!empty($fname)) {
$filename = "../links/$fname";
if (!is_dir($filename)) mkdir($filename, 0777);
$filename = $filename. "/index.php";
write_to_file($filename, $dlink, "h");
}
}
😃 😃 😃