Location: PHPKode > projects > Top Music module > Top Music 3.0.7/html/modules/topMusic/install/topmusic_install.php
<html>
<head>
<style type="text/css">
FONT		{FONT-FAMILY: Verdana,Helvetica; FONT-SIZE: 10px}
TD		{FONT-FAMILY: Verdana,Helvetica; FONT-SIZE: 10px}
BODY		{FONT-FAMILY: Verdana,Helvetica; FONT-SIZE: 10px}
P		{FONT-FAMILY: Verdana,Helvetica; FONT-SIZE: 10px}
DIV		{FONT-FAMILY: Verdana,Helvetica; FONT-SIZE: 10px}
INPUT 		{BORDER-TOP-COLOR: #000000; BORDER-LEFT-COLOR: #000000; BORDER-RIGHT-COLOR: #000000; BORDER-BOTTOM-COLOR: #000000; BORDER-TOP-WIDTH: 1px; BORDER-LEFT-WIDTH: 1px; FONT-SIZE: 10px; BORDER-BOTTOM-WIDTH: 1px; FONT-FAMILY: Verdana,Helvetica; BORDER-RIGHT-WIDTH: 1px}
TEXTAREA	{BORDER-TOP-COLOR: #000000; BORDER-LEFT-COLOR: #000000; BORDER-RIGHT-COLOR: #000000; BORDER-BOTTOM-COLOR: #000000; BORDER-TOP-WIDTH: 1px; BORDER-LEFT-WIDTH: 1px; FONT-SIZE: 10px; BORDER-BOTTOM-WIDTH: 1px; FONT-FAMILY: Verdana,Helvetica; BORDER-RIGHT-WIDTH: 1px}
SELECT 		{BORDER-TOP-COLOR: #000000; BORDER-LEFT-COLOR: #000000; BORDER-RIGHT-COLOR: #000000; BORDER-BOTTOM-COLOR: #000000; BORDER-TOP-WIDTH: 1px; BORDER-LEFT-WIDTH: 1px; FONT-SIZE: 10px; BORDER-BOTTOM-WIDTH: 1px; FONT-FAMILY: Verdana,Helvetica; BORDER-RIGHT-WIDTH: 1px}
FORM 		{FONT-FAMILY: Verdana,Helvetica; FONT-SIZE: 10px}
A:link          {BACKGROUND: none; COLOR: #363636; FONT-SIZE: 10px; FONT-FAMILY: Verdana, Helvetica; TEXT-DECORATION: underline}
A:active        {BACKGROUND: none; COLOR: #363636; FONT-SIZE: 10px; FONT-FAMILY: Verdana, Helvetica; TEXT-DECORATION: underline}
A:visited       {BACKGROUND: none; COLOR: #363636; FONT-SIZE: 10px; FONT-FAMILY: Verdana, Helvetica; TEXT-DECORATION: underline}
A:hover         {BACKGROUND: none; COLOR: #363636; FONT-SIZE: 10px; FONT-FAMILY: Verdana, Helvetica; TEXT-DECORATION: underline}
.title 		{BACKGROUND: none; COLOR: #000000; FONT-SIZE: 14px; FONT-WEIGHT: bold; FONT-FAMILY: Verdana, Helvetica; TEXT-DECORATION: none}
.content 	{BACKGROUND: none; COLOR: #000000; FONT-SIZE: 10px; FONT-FAMILY: Verdana, Helvetica}
.block-title	{BACKGROUND: none; COLOR: #FFFFFF; FONT-SIZE: 10px; FONT-FAMILY: Verdana, Helvetica}
.storytitle 	{BACKGROUND: none; COLOR: #363636; FONT-SIZE: 12px; FONT-WEIGHT: bold; FONT-FAMILY: Verdana, Helvetica; TEXT-DECORATION: none}
.storycat	{BACKGROUND: none; COLOR: #363636; FONT-SIZE: 10px; FONT-WEIGHT: bold; FONT-FAMILY: Verdana, Helvetica; TEXT-DECORATION: underline}
.boxtitle 	{BACKGROUND: none; COLOR: #363636; FONT-SIZE: 10px; FONT-WEIGHT: bold; FONT-FAMILY: Verdana, Helvetica; TEXT-DECORATION: none}
.boxcontent 	{BACKGROUND: none; COLOR: #000000; FONT-SIZE: 10px; FONT-FAMILY: Verdana, Helvetica}
.option 	{BACKGROUND: none; COLOR: #000000; FONT-SIZE: 10px; FONT-WEIGHT: bold; FONT-FAMILY: Verdana, Helvetica; TEXT-DECORATION: none}
.tiny		{BACKGROUND: none; COLOR: #000000; FONT-SIZE: 10px; FONT-WEIGHT: normal; FONT-FAMILY: Verdana, Helvetica; TEXT-DECORATION: none}

</style>
	<link rel="stylesheet" href="../themes/sergids/css/common.css" TYPE="text/css">
</head>
<body>
<?php
define(FORUM_ADMIN,'1');
define(ADMIN_FILE,'1');
include_once("../../../mainfile.php");
include_once("../../../config.php");

define(_INSTALL_MODULENAME,"Top Music");
define(_INSTALL_VERSION,"3");
######################################################################
# Top Music 3.0.0
######################################################################
#
# Copyright (c) 2005 by SergiDs.com
# http://www.sergids.com
#
######################################################################

global $admin,$prefix,$db,$language;

if (!is_admin($admin)) { die ("To install/uninstall Top Music you must be an administrator.<br><br><b><a href=\"/".$admin_file.".php\">Return to PHPNuke Administration</a></b><br>\n"); }

switch($op) {

    default:
		echo "<center><b>"._INSTALL_MODULENAME." :: Install/Uninstall</b></center>";
		echo "<br>";
		echo "<table align='center' border='0' cellpadding='2' cellspacing='2'>\n";
		echo "<form action='".$_SERVER['PHP_SELF']."' method='post'>\n";
		echo "<tr><td>This script will install or uninstall the SQL tables for "._INSTALL_MODULENAME." "._INSTALL_VERSION."</td></tr>\n";
		echo "<tr><td><b>You should backup your SQL Tables before upgrading.</b></td></tr>\n";
		echo "<tr><td><select name='op'>\n";
		echo "<option value='install'>Install "._INSTALL_MODULENAME."</option>\n";
		echo "<option value='loadData'>Load sample data</option>\n";
		echo "<option value='uninstall'>Uninstall "._INSTALL_MODULENAME."</option>\n";
		echo "</select> <input type='submit' value='COMMIT'></td></tr>\n";
		echo "<tr><td><b>Once you have finished with this script, delete it from your server!</b></td></tr>\n";
		echo "</form>";
		echo "</table>\n";
    break;

    case "install":
		echo "<center><b>"._INSTALL_MODULENAME." :: Install</b></center>";
		echo "<br>";
		parse_mysql_dump($db,$prefix,"./metadata.sql",&$success,&$errors);
    break;

    case "loadData":
		echo "<center><b>"._INSTALL_MODULENAME." :: Load sample data</b></center>";
		echo "<br>";
		parse_mysql_dump($db,$prefix,"./data.sql",$success,&$errors);
    break;

    case "uninstall":
		echo "<center><b>"._INSTALL_MODULENAME." :: Uninstall</b></center>";
		echo "<br>";
		parse_mysql_dump($db,$prefix,"./metadata_tables.sql",$success,&$errors);
		echo "<br>";
		echo "<center>Let us know why you want to uninstall Top Music <a href=\"http://www.sergids.com/modules.php?name=Feedback2\" target=\"_blank\">here</a></center>";
    break;

}
echo "<center>";
if($success){
	echo "<br><br><font color='green'><b>Operation Complete Successfully!</b></font><br>\n";
	if($_POST['op']!="" && $_POST['op']!="uninstall"){
		echo "<br><br><b><a href=\"/".$admin_file.".php?op=topmusic&action=config\">Configure TopMusic</a> :: <a href=\"topmusic_install.php\">Go back to installation menu</a></b><br>\n";	
		echo '<br><br><b><font color="red">Don\'t forget to delete installation files when finish!! (modules/topMusic/install)</font></b>';
	}elseif($_POST['op']=="uninstall"){
		echo "<br><br><b><a href=\"/".$admin_file.".php\">Return to PHPNuke administration</a></b> :: <a href=\"topmusic_install.php\">Go back to installation menu</a></b><br><br>\n";	
		echo '<br><br><b><font color="red">Don\'t forget to delete Top Music files!! (modules/topMusic)</font></b>';
	}
}
elseif($_POST['op']!=""){
	echo "<br><br><font color='red'><b>Operation Failed!</b></font><br>\n";
	echo $errors;
	echo "<br>";
	echo "<br><br><b><a href=\"topmusic_install.php\">Return to installation menu</a></b><br>\n";
echo "</center>";
}

function parse_mysql_dump($db,$prefix, $url, &$success,&$errors) {
   $success=true;
   $file_content = file($url);
 	$file_content=str_replace('`nuke`.`nuke_','`'.$db->dbname.'`.`'.$prefix.'_',$file_content);
   //die(print_r($file_content));
   foreach($file_content as $sql_line) {
     $sqlQuery.=$sql_line;
     if(strpos($sqlQuery,";\n")){
     	$sqlQuery=str_replace(";\n","",$sqlQuery);
     	//$sqlQuery=str_replace(';\n','',$sqlQuery);
    	//echo "sql=$sqlQuery<br>";
     	$result = $db->sql_query($sqlQuery);
		$error=$db->sql_error();
		if ($error['message']!="") { 
			//echo "Query: $sqlQuery <br>\n";
			//echo "<font color='red'>Failed: ".$error['message']."</font><br><br>\n"; 
			$errors.=$error['message']."<br>";
			$success=false;
		} else { 
			//echo "Success!<br>\n"; 
		}
     	$sqlQuery="";
     }
     
   }
  }

?>
</body>
</html>
Return current item: Top Music module