From 7aab22b6b9a0b2d308325cea5710c7454ad1ac0e Mon Sep 17 00:00:00 2001 From: Daniel Neto Date: Mon, 30 Dec 2024 17:28:03 -0300 Subject: [PATCH] Update --- install/makeAdmin.php | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/install/makeAdmin.php b/install/makeAdmin.php index 766c4ee08..c7502820c 100644 --- a/install/makeAdmin.php +++ b/install/makeAdmin.php @@ -3,24 +3,33 @@ require_once '../videos/configuration.php'; if (!isCommandLineInterface()) { - return die('Command Line only'); + die('Command Line only'); +} + +// Check if a username is passed as a command line argument +$userName = isset($argv[1]) ? trim($argv[1]) : ''; + +if (empty($userName)) { + echo "Enter the username or press enter to skip:"; + echo "\n"; + ob_flush(); + $userName = trim(readline("")); } -echo "Enter the username or press enter to skip:"; -echo "\n"; -ob_flush(); -$userName = trim(readline("")); if (!empty($userName)) { - $sql = "UPDATE {$global['tablesPrefix']}streamers SET isAdmin = 1 where user = '" . $userName . "'"; - echo $sql.PHP_EOL; + $sql = "UPDATE {$global['tablesPrefix']}streamers SET isAdmin = 1 WHERE user = '" . $userName . "'"; + echo $sql . PHP_EOL; + $insert_row = $global['mysqli']->query($sql); if ($insert_row) { - echo "User created".PHP_EOL; + echo "User updated to admin successfully." . PHP_EOL; } else { die($sql . ' Error : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error); } +} else { + echo "No username provided. Exiting." . PHP_EOL; } + echo "Bye"; -echo "\n"; -die(); +?>