-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcli.php
More file actions
81 lines (72 loc) · 1.87 KB
/
cli.php
File metadata and controls
81 lines (72 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
/**
* cli.php
*
* Quick way to update some parts of Storio from the command line
* Currently a WIP
*
* @package Storio
* @author Alex White
* @copyright 2022 Storio
* @link https://github.com/ialexpw/Storio
*/
include 'public/app/storio.app.php';
if(php_sapi_name() === 'cli') {
if(!empty($argv[1])) {
// Create a new user
if(strtolower($argv[1]) == 'create-user') {
// Check the user exists already
if(!file_exists('users/' . $argv[2])) {
// Password supplied
if(isset($argv[3])) {
// Hash the password
$usrPass = password_hash($argv[3], PASSWORD_DEFAULT);
// Default settings
$usrAr = array(
"enabled" => "true",
"upload" => "true",
"admin" => "false"
);
// Create with default perms
if(Storio::AddUser(strtolower($argv[2]), $usrPass, 1000, $usrAr)) {
exit("User created");
}else{
exit("Failed to create user");
}
}else{
exit("Supply a password");
}
}else{
exit("User exists");
}
}
// Set a password
if(strtolower($argv[1]) == 'set-password') {
// Check the user exists
if(file_exists('users/' . $argv[2])) {
// Password supplied
if(isset($argv[3])) {
// Load the user configuration
$usrCfg = Storio::UserConfig($argv[2]);
// Hash the new password
$usrCfg['passWord'] = password_hash($argv[3], PASSWORD_DEFAULT);
// Encode and resave the config
$usrCfgEncode = json_encode($usrCfg);
file_put_contents('users/configs/' . $argv[2] . '-cfg.json', $usrCfgEncode);
exit('Password updated');
}else{
exit('Supply a password');
}
}else{
exit('User not found');
}
}
// Create video thumbnails FFMPEG required
if(strtolower($argv[1]) == 'video-thumbs') {
exit();
}
}else{
exit('No params');
}
}
?>