...

View Full Version : Only show button if... ?



TomBower
06-20-2010, 10:39 AM
<table width="100%" border="0" cellpadding="3" style="text-align:center;">
<tr>
<th style="border:0px;"><b>File Name</b></th>
<th style="border:0px;"><b>Required Chmod</b></th>
<th style="border:0px;"><b>Current Chmod</b></th>
</tr>
<?php
function check_perms($path,$perm)
{
clearstatcache();
$configmod = substr(sprintf('%o', fileperms($path)), -4);
$trcss = (($configmod != $perm) ? "background-color:#fd7a7a;" : "background-color:#91f587;");
echo "<tr style=".$trcss.">";
echo "<td style=\"border:0px;\">". $path ."</td>";
echo "<td style=\"border:0px;\">$perm</td>";
echo "<td style=\"border:0px;\">$configmod</td>";
echo "</tr>";
}

check_perms("img","777");
check_perms("config.php","777");
check_perms("cache","777");

?>
</table>
<p><br />
<a class="button" href="requirements.php">Proceed to 'MySQL Configuration'</a><br />


How could I make it so that the 'Proceed' button only appears if the perms are correct and if they aren't, show a 'recheck' button?


Thankyou for your time taken to read this.

DJCMBear
06-20-2010, 11:01 AM
You could do this.


$pram1 = check_perms("img","777");
$pram2 = check_perms("config.php","777");
$pram3 = check_perms("cache","777");

?>
</table>
<p><br />
<?php
if($pram1 && $pram2 && $pram3)
{
print <<<EOD
<a class="button" href="requirements.php">Proceed to 'MySQL Configuration'</a>
EOD;
}
else
{
// other btn here
}
?>
<br />



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum