i have problem to copy same file name ex : 00000.php to the same folder (00000) note : folder & file (.php) was create by "Hash" code. it's my code :
<?php
header ('Location: admin.php');
// Variables
$ads= $_POST['ads'];
$navbar = $_POST['navbar'];
$slider = $_POST['slidermenu'];
$news = $_POST['news'];
$items = $_POST['items'];
$footer = $_POST['footer'];
$rand = md5($_SERVER['REMOTE_ADDR'] . time());
// File Open
chdir("../pages/");
mkdir($rand);
$filename = fopen($cd . $rand . "." . "php" ,"a");
copy($filename,$rand);
// Should Include It's Head (Css / Js)
fwrite($filename,'<?php include($_SERVER["DOCUMENT_ROOT"] . "/include/settings.php"); ?>');
fwrite($filename,"
");
// Start Function For Radio Boxs
if ($ads == "ads-yes") {
fwrite($filename,'<?php include($_SERVER["DOCUMENT_ROOT"] . "/include/ads.php"); ?>');
fwrite($filename,"
");
}
if ($navbar== "navbar-yes") {
fwrite($filename,'<?php include($_SERVER["DOCUMENT_ROOT"] . "/include/navbar.php"); ?>');
fwrite($filename,"
");
}
if ($slider == "slidermenu-yes") {
fwrite($filename,'<?php include($_SERVER["DOCUMENT_ROOT"] . "/include/slider.php"); ?>');
fwrite($filename,"
");
}
if ($news== "news-yes") {
fwrite($filename,'<?php include($_SERVER["DOCUMENT_ROOT"] . "/include/news.php"); ?>');
fwrite($filename,"
");
}
if ($items == "items-yes") {
fwrite($filename,'<?php include($_SERVER["DOCUMENT_ROOT"] . "/include/items.php"); ?>');
fwrite($filename,"
");
}
if ($footer== "footer-yes") {
fwrite($filename,'<?php include($_SERVER["DOCUMENT_ROOT"] . "/include/footer.php"); ?>');
fwrite($filename,"
");
}
// End Function For Radio Boxs
// File Close
fclose($handle);
exit;
?>
Images : http://i.stack.imgur.com/vjkoT.png
thanks
</div>
You don't try to copy a file which is currently opened by PHP before writing data to that file, are you?
Its like everything on the computer: You should first WRITE the file before trying to copy it.
ALSO you try to create a file in its folders location.
What are you copying:
/example.php to /example -> copy($filename,$rand);
What are you trying to copy:
/example.php to /example/example.php -> copy($filename,$rand."/".$filename);