[Tutorial] Registration Engine

Frequently asked questions. Tutorials, tips and tricks.
gurutech
Contributor
Contributor
Posts: 323
Joined: 02 Jan 2013, 04:56
Has thanked: 11 times
Been thanked: 105 times

[Tutorial] Registration Engine

Unread post by gurutech » 07 Jul 2013, 22:46

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.
Last edited by gurutech on 10 Jul 2013, 03:41, edited 1 time in total.
These users thanked the author gurutech for the post (total 3):
MadsonicRicky1252Andrusa

Ricky1252
Contributor
Contributor
Posts: 12
Joined: 18 Mar 2013, 01:13
Has thanked: 4 times
Been thanked: 7 times

Re: [Tutorial] Registration Engine

Unread post by Ricky1252 » 09 Jul 2013, 23:53

Wow, vary nice. I don't have time right now but I'm definitely going to check this out! Thanks guru

gurutech
Contributor
Contributor
Posts: 323
Joined: 02 Jan 2013, 04:56
Has thanked: 11 times
Been thanked: 105 times

Re: [Tutorial] Registration Engine

Unread post by gurutech » 10 Jul 2013, 03:43

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!

kleverbear
Posts: 2
Joined: 19 Jul 2013, 00:37
Has thanked: 1 time
Been thanked: 1 time

Re: [Tutorial] Registration Engine

Unread post by kleverbear » 25 Jul 2013, 00:59

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
Last edited by kleverbear on 25 Jul 2013, 02:42, edited 1 time in total.

gurutech
Contributor
Contributor
Posts: 323
Joined: 02 Jan 2013, 04:56
Has thanked: 11 times
Been thanked: 105 times

Re: [Tutorial] Registration Engine

Unread post by gurutech » 25 Jul 2013, 01:35

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.

kleverbear
Posts: 2
Joined: 19 Jul 2013, 00:37
Has thanked: 1 time
Been thanked: 1 time

Re: [Tutorial] Registration Engine

Unread post by kleverbear » 25 Jul 2013, 02:19

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="
These users thanked the author kleverbear for the post:
Madsonic

gurutech
Contributor
Contributor
Posts: 323
Joined: 02 Jan 2013, 04:56
Has thanked: 11 times
Been thanked: 105 times

Re: [Tutorial] Registration Engine

Unread post by gurutech » 25 Jul 2013, 03:08

That'll do it! Glad you got it fixed!
These users thanked the author gurutech for the post (total 2):
Madsonickleverbear

Metzlmane
Posts: 21
Joined: 09 Aug 2013, 16:55
Has thanked: 14 times
Been thanked: 7 times

Re: [Tutorial] Registration Engine

Unread post by Metzlmane » 22 Aug 2013, 14:09

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).

gurutech
Contributor
Contributor
Posts: 323
Joined: 02 Jan 2013, 04:56
Has thanked: 11 times
Been thanked: 105 times

Re: [Tutorial] Registration Engine

Unread post by gurutech » 23 Aug 2013, 00:48

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.

gurutech
Contributor
Contributor
Posts: 323
Joined: 02 Jan 2013, 04:56
Has thanked: 11 times
Been thanked: 105 times

Re: [Tutorial] Registration Engine

Unread post by gurutech » 08 Sep 2013, 15:13

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...
These users thanked the author gurutech for the post:
Madsonic

Clayboy
Posts: 9
Joined: 08 Aug 2013, 04:56
Has thanked: 2 times
Been thanked: 4 times

Re: [Tutorial] Registration Engine

Unread post by Clayboy » 30 Sep 2013, 23:17

does this also work on windows... or just linux

gurutech
Contributor
Contributor
Posts: 323
Joined: 02 Jan 2013, 04:56
Has thanked: 11 times
Been thanked: 105 times

Re: [Tutorial] Registration Engine

Unread post by gurutech » 01 Oct 2013, 01:22

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...

silversix311
Posts: 6
Joined: 15 Mar 2014, 21:58
Has thanked: 0
Been thanked: 1 time

Re: [Tutorial] Registration Engine

Unread post by silversix311 » 26 Jun 2014, 07:39

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...

User avatar
DoCC
Contributor
Contributor
Posts: 210
Joined: 25 Feb 2014, 14:41
Location: UpperBavaria : ))
Has thanked: 39 times
Been thanked: 65 times
Contact:

Re: [Tutorial] Registration Engine

Unread post by DoCC » 01 Dec 2014, 23:09

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

gurutech
Contributor
Contributor
Posts: 323
Joined: 02 Jan 2013, 04:56
Has thanked: 11 times
Been thanked: 105 times

Re: [Tutorial] Registration Engine

Unread post by gurutech » 04 Dec 2014, 03:50

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.

User avatar
DoCC
Contributor
Contributor
Posts: 210
Joined: 25 Feb 2014, 14:41
Location: UpperBavaria : ))
Has thanked: 39 times
Been thanked: 65 times
Contact:

Re: [Tutorial] Registration Engine

Unread post by DoCC » 07 Dec 2014, 01:13

lol your suggestion is a lil bit insane ... imagine beeing able to inject your AD server via an open webfrontend : ) uuuaaaaahhhh ^^

gurutech
Contributor
Contributor
Posts: 323
Joined: 02 Jan 2013, 04:56
Has thanked: 11 times
Been thanked: 105 times

Re: [Tutorial] Registration Engine

Unread post by gurutech » 08 Dec 2014, 17:45

If LDAP could be kept separate from AD, that would still work. But yeah, huge security issue if they are tied together...

User avatar
DoCC
Contributor
Contributor
Posts: 210
Joined: 25 Feb 2014, 14:41
Location: UpperBavaria : ))
Has thanked: 39 times
Been thanked: 65 times
Contact:

Re: [Tutorial] Registration Engine

Unread post by DoCC » 08 Dec 2014, 20:48

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 .

Post Reply