Location: PHPKode > projects > Top Music module > Top Music 3.0.7/html/modules/topMusic/admin/index.php
<?php

/************************************************************************/
/* Top Music: Administration Module                                          */
/* ===========================                                          */
/*                                                                      */
/* Copyright (c) 2004 by SergiDs.com                                */
/* http://phpnuke.org                                                   */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/
if (!defined('ADMIN_FILE')) {
	die ("Access Denied");
}
global $prefix, $db, $admin_file;

$module_name=explode('/',dirname(__FILE__));
if(count($module_name)<=1)
	$module_name=explode('\\',dirname(__FILE__));
$module_name = $module_name[count($module_name)-2];
$aid = substr("$aid", 0,25);
$row = $db->sql_fetchrow($db->sql_query("SELECT title, admins FROM ".$prefix."_modules WHERE title='".$module_name."'"));
$row2 = $db->sql_fetchrow($db->sql_query("SELECT name, radminsuper FROM ".$prefix."_authors WHERE aid='$aid'"));
$admins = explode(",", $row['admins']);
$auth_user = 0;
for ($i=0; $i < sizeof($admins); $i++) {
	if ($row2['name'] == "$admins[$i]" AND $row['admins'] != "") {
		$auth_user = 1;
	}
}

if ($row2['radminsuper'] == 1 || $auth_user == 1) {

	echo '<script charset="'._CHARSET.'" type="text/javascript" language="javascript" src="modules/'.$module_name.'/admin/js/mootools.js"></script>
	<script charset="'._CHARSET.' type="text/javascript" language="javascript" src="modules/'.$module_name.'/admin/js/common.js"></script>
	<script charset="'._CHARSET.' type="text/javascript" language="javascript" src="modules/'.$module_name.'/themes/sergids/js/common.js"></script>
	<script charset="'._CHARSET.' type="text/javascript" language="javascript" src="modules/'.$module_name.'/admin/js/artist.js"></script>';
	
	
	//load configuration
	require_once("modules/$module_name/admin/lib/com/sergids/topmusic/model/ConfigAdminDAO.php");
	$configAdminDAO=new ConfigAdminDAO($db,$prefix);
	$configAdmin=$configAdminDAO->load();
	define(_TOPMUSIC_MODULENAME,$module_name);
	define(_TOPMUSIC_BASEURL,$configAdmin->base_url);

	if(file_exists("modules/"._TOPMUSIC_MODULENAME."/language/lang-$currentlang.php")) { include("modules/"._TOPMUSIC_MODULENAME."/language/lang-$currentlang.php"); } else { include("modules/"._TOPMUSIC_MODULENAME."/language/lang-english.php"); }
	if(file_exists("modules/"._TOPMUSIC_MODULENAME."/admin/language/lang-$currentlang.php")) { include("modules/"._TOPMUSIC_MODULENAME."/admin/language/lang-$currentlang.php"); } else { include("modules/"._TOPMUSIC_MODULENAME."/admin/language/lang-english.php"); }

	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/view/AdminTopView.php");
	include("header.php");
	if($configAdmin->nuke_menu) {
		GraphicAdmin();
	}
	$action=$_POST['action'];
	if($action=="")
		$action=$_GET['action'];
	echo "<a name=\"top\">";
	AdminTopView::printMenu($action);
	switch ($action) {
	    case "addArtist":
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/GenreAdminDAO.php");
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/view/GenericAdminView.php");
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/ArtistAdminDAO.php");
	    	$genreDAO=new GenreAdminDAO($db,$prefix);
	    	$genreList=$genreDAO->getGenreList($currentlang);
	    	$artistDAO=new ArtistAdminDAO($db,$prefix);
	    	$artistList=$artistDAO->getSelectList();
	    	$artistFields=$artistDAO->getCustomFields();
	    	if($_POST['submit']!=""){
				require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/ArtistAdminO.php");
				$artistO=new ArtistAdminO();
				$artistO->setGenreid($_POST['genre']);
				$artistO->setName($_POST['name']);
				$artistO->setBornyear($_POST['bornyear']);
				$artistO->setDeadyear($_POST['deadyear']);
				$artistO->setBiography($_POST['biography']);
				$artistO->setPhoto($_POST['photo']);
				$artistO->setWeb($_POST['web']);
				$artistO->setForum($_POST['forum']);
				$artistO->setMembers($_POST['members']);
				$artistO->setCount($_POST['views']);
				$artistO->setAvgvotes($_POST['avgvotes']);
				if($_FILES["photo_upload"]["size"]>0){
					$directory="modules/"._TOPMUSIC_MODULENAME."/photos/";
					if(move_uploaded_file($_FILES["photo_upload"]["tmp_name"],($directory.$_FILES["photo_upload"]["name"]))){
						chmod($directory.$_FILES["photo_upload"]["name"],0755);
				    	$artistO->photo_file=$_FILES["photo_upload"]["name"]; 
					}
				}elseif($_POST['photo_url']!="") { 
               		$artistO->photo=$_POST['photo_url']; 
            	}
				$artistDAO->insertArtist(&$artistO,$currentlang);
				$artistDAO->updateCustomFields($artistO->getId(),$_POST);
				$error=$db->sql_error();
				if($error['message']==""){
					if($_POST["related"]!="" && $_POST["related"]!="..."){
						if(!$artistDAO->insertRelated($artistO->getId(),$_POST["related"]))
							$message=_TOPMUSIC_RELATED_ARTIST_ERROR."<br>";
					}
					$message=_TOPMUSIC_ADDARTIST_SUCCESSFULLY;
				}else
					$message=_TOPMUSIC_ADDARTIST_ERROR.": ".$error['message'];
			}
	    	OpenTable();
			echo "<center><B>"._TOPMUSIC_ADDARTIST."</B></center>";
			CloseTable();
			echo "<br>";
	    	include("modules/"._TOPMUSIC_MODULENAME."/admin/newArtist.php");
	    	break;
	    case "addAlbum":
			require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/GenreAdminDAO.php");
			require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/ArtistAdminDAO.php");
			require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/AlbumAdminDAO.php");
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/view/GenericAdminView.php");
	    	$genreDAO=new GenreAdminDAO($db,$prefix);
			$artistDAO=new ArtistAdminDAO($db,$prefix);
	    	$albumDAO=new AlbumAdminDAO($db,$prefix);
	    	$genreList=$genreDAO->getGenreList($currentlang);
	    	$artistList=$artistDAO->getSelectList(true);
	    	$albumFields=$albumDAO->getCustomFields();
	    	if($_POST["artist"])
	    		$artist=$_POST["artist"];
	    	elseif($_GET["idartist"])
	    		$artist=$_GET["idartist"];
	    	if($_POST['submit']!=""){
				require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/AlbumAdminO.php");
				require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/AlbumAdminDAO.php");
				$albumO=new AlbumAdminO();
				
				if($_FILES["frontcover_file"]["size"]>0){
					$directory="modules/"._TOPMUSIC_MODULENAME."/photos/albums/";
					if(move_uploaded_file($_FILES["frontcover_file"]["tmp_name"],($directory.$_FILES["frontcover_file"]["name"]))){
						chmod($directory.$_FILES["frontcover_file"]["name"],0755);
				    	$albumO->setFrontcover_file($_FILES["frontcover_file"]["name"]); 
					}else{
						$message.=_TOPMUSIC_FRONTCOVER_FILE_UPLOAD_ERROR."<br>";
					}
				}
				if($_FILES["backcover_file"]["size"]>0){
					$directory="modules/"._TOPMUSIC_MODULENAME."/photos/albums/";
					if(move_uploaded_file($_FILES["backcover_file"]["tmp_name"],($directory.$_FILES["backcover_file"]["name"]))){
						chmod($directory.$_FILES["backcover_file"]["name"],0755);
				    	$albumO->setBackcover_file($_FILES["backcover_file"]["name"]); 
					}else{
						$message.=_TOPMUSIC_BACKCOVER_FILE_UPLOAD_ERROR."<br>";
					}
				}
				$albumO->setGenreid($_POST['genre']);
				$albumO->setTitle($_POST['title']);
				$albumO->setYeardate($_POST['yeardate']);
				$albumO->setComments($_POST['comments']);
				$albumO->setFrontcover_url($_POST['frontcover_url']);
				$albumO->setBackcover_url($_POST['backcover_url']);
				$albumO->setIdartist($artist);
				$albumO->setAmazonid($_POST['amazonid']);
				$albumO->setCount($_POST['views']);
				$albumO->setAvgvotes($_POST['avgvotes']);
				$albumDAO->insertAlbum(&$albumO,$currentlang);
				$albumDAO->updateCustomFields($albumO->getId(),$_POST);
				$error=$db->sql_error();
				if($error['message']==""){
					if($_POST["related"]!="" && $_POST["related"]!="..."){
						if(!$albumDAO->insertRelated($albumO->getId(),$_POST["related"]))
							$message=_TOPMUSIC_RELATED_ALBUM_ERROR."<br>";
					}
					$message=_TOPMUSIC_ADDALBUM_SUCCESSFULLY;
				}else
					$message=_TOPMUSIC_ADDALBUM_ERROR.": ".$error['message'];
			}
	    	OpenTable();
			echo "<center><B>"._TOPMUSIC_ADDALBUM."</B></center>";
			CloseTable();
			echo "<br>";
	    	include("modules/"._TOPMUSIC_MODULENAME."/admin/newAlbum.php");
	    	break;
	    case "addSong":
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/GenreAdminDAO.php");
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/view/GenericAdminView.php");
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/ArtistAdminDAO.php");
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/SongAdminDAO.php");
	    	$genreDAO=new GenreAdminDAO($db,$prefix);
	    	$genreList=$genreDAO->getGenreList($currentlang);
	    	$artistDAO=new ArtistAdminDAO($db,$prefix);
	    	$artistList=$artistDAO->getSelectList(true);
	    	if($_POST["artist"])
	    		$artist=$_POST["artist"];
	    	elseif($_GET["idartist"])
	    		$artist=$_GET["idartist"];
	    	if($_POST["album"])
	    		$album=$_POST["album"];
	    	elseif($_GET["idalbum"])
	    		$album=$_GET["idalbum"];
	    	$albumDAO=new AlbumAdminDAO($db,$prefix);
	    	$albumList=$albumDAO->getSelectList($artist,true);
	    	$songDAO=new SongAdminDAO($db,$prefix);
	    	$songFields=$songDAO->getCustomFields();
	    	if($_POST['submit']!=""){
				require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/SongAdminO.php");
				$songO=new SongAdminO();
				$songO->setGenreid($_POST['genre']);
				$songO->setTitle($_POST['title']);
				$songO->setTrack($_POST['track']);
				$songO->setLyrics($_POST['lyrics']);
				$songO->setIdalbum($album);
				$songO->setNumber($_POST['number']);
				$songO->setCount($_POST['views']);
				$songO->setAvgvotes($_POST['avgvotes']);
				$songDAO->insertSong(&$songO,$currentlang);
				$songDAO->updateCustomFields($songO->getId(),$_POST);
				$error=$db->sql_error();
				if($error['message']==""){
					if($_POST["related"]!="" && $_POST["related"]!="..."){
						if(!$songDAO->insertRelated($songO->getId(),$_POST["related"]))
							$message=_TOPMUSIC_RELATED_SONG_ERROR."<br>";
					}
					$message=_TOPMUSIC_ADDSONG_SUCCESSFULLY;
				}else
					$message=_TOPMUSIC_ADDSONG_ERROR.": ".$error['message'];
			}
	    	OpenTable();
			echo "<center><B>"._TOPMUSIC_ADDSONG."</B></center>";
			CloseTable();
			echo "<br>";
	    	include("modules/"._TOPMUSIC_MODULENAME."/admin/newSong.php");
	    	break;
	    case "delAlbum":
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/AlbumAdminDAO.php");
			$albumDAO=new AlbumAdminDAO($db,$prefix);
			$albumDAO->deleteAlbum($_GET['idartist'],$_GET['idalbum']);
			$error=$db->sql_error();
			if($error['message']==""){
				$message=_TOPMUSIC_DELETEALBUM_SUCCESSFULLY;
			}else{
				$message=_TOPMUSIC_DELETEALBUM_ERROR.": ".$error['message'];
			}
			echo "<font color=\"red\">$message</font>";
	    case "listAlbum":
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/ArtistAdminDAO.php");
			require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/AlbumAdminDAO.php");
			require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/ArtistAdminO.php");
			require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/AlbumAdminO.php");
			require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/view/AlbumAdminView.php");
			require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/view/GenericAdminView.php");
			if($_POST["artist"])
				$artist=$_POST["artist"];
			else
				$artist=$_GET["idartist"];
			$artistDAO=new ArtistAdminDAO($db,$prefix);
			$artistO=$artistDAO->getArtist($artist,$currentlang);
	    	$artistList=$artistDAO->getSelectList();
			$albumDAO=new AlbumAdminDAO($db,$prefix);
			if(!is_numeric($artist))
				$orphanAlbumList=$albumDAO->getOrphanList($currentlang);
			else
				$albumList=$albumDAO->getAlbumList($artist,$currentlang);			
			include("modules/"._TOPMUSIC_MODULENAME."/admin/listAlbum.php");
	    	break;
	     case "orphanAlbums":
			require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/AlbumAdminDAO.php");
			require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/AlbumAdminO.php");
			require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/view/AlbumAdminView.php");
			require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/view/GenericAdminView.php");
			$albumDAO=new AlbumAdminDAO($db,$prefix);
			$orphanAlbumList=$albumDAO->getOrphanList($currentlang);
			include("modules/"._TOPMUSIC_MODULENAME."/admin/orphanAlbums.php");
	    	break;
	    case "delSong":
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/SongAdminDAO.php");
			$songDAO=new SongAdminDAO($db,$prefix);
			$songDAO->deleteSong($_GET['idsong']);
			$error=$db->sql_error();
			if($error['message']==""){
				$message=_TOPMUSIC_DELETESONG_SUCCESSFULLY;
			}else{
				$message=_TOPMUSIC_DELETESONG_ERROR.": ".$error['message'];
			}
			echo "<font color=\"red\">$message</font>";
	    case "listSong":
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/AlbumAdminDAO.php");
			require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/SongAdminDAO.php");
			require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/AlbumAdminO.php");
			require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/SongAdminO.php");
			require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/view/SongAdminView.php");
			require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/view/GenericAdminView.php");
			if($_POST["artist"])
				$idartist=$_POST["artist"];
			else
				$idartist=$_GET["idartist"];
			if($_POST["album"])
				$album=$_POST["album"];
			else
				$album=$_GET["idalbum"];
			$artistDAO=new ArtistAdminDAO($db,$prefix);
			$artistList=$artistDAO->getSelectList(true);
			$albumDAO=new AlbumAdminDAO($db,$prefix);
			$albumO=$albumDAO->getAlbum($album,$currentlang);
			if(is_numeric($idartist))
				$albumList=$albumDAO->getSelectList($idartist,false);
			elseif($idartist=="orphan")
				$albumList=$albumDAO->getSelectList("orphan",true);
			$songDAO=new SongAdminDAO($db,$prefix);
			if(!is_numeric($album))
				$orphanList=$songDAO->getOrphanList($currentlang);
			else
				$songList=$songDAO->getSongList($album,$currentlang);	
			include("modules/"._TOPMUSIC_MODULENAME."/admin/listSong.php");
	    	break;
	    case "orphanSongs":
			require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/SongAdminDAO.php");
			require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/SongAdminO.php");
			require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/view/SongAdminView.php");
			require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/view/GenericAdminView.php");
			$songDAO=new SongAdminDAO($db,$prefix);
			$orphanList=$songDAO->getOrphanList($currentlang);
			include("modules/"._TOPMUSIC_MODULENAME."/admin/orphanSongs.php");
	    	break;
	    case "editArtist":
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/ArtistAdminO.php");
			require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/ArtistAdminDAO.php");
			require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/GenreAdminDAO.php");
			require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/GenericAdminDAO.php");
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/view/ArtistAdminView.php");
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/ArtistAdminBiz.php");
			$artistDAO=new ArtistAdminDAO($db,$prefix);
			$genreDAO=new GenreAdminDAO($db,$prefix);
			$genericDAO=new GenericAdminDAO($db,$prefix);
			$genreList=$genreDAO->getGenreList($currentlang);
	    	$artistList=$artistDAO->getSelectList();
			$artistO=new ArtistAdminO();
			$artistO->setId($_GET['idartist']);
			$languageList=$genericDAO->getLanguageList();
			if($_POST['submit1']!="" || $_POST["addRelated"]!=""){
				if($_FILES["photo_upload"]["size"]>0){
					$directory="modules/"._TOPMUSIC_MODULENAME."/photos/";
					if(move_uploaded_file($_FILES["photo_upload"]["tmp_name"],($directory.$_FILES["photo_upload"]["name"]))){
						chmod($directory.$_FILES["photo_upload"]["name"],0755);
				    	$artistO->setPhoto_file($_FILES["photo_upload"]["name"]); 
					}
				}elseif($_POST['photo']!=""){
					$artistO->setPhoto_file($_POST['photo']);
				}
				$artistO->setGenreid($_POST['genre']);
				$artistO->setName($_POST['name']);
				$artistO->setBornyear($_POST['bornyear']);
				$artistO->setDeadyear($_POST['deadyear']);
				$artistO->setBiography($_POST['biography']);
				$artistO->setPhoto($_POST['photo']);
				$artistO->setWeb($_POST['web']);
				$artistO->setForum($_POST['forum']);
				$artistO->setMembers($_POST['members']);
				$artistO->setCount($_POST['views']);
				$artistO->setAvgvotes($_POST['avgvotes']);
				$artistDAO->updateArtist($artistO,$currentlang);
				$artistDAO->updateCustomFields($_GET['idartist'],$_POST);
				$error=$db->sql_error();
				if($error['message']==""){
					$message=_TOPMUSIC_UPDATEARTIST_SUCCESSFULLY;
					if($_POST["related"]!="" && $_POST["related"]!="..."){
						if(!$artistDAO->insertRelated($artistO->getId(),$_POST["related"]))
							$message=_TOPMUSIC_RELATED_ARTIST_ERROR;
					}
				}else
					$message=_TOPMUSIC_EDITARTIST_ERROR.": ".$error['message'];
			}
			if($_POST["actiondel"]=="deletePhoto"){
				ArtistAdminBiz::deletePhoto($_GET['idartist'],$artistDAO,$currentlang,_TOPMUSIC_MODULENAME);
			}
			if($_POST["unlink"]!=""){
					if(!$artistDAO->deleteRelated($artistO->getId(),$_POST["unlink"]))
						$message=_TOPMUSIC_UNLINKARTIST_ERROR;
			}
			$artist=$artistDAO->getArtist($_GET['idartist'],$currentlang);
			$artistFields=$artistDAO->getCustomFieldsValues($_GET['idartist']);
			$relatedList=$artistDAO->getRelated($_GET['idartist']);
			OpenTable();
			echo "<center><B>"._TOPMUSICEDITARTIST."</B></center>";
			CloseTable();
			echo "<br>";
			include_once("editArtist.php");
	    	break;
	    case "editAlbum":
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/AlbumAdminDAO.php");
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/ArtistAdminDAO.php");
			require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/GenreAdminDAO.php");
			require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/GenericAdminDAO.php");
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/view/AlbumAdminView.php");
			require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/AlbumAdminO.php");
			require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/view/GenericAdminView.php");
			require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/AlbumAdminBiz.php");
			$albumDAO=new AlbumAdminDAO($db,$prefix);
			$artistDAO=new ArtistAdminDAO($db,$prefix);
			$genreDAO=new GenreAdminDAO($db,$prefix);
			$genericDAO=new GenericAdminDAO($db,$prefix);
			$genreList=$genreDAO->getGenreList($currentlang);
			$artistList=$artistDAO->getSelectList(true);
			$albumList=$albumDAO->getSelectList();
			$languageList=$genericDAO->getLanguageList();
			if($_POST["artist"]!="")
				$artist=$_POST["artist"];
			else
				$artist=$_GET["idartist"];
			if($_POST['submit1']!="" || $_POST["addRelated"]!=""){
				$albumO=new AlbumAdminO();
				if($_FILES["frontcover_file"]["size"]>0){
					$directory="modules/"._TOPMUSIC_MODULENAME."/photos/albums/";
					if(move_uploaded_file($_FILES["frontcover_file"]["tmp_name"],($directory.$_FILES["frontcover_file"]["name"]))){
				    	chmod($directory.$_FILES["frontcover_file"]["name"],0755);
				    	$albumO->setFrontcover_file($_FILES["frontcover_file"]["name"]); 
					}
				}
				if($_FILES["backcover_file"]["size"]>0){
					$directory="modules/"._TOPMUSIC_MODULENAME."/photos/albums/";
					if(move_uploaded_file($_FILES["backcover_file"]["tmp_name"],($directory.$_FILES["backcover_file"]["name"]))){
						chmod($directory.$_FILES["backcover_file"]["name"],0755);
				    	$albumO->setBackcover_file($_FILES["backcover_file"]["name"]); 
					}
				}
				$albumO->setFrontcover_url($_POST['frontcover_url']);
				$albumO->setBackcover_url($_POST['backcover_url']);
				$albumO->setId($_GET['idalbum']);
				$albumO->setIdartist($artist);
				$albumO->setGenreid($_POST['genre']);
				$albumO->setTitle($_POST['title']);
				$albumO->setYeardate($_POST['yeardate']);
				$albumO->setComments($_POST['comments']);
				$albumO->setShopurl($_POST['amazonid']);
				$albumO->setCount($_POST['views']);
				$albumO->setAvgvotes($_POST['avgvotes']);
				$albumDAO->updateAlbum($albumO,$currentlang);
				$albumDAO->updateCustomFields($_GET['idalbum'],$_POST);
				$error=$db->sql_error();
				if($error['message']==""){
					$message=_TOPMUSIC_UPDATEALBUM_SUCCESSFULLY;
					if($_POST["related"]!="" && $_POST["related"]!="..."){
						if(!$albumDAO->insertRelated($albumO->getId(),$_POST["related"]))
							$message=_TOPMUSIC_RELATED_ALBUM_ERROR;
					}
				}else
					$message=_TOPMUSIC_EDITALBUM_ERROR.": ".$error['message'];
			}elseif($_POST["actiondel"]!=""){
				if(AlbumAdminBiz::deletePhoto($_GET['idalbum'],$albumDAO,$currentlang,_TOPMUSIC_MODULENAME,$_POST["actiondel"]))
					$message=_TOPMUSIC_DELETEFILE_SUCCESSFULLY;
				else
					$message=_TOPMUSIC_DELETEFILE_ERROR;
			}elseif($_POST["unlink"]!=""){
					if(!$albumDAO->deleteRelated($_GET['idalbum'],$_POST["unlink"]))
						$message=_TOPMUSIC_UNLINKALBUM_ERROR;
			}
			$album=$albumDAO->getAlbum($_GET['idalbum'],$currentlang);
			$albumFields=$albumDAO->getCustomFieldsValues($_GET['idalbum']);
			$relatedList=$albumDAO->getRelated($_GET['idalbum']);
			OpenTable();
			echo "<center><B>"._TOPMUSIC_EDITALBUM."</B></center>";
			CloseTable();
			echo "<br>";
			include_once("editAlbum.php");
	    	break;
	    case "editSong":
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/SongAdminO.php");
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/SongAdminDAO.php");
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/ArtistAdminDAO.php");
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/AlbumAdminDAO.php");
			require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/GenreAdminDAO.php");
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/view/SongAdminView.php");
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/view/GenericAdminView.php");
			$songDAO=new SongAdminDAO($db,$prefix);
			$genreDAO=new GenreAdminDAO($db,$prefix);
			$genreList=$genreDAO->getGenreList($currentlang);
			$artistDAO=new ArtistAdminDAO($db,$prefix);
			$artistList=$artistDAO->getSelectList(true);
			$albumDAO=new AlbumAdminDAO($db,$prefix);
			$albumList_related=$albumDAO->getSelectList($_GET['idartist'],true);
			$albumList=$albumDAO->getSelectList($_GET['idartist']);
			if($_POST["album"])
				$album=$_POST["album"];
			else
				$album=$_GET["idalbum"];
			if($_POST['submit1']!="" || ($_POST["link"]!="..." && $_POST["link"]!="")){
				$songO=new SongAdminO();
				$songO->setId($_GET['idsong']);
				$songO->setIdalbum($album);
				$songO->setGenreid($_POST['genre']);
				$songO->setTitle($_POST['title']);
				$songO->setNumber($_POST['number']);
				$songO->setLyrics($_POST['lyrics']);
				$songO->setTrack($_POST['track']);
				$songO->setCount($_POST['views']);
				$songO->setAvgvotes($_POST['avgvotes']);
				$songDAO->updateSong($songO,$currentlang);
				$songDAO->updateCustomFields($_GET['idsong'],$_POST);
				$error=$db->sql_error();
				if($error['message']==""){
					$message=_TOPMUSIC_UPDATESONG_SUCCESSFULLY;
					if($_POST["link"]!="" && $_POST["link"]!="..."){
						if(!$songDAO->insertRelated($songO->getId(),$_POST["link"]))
							$message=_TOPMUSIC_RELATED_SONG_ERROR;
					}
				}else
					$message=_TOPMUSIC_EDITSONG_ERROR.": ".$error['message'];
			}elseif($_POST["unlink"]!=""){
					if(!$songDAO->deleteRelated($_GET['idsong'],$_POST["unlink"]))
						$message=_TOPMUSIC_UNLINKSONG_ERROR;
			}
			
			$song=$songDAO->getSong($_GET['idsong'],$currentlang);
			$songFields=$songDAO->getCustomFieldsValues($_GET['idsong']);
			$relatedList=$songDAO->getRelated($_GET['idsong']);
			OpenTable();
			echo "<center><B>"._TOPMUSIC_EDITSONG."</B></center>";
			CloseTable();
			echo "<br>";
			include_once("editSong.php");
	    	break;
	    case "search":
			require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/view/GenericAdminView.php");
			require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/GenreAdminDAO.php");
			if($_POST['page']!="" && $_POST['page']>0)
					$searchPage=$_POST['page'];
				else
					$searchPage=1;
				if($_POST['what']!=""){
					switch($_POST['what']){
						case "artists":
							require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/ArtistAdminO.php");
							require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/ArtistAdminDAO.php");
							require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/view/ArtistAdminView.php");
							$artistO=new ArtistAdminO();
							$artistView=new ArtistAdminView();
							$artistO->setName($_POST['artistname']);
							$artistO->setBornyear($_POST['year']);
							$artistO->setGenreid($_POST['genre']);
							$artistO->setSongtitle($_POST['songname']);
							$artistO->setAlbumname($_POST['albumname']);
							$artistDAO=new ArtistAdminDAO($db,$prefix);
							$artistList=$artistDAO->searchArtist($artistO,$_POST['content'],$currentlang,$searchPage,10);
							break;
						case "albums":
							require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/AlbumAdminO.php");
							require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/AlbumAdminDAO.php");
							require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/view/AlbumAdminView.php");
							$albumO=new AlbumAdminO();
							$albumView=new AlbumAdminView();
							$albumO->setArtistname($_POST['artistname']);
							$albumO->setTitle($_POST['albumname']);
							$albumO->setSongtitle($_POST['songname']);
							$albumO->setYeardate($_POST['year']);
							$albumO->setGenreid($_POST['genre']);
							$albumDAO=new AlbumAdminDAO($db,$prefix);
							$albumList=$albumDAO->searchAlbum($albumO,$_POST['content'],$currentlang,$searchPage,10);
							break;
						default:
							require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/SongAdminO.php");
							require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/SongAdminDAO.php");
							require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/view/SongAdminView.php");
							$songO=new SongAdminO();
							$songView=new SongAdminView();
							$songO->setTitle($_POST['songname']);
							$songO->setAlbumname($_POST['albumname']);
							$songO->setArtistname($_POST['artistname']);
							$songO->setGenreid($_POST['genre']);
							$songDAO=new SongAdminDAO($db,$prefix);
							$songList=$songDAO->searchSong($songO,$_POST['content'],$currentlang,$searchPage,10);
							if($_POST['page']!="" && $_POST['page']==1)
								$numSongs=count($songList);
					}
				}
				$genreDAO=new GenreAdminDAO($db,$prefix);
				$genreList=$genreDAO->getGenreList($currentlang);
				$genericView=new GenericAdminView();
				OpenTable();
				echo "<center><B>"._TOPMUSIC_SEARCH."</B> - "._TOPMUSIC_SELECTTOSEARCH."</center>";
				CloseTable();
				include("modules/"._TOPMUSIC_MODULENAME."/admin/search.php");
	    	break;
	    case "delGenre":
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/GenreAdminDAO.php");
	    	$genreDAO=new GenreAdminDAO($db,$prefix);
	    	$genreDAO->deleteGenre($_GET['idgenre']);
			$error=$db->sql_error();
			if($error['message']==""){
				$message=_TOPMUSIC_DELETEGENRE_SUCCESSFULLY;
			}else{
				$message=_TOPMUSIC_DELETEGENRE_ERROR.": ".$error['message'];
			}
	    case "listGenre":
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/GenreAdminDAO.php");
	    	$genreDAO=new GenreAdminDAO($db,$prefix);
	    	$listGenre=$genreDAO->getGenreList($currentlang);
	    	include("modules/"._TOPMUSIC_MODULENAME."/admin/listGenre.php");
	    	break;
	    case "editGenre":
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/GenreAdminDAO.php");
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/GenreAdminO.php");
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/GenericAdminDAO.php");
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/view/GenericAdminView.php");
	    	$genericDAO=new GenericAdminDAO($db,$prefix);
	    	$languageList=$genericDAO->getLanguageList();
	    	if($_POST['submit1']!=""){
				$genreO=new GenreAdminO();
				$genreDAO=new GenreAdminDAO($db,$prefix);
				$genreO->setId($_GET['idgenre']);
				$genreO->setName($_POST['name']);
				if($genreDAO->existsGenreLang($_GET['idgenre'],$currentlang)){
					$genreDAO->updateGenre($genreO,$currentlang);
	    		}else{
	    			$genreDAO->insertGenreLang($genreO,$currentlang);	
	    		}
				$error=$db->sql_error();
				if($error['message']=="")
					$message=_TOPMUSIC_UPDATEGENRE_SUCCESSFULLY;
				else
					$message=_TOPMUSIC_EDITGENRE_ERROR.": ".$error['message'];
			}
			$genreDAO=new GenreAdminDAO($db,$prefix);
			$genre=$genreDAO->getGenre($_GET['idgenre'],$currentlang);
			OpenTable();
			echo "<center><B>"._TOPMUSIC_EDITGENRE."</B></center>";
			CloseTable();
			echo "<br>";
			include_once("editGenre.php");
	    	break;
	    case "addGenre":
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/GenreAdminDAO.php");
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/GenreAdminO.php");
	    	if($_POST['submit1']!=""){
				$genreO=new GenreAdminO();
				$genreDAO=new GenreAdminDAO($db,$prefix);
				$genreO->setId($_GET['idgenre']);
				$genreO->setName($_POST['name']);
				$genreDAO->insertGenre($genreO,$currentlang);
				$error=$db->sql_error();
				if($error['message']=="")
					$message=_TOPMUSIC_ADDGENRE_SUCCESSFULLY;
				else
					$message=_TOPMUSIC_ADDGENRE_ERROR.": ".$error['message'];
			}
			OpenTable();
			echo "<center><B>"._TOPMUSIC_EDITGENRE."</B></center>";
			CloseTable();
			echo "<br>";
			include_once("newGenre.php");
	    	break;
	   case "delArtist":
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/ArtistAdminDAO.php");
			$artistDAO=new ArtistAdminDAO($db,$prefix);
			$artistDAO->deleteArtist($_GET['idartist']);
			$error=$db->sql_error();
			if($error['message']==""){
				$message=_TOPMUSIC_DELETEARTIST_SUCCESSFULLY;
			}else{
				$message=_TOPMUSIC_DELETEARTIST_ERROR.": ".$error['message'];
			}
			echo "<font color=\"red\">$message</font>";
	    case "AZ":
		default:
			require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/ArtistAdminO.php");
			require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/ArtistAdminDAO.php");
			require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/ArtistAdmin.php");
			require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/view/ArtistAdminView.php");
			$artistDAO=new ArtistAdminDAO($db,$prefix);
			$artistOO=new ArtistAdmin();
			$artistList=$artistDAO->getArtistIndex();
			if(count($artistList)>0)
				$artistAZ=$artistOO->orderAZ($artistList);
			$artistView=new ArtistAdminView();
			OpenTable();
			echo "<center><B>"._TOPMUSIC_BANDSAZ."</B> - "._TOPMUSIC_SELECTABANDTOEDIT."</center>";
			echo "<br>";
			if(count($artistList)>0)
				include("modules/"._TOPMUSIC_MODULENAME."/admin/AZ.php");
			CloseTable();
			OpenTable();
			if($artistList!="")
				$artistView->printArtistAZ($artistAZ);
			else
				echo "<center>"._TOPMUSIC_NOARTISTBAND."</center>";
			CloseTable();
			OpenTable();
			if($artistList!="")
				include("modules/"._TOPMUSIC_MODULENAME."/admin/AZ.php");
			CloseTable();
			break;
		case "config":
			require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/ConfigAdminO.php");
			require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/ConfigAdminDAO.php");
			$configDAO=new ConfigAdminDAO($db,$prefix);
			$config=new ConfigAdminO();
			if($_POST['saveconf']!=""){
				$config->request($_POST);
				$configDAO->update($config);
			}
			$config=null;
			$config=$configDAO->load();
			include("config_form.php");
			break;
		case "customFieldsArtist":
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/ArtistAdminDAO.php");
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/CustomFieldAdminO.php");
	    	$artistDAO=new ArtistAdminDAO($db,$prefix);
			
			if($_POST['fieldaction']!=""){
					$artistDAO->delCustomField($_POST['idfield']);
					$error=$db->sql_error();
					if($error['message']=="")
						$message=_TOPMUSIC_DELETECUSTOMFIELD_SUCCESSFULLY;
					else
						$message=_TOPMUSIC_DELETECUSTOMFIELD_ERROR.": ".$error['message'];
			}
			echo "<font color=\"red\">$message</font>";			
			$fieldsList=$artistDAO->getCustomFields();
			OpenTable();
			echo "<center><B>"._TOPMUSIC_CUSTOMFIELDS_ARTIST."</B></center>";
			CloseTable();
			echo "<br>";
			include_once("customFieldsArtist.php");
	    	break;
	    case "customFieldsAlbum":
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/AlbumAdminDAO.php");
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/CustomFieldAdminO.php");
	    	$albumDAO=new AlbumAdminDAO($db,$prefix);
			
			if($_POST['fieldaction']!=""){
				if($_POST['fieldaction']=="add"){
					$fieldname=$_POST['name'];
					$fieldname=str_replace(" ","",$fieldname);
					$fieldname=substr($fieldname,0,25);
					$customFieldO=new CustomFieldAdminO();
					$customFieldO->name=$fieldname;
					$customFieldO->description=$_POST['description'];
					$customFieldO->type=$_POST['type'];
					$albumDAO->addCustomField($customFieldO);
					$error=$db->sql_error();
					if($error['message']=="")
						$message=_TOPMUSIC_ADD_CUSTOMFIELD_SUCCESSFULLY;
					else
						$message=_TOPMUSIC_ADD_CUSTOMFIELD_ERROR.": ".$error['message'];
				}else{
					$albumDAO->delCustomField($_POST['idfield']);
					$error=$db->sql_error();
					if($error['message']=="")
						$message=_TOPMUSIC_DELETECUSTOMFIELD_SUCCESSFULLY;
					else
						$message=_TOPMUSIC_DELETECUSTOMFIELD_ERROR.": ".$error['message'];
				}
			}
			echo "<font color=\"red\">$message</font>";			
			$fieldsList=$albumDAO->getCustomFields();
			OpenTable();
			echo "<center><B>"._TOPMUSIC_CUSTOMFIELDS_ALBUM."</B></center>";
			CloseTable();
			echo "<br>";
			include_once("customFieldsAlbum.php");
	    	break;
	    case "customFieldsSong":
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/SongAdminDAO.php");
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/CustomFieldAdminO.php");
	    	$songDAO=new SongAdminDAO($db,$prefix);
			
			if($_POST['fieldaction']!=""){
				if($_POST['fieldaction']=="add"){
					$fieldname=$_POST['name'];
					$fieldname=str_replace(" ","",$fieldname);
					$fieldname=substr($fieldname,0,25);
					$customFieldO=new CustomFieldAdminO();
					$customFieldO->name=$fieldname;
					$customFieldO->description=$_POST['description'];
					$customFieldO->type=$_POST['type'];
					$songDAO->addCustomField($customFieldO);
					$error=$db->sql_error();
					if($error['message']=="")
						$message=_TOPMUSIC_ADD_CUSTOMFIELD_SUCCESSFULLY;
					else
						$message=_TOPMUSIC_ADD_CUSTOMFIELD_ERROR.": ".$error['message'];
				}else{
					$songDAO->delCustomField($_POST['idfield']);
					$error=$db->sql_error();
					if($error['message']=="")
						$message=_TOPMUSIC_DELETECUSTOMFIELD_SUCCESSFULLY;
					else
						$message=_TOPMUSIC_DELETECUSTOMFIELD_ERROR.": ".$error['message'];
				}
			}
			echo "<font color=\"red\">$message</font>";			
			$fieldsList=$songDAO->getCustomFields();
			OpenTable();
			echo "<center><B>"._TOPMUSIC_CUSTOMFIELDS_SONG."</B></center>";
			CloseTable();
			echo "<br>";
			include_once("customFieldsSong.php");
	    	break;
	    case "addCustomfield":
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/CustomFieldAdminO.php");
			if($_POST['act']=="add"){
				$fieldname=$_POST['name'];
				$fieldname=str_replace(" ","",$fieldname);
				$fieldname=substr($fieldname,0,25);
				$fieldO=new CustomFieldAdminO();
				$fieldO->name=$fieldname;
				$fieldO->description=$_POST['description'];
				$fieldO->type=$_POST['type'];
				$fieldO->file_path=$_POST['file_path'];
				$fieldO->file_icon=$_POST['file_icon'];
				$fieldO->image_width=$_POST['image_width'];
				$fieldO->select_values=$_POST['values'];
				switch($_POST['from']){
					case "Artist":
						require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/ArtistAdminDAO.php");
						$artistDAO=new ArtistAdminDAO($db,$prefix);
						$artistDAO->addCustomField($fieldO);
						break;
					case "Album":
						require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/AlbumAdminDAO.php");
						$albumDAO=new AlbumAdminDAO($db,$prefix);
						$albumDAO->addCustomField($fieldO);
						break;
					case "Song":
						require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/SongAdminDAO.php");
						$songDAO=new SongAdminDAO($db,$prefix);
						$songDAO->addCustomField($fieldO);
						break;
				}
				$error=$db->sql_error();
				if($error['message']=="")
						$message=_TOPMUSIC_ADD_CUSTOMFIELD_SUCCESSFULLY;
					else
						$message=_TOPMUSIC_ADD_CUSTOMFIELD_ERROR.": ".$error['message'];
			}

			echo "<font color=\"red\">$message</font>";			
			OpenTable();
			echo "<center><B>"._TOPMUSIC_ADD_CUSTOMFIELD."</B></center>";
			CloseTable();
			echo "<br>";
			include_once("addCustomField.php");
	    	break;
	    case "addArtistMusicMoz":
	    	if($_POST['act']=='insert'){
	    		
	    	}
	    	
	    	break;

 	
	    case "addChart":
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/ChartAdminDAO.php");
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/ChartAdminO.php");
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/view/ChartAdminView.php");
	    	$chartDAO=new ChartAdminDAO($db,$prefix);
			
	    	if($_POST['submit']!=""){
				if($_POST['title']!=""){
					$chartO->type=$_POST['type'];
					$chartO->title=$_POST['title'];
					$chartO->description=$_POST['description'];
					$chartO->number_elements=$_POST['number_elements'];
					$chartO->default=$_POST['default'];
					$chartDAO->newChart($chartO,$currentlang);
					$error=$db->sql_error();
					if($error['message']=="")
						$message="Chart created successfully";
					else
						$message="Error creating chart: ".$error['message'];
				}else{
					$message="Title is required";
				}
	    	}
			echo "<font color=\"red\">$message</font>";			
			$chartList=$chartDAO->getChartList($currentlang);
			OpenTable();
			echo "<center><B>"._TOPMUSIC_CHARTLIST."</B></center>";
			CloseTable();
			echo "<br>";
			include_once("listChart.php");
			OpenTable();
			echo "<center><B>"._TOPMUSIC_NEWCHART."</B></center>";
			CloseTable();
			echo "<br>";
			include_once("newChart.php");
	    	break;
	    
	    case "editChart":
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/ChartAdminDAO.php");
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/ChartAdminO.php");
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/ChartElementAdminO.php");
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/SongAdminO.php");
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/AlbumAdminO.php");
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/ArtistAdminO.php");
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/view/ChartAdminView.php");
	    	if($chartDAO==""){
	    		$chartDAO=new ChartAdminDAO($db,$prefix);
	    	}
	    	$chartO=$chartDAO->getChart($_GET['idchart'],$currentlang);
			//echo "<script type=\"text/javascript\" src=\"/modules/"._TOPMUSIC_MODULENAME."/admin/js/mootools.js\"></script>\n";
			echo "<script type=\"text/javascript\" src=\"modules/"._TOPMUSIC_MODULENAME."/themes/sergids/js/common.js\"></script>\n";
			OpenTable();
			echo "<center><B>"._TOPMUSIC_CHARTELEMENTSLIST."</B></center>";
			CloseTable();
			echo "<br>";
			ChartAdminView::printChart($chartO);
			ChartAdminView::printElements($chartO);
	    	break;
	    case "setDefaultChart":
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/ChartAdminDAO.php");
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/ChartAdminO.php");
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/view/ChartAdminView.php");
	    	$chartDAO=new ChartAdminDAO($db,$prefix);
	    	if(is_numeric($idchart)){
				$chartDAO->setDefault($idchart);
				$error=$db->sql_error();
				if($error['message']=="")
					$message="Chart set as default successfully";
				else
					$message="Error setting chart as default: ".$error['message'];
	    	}
			echo "<font color=\"red\">$message</font>";			
			$chartList=$chartDAO->getChartList($currentlang);
			OpenTable();
			echo "<center><B>"._TOPMUSIC_CHARTLIST."</B></center>";
			CloseTable();
			echo "<br>";
			include_once("listChart.php");
			OpenTable();
			echo "<center><B>"._TOPMUSIC_NEWCHART."</B></center>";
			CloseTable();
			echo "<br>";
			include_once("newChart.php");
	    	break;
	    case "delChart":
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/ChartAdminDAO.php");
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/model/ChartAdminO.php");
	    	require_once("modules/"._TOPMUSIC_MODULENAME."/admin/lib/com/sergids/topmusic/view/ChartAdminView.php");
	    	$chartDAO=new ChartAdminDAO($db,$prefix);
	    	if(is_numeric($idchart)){
				$chartDAO->delChart($idchart);
				$error=$db->sql_error();
				if($error['message']=="")
					$message="Chart deleted successfully";
				else
					$message="Error deleting chart: ".$error['message'];
	    	}
			echo "<font color=\"red\">$message</font>";			
			$chartList=$chartDAO->getChartList($currentlang);
			OpenTable();
			echo "<center><B>"._TOPMUSIC_CHARTLIST."</B></center>";
			CloseTable();
			echo "<br>";
			include_once("listChart.php");
			OpenTable();
			echo "<center><B>"._TOPMUSIC_NEWCHART."</B></center>";
			CloseTable();
			echo "<br>";
			include_once("newChart.php");
	    	break;
	}
	AdminTopView::printFoot();
	include("footer.php");

} else {
	include("header.php");
	if($configAdmin->getNukeMenu()=="1") {
		GraphicAdmin();
	}
	OpenTable();
	echo "<center><b>"._ERROR."</b><br><br>"._TOPMUSICADMINPERMISSION." "._TOPMUSIC_MODULENAME."</center>";
	CloseTable();
	include("footer.php");
}
?>
Return current item: Top Music module