<?

require_once('../../sites/default/settings.php');

if ( preg_match('/mysql:\/\/(\w+):(\w+)@([\w\.]+)\/(\w+)/',$db_url,$matches) == 0 ) {
  print "Unable to parse db_url";
  exit(0);
}
$dbhost=$matches[3];
$dbuser=$matches[1];
$dbpass=$matches[2];
$dbname=$matches[4];

if (!mysql_connect($dbhost, $dbuser, $dbpass)) {
  print "Error: connection to mysql failed !";
  exit();
}

if (!mysql_select_db($dbname)) {
  print "Error: connection to database failed !";
  exit();
}

$strQuery="DROP TABLE IF EXISTS `" .$dbprfx. "bittorrent_metainfo`";
$rr = mysql_query($strQuery);
if (!$rr) {
	print "Error : ". mysql_error($rr);
}
$strQuery="CREATE TABLE `" .$dbprfx. "bittorrent_metainfo` (
    `nid` int(10) unsigned NOT NULL default '0',
    `filename` varchar(255) NOT NULL,
    `metainfo_info` MEDIUMBLOB NOT NULL,
    PRIMARY KEY  (`nid`)
)";

$rr = mysql_query($strQuery);
if (!$rr) {
	print "Error : ". mysql_error($rr);
}

print "Tables created.";

?>
