Exemplo n.º 1
0
function bp_forums_bbpress_install($location = '')
{
    global $wpdb, $bbdb;
    check_admin_referer('bp_forums_new_install_init');
    if (empty($location)) {
        $location = ABSPATH . 'bb-config.php';
    }
    $bp = buddypress();
    // Create the bb-config.php file.
    $initial_write = bp_forums_bbpress_write($bp->plugin_dir . '/bp-forums/bbpress/bb-config-sample.php', $location, array("define( 'BBDB_NAME'," => array("'bbpress'", "'" . DB_NAME . "'"), "define( 'BBDB_USER'," => array("'username'", "'" . DB_USER . "'"), "define( 'BBDB_PASSWO" => array("'password'", "'" . DB_PASSWORD . "'"), "define( 'BBDB_HOST'," => array("'localhost'", "'" . DB_HOST . "'"), "define( 'BBDB_CHARSE" => array("'utf8'", "'" . DB_CHARSET . "'"), "define( 'BBDB_COLLAT" => array("''", "'" . DB_COLLATE . "'"), "define( 'BB_AUTH_KEY" => array("'put your unique phrase here'", "'" . addslashes(AUTH_KEY) . "'"), "define( 'BB_SECURE_A" => array("'put your unique phrase here'", "'" . addslashes(SECURE_AUTH_KEY) . "'"), "define( 'BB_LOGGED_I" => array("'put your unique phrase here'", "'" . addslashes(LOGGED_IN_KEY) . "'"), "define( 'BB_NONCE_KE" => array("'put your unique phrase here'", "'" . addslashes(NONCE_KEY) . "'"), "\$bb_table_prefix = '" => array("'bb_'", "'" . $bp->table_prefix . "bb_'"), "define( 'BB_LANG', '" => array("''", "'" . get_locale() . "'")));
    // Add the custom user and usermeta entries to the config file.
    if ($initial_write == 1) {
        $file = file_get_contents($location);
    } else {
        $file =& $initial_write;
    }
    $file = trim($file);
    if ('?>' == substr($file, -2, 2)) {
        $file = substr($file, 0, -2);
    }
    $file .= "\n" . '$bb->custom_user_table = \'' . $wpdb->users . '\';';
    $file .= "\n" . '$bb->custom_user_meta_table = \'' . $wpdb->usermeta . '\';';
    $file .= "\n\n" . '$bb->uri = \'' . $bp->plugin_url . '/bp-forums/bbpress/\';';
    $file .= "\n" . '$bb->name = \'' . get_blog_option(bp_get_root_blog_id(), 'blogname') . ' ' . __('Forums', 'buddypress') . '\';';
    if (is_multisite()) {
        $file .= "\n" . '$bb->wordpress_mu_primary_blog_id = ' . bp_get_root_blog_id() . ';';
    }
    if (defined('AUTH_SALT')) {
        $file .= "\n\n" . 'define(\'BB_AUTH_SALT\', \'' . addslashes(AUTH_SALT) . '\');';
    }
    if (defined('LOGGED_IN_SALT')) {
        $file .= "\n" . 'define(\'BB_LOGGED_IN_SALT\', \'' . addslashes(LOGGED_IN_SALT) . '\');';
    }
    if (defined('SECURE_AUTH_SALT')) {
        $file .= "\n" . 'define(\'BB_SECURE_AUTH_SALT\', \'' . addslashes(SECURE_AUTH_SALT) . '\');';
    }
    $file .= "\n\n" . 'define(\'WP_AUTH_COOKIE_VERSION\', 2);';
    $file .= "\n\n" . '?>';
    if ($initial_write == 1) {
        $file_handle = fopen($location, 'w');
        fwrite($file_handle, $file);
        fclose($file_handle);
    } else {
        $initial_write = $file;
    }
    bp_update_option('bb-config-location', $location);
    return $initial_write;
}
Exemplo n.º 2
0
function bp_forums_bbpress_install() {
	global $wpdb, $bbdb, $bp;

	check_admin_referer( 'bp_forums_new_install_init' );

	/* Create the bb-config.php file */
	$initial_write = bp_forums_bbpress_write(
		BP_PLUGIN_DIR . '/bp-forums/bbpress/bb-config-sample.php',
		ABSPATH . 'bb-config.php',
		array(
			"define( 'BBDB_NAME',"  		=> array( "'bbpress'",                     	"'" . DB_NAME . "'" ),
			"define( 'BBDB_USER',"  		=> array( "'username'",                    	"'" . DB_USER . "'" ),
			"define( 'BBDB_PASSWO"  		=> array( "'password'",                    	"'" . DB_PASSWORD . "'" ),
			"define( 'BBDB_HOST',"  		=> array( "'localhost'",                   	"'" . DB_HOST . "'" ),
			"define( 'BBDB_CHARSE"  		=> array( "'utf8'",                        	"'" . DB_CHARSET . "'" ),
			"define( 'BBDB_COLLAT"  		=> array( "''",                            	"'" . DB_COLLATE . "'" ),
			"define( 'BB_AUTH_KEY"  		=> array( "'put your unique phrase here'",  "'" . addslashes( AUTH_KEY ) . "'" ),
			"define( 'BB_SECURE_A"  		=> array( "'put your unique phrase here'",  "'" . addslashes( SECURE_AUTH_KEY ) . "'" ),
			"define( 'BB_LOGGED_I"  		=> array( "'put your unique phrase here'",  "'" . addslashes( LOGGED_IN_KEY ) . "'" ),
			"define( 'BB_NONCE_KE"  		=> array( "'put your unique phrase here'",  "'" . addslashes( NONCE_KEY ) . "'" ),
			"\$bb_table_prefix = '" 		=> array( "'bb_'",                          "'" . $bp->table_prefix . "bb_'" ),
			"define( 'BB_LANG', '" 			=> array( "''",                          	"'" . WPLANG . "'" )
		)
	);

	/* Add the custom user and usermeta entries to the config file */
	if ( $initial_write == 1 ) {
		$file = file_get_contents( ABSPATH . 'bb-config.php' );
	} else {
		$file = &$initial_write;
	}

	$file = substr( $file, 0, -2 );
	$file .= "\n" .   '$bb->custom_user_table = \'' . $wpdb->users . '\';';
	$file .= "\n" .   '$bb->custom_user_meta_table = \'' . $wpdb->usermeta . '\';';
	$file .= "\n\n" . '$bb->uri = \'' . BP_PLUGIN_URL . '/bp-forums/bbpress/\';';
	$file .= "\n" .   '$bb->name = \'' . get_blog_option( BP_ROOT_BLOG, 'name' ) . ' ' . __( 'Forums', 'buddypress' ) . '\';';

	if ( bp_core_is_multisite() )
		$file .= "\n" .   '$bb->wordpress_mu_primary_blog_id = ' . BP_ROOT_BLOG . ';';

	if ( defined( 'AUTH_SALT' ) )
		$file .= "\n\n" . 'define(\'BB_AUTH_SALT\', \'' . addslashes( AUTH_SALT ) . '\');';

	if ( defined( 'LOGGED_IN_SALT' ) )
		$file .= "\n" .   'define(\'BB_LOGGED_IN_SALT\', \'' . addslashes( LOGGED_IN_SALT ) . '\');';

	if ( defined( 'SECURE_AUTH_SALT' ) )
		$file .= "\n" .   'define(\'BB_SECURE_AUTH_SALT\', \'' . addslashes( SECURE_AUTH_SALT ) . '\');';

	$file .= "\n\n" . 'define(\'WP_AUTH_COOKIE_VERSION\', 2);';
	$file .= "\n\n" . '?>';

	if ( $initial_write == 1 ) {
		$file_handle = fopen( ABSPATH . 'bb-config.php', 'w' );
		fwrite( $file_handle, $file );
		fclose( $file_handle );
	} else {
		$initial_write = $file;
	}

	update_site_option( 'bb-config-location', ABSPATH . 'bb-config.php' );
	return $initial_write;
}