Page 1 of 1

[Script] Create User Accounts within Madsonic

Unread postPosted: 04 Apr 2013, 13:53
by Madevil
Hi,

i wrote a short windows script to create User Accounts within Madsonic.

i used a special wget version which can handle self signed certificates if you use SSL.

NEW: Set Default Security GroupID & new Role searchRole

REST API 1.9.2 needed (Madsonic 5.0)

Code: Select all
::::::::::::::::::::::::::::
:: Create Madsonic Acount ::
::::::::::::::::::::::::::::

:: Create Madsonic Useraccounts
:: edit username/password/serverlink to your need

set username=admin
set password=admin
set serverlink=http://127.0.0.1:4040

:::::::::::::::::::::::::::::::::::::::::::::::::

set wgetsettings=--spider --no-check-certificate --cookies=on --keep-session-cookies --save-cookies=%temp%\cookie.txt

.\bin\wget %wgetsettings% --user-agent=Mozilla "%serverlink%/login.view?user=%username%&password=%password%"

:: Create Backup Admin
.\bin\wget %wgetsettings% --load-cookies=%temp%\cookie.txt --referer="%serverlink%" "%serverlink%/rest/createUser.view?u=%username%&p=%password

%&v=1.9.2&c=remoteregister&username=sysop&password=sysop1$&email=sysop@home.com&adminRole=true&settingsRole=true&streamRole=true&jukeboxRole=true&downloadRole=true

&uploadRole=true&playlistRole=true&coverartRole=true&commentRole=true&podcastRole=true&shareRole=true&coverArtRole=true&commentRole=true&searchRole=true&groupId=0"

:: Create Guest
.\bin\wget %wgetsettings% --load-cookies=%temp%\cookie.txt --referer="%serverlink%" "%serverlink%/rest/createUser.view?u=%username%&p=%password

%&v=1.9.2&c=remoteregister&username=guest&password=guest2$&email=guest@home.com&settingsRole=true&streamRole=true&settingsRole=false&jukeboxRole=false&downloadRole

=false&uploadRole=false&playlistRole=false&coverartRole=false&commentRole=false&podcastRole=false&shareRole=false&searchRole=false&groupId=1"

:: Create Friend
.\bin\wget %wgetsettings% --load-cookies=%temp%\cookie.txt --referer="%serverlink%" "%serverlink%/rest/createUser.view?u=%username%&p=%password

%&v=1.9.2&c=remoteregister&username=friend&password=friend3$&email=friend@home.com&settingsRole=true&streamRole=true&jukeboxRole=false&downloadRole=true&uploadRole

=true&playlistRole=true&coverartRole=false&commentRole=false&podcastRole=false&shareRole=false&commentRole=true&searchRole=true&groupId=3"


best regards

Re: [Script] Create User Accounts within Madsonic

Unread postPosted: 05 Apr 2013, 05:02
by gurutech
I've added the following to the script, so it will prompt you for a username, password (which will NOT be hidden), email address, and access level.

To implement, add the following to the beginning of the script, just after the section where you add your "admin" ID and password and the server URL:
Code: Select all
set /p user= "Username: "
set /p userpw= "Password: "
set /p useremail= "E-Mail: "

echo 0 = FULL ACCESS
echo 1 = GUEST
echo 2 = FAMILY
echo 3 = FRIENDS
echo 4 = LIMITED
echo.
set /p accesslevel= "Enter # for Access Level: "


Then add the following line at the END of the script. Comment out the three existing lines (samples) to create a new admin, guest, and friend.

Code: Select all
.\bin\wget %wgetsettings% --load-cookies=%temp%\cookie.txt --referer="%serverlink%" "%serverlink%/rest/createUser.view?u=%username%&p=%password%&v=1.9.2&c=remoteregister&username=%user%&password=%userpw%$&email=%useremail%&settingsRole=true&streamRole=true&jukeboxRole=false&downloadRole=false&uploadRole=false&playlistRole=true&coverartRole=false&commentRole=false&podcastRole=false&shareRole=true&commentRole=true&searchRole=true&groupId=%accesslevel%" >nul


I'm working on adding capability to set permissions on individual components (Jukebox, streaming, download, upload, etc...) through being prompted. Will reply again with that update.

Re: [Script] Create User Accounts within Madsonic

Unread postPosted: 23 Mar 2014, 04:09
by e1z0
Creating user accounts using php as easy as shell scripts for example for external php registration. So here is the code:

Code: Select all
// ADMINISTRATOR ACCOUNT INFO
$ADMIN = 'admin';
$PASS = 'verylongpassword';
$HOST = 'http://127.0.0.1:4040'; # we not use external URL for security reasons
// USER PERMISSIONS
$STREAMING='true';
$JUKEBOX='false';
$DOWNLOAD='false';
$UPLOAD='false';
$PLAYLIST='true';
$COVERART='false';
$COMMENT='false';
$PODCAST='false';
$SHARE='false';
$COMMENT='true';
$SEARCH='true';
$GROUPID='3';


Code: Select all
// function to register user to Madsonic database using external API's
function madsonic_regiser($username,$password,$email) {
    global $ADMIN, $PASS, $HOST, $STREAMING, $JUKEBOX, $DOWNLOAD, $UPLOAD, $PLAYLIST, $COVERART, $COMMENT, $PODCAST, $SHARE, $COMMENT, $SEARCH, $GROUPID, $INVITE;     
QUERY = $HOST."/rest/createUser.view?u=".$ADMIN."&p=".$PASS."&v=1.9.2&c=remoteregister&username=".$username."&password=".$password."&email=".$email."&settingsRole=true&streamRole=".$STREAMING."&jukeboxRole=".$JUKEBOX."&downloadRole=".$DOWNLOAD."&uploadRole=".$UPLOAD."&playlistRole=".$PLAYLIST."&coverartRole=".$COVERART."&commentRole=".$COMMENT."&podcastRole=".$PODCAST."&shareRole=".$SHARE."&commentRole=".$COMMENT."&searchRole=".$SEARCH."&groupId=".$GROUPID;
$ch = curl_init($QUERY);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);

Cheers!  :)
}