summaryrefslogtreecommitdiff
path: root/lib/exe/indexer.php
diff options
context:
space:
mode:
authorhfuecks <hfuecks@gmail.com>2005-10-06 15:06:51 +0200
committerhfuecks <hfuecks@gmail.com>2005-10-06 15:06:51 +0200
commitc73c757e0e421668521e2e4d146aa0f9acac4057 (patch)
tree841d934772e4de763c3da875bb6f9bbeec883ffc /lib/exe/indexer.php
parent6e026dfa35b6d1e5beded6604491c9a8a9093f98 (diff)
downloadrpg-c73c757e0e421668521e2e4d146aa0f9acac4057.tar.gz
rpg-c73c757e0e421668521e2e4d146aa0f9acac4057.tar.bz2
indexer_patch_flush_image
darcs-hash:20051006130651-e96b6-6496b235c56a40cdea06df6198a5d39e5bfa9d13.gz
Diffstat (limited to 'lib/exe/indexer.php')
-rw-r--r--lib/exe/indexer.php59
1 files changed, 43 insertions, 16 deletions
diff --git a/lib/exe/indexer.php b/lib/exe/indexer.php
index 451ba97ca..74f0b3924 100644
--- a/lib/exe/indexer.php
+++ b/lib/exe/indexer.php
@@ -6,6 +6,42 @@
* @author Andreas Gohr <andi@splitbrain.org>
*/
+/**
+ * Just send a 1x1 pixel blank gif to the browser and exit
+
+ */
+function sendGIF(){
+ $img = base64_decode('R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAEALAAAAAABAAEAAAIBTAA7');
+ header('Content-Type: image/gif');
+ header('Content-Length: '.strlen($img));
+ header('Connection: Close');
+ print $img;
+ // Browser should drop connection after this
+ // Thinks it's got the whole image
+}
+
+// Make sure image is sent to the browser immediately
+ob_implicit_flush(TRUE);
+
+// keep running after browser closes connection
+@ignore_user_abort(true);
+
+sendGIF();
+
+// Switch off implicit flush again - we don't want to send any more output
+ob_implicit_flush(FALSE);
+
+// Catch any possible output (e.g. errors)
+// - probably not needed but better safe...
+ob_start();
+
+// Called to exit - we don't want any output going anywhere
+function indexer_stop() {
+ ob_end_clean();
+ exit();
+}
+
+// Now start work
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
require_once(DOKU_INC.'inc/init.php');
require_once(DOKU_INC.'inc/indexer.php');
@@ -14,14 +50,12 @@ session_write_close();
$ID = cleanID($_REQUEST['id']);
-if(!$ID) sendGIF();
+if(!$ID) indexer_stop();
// check if indexing needed
$last = @filemtime(metaFN($ID,'.indexed'));
-if($last > @filemtime(wikiFN($ID))) sendGIF();
+if($last > @filemtime(wikiFN($ID))) indexer_stop();
-// keep running
-@ignore_user_abort(true);
// try to aquire a lock
$lock = $conf['lockdir'].'/_indexer.lock';
@@ -30,7 +64,7 @@ while(!@mkdir($lock,0777)){
// looks like a stale lock - remove it
@rmdir($lock);
}else{
- sendGIF();
+ indexer_stop();
}
}
@@ -40,16 +74,9 @@ idx_addPage($ID);
// we're finished
io_saveFile(metaFN($ID,'.indexed'),'');
@rmdir($lock);
-sendGIF();
-
-/**
- * Just send a 1x1 pixel blank gif to the browser and exit
- */
-function sendGIF(){
- header('Content-Type: image/gif');
- print base64_decode('R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAEALAAAAAABAAEAAAIBTAA7');
- exit;
-}
+indexer_stop();
//Setup VIM: ex: et ts=4 enc=utf-8 :
-?>
+
+// No trailing PHP closing tag - no output please!
+// See Note at http://www.php.net/manual/en/language.basic-syntax.instruction-separation.php \ No newline at end of file