$v) { if (!trim($v)) { unset($lines[$k]); } else { if (trim($v) == $username) { echo "User:" . $username . " already banned.\n"; return; } } } $lines[] = $username; file_put_contents($banfile, "\n" . implode($lines) . "\n"); } } function change_user_email($username, $email) { global $config_dir; $username = strtolower($username); $userfile = $config_dir . '/users/' . $username; if (! file_exists($userfile)) { echo "User:" . $username . " Not Found\r\n"; return; } else { set_user_config($username, 'email', $email); } } function change_user_password($username, $password) { global $config_dir; $username = strtolower($username); $userfile = $config_dir . '/users/' . $username; if (! file_exists($userfile)) { echo "User:" . $username . " Not Found\r\n"; return; } else { file_put_contents($userfile, password_hash($password, PASSWORD_DEFAULT)); echo "Password changed for: " . $username . "\n"; echo "Password: " . $password . "\n"; } } function create_new($username, $password, $user_email) { global $config_dir; $workpath = $config_dir . "users/"; $keypath = $config_dir . "userconfig/"; $username = strtolower($username); $userFilename = $workpath . $username; $keyFilename = $keypath . $username; if (file_exists($userFilename)) { echo "User:" . $username . " Already Exists\r\n"; exit(); } if ($userFileHandle = @fopen($userFilename, 'w+')) { fwrite($userFileHandle, password_hash($password, PASSWORD_DEFAULT)); fclose($userFileHandle); chmod($userFilename, 0666); } $newkey = make_key($username); if ($userFileHandle = @fopen($keyFilename, 'w+')) { fwrite($userFileHandle, 'encryptionkey:' . $newkey . "\r\n"); fwrite($userFileHandle, 'email:' . $user_email . "\r\n"); fwrite($userFileHandle, "email_verified:true\r\n"); fclose($userFileHandle); chmod($userFilename, 0666); } echo "User: " . $username . " Created\r\n"; echo "Password: " . $password . "\n"; echo "Email: " . $user_email . "\n"; exit(0); } function make_key($username) { $key = openssl_random_pseudo_bytes(44); return base64_encode($key); }