Jump to content

[SOLVED] Having trouble getting a function to work


N1CK3RS0N

Recommended Posts

Greetings.

 

I'm doing step 3 of the installation of my CMS now, which is to check file permissions. Can't seem to get it to work right...

 

Below is the code I'm using. I'm echoing $permissions in my template file. Outputs nothing...

 

<?php
function check_perms( $path, $file, $perm )
{
clearstatcache();
$configmod = substr(sprintf('%o', fileperms($path)), -4);
$text = (($configmod != $perm) ? "color: #e30000;" : "color: #88e300;");
$file_perm = "<tr>\n";
$file_perm .= "<td style=\"$text\">$file</td>\n";
$file_perm .= "<td style=\"$text\">$perm</td>\n";
$file_perm .= "<td style=\"$text\">$configmod</td>\n";
$file_perm .= "</tr>\n";
return $file_perm;
}

function permissions()
{
echo "<table class=\"form_area\" width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"10\">";
check_perms( "../config.php", "config.php", "0777" );
check_perms( "../downloads/uploads", "downloads/uploads/", "0777" );
check_perms( "../images/uploads", "images/uploads/", "0777" );
echo "</table>";
}

switch ($_GET['step'])
{

case 3:
$permissions = permissions();
include('templates/default/step3.tpl');
break;
?>

You need to echo out the functions

 

function permissions()
{
   echo "</pre>
<table class='\"form_area\"' width='\"100%\"' border='\"0\"' cellpadding='\"0\"' cellspacing='\"10\"'>";
   echo check_perms( "../config.php", "config.php", "0777" );
   echo check_perms( "../downloads/uploads", "downloads/uploads/", "0777" );
   echo check_perms( "../images/uploads", "images/uploads/", "0777" );
   echo "</table>"

Why don't you return a string...  Then you can echo $permissions wherever you want.

 

function permissions()
{
   $perm = "</pre>
<table class='\"form_area\"' width='\"100%\"' border='\"0\"' cellpadding='\"0\"' cellspacing='\"10\"'>";
   $perm .= check_perms( "../config.php", "config.php", "0777" );
   $perm .= check_perms( "../downloads/uploads", "downloads/uploads/", "0777" );
   $perm .= check_perms( "../images/uploads", "images/uploads/", "0777" );
   $perm .= "</table>";<br><br>   return $perm

Why don't you return a string...  Then you can echo $permissions wherever you want.

 

function permissions()
{
   $perm = "<table class=\"form_area\" width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"10\">";
   $perm .= check_perms( "../config.php", "config.php", "0777" );
   $perm .= check_perms( "../downloads/uploads", "downloads/uploads/", "0777" );
   $perm .= check_perms( "../images/uploads", "images/uploads/", "0777" );
   $perm .= "</table>";

   return $perm;
}

 

Thanks worked. You the man. :)

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.