Location: PHPKode > projects > Mummi (Multi-user MOD_MP3 Interface) > mummi.0.6/htroot/mysqlsetup.php
<?
//  This get the document root specified in the virtual host of apache
$GLOBALS[int_path] = getenv(DOCUMENT_ROOT);

// This will be changed to look at a file that the user can set the prefrence of.
$GLOBALS[lib_path] = "$GLOBALS[int_path]/../lib";

include "$GLOBALS[lib_path]/config.inc";
include "$GLOBALS[lib_path]/mysql.inc";
include "$GLOBALS[lib_path]/filesys.inc";
include "$GLOBALS[lib_path]/overseer.inc";

$os = new OVERSEER;
$os->connect("$GLOBALS[dbhost]","$GLOBALS[dbusername]","$GLOBALS[dbuserpassword]","$GLOBALS[dbname]");


// don't use the actual "audiodevil" database..
$dbname = "audiodevil2";

// setting the schema folder.. this will be put somewhere else
$schema_folder = "/usr/home/domains/demo.audiodevil.com/scm";


// Checking to see if the DB exists, if so, remove it and recreate | else create it


// start loading and creating the schema files

// use the classes needed for this page
$db = new MYSQL_DB();
//$scm = new SCHEMA_DB();
$fp = new FILESYS();


// Check for a connection to the database
if(!$db->connect("$GLOBALS[dbhost]","$GLOBALS[dbusername]","$GLOBALS[dbuserpassword]")) echo "connection to server Failed!!<br><br>";

// If you can select the DB then it exists, otherwise you get an error.. this works
if($db->query("use $dbname")){ // Database FOUND
	echo "DB: $dbname FOUND<br><br>";
	if(!$db->query("drop database $dbname")) echo "Error dropping DB<br>";
		echo "dropped db $dbname<br>";
}else{ // Database NOT FOUND
	echo "DB: $dbname NOT FOUND<br>";
}

// Building the database
if(!$db->query("create database $dbname")) echo "Error creating db<br>";
else echo "DB :$dbname: Created<br><br>";

// loading the schema files one by one and then pusing the string (loaded file) into a query

// allowed file extensions
	$ext=array(scm);

// The hidden part of the path
	$p_path = "$schema_folder";

// Combine the hidden path with the relitive path.
	$w_path = $fp->create_path($p_path, $rr_path);

// Read this folder, non-recurisvly.
	$fc = $fp->rdir($w_path,f,$ext);

// sort the array
//$fc[0] = sorty($fc[0]);
$fc[1] = $fp->sorty($fc[1]);



// Echo that we found the files and list them out
echo "Found DB Schema files:<br>";


// Display ONLY the Files.
$q=0;
while(list($key1, $val) = each($fc[1])){


	// The class method... returns
	//$schema->open_schema_file("$val");

	echo "<b>loading file: $schema_folder/$key1<br></b>\n";

	// Opening the file for use
	$scm_file = $fp->open_file("$schema_folder/$key1");
		//echo "<br>$scm_file";
	$contents = $fp->get_scm_data($scm_file);
	$fp->close_file($scm_file);

	// Pushing the contents into the db
	echo "<b>Pusing contents........</b>";
		echo "$contents<br>";

	// Tell is failed or success
	if(!$db->query($contents)) echo "<b>FAILED..........<br><br></b>";
	else echo "<b>SUCCESS.....<br><br></b>";
}






?>
Return current item: Mummi (Multi-user MOD_MP3 Interface)