N1CK3RS0N Posted January 23, 2009 Share Posted January 23, 2009 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; ?> Link to comment https://forums.phpfreaks.com/topic/142167-solved-having-trouble-getting-a-function-to-work/ Share on other sites More sharing options...
Maq Posted January 23, 2009 Share Posted January 23, 2009 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>" Link to comment https://forums.phpfreaks.com/topic/142167-solved-having-trouble-getting-a-function-to-work/#findComment-744712 Share on other sites More sharing options...
N1CK3RS0N Posted January 23, 2009 Author Share Posted January 23, 2009 Thanks that helped a bit, but I'm still having trouble. Its just echoing it where it is, instead of where the variable is. Ideas? Thanks Link to comment https://forums.phpfreaks.com/topic/142167-solved-having-trouble-getting-a-function-to-work/#findComment-744748 Share on other sites More sharing options...
Maq Posted January 23, 2009 Share Posted January 23, 2009 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 Link to comment https://forums.phpfreaks.com/topic/142167-solved-having-trouble-getting-a-function-to-work/#findComment-744758 Share on other sites More sharing options...
N1CK3RS0N Posted January 23, 2009 Author Share Posted January 23, 2009 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. Link to comment https://forums.phpfreaks.com/topic/142167-solved-having-trouble-getting-a-function-to-work/#findComment-744762 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.