Skip to content

Commit 7aab22b

Browse files
author
Daniel Neto
committed
Update
1 parent 9e3500f commit 7aab22b

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

install/makeAdmin.php

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,33 @@
33
require_once '../videos/configuration.php';
44

55
if (!isCommandLineInterface()) {
6-
return die('Command Line only');
6+
die('Command Line only');
7+
}
8+
9+
// Check if a username is passed as a command line argument
10+
$userName = isset($argv[1]) ? trim($argv[1]) : '';
11+
12+
if (empty($userName)) {
13+
echo "Enter the username or press enter to skip:";
14+
echo "\n";
15+
ob_flush();
16+
$userName = trim(readline(""));
717
}
8-
echo "Enter the username or press enter to skip:";
9-
echo "\n";
10-
ob_flush();
11-
$userName = trim(readline(""));
1218

1319
if (!empty($userName)) {
14-
$sql = "UPDATE {$global['tablesPrefix']}streamers SET isAdmin = 1 where user = '" . $userName . "'";
15-
echo $sql.PHP_EOL;
20+
$sql = "UPDATE {$global['tablesPrefix']}streamers SET isAdmin = 1 WHERE user = '" . $userName . "'";
21+
echo $sql . PHP_EOL;
22+
1623
$insert_row = $global['mysqli']->query($sql);
1724

1825
if ($insert_row) {
19-
echo "User created".PHP_EOL;
26+
echo "User updated to admin successfully." . PHP_EOL;
2027
} else {
2128
die($sql . ' Error : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
2229
}
30+
} else {
31+
echo "No username provided. Exiting." . PHP_EOL;
2332
}
33+
2434
echo "Bye";
25-
echo "\n";
26-
die();
35+
?>

0 commit comments

Comments
 (0)