<?php

#############################################################################
#           			                   Site@School
# Site@School is a website management system designed for primary schools.
#
# About Site@School:
# Comissioned by: City District 'de Baarsjes', Amsterdam, Netherlands
# Original idea, coding (version 1.0) and design : Mark de Haan (mark@starwave.nl)
# Ideas, improvements, expansions (version 1.1 - 2.3): Fred Stuurman 
# Current coder & maintainer: Fred Stuurman (fc.stuurman@hccnet.nl)
############################################################################
# replace.inc.php: last changed 14/01/2005  2.3
#                       by Fred Stuurman (fc.stuurman@hccnet.nl)
#$Id: replace.inc.php,v 1.1 2006/10/03 08:33:55 fstuurman Exp $
############################################################################
#                        LICENSE INFORMATION
# Copyright (C) 2002, 2003, 2004 Municipality of Amsterdam, City District
#  'de Baarsjes', Amsterdam, the Netherlands.
#
# This program 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.
#
# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
##############################################################################
if (!defined('IN_SAS'))
{
	die("Hacking attempt");
}
if (IsSet ($_POST['from']))
{
	$from = $_POST['from'];
}
if (IsSet ($_POST['to']))
{
	$to = $_POST['to'];
}
if (IsSet ($_GET['step']))
{
	$step = $_GET['step'];
}

include ("interface/header.inc.php");
include ("interface/menubar.inc.php");
include ("interface/menustart.inc.php");
include ("interface/menuend.inc.php");
include ("interface/pagestart.inc.php");

if (substr("$access", 13, 1) == "0") //bit 14 off the accessrights
{
	print "<span class=\"heading\">" . $sas_lang['noaccess'] . "<br></span>";
	print "<span class=\"text\">" . $sas_lang['noaccess_introduction'] . "</span><br><br><br>";
	include ("interface/pageend.inc.php");
	include ("interface/footer.inc.php");
	exit;
}

print "<span class=\"heading\">" . $sas_lang['replace_tool'] . "<p></span>";

if ($step == "go")
{
	mysql_query("UPDATE $table_pages SET content = REPLACE(content, '$from' , '$to') WHERE id > 0");
	$table_pages = $dbprefix . "prot_pages";
	mysql_query("UPDATE $table_pages SET content = REPLACE(content, '$from' , '$to') WHERE id > 0");
	$table_news = $dbprefix . "m_news_articles";
	mysql_query("UPDATE $table_news SET content = REPLACE(content, '$from' , '$to') WHERE id > 0");
	$table_newsletters = $dbprefix . "m_newsletters";
	mysql_query("UPDATE $table_newsletters SET content = REPLACE(content, '$from' , '$to') WHERE id > 0");

	print "<span class=\"text\"><p>" . $sas_lang['text'] . " <b>$from</b> " . $sas_lang['replaced_by'] . " <b>$to</b>.</span>";
	print "<p><input type=\"button\" value=\"&nbsp;&nbsp;&nbsp;" . $sas_lang['goback'] . "\" name=\"backbutton\" 
				onClick=\"javascript:parent.location='index.php?option=tools&suboption=replace';\" class=\"backbutton\">";

}
else
{
	print "<span class=\"text\">" . $sas_lang['replace_tool_intro'] . "<p></span>";
	print "<br><FORM METHOD=\"POST\" ACTION=\"index.php?option=tools&suboption=replace&step=go\">";
	print "<span class=\"text\">" . $sas_lang['replace_from'] . ":</span><br><input type=text size=45 class=\"textfield\" name=\"from\"><p>";
	print "<span class=\"text\">" . $sas_lang['replace_to'] . ":</span><br><input type=text size=45 class=\"textfield\" name=\"to\">";

	print "<p><input type=\"button\" value=\"&nbsp;&nbsp;&nbsp;" . $sas_lang['goback'] . "\" name=\"backbutton\" 
				onClick=\"javascript:parent.location='index.php?option=tools';\" class=\"backbutton\">";
	print "\n&nbsp;<input type=\"submit\" value=\"&nbsp;&nbsp;&nbsp;" . $sas_lang['save'] . "\" name=\"savebutton\" class=\"savebutton\">";
	print "</form>";
}

include ("interface/menuend.inc.php");
include ("interface/pagestart.inc.php");
?>
