[SOLVED] Database issue

A little external engine to register users in Subsonic

Moderator: moderators

[SOLVED] Database issue

Postby XJRodzx » Fri Jan 04, 2013 7:26 pm

I saw on the OP for the reg engine that a few people were having this issue I am having which is, users get registered to mysql but not to subsonic. Ive made sure that my config had the proper credentials and that Curl was enabled and nothing...

I want to mention, I did have this 100% working prior to wiping and re-installing Ubuntu. Before I wiped, I backed up both the subregengine folder and the login.jsp and restored them on the new install. For web server I am using Xampp.

Does anyone have any ideas as to what the problem can be?
Last edited by XJRodzx on Sun Jan 06, 2013 1:11 am, edited 1 time in total.
XJRodzx
 
Posts: 6
Joined: Sun Feb 26, 2012 4:48 pm

Re: Database issue

Postby XJRodzx » Fri Jan 04, 2013 7:46 pm

This is my Config.php

Code: Select all
<?php
//Database  connetion
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "";
$dbname = "subsonicusers";
$usertable = "users";
$woausertable = "woausers";
$multihosttable = "multihost";
$connect = mysql_connect($dbhost, $dbuser, $dbpass) or die('Cannot connect to the database, username or password are wrong.');
mysql_select_db($dbname, $connect) or die("Cannot connect database tot '$db_name'.");

//Register settings
$dbreg = true; //Register users in Global DB.
$subsonicreg = true; //Register users in Subsonic.
$multihostreg = false; //Register users in a multihost DB
$woa = false; //Enable approval feature. This will require the admin to approve users before they can user their credentials.
$woaadmin = "Marc"; //If the previous setting is true, give the name of the user who may approve users (only 1 user possible, make sure to use lower/upper case characters).

//Set subsonic permisions
$protocol = "http"; //can be http or https... Don't foreget to CHMOD the tmp directory if you use https...
$subsonicdomain = "MyIP:Port"; //Example: example.org or mydomain.com:81
$admin = "myusername";
$pass = "mypassword";
$settingsRole = false;
$streamRole = true;
$jukeboxRole = false;
$downloadRole = false;
$uploadRole = false;
$playlistRole = false;
$coverartRole = false;
$commentRole = false;
$podcastRole = false;
$shareRole = true;

//Auto register mail & Pass reset mail
//Zie: lib/mailconf.php
?>
XJRodzx
 
Posts: 6
Joined: Sun Feb 26, 2012 4:48 pm

Re: Database issue

Postby gurutech » Sat Jan 05, 2013 6:39 pm

Can you post your register.php and signature.php files as well?

As far as I can tell, the config.php file is working fine, as it connects to the database with no issues.
Image
gurutech
 
Posts: 492
Joined: Sun Jan 15, 2012 9:56 pm

Re: Database issue

Postby XJRodzx » Sat Jan 05, 2013 6:53 pm

