<?php
////////////////////////////////////////////////////////////////////////
// Breeze Website Builder
// Copyright Silver Dolphin Solutions, LLC, Edward Lemmers, P.E.
// For licensing, see license.txt.
// Created: 10/12/2010	ELL
// Revised: 2/8/2012	ELL
// Added references to website files, images, CSS, scripts, media and Flash folder configurations.
// 
	
	include ("check_session.php");
	
	if (BWB_BASE_DIR == '')
		$userfiles_path = '';
	else
		$userfiles_path = "/" . BWB_BASE_DIR;
		
	if (BWB_WEBPAGE_DIR == '')
		$website_path = $userfiles_path;
	else
		$website_path = $userfiles_path . "/" . BWB_WEBPAGE_DIR;

	$path = ".." . $website_path . "/";
	if ($handle = opendir($path))
	{
		while (false !== ($file = readdir($handle)))
		{
//			echo "file: $file<br>\n";
//			echo strpos($file, "sitemap.xml");
//			echo "<br>\n";
			if (!(strpos($file, "sitemap.xml") === false) && (strlen($file) > 20))
			{
				$file_path = $path . $file;
				unlink($file_path);
//				echo "file_path: $file_path<br>\n";
			}
		}
		closedir($handle);
	}
	
	$path = ".." . $userfiles_path . "/" . BWB_CSS_DIR . "/";
	if ($handle = opendir($path)) 
	{
		while (false !== ($file = readdir($handle)))
		{
			if ((!(strpos($file, "calendar.css") === false) || !(strpos($file, "mail_form.css") === false) || !(strpos($file, "menu.css") === false) || !(strpos($file, "menu1.css") === false) || !(strpos($file, "menu2.css") === false) || !(strpos($file, "menu3.css") === false) || !(strpos($file, "menu4.css") === false) || !(strpos($file, "site.css") === false) || !(strpos($file, "site_preview.css") === false)) && (strlen($file) > 17))
			{
				$file_path = $path . $file;
				unlink($file_path);
			}
		}
		closedir($handle);
	}
	
	$path = ".." . $userfiles_path . "/" . BWB_SCRIPTS_DIR . "/";
	if ($handle = opendir($path)) 
	{
		while (false !== ($file = readdir($handle)))
		{
			if ((!(strpos($file, "menu_items.js") === false) || !(strpos($file, "menu_tpl.js") === false)) && (strlen($file) > 20))
			{
				$file_path = $path . $file;
				unlink($file_path);
			}
		}
		closedir($handle);
	}
	
	header("Location: admin_function_select.php?display_pruned_bkup_files_msg=1");
?>
