RyanT
11-20-2006, 08:53 PM
Hello,
Im running into a problem, I have a single page login that displays the contents of a directory....
<hmtl>
<head>
<script LANGUAGE="JavaScript">
<!--
function confirmSubmit()
{
var agree=confirm("This will delete this File Permanently. Do you want to continue?");
if (agree)
return true ;
else
return false ;
}
// -->
</script>
</head>
<body>
<?php
$username = "xxxxxxx";
$password = "xxxxxxx";
if ($_POST['txtUsername'] != $username || $_POST['txtPassword'] != $password) {
?>
<center>
<form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<h1>Login <br> Holidays Get Published</h1><br>
<p><label for="txtUsername">Username:</label> <br />
<input type="text" title="Enter your Username" name="txtUsername" /></p>
<p><label for="txtpassword">Password:</label> <br /><input type="password" title="Enter your password" name="txtPassword" /></p>
<p><input type="submit" name="Submit" value="Login" class="buttons"/><br><br></p></form>
</center>
<?php
}
else {
?>
<?
$dir = 'xxxxx/xxxxx/xxxxxx/';
$filecount = 0;
$d = dir($dir);
while ($f = $d->read()) {
if(($f!= ".") && ($f!= "..")) {
if(!is_dir($f)) $filecount++;
}
}
echo 'there are currently ',$filecount,' files <br><br>';
$rep = "xxxxxxxx/xxxxxx/xxxx/";
$dir = opendir($rep);
function dd($date) {
return date("m/d/Y H:i:s",$date);
}
while ($f = readdir($dir)) {
if(is_file($rep.$f)) {
echo "<div class='box'>";
echo "<li>Name: $f";
echo "<li><b><a href='xxxxxxxx/$f'>Download</a></b> <font color=red>(Right-Click, Save As...) </font>";
echo "<li><b><a href='deletefiles.php?file=holidayuploads/$f&page=getcontent_holidays.php' onClick='return confirmSubmit()'>Delete</a></b>";
echo "<li>Size: ".filesize($rep.$f)." bytes";
echo "<li>Creation: ".dd(filectime($rep.$f));
echo "<li>Modification: ".dd(filemtime($rep.$f));
echo "<li>Thumb:<br><img src='holidayuploads/$f' width='150px'>";
echo "</div>";
echo "<br><br>";
}
}closedir($dir); ?>
<?php
}
?>
</body>
</html>
Now the problem is when i click delete is goes to a page called deletefiles.php where i have
<?php
#!/usr/bin/php
$do = unlink("$file");
if($do=="1"){
echo "The file was deleted successfully. <meta http-equiv='refresh' content='2;url=$page'>";
} else { echo "There was an error trying to delete the file."; }
?>
then redirects back to the main page, this is where i have a problem, everytime i do it asked me to log in agian, is there a way around this?
Thanks
Ryan
Im running into a problem, I have a single page login that displays the contents of a directory....
<hmtl>
<head>
<script LANGUAGE="JavaScript">
<!--
function confirmSubmit()
{
var agree=confirm("This will delete this File Permanently. Do you want to continue?");
if (agree)
return true ;
else
return false ;
}
// -->
</script>
</head>
<body>
<?php
$username = "xxxxxxx";
$password = "xxxxxxx";
if ($_POST['txtUsername'] != $username || $_POST['txtPassword'] != $password) {
?>
<center>
<form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<h1>Login <br> Holidays Get Published</h1><br>
<p><label for="txtUsername">Username:</label> <br />
<input type="text" title="Enter your Username" name="txtUsername" /></p>
<p><label for="txtpassword">Password:</label> <br /><input type="password" title="Enter your password" name="txtPassword" /></p>
<p><input type="submit" name="Submit" value="Login" class="buttons"/><br><br></p></form>
</center>
<?php
}
else {
?>
<?
$dir = 'xxxxx/xxxxx/xxxxxx/';
$filecount = 0;
$d = dir($dir);
while ($f = $d->read()) {
if(($f!= ".") && ($f!= "..")) {
if(!is_dir($f)) $filecount++;
}
}
echo 'there are currently ',$filecount,' files <br><br>';
$rep = "xxxxxxxx/xxxxxx/xxxx/";
$dir = opendir($rep);
function dd($date) {
return date("m/d/Y H:i:s",$date);
}
while ($f = readdir($dir)) {
if(is_file($rep.$f)) {
echo "<div class='box'>";
echo "<li>Name: $f";
echo "<li><b><a href='xxxxxxxx/$f'>Download</a></b> <font color=red>(Right-Click, Save As...) </font>";
echo "<li><b><a href='deletefiles.php?file=holidayuploads/$f&page=getcontent_holidays.php' onClick='return confirmSubmit()'>Delete</a></b>";
echo "<li>Size: ".filesize($rep.$f)." bytes";
echo "<li>Creation: ".dd(filectime($rep.$f));
echo "<li>Modification: ".dd(filemtime($rep.$f));
echo "<li>Thumb:<br><img src='holidayuploads/$f' width='150px'>";
echo "</div>";
echo "<br><br>";
}
}closedir($dir); ?>
<?php
}
?>
</body>
</html>
Now the problem is when i click delete is goes to a page called deletefiles.php where i have
<?php
#!/usr/bin/php
$do = unlink("$file");
if($do=="1"){
echo "The file was deleted successfully. <meta http-equiv='refresh' content='2;url=$page'>";
} else { echo "There was an error trying to delete the file."; }
?>
then redirects back to the main page, this is where i have a problem, everytime i do it asked me to log in agian, is there a way around this?
Thanks
Ryan