<?php
/////////////////////////////////////////////
// Delete Favicon /////
////////////////////////////////////////////////////////////////////////
// Breeze Website Builder
// Copyright Silver Dolphin Solutions, LLC, 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("Y-m-d H:m:s"));
	
	if (BWB_BASE_DIR == '')
		$userfiles = '';
	else
		$userfiles = "/" . BWB_BASE_DIR;
		
	if (BWB_WEBPAGE_DIR == '')
		$rel_path = '';
	else
		$rel_path = "../";
		
	$query = "SELECT * FROM " . BWB_TABLE_PREFIX . "head";
	$result = $bwb_dbh->query($query);
	while ($row = $result->fetch(PDO::FETCH_ASSOC))
	{
		$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='" . $rel_path . BWB_IMAGE_DIR . "/favicon.ico' type='image/x-icon'>", " ", $head_content);
			$head_content = addslashes($head_content);
			$query2 = "UPDATE `" . BWB_TABLE_PREFIX . "head` SET `head_content` = '" . $head_content . "', `revised` = '" . $today . "' WHERE `id` = '" . $id . "'";
			$cnt = $bwb_dbh->exec($query2);
		}
	}
	
	$document_root = getenv('DOCUMENT_ROOT');
	$favicon = $document_root . $userfiles . "/" . BWB_IMAGE_DIR . "/favicon.ico";

	if (file_exists($favicon))
		unlink($favicon);

	header("Location: edit_favicon.php");
	
?>