Register.php
Code: Select all
<?php
session_start();
include("lib/config.php");
include("lib/functions.php");
if(isset($_POST["username"])) {
$redirect = $_POST["redirect"];
$username = mysql_real_escape_string($_POST["username"]);
$email = mysql_real_escape_string($_POST["email"]);
$password = mysql_real_escape_string(md5($_POST["password"]));
$cpassword = mysql_real_escape_string(md5($_POST["cpassword"]));
$spassword = mysql_real_escape_string($_POST['password']);
$captcha = md5($_POST['captcha']);

if($username==NULL|$email==NULL|$password==NULL|$cpassword==NULL|$captcha==NULL) {
$error = "All fields are required!";
}else{

if($password!=$cpassword) {
$error = "Both passwords must be the same.";
}else{

if(preg_match("/\\s/", $username)) {
$error = "You can't use a space in your username!";
}else{

$checkuser = mysql_query("SELECT username FROM $usertable WHERE username='$username' OR email='$email'");
$username_exist = mysql_num_rows($checkuser);

if($username_exist>0) {
$error = "This user or e-mail address already exists.";
}else{
include("lib/vmail.php");
$check = vMail($email);
if($check==FALSE) {
$error = "The field \"E-mail\" doesn't contain a valid e-mail address.";
}else{
if($captcha!=$_SESSION['captcha']) {
$error = "Veryfication code is incorrect.";
}else{
if($woa==true) {
$query = "INSERT INTO $woausertable (username, password, spassword, email) VALUES('$username','$password','$spassword','$email')";
mysql_query($query) or die(mysql_error());
require("lib/mailconf.php");
//mail for admin
mail($adminemail, $adminsubject, $adminmessage, "From: $fromname <$sender>\r\nContent-type: text/html\r\nX-Mailer:PHP/".phpversion());
echo "<center>\n";
echo "<table width=\"400\" cellspacing=\"0\" cellpadding=\"3\" border=\"0\" bgcolor=\"#FFFFFF\" style=\"border:1px solid #535353;\">\n";
echo "<tr>\n";
echo "<td colspan=\"2\" bgcolor=\"#535353\" style=\"text-align:center;padding:4px;font-size:11px;font-family:Verdana;font-weight:normal;text-decoration:none;color:#FFFFFF\"><b>Registreren</b></td>";
echo "</tr>\n";
echo "<tr><td style=\"font-size:11px;font-family:Verdana;font-weight:normal;text-decoration:none;color:#535353\" align=\"right\" width=\"30%\">\n";
echo "$username is now waiting for approval, you will receive an e-mail if the administrator activated your account.\n";
echo "</td></tr>\n";
echo "</table>\n";
echo "</center>\n";
exit();
}else{
if($dbreg==true) {
$query = "INSERT INTO $usertable (username, password, email) VALUES('$username','$password','$email')";
mysql_query($query) or die(mysql_error());
}
if($subsonicreg==true) {
$url = $protocol."://".$subsonicdomain."/rest/createUser.view?u=".$admin."&p=".$pass."&v=1.1.0&c=remoteregister&username=".$username."&password=".$spassword."&email=".$email."&settingsRole=".$settingsRole."&streamRole=".$streamRole."&jukeboxRole=".$jukeboxRole."&downloadRole=".$downloadRole."&uploadRole=".$uploadRole."&playlistRole=".$playlistRole."&coverartRole=".$coverartRole."&commentRole=".$commentRole."&podcastRole=".$podcastRole."&shareRole=".$shareRole;
open_https_url($url,"",true,"");
}
if($multihostreg==true) {
$time = time();
mysql_select_db($multihosttable, $connect) or die("Cannot connect database 'multihost'.");
$query2 = mysql_query("INSERT INTO `mmh_user_info` (`username`, `password`, `email_address`, `ip_address`, `private_gallery`, `time_joined`, `user_group`, `upload_type`) VALUES('$username', '$password', '$email', '0.0.0.0', '0', '$time', 'normal_user', 'standard')")or die("Error in multihost DB: ".mysql_error());
}
require("lib/mailconf.php");
//Mail for user
mail($email, $subject, $message, "From: $fromname <$sender>\r\nContent-type: text/html\r\nX-Mailer:PHP/".phpversion());
//mail for admin
mail($adminemail, $adminsubject, $adminmessage, "From: $fromname <$sender>\r\nContent-type: text/html\r\nX-Mailer:PHP/".phpversion());
echo "<center>\n";
echo "<table width=\"400\" cellspacing=\"0\" cellpadding=\"3\" border=\"0\" bgcolor=\"#FFFFFF\" style=\"border:1px solid #535353;\">\n";
echo "<tr>\n";
echo "<td colspan=\"2\" bgcolor=\"#535353\" style=\"text-align:center;padding:4px;font-size:11px;font-family:Verdana;font-weight:normal;text-decoration:none;color:#FFFFFF\"><b>Registreren</b></td>";
echo "</tr>\n";
echo "<tr><td style=\"font-size:11px;font-family:Verdana;font-weight:normal;text-decoration:none;color:#535353\" align=\"right\" width=\"30%\">\n";
echo "$username is successfully registered.\n";
echo "</td></tr>\n";
echo "</table>\n";
echo "</center>\n";
}
if($redirect=="1") {
echo "<meta http-equiv=Refresh content=3;url=".$protocol."://".$subsonicdomain.">";
}else{
echo "<meta http-equiv=Refresh content=3;url=http://MyIP:Port>";
}
exit();
}
}
}
}
}
}
}
?>
<html>
<head>
<title>Register on XJRodzx Music</title>
</head>

<body>
<center>
<span style="font-size:11px;font-family:Verdana;font-weight:bold;text-decoration:none;color:#535353">Register for services on XJRodzx Music!<br><br><br></span>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<table width="400" cellspacing="0" cellpadding="3" border="0" bgcolor="#FFFFFF" style="border:1px solid #535353;">
<tr>
<td colspan="2" bgcolor="#535353" style="text-align:center;padding:4px;font-size:11px;font-family:Verdana;font-weight:normal;text-decoration:none;color:#FFFFFF"><b>Registrer</b></td>
</tr>
<tr><td colspan="2" align="center" style="font-size:11px;font-family:Verdana;font-weight:normal;text-decoration:none;color:#535353">
<?php echo $error; ?>
</td></tr>
<tr><td style="font-size:11px;font-family:Verdana;font-weight:normal;text-decoration:none;color:#535353" align="right" width="30%">
Username:
</td>
<td>
<input type="hidden" name="redirect" value="0">
<input type="text" size="15" maxlength="25" name="username" style="border:1px solid #535353;width:250px;">
</td>
<tr><td style="font-size:11px;font-family:Verdana;font-weight:normal;text-decoration:none;color:#535353" align="right" width="30%">
E-mail:
</td>
<td>
<input type="text" size="15" maxlength="25" name="email" style="border:1px solid #535353;width:250px;">
</td>
</tr>
<tr><td style="font-size:11px;font-family:Verdana;font-weight:normal;text-decoration:none;color:#535353" align="right" width="30%">
Password:
<td>
<input type="password" size="15" maxlength="25" name="password" style="border:1px solid #535353;width:250px;">
</td>
</td></tr>
<tr><td style="font-size:11px;font-family:Verdana;font-weight:normal;text-decoration:none;color:#535353" align="right" width="30%">
Confirm password:
<td>
<input type="password" size="15" maxlength="25" name="cpassword" style="border:1px solid #535353;width:250px;">
</td>
</td></tr>
<tr><td>
Veryfication code:
</td>
<td>
<img src="lib/captcha.php" border="0"><br>
<input type="text" name="captcha" size="15" maxlength="25" style="border:1px solid #535353;width:250px;">
</td></tr>
<tr><td colspan="2" align="center">
<input type="submit" value="Register">
</td></tr>
</table>
</form>
</center>
</body>
</html>


