hey guys I need a little help.
Basically I some code that I use to make directories it works, but it runs the code when I run the open the page. I need it to work when I click a button (submit etc.) Do I have to make it a function or if statement? Or whatever? lol…Been a while since I’ve usd PHP so I’m not sure. Here is most of the code for that bit:
<?
/////not too sure about this bit here, how to get it to create a directory when I click submit etc../////
$mypath='slides/'.time();
$mypath2='slides/'.time().'/imgs';
$mypath3='slides/'.time().'/images';
mkdir($mypath, 0777);
mkdir($mypath2, 0777);
mkdir($mypath3, 0777);
$file1 = 'templates/gallery.swf';
$file2 = 'templates/images.xml';
$file3 = 'templates/index.html';
$file4 = 'templates/AC_RunActiveContent.js';
$file5 = 'templates/imageForm+xml.php';
$file6 = 'templates/css.css';
//$file7 = 'templates/imgs';
$file8 = 'imgs/accept_icon.gif';
$file9 = 'imgs/error_icon.gif';
$file10 = 'imgs/img_icon.gif';
$file11 = 'imgs/warn_icon.gif';
$file12 = 'imgs/write_icon.gif';
$file13 = 'imgs/header2.gif';
$file14 = 'imgs/header.gif';
$newfile1 = $mypath.'/gallery.swf';
$newfile2 = $mypath.'/images.xml';
$newfile3 = $mypath.'/index.html';
$newfile4 = $mypath.'/AC_RunActiveContent.js';
$newfile5 = $mypath.'/imageForm+xml.php';
$newfile6 = $mypath.'/css.css';
//$newfile7 = $mypath.'/imgs';
$newfile8 = $mypath2.'/accept_icon.gif';
$newfile9 = $mypath2.'/error_icon.gif';
$newfile10 = $mypath2.'/img_icon.gif';
$newfile11 = $mypath2.'/warn_icon.gif';
$newfile12 = $mypath2.'/write_icon.gif';
$newfile13 = $mypath2.'/header2.gif';
$newfile14 = $mypath2.'/header.gif';
if (!copy($file1, $newfile1))
{
echo "failed to copy $file1...
";
}
if (!copy($file2, $newfile2))
{
echo "failed to copy $file2...
";
}
if (!copy($file3, $newfile3))
{
echo "failed to copy $file3...
";
}
if (!copy($file4, $newfile4))
{
echo "failed to copy $file4...
";
}
if (!copy($file5, $newfile5))
{
echo "failed to copy $file5...
";
}
if (!copy($file6, $newfile6))
{
echo "failed to copy $file6...
";
}
/*if (!copy($file7, $newfile7))
{
echo "failed to copy $file7...
";
}*/
if (!copy($file8, $newfile8))
{
echo "failed to copy $file7...
";
}
if (!copy($file9, $newfile9))
{
echo "failed to copy $file10...
";
}
if (!copy($file10, $newfile10))
{
echo "failed to copy $file10...
";
}
if (!copy($file11, $newfile11))
{
echo "failed to copy $file11...
";
}
if (!copy($file12, $newfile12))
{
echo "failed to copy $file12...
";
}
if (!copy($file13, $newfile13))
{
echo "failed to copy $file13...
";
}
if (!copy($file14, $newfile14))
{
echo "failed to copy $file14...
";
}
?>
<p align="left"><a href="slides.php">View current Slideshows</a></p><p align="right"><a href="<?php echo $logoutAction ?>">Log out</a></p>
<div id="form_centre">
<form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="slideshowCreator">
<label>Name of Slide Show:</label><input name="name" type="text" value="" /><br /><div id="input_help">Make sure that this name is unique! Otherwise we're all ****ed!"</div>
<label>Description of Slide Show:</label><textarea name="des" cols="26" rows="10" wrap="virtual"></textarea>
<br />
<input name="path" type="hidden" value="<? echo $mypath ?>" />
<input name="url2" type="hidden" value="<? echo $newfile5 ?>" />
<label></label><input name="Submit" type="submit" value="Submit">
<input type="hidden" name="MM_insert" value="slideshowCreator" />
</form>
I then want to remove those folders when I access a page I have called ‘delete.php’ I’m using this script:
<?
$path=$row_delete['url'];
function full_rmdir($dirname)
{
if ($dirHandle = opendir($dirname))
{
$old_cwd = getcwd();
chdir($dirname);
while ($file = readdir($dirHandle))
{
if ($file == '.' || $file == '..') continue;
if (is_dir($file))
{
if (!full_rmdir($file)) return false;
}
else
{
if (!unlink($file)) return false;
}
}
closedir($dirHandle);
chdir($old_cwd);
if (!rmdir($dirname)) return false;
echo "directory deleted!!!!";
return true;
}
else
{
return false;
}
}
full_rmdir($path);
?>
Now it should work, but it doesn’t I think it has something to do with the chmod. In the mkdir bit above I have it so it sets the folders to 777, but when I check on my ftp it’s 755 and I can’t change it. I’ve even tried using the chmod function, but it’s not working lol.
Any info and advice would help