Location: PHPKode > scripts > 2BGal > 2bgal/admin/suppr_album.inc.php
<?php
// Copyright 2003 Benjamin Py [www.ben3w.com] 

// This file is part of 2BGAL
// 2BGAL 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, or
// (at your option) any later version.
// 2BGAL is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with 2BGAL ; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

//securite #1 : pas d'appel direct du fichier
if (!defined('STAYONINCLUDE')) {exit;}
stayoninclude();

//recuperation des variables
if (isset($_GET["id_album"])) {$id_album=$_GET["id_album"];} else {$id_album=0;}

//securite #2 : type des variables
if (!ereg("^([0-9]+)$",$id_album,$secereg)) {$id_album=0;}

//inclusion langue
$lang_filename = "lang/".$lang."/suppr_album.inc.php";
require($lang_filename);

//action demandee
//------------------------------------------------------------
//supprimer un album  
if ($admaction == "supprimer")
{ 
	echo "<p class=\"actiontitlebar\">".$txt_titreaction."</p>\n";
	echo $txt_etfils."<br />";
	echo "<br /><img src=\"actionok.png\" alt=\"\" /><a href=\"index.php?admaction=supprimerconfirme&amp;id_album=".$id_album."\">".$txt_valider."</a>";
	echo "<br /><br /><img src=\"actionko.png\" alt=\"\" /><a href=\"index.php\">".$txt_annuler."</a><br />";
}

if ($admaction == "supprimerconfirme")
{
	echo "<p class=\"actionresult\">\n";
	function deleterec($ident,$table_ilist,$table_alist)
	{
		GLOBAL $txt_imgcons;
		GLOBAL $txt_supprokdb;
		$chaine="SELECT id,folder FROM ".$table_alist." WHERE idpere=".$ident;
		//echo $chaine;
		$result_query2 = mysql_query($chaine);
		$nb_fils = MYSQL_NUMROWS($result_query2);
		 $i=0;
		while ($i<$nb_fils)
		{
			$id_albumfils = mysql_result($result_query2,$i,"id");
			$folderfils = mysql_result($result_query2,$i,"folder");
			deleterec($id_albumfils,$table_ilist,$table_alist);
			$i++;
		}
		$chaine="SELECT folder,gere FROM ".$table_alist." WHERE id=".$ident;
		$result_query3 = mysql_query($chaine);
		$oldfolder = mysql_result($result_query3,0,"folder");
		$oldgere = mysql_result($result_query3,0,"gere");
		$chaine="DELETE FROM ".$table_alist." WHERE id=".$ident;
		//echo $chaine."<br />\n";
		$result_query = mysql_query($chaine);
		$chaine="DELETE FROM ".$table_ilist." WHERE album=".$ident;
		//echo $chaine."<br />\n";
		$result_query = mysql_query($chaine);
		echo "<img src=\"actionok.png\" alt=\"\" />".$txt_supprokdb." $ident<br />\n";
		if ($oldgere=='standalone') echo "<img src=\"actionwarning.png\" alt=\"\" />".$txt_imgcons." img/$oldfolder<br /><br />\n";
	}

	//BD seulement
	$chaine="SELECT id FROM $tbl_alist WHERE id=".$id_album;
	$request = MYSQL_QUERY($chaine);
	$nb_album = MYSQL_NUMROWS($request);
	if ($nb_album>0)
	{
		//supprimer l'album pere
		deleterec($id_album,$tbl_ilist,$tbl_alist);
	}

	echo "</p>\n";
	$admaction="";
	include("default.inc.php");
}
?>
Return current item: 2BGal