forked from Ctrlpanel-gg/panel
-
Notifications
You must be signed in to change notification settings - Fork 1
/
transferusers.php
95 lines (79 loc) · 3.15 KB
/
transferusers.php
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
/*
* ---------CONFIG----------
*
* FILL IN THE DATABASE INFORMATION
*/
function generateRandomString($length = 8) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
echo "ENTER YOUR PTERODACTYL DATABASE HOST: ";
$PTERODACTYL_HOST = trim(fgets(STDIN));
echo "ENTER YOUR PTERODACTYL DATABASE USER: ";
$PTERODACTYL_USER = trim(fgets(STDIN));
echo "ENTER YOUR PTERODACTYL DATABASE PASSWORD: ";
$PTERODACTYL_PASSWORD = trim(fgets(STDIN));
echo "ENTER YOUR PTERODACTYL DATABASE DATABASE NAME: ";
$PTERODACTYL_DATABASE = trim(fgets(STDIN));
$pterodb = new mysqli($PTERODACTYL_HOST, $PTERODACTYL_USER, $PTERODACTYL_PASSWORD, $PTERODACTYL_DATABASE);
if (!$pterodb) {
die('Connect Error (' . mysqli_connect_errno() . ') '
. mysqli_connect_error());
}
echo "ENTER YOUR CPGG DATABASE HOST: ";
$CPGG_HOST = trim(fgets(STDIN));
echo "ENTER YOUR CPGG DATABASE USER: ";
$CPGG_USER = trim(fgets(STDIN));
echo "ENTER YOUR CPGG DATABASE PASSWORD: ";
$CPPPG_PASSWORD = trim(fgets(STDIN));
echo "ENTER YOUR CPGG DATABASE DATABASE NAME: ";
$CPGG_DATABASE = trim(fgets(STDIN));
$cpggdb = new mysqli($CPGG_HOST, $CPGG_USER, $CPPPG_PASSWORD, $CPGG_DATABASE);
if (!$cpggdb) {
die('Connect Error (' . mysqli_connect_errno() . ') '
. mysqli_connect_error());
}
echo "ENTER THE AMOUNT OF CREDITS A USER SHOULD START WITH (default: 250)";
$init_credits = trim(fgets(STDIN));
if (empty($init_credits)) {
$init_credits = 250;
}
echo "ENTER THE AMOUNT OF SERVERS A USER SHOULD START WITH (default: 2)";
$serverlimit = trim(fgets(STDIN));
if (empty($serverlimit)) {
$serverlimit = 2;
}
$userSQL = "SELECT * FROM `users`";
$pteroUserResult = mysqli_query($pterodb, $userSQL);
$cpggUserResult = mysqli_query($cpggdb, $userSQL);
while ($pterouser = $pteroUserResult->fetch_assoc()) {
$id = $pterouser["id"];
$username = $pterouser["username"];
$email = $pterouser['email'];
$password = $pterouser['password'];
$now = date("Y-m-d H:i:s");
$role = "member";
$referral_code = generateRandomString();
try {
if ($pterouser["root_admin"]) {
$role = "admin";
}
$checkusersql = mysqli_query($cpggdb, "SELECT * FROM `users` WHERE `email` = '$email'");
if (mysqli_num_rows($checkusersql) > 0) {
echo "User ".$email." exists. Skipping! \n";
} else {
$sql = "INSERT INTO `users` (`id`, `name`, `role`, `credits`, `server_limit`, `pterodactyl_id`, `avatar`, `email`, `email_verified_at`, `password`, `remember_token`, `created_at`, `updated_at`, `ip`, `last_seen`, `discord_verified_at`, `suspended`, `referral_code`) VALUES (NULL, '$username', '$role', '$init_credits', '$serverlimit', '$id', NULL, '$email', NULL, '$password', NULL, '$now', NULL, NULL, NULL, NULL, '0', '$referral_code')";
$res = mysqli_query($cpggdb, $sql);
echo "User ".$email." created \n";
}
} catch (Exception $e) {
echo "Fail: " . $e;
}
}
?>