Forum Moderators: coopster
<?
if((!$activate) ¦¦ (!file_exists("engines/".$activate))){
$dir = "engines/";
$d = dir($dir);
while($f = $d->read()) {
if(($f!= ".") && ($f!= "..")) {
$html .= "\n<p><a href=\"".$PHP_SELF."?activate=".$f."\">".basename($f,".php")."</p>";
}
}
echo "<html><head><title>Activate</title><style type=text/css>p { font-size:25pt; } a {text-decoration:none; border-bottom-color:0000ff; border-bottom-width:1; border-bottom-style:dotted; }</style></head><body link=blue alink=blue vlink=blue><h1 align=center>Activate which engine?</h1><hr width=85%><br>".$html;
} else {
$error = 0;
include("engines/$activate");
if($error) {
echo "failed";
} else {
if(@unlink("engines/$activate")) {
echo "Engine Successfully installed";
} else {
echo "Engine successfully installed. <b>Unable to delete temp files.</b>";
}
}
}
?>
it is used to install patches for a site when the user is ready
it works fine except that it won't delete the setup file and returns the error message the file has 0777 permissions why won't it delete?
That may not be right, but you definitely need to fix that for starters.
If it still doesn't work, upon failure echo out the full path of the file you are trying to delete and make sure it is where you think it is.
Tom
$error = 0;
include("engines/$activate");
if($error)
This is the problem. It means that your test for an error is always false. The problem is not with the if statement per se so much as the fact that your $error variable is meaningless. You statement is the equivalent of
if (false)
which will always evaluate to false. You have to put the $error=0 at the top of your script to initialize it, and then set it to something else if there is an error.
<?
if($file = fopen("somepage.php",w)){
fputs($file,"<? header(\"Location:somefolder/index.php\");?>");
fclose($file);
} else {
$error = 1;
}
?>
the problem is the unlink never works it always returns
Engine successfully installed. <b>Unable to delete temp files.</b>
By default, though, you would get a warning unless you have error reporting set to suppress warnings.
Why don't you try this. Right above the unlink, do this
$msg = (file_exists("engines/$activate"))? "<h1>File found</h1>" : "<h1>File NOT found</h1>";
echo $msg;
If the file is found and it still is not unlinking, perhaps it's a safe mode issue?
Tom
also if the file didn't exist wouldn't the top line catch itif((!$activate) ¦¦ (!file_exists("engines/".$activate))){
Not necessarily, since you have an OR clause there in which you are also checking to see if there is no
$activatevariable. Try checking the file's existence again right before you
unlinkit (and take the error suppression off as ergophobe suggested until you have figured out the issue)...
sorry for all the unneccessary trouble