Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Feb 2010
    Posts
    81
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Only show button if... ?

    PHP Code:
    <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.

  • #2
    Senior Coder DJCMBear's Avatar
    Join Date
    Mar 2010
    Location
    United Kindom
    Posts
    1,173
    Thanks
    14
    Thanked 136 Times in 136 Posts
    You could do this.
    PHP Code:
        $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 />
    Official BinPress hand picked coder.
    For anyone worried about SQL injection go have a look at my small yet powerful script here.
    Go Pledge for Light Table, if it hit's $300,000 Python and other languages will get added.
    I am 1 of 65,608 people to get a Pebble Watch :P


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •