[Tutorial] Registration Engine

Tutorials, tips and tricks.

Moderator: moderators

[Tutorial] Registration Engine

Postby gurutech » Mon Jul 08, 2013 4:00 am

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. Not 100% sure this will work for Subsonic, but I am running Madsonic, and it works fine.

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://bustermusic.servemp3.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.
Image
gurutech
 
Posts: 492
Joined: Sun Jan 15, 2012 9:56 pm

Re: [Tutorial] Registration Engine

Postby mjeppo » Thu Jul 18, 2013 7:59 am

Hi there,
I set up the script and I see a new user has been created in my database. However, this user is not present in my subsonic (not using madsonic).
It seems the database is not communicating with ss?
Where do I look for the problem (I'm a noob in scripting...)?
9.445 artiesten
21.140 albums
342.780 songs
14998,37 GB
28.673 uren
User avatar
mjeppo
 
Posts: 20
Joined: Thu Oct 20, 2011 8:18 am
Location: Groningen, the Netherlands

Re: [Tutorial] Registration Engine

Postby gurutech » Thu Jul 18, 2013 11:15 pm

I would check the following (in no particular order)
1) make sure that cURL is running on your server.
2) change the &v=1.9.5 in the $url = line to read &v=1.8.0, then try running a "fake" registration through to see if it appears in both the database and Subsonic.

There is no direct connection between the MySQL database and Subsonic. That's something I know a few people are working on, so Subsonic (or Madsonic) can use an external database for user accounts.
Image
gurutech
 
Posts: 492
Joined: Sun Jan 15, 2012 9:56 pm


Return to Tutorials

Who is online

Users browsing this forum: No registered users and 11 guests