<?php

require_once("config.php");
$link = mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) or die ("Could not connect");

@mysql_select_db(DB_NAME, $link);

if (isset($_GET['bloguser'])) {
  $blog_user_name = $_GET['bloguser'];
}
else {
  $arr = explode("/",$_SERVER['SCRIPT_NAME']);

  if (strpos($arr[1],".")) {
    $blog_user_name="noblogs";
    $blog_posts=-1;
    $r=mysql_query("select username,posts from blogusers",$link);
    while($arr=mysql_fetch_array($r)) {
      if ($arr['posts']>$blog_posts) {
	$blog_posts=$arr['posts'];	
	$blog_user_name=$arr['username'];	
      }
    }
  }
  else {
    $blog_user_name = $arr[1];
  }
}



$table_prefix  = "wp_".$blog_user_name."_";   // example: 'wp_' or 'b2' or 'mylogin_'

//echo "<h1>$table_prefix</h1>";

/** WordPress's config file **/
/** http://wordpress.org/   **/

// ** MySQL settings ** //
/*define('DB_NAME', 'delorg');     // The name of the database
define('DB_USER', 'root');     // Your MySQL username
define('DB_PASSWORD', ''); // ...and password
define('DB_HOST', 'localhost');     // 99% chance you won't need to change this value
*/
// Change the prefix if you want to have multiple blogs in a single database.

//$table_prefix  = 'wp_';   // example: 'wp_' or 'b2' or 'mylogin_'

// Change this to localize WordPress.  A corresponding MO file for the
// chosen language must be installed to wp-includes/languages.
// For example, install de.mo to wp-includes/languages and set WPLANG to 'de'
// to enable German language support.
define ('WPLANG', '');

/* Stop editing */

$server = DB_HOST;
$loginsql = DB_USER;
$passsql = DB_PASSWORD;
$base = DB_NAME;

define('ABSPATH', dirname(__FILE__).'/');

// Get everything else
if ($blog_user_name!="noblogs") require_once(ABSPATH.'wp-settings.php');
?>