Page 1 of 1

[Tutorial] Registration Engine

Posted: 07 Jul 2013, 22:46
by gurutech
Well, it seems my hard work (on and off, of course!) has finally paid off. While it doesn't integrate directly with Facebook, I have successfully created a registration engine that allows new users to create their own username on my Madsonic server.

Pre-requisites:
1) A server running MySQL (can be the same server you are running Madsonic from)
2) A server with Sendmail or PostFix installed and configured to send email (does not need to "receive" email)
3) The registration script, which can be downloaded here: http://www.html-form-guide.com/files/ph ... onForm.zip

Instructions:
1) Unzip the downloaded files into your main website folder, so all of the files are under a subfolder called "Source".
2) Edit the "source/include/membersite_config.php" file in a text editor or whatever you use (I use Dreamweaver).
2a) Set the "website name" to the name of your site - don't use the URL for your site, just the name.
2b) Set the administrator's email address.
2c) Enter the hostname (or IP address), username, password, database name, and table name for your MySQL server
(table name can be anything you want - the script will create the table the first time it is run)
2d) (optional) Create a "random" key.
3) Edit the "source/include/fg_membersite.php" file.
3a) Change "$this->sitename" to your site, without the http:// in front.
3b) Copy the "random" key from the previous file and paste it here, under "rand_key"
3c) Scroll down to almost the bottom of this file, to around line 790 or so, or where you find the lines:

Code: Select all

$insert_query = 'insert into '.$this->tablename.'(
                name,
                email,
                username,
                password,
                confirmcode
                )
                values
                (
                "' . $this->SanitizeForSQL($formvars['name']) . '",
                "' . $this->SanitizeForSQL($formvars['email']) . '",
                "' . $this->SanitizeForSQL($formvars['username']) . '",
                "' . md5($formvars['password']) . '",
                "' . $confirmcode . '"
                )';
Just below these lines, you will see a line stating "return true". ABOVE this line, but BELOW the "return false", add the following lines:

Code: Select all

		$url = "http://(YOUR SITE NAME)/rest/createUser.view?u=(YOUR ADMIN NAME)&p=(YOUR ADMIN PASSWORD)&v=1.9.5&c=remoteregister&username=". $this->SanitizeForSQL($formvars['username']) ."&password=". ($formvars['password']) ."&email=". $this->SanitizeForSQL($formvars['email']) ."&settingsRole=true&streamRole=true&jukeboxRole=false&downloadRole=false&uploadRole=false&playlistRole=true&coverartRole=false&commentRole=false&podcastRole=false&shareRole=true&searchRole=true&groupID=4";
		$curl = curl_init();
		curl_setopt($curl, CURLOPT_URL, $url);
		curl_exec($curl);
		curl_close($curl);
Replace the parts (YOUR _____ HERE) with your information.
4) Edit the "thank-you-regd.html" file. At the last line, beginning with "a href", change the "login.php" name to your site's homepage.

Save all files as you move on to the next one.

Last step is to go into Madsonic, under Settings/General, scroll to the bottom, and create a "link" in the login message - something similar to this:

Code: Select all

If you don't have an account, click {link:HERE|http://yoursite.com/source/register.php} to create an account.   You will be able to login after clicking the link in the confirmation email that will be sent to you.
Save these settings, and then logout and you will see this link on your login screen.

Please post up any issues you run into, and I'll see what I can do to resolve them for you.

Re: [Tutorial] Registration Engine

Posted: 09 Jul 2013, 23:53
by Ricky1252
Wow, vary nice. I don't have time right now but I'm definitely going to check this out! Thanks guru

Re: [Tutorial] Registration Engine

