<?php

/***************************************************************************

 m_sitesdel.php
 ---------------
 copyright : (C) 2002-2003 The ezContents Development Team

 ***************************************************************************/

/***************************************************************************
 The ezContents Development Team offers no warranties on this script.
 The owner/licensee of the script is solely responsible for any problems
 caused by installation of the script or use of the script.
 All copyright notices regarding ezContents must remain intact on the

 scripts and in the HTML for the scripts.

 For more info on ezContents,
 visit http://www.ezcontents.org/

/***************************************************************************

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the License which can be found within the
 *   zipped package.
 *
 ***************************************************************************/

include_once ("rootdatapath.php");
require_once ($GLOBALS["rootdp"]."include/config.php");
require_once ($GLOBALS["rootdp"]."include/db.php");
require_once ($GLOBALS["rootdp"]."include/session.php");
include ($GLOBALS["rootdp"]."include/access.php");
include ($GLOBALS["rootdp"]."include/functions.php");

$GLOBALS["form"] = 'sites';
$validaccess = VerifyAdminLogin();


if ($GLOBALS["candelete"] == False)
{
   Header("Location: ".BuildLink('adminlogin.php'));
}
else
{
   DeleteSite();
   Header("Location: ".BuildLink('m_sites.php')."&page=".$HTTP_GET_VARS["page"]."&sort=".$HTTP_GET_VARS["sort"]);
}


function DeleteSite()
{
   global $HTTP_GET_VARS;

   $sqlString = "DROP TABLE ".$HTTP_GET_VARS["SiteCode"]."ratings";
   $result = dbExecute($sqlString,true);

   $sqlString = "DROP TABLE ".$HTTP_GET_VARS["SiteCode"]."contents";
   $result = dbExecute($sqlString,true);

   $sqlString = "DROP TABLE ".$HTTP_GET_VARS["SiteCode"]."subgroups";
   $result = dbExecute($sqlString,true);

   $sqlString = "DROP TABLE ".$HTTP_GET_VARS["SiteCode"]."groups";
   $result = dbExecute($sqlString,true);

   $sqlString = "DROP TABLE ".$HTTP_GET_VARS["SiteCode"]."topgroups";
   $result = dbExecute($sqlString,true);

   $sqlString = "DROP TABLE ".$HTTP_GET_VARS["SiteCode"]."banners";
   $result = dbExecute($sqlString,true);

   $sqlString = "SELECT * FROM ".$GLOBALS["eztbSpecialcontents"];
   $lresult = dbRetrieve($sqlString,true,0,0);
   while ($rs = dbFetch($lresult))
   {
      $tablename = $HTTP_GET_VARS["SiteCode"].$rs["scdb"];
      $sqlString = "DROP TABLE ".$tablename;
      $result = dbExecute($sqlString,true);

      $tablename = $HTTP_GET_VARS["SiteCode"].$rs["scdb"].'categories';
      $sqlString = "DROP TABLE ".$tablename;
      $result = dbExecute($sqlString,true);
   }
   dbFreeResult($lresult);

   $sqlString = "DROP TABLE ".$HTTP_GET_VARS["SiteCode"]."specialcontents";
   $result = dbExecute($sqlString,true);

   $sqlString = "DROP TABLE ".$HTTP_GET_VARS["SiteCode"]."themes";
   $result = dbExecute($sqlString,true);

   $sqlString = "DROP TABLE ".$HTTP_GET_VARS["SiteCode"]."userdata";
   $result = dbExecute($sqlString,true);

   $sqlString = "DROP TABLE ".$HTTP_GET_VARS["SiteCode"]."authors";
   $result = dbExecute($sqlString,false);

   $sqlString = "DROP TABLE ".$HTTP_GET_VARS["SiteCode"]."settings";
   $result = dbExecute($sqlString,true);

   $strQuery = "DELETE FROM ".$GLOBALS["eztbSites"]." WHERE sitecode='".$HTTP_GET_VARS["SiteCode"]."'";
   $result = dbExecute($strQuery,true);
   dbCommit();
} // function DeleteTag()

?>
