Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Questions and Supports

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 01-07-2016, 10:12 AM
NobodysHero's Avatar
NobodysHero NobodysHero is offline
Co-Owner of MystFell
 
Join Date: Nov 2013
Posts: 144
Gender: Female
Credits: 18,720
NobodysHero is on a distinguished road
Default Post Forum Installation Issue.

Some of you may know, but our hosting provider went out of business and we didn't receive notice, so we lost all of the updates to our code and are having to start over. There are benefits and downfalls to this situation, but we're looking forward to the fresh start, mostly because this means that we can now allow our users access to the forums!

I've been scouring the Mysidia forums for the answer, but so far nothing I've tried has worked, so I'm hoping someone has the answer to share. I'm getting the message akin to Forum account could not be created. I can access the forums, my admin account works, I can create threads in the forums, but it will not automatically create users when registering through Mysidia.

Things I've Tried:
Pachoofoosh's Coding Fix for the functions_forums page.
HoF's reminder to change the htaccess.txt to .htaccess
Tutorial's step to update the config_forums.php.
Fully installed forums, turned off registration in admin panel.

Commonly Asked for Files:

config_forums.php
Code:
<?php
//Mysidia Adoptables Site Configuration File

//Forum Integration Info: MyBB
$mybbenabled = 1; // 0 = disabled, 1 = enabled
$mybbhost = 'localhost'; // Consult your host if you believe this field is not localhost
$mybbuser = 'mystfel3_Hero';
$mybbpass = '**********';
$mybbdbname = 'mystfel3_forums';
$mybbpath = '/forums/';
$mybbprefix = 'mybb_'; // This is the default setting as you install MyBB forum, feel free changing it if you have a different prefix
$mybbremember = -1;  		
?>
functions_forums.php
Code:
<?php

// File ID: functions_forums.php
// Purpose: Provides specific functions for forum integration, for now it is MyBB only.

function mybbregister(){ 
    $mysidia = Registry::get("mysidia");
    include("inc/config_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($mysidia->input->post("pass1"));
    $fpass = md5(md5($salty).$md5pass); 
    $ip = $_SERVER['REMOTE_ADDR'];
    $altip = ipgen($ip);  
    $username = $mysidia->input->post("username");
    $email = $mysidia->input->post("email");
    $avatar = (strpos($imageurl, "http://") !== false)?$avatar:"http://www.".DOMAIN.SCRIPTPATH."/".$mysidia->input->post("avatar");
    $birthday = $mysidia->input->post("birthday");
    $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, usernotes)
                                       VALUES ('', '$username', '$fpass','$salty','$loginkey', '$email', '0', '$avatar', '', '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','')";
    $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); 
}

function mybblogin(){
    $mysidia = Registry::get("mysidia");
    include("inc/config_forums.php");
    $forums = new Database($mybbdbname, $mybbhost, $mybbuser, $mybbpass, $mybbprefix) or die("Cannot connect to forum database, please contact an admin immediately.");
    $mybbuser = $forums->select("users", array("uid", "loginkey"), "username = '{$mysidia->input->post("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); 
}

function mybblogout(){
    $mysidia = Registry::get("mysidia");
    include("inc/config_forums.php");
    mybbunsetcookie("mybbuser");
    mybbunsetcookie("sid");
    $forums = new Database($mybbdbname, $mybbhost, $mybbuser, $mybbpass, $mybbprefix) or die("Cannot connect to forum database, please contact an admin immediately.");
    $loginkey = codegen(50, 0);
    $lastvisit = time() - 900;
    $lastactive = time();
    $forums->update("users", array("loginkey" => $loginkey, "lastvisit" => $lastvisit, "lastactive" => $lastactive), "uid = '{$mysidia->user->uid}'");
    $forums->delete("sessions", "uid = '{$mysidia->user->uid}'");
}

