Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.