Mysidia Adoptables Support Forum

Mysidia Adoptables Support Forum (http://www.mysidiaadoptables.com/forum/index.php)
-   Questions and Supports (http://www.mysidiaadoptables.com/forum/forumdisplay.php?f=18)
-   -   Forum registeration (http://www.mysidiaadoptables.com/forum/showthread.php?t=3621)

ChibiMaestro 04-22-2012 06:12 AM

Forum registeration
 
Is it possible so that when someone registers on the Mys site, they also register on a MyBB forum automatically??

If so... how?? o.O I'd appreciate any help! Thank you XD

(Yus, I am thinking of creating a site using Mys :3)

Hall of Famer 04-22-2012 07:36 AM

Well yes, this is what the forum integration does. In fact they also automatically log into both of their accounts in Mys v1.3.1, which is an improvement over the old script in which they have to sign in twice.

ChibiMaestro 04-22-2012 07:55 AM

Ergh, so how would I install the forum so that it'll be 'connected'?
OH WAIT. That's what happens when I'm lazy and I skip things ._. Just read the Mys 1.3.1 thread again o.O *facepalm*

Thanks Hoffie ^-^

Hall of Famer 04-22-2012 08:02 AM

No worries, glad you figured it out. The forum integration at this point is able to register the user on both adoptables site and forum, while logging them in simultaneously if they sign in from the site. It is a good idea to disable forum registration to avoid confusion(if a user registers on the forum before on the adoptables site, you may have a problem).

Note the forum integration does not update forum statistics yet, so you have to do it manually when you see some users register. It is not necessary, but will make your site look somewhat better.

ChibiMaestro 04-22-2012 01:25 PM

Okay, I'm still confused on what exactly to do o.O Can you explain in detail? Thanks ^-^

Hall of Famer 04-22-2012 01:29 PM

Well you need to install the adoptables site and forum separately, then edit the file config_forums.php to enter your forum config data. Make sure to change $mybbenabled to 1 to enable forum integration, 0 means the integration is disabled. Its recommended to turn off forum registration so users can only register on the adoptables site(and their corresponding forum account will be generated simultaneously once their site account is created).

ChibiMaestro 04-22-2012 01:47 PM

OOH. I GOT IT.
I test registered, but then I got this on the Mys site's register page:

Warning: include(../inc/config_forums.php) [function.include]: failed to open stream: No such file or directory in /home/cunicu/domains/sitename.com/public_html/functions/functions.php on line 306

Warning: include(../inc/config_forums.php) [function.include]: failed to open stream: No such file or directory in /home/cunicu/domains/sitename.com/public_html/functions/functions.php on line 306

Warning: include() [function.include]: Failed opening '../inc/config_forums.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/cunicu/domains/sitename.com/public_html/functions/functions.php on line 306

I edited the stuff above to replace my site URL to 'sitename.com'... what's the problem?
Is it because I left $mybbpath = ''; as it is? Am I supposed to?

Hall of Famer 04-22-2012 02:02 PM

Well this has nothing to do with mybbpath... Your register.php is located in the root directory, it should not be reporting errors/warnings like Warning: include(../inc/config_forums.php). Did you edit the register.php file? o_o

ChibiMaestro 04-22-2012 02:30 PM

Nope, I didn't edit it at all o.O

I tried adding /forum as the path, just in case ya'know, still no difference at all. I tried re-registering... NO DIFFERENCE ._.

I don't think this is a really big error, just quite not appealing when you register, and a code/thing appears o.O

ChibiMaestro 04-23-2012 10:37 AM

Erm, anyone think they know the problem?

Hall of Famer 04-23-2012 12:45 PM

Well I am a bit confused here... Is registration not working for you and your members at all? Or are you only getting these messages out of nowhere while you can register and login?

ChibiMaestro 04-23-2012 01:03 PM

Registration is fine. It's just that the message appears when you register on the register.php page at the top.

Hall of Famer 04-23-2012 01:13 PM

Are you sure about this? The registration and login system appear to be fine on both of your adoptables site and forum? If so, post your register.php and I will tell you how to fix it. Looks like the problem is with inclusion path of library files.

ChibiMaestro 04-25-2012 12:30 PM

Okay, here it is:
Code:

<?php

include("functions/functions.php");
include("functions/functions_users.php");
include("inc/config_forums.php");
include("inc/lang.php");

//***************//
//  START SCRIPT //
//***************//

if($isloggedin == "yes"){

$article_title = "You already have an account";
$article_content = "You already have an account, thus there is no need for you to register a new one.";

}
else{

//Grab the post data from the form

$username = $_POST["username"];
$username = secure($username);
$pass1 = $_POST["pass1"];
$pass1 = secure($pass1);
$pass2 = $_POST["pass2"];
$pass2 = secure($pass2);
$email = $_POST["email"];
$ip = $_POST['ip'];
$birthday = $_POST['birthday'];
$avatar = $_POST["avatar"];
$tos = $_POST["tos"];
$hidden = $_POST["hidden"];
$answer = $_POST["answer"];
$answer2 = $_POST["answer2"];

  if($hidden != "goregister"){

        //The form was not submitted, so we are showing the signup page...
    $question = grabanysetting("securityquestion");
    $answer = grabanysetting("securityanswer");
        $article_title = $regnew;
        $article_content = $regnewexplain."<br><form name='form1' method='post' action='register.php'>
          <p>Username: <input name='username' type='text' id='username' maxlength='20'></p>
          <p>Your username may be up to 20 characters long and may only contain letters, numbers and spaces. </p>
          <p>Password: <input name='pass1' type='password' id='pass1' maxlength='20'></p>
          <p>Your password may be up to 20 characters long and may contain letters, numbers, spaces and special characters. The use of a special character, such as * or ! is recommended for increased security. </p>
          <p>Confirm Password: <input name='pass2' type='password' id='pass2' maxlength='20'></p>
          <p>Email Address: <input name='email' type='text' id='email'></p>
        <p>Birthday(mm/dd/yyyy): <input name='birthday' type='text' id='birthday'></p>
          <p>Avatar url: <input name='avatar' type='text' id='avatar' value='templates/icons/default_avatar.gif'></p>
    <p>Security Question: {$question}
    <input name='answer' type='hidden' id='answer' value='{$answer}'></p>
    <p>Answer: <input name='answer2' type='text' id='answer2'></p>
          <p><input name='tos' type='checkbox' id='tos' value='yes'> I agree to the <a href='tos.php' target='_blank'>Terms of Service</a>.
          <input name='ip' type='hidden' id='ip' value='{$_SERVER['REMOTE_ADDR']}'></p>
        <input name='hidden' type='hidden' id='hidden' value='goregister'></p>
          <p><input type='submit' name='Submit' value='Register'>
          </p></form>";


  }
  else{

        //We are attempting to register the user...
       
    $salt = codegen(15, 0);
        $password1 = passencr($username, $pass1, $salt);
        $password2 = passencr($username, $pass2, $salt);

        //Next check that the username does not already exist...

        $flag = 0;
        $row = $adopts->select("users", array(), "username = '{$username}'")->fetchObject();
        if(is_object($row)) $flag = 1;
        //Now we verify that the email address is a valid email address...
        $emailisvalid = "no";
    $regex = '/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i';
       
        if(preg_match($regex, $email)) $emailisvalid = "yes";
       
        //First check that something required was not left blank...

        if($username == "" or $password1 == "" or $password2 == "" or $email == ""){
          $article_title = "Error";
          $article_content = $regblank;
        }
        else if($password1 != $password2){
       
          //Passwords do not match
          $article_title = "Your passwords do not match";
          $article_content = $passnomatch;
        }
        else if($tos != "yes"){

          //User did not agree to TOS
          $article_title = "Terms of Service Error";
          $article_content = $notos;
        }
        else if($flag > 0){
       
          //Username already exists
          $article_title = "Your username already exists";
          $article_content = $userexists;       
        }
        else if($emailisvalid != "yes"){

            //Email address is not valid or is a fake
          $article_title = "Email address is not valid";
          $article_content = $emailinvalid;
        }
        else if($answer != $answer2){

          //Email address is not valid or is a fake
          $article_title = "An error has occurred";
          $article_content = "It seems that you did not answer the security question correctly...";
        }
        else{

          //All checks are done, actually create the user's account on the database

          $date = date('Y-m-d');
          $session = session_id();
      $myssession = md5($uid.$session);
          $adopts->insert("users", array("uid" => NULL, "username" => $username, "salt" => $salt, "password" => $password1, "session" => $myssession, "email" => $email, "ip" => $_SERVER['REMOTE_ADDR'],
                                                  "usergroup" => 3, "birthday" => $birthday, "membersince" => $date, "money" => $GLOBALS['settings']['startmoney'], "friends" => NULL));
       
      $adopts->insert("users_contacts", array("uid" => NULL, "username" => $username, "website" => NULL, "facebook" => NULL, "twitter" => NULL,
                                                  "aim" => NULL, "yahoo" => NULL, "msn" => NULL, "skype" => NULL));
       
          $adopts->insert("users_options", array("uid" => NULL, "username" => $username, "newmessagenotify" => 1, "pmstatus" => 0,
                                                  "vmstatus" => 0, "tradestatus" => 0, "theme" => $GLOBALS['settings']['theme']));

      $adopts->insert("users_profile", array("uid" => NULL, "username" => $username, "avatar" => $avatar, "bio" => NULL, "color" => NULL,
                                                  "about" => NULL, "favpet" => 0, "gender" => 'unknown', "nickname" => NULL));                                                                                         
       
          $adopts->insert("users_status", array("uid" => NULL, "username" => $username, "canlevel" => 'yes', "canvm" => 'yes', "canfriend" => 'yes',
                                                "cantrade" => 'yes', "canbreed" => 'yes', "canpound" => 'yes', "canshop" => 'yes'));       
               
      //Now check if Mybb forum integration is enabled
      if($mybbenabled == 1){
          //Mybb forum integration is enabled, now generate the user account on Mybb forum!
          include("functions/functions_forums.php");
          $forums = new Database($mybbdbname, $mybbhost, $mybbuser, $mybbpass, $mybbprefix) or die("Cannot connect to forum database, please contact an admin immediately.");

          //Now the database has been switched to mybb forum's. Before inserting user info, lets generate the password and salt in Mybb format.
          $salty = codegen(8, 0);
          $loginkey = codegen(50, 0);
          $md5pass = md5($pass1);
          $fpass = md5(md5($salty).$md5pass);
          $ip = $_SERVER['REMOTE_ADDR'];
          $altip = ipgen($ip); 
          $query = "INSERT INTO {$mybbprefix}users (uid, username, password, salt, loginkey, email, postnum, avatar, avatardimensions, avatartype, usergroup, additionalgroups, displaygroup, usertitle, regdate, lastactive, lastvisit, lastpost, website, icq, aim, yahoo, msn, birthday, birthdayprivacy, signature, allownotices, hideemail, subscriptionmethod, invisible, receivepms, receivefrombuddy, pmnotice, pmnotify, threadmode, showsigs, showavatars, showquickreply, showredirect, ppp, tpp, daysprune, dateformat, timeformat, timezone, dst, dstcorrection, buddylist, ignorelist, style, away, awaydate, returndate, awayreason, pmfolders, notepad, referrer, referrals, reputation, regip, lastip, longregip, longlastip, language, timeonline, showcodebuttons, totalpms, unreadpms, warningpoints, moderateposts, moderationtime, suspendposting, suspensiontime, suspendsignature, suspendsigtime, coppauser, classicpostbit, loginattempts, failedlogin, usernotes)
                                                                              VALUES ('', '$username', '$fpass','$salty','$loginkey','$email', '0', '', '', '0', '2', '', '0', '', 'time()', 'time()', 'time()', '0', '', '', '', '', '', '$birthday', 'all', '', '1', '0', '0', '0', '1', '0', '1', '1', '', '1', '1', '1', '1', '0', '0', '0', '', '', '0', '0', '0', '', '', '0', '0', '0', '', '', '', '', '0','0','0','$ip', '$ip','$altip','$altip','','0','1', '0', '0', '0','0','0','0','0','0','0','0','0','1','0','')";
          $forums->query($query) or die("Failed to create forum account");

          // Now set the cookie for user on MyBB       
          $mybbuser = $forums->select("users", array("uid", "loginkey"), "username = '{$username}'")->fetchObject();
          $cookiesettings = array();
          $cookiesettings['cookiedomain'] = $forums->select("settings", array("value"), "name = 'cookiedomain'")->fetchColumn();
          $cookiesettings['cookiepath'] = $forums->select("settings", array("value"), "name = 'cookiepath'")->fetchColumn();
          $cookiesettings['cookieprefix'] = $forums->select("settings", array("value"), "name = 'cookieprefix'")->fetchColumn();
          mybbsetcookie("mybbuser", $mybbuser->uid."_".$mybbuser->loginkey, NULL, true, $cookiesettings);

          $mybbsid = mybb_random_str(32);
          mybbsetcookie("sid", $mybbsid, -1, true);
      }   

          //Now that we have created the user, let's log them in...

          $status = dologin($username, $password1, $myssession);

          if($status != "success"){
       
              $article_title = "Something is Wrong!";
              $article_content = "Something is very, very wrong.  Please contact Mysidia Adoptables about this error.";

          }
          else{

          //We are registered and logged in...
          $article_title = $titleregsuccess;
          $article_content = $regsuccess."".$username."".$regsuccess2;

      if($mybbenabled == 1) $article_content .= "</br></br>You may also visit your forum account and edit your profile.";

          //Reflect our changes in the sidebar...
          $sidebar = "<b><u>Welcome {$username}</u></b>:<br><a href='account.php'>Go to My Account</a><br><a href='adopt.php'>Adopt Some Pets</a>";

          }
        }
       


  }

}

//***************//
//  OUTPUT PAGE  //
//***************//

echo showpage($article_title, $article_content, $date);

?>


Hall of Famer 04-25-2012 03:08 PM

Well I see the problem is not with register.php... Open your functions.php and find this line

PHP Code:

include("../inc/config_forums.php"); 

Replace by:

PHP Code:

include("inc/config_forums.php"); 

This should fix your problem, I am not sure why this error is not displaying for my demo site though. It looks like a glitch, I will post it in bug tracker now.

ChibiMaestro 04-25-2012 04:52 PM

Woah. Magic. Yay ^-^ Thanks Hoffie!!!! It works without displaying any kind of weird messages!


All times are GMT -5. The time now is 06:28 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.