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

28 lines
676 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;
}
$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";
}
}
echo "Modification terminée.\n";