designtopack/public/assets/php/change-user-roles.php
2025-01-20 14:53:22 +01:00

38 lines
911 B
PHP

<?php
$directory = __DIR__ . '/../../site/accounts';
foreach (glob($directory . '/*/index.php') as $filePath) {
$data = include $filePath;
if (is_array($data) && array_key_exists('role', $data)) {
switch ($data["role"]) {
case "client":
$newRoleValue = "0_client";
break;
case "pochet":
$newRoleValue = "1_pochet";
break;
case NULL:
$newRoleValue = "admin";
break;
}
if (isset($newRoleValue)) {
$data['role'] = $newRoleValue;
$exportedData = "<?php\n\nreturn " . var_export($data, true) . ";\n";
file_put_contents($filePath, $exportedData);
echo "Fichier modifié : $filePath\n";
} else {
echo "Fichier ignoré ou format inattendu : $filePath\n";
}
} else {
echo "Fichier ignoré ou format inattendu : $filePath\n";
}
}
echo "Modification terminée.\n";