Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Neto committed Dec 30, 2024
1 parent 9e3500f commit 7aab22b
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions install/makeAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
?>

0 comments on commit 7aab22b

Please sign in to comment.