' . (($perms & 0x0100) ? 'r' : '-') . ''; $perm_string .= '' . (($perms & 0x0080) ? 'w' : '-') . ''; $perm_string .= '' . (($perms & 0x0040) ? (($perms & 0x0800) ? 's' : 'x' ) : (($perms & 0x0800) ? 'S' : '-')) . ''; // Group $perm_string .= '' . (($perms & 0x0020) ? 'r' : '-') . ''; $perm_string .= '' . (($perms & 0x0010) ? 'w' : '-') . ''; $perm_string .= '' . (($perms & 0x0008) ? (($perms & 0x0400) ? 's' : 'x' ) : (($perms & 0x0400) ? 'S' : '-')) . ''; // World $perm_string .= '' . (($perms & 0x0004) ? 'r' : '-') . ''; $perm_string .= '' . (($perms & 0x0002) ? 'w' : '-') . ''; $perm_string .= '' . (($perms & 0x0001) ? (($perms & 0x0200) ? 't' : 'x' ) : (($perms & 0x0200) ? 'T' : '-')) . ''; } else { $perm_string = "no access"; } return $perm_string; } function get_perms_octal($filename) { if (file_exists($filename)) { $perms_oct = substr(sprintf('%o', fileperms($filename)), -3); } else { $perms_oct = '999'; } return $perms_oct; } function prepare_htaccess_password_protection($filename) { $new_htaccess = $filename; $new_htaccess = 'new_htaccess'; // if (file_exists($new_htaccess)) { //$template_htaccess = '_htaccess'; $my_htpasswd = '.htpasswd'; $fileout = fopen($new_htaccess, 'w') or exit('Unable to open file ' . $new_htaccess . '!'); $my_document_root_path = $_SERVER['DOCUMENT_ROOT']; $my_html_path = dirname($_SERVER['PHP_SELF']); fwrite($fileout, 'AuthUserFile '); fwrite($fileout, $my_document_root_path); fwrite($fileout, $my_html_path); fwrite($fileout, '/' . $my_htpasswd . "\n"); // early version - hardcoded output - intended to be read from template fwrite($fileout, 'AuthName "permissioncheck password protection"' . "\n"); fwrite($fileout, 'AuthType Basic' . "\n"); fwrite($fileout, '' . "\n"); fwrite($fileout, 'require valid-user' . "\n"); fwrite($fileout, '' . "\n"); //fwrite($fileout, '' . "\n"); fwrite($fileout, '' . "\n"); fwrite($fileout, 'order deny,allow' . "\n"); fwrite($fileout, 'deny from all' . "\n"); fwrite($fileout, '' . "\n"); fclose($fileout); $success = false; // } else { $success = false; // } return $success; }