Location: PHPKode > projects > Top Music module > Top Music 3.0.7/html/modules/topMusic/install/topmusic_update.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");

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 update 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:
		//include("../../../header.php");
		echo "<div id=\"tm_module\">\n";
		echo "<div id=\"tm_title\"><center><img src=\"../themes/sergids/images/topmusic.gif\" align=\"absmiddle\"><b> :: Update from 2.1.4 to "._INSTALL_VERSION."</b></center></div>\n";
		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 update the SQL tables to "._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='update'>Update tables "._INSTALL_MODULENAME." from 2.x to "._INSTALL_VERSION."</option>\n";
		echo "<option value='update2'>Update tables "._INSTALL_MODULENAME." from 3.0PR5 to "._INSTALL_VERSION."</option>\n";
		//echo "<option value='updateData'>Update sample data</option>\n";
		echo "</select> <input type='submit' value='COMMIT'></td></tr>\n";
		echo "<tr><td><b><font color=\"red\">Once you have finished with this script, delete install folder from your server!</font></b></td></tr>\n";
		echo "</form>\n";
		echo "</table>\n";
		echo "</div>\n";

		//include("../../../footer.php");
    break;

    case "update":
		echo "<div id=\"tm_module\"><div id=\"tm_title\"><center><img src=\"../themes/sergids/images/topmusic.gif\" align=\"absmiddle\"><b> :: UPDATE</b></center></div></div>";
		echo "<br>";
		parse_mysql_dump($db,$prefix,"./update_2x_3.sql",&$success,&$errors);
    break;

   case "update2":
		echo "<center><img src=\"../themes/sergids/images/topmusic.gif\" align=\"absmiddle\"><b> :: UPDATE</b></center>";
		echo "<br>";
		parse_mysql_dump($db,$prefix,"./update_3PR5_3.sql",&$success,&$errors);
    break;

   case "updateData":
		echo "<center><img src=\"../themes/sergids/images/topmusic.gif\" align=\"absmiddle\"><b> :: Update sample data</b></center>";
		echo "<br>Caution, This action will delete all contents in existing top music tables.";
		echo "<br>";
	
		//START UPDATEDATA
	
		//END LOAD
    break;

}
if($_POST['op']!=""){
	echo "<div id=\"tm_module\">";
	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></b><br>\n";	
		elseif($_POST['op']=="uninstall")
			echo "<br><br><b><a href=\"/".$admin_file.".php?op=topmusic&action=config\">Return to PHPNuke administration</a></b><br>\n";	
	}
	else{
		echo "<br><br><font color='red'><b>Operation Failed!</b></font><br>\n";
		echo $errors;
	}
	echo "</center></div>";
	echo "<div id=\"tm_module\">";
	echo "<center>";
	echo "<br><br><b><a href=\"topmusic_update.php\">Return to menu</a></b><br>\n";
	echo "</center>";
	echo "</div>";
}else{
		echo "<div id=\"tm_module\">";
	echo "<center>";
	echo "<br><br><b><a href=\"/".$admin_file.".php\">Return to PHPNuke Administration</a></b><br>\n";
	echo "</center>";
	echo "</div>";
}

function parse_mysql_dump($db,$prefix, $url, &$success,&$errors) {
   $success=true;
   $file_content = file($url);
   if($db->prefix!="nuke")
   	$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,";")){
    	//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