'; echo ''; echo ''; echo ''; include('footer.php'); } $filename = $dir.'/'.rawurlencode($_POST['filename']); $lines = explode("\n", file_get_contents($filename)); $reporters = array(); $reporter = ''; $cite = ''; foreach ($lines as $line) { preg_match('/^(\**) +(.*)/', $line, $matches); $base = $matches[1]; $content = $matches[2]; switch ($base) { case '*': break; case '**': $reporter = $content; $reporters[$reporter] = array(); break; case '***': $cite = $content; break; case '': $reporters[$reporter][] = array('cite'=>$cite, 'text'=>$content); break; } } if (!isset($_POST['q'])) { include('header.php'); echo '
'; echo ''; echo ''; $i = 0; foreach ($reporters as $name => $quotes) { if (count($quotes)>1) { echo '
'; echo ''.$name.''; echo ''; echo '
'; } echo ''; echo '
'; include('footer.php'); } else { header('Content-type: text/plain; charset=utf-8'); $quotes = array(); foreach ($_POST['q'] as $reporter => $quote_id) { $quote = $reporters[$reporter][$quote_id]; $quote['reporter'] = $reporter; $quotes[] = $quote; } echo htmlentities($_POST['open']); echo "\n\n"; $reporter_names = array(); foreach ($quotes as $quote) { $reporter_names[] = $quote['reporter']; echo "
"; echo $quote['text']; echo "
\n"; } $last_reporter = array_pop($reporter_names); echo "\nQuotes gathered by ".(count($reporter_names)>0?implode(', ', $reporter_names).' and ':'').$last_reporter.'.'; }