function mybbsetcookie($name, $value="", $expires="", $httponly=false, $cookiesettings = array()){
    $mysidia = Registry::get("mysidia");
    if(!$cookiesettings['cookiepath']) $cookiesettings['cookiepath'] = "/";

    if($expires == -1) $expires = 0;
    elseif($expires == "" || $expires == null) $expires = time() + (60*60*24*365); // Make the cookie expire in a years time
    else $expires = time() + intval($expires);

    $cookiesettings['cookiepath'] = str_replace(array("\n","\r"), "", $cookiesettings['cookiepath']);
    $cookiesettings['cookiedomain'] = str_replace(array("\n","\r"), "", $cookiesettings['cookiedomain']);
    $cookiesettings['cookieprefix'] = str_replace(array("\n","\r", " "), "", $cookiesettings['cookieprefix']);

    // Versions of PHP prior to 5.2 do not support HttpOnly cookies and IE is buggy when specifying a blank domain so set the cookie manually
    $cookie = "Set-Cookie: {$cookiesettings['cookieprefix']}{$name}=".urlencode($value);

    if($expires > 0) $cookie .= "; expires=".@gmdate('D, d-M-Y H:i:s \\G\\M\\T', $expires);
    if(!empty($cookiesettings['cookiepath'])) $cookie .= "; path={$cookiesettings['cookiepath']}";
    if(!empty($cookiesettings['cookiedomain'])) $cookie .= "; domain={$cookiesettings['cookiedomain']}";
    if($httponly == true) $cookie .= "; HttpOnly";
    
    $cookiesettings[$name] = $value;
    header($cookie, false);
}

function mybbunsetcookie($name){    
    $expires = -3600;
    mybbsetcookie($name, "", $expires);        
}


function mybb_seed_rng($count=8){
    $output = '';
    
    // Try the unix/linux method
    if(@is_readable('/dev/urandom') && ($handle = @fopen('/dev/urandom', 'rb'))){
        $output = @fread($handle, $count);
        @fclose($handle);
    }
    
    // Didn't work? Do we still not have enough bytes? Use our own (less secure) rng generator
    if(strlen($output) < $count){
        $output = '';
        
        // Close to what PHP basically uses internally to seed, but not quite.
        $unique_state = microtime().@getmypid();
        
        for($i = 0; $i < $count; $i += 16){
            $unique_state = md5(microtime().$unique_state);
            $output .= pack('H*', md5($unique_state));
        }
    }
    
    // /dev/urandom and openssl will always be twice as long as $count. base64_encode will roughly take up 33% more space but crc32 will put it to 32 characters
    $output = hexdec(substr(dechex(crc32(base64_encode($output))), 0, $count));
    
    return $output;
}

function mybb_rand($min=null, $max=null, $force_seed=false){
    static $seeded = false;
    static $obfuscator = 0;

    if($seeded == false || $force_seed == true){
        mt_srand(mybb_seed_rng());
        $seeded = true;

        $obfuscator = abs((int) mybb_seed_rng());
        
        // Ensure that $obfuscator is <= mt_getrandmax() for 64 bit systems.
        if($obfuscator > mt_getrandmax()) $obfuscator -= mt_getrandmax();
    }

    if($min !== null && $max !== null){
        $distance = $max - $min;
        if ($distance > 0) return $min + (int)((float)($distance + 1) * (float)(mt_rand() ^ $obfuscator) / (mt_getrandmax() + 1));
        else return mt_rand($min, $max);
    }
    else{
        $val = mt_rand() ^ $obfuscator;
        return $val;
    }
}

function mybb_random_str($length="8"){
    $set = array("a","A","b","B","c","C","d","D","e","E","f","F","g","G","h","H","i","I","j","J","k","K","l","L","m","M","n","N","o","O","p","P","q","Q","r","R","s","S","t","T","u","U","v","V","w","W","x","X","y","Y","z","Z","1","2","3","4","5","6","7","8","9");
    $str = '';

    for($i = 1; $i <= $length; ++$i){
        $ch = mybb_rand(0, count($set)-1);
        $str .= $set[$ch];
    }

    return $str;
}

function mybbrebuildstats(){
    $mysidia = Registry::get("mysidia");
    include("inc/config_forums.php");
    if(!$mysidia->input->post("username")) return FALSE;
    
    $forums = new Database($mybbdbname, $mybbhost, $mybbuser, $mybbpass, $mybbprefix) or die("Cannot connect to forum database, please contact an admin immediately.");
    $oldstats = $forums->select("datacache", array("cache"), "title = 'stats'")->fetchColumn();
    $stats = unserialize($oldstats); 
    $uid = $forums->select("users", array("uid"), "username = '{$mysidia->input->post("username")}'")->fetchColumn();
    
    if($stats['lastuid'] == $uid) return FALSE;
    $stats['numusers']++;
    $stats['lastuid'] = $uid;
    $stats['lastusername'] = $mysidia->input->post("username");
    $newstats = serialize($stats);
    
    $forums->update("datacache", array("cache" => $newstats), "title = 'stats'");
    $forums->delete("stats");
    $forums->insert("stats", array("dateline" => time(), "numusers" => $stats['numusers'], "numthreads" => $stats['numthreads'], "numposts" => $stats['numposts']));
    return TRUE;
}

