2 include("t_config.php");
6 <title>XT: cache static files' text into database</title>
7 <link rel="stylesheet" type="text/css" href="t_config.css">
9 <body bgcolor="#ffffff" text="#000000">
10 <h1>cache static files</h1>
15 if ($_REQUEST["go"]) {
17 $dir = $_REQUEST["dir"];
18 $prefix = $_REQUEST["prefix"];
19 $glob = $_REQUEST["glob"];
23 foreach ($ls as $fn) if (fnmatch($glob, $fn)) {
26 #-- checking for entry
27 if ($data = ewiki_db::GET($id)) {
28 // our cache entries don't have any flag set
29 if ($data["flags"] & EWIKI_DB_F_TYPE) {
30 continue; // real page exists, definetely won't overwrite
35 $content = file_get_contents("$dir/$fn");
36 $data = ewiki_db::CREATE($id, 0x000);
37 $data["content"] = $content;
38 $data["meta"]["class"] = "search";
41 ewiki_db::WRITE($id, "_OVERWRITE=1");
45 #-- returns only filenames (no dirs) with leading dirspec omitted
46 function scan_dir($dir, $pfix="") {
49 while ($fn = readdir($dh)) {
50 if (is_dir("$dir/$pfix$fn")) {
51 $r += scan_dir($dir, "$pfix$fn/");
66 This tool is useful if 'yoursite.php' loads from static files and from the Wiki
67 database concurrently and the URLs are therefore similar enough to warrant
68 caching of static .html files into the database to use the unified search
70 This is the case if you use <b>mod_rewrite</b> and have URLs like
71 <tt>http://example.org/WikiPage</tt> and <tt>http://example.org/otherpage.html</tt>
72 and both get displayed by your index.php script depending on if such a static page
73 exists. In this case EWIKI_SCRIPT is most always set to "/".
76 Else don't use this tool, it would generate silly database entries then
80 <form action="xt_searchcache_staticf.php" method="POST">
81 directory <input type="text" name="dir" value="./static/"><br>
82 (we're currently in "<?php echo getcwd(); ?>")
84 maps to <input type="text" name="prefix" value="static/"><br>
85 (don't forget that EWIKI_SCRIPT is also prepended to this)
87 file types <input type="text" name="glob" value="*.htm*"><br>
88 (unix filename globbing!)
90 <input type="submit" value="Generate" name="go">