1<?php
2$replaceContent = file_get_contents('box.tpl');
3filesInDir('../data/pages');
4function filesInDir($tdir)
5{
6	$dirs = scandir($tdir);
7	foreach($dirs as $file)
8	{
9		if (($file == '.')||($file == '..'))
10		{
11		}
12		elseif (is_dir($tdir.'/'.$file))
13		{
14			filesInDir($tdir.'/'.$file);
15		}
16		else
17		{
18			//echo $tdir.'/'.$file."<br>";
19			clean($tdir.'/'.$file);
20		}
21	}
22}
23
24function clean($file)
25{
26	global $replaceContent;
27	//echo $file."<br>";
28	$fileContent = file_get_contents($file);
29	//preg_match_all('(\<box.*\>[^\r\n].*\</box\>)', $fileContent, $regs);
30	$result = ereg_replace('(\<box.*\>[^.*]*.*\</box\>)','', $fileContent);
31	//print_r($result);
32
33	//echo $file."<br>";
34	//$newContent = str_replace($replaceContent, '', $fileContent);
35	//echo $newContent;
36	$handle = fopen($file, 'w');
37	fwrite($handle, $result);
38	fclose($handle);
39
40}
41?>
42