Posted: 10 Jul 2013, 03:43
by gurutech
It took me about an hour to get everything working, but that included finding the source script online, modifying it to meet my system specs, troubleshooting a mailflow issue (I forward my mail through smtp.gmail.com, and I had the wrong port # assigned, and no SSL certificate!), and typing up the tutorial.

I'm sure following my instructions should only take 15-20 mins, unless I messed up somewhere!

Re: [Tutorial] Registration Engine

Posted: 25 Jul 2013, 00:59
by kleverbear
Hi there,
I am having a slight problem getting this to work. I have the latest Beta build of Madsonic on a Ubuntu 12.04 Lts. I tested the script in Apache and it does populate in SQL, once moved to the jetty/xxxx/webapp/ folder it will not redirect. My site page?. Any ideas of what might be causing it?


edit: removed url

Re: [Tutorial] Registration Engine

Posted: 25 Jul 2013, 01:35
by gurutech
The script doesn't go into the "jetty" folder. It goes on your machine, under the /var/www/html folder.

I'm sure you could adjust the script to allow it to be placed in the jetty folder, but I haven't looked into that.

Re: [Tutorial] Registration Engine

Posted: 25 Jul 2013, 02:19
by kleverbear
Thank you gurutech
So as i stated before i did test it in Apache and it works to an extent, it will populate SQL but nothing goes into Sonic list of users. I just retested again to make sure and it still does the same it wont populate in to MadSonic, any additional pointers?


I figured out my error, i forgot to take of the parentheses out of this line

Code: Select all

 $url = "http://(YOUR SITE NAME)/rest/createUser.view?u=(YOUR ADMIN NAME)&p=(YOUR ADMIN PASSWORD)&v=1.9.5&c=remoteregister&username="

Re: [Tutorial] Registration Engine

Posted: 25 Jul 2013, 03:08
by gurutech
That'll do it! Glad you got it fixed!

Re: [Tutorial] Registration Engine

Posted: 22 Aug 2013, 14:09
by Metzlmane
If i place the curl-command at the position you mentioned, the confirmation mail is useless, because the account is created with submitting the data. This means everyone can register his account on madsonic, you just see it happening.
I tried to set the curl-command at a other part of the code, but there is no chance to geht the pw, because it's stored as md5-checksum (which is the correct way to do it).

Re: [Tutorial] Registration Engine

Posted: 23 Aug 2013, 00:48
by gurutech
But if you look in the MySQL database, you can see who hasn't "confirmed" their registration, and I periodically go through Madsonic and delete those users. And the bonus to that is they can't re-register using the same email address because they are still in the MySQL database, but not in Madsonic.

Re: [Tutorial] Registration Engine

Posted: 08 Sep 2013, 15:13
by gurutech
Wondering who has downloaded this and set it up, and if there have been any issues that aren't already mentioned here.

Trying to find some time to do some updates...

Re: [Tutorial] Registration Engine

Posted: 30 Sep 2013, 23:17
by Clayboy
does this also work on windows... or just linux

Re: [Tutorial] Registration Engine

Posted: 01 Oct 2013, 01:22
by gurutech
Clayboy wrote:does this also work on windows... or just linux

Honestly, I never checked to see... :oops: If the registration script works under Windows, then this should work as well, provided your setup meets the prerequisites I defined in my initial post...

Re: [Tutorial] Registration Engine

Posted: 26 Jun 2014, 07:39
by silversix311
I tried to get this working on my windows machine, but i could not get it figured out for the life of me...

I have no idea how to setup MySQL or the Mail server i was trying to run so i gave up...

Re: [Tutorial] Registration Engine

Posted: 01 Dec 2014, 23:09
by DoCC
very nice, i will give this a try.
an even better idea would be to switch the entire controlfeatures to a MySQL based db.
all the music stuff can remain as is, but the rest would be a great thing to have it outside xD

Re: [Tutorial] Registration Engine

Posted: 04 Dec 2014, 03:50
by gurutech
I'm sure the coding could be altered to save user info into an LDAP directory, and then use LDAP for authentication in Madsonic, but I'm not that experienced as a coder, so I wouldn't know how to do that.

Re: [Tutorial] Registration Engine

Posted: 07 Dec 2014, 01:13
by DoCC
lol your suggestion is a lil bit insane ... imagine beeing able to inject your AD server via an open webfrontend : ) uuuaaaaahhhh ^^

Re: [Tutorial] Registration Engine

Posted: 08 Dec 2014, 17:45
by gurutech
If LDAP could be kept separate from AD, that would still work. But yeah, huge security issue if they are tied together...

Re: [Tutorial] Registration Engine

Posted: 08 Dec 2014, 20:48
by DoCC
thats the point, i got a MS Active Directory Domain here ...
just some services are running on linux.

In this case i guess it would make no sence to be able to deal with AD .