<?php
/////////////////////////////////////////////
// Delete Favicon /////
////////////////////////////////////////////////////////////////////////
// Breeze Website Builder
// Copyright EB Dynamics, Inc., Edward Lemmers, P.E.
// For licensing, see license.txt.
// Created: 11/13/2009	ELL
// Revised: 2/8/2012	ELL
// Added table prefix handling. Added reference to images folder constant.
// 
//
	include ("check_session.php");
		
	$today = addslashes(date("m/d/Y  H:m:s"));
		
	$query = "SELECT * FROM " . BWB_TABLE_PREFIX . "head";
	$result = mysql_query($query, $bwb_link);
	while ($row = mysql_fetch_array($result))
	{
		$id = $row["id"];
		$head_content = $row["head_content"];
		$pos = strrpos($head_content, "favicon.ico");
		if ($pos !== false)
		{
			$head_content = str_replace("<link rel='shortcut icon' href='../" . BWB_IMAGE_DIR . "/favicon.ico' type='image/x-icon'>", "", $head_content);
			$query2 = "UPDATE " . BWB_TABLE_PREFIX . "head SET head_content = '" . $head_content . "', revised='" . $today . "' WHERE id = " . $id;
			$result2 = mysql_query($query2, $bwb_link);
		}
	}
	
	if (BWB_BASE_DIR == "")
		$favicon = getenv('DOCUMENT_ROOT') . "/" . BWB_IMAGE_DIR ."/favicon.ico";
	else
		$favicon = getenv('DOCUMENT_ROOT') . "/" . BWB_BASE_DIR . "/" . BWB_IMAGE_DIR . "/favicon.ico";
		
	if (file_exists($favicon))
		unlink($favicon);
		
	header("Location: edit_favicon.php");
	
?>
