Using table_prefix for multiple blogs (5 posts)

  1. msolution
    Posted 5 years ago #

    my objective is to use a single wp installation for various blogs.
    and i need to do this with wp, not wpmu.

    following is my code:

    if(!$_SESSION)	session_start();
    if(isset($_GET['blog']) && $_GET['blog'] != ''){
    	$blog = trim(strip_tags($_GET['blog']));
    	$table_prefix  = $_SESSION['table_prefix'] = 'wp_'.$blog.'_';
    	header('Location: http://ww.dir.vc/demo/'); //back to same URL without the ?...
    } else if(isset($_SESSION['table_prefix'])) {
    	$table_prefix  = $_SESSION['table_prefix'];
    } else {
    	die('no blog found');

    it does register table_prefix,...gets redirected to an absolute URL, and then shows me a blank page

  2. msolution
    Posted 5 years ago #

    UPDATE: this issue is a possible bug with 3.0,
    the above works with wordpress 2.9.2

  3. Austin Matzko
    Posted 5 years ago #

    Your code introduces a potentially serious security vulnerability by allowing the public to set the tables' prefix to an arbitrary string.

  4. msolution
    Posted 5 years ago #

    the above is a cut down version of what im trying to accomplish, didnt want to add unnecessary code here.

    before putting the variable into a session variable im checking if its a digit, and if that id is present in the database.

    let me know if this helps, would appreciate, if this is checked, else i would have to take my plugin back to the drawing board.


  5. Darrell Schauss
    Posted 5 years ago #

    It will probably give you tons of headache the next time the database needs to be updated when WordPress gets updated. What about this... WordPress and WordPress MU have merged, allowing the management of multiple sites (called Multisite) from one WordPress installation. Is this saying that wordpress multisite/multiblog functionality is now part of WordPress 3 or that they are collaborating with each other now?

Topic Closed

This topic has been closed to new replies.

About this Topic