Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel authored and daniel committed Jun 14, 2024
1 parent 5a09587 commit 90ab24a
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions install/fix_dirs_permissions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
require_once '../videos/configuration.php';

if (!isCommandLineInterface()) {
return die('Command Line only');
}

function setPermissions($directories) {
foreach ($directories as $dir) {
if (is_dir($dir)) {
echo "Set Permission ".PHP_EOL;
setPermissionsRecursively($dir);
} else {
echo "The path $dir is not a directory.\n";
}
}
}

function setPermissionsRecursively($dir) {
// Ensure the directory path is safe to use
$safeDir = escapeshellarg($dir);

// Set directory permissions to 755
exec("find $safeDir -type d -exec chmod 755 {} +");

// Set file permissions to 644
exec("find $safeDir -type f -exec chmod 644 {} +");

// Change ownership to www-data
exec("chown -R www-data:www-data $safeDir");
}

// Example usage
$directories = [
"{$global['systemRootPath']}videos" . DIRECTORY_SEPARATOR
];

setPermissions($directories);

echo "Permissions have been set successfully.\n";

?>

0 comments on commit 90ab24a

Please sign in to comment.