?>
And finally, the forums' config.php

Code:
<?php
/**
 * Database configuration
 *
 * Please see the MyBB Docs for advanced
 * database configuration for larger installations
 * http://docs.mybb.com/
 */

$config['database']['type'] = 'mysqli';
$config['database']['database'] = 'mystfel3_forums';
$config['database']['table_prefix'] = 'mybb_';

$config['database']['hostname'] = 'localhost';
$config['database']['username'] = 'mystfel3_Hero';
$config['database']['password'] = '**********';

/**
 * Admin CP directory
 *  For security reasons, it is recommended you
 *  rename your Admin CP directory. You then need
 *  to adjust the value below to point to the
 *  new directory.
 */

$config['admin_dir'] = 'admin';

/**
 * Hide all Admin CP links
 *  If you wish to hide all Admin CP links
 *  on the front end of the board after
 *  renaming your Admin CP directory, set this
 *  to 1.
 */

$config['hide_admin_links'] = 0;

/**
 * Data-cache configuration
 *  The data cache is a temporary cache
 *  of the most commonly accessed data in MyBB.
 *  By default, the database is used to store this data.
 *
 *  If you wish to use the file system (cache/ directory), MemCache (or MemCached), xcache, APC, or eAccelerator
 *  you can change the value below to 'files', 'memcache', 'memcached', 'xcache', 'apc' or 'eaccelerator' from 'db'.
 */

$config['cache_store'] = 'db';

/**
 * Memcache configuration
 *  If you are using memcache or memcached as your
 *  data-cache, you need to configure the hostname
 *  and port of your memcache server below.
 *
 * If not using memcache, ignore this section.
 */

$config['memcache']['host'] = 'localhost';
$config['memcache']['port'] = 11211;

/**
 * Super Administrators
 *  A comma separated list of user IDs who cannot
 *  be edited, deleted or banned in the Admin CP.
 *  The administrator permissions for these users
 *  cannot be altered either.
 */

$config['super_admins'] = '1';

/**
 * Database Encoding
 *  If you wish to set an encoding for MyBB uncomment
 *  the line below (if it isn't already) and change
 *  the current value to the mysql charset:
 *  http://dev.mysql.com/doc/refman/5.1/en/charset-mysql.html
 */

$config['database']['encoding'] = 'utf8';

/**
 * Automatic Log Pruning
 *  The MyBB task system can automatically prune
 *  various log files created by MyBB.
 *  To enable this functionality for the logs below, set the
 *  the number of days before each log should be pruned.
 *  If you set the value to 0, the logs will not be pruned.
 */

$config['log_pruning'] = array(
	'admin_logs' => 365, // Administrator logs
	'mod_logs' => 365, // Moderator logs
	'task_logs' => 30, // Scheduled task logs
	'mail_logs' => 180, // Mail error logs
	'user_mail_logs' => 180, // User mail logs
	'promotion_logs' => 180 // Promotion logs
);

/**
 * Admin CP Secret PIN
 *  If you wish to request a PIN
 *  when someone tries to login
 *  on your Admin CP, enter it below.
 */

$config['secret_pin'] = '******';
If more information is needed or I missed a step, please let me know. I'd love to get this all figured out.

Last edited by NobodysHero; 01-07-2016 at 10:14 AM.
Reply With Quote
  #2  
Old 01-07-2016, 11:22 AM
Distortion's Avatar
Distortion Distortion is offline
Member
 
Join Date: Dec 2015
Location: Somewhere beyond the sea
Posts: 31
Gender: Female
Credits: 3,842
Distortion is on a distinguished road
Default

http://mysidiaadoptables.com/forum/p...php?issueid=52
http://mysidiaadoptables.com/forum/blog.php?b=100
__________________

Last edited by Distortion; 01-07-2016 at 11:24 AM.
Reply With Quote
  #3  
Old 01-07-2016, 12:19 PM
NobodysHero's Avatar
NobodysHero NobodysHero is offline
Co-Owner of MystFell
 
Join Date: Nov 2013
Posts: 144
Gender: Female
Credits: 18,720
NobodysHero is on a distinguished road
Default

I did miss something! Thank you so much, Distortion. That first link was the answer I needed. Sincerely appreciate the assist.
Reply With Quote
  #4  
Old 01-07-2016, 12:21 PM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 333,420
Hall of Famer is on a distinguished road
Default

Alternatively you can just install MyBB 1.6, which will surely work flawlessly.
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 05:59 AM.

Currently Active Users: 9829 (0 members and 9829 guests)
Threads: 4,080, Posts: 32,024, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636