Jump to content

File permissions button.


Russia

Recommended Posts

I currently have this:

 

PHP/b]

<?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>";  
}
?>
<table width=\"100%\"  border=\"0\" cellspacing=\"0\" cellpadding=\"3\" style=\"text-align:center;\">
     <tr>
	<th style="border:0px;"><b>File Name</b></th>
	<th style="border:0px;"><b>Needed Chmod</b></th>
	<th style="border:0px;"><b>Current Chmod</b></th>
</tr>
<?php 
        check_perms("cache","0777");
	check_perms("include/keys","0777");
	check_perms("backup","0777");
	check_perms("uploads","0777");
	check_perms("include/template","0777");
	check_perms("include/user","0777");
	check_perms("img","0777");
	check_perms("img/avatars","0777");
?>
</table>

 

Basicly I need that when all file permissions are correct you are allowed to go to the next page of the installation, if not there can be a refresh button, so that when you change permissions, you can refresh the page to see if the Continue Installation button is showing.

 

Thank You.

Link to comment
https://forums.phpfreaks.com/topic/169473-file-permissions-button/
Share on other sites

I have wrote it myself. But the page is blank. It is supposed to show a button at the bottom.

<?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>";
If($configmod =! $perm){
	If($correctperms){
		return False;
	}
}
} 
?> 
<table width=\"100%\"  border=\"0\" cellspacing=\"0\" cellpadding=\"3\" style=\"text-align:center;\"> 
         <tr> 
        <th style="border:0px;"><b>File Name</b></th> 
        <th style="border:0px;"><b>Needed Chmod</b></th> 
        <th style="border:0px;"><b>Current Chmod</b></th> 
    </tr> 
    <?php  
	global $correctperms = True;
        check_perms("../inc/config.php","0777"); 
        check_perms("install2.php","0777"); 

	If($correctperms){
		//Echo Continue Button Code.
		echo'<input type="button" onclick"window.location=''test.php''" value="Continue">';
	} else {
		//Echo Refresh Button Code
		echo'<input type="button" onclick"window.location.reload(true)" value="Refresh">';
	}
    ?> 
</table>

 

 

You have an HTML issue. You cannot have anything except <tr><td></td></tr> between  </tr> and </table>.

 

This line

global $correctperms = True;

 

Should be within your function.

function check_perms($path,$perm)
{
    global $correctperms = True;
...

Like this?

 

<?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>";
   If($configmod =! $perm){
      If($correctperms){
         return False;
      }
   }
} 
?>
<table width=\"100%\"  border=\"0\" cellspacing=\"0\" cellpadding=\"3\" style=\"text-align:center;\">
         <tr>
        <th style="border:0px;"><b>File Name</b></th>
        <th style="border:0px;"><b>Needed Chmod</b></th>
        <th style="border:0px;"><b>Current Chmod</b></th>
    </tr>
    <?php  
function check_perms($path,$perm)
{
    global $correctperms = True;
        check_perms("../inc/config.php","0777"); 
        check_perms("install2.php","0777"); 

<tr><td>
      If($correctperms){
         //Echo Continue Button Code.
         echo'<input type="button" onclick"window.location=''test.php''" value="Continue">';
      } else {
         //Echo Refresh Button Code
         echo'<input type="button" onclick"window.location.reload(true)" value="Refresh">';
      }
</td></tr>
    ?>
</table>

No no. Not like that. The first four lines of your code should read

<?php 
function check_perms($path,$perm) 
{ 
    global $correctperms;

 

You should remove the folowing line

global $correctperms = True;

 

Hope that clears up what I meant earlier.

 

However after looking at your code further this section:

   If($configmod =! $perm){
      If($correctperms){
         return False;
      }
   }

 

needs to be changed to

   If($configmod != $perm){
      $correctperms = false;
      }
      else {
            $correctperms = true;
      }
   }

 

Also

<tr><td> need to be echo "<tr><td>"; and

</td></tr> need to be echo "</td></tr>";

I think I got it:

 

<?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>";  
}  
if ($chmods = "0777")
{
test continue
}
else
{
test refresh
}
?>

<table id="notice" align="center" width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\">
         <tr>
        <th align="left" style="border:0px;"><b>File/Folder Name</b></th>
        <th align="left" style="border:0px;"><b>Needed Chmod</b></th>
        <th align="left" style="border:0px;"><b>Current Chmod</b></th>
    </tr>
    <?php 
        check_perms("install2.php","0777");
        check_perms("../inc/config.php","0777");

    ?>

 

What am I doing wrong? It shows a blank page...

 

Hey Cory, whats ur msn? I would like to add you to my buddy list.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.