fix doc directory reading bug

This commit is contained in:
John Bintz 2009-11-19 21:48:15 -05:00
parent d8b6c0f859
commit b25f03389b
1 changed files with 11 additions and 9 deletions

View File

@ -171,18 +171,20 @@ class ComicPressAdmin {
$all_docs = array(); $all_docs = array();
if (($dh = opendir($path)) !== false) { if (($dh = opendir($path)) !== false) {
while (($file = readdir($dh)) !== false) { while (($file = readdir($dh)) !== false) {
$content = file($path . '/' . $file); if (is_file($path . '/' . $file)) {
$title = false; $content = file($path . '/' . $file);
foreach ($content as $line) { $title = false;
if (preg_match('#<h1>(.*)</h1>#', $line, $matches) > 0) { foreach ($content as $line) {
list($all, $title) = $matches; if (preg_match('#<h1>(.*)</h1>#', $line, $matches) > 0) {
list($all, $title) = $matches;
$id = preg_replace('#[^a-z0-9]+#', '_', strtolower($title)); $id = preg_replace('#[^a-z0-9]+#', '_', strtolower($title));
$content = implode('', $content); $content = implode('', $content);
$content = str_replace('src="', 'src="' . plugin_dir_url($path . '/' . $file), $content); $content = str_replace('src="', 'src="' . plugin_dir_url($path . '/' . $file), $content);
$all_docs[$id] = compact('title', 'content'); $all_docs[$id] = compact('title', 'content');
}
} }
} }
} }