Where is the signature.php located? I dont see that in the SubRegEngine folder?
XJRodzx
 
Posts: 6
Joined: Sun Feb 26, 2012 4:48 pm

Re: Database issue

Postby gurutech » Sat Jan 05, 2013 7:44 pm

Sorry, the "signature.php" file is part of a different mod that I have (displays what music I am listening to as my signature file on this site). Others have done this mod also.

Check your register.php file for the following line:
Code: Select all
$url = $protocol."://".$subsonicdomain."/rest/createUser.view?u=".$admin."&p=".$pass."&v=1.1.0&c=remoteregister&username=".$username."&password=".$spassword."&email=".$email."&settingsRole=".$settingsRole."&streamRole=".$streamRole."&jukeboxRole=".$jukeboxRole."&downloadRole=".$downloadRole."&uploadRole=".$uploadRole."&playlistRole=".$playlistRole."&coverartRole=".$coverartRole."&commentRole=".$commentRole."&podcastRole=".$podcastRole."&shareRole=".$shareRole;

And add:
Code: Select all
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_exec($curl);
curl_close($curl);

before the } just before the "if multihostreg=true" line.
Image
gurutech
 
Posts: 492
Joined: Sun Jan 15, 2012 9:56 pm

Re: Database issue

Postby XJRodzx » Sun Jan 06, 2013 1:10 am

You sir, are the man. That did the trick. After I added that line as you instructed, users are now being registered on both mysql and being created on subsonic as well.

Thanks so much for your help :)
XJRodzx
 
Posts: 6
Joined: Sun Feb 26, 2012 4:48 pm

Re: [SOLVED] Database issue

Postby dsync89 » Sat Mar 02, 2013 7:38 am

For somewhat reason the user created does not have the Share role ($shareRole) even though it is set to 'true' in the config file. Anyone having the same problem as I did?

Besides, even after using the curl the user still only registered in the db but not subsonic itself. Sometimes it did though, but very rare.

EDIT: Well I managed to solve it. It turned out that it was the redirection fault by NO-IP.
musicScrape @ Music Cabinet Mod
http://musicscrape.zapto.org:8080
dsync89
 
Posts: 72
Joined: Fri Oct 19, 2012 8:51 am

Re: [SOLVED] Database issue

Postby gurutech » Sun Mar 24, 2013 1:56 am

How did you resolve the redirect issue with No-IP? I think I may be having a similar issue.
Image
gurutech
 
Posts: 492
Joined: Sun Jan 15, 2012 9:56 pm

Re: [SOLVED] Database issue

Postby suprexus » Wed Apr 17, 2013 8:40 pm

I'm having this same issue. I added the lines mentioned above but i'm still having the same problem where users are added to mysql but not to subsonic. Any other Ideas?

Thanks in advanced!!
suprexus
 
Posts: 2
Joined: Wed Apr 17, 2013 8:38 pm

Re: [SOLVED] Database issue

Postby gurutech » Wed Apr 17, 2013 9:16 pm

Wish I could help... Mine isn't working at all any more. Not adding users to MySQL or the Subsonic database... :(
Image
gurutech
 
Posts: 492
Joined: Sun Jan 15, 2012 9:56 pm

Re: [SOLVED] Database issue

Postby suprexus » Wed Apr 17, 2013 10:30 pm

Sucksss...I'm trying it again from scratch see if I can get anywhere. Thanks though.
suprexus
 
Posts: 2
Joined: Wed Apr 17, 2013 8:38 pm

Re: [SOLVED] Database issue

Postby Excessive » Wed Nov 27, 2013 3:51 am

When I've been doin it, it did seem that if I copied the gbuser folder and the login.jsp over to some place else while formatting the machine/reinstalling from fresh, etc .......... and then trying to reinstall I worked out that for me it was the login.jsp file that played up! The gbuser folder with all ur edited files is fine! Do not touch anything in there. What I had to do is that every time I do this I have to start with a freshly unzipped subreg folder and get the fresh login.jsp and edit that from the beginning and then everything works.
In relation to ur no-ip issue it's easy to work out if it is ur no-ip service or not. Just go to whatismyipaddress.com and use ur ip assigned to u at that instance and work out if it is the no-ip service or not.
Excessive
 
Posts: 33
Joined: Wed Apr 04, 2012 10:19 am


Return to Subsonic Registration Engine

Who is online

Users browsing this forum: No registered users and 1 guest