2
// ><html><body><h1> Sorry, no php enabled, this won't work! </h1></body></html><!--
5
$top = 'ACL2____TOP'; // top topic
6
$notFound = 'DOCNOTFOUND'; // not found topic
7
$index = 'DOCINDEX'; // index page
9
$basedir=pathinfo($_SERVER["SCRIPT_NAME"],PATHINFO_DIRNAME)."/";
10
$scriptdir=$_SERVER["SCRIPT_NAME"].'/';
11
error_reporting(E_ALL);
12
ini_set('display_errors', 1);
14
class MyDB extends SQLite3
16
function __construct()
18
$this->open('xdata-seo.db');
23
echo $db->lastErrorMsg();
27
if(isset($_SERVER["PATH_INFO"]) && (strlen($_SERVER["PATH_INFO"])>1))
28
$key = pathinfo($_SERVER["PATH_INFO"],PATHINFO_BASENAME);
31
if($key=="*") {$showIndex=true;$key=$index;unset($_GET['path']);}
33
$ret = $db->query("SELECT * from xdoc_data where XKEY='".sqlite_escape_string($key)."'");
34
$page = $ret->fetchArray(SQLITE3_ASSOC);
36
if(!$page || $page['XKEY']!=$key){
37
header("HTTP/1.0 404 Not Found");
39
$ret = $db->query("SELECT * from xdoc_data where XKEY='".$key."'");
40
$page = $ret->fetchArray(SQLITE3_ASSOC);
43
$preferedURL=$scriptdir.$page['XKEY'];
44
header("Content-Location: ".$preferedURL);
47
if(!$page) { // fallback when not even the 404 page was found
48
header("Location: ".$scriptdir);
53
$lookup = array($page['ID']=>$page);
54
$lookupx = array($page['XKEY']=>$page);
55
if(isset($_GET['path'])) $path_idea = explode('/',$_GET['path']); else $path_idea = array();
56
$path_reversed=array();
58
$parents = explode(',',substr($cur['PARENTIDS'],1,-1));
59
while (count($parents)) {
60
$candidates = array_intersect($path_idea,$parents);
61
if(count($candidates)){ // found something (hopefully one)
62
$path_idea = array_diff($path_idea,$parents);
63
$nextID = array_pop($candidates);
65
$nextID = $parents[0]; // nothing found, pick first parent
67
if(isset($lookup[$nextID])){ // loop found! Abort
70
$ret = $db->query("SELECT * from xdoc_data where ID='".sqlite_escape_string($nextID)."'");
71
$cur = $ret->fetchArray(SQLITE3_ASSOC);
73
$lookup[$cur['ID']] = $cur;
74
$path_reversed[] = $cur['ID'];
75
$parents = explode(',',substr($cur['PARENTIDS'],1,-1));
76
}else $parents = array();
78
}; // while (count($parents));
80
foreach($path_reversed as $itm){
84
function lookup_by_id($id){
85
global $lookup, $lookupx, $db;
86
if(!isset($lookup[$id])){
87
$ret = $db->query("SELECT * from xdoc_data where ID='".sqlite_escape_string($id)."'");
88
$cur = $ret->fetchArray(SQLITE3_ASSOC);
89
$lookup[$cur['ID']] = $cur;
90
$lookupx[$cur['XKEY']] = $cur;
94
function lookup_by_xkey($xkey){
95
global $lookup, $lookupx, $db;
96
if(!isset($lookupx[$xkey])){
97
$ret = $db->query("SELECT * from xdoc_data where XKEY='".sqlite_escape_string($xkey)."'");
98
$cur = $ret->fetchArray(SQLITE3_ASSOC);
99
$lookup[$cur['ID']] = $cur;
100
$lookupx[$cur['XKEY']] = $cur;
102
return $lookupx[$xkey];
108
array('<see topic="' ,'</see>','<code>' ,'</code>')
109
,array('<a href="'.$scriptdir,'</a>' ,'<pre class="code">','</pre>')
116
if(isset($preferedURL)){ echo '<link rel="canonical" href="http://'.$_SERVER['SERVER_NAME'].$preferedURL.'" />'; }
118
<meta charset="UTF-8">
120
; Original author: Jared Davis <jared@centtech.com>
121
; PHP version by Sebastiaan Joosten
122
; Content by various authors
124
<title><?php echo($page['PACKAGE'] .' - '. $page['TITLE']); ?></title>
125
<link rel="stylesheet" type="text/css" href="<?= $basedir ?>style.css"/>
126
<link rel="shortcut icon" href="<?= $basedir ?>favicon.png"/>
132
<table border="0" id="toolbar">
135
<a href="<?= $scriptdir ?>ACL2____TOP">
136
<img class="toolbutton" src="<?= $basedir ?>xdoc-home.png"
137
data-powertip="<p>Go to the Top topic.</p>">
138
</a> </th><th>
139
<a href="<?= $scriptdir ?>*">
140
<img class="toolbutton" src="<?= $basedir ?>view_flat.png"
141
data-powertip="<p>View sitemap.</p>"/>
143
<a target="DownloadWindow" href="<?= $basedir ?>download/manual.zip">
144
<img class="rtoolbutton" src="<?= $basedir ?>download.png"
145
data-powertip="<p>Download a zipped copy of this manual (for
146
faster or offline browsing).</p>"/>
149
<td><label style="color:white">
150
Search-engine friendly clone of the <a href="http://www.cs.utexas.edu/users/moore/acl2/manuals/current/manual/" style="color:white;text-decoration:underline">ACL2 documentation</a>.
161
$cur = lookup_by_xkey($top);
162
$path_reversed[] = $page['ID'];
163
function show_rec($cur,$newpath){
164
global $path_reversed, $scriptdir;
165
echo '<LI style="list-style-type:';
166
if(strlen($cur['CHILDREN'])) echo 'disc'; else echo 'circle';
167
echo '"><nobr><A HREF="'.$scriptdir.$cur['XKEY'].'?path='.$newpath.'" title="'.htmlentities(strip_tags($cur['SHORTDESC'])).'">'.$cur['TITLE'].'</A></nobr>';
168
if(array_search($cur['ID'],$path_reversed)!==FALSE){
169
$children=explode(',',$cur['CHILDREN']);
170
if(count($children)){
172
for($i=1;$i<count($children);$i++){
173
$kid=lookup_by_xkey($children[$i]);
174
show_rec($kid,$newpath.'/'.$kid['ID']);
180
show_rec($cur,$cur['ID']);
187
$ps=explode(',',substr($page['PARENTIDS'],1,-1));
188
function ispos($x){return strlen($x)&&(-$x<1);}
189
$ps = array_filter($ps,"ispos");
194
$cur=lookup_by_id($id);
195
echo '<li><a id="'.$id.'" href="'.$scriptdir.$cur['XKEY'].'?path='.$path.'"';
196
echo ' title="'.htmlentities(strip_tags($cur['SHORTDESC'])).'">'.$cur['TITLE'].'</a></li>';
203
<H1><?php echo $page['TITLE']; ?></H1>
204
<P align="center"><?php
205
disp($page['SHORTDESC']);
208
disp($page['LONGDESC']);
211
$ret = $db->query("SELECT XKEY,TITLE,SHORTDESC,PACKAGE from xdoc_data ORDER BY TITLE");
212
while($cur=$ret->fetchArray(SQLITE3_ASSOC)){
213
if(strlen($cur['PACKAGE'])){
214
echo '<LI><a href="'.$scriptdir.$cur['XKEY'].'" title="'.htmlentities(strip_tags($cur['SHORTDESC'])).'">';
221
if(strlen($page['CHILDREN'])){
225
$childs = explode(',',$page['CHILDREN']);
226
for($i=1;$i<count($childs);$i++){
227
$cur = lookup_by_xkey($childs[$i]);
228
echo '<DT><a href="'.$scriptdir.$cur['XKEY'].'?path='.$path.'">';
230
echo '</a></dt><dd>';
231
disp($cur['SHORTDESC']);
b'\\ No newline at end of file'