Skip to content
This repository was archived by the owner on Apr 21, 2026. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions gen-phpweb-sqlite-db.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -81,7 +81,7 @@ function scan($dir, $lang)
'control-structures.', 'language.',
'about.', 'faq.', 'features.',
);

$count = 0;
echo "Lang: $lang\n";

Expand DownExpand Up@@ -115,7 +115,7 @@ function scan($dir, $lang)
if ($x !== false) {
$keyword = substr($keyword, 0, $x);
}

// Skip PHP 4 domxml (book.domxml). It uses function. syntax, unlike book.dom
if (0 === strpos($keyword, 'function.dom') && false === strpos($keyword, 'simplexml')) {
continue;
Expand DownExpand Up@@ -164,9 +164,33 @@ function scan($dir, $lang)
$dbh->exec("INSERT INTO fs (lang, prefix, keyword, name, prio) values ('$lang', '$prefix', '" . metaphone($keyword) . "', '$doc_rel', ".($prio+10).")");

}

if ($f === 'reserved.keywords.php' && $handle = fopen($file, 'r')) {
// Yes, this is fragile.
$stm = $dbh->prepare('INSERT INTO fs (lang, prefix, keyword, name, prio) VALUES (?, ?, ?, ?, ?)');
$path_base = dirname($doc_rel);
while ($stm && false !== ($line = fgets($handle))) {
if (strpos($line, '<a href=') === false) {
continue;
}

if (!preg_match('!<a href="([^"]+)" class="[^"]+">([^<]+)</a>!', $line, $matches)) {
continue;
}

$keyword = strtolower(rtrim($matches[2], '()'));
$href = $matches[1];

if ($x = strpos($href, '#')) {
$href = substr($href, 0, $x);
}

$stm->execute([$lang, $prefix ?? '', $keyword, $path_base . '/' . $href, $prio ?? 200]);
}
}
}
closedir($d);

echo "Added entries for $count files\n";
echo "\n";
}
Expand DownExpand Up@@ -195,4 +219,3 @@ function scan_langs($root)
}
closedir($d);
}