<?php
/*
phpCookBook index file
http://phpcookbook.sourceforge.net
Copyright (c)2002 Floris Barthel <hide@address.com>
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
included LICENCE file for more details.
*/
//Header file
include_once('includes/inc.header.php');
global $iniSettings, $parser;
$dp = opendir($iniSettings['xml']['directory']);
while($file = readdir($dp))
{
if($file != '..' && $file != '.' && $file != 'default.dtd') {
$lines = file($iniSettings['xml']['directory'] . '/' . $file);
$name = preg_match("/name=\"(.+?)\"/i", $lines[2], $matches);
$x = explode('.', $file);
$files[] = array('file' => 'view.php?' . $x[0], 'title' => $matches[1]);
}
}
$lines = file('templates/index-template.htm');
$lines = implode('', $lines);
$x = explode('<LOOP recipies>', $lines);
$y = explode('</LOOP recipies>', $x[1]);
$x = explode('<recipe>', $y[0]);
$loop_temp = $x[1] . $x[0] . '<recipe>';
$loop = 1;
$count = count($files);
foreach($files as $v)
{
if($count != $loop)
$lines = str_replace('<recipe>', '<a href="' . $v['file'] . '">' . $v['title'] . '</a>' . $loop_temp, $lines);
elseif($count == $loop)
$lines = str_replace('<recipe>', '<a href="' . $v['file'] . '">' . $v['title'] . '</a>', $lines);
$loop++;
}
print($lines);
?>